diff --git a/public/iframe/for-plotly.html b/public/iframe/for-plotly.html new file mode 100644 index 0000000..ac923db --- /dev/null +++ b/public/iframe/for-plotly.html @@ -0,0 +1,32 @@ + + + +
+ + +Note that the boolean return here does not work like the
+ * {@code delete} operator. The {@code delete} operator returns
+ * whether the deletion succeeds at bringing about a state in
+ * which the deleted property is absent. The {@code delete}
+ * operator therefore returns true if the property was already
+ * absent, whereas this {@code delete} method returns false if
+ * the association was already absent.
+ */
+ value: function remove(key) {
+ return this.delete___(key);
+ },
+ writable: true,
+ configurable: true
+ }
+ });
+ if (typeof HostWeakMap === "function") {
+ (function() {
+ if (doubleWeakMapCheckSilentFailure && typeof Proxy !== "undefined") {
+ Proxy = void 0;
+ }
+ function DoubleWeakMap() {
+ if (!(this instanceof OurWeakMap)) {
+ calledAsFunctionWarning();
+ }
+ var hmap = new HostWeakMap();
+ var omap = void 0;
+ var enableSwitching = false;
+ function dget(key, opt_default) {
+ if (omap) {
+ return hmap.has(key) ? hmap.get(key) : omap.get___(key, opt_default);
+ } else {
+ return hmap.get(key, opt_default);
+ }
+ }
+ function dhas(key) {
+ return hmap.has(key) || (omap ? omap.has___(key) : false);
+ }
+ var dset;
+ if (doubleWeakMapCheckSilentFailure) {
+ dset = function(key, value) {
+ hmap.set(key, value);
+ if (!hmap.has(key)) {
+ if (!omap) {
+ omap = new OurWeakMap();
+ }
+ omap.set(key, value);
+ }
+ return this;
+ };
+ } else {
+ dset = function(key, value) {
+ if (enableSwitching) {
+ try {
+ hmap.set(key, value);
+ } catch (e) {
+ if (!omap) {
+ omap = new OurWeakMap();
+ }
+ omap.set___(key, value);
+ }
+ } else {
+ hmap.set(key, value);
+ }
+ return this;
+ };
+ }
+ function ddelete(key) {
+ var result = !!hmap["delete"](key);
+ if (omap) {
+ return omap.delete___(key) || result;
+ }
+ return result;
+ }
+ return Object.create(OurWeakMap.prototype, {
+ get___: { value: constFunc(dget) },
+ has___: { value: constFunc(dhas) },
+ set___: { value: constFunc(dset) },
+ delete___: { value: constFunc(ddelete) },
+ permitHostObjects___: { value: constFunc(function(token) {
+ if (token === weakMapPermitHostObjects) {
+ enableSwitching = true;
+ } else {
+ throw new Error("bogus call to permitHostObjects___");
+ }
+ }) }
+ });
+ }
+ DoubleWeakMap.prototype = OurWeakMap.prototype;
+ module2.exports = DoubleWeakMap;
+ Object.defineProperty(WeakMap.prototype, "constructor", {
+ value: WeakMap,
+ enumerable: false,
+ // as default .constructor is
+ configurable: true,
+ writable: true
+ });
+ })();
+ } else {
+ if (typeof Proxy !== "undefined") {
+ Proxy = void 0;
+ }
+ module2.exports = OurWeakMap;
+ }
+ })();
+ }
+ ),
+ /***/
+ 236: (
+ /***/
+ function(module2, __unused_webpack_exports, __webpack_require__2) {
+ var hiddenStore = __webpack_require__2(8284);
+ module2.exports = createStore;
+ function createStore() {
+ var key = {};
+ return function(obj) {
+ if ((typeof obj !== "object" || obj === null) && typeof obj !== "function") {
+ throw new Error("Weakmap-shim: Key must be object");
+ }
+ var store = obj.valueOf(key);
+ return store && store.identity === key ? store : hiddenStore(obj, key);
+ };
+ }
+ }
+ ),
+ /***/
+ 8284: (
+ /***/
+ function(module2) {
+ module2.exports = hiddenStore;
+ function hiddenStore(obj, key) {
+ var store = { identity: key };
+ var valueOf = obj.valueOf;
+ Object.defineProperty(obj, "valueOf", {
+ value: function(value) {
+ return value !== key ? valueOf.apply(this, arguments) : store;
+ },
+ writable: true
+ });
+ return store;
+ }
+ }
+ ),
+ /***/
+ 606: (
+ /***/
+ function(module2, __unused_webpack_exports, __webpack_require__2) {
+ var createStore = __webpack_require__2(236);
+ module2.exports = weakMap;
+ function weakMap() {
+ var privates = createStore();
+ return {
+ "get": function(key, fallback) {
+ var store = privates(key);
+ return store.hasOwnProperty("value") ? store.value : fallback;
+ },
+ "set": function(key, value) {
+ privates(key).value = value;
+ return this;
+ },
+ "has": function(key) {
+ return "value" in privates(key);
+ },
+ "delete": function(key) {
+ return delete privates(key).value;
+ }
+ };
+ }
+ }
+ ),
+ /***/
+ 3349: (
+ /***/
+ function(module2) {
+ "use strict";
+ function CWiseOp() {
+ return function(SS, a0, t02, p0, Y0, Y1) {
+ var s0 = SS[0], t0p0 = t02[0], index = [0], q0 = t0p0;
+ p0 |= 0;
+ var i0 = 0, d0s0 = t0p0;
+ for (i0 = 0; i0 < s0; ++i0) {
+ {
+ var da = a0[p0] - Y1;
+ var db = a0[p0 + q0] - Y1;
+ if (da >= 0 !== db >= 0) {
+ Y0.push(index[0] + 0.5 + 0.5 * (da + db) / (da - db));
+ }
+ }
+ p0 += d0s0;
+ ++index[0];
+ }
+ };
+ }
+ function generateCWiseOp() {
+ return CWiseOp();
+ }
+ var compile = generateCWiseOp;
+ function thunk(compile2) {
+ var CACHED = {};
+ return function zeroCrossings_cwise_thunk(array0, scalar2, scalar3) {
+ var t02 = array0.dtype, r0 = array0.order, type = [t02, r0.join()].join(), proc = CACHED[type];
+ if (!proc) {
+ CACHED[type] = proc = compile2([t02, r0]);
+ }
+ return proc(array0.shape.slice(0), array0.data, array0.stride, array0.offset | 0, scalar2, scalar3);
+ };
+ }
+ function createThunk(proc) {
+ return thunk(compile.bind(void 0, proc));
+ }
+ function compileCwise(user_args) {
+ return createThunk({
+ funcName: user_args.funcName
+ });
+ }
+ module2.exports = compileCwise({
+ funcName: "zeroCrossings"
+ });
+ }
+ ),
+ /***/
+ 781: (
+ /***/
+ function(module2, __unused_webpack_exports, __webpack_require__2) {
+ "use strict";
+ module2.exports = findZeroCrossings;
+ var core = __webpack_require__2(3349);
+ function findZeroCrossings(array, level) {
+ var cross = [];
+ level = +level || 0;
+ core(array.hi(array.shape[0] - 1), cross, level);
+ return cross;
+ }
+ }
+ ),
+ /***/
+ 7790: (
+ /***/
+ function() {
+ }
+ )
+ /******/
+ };
+ var __webpack_module_cache__ = {};
+ function __webpack_require__(moduleId) {
+ var cachedModule = __webpack_module_cache__[moduleId];
+ if (cachedModule !== void 0) {
+ return cachedModule.exports;
+ }
+ var module2 = __webpack_module_cache__[moduleId] = {
+ /******/
+ id: moduleId,
+ /******/
+ loaded: false,
+ /******/
+ exports: {}
+ /******/
+ };
+ __webpack_modules__[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
+ module2.loaded = true;
+ return module2.exports;
+ }
+ !function() {
+ __webpack_require__.g = function() {
+ if (typeof globalThis === "object") return globalThis;
+ try {
+ return this || new Function("return this")();
+ } catch (e) {
+ if (typeof window === "object") return window;
+ }
+ }();
+ }();
+ !function() {
+ __webpack_require__.nmd = function(module2) {
+ module2.paths = [];
+ if (!module2.children) module2.children = [];
+ return module2;
+ };
+ }();
+ var __webpack_exports__ = __webpack_require__(1964);
+ module.exports = __webpack_exports__;
+ })();
+ }
+ });
+
+ // node_modules/color-name/index.js
+ var require_color_name = __commonJS({
+ "node_modules/color-name/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ "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]
+ };
+ }
+ });
+
+ // node_modules/color-normalize/node_modules/color-parse/index.js
+ var require_color_parse = __commonJS({
+ "node_modules/color-normalize/node_modules/color-parse/index.js"(exports, module) {
+ "use strict";
+ var names2 = require_color_name();
+ module.exports = parse2;
+ var baseHues2 = {
+ red: 0,
+ orange: 60,
+ yellow: 120,
+ green: 180,
+ blue: 240,
+ purple: 300
+ };
+ function parse2(cstr) {
+ var m, parts = [], alpha = 1, space;
+ if (typeof cstr === "string") {
+ cstr = cstr.toLowerCase();
+ if (names2[cstr]) {
+ parts = names2[cstr].slice();
+ space = "rgb";
+ } else if (cstr === "transparent") {
+ alpha = 0;
+ space = "rgb";
+ parts = [0, 0, 0];
+ } else if (/^#[A-Fa-f0-9]+$/.test(cstr)) {
+ var base = cstr.slice(1);
+ var size = base.length;
+ var isShort = size <= 4;
+ alpha = 1;
+ if (isShort) {
+ parts = [
+ parseInt(base[0] + base[0], 16),
+ parseInt(base[1] + base[1], 16),
+ parseInt(base[2] + base[2], 16)
+ ];
+ if (size === 4) {
+ alpha = parseInt(base[3] + base[3], 16) / 255;
+ }
+ } else {
+ parts = [
+ parseInt(base[0] + base[1], 16),
+ parseInt(base[2] + base[3], 16),
+ parseInt(base[4] + base[5], 16)
+ ];
+ if (size === 8) {
+ alpha = parseInt(base[6] + base[7], 16) / 255;
+ }
+ }
+ if (!parts[0]) parts[0] = 0;
+ if (!parts[1]) parts[1] = 0;
+ if (!parts[2]) parts[2] = 0;
+ space = "rgb";
+ } else if (m = /^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(cstr)) {
+ var name2 = m[1];
+ var isRGB = name2 === "rgb";
+ var base = name2.replace(/a$/, "");
+ space = base;
+ var size = base === "cmyk" ? 4 : base === "gray" ? 1 : 3;
+ parts = m[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(x, i) {
+ if (/%$/.test(x)) {
+ if (i === size) return parseFloat(x) / 100;
+ if (base === "rgb") return parseFloat(x) * 255 / 100;
+ return parseFloat(x);
+ } else if (base[i] === "h") {
+ if (/deg$/.test(x)) {
+ return parseFloat(x);
+ } else if (baseHues2[x] !== void 0) {
+ return baseHues2[x];
+ }
+ }
+ return parseFloat(x);
+ });
+ if (name2 === base) parts.push(1);
+ alpha = isRGB ? 1 : parts[size] === void 0 ? 1 : parts[size];
+ parts = parts.slice(0, size);
+ } else if (cstr.length > 10 && /[0-9](?:\s|\/)/.test(cstr)) {
+ parts = cstr.match(/([0-9]+)/g).map(function(value) {
+ return parseFloat(value);
+ });
+ space = cstr.match(/([a-z])/ig).join("").toLowerCase();
+ }
+ } else if (!isNaN(cstr)) {
+ space = "rgb";
+ parts = [cstr >>> 16, (cstr & 65280) >>> 8, cstr & 255];
+ } else if (Array.isArray(cstr) || cstr.length) {
+ parts = [cstr[0], cstr[1], cstr[2]];
+ space = "rgb";
+ alpha = cstr.length === 4 ? cstr[3] : 1;
+ } else if (cstr instanceof Object) {
+ if (cstr.r != null || cstr.red != null || cstr.R != null) {
+ space = "rgb";
+ parts = [
+ cstr.r || cstr.red || cstr.R || 0,
+ cstr.g || cstr.green || cstr.G || 0,
+ cstr.b || cstr.blue || cstr.B || 0
+ ];
+ } else {
+ space = "hsl";
+ parts = [
+ cstr.h || cstr.hue || cstr.H || 0,
+ cstr.s || cstr.saturation || cstr.S || 0,
+ cstr.l || cstr.lightness || cstr.L || cstr.b || cstr.brightness
+ ];
+ }
+ alpha = cstr.a || cstr.alpha || cstr.opacity || 1;
+ if (cstr.opacity != null) alpha /= 100;
+ }
+ return {
+ space,
+ values: parts,
+ alpha
+ };
+ }
+ }
+ });
+
+ // node_modules/color-normalize/node_modules/color-rgba/index.js
+ var require_color_rgba = __commonJS({
+ "node_modules/color-normalize/node_modules/color-rgba/index.js"(exports, module) {
+ "use strict";
+ var parse2 = require_color_parse();
+ module.exports = function rgba3(color2) {
+ if (Array.isArray(color2) && color2.raw) color2 = String.raw.apply(null, arguments);
+ var values, i, l;
+ var parsed = parse2(color2);
+ if (!parsed.space) return [];
+ var min = [0, 0, 0], max = parsed.space[0] === "h" ? [360, 100, 100] : [255, 255, 255];
+ values = Array(3);
+ values[0] = Math.min(Math.max(parsed.values[0], min[0]), max[0]);
+ values[1] = Math.min(Math.max(parsed.values[1], min[1]), max[1]);
+ values[2] = Math.min(Math.max(parsed.values[2], min[2]), max[2]);
+ if (parsed.space[0] === "h") values = hsl2rgb2(values);
+ values.push(Math.min(Math.max(parsed.alpha, 0), 1));
+ return values;
+ };
+ function hsl2rgb2(hsl3) {
+ var h = hsl3[0] / 360, s = hsl3[1] / 100, l = hsl3[2] / 100, t12, t22, t32, rgb2, val, i = 0;
+ if (s === 0) return val = l * 255, [val, val, val];
+ t22 = l < 0.5 ? l * (1 + s) : l + s - l * s;
+ t12 = 2 * l - t22;
+ rgb2 = [0, 0, 0];
+ for (; i < 3; ) {
+ t32 = h + 1 / 3 * -(i - 1);
+ t32 < 0 ? t32++ : t32 > 1 && t32--;
+ val = 6 * t32 < 1 ? t12 + (t22 - t12) * 6 * t32 : 2 * t32 < 1 ? t22 : 3 * t32 < 2 ? t12 + (t22 - t12) * (2 / 3 - t32) * 6 : t12;
+ rgb2[i++] = val * 255;
+ }
+ return rgb2;
+ }
+ }
+ });
+
+ // node_modules/clamp/index.js
+ var require_clamp = __commonJS({
+ "node_modules/clamp/index.js"(exports, module) {
+ module.exports = clamp;
+ function clamp(value, min, max) {
+ return min < max ? value < min ? min : value > max ? max : value : value < max ? max : value > min ? min : value;
+ }
+ }
+ });
+
+ // node_modules/dtype/index.js
+ var require_dtype = __commonJS({
+ "node_modules/dtype/index.js"(exports, module) {
+ module.exports = function(dtype) {
+ switch (dtype) {
+ case "int8":
+ return Int8Array;
+ case "int16":
+ return Int16Array;
+ case "int32":
+ return Int32Array;
+ case "uint8":
+ return Uint8Array;
+ case "uint16":
+ return Uint16Array;
+ case "uint32":
+ return Uint32Array;
+ case "float32":
+ return Float32Array;
+ case "float64":
+ return Float64Array;
+ case "array":
+ return Array;
+ case "uint8_clamped":
+ return Uint8ClampedArray;
+ }
+ };
+ }
+ });
+
+ // node_modules/color-normalize/index.js
+ var require_color_normalize = __commonJS({
+ "node_modules/color-normalize/index.js"(exports, module) {
+ "use strict";
+ var rgba3 = require_color_rgba();
+ var clamp = require_clamp();
+ var dtype = require_dtype();
+ module.exports = function normalize(color2, type) {
+ if (type === "float" || !type) type = "array";
+ if (type === "uint") type = "uint8";
+ if (type === "uint_clamped") type = "uint8_clamped";
+ var Ctor = dtype(type);
+ var output = new Ctor(4);
+ var normalize2 = type !== "uint8" && type !== "uint8_clamped";
+ if (!color2.length || typeof color2 === "string") {
+ color2 = rgba3(color2);
+ color2[0] /= 255;
+ color2[1] /= 255;
+ color2[2] /= 255;
+ }
+ if (isInt(color2)) {
+ output[0] = color2[0];
+ output[1] = color2[1];
+ output[2] = color2[2];
+ output[3] = color2[3] != null ? color2[3] : 255;
+ if (normalize2) {
+ output[0] /= 255;
+ output[1] /= 255;
+ output[2] /= 255;
+ output[3] /= 255;
+ }
+ return output;
+ }
+ if (!normalize2) {
+ output[0] = clamp(Math.floor(color2[0] * 255), 0, 255);
+ output[1] = clamp(Math.floor(color2[1] * 255), 0, 255);
+ output[2] = clamp(Math.floor(color2[2] * 255), 0, 255);
+ output[3] = color2[3] == null ? 255 : clamp(Math.floor(color2[3] * 255), 0, 255);
+ } else {
+ output[0] = color2[0];
+ output[1] = color2[1];
+ output[2] = color2[2];
+ output[3] = color2[3] != null ? color2[3] : 1;
+ }
+ return output;
+ };
+ function isInt(color2) {
+ if (color2 instanceof Uint8Array || color2 instanceof Uint8ClampedArray) return true;
+ if (Array.isArray(color2) && (color2[0] > 1 || color2[0] === 0) && (color2[1] > 1 || color2[1] === 0) && (color2[2] > 1 || color2[2] === 0) && (!color2[3] || color2[3] > 1)) return true;
+ return false;
+ }
+ }
+ });
+
+ // src/lib/str2rgbarray.js
+ var require_str2rgbarray = __commonJS({
+ "src/lib/str2rgbarray.js"(exports, module) {
+ "use strict";
+ var rgba3 = require_color_normalize();
+ function str2RgbaArray(color2) {
+ if (!color2) return [0, 0, 0, 1];
+ return rgba3(color2);
+ }
+ module.exports = str2RgbaArray;
+ }
+ });
+
+ // src/lib/gl_format_color.js
+ var require_gl_format_color = __commonJS({
+ "src/lib/gl_format_color.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var tinycolor = require_tinycolor();
+ var rgba3 = require_color_normalize();
+ var Colorscale = require_colorscale();
+ var colorDflt = require_attributes3().defaultLine;
+ var isArrayOrTypedArray = require_array().isArrayOrTypedArray;
+ var colorDfltRgba = rgba3(colorDflt);
+ var opacityDflt = 1;
+ function calculateColor(colorIn, opacityIn) {
+ var colorOut = colorIn;
+ colorOut[3] *= opacityIn;
+ return colorOut;
+ }
+ function validateColor(colorIn) {
+ if (isNumeric(colorIn)) return colorDfltRgba;
+ var colorOut = rgba3(colorIn);
+ return colorOut.length ? colorOut : colorDfltRgba;
+ }
+ function validateOpacity(opacityIn) {
+ return isNumeric(opacityIn) ? opacityIn : opacityDflt;
+ }
+ function formatColor(containerIn, opacityIn, len) {
+ var colorIn = containerIn.color;
+ if (colorIn && colorIn._inputArray) colorIn = colorIn._inputArray;
+ var isArrayColorIn = isArrayOrTypedArray(colorIn);
+ var isArrayOpacityIn = isArrayOrTypedArray(opacityIn);
+ var cOpts = Colorscale.extractOpts(containerIn);
+ var colorOut = [];
+ var sclFunc, getColor, getOpacity, colori, opacityi;
+ if (cOpts.colorscale !== void 0) {
+ sclFunc = Colorscale.makeColorScaleFuncFromTrace(containerIn);
+ } else {
+ sclFunc = validateColor;
+ }
+ if (isArrayColorIn) {
+ getColor = function(c, i2) {
+ return c[i2] === void 0 ? colorDfltRgba : rgba3(sclFunc(c[i2]));
+ };
+ } else getColor = validateColor;
+ if (isArrayOpacityIn) {
+ getOpacity = function(o, i2) {
+ return o[i2] === void 0 ? opacityDflt : validateOpacity(o[i2]);
+ };
+ } else getOpacity = validateOpacity;
+ if (isArrayColorIn || isArrayOpacityIn) {
+ for (var i = 0; i < len; i++) {
+ colori = getColor(colorIn, i);
+ opacityi = getOpacity(opacityIn, i);
+ colorOut[i] = calculateColor(colori, opacityi);
+ }
+ } else colorOut = calculateColor(rgba3(colorIn), opacityIn);
+ return colorOut;
+ }
+ function parseColorScale(cont) {
+ var cOpts = Colorscale.extractOpts(cont);
+ var colorscale = cOpts.colorscale;
+ if (cOpts.reversescale) colorscale = Colorscale.flipScale(cOpts.colorscale);
+ return colorscale.map(function(elem) {
+ var index = elem[0];
+ var color2 = tinycolor(elem[1]);
+ var rgb2 = color2.toRgb();
+ return {
+ index,
+ rgb: [rgb2.r, rgb2.g, rgb2.b, rgb2.a]
+ };
+ });
+ }
+ module.exports = {
+ formatColor,
+ parseColorScale
+ };
+ }
+ });
+
+ // src/constants/gl3d_dashes.js
+ var require_gl3d_dashes = __commonJS({
+ "src/constants/gl3d_dashes.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ solid: [[], 0],
+ dot: [[0.5, 1], 200],
+ dash: [[0.5, 1], 50],
+ longdash: [[0.5, 1], 10],
+ dashdot: [[0.5, 0.625, 0.875, 1], 50],
+ longdashdot: [[0.5, 0.7, 0.8, 1], 10]
+ };
+ }
+ });
+
+ // src/constants/gl3d_markers.js
+ var require_gl3d_markers = __commonJS({
+ "src/constants/gl3d_markers.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ circle: "\u25CF",
+ "circle-open": "\u25CB",
+ square: "\u25A0",
+ "square-open": "\u25A1",
+ diamond: "\u25C6",
+ "diamond-open": "\u25C7",
+ cross: "+",
+ x: "\u274C"
+ };
+ }
+ });
+
+ // src/traces/scatter3d/calc_errors.js
+ var require_calc_errors = __commonJS({
+ "src/traces/scatter3d/calc_errors.js"(exports, module) {
+ "use strict";
+ var Registry = require_registry();
+ function calculateAxisErrors(data, params, scaleFactor, axis) {
+ if (!params || !params.visible) return null;
+ var computeError = Registry.getComponentMethod("errorbars", "makeComputeError")(params);
+ var result = new Array(data.length);
+ for (var i = 0; i < data.length; i++) {
+ var errors = computeError(+data[i], i);
+ if (axis.type === "log") {
+ var point = axis.c2l(data[i]);
+ var min = data[i] - errors[0];
+ var max = data[i] + errors[1];
+ result[i] = [
+ (axis.c2l(min, true) - point) * scaleFactor,
+ (axis.c2l(max, true) - point) * scaleFactor
+ ];
+ if (min > 0) {
+ var lower = axis.c2l(min);
+ if (!axis._lowerLogErrorBound) axis._lowerLogErrorBound = lower;
+ axis._lowerErrorBound = Math.min(axis._lowerLogErrorBound, lower);
+ }
+ } else {
+ result[i] = [
+ -errors[0] * scaleFactor,
+ errors[1] * scaleFactor
+ ];
+ }
+ }
+ return result;
+ }
+ function dataLength(array) {
+ for (var i = 0; i < array.length; i++) {
+ if (array[i]) return array[i].length;
+ }
+ return 0;
+ }
+ function calculateErrors(data, scaleFactor, sceneLayout) {
+ var errors = [
+ calculateAxisErrors(data.x, data.error_x, scaleFactor[0], sceneLayout.xaxis),
+ calculateAxisErrors(data.y, data.error_y, scaleFactor[1], sceneLayout.yaxis),
+ calculateAxisErrors(data.z, data.error_z, scaleFactor[2], sceneLayout.zaxis)
+ ];
+ var n = dataLength(errors);
+ if (n === 0) return null;
+ var errorBounds = new Array(n);
+ for (var i = 0; i < n; i++) {
+ var bound = [[0, 0, 0], [0, 0, 0]];
+ for (var j = 0; j < 3; j++) {
+ if (errors[j]) {
+ for (var k = 0; k < 2; k++) {
+ bound[k][j] = errors[j][i][k];
+ }
+ }
+ }
+ errorBounds[i] = bound;
+ }
+ return errorBounds;
+ }
+ module.exports = calculateErrors;
+ }
+ });
+
+ // src/traces/scatter3d/convert.js
+ var require_convert2 = __commonJS({
+ "src/traces/scatter3d/convert.js"(exports, module) {
+ "use strict";
+ var createLinePlot = require_stackgl_modules().gl_line3d;
+ var createScatterPlot = require_stackgl_modules().gl_scatter3d;
+ var createErrorBars = require_stackgl_modules().gl_error3d;
+ var createMesh = require_stackgl_modules().gl_mesh3d;
+ var triangulate = require_stackgl_modules().delaunay_triangulate;
+ var Lib = require_lib();
+ var str2RgbaArray = require_str2rgbarray();
+ var formatColor = require_gl_format_color().formatColor;
+ var makeBubbleSizeFn = require_make_bubble_size_func();
+ var DASH_PATTERNS = require_gl3d_dashes();
+ var MARKER_SYMBOLS = require_gl3d_markers();
+ var Axes = require_axes();
+ var appendArrayPointValue = require_helpers2().appendArrayPointValue;
+ var calculateError = require_calc_errors();
+ function LineWithMarkers(scene, uid) {
+ this.scene = scene;
+ this.uid = uid;
+ this.linePlot = null;
+ this.scatterPlot = null;
+ this.errorBars = null;
+ this.textMarkers = null;
+ this.delaunayMesh = null;
+ this.color = null;
+ this.mode = "";
+ this.dataPoints = [];
+ this.axesBounds = [
+ [-Infinity, -Infinity, -Infinity],
+ [Infinity, Infinity, Infinity]
+ ];
+ this.textLabels = null;
+ this.data = null;
+ }
+ var proto = LineWithMarkers.prototype;
+ proto.handlePick = function(selection) {
+ if (selection.object && (selection.object === this.linePlot || selection.object === this.delaunayMesh || selection.object === this.textMarkers || selection.object === this.scatterPlot)) {
+ var ind = selection.index = selection.data.index;
+ if (selection.object.highlight) {
+ selection.object.highlight(null);
+ }
+ if (this.scatterPlot) {
+ selection.object = this.scatterPlot;
+ this.scatterPlot.highlight(selection.data);
+ }
+ selection.textLabel = "";
+ if (this.textLabels) {
+ if (Lib.isArrayOrTypedArray(this.textLabels)) {
+ if (this.textLabels[ind] || this.textLabels[ind] === 0) {
+ selection.textLabel = this.textLabels[ind];
+ }
+ } else {
+ selection.textLabel = this.textLabels;
+ }
+ }
+ selection.traceCoordinate = [
+ this.data.x[ind],
+ this.data.y[ind],
+ this.data.z[ind]
+ ];
+ return true;
+ }
+ };
+ function constructDelaunay(points, color2, axis) {
+ var u = (axis + 1) % 3;
+ var v = (axis + 2) % 3;
+ var filteredPoints = [];
+ var filteredIds = [];
+ var i;
+ for (i = 0; i < points.length; ++i) {
+ var p = points[i];
+ if (isNaN(p[u]) || !isFinite(p[u]) || isNaN(p[v]) || !isFinite(p[v])) {
+ continue;
+ }
+ filteredPoints.push([p[u], p[v]]);
+ filteredIds.push(i);
+ }
+ var cells = triangulate(filteredPoints);
+ for (i = 0; i < cells.length; ++i) {
+ var c = cells[i];
+ for (var j = 0; j < c.length; ++j) {
+ c[j] = filteredIds[c[j]];
+ }
+ }
+ return {
+ positions: points,
+ cells,
+ meshColor: color2
+ };
+ }
+ function calculateErrorParams(errors) {
+ var capSize = [0, 0, 0];
+ var color2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
+ var lineWidth = [1, 1, 1];
+ for (var i = 0; i < 3; i++) {
+ var e = errors[i];
+ if (e && e.copy_zstyle !== false && errors[2].visible !== false) e = errors[2];
+ if (!e || !e.visible) continue;
+ capSize[i] = e.width / 2;
+ color2[i] = str2RgbaArray(e.color);
+ lineWidth[i] = e.thickness;
+ }
+ return { capSize, color: color2, lineWidth };
+ }
+ function parseAlignmentX(a) {
+ if (a === null || a === void 0) return 0;
+ return a.indexOf("left") > -1 ? -1 : a.indexOf("right") > -1 ? 1 : 0;
+ }
+ function parseAlignmentY(a) {
+ if (a === null || a === void 0) return 0;
+ return a.indexOf("top") > -1 ? -1 : a.indexOf("bottom") > -1 ? 1 : 0;
+ }
+ function calculateTextOffset(tp) {
+ var defaultAlignmentX = 0;
+ var defaultAlignmentY = 0;
+ var textOffset = [
+ defaultAlignmentX,
+ defaultAlignmentY
+ ];
+ if (Array.isArray(tp)) {
+ for (var i = 0; i < tp.length; i++) {
+ textOffset[i] = [
+ defaultAlignmentX,
+ defaultAlignmentY
+ ];
+ if (tp[i]) {
+ textOffset[i][0] = parseAlignmentX(tp[i]);
+ textOffset[i][1] = parseAlignmentY(tp[i]);
+ }
+ }
+ } else {
+ textOffset[0] = parseAlignmentX(tp);
+ textOffset[1] = parseAlignmentY(tp);
+ }
+ return textOffset;
+ }
+ function calculateSize(sizeIn, sizeFn) {
+ return sizeFn(sizeIn * 4);
+ }
+ function calculateSymbol(symbolIn) {
+ return MARKER_SYMBOLS[symbolIn];
+ }
+ function formatParam(paramIn, len, calculate, dflt, extraFn) {
+ var paramOut = null;
+ if (Lib.isArrayOrTypedArray(paramIn)) {
+ paramOut = [];
+ for (var i = 0; i < len; i++) {
+ if (paramIn[i] === void 0) paramOut[i] = dflt;
+ else paramOut[i] = calculate(paramIn[i], extraFn);
+ }
+ } else paramOut = calculate(paramIn, Lib.identity);
+ return paramOut;
+ }
+ function convertPlotlyOptions(scene, data) {
+ var points = [];
+ var sceneLayout = scene.fullSceneLayout;
+ var scaleFactor = scene.dataScale;
+ var xaxis = sceneLayout.xaxis;
+ var yaxis = sceneLayout.yaxis;
+ var zaxis = sceneLayout.zaxis;
+ var marker = data.marker;
+ var line = data.line;
+ var x = data.x || [];
+ var y = data.y || [];
+ var z = data.z || [];
+ var len = x.length;
+ var xcalendar = data.xcalendar;
+ var ycalendar = data.ycalendar;
+ var zcalendar = data.zcalendar;
+ var xc, yc, zc;
+ var params, i;
+ var text;
+ for (i = 0; i < len; i++) {
+ xc = xaxis.d2l(x[i], 0, xcalendar) * scaleFactor[0];
+ yc = yaxis.d2l(y[i], 0, ycalendar) * scaleFactor[1];
+ zc = zaxis.d2l(z[i], 0, zcalendar) * scaleFactor[2];
+ points[i] = [xc, yc, zc];
+ }
+ if (Array.isArray(data.text)) {
+ text = data.text;
+ } else if (Lib.isTypedArray(data.text)) {
+ text = Array.from(data.text);
+ } else if (data.text !== void 0) {
+ text = new Array(len);
+ for (i = 0; i < len; i++) text[i] = data.text;
+ }
+ function formatter(axName, val) {
+ var ax = sceneLayout[axName];
+ return Axes.tickText(ax, ax.d2l(val), true).text;
+ }
+ var texttemplate = data.texttemplate;
+ if (texttemplate) {
+ var fullLayout = scene.fullLayout;
+ var d3locale = fullLayout._d3locale;
+ var isArray = Array.isArray(texttemplate);
+ var N = isArray ? Math.min(texttemplate.length, len) : len;
+ var txt = isArray ? function(i2) {
+ return texttemplate[i2];
+ } : function() {
+ return texttemplate;
+ };
+ text = new Array(N);
+ for (i = 0; i < N; i++) {
+ var d = { x: x[i], y: y[i], z: z[i] };
+ var labels = {
+ xLabel: formatter("xaxis", x[i]),
+ yLabel: formatter("yaxis", y[i]),
+ zLabel: formatter("zaxis", z[i])
+ };
+ var pointValues = {};
+ appendArrayPointValue(pointValues, data, i);
+ var meta = data._meta || {};
+ text[i] = Lib.texttemplateString(txt(i), labels, d3locale, pointValues, d, meta);
+ }
+ }
+ params = {
+ position: points,
+ mode: data.mode,
+ text
+ };
+ if ("line" in data) {
+ params.lineColor = formatColor(line, 1, len);
+ params.lineWidth = line.width;
+ params.lineDashes = line.dash;
+ }
+ if ("marker" in data) {
+ var sizeFn = makeBubbleSizeFn(data);
+ params.scatterColor = formatColor(marker, 1, len);
+ params.scatterSize = formatParam(marker.size, len, calculateSize, 20, sizeFn);
+ params.scatterMarker = formatParam(marker.symbol, len, calculateSymbol, "\u25CF");
+ params.scatterLineWidth = marker.line.width;
+ params.scatterLineColor = formatColor(marker.line, 1, len);
+ params.scatterAngle = 0;
+ }
+ if ("textposition" in data) {
+ params.textOffset = calculateTextOffset(data.textposition);
+ params.textColor = formatColor(data.textfont, 1, len);
+ params.textSize = formatParam(data.textfont.size, len, Lib.identity, 12);
+ params.textFontFamily = data.textfont.family;
+ params.textFontWeight = data.textfont.weight;
+ params.textFontStyle = data.textfont.style;
+ params.textFontVariant = data.textfont.variant;
+ params.textAngle = 0;
+ }
+ var dims = ["x", "y", "z"];
+ params.project = [false, false, false];
+ params.projectScale = [1, 1, 1];
+ params.projectOpacity = [1, 1, 1];
+ for (i = 0; i < 3; ++i) {
+ var projection = data.projection[dims[i]];
+ if (params.project[i] = projection.show) {
+ params.projectOpacity[i] = projection.opacity;
+ params.projectScale[i] = projection.scale;
+ }
+ }
+ params.errorBounds = calculateError(data, scaleFactor, sceneLayout);
+ var errorParams = calculateErrorParams([data.error_x, data.error_y, data.error_z]);
+ params.errorColor = errorParams.color;
+ params.errorLineWidth = errorParams.lineWidth;
+ params.errorCapSize = errorParams.capSize;
+ params.delaunayAxis = data.surfaceaxis;
+ params.delaunayColor = str2RgbaArray(data.surfacecolor);
+ return params;
+ }
+ function _arrayToColor(color2) {
+ if (Lib.isArrayOrTypedArray(color2)) {
+ var c = color2[0];
+ if (Lib.isArrayOrTypedArray(c)) color2 = c;
+ return "rgb(" + color2.slice(0, 3).map(function(x) {
+ return Math.round(x * 255);
+ }) + ")";
+ }
+ return null;
+ }
+ function arrayToColor(colors) {
+ if (!Lib.isArrayOrTypedArray(colors)) {
+ return null;
+ }
+ if (colors.length === 4 && typeof colors[0] === "number") {
+ return _arrayToColor(colors);
+ }
+ return colors.map(_arrayToColor);
+ }
+ proto.update = function(data) {
+ var gl2 = this.scene.glplot.gl;
+ var lineOptions;
+ var scatterOptions;
+ var errorOptions;
+ var textOptions;
+ var dashPattern = DASH_PATTERNS.solid;
+ this.data = data;
+ var options = convertPlotlyOptions(this.scene, data);
+ if ("mode" in options) {
+ this.mode = options.mode;
+ }
+ if ("lineDashes" in options) {
+ if (options.lineDashes in DASH_PATTERNS) {
+ dashPattern = DASH_PATTERNS[options.lineDashes];
+ }
+ }
+ this.color = arrayToColor(options.scatterColor) || arrayToColor(options.lineColor);
+ this.dataPoints = options.position;
+ lineOptions = {
+ gl: this.scene.glplot.gl,
+ position: options.position,
+ color: options.lineColor,
+ lineWidth: options.lineWidth || 1,
+ dashes: dashPattern[0],
+ dashScale: dashPattern[1],
+ opacity: data.opacity,
+ connectGaps: data.connectgaps
+ };
+ if (this.mode.indexOf("lines") !== -1) {
+ if (this.linePlot) this.linePlot.update(lineOptions);
+ else {
+ this.linePlot = createLinePlot(lineOptions);
+ this.linePlot._trace = this;
+ this.scene.glplot.add(this.linePlot);
+ }
+ } else if (this.linePlot) {
+ this.scene.glplot.remove(this.linePlot);
+ this.linePlot.dispose();
+ this.linePlot = null;
+ }
+ var scatterOpacity = data.opacity;
+ if (data.marker && data.marker.opacity !== void 0) scatterOpacity *= data.marker.opacity;
+ scatterOptions = {
+ gl: this.scene.glplot.gl,
+ position: options.position,
+ color: options.scatterColor,
+ size: options.scatterSize,
+ glyph: options.scatterMarker,
+ opacity: scatterOpacity,
+ orthographic: true,
+ lineWidth: options.scatterLineWidth,
+ lineColor: options.scatterLineColor,
+ project: options.project,
+ projectScale: options.projectScale,
+ projectOpacity: options.projectOpacity
+ };
+ if (this.mode.indexOf("markers") !== -1) {
+ if (this.scatterPlot) this.scatterPlot.update(scatterOptions);
+ else {
+ this.scatterPlot = createScatterPlot(scatterOptions);
+ this.scatterPlot._trace = this;
+ this.scatterPlot.highlightScale = 1;
+ this.scene.glplot.add(this.scatterPlot);
+ }
+ } else if (this.scatterPlot) {
+ this.scene.glplot.remove(this.scatterPlot);
+ this.scatterPlot.dispose();
+ this.scatterPlot = null;
+ }
+ textOptions = {
+ gl: this.scene.glplot.gl,
+ position: options.position,
+ glyph: options.text,
+ color: options.textColor,
+ size: options.textSize,
+ angle: options.textAngle,
+ alignment: options.textOffset,
+ font: options.textFontFamily,
+ fontWeight: options.textFontWeight,
+ fontStyle: options.textFontStyle,
+ fontVariant: options.textFontVariant,
+ orthographic: true,
+ lineWidth: 0,
+ project: false,
+ opacity: data.opacity
+ };
+ this.textLabels = data.hovertext || data.text;
+ if (this.mode.indexOf("text") !== -1) {
+ if (this.textMarkers) this.textMarkers.update(textOptions);
+ else {
+ this.textMarkers = createScatterPlot(textOptions);
+ this.textMarkers._trace = this;
+ this.textMarkers.highlightScale = 1;
+ this.scene.glplot.add(this.textMarkers);
+ }
+ } else if (this.textMarkers) {
+ this.scene.glplot.remove(this.textMarkers);
+ this.textMarkers.dispose();
+ this.textMarkers = null;
+ }
+ errorOptions = {
+ gl: this.scene.glplot.gl,
+ position: options.position,
+ color: options.errorColor,
+ error: options.errorBounds,
+ lineWidth: options.errorLineWidth,
+ capSize: options.errorCapSize,
+ opacity: data.opacity
+ };
+ if (this.errorBars) {
+ if (options.errorBounds) {
+ this.errorBars.update(errorOptions);
+ } else {
+ this.scene.glplot.remove(this.errorBars);
+ this.errorBars.dispose();
+ this.errorBars = null;
+ }
+ } else if (options.errorBounds) {
+ this.errorBars = createErrorBars(errorOptions);
+ this.errorBars._trace = this;
+ this.scene.glplot.add(this.errorBars);
+ }
+ if (options.delaunayAxis >= 0) {
+ var delaunayOptions = constructDelaunay(
+ options.position,
+ options.delaunayColor,
+ options.delaunayAxis
+ );
+ delaunayOptions.opacity = data.opacity;
+ if (this.delaunayMesh) {
+ this.delaunayMesh.update(delaunayOptions);
+ } else {
+ delaunayOptions.gl = gl2;
+ this.delaunayMesh = createMesh(delaunayOptions);
+ this.delaunayMesh._trace = this;
+ this.scene.glplot.add(this.delaunayMesh);
+ }
+ } else if (this.delaunayMesh) {
+ this.scene.glplot.remove(this.delaunayMesh);
+ this.delaunayMesh.dispose();
+ this.delaunayMesh = null;
+ }
+ };
+ proto.dispose = function() {
+ if (this.linePlot) {
+ this.scene.glplot.remove(this.linePlot);
+ this.linePlot.dispose();
+ }
+ if (this.scatterPlot) {
+ this.scene.glplot.remove(this.scatterPlot);
+ this.scatterPlot.dispose();
+ }
+ if (this.errorBars) {
+ this.scene.glplot.remove(this.errorBars);
+ this.errorBars.dispose();
+ }
+ if (this.textMarkers) {
+ this.scene.glplot.remove(this.textMarkers);
+ this.textMarkers.dispose();
+ }
+ if (this.delaunayMesh) {
+ this.scene.glplot.remove(this.delaunayMesh);
+ this.delaunayMesh.dispose();
+ }
+ };
+ function createLineWithMarkers(scene, data) {
+ var plot = new LineWithMarkers(scene, data.uid);
+ plot.update(data);
+ return plot;
+ }
+ module.exports = createLineWithMarkers;
+ }
+ });
+
+ // src/traces/scatter3d/attributes.js
+ var require_attributes40 = __commonJS({
+ "src/traces/scatter3d/attributes.js"(exports, module) {
+ "use strict";
+ var scatterAttrs = require_attributes12();
+ var fontAttrs = require_font_attributes();
+ var colorAttributes = require_attributes8();
+ var axisHoverFormat = require_axis_format_attributes().axisHoverFormat;
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var texttemplateAttrs = require_template_attributes().texttemplateAttrs;
+ var baseAttrs = require_attributes2();
+ var DASHES = require_gl3d_dashes();
+ var MARKER_SYMBOLS = require_gl3d_markers();
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var sortObjectKeys = require_sort_object_keys();
+ var scatterLineAttrs = scatterAttrs.line;
+ var scatterMarkerAttrs = scatterAttrs.marker;
+ var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
+ var lineAttrs = extendFlat({
+ width: scatterLineAttrs.width,
+ dash: {
+ valType: "enumerated",
+ values: sortObjectKeys(DASHES),
+ dflt: "solid"
+ }
+ }, colorAttributes("line"));
+ function makeProjectionAttr(axLetter) {
+ return {
+ show: {
+ valType: "boolean",
+ dflt: false
+ },
+ opacity: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1
+ },
+ scale: {
+ valType: "number",
+ min: 0,
+ max: 10,
+ dflt: 2 / 3
+ }
+ };
+ }
+ var attrs = module.exports = overrideAll({
+ x: scatterAttrs.x,
+ y: scatterAttrs.y,
+ z: {
+ valType: "data_array"
+ },
+ text: extendFlat({}, scatterAttrs.text, {}),
+ texttemplate: texttemplateAttrs({}, {}),
+ hovertext: extendFlat({}, scatterAttrs.hovertext, {}),
+ hovertemplate: hovertemplateAttrs(),
+ xhoverformat: axisHoverFormat("x"),
+ yhoverformat: axisHoverFormat("y"),
+ zhoverformat: axisHoverFormat("z"),
+ mode: extendFlat(
+ {},
+ scatterAttrs.mode,
+ // shouldn't this be on-par with 2D?
+ { dflt: "lines+markers" }
+ ),
+ surfaceaxis: {
+ valType: "enumerated",
+ values: [-1, 0, 1, 2],
+ dflt: -1
+ },
+ surfacecolor: {
+ valType: "color"
+ },
+ projection: {
+ x: makeProjectionAttr("x"),
+ y: makeProjectionAttr("y"),
+ z: makeProjectionAttr("z")
+ },
+ connectgaps: scatterAttrs.connectgaps,
+ line: lineAttrs,
+ marker: extendFlat(
+ {
+ // Parity with scatter.js?
+ symbol: {
+ valType: "enumerated",
+ values: sortObjectKeys(MARKER_SYMBOLS),
+ dflt: "circle",
+ arrayOk: true
+ },
+ size: extendFlat({}, scatterMarkerAttrs.size, { dflt: 8 }),
+ sizeref: scatterMarkerAttrs.sizeref,
+ sizemin: scatterMarkerAttrs.sizemin,
+ sizemode: scatterMarkerAttrs.sizemode,
+ opacity: extendFlat({}, scatterMarkerAttrs.opacity, {
+ arrayOk: false
+ }),
+ colorbar: scatterMarkerAttrs.colorbar,
+ line: extendFlat(
+ {
+ width: extendFlat({}, scatterMarkerLineAttrs.width, { arrayOk: false })
+ },
+ colorAttributes("marker.line")
+ )
+ },
+ colorAttributes("marker")
+ ),
+ textposition: extendFlat({}, scatterAttrs.textposition, { dflt: "top center" }),
+ textfont: fontAttrs({
+ noFontShadow: true,
+ noFontLineposition: true,
+ noFontTextcase: true,
+ editType: "calc",
+ colorEditType: "style",
+ arrayOk: true,
+ variantValues: ["normal", "small-caps"]
+ }),
+ opacity: baseAttrs.opacity,
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo)
+ }, "calc", "nested");
+ attrs.x.editType = attrs.y.editType = attrs.z.editType = "calc+clearAxisTypes";
+ }
+ });
+
+ // src/traces/scatter3d/defaults.js
+ var require_defaults36 = __commonJS({
+ "src/traces/scatter3d/defaults.js"(exports, module) {
+ "use strict";
+ var Registry = require_registry();
+ var Lib = require_lib();
+ var subTypes = require_subtypes();
+ var handleMarkerDefaults = require_marker_defaults();
+ var handleLineDefaults = require_line_defaults();
+ var handleTextDefaults = require_text_defaults();
+ var attributes = require_attributes40();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var len = handleXYZDefaults(traceIn, traceOut, coerce, layout);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ coerce("xhoverformat");
+ coerce("yhoverformat");
+ coerce("zhoverformat");
+ coerce("mode");
+ if (subTypes.hasMarkers(traceOut)) {
+ handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, { noSelect: true, noAngle: true });
+ }
+ if (subTypes.hasLines(traceOut)) {
+ coerce("connectgaps");
+ handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
+ }
+ if (subTypes.hasText(traceOut)) {
+ coerce("texttemplate");
+ handleTextDefaults(traceIn, traceOut, layout, coerce, {
+ noSelect: true,
+ noFontShadow: true,
+ noFontLineposition: true,
+ noFontTextcase: true
+ });
+ }
+ var lineColor = (traceOut.line || {}).color;
+ var markerColor = (traceOut.marker || {}).color;
+ if (coerce("surfaceaxis") >= 0) coerce("surfacecolor", lineColor || markerColor);
+ var dims = ["x", "y", "z"];
+ for (var i = 0; i < 3; ++i) {
+ var projection = "projection." + dims[i];
+ if (coerce(projection + ".show")) {
+ coerce(projection + ".opacity");
+ coerce(projection + ".scale");
+ }
+ }
+ var errorBarsSupplyDefaults = Registry.getComponentMethod("errorbars", "supplyDefaults");
+ errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, { axis: "z" });
+ errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, { axis: "y", inherit: "z" });
+ errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, { axis: "x", inherit: "z" });
+ };
+ function handleXYZDefaults(traceIn, traceOut, coerce, layout) {
+ var len = 0;
+ var x = coerce("x");
+ var y = coerce("y");
+ var z = coerce("z");
+ var handleCalendarDefaults = Registry.getComponentMethod("calendars", "handleTraceDefaults");
+ handleCalendarDefaults(traceIn, traceOut, ["x", "y", "z"], layout);
+ if (x && y && z) {
+ len = Math.min(x.length, y.length, z.length);
+ traceOut._length = traceOut._xlength = traceOut._ylength = traceOut._zlength = len;
+ }
+ return len;
+ }
+ }
+ });
+
+ // src/traces/scatter3d/calc.js
+ var require_calc21 = __commonJS({
+ "src/traces/scatter3d/calc.js"(exports, module) {
+ "use strict";
+ var arraysToCalcdata = require_arrays_to_calcdata();
+ var calcColorscale = require_colorscale_calc();
+ module.exports = function calc(gd, trace) {
+ var cd = [{ x: false, y: false, trace, t: {} }];
+ arraysToCalcdata(cd, trace);
+ calcColorscale(gd, trace);
+ return cd;
+ };
+ }
+ });
+
+ // node_modules/get-canvas-context/index.js
+ var require_get_canvas_context = __commonJS({
+ "node_modules/get-canvas-context/index.js"(exports, module) {
+ module.exports = getCanvasContext;
+ function getCanvasContext(type, opts) {
+ if (typeof type !== "string") {
+ throw new TypeError("must specify type string");
+ }
+ opts = opts || {};
+ if (typeof document === "undefined" && !opts.canvas) {
+ return null;
+ }
+ var canvas = opts.canvas || document.createElement("canvas");
+ if (typeof opts.width === "number") {
+ canvas.width = opts.width;
+ }
+ if (typeof opts.height === "number") {
+ canvas.height = opts.height;
+ }
+ var attribs = opts;
+ var gl2;
+ try {
+ var names2 = [type];
+ if (type.indexOf("webgl") === 0) {
+ names2.push("experimental-" + type);
+ }
+ for (var i = 0; i < names2.length; i++) {
+ gl2 = canvas.getContext(names2[i], attribs);
+ if (gl2) return gl2;
+ }
+ } catch (e) {
+ gl2 = null;
+ }
+ return gl2 || null;
+ }
+ }
+ });
+
+ // node_modules/webgl-context/index.js
+ var require_webgl_context = __commonJS({
+ "node_modules/webgl-context/index.js"(exports, module) {
+ var getContext = require_get_canvas_context();
+ module.exports = function getWebGLContext(opt) {
+ return getContext("webgl", opt);
+ };
+ }
+ });
+
+ // src/lib/show_no_webgl_msg.js
+ var require_show_no_webgl_msg = __commonJS({
+ "src/lib/show_no_webgl_msg.js"(exports, module) {
+ "use strict";
+ var Color2 = require_color();
+ var noop = function() {
+ };
+ module.exports = function showNoWebGlMsg(scene) {
+ for (var prop in scene) {
+ if (typeof scene[prop] === "function") scene[prop] = noop;
+ }
+ scene.destroy = function() {
+ scene.container.parentNode.removeChild(scene.container);
+ };
+ var div = document.createElement("div");
+ div.className = "no-webgl";
+ div.style.cursor = "pointer";
+ div.style.fontSize = "24px";
+ div.style.color = Color2.defaults[0];
+ div.style.position = "absolute";
+ div.style.left = div.style.top = "0px";
+ div.style.width = div.style.height = "100%";
+ div.style["background-color"] = Color2.lightLine;
+ div.style["z-index"] = 30;
+ var p = document.createElement("p");
+ p.textContent = "WebGL is not supported by your browser - visit https://get.webgl.org for more info";
+ p.style.position = "relative";
+ p.style.top = "50%";
+ p.style.left = "50%";
+ p.style.height = "30%";
+ p.style.width = "50%";
+ p.style.margin = "-15% 0 0 -25%";
+ div.appendChild(p);
+ scene.container.appendChild(div);
+ scene.container.style.background = "#FFFFFF";
+ scene.container.onclick = function() {
+ window.open("https://get.webgl.org");
+ };
+ return false;
+ };
+ }
+ });
+
+ // src/plots/gl3d/layout/convert.js
+ var require_convert3 = __commonJS({
+ "src/plots/gl3d/layout/convert.js"(exports, module) {
+ "use strict";
+ var str2RgbaArray = require_str2rgbarray();
+ var Lib = require_lib();
+ var AXES_NAMES = ["xaxis", "yaxis", "zaxis"];
+ function AxesOptions() {
+ this.bounds = [
+ [-10, -10, -10],
+ [10, 10, 10]
+ ];
+ this.ticks = [[], [], []];
+ this.tickEnable = [true, true, true];
+ this.tickFont = ["sans-serif", "sans-serif", "sans-serif"];
+ this.tickSize = [12, 12, 12];
+ this.tickFontWeight = ["normal", "normal", "normal", "normal"];
+ this.tickFontStyle = ["normal", "normal", "normal", "normal"];
+ this.tickFontVariant = ["normal", "normal", "normal", "normal"];
+ this.tickAngle = [0, 0, 0];
+ this.tickColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]];
+ this.tickPad = [18, 18, 18];
+ this.labels = ["x", "y", "z"];
+ this.labelEnable = [true, true, true];
+ this.labelFont = ["Open Sans", "Open Sans", "Open Sans"];
+ this.labelSize = [20, 20, 20];
+ this.labelFontWeight = ["normal", "normal", "normal", "normal"];
+ this.labelFontStyle = ["normal", "normal", "normal", "normal"];
+ this.labelFontVariant = ["normal", "normal", "normal", "normal"];
+ this.labelColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]];
+ this.labelPad = [30, 30, 30];
+ this.lineEnable = [true, true, true];
+ this.lineMirror = [false, false, false];
+ this.lineWidth = [1, 1, 1];
+ this.lineColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]];
+ this.lineTickEnable = [true, true, true];
+ this.lineTickMirror = [false, false, false];
+ this.lineTickLength = [10, 10, 10];
+ this.lineTickWidth = [1, 1, 1];
+ this.lineTickColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]];
+ this.gridEnable = [true, true, true];
+ this.gridWidth = [1, 1, 1];
+ this.gridColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]];
+ this.zeroEnable = [true, true, true];
+ this.zeroLineColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]];
+ this.zeroLineWidth = [2, 2, 2];
+ this.backgroundEnable = [true, true, true];
+ this.backgroundColor = [
+ [0.8, 0.8, 0.8, 0.5],
+ [0.8, 0.8, 0.8, 0.5],
+ [0.8, 0.8, 0.8, 0.5]
+ ];
+ this._defaultTickPad = this.tickPad.slice();
+ this._defaultLabelPad = this.labelPad.slice();
+ this._defaultLineTickLength = this.lineTickLength.slice();
+ }
+ var proto = AxesOptions.prototype;
+ proto.merge = function(fullLayout, sceneLayout) {
+ var opts = this;
+ for (var i = 0; i < 3; ++i) {
+ var axes = sceneLayout[AXES_NAMES[i]];
+ if (!axes.visible) {
+ opts.tickEnable[i] = false;
+ opts.labelEnable[i] = false;
+ opts.lineEnable[i] = false;
+ opts.lineTickEnable[i] = false;
+ opts.gridEnable[i] = false;
+ opts.zeroEnable[i] = false;
+ opts.backgroundEnable[i] = false;
+ continue;
+ }
+ opts.labels[i] = fullLayout._meta ? Lib.templateString(axes.title.text, fullLayout._meta) : axes.title.text;
+ if ("font" in axes.title) {
+ if (axes.title.font.color) opts.labelColor[i] = str2RgbaArray(axes.title.font.color);
+ if (axes.title.font.family) opts.labelFont[i] = axes.title.font.family;
+ if (axes.title.font.size) opts.labelSize[i] = axes.title.font.size;
+ if (axes.title.font.weight) opts.labelFontWeight[i] = axes.title.font.weight;
+ if (axes.title.font.style) opts.labelFontStyle[i] = axes.title.font.style;
+ if (axes.title.font.variant) opts.labelFontVariant[i] = axes.title.font.variant;
+ }
+ if ("showline" in axes) opts.lineEnable[i] = axes.showline;
+ if ("linecolor" in axes) opts.lineColor[i] = str2RgbaArray(axes.linecolor);
+ if ("linewidth" in axes) opts.lineWidth[i] = axes.linewidth;
+ if ("showgrid" in axes) opts.gridEnable[i] = axes.showgrid;
+ if ("gridcolor" in axes) opts.gridColor[i] = str2RgbaArray(axes.gridcolor);
+ if ("gridwidth" in axes) opts.gridWidth[i] = axes.gridwidth;
+ if (axes.type === "log") opts.zeroEnable[i] = false;
+ else if ("zeroline" in axes) opts.zeroEnable[i] = axes.zeroline;
+ if ("zerolinecolor" in axes) opts.zeroLineColor[i] = str2RgbaArray(axes.zerolinecolor);
+ if ("zerolinewidth" in axes) opts.zeroLineWidth[i] = axes.zerolinewidth;
+ if ("ticks" in axes && !!axes.ticks) opts.lineTickEnable[i] = true;
+ else opts.lineTickEnable[i] = false;
+ if ("ticklen" in axes) {
+ opts.lineTickLength[i] = opts._defaultLineTickLength[i] = axes.ticklen;
+ }
+ if ("tickcolor" in axes) opts.lineTickColor[i] = str2RgbaArray(axes.tickcolor);
+ if ("tickwidth" in axes) opts.lineTickWidth[i] = axes.tickwidth;
+ if ("tickangle" in axes) {
+ opts.tickAngle[i] = axes.tickangle === "auto" ? -3600 : (
+ // i.e. special number to set auto option
+ Math.PI * -axes.tickangle / 180
+ );
+ }
+ if ("showticklabels" in axes) opts.tickEnable[i] = axes.showticklabels;
+ if ("tickfont" in axes) {
+ if (axes.tickfont.color) opts.tickColor[i] = str2RgbaArray(axes.tickfont.color);
+ if (axes.tickfont.family) opts.tickFont[i] = axes.tickfont.family;
+ if (axes.tickfont.size) opts.tickSize[i] = axes.tickfont.size;
+ if (axes.tickfont.weight) opts.tickFontWeight[i] = axes.tickfont.weight;
+ if (axes.tickfont.style) opts.tickFontStyle[i] = axes.tickfont.style;
+ if (axes.tickfont.variant) opts.tickFontVariant[i] = axes.tickfont.variant;
+ }
+ if ("mirror" in axes) {
+ if (["ticks", "all", "allticks"].indexOf(axes.mirror) !== -1) {
+ opts.lineTickMirror[i] = true;
+ opts.lineMirror[i] = true;
+ } else if (axes.mirror === true) {
+ opts.lineTickMirror[i] = false;
+ opts.lineMirror[i] = true;
+ } else {
+ opts.lineTickMirror[i] = false;
+ opts.lineMirror[i] = false;
+ }
+ } else opts.lineMirror[i] = false;
+ if ("showbackground" in axes && axes.showbackground !== false) {
+ opts.backgroundEnable[i] = true;
+ opts.backgroundColor[i] = str2RgbaArray(axes.backgroundcolor);
+ } else opts.backgroundEnable[i] = false;
+ }
+ };
+ function createAxesOptions(fullLayout, sceneLayout) {
+ var result = new AxesOptions();
+ result.merge(fullLayout, sceneLayout);
+ return result;
+ }
+ module.exports = createAxesOptions;
+ }
+ });
+
+ // src/plots/gl3d/layout/spikes.js
+ var require_spikes = __commonJS({
+ "src/plots/gl3d/layout/spikes.js"(exports, module) {
+ "use strict";
+ var str2RGBArray = require_str2rgbarray();
+ var AXES_NAMES = ["xaxis", "yaxis", "zaxis"];
+ function SpikeOptions() {
+ this.enabled = [true, true, true];
+ this.colors = [
+ [0, 0, 0, 1],
+ [0, 0, 0, 1],
+ [0, 0, 0, 1]
+ ];
+ this.drawSides = [true, true, true];
+ this.lineWidth = [1, 1, 1];
+ }
+ var proto = SpikeOptions.prototype;
+ proto.merge = function(sceneLayout) {
+ for (var i = 0; i < 3; ++i) {
+ var axes = sceneLayout[AXES_NAMES[i]];
+ if (!axes.visible) {
+ this.enabled[i] = false;
+ this.drawSides[i] = false;
+ continue;
+ }
+ this.enabled[i] = axes.showspikes;
+ this.colors[i] = str2RGBArray(axes.spikecolor);
+ this.drawSides[i] = axes.spikesides;
+ this.lineWidth[i] = axes.spikethickness;
+ }
+ };
+ function createSpikeOptions(layout) {
+ var result = new SpikeOptions();
+ result.merge(layout);
+ return result;
+ }
+ module.exports = createSpikeOptions;
+ }
+ });
+
+ // src/plots/gl3d/layout/tick_marks.js
+ var require_tick_marks = __commonJS({
+ "src/plots/gl3d/layout/tick_marks.js"(exports, module) {
+ "use strict";
+ module.exports = computeTickMarks;
+ var Axes = require_axes();
+ var Lib = require_lib();
+ var AXES_NAMES = ["xaxis", "yaxis", "zaxis"];
+ var centerPoint = [0, 0, 0];
+ function contourLevelsFromTicks(ticks) {
+ var result = new Array(3);
+ for (var i = 0; i < 3; ++i) {
+ var tlevel = ticks[i];
+ var clevel = new Array(tlevel.length);
+ for (var j = 0; j < tlevel.length; ++j) {
+ clevel[j] = tlevel[j].x;
+ }
+ result[i] = clevel;
+ }
+ return result;
+ }
+ function computeTickMarks(scene) {
+ var axesOptions = scene.axesOptions;
+ var glRange = scene.glplot.axesPixels;
+ var sceneLayout = scene.fullSceneLayout;
+ var ticks = [[], [], []];
+ for (var i = 0; i < 3; ++i) {
+ var axes = sceneLayout[AXES_NAMES[i]];
+ axes._length = (glRange[i].hi - glRange[i].lo) * glRange[i].pixelsPerDataUnit / scene.dataScale[i];
+ if (Math.abs(axes._length) === Infinity || isNaN(axes._length)) {
+ ticks[i] = [];
+ } else {
+ axes._input_range = axes.range.slice();
+ axes.range[0] = glRange[i].lo / scene.dataScale[i];
+ axes.range[1] = glRange[i].hi / scene.dataScale[i];
+ axes._m = 1 / (scene.dataScale[i] * glRange[i].pixelsPerDataUnit);
+ if (axes.range[0] === axes.range[1]) {
+ axes.range[0] -= 1;
+ axes.range[1] += 1;
+ }
+ var tickModeCached = axes.tickmode;
+ if (axes.tickmode === "auto") {
+ axes.tickmode = "linear";
+ var nticks = axes.nticks || Lib.constrain(axes._length / 40, 4, 9);
+ Axes.autoTicks(axes, Math.abs(axes.range[1] - axes.range[0]) / nticks);
+ }
+ var dataTicks = Axes.calcTicks(axes, { msUTC: true });
+ for (var j = 0; j < dataTicks.length; ++j) {
+ dataTicks[j].x = dataTicks[j].x * scene.dataScale[i];
+ if (axes.type === "date") {
+ dataTicks[j].text = dataTicks[j].text.replace(/\
/g, " ");
+ }
+ }
+ ticks[i] = dataTicks;
+ axes.tickmode = tickModeCached;
+ }
+ }
+ axesOptions.ticks = ticks;
+ for (var i = 0; i < 3; ++i) {
+ centerPoint[i] = 0.5 * (scene.glplot.bounds[0][i] + scene.glplot.bounds[1][i]);
+ for (var j = 0; j < 2; ++j) {
+ axesOptions.bounds[j][i] = scene.glplot.bounds[j][i];
+ }
+ }
+ scene.contourLevels = contourLevelsFromTicks(ticks);
+ }
+ }
+ });
+
+ // src/plots/gl3d/scene.js
+ var require_scene = __commonJS({
+ "src/plots/gl3d/scene.js"(exports, module) {
+ "use strict";
+ var glPlot3d = require_stackgl_modules().gl_plot3d;
+ var createCamera = glPlot3d.createCamera;
+ var createPlot = glPlot3d.createScene;
+ var getContext = require_webgl_context();
+ var passiveSupported = require_has_passive_events();
+ var Registry = require_registry();
+ var Lib = require_lib();
+ var preserveDrawingBuffer = Lib.preserveDrawingBuffer();
+ var Axes = require_axes();
+ var Fx = require_fx();
+ var str2RGBAarray = require_str2rgbarray();
+ var showNoWebGlMsg = require_show_no_webgl_msg();
+ var project = require_project();
+ var createAxesOptions = require_convert3();
+ var createSpikeOptions = require_spikes();
+ var computeTickMarks = require_tick_marks();
+ var applyAutorangeOptions = require_autorange().applyAutorangeOptions;
+ var STATIC_CANVAS;
+ var STATIC_CONTEXT;
+ var tabletmode = false;
+ function Scene(options, fullLayout) {
+ var sceneContainer = document.createElement("div");
+ var plotContainer = options.container;
+ this.graphDiv = options.graphDiv;
+ var svgContainer = document.createElementNS(
+ "http://www.w3.org/2000/svg",
+ "svg"
+ );
+ svgContainer.style.position = "absolute";
+ svgContainer.style.top = svgContainer.style.left = "0px";
+ svgContainer.style.width = svgContainer.style.height = "100%";
+ svgContainer.style["z-index"] = 20;
+ svgContainer.style["pointer-events"] = "none";
+ sceneContainer.appendChild(svgContainer);
+ this.svgContainer = svgContainer;
+ sceneContainer.id = options.id;
+ sceneContainer.style.position = "absolute";
+ sceneContainer.style.top = sceneContainer.style.left = "0px";
+ sceneContainer.style.width = sceneContainer.style.height = "100%";
+ plotContainer.appendChild(sceneContainer);
+ this.fullLayout = fullLayout;
+ this.id = options.id || "scene";
+ this.fullSceneLayout = fullLayout[this.id];
+ this.plotArgs = [[], {}, {}];
+ this.axesOptions = createAxesOptions(fullLayout, fullLayout[this.id]);
+ this.spikeOptions = createSpikeOptions(fullLayout[this.id]);
+ this.container = sceneContainer;
+ this.staticMode = !!options.staticPlot;
+ this.pixelRatio = this.pixelRatio || options.plotGlPixelRatio || 2;
+ this.dataScale = [1, 1, 1];
+ this.contourLevels = [[], [], []];
+ this.convertAnnotations = Registry.getComponentMethod("annotations3d", "convert");
+ this.drawAnnotations = Registry.getComponentMethod("annotations3d", "draw");
+ this.initializeGLPlot();
+ }
+ var proto = Scene.prototype;
+ proto.prepareOptions = function() {
+ var scene = this;
+ var opts = {
+ canvas: scene.canvas,
+ gl: scene.gl,
+ glOptions: {
+ preserveDrawingBuffer,
+ premultipliedAlpha: true,
+ antialias: true
+ },
+ container: scene.container,
+ axes: scene.axesOptions,
+ spikes: scene.spikeOptions,
+ pickRadius: 10,
+ snapToData: true,
+ autoScale: true,
+ autoBounds: false,
+ cameraObject: scene.camera,
+ pixelRatio: scene.pixelRatio
+ };
+ if (scene.staticMode) {
+ if (!STATIC_CONTEXT) {
+ STATIC_CANVAS = document.createElement("canvas");
+ STATIC_CONTEXT = getContext({
+ canvas: STATIC_CANVAS,
+ preserveDrawingBuffer: true,
+ premultipliedAlpha: true,
+ antialias: true
+ });
+ if (!STATIC_CONTEXT) {
+ throw new Error("error creating static canvas/context for image server");
+ }
+ }
+ opts.gl = STATIC_CONTEXT;
+ opts.canvas = STATIC_CANVAS;
+ }
+ return opts;
+ };
+ var firstInit = true;
+ proto.tryCreatePlot = function() {
+ var scene = this;
+ var opts = scene.prepareOptions();
+ var success = true;
+ try {
+ scene.glplot = createPlot(opts);
+ } catch (e) {
+ if (scene.staticMode || !firstInit || preserveDrawingBuffer) {
+ success = false;
+ } else {
+ Lib.warn([
+ "webgl setup failed possibly due to",
+ "false preserveDrawingBuffer config.",
+ "The mobile/tablet device may not be detected by is-mobile module.",
+ "Enabling preserveDrawingBuffer in second attempt to create webgl scene..."
+ ].join(" "));
+ try {
+ preserveDrawingBuffer = opts.glOptions.preserveDrawingBuffer = true;
+ scene.glplot = createPlot(opts);
+ } catch (e2) {
+ preserveDrawingBuffer = opts.glOptions.preserveDrawingBuffer = false;
+ success = false;
+ }
+ }
+ }
+ firstInit = false;
+ return success;
+ };
+ proto.initializeGLCamera = function() {
+ var scene = this;
+ var cameraData = scene.fullSceneLayout.camera;
+ var isOrtho = cameraData.projection.type === "orthographic";
+ scene.camera = createCamera(scene.container, {
+ center: [cameraData.center.x, cameraData.center.y, cameraData.center.z],
+ eye: [cameraData.eye.x, cameraData.eye.y, cameraData.eye.z],
+ up: [cameraData.up.x, cameraData.up.y, cameraData.up.z],
+ _ortho: isOrtho,
+ zoomMin: 0.01,
+ zoomMax: 100,
+ mode: "orbit"
+ });
+ };
+ proto.initializeGLPlot = function() {
+ var scene = this;
+ scene.initializeGLCamera();
+ var success = scene.tryCreatePlot();
+ if (!success) return showNoWebGlMsg(scene);
+ scene.traces = {};
+ scene.make4thDimension();
+ var gd = scene.graphDiv;
+ var layout = gd.layout;
+ var makeUpdate = function() {
+ var update = {};
+ if (scene.isCameraChanged(layout)) {
+ update[scene.id + ".camera"] = scene.getCamera();
+ }
+ if (scene.isAspectChanged(layout)) {
+ update[scene.id + ".aspectratio"] = scene.glplot.getAspectratio();
+ if (layout[scene.id].aspectmode !== "manual") {
+ scene.fullSceneLayout.aspectmode = layout[scene.id].aspectmode = update[scene.id + ".aspectmode"] = "manual";
+ }
+ }
+ return update;
+ };
+ var relayoutCallback = function(scene2) {
+ if (scene2.fullSceneLayout.dragmode === false) return;
+ var update = makeUpdate();
+ scene2.saveLayout(layout);
+ scene2.graphDiv.emit("plotly_relayout", update);
+ };
+ if (scene.glplot.canvas) {
+ scene.glplot.canvas.addEventListener("mouseup", function() {
+ relayoutCallback(scene);
+ });
+ scene.glplot.canvas.addEventListener("touchstart", function() {
+ tabletmode = true;
+ });
+ scene.glplot.canvas.addEventListener("wheel", function(e) {
+ if (gd._context._scrollZoom.gl3d) {
+ if (scene.camera._ortho) {
+ var s = e.deltaX > e.deltaY ? 1.1 : 1 / 1.1;
+ var o = scene.glplot.getAspectratio();
+ scene.glplot.setAspectratio({
+ x: s * o.x,
+ y: s * o.y,
+ z: s * o.z
+ });
+ }
+ relayoutCallback(scene);
+ }
+ }, passiveSupported ? { passive: false } : false);
+ scene.glplot.canvas.addEventListener("mousemove", function() {
+ if (scene.fullSceneLayout.dragmode === false) return;
+ if (scene.camera.mouseListener.buttons === 0) return;
+ var update = makeUpdate();
+ scene.graphDiv.emit("plotly_relayouting", update);
+ });
+ if (!scene.staticMode) {
+ scene.glplot.canvas.addEventListener("webglcontextlost", function(event) {
+ if (gd && gd.emit) {
+ gd.emit("plotly_webglcontextlost", {
+ event,
+ layer: scene.id
+ });
+ }
+ }, false);
+ }
+ }
+ scene.glplot.oncontextloss = function() {
+ scene.recoverContext();
+ };
+ scene.glplot.onrender = function() {
+ scene.render();
+ };
+ return true;
+ };
+ proto.render = function() {
+ var scene = this;
+ var gd = scene.graphDiv;
+ var trace;
+ var svgContainer = scene.svgContainer;
+ var clientRect = scene.container.getBoundingClientRect();
+ gd._fullLayout._calcInverseTransform(gd);
+ var scaleX = gd._fullLayout._invScaleX;
+ var scaleY = gd._fullLayout._invScaleY;
+ var width = clientRect.width * scaleX;
+ var height = clientRect.height * scaleY;
+ svgContainer.setAttributeNS(null, "viewBox", "0 0 " + width + " " + height);
+ svgContainer.setAttributeNS(null, "width", width);
+ svgContainer.setAttributeNS(null, "height", height);
+ computeTickMarks(scene);
+ scene.glplot.axes.update(scene.axesOptions);
+ var keys = Object.keys(scene.traces);
+ var lastPicked = null;
+ var selection = scene.glplot.selection;
+ for (var i = 0; i < keys.length; ++i) {
+ trace = scene.traces[keys[i]];
+ if (trace.data.hoverinfo !== "skip" && trace.handlePick(selection)) {
+ lastPicked = trace;
+ }
+ if (trace.setContourLevels) trace.setContourLevels();
+ }
+ function formatter(axLetter, val, hoverformat) {
+ var ax = scene.fullSceneLayout[axLetter + "axis"];
+ if (ax.type !== "log") {
+ val = ax.d2l(val);
+ }
+ return Axes.hoverLabelText(ax, val, hoverformat);
+ }
+ if (lastPicked !== null) {
+ var pdata = project(scene.glplot.cameraParams, selection.dataCoordinate);
+ trace = lastPicked.data;
+ var traceNow = gd._fullData[trace.index];
+ var ptNumber = selection.index;
+ var labels = {
+ xLabel: formatter("x", selection.traceCoordinate[0], trace.xhoverformat),
+ yLabel: formatter("y", selection.traceCoordinate[1], trace.yhoverformat),
+ zLabel: formatter("z", selection.traceCoordinate[2], trace.zhoverformat)
+ };
+ var hoverinfo = Fx.castHoverinfo(traceNow, scene.fullLayout, ptNumber);
+ var hoverinfoParts = (hoverinfo || "").split("+");
+ var isHoverinfoAll = hoverinfo && hoverinfo === "all";
+ if (!traceNow.hovertemplate && !isHoverinfoAll) {
+ if (hoverinfoParts.indexOf("x") === -1) labels.xLabel = void 0;
+ if (hoverinfoParts.indexOf("y") === -1) labels.yLabel = void 0;
+ if (hoverinfoParts.indexOf("z") === -1) labels.zLabel = void 0;
+ if (hoverinfoParts.indexOf("text") === -1) selection.textLabel = void 0;
+ if (hoverinfoParts.indexOf("name") === -1) lastPicked.name = void 0;
+ }
+ var tx;
+ var vectorTx = [];
+ if (trace.type === "cone" || trace.type === "streamtube") {
+ labels.uLabel = formatter("x", selection.traceCoordinate[3], trace.uhoverformat);
+ if (isHoverinfoAll || hoverinfoParts.indexOf("u") !== -1) {
+ vectorTx.push("u: " + labels.uLabel);
+ }
+ labels.vLabel = formatter("y", selection.traceCoordinate[4], trace.vhoverformat);
+ if (isHoverinfoAll || hoverinfoParts.indexOf("v") !== -1) {
+ vectorTx.push("v: " + labels.vLabel);
+ }
+ labels.wLabel = formatter("z", selection.traceCoordinate[5], trace.whoverformat);
+ if (isHoverinfoAll || hoverinfoParts.indexOf("w") !== -1) {
+ vectorTx.push("w: " + labels.wLabel);
+ }
+ labels.normLabel = selection.traceCoordinate[6].toPrecision(3);
+ if (isHoverinfoAll || hoverinfoParts.indexOf("norm") !== -1) {
+ vectorTx.push("norm: " + labels.normLabel);
+ }
+ if (trace.type === "streamtube") {
+ labels.divergenceLabel = selection.traceCoordinate[7].toPrecision(3);
+ if (isHoverinfoAll || hoverinfoParts.indexOf("divergence") !== -1) {
+ vectorTx.push("divergence: " + labels.divergenceLabel);
+ }
+ }
+ if (selection.textLabel) {
+ vectorTx.push(selection.textLabel);
+ }
+ tx = vectorTx.join("
");
+ } else if (trace.type === "isosurface" || trace.type === "volume") {
+ labels.valueLabel = Axes.hoverLabelText(scene._mockAxis, scene._mockAxis.d2l(selection.traceCoordinate[3]), trace.valuehoverformat);
+ vectorTx.push("value: " + labels.valueLabel);
+ if (selection.textLabel) {
+ vectorTx.push(selection.textLabel);
+ }
+ tx = vectorTx.join("
");
+ } else {
+ tx = selection.textLabel;
+ }
+ var pointData = {
+ x: selection.traceCoordinate[0],
+ y: selection.traceCoordinate[1],
+ z: selection.traceCoordinate[2],
+ data: traceNow._input,
+ fullData: traceNow,
+ curveNumber: traceNow.index,
+ pointNumber: ptNumber
+ };
+ Fx.appendArrayPointValue(pointData, traceNow, ptNumber);
+ if (trace._module.eventData) {
+ pointData = traceNow._module.eventData(pointData, selection, traceNow, {}, ptNumber);
+ }
+ var eventData = { points: [pointData] };
+ if (scene.fullSceneLayout.hovermode) {
+ var bbox = [];
+ Fx.loneHover({
+ trace: traceNow,
+ x: (0.5 + 0.5 * pdata[0] / pdata[3]) * width,
+ y: (0.5 - 0.5 * pdata[1] / pdata[3]) * height,
+ xLabel: labels.xLabel,
+ yLabel: labels.yLabel,
+ zLabel: labels.zLabel,
+ text: tx,
+ name: lastPicked.name,
+ color: Fx.castHoverOption(traceNow, ptNumber, "bgcolor") || lastPicked.color,
+ borderColor: Fx.castHoverOption(traceNow, ptNumber, "bordercolor"),
+ fontFamily: Fx.castHoverOption(traceNow, ptNumber, "font.family"),
+ fontSize: Fx.castHoverOption(traceNow, ptNumber, "font.size"),
+ fontColor: Fx.castHoverOption(traceNow, ptNumber, "font.color"),
+ nameLength: Fx.castHoverOption(traceNow, ptNumber, "namelength"),
+ textAlign: Fx.castHoverOption(traceNow, ptNumber, "align"),
+ hovertemplate: Lib.castOption(traceNow, ptNumber, "hovertemplate"),
+ hovertemplateLabels: Lib.extendFlat({}, pointData, labels),
+ eventData: [pointData]
+ }, {
+ container: svgContainer,
+ gd,
+ inOut_bbox: bbox
+ });
+ pointData.bbox = bbox[0];
+ }
+ if (selection.distance < 5 && (selection.buttons || tabletmode)) {
+ gd.emit("plotly_click", eventData);
+ } else {
+ gd.emit("plotly_hover", eventData);
+ }
+ this.oldEventData = eventData;
+ } else {
+ Fx.loneUnhover(svgContainer);
+ if (this.oldEventData) gd.emit("plotly_unhover", this.oldEventData);
+ this.oldEventData = void 0;
+ }
+ scene.drawAnnotations(scene);
+ };
+ proto.recoverContext = function() {
+ var scene = this;
+ scene.glplot.dispose();
+ var tryRecover = function() {
+ if (scene.glplot.gl.isContextLost()) {
+ requestAnimationFrame(tryRecover);
+ return;
+ }
+ if (!scene.initializeGLPlot()) {
+ Lib.error("Catastrophic and unrecoverable WebGL error. Context lost.");
+ return;
+ }
+ scene.plot.apply(scene, scene.plotArgs);
+ };
+ requestAnimationFrame(tryRecover);
+ };
+ var axisProperties = ["xaxis", "yaxis", "zaxis"];
+ function computeTraceBounds(scene, trace, bounds) {
+ var fullSceneLayout = scene.fullSceneLayout;
+ for (var d = 0; d < 3; d++) {
+ var axisName = axisProperties[d];
+ var axLetter = axisName.charAt(0);
+ var ax = fullSceneLayout[axisName];
+ var coords = trace[axLetter];
+ var calendar = trace[axLetter + "calendar"];
+ var len = trace["_" + axLetter + "length"];
+ if (!Lib.isArrayOrTypedArray(coords)) {
+ bounds[0][d] = Math.min(bounds[0][d], 0);
+ bounds[1][d] = Math.max(bounds[1][d], len - 1);
+ } else {
+ var v;
+ for (var i = 0; i < (len || coords.length); i++) {
+ if (Lib.isArrayOrTypedArray(coords[i])) {
+ for (var j = 0; j < coords[i].length; ++j) {
+ v = ax.d2l(coords[i][j], 0, calendar);
+ if (!isNaN(v) && isFinite(v)) {
+ bounds[0][d] = Math.min(bounds[0][d], v);
+ bounds[1][d] = Math.max(bounds[1][d], v);
+ }
+ }
+ } else {
+ v = ax.d2l(coords[i], 0, calendar);
+ if (!isNaN(v) && isFinite(v)) {
+ bounds[0][d] = Math.min(bounds[0][d], v);
+ bounds[1][d] = Math.max(bounds[1][d], v);
+ }
+ }
+ }
+ }
+ }
+ }
+ function computeAnnotationBounds(scene, bounds) {
+ var fullSceneLayout = scene.fullSceneLayout;
+ var annotations = fullSceneLayout.annotations || [];
+ for (var d = 0; d < 3; d++) {
+ var axisName = axisProperties[d];
+ var axLetter = axisName.charAt(0);
+ var ax = fullSceneLayout[axisName];
+ for (var j = 0; j < annotations.length; j++) {
+ var ann = annotations[j];
+ if (ann.visible) {
+ var pos = ax.r2l(ann[axLetter]);
+ if (!isNaN(pos) && isFinite(pos)) {
+ bounds[0][d] = Math.min(bounds[0][d], pos);
+ bounds[1][d] = Math.max(bounds[1][d], pos);
+ }
+ }
+ }
+ }
+ }
+ proto.plot = function(sceneData, fullLayout, layout) {
+ var scene = this;
+ scene.plotArgs = [sceneData, fullLayout, layout];
+ if (scene.glplot.contextLost) return;
+ var data, trace;
+ var i, j, axis, axisType;
+ var fullSceneLayout = fullLayout[scene.id];
+ var sceneLayout = layout[scene.id];
+ scene.fullLayout = fullLayout;
+ scene.fullSceneLayout = fullSceneLayout;
+ scene.axesOptions.merge(fullLayout, fullSceneLayout);
+ scene.spikeOptions.merge(fullSceneLayout);
+ scene.setViewport(fullSceneLayout);
+ scene.updateFx(fullSceneLayout.dragmode, fullSceneLayout.hovermode);
+ scene.camera.enableWheel = scene.graphDiv._context._scrollZoom.gl3d;
+ scene.glplot.setClearColor(str2RGBAarray(fullSceneLayout.bgcolor));
+ scene.setConvert(axis);
+ if (!sceneData) sceneData = [];
+ else if (!Array.isArray(sceneData)) sceneData = [sceneData];
+ var dataBounds = [
+ [Infinity, Infinity, Infinity],
+ [-Infinity, -Infinity, -Infinity]
+ ];
+ for (i = 0; i < sceneData.length; ++i) {
+ data = sceneData[i];
+ if (data.visible !== true || data._length === 0) continue;
+ computeTraceBounds(this, data, dataBounds);
+ }
+ computeAnnotationBounds(this, dataBounds);
+ var dataScale = [1, 1, 1];
+ for (j = 0; j < 3; ++j) {
+ if (dataBounds[1][j] === dataBounds[0][j]) {
+ dataScale[j] = 1;
+ } else {
+ dataScale[j] = 1 / (dataBounds[1][j] - dataBounds[0][j]);
+ }
+ }
+ scene.dataScale = dataScale;
+ scene.convertAnnotations(this);
+ for (i = 0; i < sceneData.length; ++i) {
+ data = sceneData[i];
+ if (data.visible !== true || data._length === 0) {
+ continue;
+ }
+ trace = scene.traces[data.uid];
+ if (trace) {
+ if (trace.data.type === data.type) {
+ trace.update(data);
+ } else {
+ trace.dispose();
+ trace = data._module.plot(this, data);
+ scene.traces[data.uid] = trace;
+ }
+ } else {
+ trace = data._module.plot(this, data);
+ scene.traces[data.uid] = trace;
+ }
+ trace.name = data.name;
+ }
+ var traceIds = Object.keys(scene.traces);
+ traceIdLoop:
+ for (i = 0; i < traceIds.length; ++i) {
+ for (j = 0; j < sceneData.length; ++j) {
+ if (sceneData[j].uid === traceIds[i] && (sceneData[j].visible === true && sceneData[j]._length !== 0)) {
+ continue traceIdLoop;
+ }
+ }
+ trace = scene.traces[traceIds[i]];
+ trace.dispose();
+ delete scene.traces[traceIds[i]];
+ }
+ scene.glplot.objects.sort(function(a, b) {
+ return a._trace.data.index - b._trace.data.index;
+ });
+ var sceneBounds = [[0, 0, 0], [0, 0, 0]];
+ var axisDataRange = [];
+ var axisTypeRatios = {};
+ for (i = 0; i < 3; ++i) {
+ axis = fullSceneLayout[axisProperties[i]];
+ axisType = axis.type;
+ if (axisType in axisTypeRatios) {
+ axisTypeRatios[axisType].acc *= dataScale[i];
+ axisTypeRatios[axisType].count += 1;
+ } else {
+ axisTypeRatios[axisType] = {
+ acc: dataScale[i],
+ count: 1
+ };
+ }
+ var range;
+ if (axis.autorange) {
+ sceneBounds[0][i] = Infinity;
+ sceneBounds[1][i] = -Infinity;
+ var objects = scene.glplot.objects;
+ var annotations = scene.fullSceneLayout.annotations || [];
+ var axLetter = axis._name.charAt(0);
+ for (j = 0; j < objects.length; j++) {
+ var obj = objects[j];
+ var objBounds = obj.bounds;
+ var pad = obj._trace.data._pad || 0;
+ if (obj.constructor.name === "ErrorBars" && axis._lowerLogErrorBound) {
+ sceneBounds[0][i] = Math.min(sceneBounds[0][i], axis._lowerLogErrorBound);
+ } else {
+ sceneBounds[0][i] = Math.min(sceneBounds[0][i], objBounds[0][i] / dataScale[i] - pad);
+ }
+ sceneBounds[1][i] = Math.max(sceneBounds[1][i], objBounds[1][i] / dataScale[i] + pad);
+ }
+ for (j = 0; j < annotations.length; j++) {
+ var ann = annotations[j];
+ if (ann.visible) {
+ var pos = axis.r2l(ann[axLetter]);
+ sceneBounds[0][i] = Math.min(sceneBounds[0][i], pos);
+ sceneBounds[1][i] = Math.max(sceneBounds[1][i], pos);
+ }
+ }
+ if ("rangemode" in axis && axis.rangemode === "tozero") {
+ sceneBounds[0][i] = Math.min(sceneBounds[0][i], 0);
+ sceneBounds[1][i] = Math.max(sceneBounds[1][i], 0);
+ }
+ if (sceneBounds[0][i] > sceneBounds[1][i]) {
+ sceneBounds[0][i] = -1;
+ sceneBounds[1][i] = 1;
+ } else {
+ var d = sceneBounds[1][i] - sceneBounds[0][i];
+ sceneBounds[0][i] -= d / 32;
+ sceneBounds[1][i] += d / 32;
+ }
+ range = [
+ sceneBounds[0][i],
+ sceneBounds[1][i]
+ ];
+ range = applyAutorangeOptions(range, axis);
+ sceneBounds[0][i] = range[0];
+ sceneBounds[1][i] = range[1];
+ if (axis.isReversed()) {
+ var tmp = sceneBounds[0][i];
+ sceneBounds[0][i] = sceneBounds[1][i];
+ sceneBounds[1][i] = tmp;
+ }
+ } else {
+ range = axis.range;
+ sceneBounds[0][i] = axis.r2l(range[0]);
+ sceneBounds[1][i] = axis.r2l(range[1]);
+ }
+ if (sceneBounds[0][i] === sceneBounds[1][i]) {
+ sceneBounds[0][i] -= 1;
+ sceneBounds[1][i] += 1;
+ }
+ axisDataRange[i] = sceneBounds[1][i] - sceneBounds[0][i];
+ axis.range = [
+ sceneBounds[0][i],
+ sceneBounds[1][i]
+ ];
+ axis.limitRange();
+ scene.glplot.setBounds(i, {
+ min: axis.range[0] * dataScale[i],
+ max: axis.range[1] * dataScale[i]
+ });
+ }
+ var aspectRatio;
+ var aspectmode = fullSceneLayout.aspectmode;
+ if (aspectmode === "cube") {
+ aspectRatio = [1, 1, 1];
+ } else if (aspectmode === "manual") {
+ var userRatio = fullSceneLayout.aspectratio;
+ aspectRatio = [userRatio.x, userRatio.y, userRatio.z];
+ } else if (aspectmode === "auto" || aspectmode === "data") {
+ var axesScaleRatio = [1, 1, 1];
+ for (i = 0; i < 3; ++i) {
+ axis = fullSceneLayout[axisProperties[i]];
+ axisType = axis.type;
+ var axisRatio = axisTypeRatios[axisType];
+ axesScaleRatio[i] = Math.pow(axisRatio.acc, 1 / axisRatio.count) / dataScale[i];
+ }
+ if (aspectmode === "data") {
+ aspectRatio = axesScaleRatio;
+ } else {
+ if (Math.max.apply(null, axesScaleRatio) / Math.min.apply(null, axesScaleRatio) <= 4) {
+ aspectRatio = axesScaleRatio;
+ } else {
+ aspectRatio = [1, 1, 1];
+ }
+ }
+ } else {
+ throw new Error("scene.js aspectRatio was not one of the enumerated types");
+ }
+ fullSceneLayout.aspectratio.x = sceneLayout.aspectratio.x = aspectRatio[0];
+ fullSceneLayout.aspectratio.y = sceneLayout.aspectratio.y = aspectRatio[1];
+ fullSceneLayout.aspectratio.z = sceneLayout.aspectratio.z = aspectRatio[2];
+ scene.glplot.setAspectratio(fullSceneLayout.aspectratio);
+ if (!scene.viewInitial.aspectratio) {
+ scene.viewInitial.aspectratio = {
+ x: fullSceneLayout.aspectratio.x,
+ y: fullSceneLayout.aspectratio.y,
+ z: fullSceneLayout.aspectratio.z
+ };
+ }
+ if (!scene.viewInitial.aspectmode) {
+ scene.viewInitial.aspectmode = fullSceneLayout.aspectmode;
+ }
+ var domain = fullSceneLayout.domain || null;
+ var size = fullLayout._size || null;
+ if (domain && size) {
+ var containerStyle = scene.container.style;
+ containerStyle.position = "absolute";
+ containerStyle.left = size.l + domain.x[0] * size.w + "px";
+ containerStyle.top = size.t + (1 - domain.y[1]) * size.h + "px";
+ containerStyle.width = size.w * (domain.x[1] - domain.x[0]) + "px";
+ containerStyle.height = size.h * (domain.y[1] - domain.y[0]) + "px";
+ }
+ scene.glplot.redraw();
+ };
+ proto.destroy = function() {
+ var scene = this;
+ if (!scene.glplot) return;
+ scene.camera.mouseListener.enabled = false;
+ scene.container.removeEventListener("wheel", scene.camera.wheelListener);
+ scene.camera = null;
+ scene.glplot.dispose();
+ scene.container.parentNode.removeChild(scene.container);
+ scene.glplot = null;
+ };
+ function getCameraArrays(camera) {
+ return [
+ [camera.eye.x, camera.eye.y, camera.eye.z],
+ [camera.center.x, camera.center.y, camera.center.z],
+ [camera.up.x, camera.up.y, camera.up.z]
+ ];
+ }
+ function getLayoutCamera(camera) {
+ return {
+ up: { x: camera.up[0], y: camera.up[1], z: camera.up[2] },
+ center: { x: camera.center[0], y: camera.center[1], z: camera.center[2] },
+ eye: { x: camera.eye[0], y: camera.eye[1], z: camera.eye[2] },
+ projection: { type: camera._ortho === true ? "orthographic" : "perspective" }
+ };
+ }
+ proto.getCamera = function() {
+ var scene = this;
+ scene.camera.view.recalcMatrix(scene.camera.view.lastT());
+ return getLayoutCamera(scene.camera);
+ };
+ proto.setViewport = function(sceneLayout) {
+ var scene = this;
+ var cameraData = sceneLayout.camera;
+ scene.camera.lookAt.apply(this, getCameraArrays(cameraData));
+ scene.glplot.setAspectratio(sceneLayout.aspectratio);
+ var newOrtho = cameraData.projection.type === "orthographic";
+ var oldOrtho = scene.camera._ortho;
+ if (newOrtho !== oldOrtho) {
+ scene.glplot.redraw();
+ scene.glplot.clearRGBA();
+ scene.glplot.dispose();
+ scene.initializeGLPlot();
+ }
+ };
+ proto.isCameraChanged = function(layout) {
+ var scene = this;
+ var cameraData = scene.getCamera();
+ var cameraNestedProp = Lib.nestedProperty(layout, scene.id + ".camera");
+ var cameraDataLastSave = cameraNestedProp.get();
+ function same(x, y, i2, j2) {
+ var vectors = ["up", "center", "eye"];
+ var components = ["x", "y", "z"];
+ return y[vectors[i2]] && x[vectors[i2]][components[j2]] === y[vectors[i2]][components[j2]];
+ }
+ var changed = false;
+ if (cameraDataLastSave === void 0) {
+ changed = true;
+ } else {
+ for (var i = 0; i < 3; i++) {
+ for (var j = 0; j < 3; j++) {
+ if (!same(cameraData, cameraDataLastSave, i, j)) {
+ changed = true;
+ break;
+ }
+ }
+ }
+ if (!cameraDataLastSave.projection || cameraData.projection && cameraData.projection.type !== cameraDataLastSave.projection.type) {
+ changed = true;
+ }
+ }
+ return changed;
+ };
+ proto.isAspectChanged = function(layout) {
+ var scene = this;
+ var aspectData = scene.glplot.getAspectratio();
+ var aspectNestedProp = Lib.nestedProperty(layout, scene.id + ".aspectratio");
+ var aspectDataLastSave = aspectNestedProp.get();
+ return aspectDataLastSave === void 0 || (aspectDataLastSave.x !== aspectData.x || aspectDataLastSave.y !== aspectData.y || aspectDataLastSave.z !== aspectData.z);
+ };
+ proto.saveLayout = function(layout) {
+ var scene = this;
+ var fullLayout = scene.fullLayout;
+ var cameraData;
+ var cameraNestedProp;
+ var cameraDataLastSave;
+ var aspectData;
+ var aspectNestedProp;
+ var aspectDataLastSave;
+ var cameraChanged = scene.isCameraChanged(layout);
+ var aspectChanged = scene.isAspectChanged(layout);
+ var hasChanged = cameraChanged || aspectChanged;
+ if (hasChanged) {
+ var preGUI = {};
+ if (cameraChanged) {
+ cameraData = scene.getCamera();
+ cameraNestedProp = Lib.nestedProperty(layout, scene.id + ".camera");
+ cameraDataLastSave = cameraNestedProp.get();
+ preGUI[scene.id + ".camera"] = cameraDataLastSave;
+ }
+ if (aspectChanged) {
+ aspectData = scene.glplot.getAspectratio();
+ aspectNestedProp = Lib.nestedProperty(layout, scene.id + ".aspectratio");
+ aspectDataLastSave = aspectNestedProp.get();
+ preGUI[scene.id + ".aspectratio"] = aspectDataLastSave;
+ }
+ Registry.call("_storeDirectGUIEdit", layout, fullLayout._preGUI, preGUI);
+ if (cameraChanged) {
+ cameraNestedProp.set(cameraData);
+ var cameraFullNP = Lib.nestedProperty(fullLayout, scene.id + ".camera");
+ cameraFullNP.set(cameraData);
+ }
+ if (aspectChanged) {
+ aspectNestedProp.set(aspectData);
+ var aspectFullNP = Lib.nestedProperty(fullLayout, scene.id + ".aspectratio");
+ aspectFullNP.set(aspectData);
+ scene.glplot.redraw();
+ }
+ }
+ return hasChanged;
+ };
+ proto.updateFx = function(dragmode, hovermode) {
+ var scene = this;
+ var camera = scene.camera;
+ if (camera) {
+ if (dragmode === "orbit") {
+ camera.mode = "orbit";
+ camera.keyBindingMode = "rotate";
+ } else if (dragmode === "turntable") {
+ camera.up = [0, 0, 1];
+ camera.mode = "turntable";
+ camera.keyBindingMode = "rotate";
+ var gd = scene.graphDiv;
+ var fullLayout = gd._fullLayout;
+ var fullCamera = scene.fullSceneLayout.camera;
+ var x = fullCamera.up.x;
+ var y = fullCamera.up.y;
+ var z = fullCamera.up.z;
+ if (z / Math.sqrt(x * x + y * y + z * z) < 0.999) {
+ var attr = scene.id + ".camera.up";
+ var zUp = { x: 0, y: 0, z: 1 };
+ var edits = {};
+ edits[attr] = zUp;
+ var layout = gd.layout;
+ Registry.call("_storeDirectGUIEdit", layout, fullLayout._preGUI, edits);
+ fullCamera.up = zUp;
+ Lib.nestedProperty(layout, attr).set(zUp);
+ }
+ } else {
+ camera.keyBindingMode = dragmode;
+ }
+ }
+ scene.fullSceneLayout.hovermode = hovermode;
+ };
+ function flipPixels(pixels, w, h) {
+ for (var i = 0, q = h - 1; i < q; ++i, --q) {
+ for (var j = 0; j < w; ++j) {
+ for (var k = 0; k < 4; ++k) {
+ var a = 4 * (w * i + j) + k;
+ var b = 4 * (w * q + j) + k;
+ var tmp = pixels[a];
+ pixels[a] = pixels[b];
+ pixels[b] = tmp;
+ }
+ }
+ }
+ }
+ function correctRGB(pixels, w, h) {
+ for (var i = 0; i < h; ++i) {
+ for (var j = 0; j < w; ++j) {
+ var k = 4 * (w * i + j);
+ var a = pixels[k + 3];
+ if (a > 0) {
+ var q = 255 / a;
+ for (var l = 0; l < 3; ++l) {
+ pixels[k + l] = Math.min(q * pixels[k + l], 255);
+ }
+ }
+ }
+ }
+ }
+ proto.toImage = function(format) {
+ var scene = this;
+ if (!format) format = "png";
+ if (scene.staticMode) scene.container.appendChild(STATIC_CANVAS);
+ scene.glplot.redraw();
+ var gl2 = scene.glplot.gl;
+ var w = gl2.drawingBufferWidth;
+ var h = gl2.drawingBufferHeight;
+ gl2.bindFramebuffer(gl2.FRAMEBUFFER, null);
+ var pixels = new Uint8Array(w * h * 4);
+ gl2.readPixels(0, 0, w, h, gl2.RGBA, gl2.UNSIGNED_BYTE, pixels);
+ flipPixels(pixels, w, h);
+ correctRGB(pixels, w, h);
+ var canvas = document.createElement("canvas");
+ canvas.width = w;
+ canvas.height = h;
+ var context = canvas.getContext("2d", { willReadFrequently: true });
+ var imageData = context.createImageData(w, h);
+ imageData.data.set(pixels);
+ context.putImageData(imageData, 0, 0);
+ var dataURL;
+ switch (format) {
+ case "jpeg":
+ dataURL = canvas.toDataURL("image/jpeg");
+ break;
+ case "webp":
+ dataURL = canvas.toDataURL("image/webp");
+ break;
+ default:
+ dataURL = canvas.toDataURL("image/png");
+ }
+ if (scene.staticMode) scene.container.removeChild(STATIC_CANVAS);
+ return dataURL;
+ };
+ proto.setConvert = function() {
+ var scene = this;
+ for (var i = 0; i < 3; i++) {
+ var ax = scene.fullSceneLayout[axisProperties[i]];
+ Axes.setConvert(ax, scene.fullLayout);
+ ax.setScale = Lib.noop;
+ }
+ };
+ proto.make4thDimension = function() {
+ var scene = this;
+ var gd = scene.graphDiv;
+ var fullLayout = gd._fullLayout;
+ scene._mockAxis = {
+ type: "linear",
+ showexponent: "all",
+ exponentformat: "B"
+ };
+ Axes.setConvert(scene._mockAxis, fullLayout);
+ };
+ module.exports = Scene;
+ }
+ });
+
+ // src/plots/gl3d/layout/attributes.js
+ var require_attributes41 = __commonJS({
+ "src/plots/gl3d/layout/attributes.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ scene: {
+ valType: "subplotid",
+ dflt: "scene",
+ editType: "calc+clearAxisTypes"
+ }
+ };
+ }
+ });
+
+ // src/plots/gl3d/layout/axis_attributes.js
+ var require_axis_attributes = __commonJS({
+ "src/plots/gl3d/layout/axis_attributes.js"(exports, module) {
+ "use strict";
+ var Color2 = require_color();
+ var axesAttrs = require_layout_attributes4();
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ module.exports = overrideAll({
+ visible: axesAttrs.visible,
+ showspikes: {
+ valType: "boolean",
+ dflt: true
+ },
+ spikesides: {
+ valType: "boolean",
+ dflt: true
+ },
+ spikethickness: {
+ valType: "number",
+ min: 0,
+ dflt: 2
+ },
+ spikecolor: {
+ valType: "color",
+ dflt: Color2.defaultLine
+ },
+ showbackground: {
+ valType: "boolean",
+ dflt: false
+ },
+ backgroundcolor: {
+ valType: "color",
+ dflt: "rgba(204, 204, 204, 0.5)"
+ },
+ showaxeslabels: {
+ valType: "boolean",
+ dflt: true
+ },
+ color: axesAttrs.color,
+ categoryorder: axesAttrs.categoryorder,
+ categoryarray: axesAttrs.categoryarray,
+ title: {
+ text: axesAttrs.title.text,
+ font: axesAttrs.title.font
+ },
+ type: extendFlat({}, axesAttrs.type, {
+ values: ["-", "linear", "log", "date", "category"]
+ }),
+ autotypenumbers: axesAttrs.autotypenumbers,
+ autorange: axesAttrs.autorange,
+ autorangeoptions: {
+ minallowed: axesAttrs.autorangeoptions.minallowed,
+ maxallowed: axesAttrs.autorangeoptions.maxallowed,
+ clipmin: axesAttrs.autorangeoptions.clipmin,
+ clipmax: axesAttrs.autorangeoptions.clipmax,
+ include: axesAttrs.autorangeoptions.include,
+ editType: "plot"
+ },
+ rangemode: axesAttrs.rangemode,
+ minallowed: axesAttrs.minallowed,
+ maxallowed: axesAttrs.maxallowed,
+ range: extendFlat({}, axesAttrs.range, {
+ items: [
+ { valType: "any", editType: "plot", impliedEdits: { "^autorange": false } },
+ { valType: "any", editType: "plot", impliedEdits: { "^autorange": false } }
+ ],
+ anim: false
+ }),
+ // ticks
+ tickmode: axesAttrs.minor.tickmode,
+ nticks: axesAttrs.nticks,
+ tick0: axesAttrs.tick0,
+ dtick: axesAttrs.dtick,
+ tickvals: axesAttrs.tickvals,
+ ticktext: axesAttrs.ticktext,
+ ticks: axesAttrs.ticks,
+ mirror: axesAttrs.mirror,
+ ticklen: axesAttrs.ticklen,
+ tickwidth: axesAttrs.tickwidth,
+ tickcolor: axesAttrs.tickcolor,
+ showticklabels: axesAttrs.showticklabels,
+ labelalias: axesAttrs.labelalias,
+ tickfont: axesAttrs.tickfont,
+ tickangle: axesAttrs.tickangle,
+ tickprefix: axesAttrs.tickprefix,
+ showtickprefix: axesAttrs.showtickprefix,
+ ticksuffix: axesAttrs.ticksuffix,
+ showticksuffix: axesAttrs.showticksuffix,
+ showexponent: axesAttrs.showexponent,
+ exponentformat: axesAttrs.exponentformat,
+ minexponent: axesAttrs.minexponent,
+ separatethousands: axesAttrs.separatethousands,
+ tickformat: axesAttrs.tickformat,
+ tickformatstops: axesAttrs.tickformatstops,
+ hoverformat: axesAttrs.hoverformat,
+ // lines and grids
+ showline: axesAttrs.showline,
+ linecolor: axesAttrs.linecolor,
+ linewidth: axesAttrs.linewidth,
+ showgrid: axesAttrs.showgrid,
+ gridcolor: extendFlat(
+ {},
+ axesAttrs.gridcolor,
+ // shouldn't this be on-par with 2D?
+ { dflt: "rgb(204, 204, 204)" }
+ ),
+ gridwidth: axesAttrs.gridwidth,
+ zeroline: axesAttrs.zeroline,
+ zerolinecolor: axesAttrs.zerolinecolor,
+ zerolinewidth: axesAttrs.zerolinewidth
+ }, "plot", "from-root");
+ }
+ });
+
+ // src/plots/gl3d/layout/layout_attributes.js
+ var require_layout_attributes17 = __commonJS({
+ "src/plots/gl3d/layout/layout_attributes.js"(exports, module) {
+ "use strict";
+ var gl3dAxisAttrs = require_axis_attributes();
+ var domainAttrs = require_domain().attributes;
+ var extendFlat = require_extend().extendFlat;
+ var counterRegex = require_lib().counterRegex;
+ function makeCameraVector(x, y, z) {
+ return {
+ x: {
+ valType: "number",
+ dflt: x,
+ editType: "camera"
+ },
+ y: {
+ valType: "number",
+ dflt: y,
+ editType: "camera"
+ },
+ z: {
+ valType: "number",
+ dflt: z,
+ editType: "camera"
+ },
+ editType: "camera"
+ };
+ }
+ module.exports = {
+ _arrayAttrRegexps: [counterRegex("scene", ".annotations", true)],
+ bgcolor: {
+ valType: "color",
+ dflt: "rgba(0,0,0,0)",
+ editType: "plot"
+ },
+ camera: {
+ up: extendFlat(makeCameraVector(0, 0, 1), {}),
+ center: extendFlat(makeCameraVector(0, 0, 0), {}),
+ eye: extendFlat(makeCameraVector(1.25, 1.25, 1.25), {}),
+ projection: {
+ type: {
+ valType: "enumerated",
+ values: ["perspective", "orthographic"],
+ dflt: "perspective",
+ editType: "calc"
+ },
+ editType: "calc"
+ },
+ editType: "camera"
+ },
+ domain: domainAttrs({ name: "scene", editType: "plot" }),
+ aspectmode: {
+ valType: "enumerated",
+ values: ["auto", "cube", "data", "manual"],
+ dflt: "auto",
+ editType: "plot",
+ impliedEdits: {
+ "aspectratio.x": void 0,
+ "aspectratio.y": void 0,
+ "aspectratio.z": void 0
+ }
+ },
+ aspectratio: {
+ // must be positive (0's are coerced to 1)
+ x: {
+ valType: "number",
+ min: 0,
+ editType: "plot",
+ impliedEdits: { "^aspectmode": "manual" }
+ },
+ y: {
+ valType: "number",
+ min: 0,
+ editType: "plot",
+ impliedEdits: { "^aspectmode": "manual" }
+ },
+ z: {
+ valType: "number",
+ min: 0,
+ editType: "plot",
+ impliedEdits: { "^aspectmode": "manual" }
+ },
+ editType: "plot",
+ impliedEdits: { aspectmode: "manual" }
+ },
+ xaxis: gl3dAxisAttrs,
+ yaxis: gl3dAxisAttrs,
+ zaxis: gl3dAxisAttrs,
+ dragmode: {
+ valType: "enumerated",
+ values: ["orbit", "turntable", "zoom", "pan", false],
+ editType: "plot"
+ },
+ hovermode: {
+ valType: "enumerated",
+ values: ["closest", false],
+ dflt: "closest",
+ editType: "modebar"
+ },
+ uirevision: {
+ valType: "any",
+ editType: "none"
+ },
+ editType: "plot"
+ };
+ }
+ });
+
+ // src/plots/gl3d/layout/axis_defaults.js
+ var require_axis_defaults2 = __commonJS({
+ "src/plots/gl3d/layout/axis_defaults.js"(exports, module) {
+ "use strict";
+ var colorMix = require_tinycolor().mix;
+ var Lib = require_lib();
+ var Template = require_plot_template();
+ var layoutAttributes = require_axis_attributes();
+ var handleTypeDefaults = require_type_defaults();
+ var handleAxisDefaults = require_axis_defaults();
+ var axesNames = ["xaxis", "yaxis", "zaxis"];
+ var gridLightness = 100 * (204 - 68) / (255 - 68);
+ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) {
+ var containerIn, containerOut;
+ function coerce(attr, dflt) {
+ return Lib.coerce(containerIn, containerOut, layoutAttributes, attr, dflt);
+ }
+ for (var j = 0; j < axesNames.length; j++) {
+ var axName = axesNames[j];
+ containerIn = layoutIn[axName] || {};
+ containerOut = Template.newContainer(layoutOut, axName);
+ containerOut._id = axName[0] + options.scene;
+ containerOut._name = axName;
+ handleTypeDefaults(containerIn, containerOut, coerce, options);
+ handleAxisDefaults(
+ containerIn,
+ containerOut,
+ coerce,
+ {
+ font: options.font,
+ letter: axName[0],
+ data: options.data,
+ showGrid: true,
+ noAutotickangles: true,
+ noTicklabelindex: true,
+ noTickson: true,
+ noTicklabelmode: true,
+ noTicklabelshift: true,
+ noTicklabelstandoff: true,
+ noTicklabelstep: true,
+ noTicklabelposition: true,
+ noTicklabeloverflow: true,
+ noInsiderange: true,
+ bgColor: options.bgColor,
+ calendar: options.calendar
+ },
+ options.fullLayout
+ );
+ coerce("gridcolor", colorMix(containerOut.color, options.bgColor, gridLightness).toRgbString());
+ coerce("title.text", axName[0]);
+ containerOut.setScale = Lib.noop;
+ if (coerce("showspikes")) {
+ coerce("spikesides");
+ coerce("spikethickness");
+ coerce("spikecolor", containerOut.color);
+ }
+ coerce("showaxeslabels");
+ if (coerce("showbackground")) coerce("backgroundcolor");
+ }
+ };
+ }
+ });
+
+ // src/plots/gl3d/layout/defaults.js
+ var require_defaults37 = __commonJS({
+ "src/plots/gl3d/layout/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var Color2 = require_color();
+ var Registry = require_registry();
+ var handleSubplotDefaults = require_subplot_defaults();
+ var supplyGl3dAxisLayoutDefaults = require_axis_defaults2();
+ var layoutAttributes = require_layout_attributes17();
+ var getSubplotData = require_get_data().getSubplotData;
+ var GL3D = "gl3d";
+ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
+ var hasNon3D = layoutOut._basePlotModules.length > 1;
+ function getDfltFromLayout(attr) {
+ if (hasNon3D) return;
+ var isValid = Lib.validate(layoutIn[attr], layoutAttributes[attr]);
+ if (isValid) return layoutIn[attr];
+ }
+ handleSubplotDefaults(layoutIn, layoutOut, fullData, {
+ type: GL3D,
+ attributes: layoutAttributes,
+ handleDefaults: handleGl3dDefaults,
+ fullLayout: layoutOut,
+ font: layoutOut.font,
+ fullData,
+ getDfltFromLayout,
+ autotypenumbersDflt: layoutOut.autotypenumbers,
+ paper_bgcolor: layoutOut.paper_bgcolor,
+ calendar: layoutOut.calendar
+ });
+ };
+ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
+ var bgcolor = coerce("bgcolor");
+ var bgColorCombined = Color2.combine(bgcolor, opts.paper_bgcolor);
+ var cameraKeys = ["up", "center", "eye"];
+ for (var j = 0; j < cameraKeys.length; j++) {
+ coerce("camera." + cameraKeys[j] + ".x");
+ coerce("camera." + cameraKeys[j] + ".y");
+ coerce("camera." + cameraKeys[j] + ".z");
+ }
+ coerce("camera.projection.type");
+ var hasAspect = !!coerce("aspectratio.x") && !!coerce("aspectratio.y") && !!coerce("aspectratio.z");
+ var defaultAspectMode = hasAspect ? "manual" : "auto";
+ var aspectMode = coerce("aspectmode", defaultAspectMode);
+ if (!hasAspect) {
+ sceneLayoutIn.aspectratio = sceneLayoutOut.aspectratio = { x: 1, y: 1, z: 1 };
+ if (aspectMode === "manual") sceneLayoutOut.aspectmode = "auto";
+ sceneLayoutIn.aspectmode = sceneLayoutOut.aspectmode;
+ }
+ var fullGl3dData = getSubplotData(opts.fullData, GL3D, opts.id);
+ supplyGl3dAxisLayoutDefaults(sceneLayoutIn, sceneLayoutOut, {
+ font: opts.font,
+ scene: opts.id,
+ data: fullGl3dData,
+ bgColor: bgColorCombined,
+ calendar: opts.calendar,
+ autotypenumbersDflt: opts.autotypenumbersDflt,
+ fullLayout: opts.fullLayout
+ });
+ Registry.getComponentMethod("annotations3d", "handleDefaults")(
+ sceneLayoutIn,
+ sceneLayoutOut,
+ opts
+ );
+ var dragmode = opts.getDfltFromLayout("dragmode");
+ if (dragmode !== false) {
+ if (!dragmode) {
+ dragmode = "orbit";
+ if (sceneLayoutIn.camera && sceneLayoutIn.camera.up) {
+ var x = sceneLayoutIn.camera.up.x;
+ var y = sceneLayoutIn.camera.up.y;
+ var z = sceneLayoutIn.camera.up.z;
+ if (z !== 0) {
+ if (!x || !y || !z) {
+ dragmode = "turntable";
+ } else if (z / Math.sqrt(x * x + y * y + z * z) > 0.999) {
+ dragmode = "turntable";
+ }
+ }
+ } else {
+ dragmode = "turntable";
+ }
+ }
+ }
+ coerce("dragmode", dragmode);
+ coerce("hovermode", opts.getDfltFromLayout("hovermode"));
+ }
+ }
+ });
+
+ // src/plots/gl3d/index.js
+ var require_gl3d = __commonJS({
+ "src/plots/gl3d/index.js"(exports) {
+ "use strict";
+ var overrideAll = require_edit_types().overrideAll;
+ var fxAttrs = require_layout_attributes();
+ var Scene = require_scene();
+ var getSubplotData = require_get_data().getSubplotData;
+ var Lib = require_lib();
+ var xmlnsNamespaces = require_xmlns_namespaces();
+ var GL3D = "gl3d";
+ var SCENE = "scene";
+ exports.name = GL3D;
+ exports.attr = SCENE;
+ exports.idRoot = SCENE;
+ exports.idRegex = exports.attrRegex = Lib.counterRegex("scene");
+ exports.attributes = require_attributes41();
+ exports.layoutAttributes = require_layout_attributes17();
+ exports.baseLayoutAttrOverrides = overrideAll({
+ hoverlabel: fxAttrs.hoverlabel
+ }, "plot", "nested");
+ exports.supplyLayoutDefaults = require_defaults37();
+ exports.plot = function plot(gd) {
+ var fullLayout = gd._fullLayout;
+ var fullData = gd._fullData;
+ var sceneIds = fullLayout._subplots[GL3D];
+ for (var i = 0; i < sceneIds.length; i++) {
+ var sceneId = sceneIds[i];
+ var fullSceneData = getSubplotData(fullData, GL3D, sceneId);
+ var sceneLayout = fullLayout[sceneId];
+ var camera = sceneLayout.camera;
+ var scene = sceneLayout._scene;
+ if (!scene) {
+ scene = new Scene(
+ {
+ id: sceneId,
+ graphDiv: gd,
+ container: gd.querySelector(".gl-container"),
+ staticPlot: gd._context.staticPlot,
+ plotGlPixelRatio: gd._context.plotGlPixelRatio,
+ camera
+ },
+ fullLayout
+ );
+ sceneLayout._scene = scene;
+ }
+ if (!scene.viewInitial) {
+ scene.viewInitial = {
+ up: {
+ x: camera.up.x,
+ y: camera.up.y,
+ z: camera.up.z
+ },
+ eye: {
+ x: camera.eye.x,
+ y: camera.eye.y,
+ z: camera.eye.z
+ },
+ center: {
+ x: camera.center.x,
+ y: camera.center.y,
+ z: camera.center.z
+ }
+ };
+ }
+ scene.plot(fullSceneData, fullLayout, gd.layout);
+ }
+ };
+ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
+ var oldSceneKeys = oldFullLayout._subplots[GL3D] || [];
+ for (var i = 0; i < oldSceneKeys.length; i++) {
+ var oldSceneKey = oldSceneKeys[i];
+ if (!newFullLayout[oldSceneKey] && !!oldFullLayout[oldSceneKey]._scene) {
+ oldFullLayout[oldSceneKey]._scene.destroy();
+ if (oldFullLayout._infolayer) {
+ oldFullLayout._infolayer.selectAll(".annotation-" + oldSceneKey).remove();
+ }
+ }
+ }
+ };
+ exports.toSVG = function(gd) {
+ var fullLayout = gd._fullLayout;
+ var sceneIds = fullLayout._subplots[GL3D];
+ var size = fullLayout._size;
+ for (var i = 0; i < sceneIds.length; i++) {
+ var sceneLayout = fullLayout[sceneIds[i]];
+ var domain = sceneLayout.domain;
+ var scene = sceneLayout._scene;
+ var imageData = scene.toImage("png");
+ var image = fullLayout._glimages.append("svg:image");
+ image.attr({
+ xmlns: xmlnsNamespaces.svg,
+ "xlink:href": imageData,
+ x: size.l + size.w * domain.x[0],
+ y: size.t + size.h * (1 - domain.y[1]),
+ width: size.w * (domain.x[1] - domain.x[0]),
+ height: size.h * (domain.y[1] - domain.y[0]),
+ preserveAspectRatio: "none"
+ });
+ scene.destroy();
+ }
+ };
+ exports.cleanId = function cleanId(id) {
+ if (!id.match(/^scene[0-9]*$/)) return;
+ var sceneNum = id.substr(5);
+ if (sceneNum === "1") sceneNum = "";
+ return SCENE + sceneNum;
+ };
+ exports.updateFx = function(gd) {
+ var fullLayout = gd._fullLayout;
+ var subplotIds = fullLayout._subplots[GL3D];
+ for (var i = 0; i < subplotIds.length; i++) {
+ var subplotObj = fullLayout[subplotIds[i]]._scene;
+ subplotObj.updateFx(fullLayout.dragmode, fullLayout.hovermode);
+ }
+ };
+ }
+ });
+
+ // src/traces/scatter3d/index.js
+ var require_scatter3d = __commonJS({
+ "src/traces/scatter3d/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ plot: require_convert2(),
+ attributes: require_attributes40(),
+ markerSymbols: require_gl3d_markers(),
+ supplyDefaults: require_defaults36(),
+ colorbar: [
+ {
+ container: "marker",
+ min: "cmin",
+ max: "cmax"
+ },
+ {
+ container: "line",
+ min: "cmin",
+ max: "cmax"
+ }
+ ],
+ calc: require_calc21(),
+ moduleType: "trace",
+ name: "scatter3d",
+ basePlotModule: require_gl3d(),
+ categories: ["gl3d", "symbols", "showLegend", "scatter-like"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/scatter3d.js
+ var require_scatter3d2 = __commonJS({
+ "lib/scatter3d.js"(exports, module) {
+ "use strict";
+ module.exports = require_scatter3d();
+ }
+ });
+
+ // src/traces/surface/attributes.js
+ var require_attributes42 = __commonJS({
+ "src/traces/surface/attributes.js"(exports, module) {
+ "use strict";
+ var Color2 = require_color();
+ var colorScaleAttrs = require_attributes8();
+ var axisHoverFormat = require_axis_format_attributes().axisHoverFormat;
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var baseAttrs = require_attributes2();
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ function makeContourProjAttr(axLetter) {
+ return {
+ valType: "boolean",
+ dflt: false
+ };
+ }
+ function makeContourAttr(axLetter) {
+ return {
+ show: {
+ valType: "boolean",
+ dflt: false
+ },
+ start: {
+ valType: "number",
+ dflt: null,
+ editType: "plot"
+ // impliedEdits: {'^autocontour': false},
+ },
+ end: {
+ valType: "number",
+ dflt: null,
+ editType: "plot"
+ // impliedEdits: {'^autocontour': false},
+ },
+ size: {
+ valType: "number",
+ dflt: null,
+ min: 0,
+ editType: "plot"
+ // impliedEdits: {'^autocontour': false},
+ },
+ project: {
+ x: makeContourProjAttr("x"),
+ y: makeContourProjAttr("y"),
+ z: makeContourProjAttr("z")
+ },
+ color: {
+ valType: "color",
+ dflt: Color2.defaultLine
+ },
+ usecolormap: {
+ valType: "boolean",
+ dflt: false
+ },
+ width: {
+ valType: "number",
+ min: 1,
+ max: 16,
+ dflt: 2
+ },
+ highlight: {
+ valType: "boolean",
+ dflt: true
+ },
+ highlightcolor: {
+ valType: "color",
+ dflt: Color2.defaultLine
+ },
+ highlightwidth: {
+ valType: "number",
+ min: 1,
+ max: 16,
+ dflt: 2
+ }
+ };
+ }
+ var attrs = module.exports = overrideAll(extendFlat(
+ {
+ z: {
+ valType: "data_array"
+ },
+ x: {
+ valType: "data_array"
+ },
+ y: {
+ valType: "data_array"
+ },
+ text: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true
+ },
+ hovertext: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true
+ },
+ hovertemplate: hovertemplateAttrs(),
+ xhoverformat: axisHoverFormat("x"),
+ yhoverformat: axisHoverFormat("y"),
+ zhoverformat: axisHoverFormat("z"),
+ connectgaps: {
+ valType: "boolean",
+ dflt: false,
+ editType: "calc"
+ },
+ surfacecolor: {
+ valType: "data_array"
+ }
+ },
+ colorScaleAttrs("", {
+ colorAttr: "z or surfacecolor",
+ showScaleDflt: true,
+ autoColorDflt: false,
+ editTypeOverride: "calc"
+ }),
+ {
+ contours: {
+ x: makeContourAttr("x"),
+ y: makeContourAttr("y"),
+ z: makeContourAttr("z")
+ },
+ hidesurface: {
+ valType: "boolean",
+ dflt: false
+ },
+ lightposition: {
+ x: {
+ valType: "number",
+ min: -1e5,
+ max: 1e5,
+ dflt: 10
+ },
+ y: {
+ valType: "number",
+ min: -1e5,
+ max: 1e5,
+ dflt: 1e4
+ },
+ z: {
+ valType: "number",
+ min: -1e5,
+ max: 1e5,
+ dflt: 0
+ }
+ },
+ lighting: {
+ ambient: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 0.8
+ },
+ diffuse: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 0.8
+ },
+ specular: {
+ valType: "number",
+ min: 0,
+ max: 2,
+ dflt: 0.05
+ },
+ roughness: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 0.5
+ },
+ fresnel: {
+ valType: "number",
+ min: 0,
+ max: 5,
+ dflt: 0.2
+ }
+ },
+ opacity: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1
+ },
+ opacityscale: {
+ valType: "any",
+ editType: "calc"
+ },
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ }
+ ), "calc", "nested");
+ attrs.x.editType = attrs.y.editType = attrs.z.editType = "calc+clearAxisTypes";
+ }
+ });
+
+ // src/traces/surface/defaults.js
+ var require_defaults38 = __commonJS({
+ "src/traces/surface/defaults.js"(exports, module) {
+ "use strict";
+ var Registry = require_registry();
+ var Lib = require_lib();
+ var colorscaleDefaults = require_defaults2();
+ var attributes = require_attributes42();
+ var MIN = 0.1;
+ function createWave(n, minOpacity) {
+ var arr = [];
+ var steps = 32;
+ for (var i = 0; i < steps; i++) {
+ var u = i / (steps - 1);
+ var v = minOpacity + (1 - minOpacity) * (1 - Math.pow(Math.sin(n * u * Math.PI), 2));
+ arr.push([
+ u,
+ Math.max(0, Math.min(1, v))
+ ]);
+ }
+ return arr;
+ }
+ function isValidScaleArray(scl) {
+ var highestVal = 0;
+ if (!Array.isArray(scl) || scl.length < 2) return false;
+ if (!scl[0] || !scl[scl.length - 1]) return false;
+ if (+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false;
+ for (var i = 0; i < scl.length; i++) {
+ var si = scl[i];
+ if (si.length !== 2 || +si[0] < highestVal) {
+ return false;
+ }
+ highestVal = +si[0];
+ }
+ return true;
+ }
+ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ var i, j;
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var x = coerce("x");
+ var y = coerce("y");
+ var z = coerce("z");
+ if (!z || !z.length || (x ? x.length < 1 : false) || (y ? y.length < 1 : false)) {
+ traceOut.visible = false;
+ return;
+ }
+ traceOut._xlength = Array.isArray(x) && Lib.isArrayOrTypedArray(x[0]) ? z.length : z[0].length;
+ traceOut._ylength = z.length;
+ var handleCalendarDefaults = Registry.getComponentMethod("calendars", "handleTraceDefaults");
+ handleCalendarDefaults(traceIn, traceOut, ["x", "y", "z"], layout);
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ coerce("xhoverformat");
+ coerce("yhoverformat");
+ coerce("zhoverformat");
+ [
+ "lighting.ambient",
+ "lighting.diffuse",
+ "lighting.specular",
+ "lighting.roughness",
+ "lighting.fresnel",
+ "lightposition.x",
+ "lightposition.y",
+ "lightposition.z",
+ "hidesurface",
+ "connectgaps",
+ "opacity"
+ ].forEach(function(x2) {
+ coerce(x2);
+ });
+ var surfaceColor = coerce("surfacecolor");
+ var dims = ["x", "y", "z"];
+ for (i = 0; i < 3; ++i) {
+ var contourDim = "contours." + dims[i];
+ var show = coerce(contourDim + ".show");
+ var highlight = coerce(contourDim + ".highlight");
+ if (show || highlight) {
+ for (j = 0; j < 3; ++j) {
+ coerce(contourDim + ".project." + dims[j]);
+ }
+ }
+ if (show) {
+ coerce(contourDim + ".color");
+ coerce(contourDim + ".width");
+ coerce(contourDim + ".usecolormap");
+ }
+ if (highlight) {
+ coerce(contourDim + ".highlightcolor");
+ coerce(contourDim + ".highlightwidth");
+ }
+ coerce(contourDim + ".start");
+ coerce(contourDim + ".end");
+ coerce(contourDim + ".size");
+ }
+ colorscaleDefaults(
+ traceIn,
+ traceOut,
+ layout,
+ coerce,
+ { prefix: "", cLetter: "c" }
+ );
+ opacityscaleDefaults(traceIn, traceOut, layout, coerce);
+ traceOut._length = null;
+ }
+ function opacityscaleDefaults(traceIn, traceOut, layout, coerce) {
+ var opacityscale = coerce("opacityscale");
+ if (opacityscale === "max") {
+ traceOut.opacityscale = [[0, MIN], [1, 1]];
+ } else if (opacityscale === "min") {
+ traceOut.opacityscale = [[0, 1], [1, MIN]];
+ } else if (opacityscale === "extremes") {
+ traceOut.opacityscale = createWave(1, MIN);
+ } else if (!isValidScaleArray(opacityscale)) {
+ traceOut.opacityscale = void 0;
+ }
+ }
+ module.exports = {
+ supplyDefaults,
+ opacityscaleDefaults
+ };
+ }
+ });
+
+ // src/traces/surface/calc.js
+ var require_calc22 = __commonJS({
+ "src/traces/surface/calc.js"(exports, module) {
+ "use strict";
+ var colorscaleCalc = require_calc();
+ module.exports = function calc(gd, trace) {
+ if (trace.surfacecolor) {
+ colorscaleCalc(gd, trace, {
+ vals: trace.surfacecolor,
+ containerStr: "",
+ cLetter: "c"
+ });
+ } else {
+ colorscaleCalc(gd, trace, {
+ vals: trace.z,
+ containerStr: "",
+ cLetter: "c"
+ });
+ }
+ };
+ }
+ });
+
+ // src/traces/surface/convert.js
+ var require_convert4 = __commonJS({
+ "src/traces/surface/convert.js"(exports, module) {
+ "use strict";
+ var createSurface = require_stackgl_modules().gl_surface3d;
+ var ndarray = require_stackgl_modules().ndarray;
+ var ndarrayInterp2d = require_stackgl_modules().ndarray_linear_interpolate.d2;
+ var interp2d = require_interp2d();
+ var findEmpties = require_find_empties();
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ var parseColorScale = require_gl_format_color().parseColorScale;
+ var str2RgbaArray = require_str2rgbarray();
+ var extractOpts = require_colorscale().extractOpts;
+ function SurfaceTrace(scene, surface, uid) {
+ this.scene = scene;
+ this.uid = uid;
+ this.surface = surface;
+ this.data = null;
+ this.showContour = [false, false, false];
+ this.contourStart = [null, null, null];
+ this.contourEnd = [null, null, null];
+ this.contourSize = [0, 0, 0];
+ this.minValues = [Infinity, Infinity, Infinity];
+ this.maxValues = [-Infinity, -Infinity, -Infinity];
+ this.dataScaleX = 1;
+ this.dataScaleY = 1;
+ this.refineData = true;
+ this.objectOffset = [0, 0, 0];
+ }
+ var proto = SurfaceTrace.prototype;
+ proto.getXat = function(a, b, calendar, axis) {
+ var v = !isArrayOrTypedArray(this.data.x) ? a : isArrayOrTypedArray(this.data.x[0]) ? this.data.x[b][a] : this.data.x[a];
+ return calendar === void 0 ? v : axis.d2l(v, 0, calendar);
+ };
+ proto.getYat = function(a, b, calendar, axis) {
+ var v = !isArrayOrTypedArray(this.data.y) ? b : isArrayOrTypedArray(this.data.y[0]) ? this.data.y[b][a] : this.data.y[b];
+ return calendar === void 0 ? v : axis.d2l(v, 0, calendar);
+ };
+ proto.getZat = function(a, b, calendar, axis) {
+ var v = this.data.z[b][a];
+ if (v === null && this.data.connectgaps && this.data._interpolatedZ) {
+ v = this.data._interpolatedZ[b][a];
+ }
+ return calendar === void 0 ? v : axis.d2l(v, 0, calendar);
+ };
+ proto.handlePick = function(selection) {
+ if (selection.object === this.surface) {
+ var xRatio = (selection.data.index[0] - 1) / this.dataScaleX - 1;
+ var yRatio = (selection.data.index[1] - 1) / this.dataScaleY - 1;
+ var j = Math.max(Math.min(Math.round(xRatio), this.data.z[0].length - 1), 0);
+ var k = Math.max(Math.min(Math.round(yRatio), this.data._ylength - 1), 0);
+ selection.index = [j, k];
+ selection.traceCoordinate = [
+ this.getXat(j, k),
+ this.getYat(j, k),
+ this.getZat(j, k)
+ ];
+ selection.dataCoordinate = [
+ this.getXat(j, k, this.data.xcalendar, this.scene.fullSceneLayout.xaxis),
+ this.getYat(j, k, this.data.ycalendar, this.scene.fullSceneLayout.yaxis),
+ this.getZat(j, k, this.data.zcalendar, this.scene.fullSceneLayout.zaxis)
+ ];
+ for (var i = 0; i < 3; i++) {
+ var v = selection.dataCoordinate[i];
+ if (v !== null && v !== void 0) {
+ selection.dataCoordinate[i] *= this.scene.dataScale[i];
+ }
+ }
+ var text = this.data.hovertext || this.data.text;
+ if (isArrayOrTypedArray(text) && text[k] && text[k][j] !== void 0) {
+ selection.textLabel = text[k][j];
+ } else if (text) {
+ selection.textLabel = text;
+ } else {
+ selection.textLabel = "";
+ }
+ selection.data.dataCoordinate = selection.dataCoordinate.slice();
+ this.surface.highlight(selection.data);
+ this.scene.glplot.spikes.position = selection.dataCoordinate;
+ return true;
+ }
+ };
+ function isColormapCircular(colormap) {
+ var first = colormap[0].rgb;
+ var last = colormap[colormap.length - 1].rgb;
+ return first[0] === last[0] && first[1] === last[1] && first[2] === last[2] && first[3] === last[3];
+ }
+ var shortPrimes = [
+ 2,
+ 3,
+ 5,
+ 7,
+ 11,
+ 13,
+ 17,
+ 19,
+ 23,
+ 29,
+ 31,
+ 37,
+ 41,
+ 43,
+ 47,
+ 53,
+ 59,
+ 61,
+ 67,
+ 71,
+ 73,
+ 79,
+ 83,
+ 89,
+ 97,
+ 101,
+ 103,
+ 107,
+ 109,
+ 113,
+ 127,
+ 131,
+ 137,
+ 139,
+ 149,
+ 151,
+ 157,
+ 163,
+ 167,
+ 173,
+ 179,
+ 181,
+ 191,
+ 193,
+ 197,
+ 199,
+ 211,
+ 223,
+ 227,
+ 229,
+ 233,
+ 239,
+ 241,
+ 251,
+ 257,
+ 263,
+ 269,
+ 271,
+ 277,
+ 281,
+ 283,
+ 293,
+ 307,
+ 311,
+ 313,
+ 317,
+ 331,
+ 337,
+ 347,
+ 349,
+ 353,
+ 359,
+ 367,
+ 373,
+ 379,
+ 383,
+ 389,
+ 397,
+ 401,
+ 409,
+ 419,
+ 421,
+ 431,
+ 433,
+ 439,
+ 443,
+ 449,
+ 457,
+ 461,
+ 463,
+ 467,
+ 479,
+ 487,
+ 491,
+ 499,
+ 503,
+ 509,
+ 521,
+ 523,
+ 541,
+ 547,
+ 557,
+ 563,
+ 569,
+ 571,
+ 577,
+ 587,
+ 593,
+ 599,
+ 601,
+ 607,
+ 613,
+ 617,
+ 619,
+ 631,
+ 641,
+ 643,
+ 647,
+ 653,
+ 659,
+ 661,
+ 673,
+ 677,
+ 683,
+ 691,
+ 701,
+ 709,
+ 719,
+ 727,
+ 733,
+ 739,
+ 743,
+ 751,
+ 757,
+ 761,
+ 769,
+ 773,
+ 787,
+ 797,
+ 809,
+ 811,
+ 821,
+ 823,
+ 827,
+ 829,
+ 839,
+ 853,
+ 857,
+ 859,
+ 863,
+ 877,
+ 881,
+ 883,
+ 887,
+ 907,
+ 911,
+ 919,
+ 929,
+ 937,
+ 941,
+ 947,
+ 953,
+ 967,
+ 971,
+ 977,
+ 983,
+ 991,
+ 997,
+ 1009,
+ 1013,
+ 1019,
+ 1021,
+ 1031,
+ 1033,
+ 1039,
+ 1049,
+ 1051,
+ 1061,
+ 1063,
+ 1069,
+ 1087,
+ 1091,
+ 1093,
+ 1097,
+ 1103,
+ 1109,
+ 1117,
+ 1123,
+ 1129,
+ 1151,
+ 1153,
+ 1163,
+ 1171,
+ 1181,
+ 1187,
+ 1193,
+ 1201,
+ 1213,
+ 1217,
+ 1223,
+ 1229,
+ 1231,
+ 1237,
+ 1249,
+ 1259,
+ 1277,
+ 1279,
+ 1283,
+ 1289,
+ 1291,
+ 1297,
+ 1301,
+ 1303,
+ 1307,
+ 1319,
+ 1321,
+ 1327,
+ 1361,
+ 1367,
+ 1373,
+ 1381,
+ 1399,
+ 1409,
+ 1423,
+ 1427,
+ 1429,
+ 1433,
+ 1439,
+ 1447,
+ 1451,
+ 1453,
+ 1459,
+ 1471,
+ 1481,
+ 1483,
+ 1487,
+ 1489,
+ 1493,
+ 1499,
+ 1511,
+ 1523,
+ 1531,
+ 1543,
+ 1549,
+ 1553,
+ 1559,
+ 1567,
+ 1571,
+ 1579,
+ 1583,
+ 1597,
+ 1601,
+ 1607,
+ 1609,
+ 1613,
+ 1619,
+ 1621,
+ 1627,
+ 1637,
+ 1657,
+ 1663,
+ 1667,
+ 1669,
+ 1693,
+ 1697,
+ 1699,
+ 1709,
+ 1721,
+ 1723,
+ 1733,
+ 1741,
+ 1747,
+ 1753,
+ 1759,
+ 1777,
+ 1783,
+ 1787,
+ 1789,
+ 1801,
+ 1811,
+ 1823,
+ 1831,
+ 1847,
+ 1861,
+ 1867,
+ 1871,
+ 1873,
+ 1877,
+ 1879,
+ 1889,
+ 1901,
+ 1907,
+ 1913,
+ 1931,
+ 1933,
+ 1949,
+ 1951,
+ 1973,
+ 1979,
+ 1987,
+ 1993,
+ 1997,
+ 1999,
+ 2003,
+ 2011,
+ 2017,
+ 2027,
+ 2029,
+ 2039,
+ 2053,
+ 2063,
+ 2069,
+ 2081,
+ 2083,
+ 2087,
+ 2089,
+ 2099,
+ 2111,
+ 2113,
+ 2129,
+ 2131,
+ 2137,
+ 2141,
+ 2143,
+ 2153,
+ 2161,
+ 2179,
+ 2203,
+ 2207,
+ 2213,
+ 2221,
+ 2237,
+ 2239,
+ 2243,
+ 2251,
+ 2267,
+ 2269,
+ 2273,
+ 2281,
+ 2287,
+ 2293,
+ 2297,
+ 2309,
+ 2311,
+ 2333,
+ 2339,
+ 2341,
+ 2347,
+ 2351,
+ 2357,
+ 2371,
+ 2377,
+ 2381,
+ 2383,
+ 2389,
+ 2393,
+ 2399,
+ 2411,
+ 2417,
+ 2423,
+ 2437,
+ 2441,
+ 2447,
+ 2459,
+ 2467,
+ 2473,
+ 2477,
+ 2503,
+ 2521,
+ 2531,
+ 2539,
+ 2543,
+ 2549,
+ 2551,
+ 2557,
+ 2579,
+ 2591,
+ 2593,
+ 2609,
+ 2617,
+ 2621,
+ 2633,
+ 2647,
+ 2657,
+ 2659,
+ 2663,
+ 2671,
+ 2677,
+ 2683,
+ 2687,
+ 2689,
+ 2693,
+ 2699,
+ 2707,
+ 2711,
+ 2713,
+ 2719,
+ 2729,
+ 2731,
+ 2741,
+ 2749,
+ 2753,
+ 2767,
+ 2777,
+ 2789,
+ 2791,
+ 2797,
+ 2801,
+ 2803,
+ 2819,
+ 2833,
+ 2837,
+ 2843,
+ 2851,
+ 2857,
+ 2861,
+ 2879,
+ 2887,
+ 2897,
+ 2903,
+ 2909,
+ 2917,
+ 2927,
+ 2939,
+ 2953,
+ 2957,
+ 2963,
+ 2969,
+ 2971,
+ 2999
+ ];
+ function getPow(a, b) {
+ if (a < b) return 0;
+ var n = 0;
+ while (Math.floor(a % b) === 0) {
+ a /= b;
+ n++;
+ }
+ return n;
+ }
+ function getFactors(a) {
+ var powers = [];
+ for (var i = 0; i < shortPrimes.length; i++) {
+ var b = shortPrimes[i];
+ powers.push(
+ getPow(a, b)
+ );
+ }
+ return powers;
+ }
+ function smallestDivisor(a) {
+ var A2 = getFactors(a);
+ var result = a;
+ for (var i = 0; i < shortPrimes.length; i++) {
+ if (A2[i] > 0) {
+ result = shortPrimes[i];
+ break;
+ }
+ }
+ return result;
+ }
+ function leastCommonMultiple(a, b) {
+ if (a < 1 || b < 1) return void 0;
+ var A2 = getFactors(a);
+ var B2 = getFactors(b);
+ var n = 1;
+ for (var i = 0; i < shortPrimes.length; i++) {
+ n *= Math.pow(
+ shortPrimes[i],
+ Math.max(A2[i], B2[i])
+ );
+ }
+ return n;
+ }
+ function arrayLCM(A2) {
+ if (A2.length === 0) return void 0;
+ var n = 1;
+ for (var i = 0; i < A2.length; i++) {
+ n = leastCommonMultiple(n, A2[i]);
+ }
+ return n;
+ }
+ proto.calcXnums = function(xlen) {
+ var i;
+ var nums = [];
+ for (i = 1; i < xlen; i++) {
+ var a = this.getXat(i - 1, 0);
+ var b = this.getXat(i, 0);
+ if (b !== a && a !== void 0 && a !== null && b !== void 0 && b !== null) {
+ nums[i - 1] = Math.abs(b - a);
+ } else {
+ nums[i - 1] = 0;
+ }
+ }
+ var totalDist = 0;
+ for (i = 1; i < xlen; i++) {
+ totalDist += nums[i - 1];
+ }
+ for (i = 1; i < xlen; i++) {
+ if (nums[i - 1] === 0) {
+ nums[i - 1] = 1;
+ } else {
+ nums[i - 1] = Math.round(totalDist / nums[i - 1]);
+ }
+ }
+ return nums;
+ };
+ proto.calcYnums = function(ylen) {
+ var i;
+ var nums = [];
+ for (i = 1; i < ylen; i++) {
+ var a = this.getYat(0, i - 1);
+ var b = this.getYat(0, i);
+ if (b !== a && a !== void 0 && a !== null && b !== void 0 && b !== null) {
+ nums[i - 1] = Math.abs(b - a);
+ } else {
+ nums[i - 1] = 0;
+ }
+ }
+ var totalDist = 0;
+ for (i = 1; i < ylen; i++) {
+ totalDist += nums[i - 1];
+ }
+ for (i = 1; i < ylen; i++) {
+ if (nums[i - 1] === 0) {
+ nums[i - 1] = 1;
+ } else {
+ nums[i - 1] = Math.round(totalDist / nums[i - 1]);
+ }
+ }
+ return nums;
+ };
+ var highlyComposites = [1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1260];
+ var MIN_RESOLUTION = highlyComposites[9];
+ var MAX_RESOLUTION = highlyComposites[13];
+ proto.estimateScale = function(resSrc, axis) {
+ var nums = axis === 0 ? this.calcXnums(resSrc) : this.calcYnums(resSrc);
+ var resDst = 1 + arrayLCM(nums);
+ while (resDst < MIN_RESOLUTION) {
+ resDst *= 2;
+ }
+ while (resDst > MAX_RESOLUTION) {
+ resDst--;
+ resDst /= smallestDivisor(resDst);
+ resDst++;
+ if (resDst < MIN_RESOLUTION) {
+ resDst = MAX_RESOLUTION;
+ }
+ }
+ var scale = Math.round(resDst / resSrc);
+ return scale > 1 ? scale : 1;
+ };
+ function fnHomography(out, inp, X) {
+ var w = X[8] + X[2] * inp[0] + X[5] * inp[1];
+ out[0] = (X[6] + X[0] * inp[0] + X[3] * inp[1]) / w;
+ out[1] = (X[7] + X[1] * inp[0] + X[4] * inp[1]) / w;
+ return out;
+ }
+ function homography(dest, src, X) {
+ warp(dest, src, fnHomography, X);
+ return dest;
+ }
+ function warp(dest, src, func, X) {
+ var warped = [0, 0];
+ var ni = dest.shape[0];
+ var nj = dest.shape[1];
+ for (var i = 0; i < ni; i++) {
+ for (var j = 0; j < nj; j++) {
+ func(warped, [i, j], X);
+ dest.set(i, j, ndarrayInterp2d(src, warped[0], warped[1]));
+ }
+ }
+ return dest;
+ }
+ proto.refineCoords = function(coords) {
+ var scaleW = this.dataScaleX;
+ var scaleH = this.dataScaleY;
+ var width = coords[0].shape[0];
+ var height = coords[0].shape[1];
+ var newWidth = Math.floor(coords[0].shape[0] * scaleW + 1) | 0;
+ var newHeight = Math.floor(coords[0].shape[1] * scaleH + 1) | 0;
+ var padWidth = 1 + width + 1;
+ var padHeight = 1 + height + 1;
+ var padImg = ndarray(new Float32Array(padWidth * padHeight), [padWidth, padHeight]);
+ var X = [
+ 1 / scaleW,
+ 0,
+ 0,
+ 0,
+ 1 / scaleH,
+ 0,
+ 0,
+ 0,
+ 1
+ ];
+ for (var i = 0; i < coords.length; ++i) {
+ this.surface.padField(padImg, coords[i]);
+ var scaledImg = ndarray(new Float32Array(newWidth * newHeight), [newWidth, newHeight]);
+ homography(scaledImg, padImg, X);
+ coords[i] = scaledImg;
+ }
+ };
+ function insertIfNewLevel(arr, newValue) {
+ var found = false;
+ for (var k = 0; k < arr.length; k++) {
+ if (newValue === arr[k]) {
+ found = true;
+ break;
+ }
+ }
+ if (found === false) arr.push(newValue);
+ }
+ proto.setContourLevels = function() {
+ var newLevels = [[], [], []];
+ var useNewLevels = [false, false, false];
+ var needsUpdate = false;
+ var i, j, value;
+ for (i = 0; i < 3; ++i) {
+ if (this.showContour[i]) {
+ needsUpdate = true;
+ if (this.contourSize[i] > 0 && this.contourStart[i] !== null && this.contourEnd[i] !== null && this.contourEnd[i] > this.contourStart[i]) {
+ useNewLevels[i] = true;
+ for (j = this.contourStart[i]; j < this.contourEnd[i]; j += this.contourSize[i]) {
+ value = j * this.scene.dataScale[i];
+ insertIfNewLevel(newLevels[i], value);
+ }
+ }
+ }
+ }
+ if (needsUpdate) {
+ var allLevels = [[], [], []];
+ for (i = 0; i < 3; ++i) {
+ if (this.showContour[i]) {
+ allLevels[i] = useNewLevels[i] ? newLevels[i] : this.scene.contourLevels[i];
+ }
+ }
+ this.surface.update({ levels: allLevels });
+ }
+ };
+ proto.update = function(data) {
+ var scene = this.scene;
+ var sceneLayout = scene.fullSceneLayout;
+ var surface = this.surface;
+ var colormap = parseColorScale(data);
+ var scaleFactor = scene.dataScale;
+ var xlen = data.z[0].length;
+ var ylen = data._ylength;
+ var contourLevels = scene.contourLevels;
+ this.data = data;
+ var i, j, k, v;
+ var rawCoords = [];
+ for (i = 0; i < 3; i++) {
+ rawCoords[i] = [];
+ for (j = 0; j < xlen; j++) {
+ rawCoords[i][j] = [];
+ }
+ }
+ for (j = 0; j < xlen; j++) {
+ for (k = 0; k < ylen; k++) {
+ rawCoords[0][j][k] = this.getXat(j, k, data.xcalendar, sceneLayout.xaxis);
+ rawCoords[1][j][k] = this.getYat(j, k, data.ycalendar, sceneLayout.yaxis);
+ rawCoords[2][j][k] = this.getZat(j, k, data.zcalendar, sceneLayout.zaxis);
+ }
+ }
+ if (data.connectgaps) {
+ data._emptypoints = findEmpties(rawCoords[2]);
+ interp2d(rawCoords[2], data._emptypoints);
+ data._interpolatedZ = [];
+ for (j = 0; j < xlen; j++) {
+ data._interpolatedZ[j] = [];
+ for (k = 0; k < ylen; k++) {
+ data._interpolatedZ[j][k] = rawCoords[2][j][k];
+ }
+ }
+ }
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < xlen; j++) {
+ for (k = 0; k < ylen; k++) {
+ v = rawCoords[i][j][k];
+ if (v === null || v === void 0) {
+ rawCoords[i][j][k] = NaN;
+ } else {
+ v = rawCoords[i][j][k] *= scaleFactor[i];
+ }
+ }
+ }
+ }
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < xlen; j++) {
+ for (k = 0; k < ylen; k++) {
+ v = rawCoords[i][j][k];
+ if (v !== null && v !== void 0) {
+ if (this.minValues[i] > v) {
+ this.minValues[i] = v;
+ }
+ if (this.maxValues[i] < v) {
+ this.maxValues[i] = v;
+ }
+ }
+ }
+ }
+ }
+ for (i = 0; i < 3; i++) {
+ this.objectOffset[i] = 0.5 * (this.minValues[i] + this.maxValues[i]);
+ }
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < xlen; j++) {
+ for (k = 0; k < ylen; k++) {
+ v = rawCoords[i][j][k];
+ if (v !== null && v !== void 0) {
+ rawCoords[i][j][k] -= this.objectOffset[i];
+ }
+ }
+ }
+ }
+ var coords = [
+ ndarray(new Float32Array(xlen * ylen), [xlen, ylen]),
+ ndarray(new Float32Array(xlen * ylen), [xlen, ylen]),
+ ndarray(new Float32Array(xlen * ylen), [xlen, ylen])
+ ];
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < xlen; j++) {
+ for (k = 0; k < ylen; k++) {
+ coords[i].set(j, k, rawCoords[i][j][k]);
+ }
+ }
+ }
+ rawCoords = [];
+ var params = {
+ colormap,
+ levels: [[], [], []],
+ showContour: [true, true, true],
+ showSurface: !data.hidesurface,
+ contourProject: [
+ [false, false, false],
+ [false, false, false],
+ [false, false, false]
+ ],
+ contourWidth: [1, 1, 1],
+ contourColor: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
+ contourTint: [1, 1, 1],
+ dynamicColor: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
+ dynamicWidth: [1, 1, 1],
+ dynamicTint: [1, 1, 1],
+ opacityscale: data.opacityscale,
+ opacity: data.opacity
+ };
+ var cOpts = extractOpts(data);
+ params.intensityBounds = [cOpts.min, cOpts.max];
+ if (data.surfacecolor) {
+ var intensity = ndarray(new Float32Array(xlen * ylen), [xlen, ylen]);
+ for (j = 0; j < xlen; j++) {
+ for (k = 0; k < ylen; k++) {
+ intensity.set(j, k, data.surfacecolor[k][j]);
+ }
+ }
+ coords.push(intensity);
+ } else {
+ params.intensityBounds[0] *= scaleFactor[2];
+ params.intensityBounds[1] *= scaleFactor[2];
+ }
+ if (MAX_RESOLUTION < coords[0].shape[0] || MAX_RESOLUTION < coords[0].shape[1]) {
+ this.refineData = false;
+ }
+ if (this.refineData === true) {
+ this.dataScaleX = this.estimateScale(coords[0].shape[0], 0);
+ this.dataScaleY = this.estimateScale(coords[0].shape[1], 1);
+ if (this.dataScaleX !== 1 || this.dataScaleY !== 1) {
+ this.refineCoords(coords);
+ }
+ }
+ if (data.surfacecolor) {
+ params.intensity = coords.pop();
+ }
+ var highlightEnable = [true, true, true];
+ var axis = ["x", "y", "z"];
+ for (i = 0; i < 3; ++i) {
+ var contourParams = data.contours[axis[i]];
+ highlightEnable[i] = contourParams.highlight;
+ params.showContour[i] = contourParams.show || contourParams.highlight;
+ if (!params.showContour[i]) continue;
+ params.contourProject[i] = [
+ contourParams.project.x,
+ contourParams.project.y,
+ contourParams.project.z
+ ];
+ if (contourParams.show) {
+ this.showContour[i] = true;
+ params.levels[i] = contourLevels[i];
+ surface.highlightColor[i] = params.contourColor[i] = str2RgbaArray(contourParams.color);
+ if (contourParams.usecolormap) {
+ surface.highlightTint[i] = params.contourTint[i] = 0;
+ } else {
+ surface.highlightTint[i] = params.contourTint[i] = 1;
+ }
+ params.contourWidth[i] = contourParams.width;
+ this.contourStart[i] = contourParams.start;
+ this.contourEnd[i] = contourParams.end;
+ this.contourSize[i] = contourParams.size;
+ } else {
+ this.showContour[i] = false;
+ this.contourStart[i] = null;
+ this.contourEnd[i] = null;
+ this.contourSize[i] = 0;
+ }
+ if (contourParams.highlight) {
+ params.dynamicColor[i] = str2RgbaArray(contourParams.highlightcolor);
+ params.dynamicWidth[i] = contourParams.highlightwidth;
+ }
+ }
+ if (isColormapCircular(colormap)) {
+ params.vertexColor = true;
+ }
+ params.objectOffset = this.objectOffset;
+ params.coords = coords;
+ surface.update(params);
+ surface.visible = data.visible;
+ surface.enableDynamic = highlightEnable;
+ surface.enableHighlight = highlightEnable;
+ surface.snapToData = true;
+ if ("lighting" in data) {
+ surface.ambientLight = data.lighting.ambient;
+ surface.diffuseLight = data.lighting.diffuse;
+ surface.specularLight = data.lighting.specular;
+ surface.roughness = data.lighting.roughness;
+ surface.fresnel = data.lighting.fresnel;
+ }
+ if ("lightposition" in data) {
+ surface.lightPosition = [data.lightposition.x, data.lightposition.y, data.lightposition.z];
+ }
+ };
+ proto.dispose = function() {
+ this.scene.glplot.remove(this.surface);
+ this.surface.dispose();
+ };
+ function createSurfaceTrace(scene, data) {
+ var gl2 = scene.glplot.gl;
+ var surface = createSurface({ gl: gl2 });
+ var result = new SurfaceTrace(scene, surface, data.uid);
+ surface._trace = result;
+ result.update(data);
+ scene.glplot.add(surface);
+ return result;
+ }
+ module.exports = createSurfaceTrace;
+ }
+ });
+
+ // src/traces/surface/index.js
+ var require_surface = __commonJS({
+ "src/traces/surface/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes42(),
+ supplyDefaults: require_defaults38().supplyDefaults,
+ colorbar: {
+ min: "cmin",
+ max: "cmax"
+ },
+ calc: require_calc22(),
+ plot: require_convert4(),
+ moduleType: "trace",
+ name: "surface",
+ basePlotModule: require_gl3d(),
+ categories: ["gl3d", "2dMap", "showLegend"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/surface.js
+ var require_surface2 = __commonJS({
+ "lib/surface.js"(exports, module) {
+ "use strict";
+ module.exports = require_surface();
+ }
+ });
+
+ // src/traces/mesh3d/attributes.js
+ var require_attributes43 = __commonJS({
+ "src/traces/mesh3d/attributes.js"(exports, module) {
+ "use strict";
+ var colorScaleAttrs = require_attributes8();
+ var axisHoverFormat = require_axis_format_attributes().axisHoverFormat;
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var surfaceAttrs = require_attributes42();
+ var baseAttrs = require_attributes2();
+ var extendFlat = require_extend().extendFlat;
+ module.exports = extendFlat(
+ {
+ x: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ y: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ z: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ i: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ j: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ k: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ text: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true,
+ editType: "calc"
+ },
+ hovertext: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true,
+ editType: "calc"
+ },
+ hovertemplate: hovertemplateAttrs({ editType: "calc" }),
+ xhoverformat: axisHoverFormat("x"),
+ yhoverformat: axisHoverFormat("y"),
+ zhoverformat: axisHoverFormat("z"),
+ delaunayaxis: {
+ valType: "enumerated",
+ values: ["x", "y", "z"],
+ dflt: "z",
+ editType: "calc"
+ },
+ alphahull: {
+ valType: "number",
+ dflt: -1,
+ editType: "calc"
+ },
+ intensity: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ intensitymode: {
+ valType: "enumerated",
+ values: ["vertex", "cell"],
+ dflt: "vertex",
+ editType: "calc"
+ },
+ // Color field
+ color: {
+ valType: "color",
+ editType: "calc"
+ },
+ vertexcolor: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ facecolor: {
+ valType: "data_array",
+ editType: "calc"
+ }
+ },
+ colorScaleAttrs("", {
+ colorAttr: "`intensity`",
+ showScaleDflt: true,
+ editTypeOverride: "calc"
+ }),
+ {
+ opacity: surfaceAttrs.opacity,
+ // Flat shaded mode
+ flatshading: {
+ valType: "boolean",
+ dflt: false,
+ editType: "calc"
+ },
+ contour: {
+ show: extendFlat({}, surfaceAttrs.contours.x.show, {}),
+ color: surfaceAttrs.contours.x.color,
+ width: surfaceAttrs.contours.x.width,
+ editType: "calc"
+ },
+ lightposition: {
+ x: extendFlat({}, surfaceAttrs.lightposition.x, { dflt: 1e5 }),
+ y: extendFlat({}, surfaceAttrs.lightposition.y, { dflt: 1e5 }),
+ z: extendFlat({}, surfaceAttrs.lightposition.z, { dflt: 0 }),
+ editType: "calc"
+ },
+ lighting: extendFlat({
+ vertexnormalsepsilon: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1e-12,
+ // otherwise finely tessellated things eg. the brain will have no specular light reflection
+ editType: "calc"
+ },
+ facenormalsepsilon: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1e-6,
+ // even the brain model doesn't appear to need finer than this
+ editType: "calc"
+ },
+ editType: "calc"
+ }, surfaceAttrs.lighting),
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, { editType: "calc" }),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ }
+ );
+ }
+ });
+
+ // src/traces/isosurface/attributes.js
+ var require_attributes44 = __commonJS({
+ "src/traces/isosurface/attributes.js"(exports, module) {
+ "use strict";
+ var colorScaleAttrs = require_attributes8();
+ var axisHoverFormat = require_axis_format_attributes().axisHoverFormat;
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var meshAttrs = require_attributes43();
+ var baseAttrs = require_attributes2();
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ function makeSliceAttr(axLetter) {
+ return {
+ show: {
+ valType: "boolean",
+ dflt: false
+ },
+ locations: {
+ valType: "data_array",
+ dflt: []
+ },
+ fill: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1
+ }
+ };
+ }
+ function makeCapAttr(axLetter) {
+ return {
+ show: {
+ valType: "boolean",
+ dflt: true
+ },
+ fill: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1
+ }
+ };
+ }
+ var attrs = module.exports = overrideAll(extendFlat(
+ {
+ x: {
+ valType: "data_array"
+ },
+ y: {
+ valType: "data_array"
+ },
+ z: {
+ valType: "data_array"
+ },
+ value: {
+ valType: "data_array"
+ },
+ isomin: {
+ valType: "number"
+ },
+ isomax: {
+ valType: "number"
+ },
+ surface: {
+ show: {
+ valType: "boolean",
+ dflt: true
+ },
+ count: {
+ valType: "integer",
+ dflt: 2,
+ min: 1
+ },
+ fill: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1
+ },
+ pattern: {
+ valType: "flaglist",
+ flags: ["A", "B", "C", "D", "E"],
+ extras: ["all", "odd", "even"],
+ dflt: "all"
+ }
+ },
+ spaceframe: {
+ show: {
+ valType: "boolean",
+ dflt: false
+ },
+ fill: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 0.15
+ }
+ },
+ slices: {
+ x: makeSliceAttr("x"),
+ y: makeSliceAttr("y"),
+ z: makeSliceAttr("z")
+ },
+ caps: {
+ x: makeCapAttr("x"),
+ y: makeCapAttr("y"),
+ z: makeCapAttr("z")
+ },
+ text: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true
+ },
+ hovertext: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true
+ },
+ hovertemplate: hovertemplateAttrs(),
+ xhoverformat: axisHoverFormat("x"),
+ yhoverformat: axisHoverFormat("y"),
+ zhoverformat: axisHoverFormat("z"),
+ valuehoverformat: axisHoverFormat("value", 1),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ },
+ colorScaleAttrs("", {
+ colorAttr: "`value`",
+ showScaleDflt: true,
+ editTypeOverride: "calc"
+ }),
+ {
+ opacity: meshAttrs.opacity,
+ lightposition: meshAttrs.lightposition,
+ lighting: meshAttrs.lighting,
+ flatshading: meshAttrs.flatshading,
+ contour: meshAttrs.contour,
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo)
+ }
+ ), "calc", "nested");
+ attrs.flatshading.dflt = true;
+ attrs.lighting.facenormalsepsilon.dflt = 0;
+ attrs.x.editType = attrs.y.editType = attrs.z.editType = attrs.value.editType = "calc+clearAxisTypes";
+ }
+ });
+
+ // src/traces/isosurface/defaults.js
+ var require_defaults39 = __commonJS({
+ "src/traces/isosurface/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var Registry = require_registry();
+ var attributes = require_attributes44();
+ var colorscaleDefaults = require_defaults2();
+ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ supplyIsoDefaults(traceIn, traceOut, defaultColor, layout, coerce);
+ }
+ function supplyIsoDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
+ var isomin = coerce("isomin");
+ var isomax = coerce("isomax");
+ if (isomax !== void 0 && isomax !== null && isomin !== void 0 && isomin !== null && isomin > isomax) {
+ traceOut.isomin = null;
+ traceOut.isomax = null;
+ }
+ var x = coerce("x");
+ var y = coerce("y");
+ var z = coerce("z");
+ var value = coerce("value");
+ if (!x || !x.length || !y || !y.length || !z || !z.length || !value || !value.length) {
+ traceOut.visible = false;
+ return;
+ }
+ var handleCalendarDefaults = Registry.getComponentMethod("calendars", "handleTraceDefaults");
+ handleCalendarDefaults(traceIn, traceOut, ["x", "y", "z"], layout);
+ coerce("valuehoverformat");
+ ["x", "y", "z"].forEach(function(dim) {
+ coerce(dim + "hoverformat");
+ var capDim = "caps." + dim;
+ var showCap = coerce(capDim + ".show");
+ if (showCap) {
+ coerce(capDim + ".fill");
+ }
+ var sliceDim = "slices." + dim;
+ var showSlice = coerce(sliceDim + ".show");
+ if (showSlice) {
+ coerce(sliceDim + ".fill");
+ coerce(sliceDim + ".locations");
+ }
+ });
+ var showSpaceframe = coerce("spaceframe.show");
+ if (showSpaceframe) {
+ coerce("spaceframe.fill");
+ }
+ var showSurface = coerce("surface.show");
+ if (showSurface) {
+ coerce("surface.count");
+ coerce("surface.fill");
+ coerce("surface.pattern");
+ }
+ var showContour = coerce("contour.show");
+ if (showContour) {
+ coerce("contour.color");
+ coerce("contour.width");
+ }
+ [
+ "text",
+ "hovertext",
+ "hovertemplate",
+ "lighting.ambient",
+ "lighting.diffuse",
+ "lighting.specular",
+ "lighting.roughness",
+ "lighting.fresnel",
+ "lighting.vertexnormalsepsilon",
+ "lighting.facenormalsepsilon",
+ "lightposition.x",
+ "lightposition.y",
+ "lightposition.z",
+ "flatshading",
+ "opacity"
+ ].forEach(function(x2) {
+ coerce(x2);
+ });
+ colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: "", cLetter: "c" });
+ traceOut._length = null;
+ }
+ module.exports = {
+ supplyDefaults,
+ supplyIsoDefaults
+ };
+ }
+ });
+
+ // src/traces/streamtube/calc.js
+ var require_calc23 = __commonJS({
+ "src/traces/streamtube/calc.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var colorscaleCalc = require_calc();
+ function calc(gd, trace) {
+ trace._len = Math.min(
+ trace.u.length,
+ trace.v.length,
+ trace.w.length,
+ trace.x.length,
+ trace.y.length,
+ trace.z.length
+ );
+ trace._u = filter(trace.u, trace._len);
+ trace._v = filter(trace.v, trace._len);
+ trace._w = filter(trace.w, trace._len);
+ trace._x = filter(trace.x, trace._len);
+ trace._y = filter(trace.y, trace._len);
+ trace._z = filter(trace.z, trace._len);
+ var grid = processGrid(trace);
+ trace._gridFill = grid.fill;
+ trace._Xs = grid.Xs;
+ trace._Ys = grid.Ys;
+ trace._Zs = grid.Zs;
+ trace._len = grid.len;
+ var slen = 0;
+ var startx, starty, startz;
+ if (trace.starts) {
+ startx = filter(trace.starts.x || []);
+ starty = filter(trace.starts.y || []);
+ startz = filter(trace.starts.z || []);
+ slen = Math.min(startx.length, starty.length, startz.length);
+ }
+ trace._startsX = startx || [];
+ trace._startsY = starty || [];
+ trace._startsZ = startz || [];
+ var normMax = 0;
+ var normMin = Infinity;
+ var i;
+ for (i = 0; i < trace._len; i++) {
+ var u = trace._u[i];
+ var v = trace._v[i];
+ var w = trace._w[i];
+ var norm = Math.sqrt(u * u + v * v + w * w);
+ normMax = Math.max(normMax, norm);
+ normMin = Math.min(normMin, norm);
+ }
+ colorscaleCalc(gd, trace, {
+ vals: [normMin, normMax],
+ containerStr: "",
+ cLetter: "c"
+ });
+ for (i = 0; i < slen; i++) {
+ var sx = startx[i];
+ grid.xMax = Math.max(grid.xMax, sx);
+ grid.xMin = Math.min(grid.xMin, sx);
+ var sy = starty[i];
+ grid.yMax = Math.max(grid.yMax, sy);
+ grid.yMin = Math.min(grid.yMin, sy);
+ var sz = startz[i];
+ grid.zMax = Math.max(grid.zMax, sz);
+ grid.zMin = Math.min(grid.zMin, sz);
+ }
+ trace._slen = slen;
+ trace._normMax = normMax;
+ trace._xbnds = [grid.xMin, grid.xMax];
+ trace._ybnds = [grid.yMin, grid.yMax];
+ trace._zbnds = [grid.zMin, grid.zMax];
+ }
+ function processGrid(trace) {
+ var x = trace._x;
+ var y = trace._y;
+ var z = trace._z;
+ var len = trace._len;
+ var i, j, k;
+ var xMax = -Infinity;
+ var xMin = Infinity;
+ var yMax = -Infinity;
+ var yMin = Infinity;
+ var zMax = -Infinity;
+ var zMin = Infinity;
+ var gridFill = "";
+ var filledX;
+ var filledY;
+ var filledZ;
+ var firstX, lastX;
+ var firstY, lastY;
+ var firstZ, lastZ;
+ if (len) {
+ firstX = x[0];
+ firstY = y[0];
+ firstZ = z[0];
+ }
+ if (len > 1) {
+ lastX = x[len - 1];
+ lastY = y[len - 1];
+ lastZ = z[len - 1];
+ }
+ for (i = 0; i < len; i++) {
+ xMax = Math.max(xMax, x[i]);
+ xMin = Math.min(xMin, x[i]);
+ yMax = Math.max(yMax, y[i]);
+ yMin = Math.min(yMin, y[i]);
+ zMax = Math.max(zMax, z[i]);
+ zMin = Math.min(zMin, z[i]);
+ if (!filledX && x[i] !== firstX) {
+ filledX = true;
+ gridFill += "x";
+ }
+ if (!filledY && y[i] !== firstY) {
+ filledY = true;
+ gridFill += "y";
+ }
+ if (!filledZ && z[i] !== firstZ) {
+ filledZ = true;
+ gridFill += "z";
+ }
+ }
+ if (!filledX) gridFill += "x";
+ if (!filledY) gridFill += "y";
+ if (!filledZ) gridFill += "z";
+ var Xs = distinctVals(trace._x);
+ var Ys = distinctVals(trace._y);
+ var Zs = distinctVals(trace._z);
+ gridFill = gridFill.replace("x", (firstX > lastX ? "-" : "+") + "x");
+ gridFill = gridFill.replace("y", (firstY > lastY ? "-" : "+") + "y");
+ gridFill = gridFill.replace("z", (firstZ > lastZ ? "-" : "+") + "z");
+ var empty = function() {
+ len = 0;
+ Xs = [];
+ Ys = [];
+ Zs = [];
+ };
+ if (!len || len < Xs.length * Ys.length * Zs.length) empty();
+ var getArray = function(c) {
+ return c === "x" ? x : c === "y" ? y : z;
+ };
+ var getVals = function(c) {
+ return c === "x" ? Xs : c === "y" ? Ys : Zs;
+ };
+ var getDir = function(c) {
+ return c[len - 1] < c[0] ? -1 : 1;
+ };
+ var arrK = getArray(gridFill[1]);
+ var arrJ = getArray(gridFill[3]);
+ var arrI = getArray(gridFill[5]);
+ var nk = getVals(gridFill[1]).length;
+ var nj = getVals(gridFill[3]).length;
+ var ni = getVals(gridFill[5]).length;
+ var arbitrary = false;
+ var getIndex = function(_i, _j, _k) {
+ return nk * (nj * _i + _j) + _k;
+ };
+ var dirK = getDir(getArray(gridFill[1]));
+ var dirJ = getDir(getArray(gridFill[3]));
+ var dirI = getDir(getArray(gridFill[5]));
+ for (i = 0; i < ni - 1; i++) {
+ for (j = 0; j < nj - 1; j++) {
+ for (k = 0; k < nk - 1; k++) {
+ var q000 = getIndex(i, j, k);
+ var q001 = getIndex(i, j, k + 1);
+ var q010 = getIndex(i, j + 1, k);
+ var q100 = getIndex(i + 1, j, k);
+ if (!(arrK[q000] * dirK < arrK[q001] * dirK) || !(arrJ[q000] * dirJ < arrJ[q010] * dirJ) || !(arrI[q000] * dirI < arrI[q100] * dirI)) {
+ arbitrary = true;
+ }
+ if (arbitrary) break;
+ }
+ if (arbitrary) break;
+ }
+ if (arbitrary) break;
+ }
+ if (arbitrary) {
+ Lib.warn("Encountered arbitrary coordinates! Unable to input data grid.");
+ empty();
+ }
+ return {
+ xMin,
+ yMin,
+ zMin,
+ xMax,
+ yMax,
+ zMax,
+ Xs,
+ Ys,
+ Zs,
+ len,
+ fill: gridFill
+ };
+ }
+ function distinctVals(col) {
+ return Lib.distinctVals(col).vals;
+ }
+ function filter(arr, len) {
+ if (len === void 0) len = arr.length;
+ if (Lib.isTypedArray(arr)) return arr.subarray(0, len);
+ var values = [];
+ for (var i = 0; i < len; i++) {
+ values[i] = +arr[i];
+ }
+ return values;
+ }
+ module.exports = {
+ calc,
+ filter,
+ processGrid
+ };
+ }
+ });
+
+ // src/traces/isosurface/calc.js
+ var require_calc24 = __commonJS({
+ "src/traces/isosurface/calc.js"(exports, module) {
+ "use strict";
+ var colorscaleCalc = require_calc();
+ var processGrid = require_calc23().processGrid;
+ var filter = require_calc23().filter;
+ module.exports = function calc(gd, trace) {
+ trace._len = Math.min(
+ trace.x.length,
+ trace.y.length,
+ trace.z.length,
+ trace.value.length
+ );
+ trace._x = filter(trace.x, trace._len);
+ trace._y = filter(trace.y, trace._len);
+ trace._z = filter(trace.z, trace._len);
+ trace._value = filter(trace.value, trace._len);
+ var grid = processGrid(trace);
+ trace._gridFill = grid.fill;
+ trace._Xs = grid.Xs;
+ trace._Ys = grid.Ys;
+ trace._Zs = grid.Zs;
+ trace._len = grid.len;
+ var min = Infinity;
+ var max = -Infinity;
+ for (var i = 0; i < trace._len; i++) {
+ var v = trace._value[i];
+ min = Math.min(min, v);
+ max = Math.max(max, v);
+ }
+ trace._minValues = min;
+ trace._maxValues = max;
+ trace._vMin = trace.isomin === void 0 || trace.isomin === null ? min : trace.isomin;
+ trace._vMax = trace.isomax === void 0 || trace.isomax === null ? max : trace.isomax;
+ colorscaleCalc(gd, trace, {
+ vals: [trace._vMin, trace._vMax],
+ containerStr: "",
+ cLetter: "c"
+ });
+ };
+ }
+ });
+
+ // src/plots/gl3d/zip3.js
+ var require_zip3 = __commonJS({
+ "src/plots/gl3d/zip3.js"(exports, module) {
+ "use strict";
+ module.exports = function zip3(x, y, z, len) {
+ len = len || x.length;
+ var result = new Array(len);
+ for (var i = 0; i < len; i++) {
+ result[i] = [x[i], y[i], z[i]];
+ }
+ return result;
+ };
+ }
+ });
+
+ // src/traces/isosurface/convert.js
+ var require_convert5 = __commonJS({
+ "src/traces/isosurface/convert.js"(exports, module) {
+ "use strict";
+ var createMesh = require_stackgl_modules().gl_mesh3d;
+ var parseColorScale = require_gl_format_color().parseColorScale;
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ var str2RgbaArray = require_str2rgbarray();
+ var extractOpts = require_colorscale().extractOpts;
+ var zip3 = require_zip3();
+ var findNearestOnAxis = function(w, arr) {
+ for (var q = arr.length - 1; q > 0; q--) {
+ var min = Math.min(arr[q], arr[q - 1]);
+ var max = Math.max(arr[q], arr[q - 1]);
+ if (max > min && min < w && w <= max) {
+ return {
+ id: q,
+ distRatio: (max - w) / (max - min)
+ };
+ }
+ }
+ return {
+ id: 0,
+ distRatio: 0
+ };
+ };
+ function IsosurfaceTrace(scene, mesh, uid) {
+ this.scene = scene;
+ this.uid = uid;
+ this.mesh = mesh;
+ this.name = "";
+ this.data = null;
+ this.showContour = false;
+ }
+ var proto = IsosurfaceTrace.prototype;
+ proto.handlePick = function(selection) {
+ if (selection.object === this.mesh) {
+ var rawId = selection.data.index;
+ var x = this.data._meshX[rawId];
+ var y = this.data._meshY[rawId];
+ var z = this.data._meshZ[rawId];
+ var height = this.data._Ys.length;
+ var depth = this.data._Zs.length;
+ var i = findNearestOnAxis(x, this.data._Xs).id;
+ var j = findNearestOnAxis(y, this.data._Ys).id;
+ var k = findNearestOnAxis(z, this.data._Zs).id;
+ var selectIndex = selection.index = k + depth * j + depth * height * i;
+ selection.traceCoordinate = [
+ this.data._meshX[selectIndex],
+ this.data._meshY[selectIndex],
+ this.data._meshZ[selectIndex],
+ this.data._value[selectIndex]
+ ];
+ var text = this.data.hovertext || this.data.text;
+ if (isArrayOrTypedArray(text) && text[selectIndex] !== void 0) {
+ selection.textLabel = text[selectIndex];
+ } else if (text) {
+ selection.textLabel = text;
+ }
+ return true;
+ }
+ };
+ proto.update = function(data) {
+ var scene = this.scene;
+ var layout = scene.fullSceneLayout;
+ this.data = generateIsoMeshes(data);
+ function toDataCoords(axis, coord, scale, calendar) {
+ return coord.map(function(x) {
+ return axis.d2l(x, 0, calendar) * scale;
+ });
+ }
+ var positions = zip3(
+ toDataCoords(layout.xaxis, data._meshX, scene.dataScale[0], data.xcalendar),
+ toDataCoords(layout.yaxis, data._meshY, scene.dataScale[1], data.ycalendar),
+ toDataCoords(layout.zaxis, data._meshZ, scene.dataScale[2], data.zcalendar)
+ );
+ var cells = zip3(data._meshI, data._meshJ, data._meshK);
+ var config = {
+ positions,
+ cells,
+ lightPosition: [data.lightposition.x, data.lightposition.y, data.lightposition.z],
+ ambient: data.lighting.ambient,
+ diffuse: data.lighting.diffuse,
+ specular: data.lighting.specular,
+ roughness: data.lighting.roughness,
+ fresnel: data.lighting.fresnel,
+ vertexNormalsEpsilon: data.lighting.vertexnormalsepsilon,
+ faceNormalsEpsilon: data.lighting.facenormalsepsilon,
+ opacity: data.opacity,
+ contourEnable: data.contour.show,
+ contourColor: str2RgbaArray(data.contour.color).slice(0, 3),
+ contourWidth: data.contour.width,
+ useFacetNormals: data.flatshading
+ };
+ var cOpts = extractOpts(data);
+ config.vertexIntensity = data._meshIntensity;
+ config.vertexIntensityBounds = [cOpts.min, cOpts.max];
+ config.colormap = parseColorScale(data);
+ this.mesh.update(config);
+ };
+ proto.dispose = function() {
+ this.scene.glplot.remove(this.mesh);
+ this.mesh.dispose();
+ };
+ var GRID_TYPES = ["xyz", "xzy", "yxz", "yzx", "zxy", "zyx"];
+ function generateIsoMeshes(data) {
+ data._meshI = [];
+ data._meshJ = [];
+ data._meshK = [];
+ var showSurface = data.surface.show;
+ var showSpaceframe = data.spaceframe.show;
+ var surfaceFill = data.surface.fill;
+ var spaceframeFill = data.spaceframe.fill;
+ var drawingSurface = false;
+ var drawingSpaceframe = false;
+ var numFaces = 0;
+ var numVertices;
+ var beginVertextLength;
+ var Xs = data._Xs;
+ var Ys = data._Ys;
+ var Zs = data._Zs;
+ var width = Xs.length;
+ var height = Ys.length;
+ var depth = Zs.length;
+ var filled = GRID_TYPES.indexOf(data._gridFill.replace(/-/g, "").replace(/\+/g, ""));
+ var getIndex = function(i, j, k) {
+ switch (filled) {
+ case 5:
+ return k + depth * j + depth * height * i;
+ case 4:
+ return k + depth * i + depth * width * j;
+ case 3:
+ return j + height * k + height * depth * i;
+ case 2:
+ return j + height * i + height * width * k;
+ case 1:
+ return i + width * k + width * depth * j;
+ default:
+ return i + width * j + width * height * k;
+ }
+ };
+ var minValues = data._minValues;
+ var maxValues = data._maxValues;
+ var vMin = data._vMin;
+ var vMax = data._vMax;
+ var allXs;
+ var allYs;
+ var allZs;
+ var allVs;
+ function findVertexId(x, y, z) {
+ var len = allVs.length;
+ for (var f = beginVertextLength; f < len; f++) {
+ if (x === allXs[f] && y === allYs[f] && z === allZs[f]) {
+ return f;
+ }
+ }
+ return -1;
+ }
+ function beginGroup() {
+ beginVertextLength = numVertices;
+ }
+ function emptyVertices() {
+ allXs = [];
+ allYs = [];
+ allZs = [];
+ allVs = [];
+ numVertices = 0;
+ beginGroup();
+ }
+ function addVertex(x, y, z, v) {
+ allXs.push(x);
+ allYs.push(y);
+ allZs.push(z);
+ allVs.push(v);
+ numVertices++;
+ return numVertices - 1;
+ }
+ function addFace(a, b, c) {
+ data._meshI.push(a);
+ data._meshJ.push(b);
+ data._meshK.push(c);
+ numFaces++;
+ return numFaces - 1;
+ }
+ function getCenter(A2, B2, C2) {
+ var M = [];
+ for (var i = 0; i < A2.length; i++) {
+ M[i] = (A2[i] + B2[i] + C2[i]) / 3;
+ }
+ return M;
+ }
+ function getBetween(A2, B2, r) {
+ var M = [];
+ for (var i = 0; i < A2.length; i++) {
+ M[i] = A2[i] * (1 - r) + r * B2[i];
+ }
+ return M;
+ }
+ var activeFill;
+ function setFill(fill) {
+ activeFill = fill;
+ }
+ function createOpenTri(xyzv, abc) {
+ var A2 = xyzv[0];
+ var B2 = xyzv[1];
+ var C2 = xyzv[2];
+ var G = getCenter(A2, B2, C2);
+ var r = Math.sqrt(1 - activeFill);
+ var p1 = getBetween(G, A2, r);
+ var p2 = getBetween(G, B2, r);
+ var p3 = getBetween(G, C2, r);
+ var a = abc[0];
+ var b = abc[1];
+ var c = abc[2];
+ return {
+ xyzv: [
+ [A2, B2, p2],
+ [p2, p1, A2],
+ [B2, C2, p3],
+ [p3, p2, B2],
+ [C2, A2, p1],
+ [p1, p3, C2]
+ ],
+ abc: [
+ [a, b, -1],
+ [-1, -1, a],
+ [b, c, -1],
+ [-1, -1, b],
+ [c, a, -1],
+ [-1, -1, c]
+ ]
+ };
+ }
+ function styleIncludes(style, char) {
+ if (style === "all" || style === null) return true;
+ return style.indexOf(char) > -1;
+ }
+ function mapValue(style, value) {
+ if (style === null) return value;
+ return style;
+ }
+ function drawTri(style, xyzv, abc) {
+ beginGroup();
+ var allXYZVs = [xyzv];
+ var allABCs = [abc];
+ if (activeFill >= 1) {
+ allXYZVs = [xyzv];
+ allABCs = [abc];
+ } else if (activeFill > 0) {
+ var openTri = createOpenTri(xyzv, abc);
+ allXYZVs = openTri.xyzv;
+ allABCs = openTri.abc;
+ }
+ for (var f = 0; f < allXYZVs.length; f++) {
+ xyzv = allXYZVs[f];
+ abc = allABCs[f];
+ var pnts = [];
+ for (var i = 0; i < 3; i++) {
+ var x = xyzv[i][0];
+ var y = xyzv[i][1];
+ var z = xyzv[i][2];
+ var v = xyzv[i][3];
+ var id = abc[i] > -1 ? abc[i] : findVertexId(x, y, z);
+ if (id > -1) {
+ pnts[i] = id;
+ } else {
+ pnts[i] = addVertex(x, y, z, mapValue(style, v));
+ }
+ }
+ addFace(pnts[0], pnts[1], pnts[2]);
+ }
+ }
+ function drawQuad(style, xyzv, abcd) {
+ var makeTri = function(i, j, k) {
+ drawTri(style, [xyzv[i], xyzv[j], xyzv[k]], [abcd[i], abcd[j], abcd[k]]);
+ };
+ makeTri(0, 1, 2);
+ makeTri(2, 3, 0);
+ }
+ function drawTetra(style, xyzv, abcd) {
+ var makeTri = function(i, j, k) {
+ drawTri(style, [xyzv[i], xyzv[j], xyzv[k]], [abcd[i], abcd[j], abcd[k]]);
+ };
+ makeTri(0, 1, 2);
+ makeTri(3, 0, 1);
+ makeTri(2, 3, 0);
+ makeTri(1, 2, 3);
+ }
+ function calcIntersection(pointOut, pointIn, min, max) {
+ var value = pointOut[3];
+ if (value < min) value = min;
+ if (value > max) value = max;
+ var ratio = (pointOut[3] - value) / (pointOut[3] - pointIn[3] + 1e-9);
+ var result = [];
+ for (var s = 0; s < 4; s++) {
+ result[s] = (1 - ratio) * pointOut[s] + ratio * pointIn[s];
+ }
+ return result;
+ }
+ function inRange(value, min, max) {
+ return value >= min && value <= max;
+ }
+ function almostInFinalRange(value) {
+ var vErr = 1e-3 * (vMax - vMin);
+ return value >= vMin - vErr && value <= vMax + vErr;
+ }
+ function getXYZV(indecies) {
+ var xyzv = [];
+ for (var q = 0; q < 4; q++) {
+ var index = indecies[q];
+ xyzv.push(
+ [
+ data._x[index],
+ data._y[index],
+ data._z[index],
+ data._value[index]
+ ]
+ );
+ }
+ return xyzv;
+ }
+ var MAX_PASS = 3;
+ function tryCreateTri(style, xyzv, abc, min, max, nPass) {
+ if (!nPass) nPass = 1;
+ abc = [-1, -1, -1];
+ var result = false;
+ var ok = [
+ inRange(xyzv[0][3], min, max),
+ inRange(xyzv[1][3], min, max),
+ inRange(xyzv[2][3], min, max)
+ ];
+ if (!ok[0] && !ok[1] && !ok[2]) {
+ return false;
+ }
+ var tryDrawTri = function(style2, xyzv2, abc2) {
+ if (
+ // we check here if the points are in `real` iso-min/max range
+ almostInFinalRange(xyzv2[0][3]) && almostInFinalRange(xyzv2[1][3]) && almostInFinalRange(xyzv2[2][3])
+ ) {
+ drawTri(style2, xyzv2, abc2);
+ return true;
+ } else if (nPass < MAX_PASS) {
+ return tryCreateTri(style2, xyzv2, abc2, vMin, vMax, ++nPass);
+ }
+ return false;
+ };
+ if (ok[0] && ok[1] && ok[2]) {
+ return tryDrawTri(style, xyzv, abc) || result;
+ }
+ var interpolated = false;
+ [
+ [0, 1, 2],
+ [2, 0, 1],
+ [1, 2, 0]
+ ].forEach(function(e) {
+ if (ok[e[0]] && ok[e[1]] && !ok[e[2]]) {
+ var A2 = xyzv[e[0]];
+ var B2 = xyzv[e[1]];
+ var C2 = xyzv[e[2]];
+ var p1 = calcIntersection(C2, A2, min, max);
+ var p2 = calcIntersection(C2, B2, min, max);
+ result = tryDrawTri(style, [p2, p1, A2], [-1, -1, abc[e[0]]]) || result;
+ result = tryDrawTri(style, [A2, B2, p2], [abc[e[0]], abc[e[1]], -1]) || result;
+ interpolated = true;
+ }
+ });
+ if (interpolated) return result;
+ [
+ [0, 1, 2],
+ [1, 2, 0],
+ [2, 0, 1]
+ ].forEach(function(e) {
+ if (ok[e[0]] && !ok[e[1]] && !ok[e[2]]) {
+ var A2 = xyzv[e[0]];
+ var B2 = xyzv[e[1]];
+ var C2 = xyzv[e[2]];
+ var p1 = calcIntersection(B2, A2, min, max);
+ var p2 = calcIntersection(C2, A2, min, max);
+ result = tryDrawTri(style, [p2, p1, A2], [-1, -1, abc[e[0]]]) || result;
+ interpolated = true;
+ }
+ });
+ return result;
+ }
+ function tryCreateTetra(style, abcd, min, max) {
+ var result = false;
+ var xyzv = getXYZV(abcd);
+ var ok = [
+ inRange(xyzv[0][3], min, max),
+ inRange(xyzv[1][3], min, max),
+ inRange(xyzv[2][3], min, max),
+ inRange(xyzv[3][3], min, max)
+ ];
+ if (!ok[0] && !ok[1] && !ok[2] && !ok[3]) {
+ return result;
+ }
+ if (ok[0] && ok[1] && ok[2] && ok[3]) {
+ if (drawingSpaceframe) {
+ result = drawTetra(style, xyzv, abcd) || result;
+ }
+ return result;
+ }
+ var interpolated = false;
+ [
+ [0, 1, 2, 3],
+ [3, 0, 1, 2],
+ [2, 3, 0, 1],
+ [1, 2, 3, 0]
+ ].forEach(function(e) {
+ if (ok[e[0]] && ok[e[1]] && ok[e[2]] && !ok[e[3]]) {
+ var A2 = xyzv[e[0]];
+ var B2 = xyzv[e[1]];
+ var C2 = xyzv[e[2]];
+ var D2 = xyzv[e[3]];
+ if (drawingSpaceframe) {
+ result = drawTri(style, [A2, B2, C2], [abcd[e[0]], abcd[e[1]], abcd[e[2]]]) || result;
+ } else {
+ var p1 = calcIntersection(D2, A2, min, max);
+ var p2 = calcIntersection(D2, B2, min, max);
+ var p3 = calcIntersection(D2, C2, min, max);
+ result = drawTri(null, [p1, p2, p3], [-1, -1, -1]) || result;
+ }
+ interpolated = true;
+ }
+ });
+ if (interpolated) return result;
+ [
+ [0, 1, 2, 3],
+ [1, 2, 3, 0],
+ [2, 3, 0, 1],
+ [3, 0, 1, 2],
+ [0, 2, 3, 1],
+ [1, 3, 2, 0]
+ ].forEach(function(e) {
+ if (ok[e[0]] && ok[e[1]] && !ok[e[2]] && !ok[e[3]]) {
+ var A2 = xyzv[e[0]];
+ var B2 = xyzv[e[1]];
+ var C2 = xyzv[e[2]];
+ var D2 = xyzv[e[3]];
+ var p1 = calcIntersection(C2, A2, min, max);
+ var p2 = calcIntersection(C2, B2, min, max);
+ var p3 = calcIntersection(D2, B2, min, max);
+ var p4 = calcIntersection(D2, A2, min, max);
+ if (drawingSpaceframe) {
+ result = drawTri(style, [A2, p4, p1], [abcd[e[0]], -1, -1]) || result;
+ result = drawTri(style, [B2, p2, p3], [abcd[e[1]], -1, -1]) || result;
+ } else {
+ result = drawQuad(null, [p1, p2, p3, p4], [-1, -1, -1, -1]) || result;
+ }
+ interpolated = true;
+ }
+ });
+ if (interpolated) return result;
+ [
+ [0, 1, 2, 3],
+ [1, 2, 3, 0],
+ [2, 3, 0, 1],
+ [3, 0, 1, 2]
+ ].forEach(function(e) {
+ if (ok[e[0]] && !ok[e[1]] && !ok[e[2]] && !ok[e[3]]) {
+ var A2 = xyzv[e[0]];
+ var B2 = xyzv[e[1]];
+ var C2 = xyzv[e[2]];
+ var D2 = xyzv[e[3]];
+ var p1 = calcIntersection(B2, A2, min, max);
+ var p2 = calcIntersection(C2, A2, min, max);
+ var p3 = calcIntersection(D2, A2, min, max);
+ if (drawingSpaceframe) {
+ result = drawTri(style, [A2, p1, p2], [abcd[e[0]], -1, -1]) || result;
+ result = drawTri(style, [A2, p2, p3], [abcd[e[0]], -1, -1]) || result;
+ result = drawTri(style, [A2, p3, p1], [abcd[e[0]], -1, -1]) || result;
+ } else {
+ result = drawTri(null, [p1, p2, p3], [-1, -1, -1]) || result;
+ }
+ interpolated = true;
+ }
+ });
+ return result;
+ }
+ function addCube(style, p000, p001, p010, p011, p100, p101, p110, p111, min, max) {
+ var result = false;
+ if (drawingSurface) {
+ if (styleIncludes(style, "A")) {
+ result = tryCreateTetra(null, [p000, p001, p010, p100], min, max) || result;
+ }
+ if (styleIncludes(style, "B")) {
+ result = tryCreateTetra(null, [p001, p010, p011, p111], min, max) || result;
+ }
+ if (styleIncludes(style, "C")) {
+ result = tryCreateTetra(null, [p001, p100, p101, p111], min, max) || result;
+ }
+ if (styleIncludes(style, "D")) {
+ result = tryCreateTetra(null, [p010, p100, p110, p111], min, max) || result;
+ }
+ if (styleIncludes(style, "E")) {
+ result = tryCreateTetra(null, [p001, p010, p100, p111], min, max) || result;
+ }
+ }
+ if (drawingSpaceframe) {
+ result = tryCreateTetra(style, [p001, p010, p100, p111], min, max) || result;
+ }
+ return result;
+ }
+ function addRect(style, a, b, c, d, min, max, previousResult) {
+ return [
+ previousResult[0] === true ? true : tryCreateTri(style, getXYZV([a, b, c]), [a, b, c], min, max),
+ previousResult[1] === true ? true : tryCreateTri(style, getXYZV([c, d, a]), [c, d, a], min, max)
+ ];
+ }
+ function begin2dCell(style, p00, p01, p10, p11, min, max, isEven, previousResult) {
+ if (isEven) {
+ return addRect(style, p00, p01, p11, p10, min, max, previousResult);
+ } else {
+ return addRect(style, p01, p11, p10, p00, min, max, previousResult);
+ }
+ }
+ function beginSection(style, i, j, k, min, max, distRatios) {
+ var result = false;
+ var A2, B2, C2, D2;
+ var makeSection = function() {
+ result = tryCreateTri(style, [A2, B2, C2], [-1, -1, -1], min, max) || result;
+ result = tryCreateTri(style, [C2, D2, A2], [-1, -1, -1], min, max) || result;
+ };
+ var rX = distRatios[0];
+ var rY = distRatios[1];
+ var rZ = distRatios[2];
+ if (rX) {
+ A2 = getBetween(getXYZV([getIndex(i, j - 0, k - 0)])[0], getXYZV([getIndex(i - 1, j - 0, k - 0)])[0], rX);
+ B2 = getBetween(getXYZV([getIndex(i, j - 0, k - 1)])[0], getXYZV([getIndex(i - 1, j - 0, k - 1)])[0], rX);
+ C2 = getBetween(getXYZV([getIndex(i, j - 1, k - 1)])[0], getXYZV([getIndex(i - 1, j - 1, k - 1)])[0], rX);
+ D2 = getBetween(getXYZV([getIndex(i, j - 1, k - 0)])[0], getXYZV([getIndex(i - 1, j - 1, k - 0)])[0], rX);
+ makeSection();
+ }
+ if (rY) {
+ A2 = getBetween(getXYZV([getIndex(i - 0, j, k - 0)])[0], getXYZV([getIndex(i - 0, j - 1, k - 0)])[0], rY);
+ B2 = getBetween(getXYZV([getIndex(i - 0, j, k - 1)])[0], getXYZV([getIndex(i - 0, j - 1, k - 1)])[0], rY);
+ C2 = getBetween(getXYZV([getIndex(i - 1, j, k - 1)])[0], getXYZV([getIndex(i - 1, j - 1, k - 1)])[0], rY);
+ D2 = getBetween(getXYZV([getIndex(i - 1, j, k - 0)])[0], getXYZV([getIndex(i - 1, j - 1, k - 0)])[0], rY);
+ makeSection();
+ }
+ if (rZ) {
+ A2 = getBetween(getXYZV([getIndex(i - 0, j - 0, k)])[0], getXYZV([getIndex(i - 0, j - 0, k - 1)])[0], rZ);
+ B2 = getBetween(getXYZV([getIndex(i - 0, j - 1, k)])[0], getXYZV([getIndex(i - 0, j - 1, k - 1)])[0], rZ);
+ C2 = getBetween(getXYZV([getIndex(i - 1, j - 1, k)])[0], getXYZV([getIndex(i - 1, j - 1, k - 1)])[0], rZ);
+ D2 = getBetween(getXYZV([getIndex(i - 1, j - 0, k)])[0], getXYZV([getIndex(i - 1, j - 0, k - 1)])[0], rZ);
+ makeSection();
+ }
+ return result;
+ }
+ function begin3dCell(style, p000, p001, p010, p011, p100, p101, p110, p111, min, max, isEven) {
+ var cellStyle = style;
+ if (isEven) {
+ if (drawingSurface && style === "even") cellStyle = null;
+ return addCube(cellStyle, p000, p001, p010, p011, p100, p101, p110, p111, min, max);
+ } else {
+ if (drawingSurface && style === "odd") cellStyle = null;
+ return addCube(cellStyle, p111, p110, p101, p100, p011, p010, p001, p000, min, max);
+ }
+ }
+ function draw2dX(style, items, min, max, previousResult) {
+ var result = [];
+ var n = 0;
+ for (var q = 0; q < items.length; q++) {
+ var i = items[q];
+ for (var k = 1; k < depth; k++) {
+ for (var j = 1; j < height; j++) {
+ result.push(
+ begin2dCell(
+ style,
+ getIndex(i, j - 1, k - 1),
+ getIndex(i, j - 1, k),
+ getIndex(i, j, k - 1),
+ getIndex(i, j, k),
+ min,
+ max,
+ (i + j + k) % 2,
+ previousResult && previousResult[n] ? previousResult[n] : []
+ )
+ );
+ n++;
+ }
+ }
+ }
+ return result;
+ }
+ function draw2dY(style, items, min, max, previousResult) {
+ var result = [];
+ var n = 0;
+ for (var q = 0; q < items.length; q++) {
+ var j = items[q];
+ for (var i = 1; i < width; i++) {
+ for (var k = 1; k < depth; k++) {
+ result.push(
+ begin2dCell(
+ style,
+ getIndex(i - 1, j, k - 1),
+ getIndex(i, j, k - 1),
+ getIndex(i - 1, j, k),
+ getIndex(i, j, k),
+ min,
+ max,
+ (i + j + k) % 2,
+ previousResult && previousResult[n] ? previousResult[n] : []
+ )
+ );
+ n++;
+ }
+ }
+ }
+ return result;
+ }
+ function draw2dZ(style, items, min, max, previousResult) {
+ var result = [];
+ var n = 0;
+ for (var q = 0; q < items.length; q++) {
+ var k = items[q];
+ for (var j = 1; j < height; j++) {
+ for (var i = 1; i < width; i++) {
+ result.push(
+ begin2dCell(
+ style,
+ getIndex(i - 1, j - 1, k),
+ getIndex(i - 1, j, k),
+ getIndex(i, j - 1, k),
+ getIndex(i, j, k),
+ min,
+ max,
+ (i + j + k) % 2,
+ previousResult && previousResult[n] ? previousResult[n] : []
+ )
+ );
+ n++;
+ }
+ }
+ }
+ return result;
+ }
+ function draw3d(style, min, max) {
+ for (var k = 1; k < depth; k++) {
+ for (var j = 1; j < height; j++) {
+ for (var i = 1; i < width; i++) {
+ begin3dCell(
+ style,
+ getIndex(i - 1, j - 1, k - 1),
+ getIndex(i - 1, j - 1, k),
+ getIndex(i - 1, j, k - 1),
+ getIndex(i - 1, j, k),
+ getIndex(i, j - 1, k - 1),
+ getIndex(i, j - 1, k),
+ getIndex(i, j, k - 1),
+ getIndex(i, j, k),
+ min,
+ max,
+ (i + j + k) % 2
+ );
+ }
+ }
+ }
+ }
+ function drawSpaceframe(style, min, max) {
+ drawingSpaceframe = true;
+ draw3d(style, min, max);
+ drawingSpaceframe = false;
+ }
+ function drawSurface(style, min, max) {
+ drawingSurface = true;
+ draw3d(style, min, max);
+ drawingSurface = false;
+ }
+ function drawSectionX(style, items, min, max, distRatios, previousResult) {
+ var result = [];
+ var n = 0;
+ for (var q = 0; q < items.length; q++) {
+ var i = items[q];
+ for (var k = 1; k < depth; k++) {
+ for (var j = 1; j < height; j++) {
+ result.push(
+ beginSection(
+ style,
+ i,
+ j,
+ k,
+ min,
+ max,
+ distRatios[q],
+ previousResult && previousResult[n] ? previousResult[n] : []
+ )
+ );
+ n++;
+ }
+ }
+ }
+ return result;
+ }
+ function drawSectionY(style, items, min, max, distRatios, previousResult) {
+ var result = [];
+ var n = 0;
+ for (var q = 0; q < items.length; q++) {
+ var j = items[q];
+ for (var i = 1; i < width; i++) {
+ for (var k = 1; k < depth; k++) {
+ result.push(
+ beginSection(
+ style,
+ i,
+ j,
+ k,
+ min,
+ max,
+ distRatios[q],
+ previousResult && previousResult[n] ? previousResult[n] : []
+ )
+ );
+ n++;
+ }
+ }
+ }
+ return result;
+ }
+ function drawSectionZ(style, items, min, max, distRatios, previousResult) {
+ var result = [];
+ var n = 0;
+ for (var q = 0; q < items.length; q++) {
+ var k = items[q];
+ for (var j = 1; j < height; j++) {
+ for (var i = 1; i < width; i++) {
+ result.push(
+ beginSection(
+ style,
+ i,
+ j,
+ k,
+ min,
+ max,
+ distRatios[q],
+ previousResult && previousResult[n] ? previousResult[n] : []
+ )
+ );
+ n++;
+ }
+ }
+ }
+ return result;
+ }
+ function createRange(a, b) {
+ var range = [];
+ for (var q = a; q < b; q++) {
+ range.push(q);
+ }
+ return range;
+ }
+ function insertGridPoints() {
+ for (var i = 0; i < width; i++) {
+ for (var j = 0; j < height; j++) {
+ for (var k = 0; k < depth; k++) {
+ var index = getIndex(i, j, k);
+ addVertex(
+ data._x[index],
+ data._y[index],
+ data._z[index],
+ data._value[index]
+ );
+ }
+ }
+ }
+ }
+ function drawAll() {
+ emptyVertices();
+ insertGridPoints();
+ var activeStyle = null;
+ if (showSpaceframe && spaceframeFill) {
+ setFill(spaceframeFill);
+ drawSpaceframe(activeStyle, vMin, vMax);
+ }
+ if (showSurface && surfaceFill) {
+ setFill(surfaceFill);
+ var surfacePattern = data.surface.pattern;
+ var surfaceCount = data.surface.count;
+ for (var q = 0; q < surfaceCount; q++) {
+ var ratio = surfaceCount === 1 ? 0.5 : q / (surfaceCount - 1);
+ var level = (1 - ratio) * vMin + ratio * vMax;
+ var d1 = Math.abs(level - minValues);
+ var d2 = Math.abs(level - maxValues);
+ var ranges = d1 > d2 ? [minValues, level] : [level, maxValues];
+ drawSurface(surfacePattern, ranges[0], ranges[1]);
+ }
+ }
+ var setupMinMax = [
+ [Math.min(vMin, maxValues), Math.max(vMin, maxValues)],
+ [Math.min(minValues, vMax), Math.max(minValues, vMax)]
+ ];
+ ["x", "y", "z"].forEach(function(e) {
+ var preRes = [];
+ for (var s = 0; s < setupMinMax.length; s++) {
+ var count = 0;
+ var activeMin = setupMinMax[s][0];
+ var activeMax = setupMinMax[s][1];
+ var slice = data.slices[e];
+ if (slice.show && slice.fill) {
+ setFill(slice.fill);
+ var exactIndices = [];
+ var ceilIndices = [];
+ var distRatios = [];
+ if (slice.locations.length) {
+ for (var q2 = 0; q2 < slice.locations.length; q2++) {
+ var near = findNearestOnAxis(
+ slice.locations[q2],
+ e === "x" ? Xs : e === "y" ? Ys : Zs
+ );
+ if (near.distRatio === 0) {
+ exactIndices.push(near.id);
+ } else if (near.id > 0) {
+ ceilIndices.push(near.id);
+ if (e === "x") {
+ distRatios.push([near.distRatio, 0, 0]);
+ } else if (e === "y") {
+ distRatios.push([0, near.distRatio, 0]);
+ } else {
+ distRatios.push([0, 0, near.distRatio]);
+ }
+ }
+ }
+ } else {
+ if (e === "x") {
+ exactIndices = createRange(1, width - 1);
+ } else if (e === "y") {
+ exactIndices = createRange(1, height - 1);
+ } else {
+ exactIndices = createRange(1, depth - 1);
+ }
+ }
+ if (ceilIndices.length > 0) {
+ if (e === "x") {
+ preRes[count] = drawSectionX(activeStyle, ceilIndices, activeMin, activeMax, distRatios, preRes[count]);
+ } else if (e === "y") {
+ preRes[count] = drawSectionY(activeStyle, ceilIndices, activeMin, activeMax, distRatios, preRes[count]);
+ } else {
+ preRes[count] = drawSectionZ(activeStyle, ceilIndices, activeMin, activeMax, distRatios, preRes[count]);
+ }
+ count++;
+ }
+ if (exactIndices.length > 0) {
+ if (e === "x") {
+ preRes[count] = draw2dX(activeStyle, exactIndices, activeMin, activeMax, preRes[count]);
+ } else if (e === "y") {
+ preRes[count] = draw2dY(activeStyle, exactIndices, activeMin, activeMax, preRes[count]);
+ } else {
+ preRes[count] = draw2dZ(activeStyle, exactIndices, activeMin, activeMax, preRes[count]);
+ }
+ count++;
+ }
+ }
+ var cap = data.caps[e];
+ if (cap.show && cap.fill) {
+ setFill(cap.fill);
+ if (e === "x") {
+ preRes[count] = draw2dX(activeStyle, [0, width - 1], activeMin, activeMax, preRes[count]);
+ } else if (e === "y") {
+ preRes[count] = draw2dY(activeStyle, [0, height - 1], activeMin, activeMax, preRes[count]);
+ } else {
+ preRes[count] = draw2dZ(activeStyle, [0, depth - 1], activeMin, activeMax, preRes[count]);
+ }
+ count++;
+ }
+ }
+ });
+ if (numFaces === 0) {
+ emptyVertices();
+ }
+ data._meshX = allXs;
+ data._meshY = allYs;
+ data._meshZ = allZs;
+ data._meshIntensity = allVs;
+ data._Xs = Xs;
+ data._Ys = Ys;
+ data._Zs = Zs;
+ }
+ drawAll();
+ return data;
+ }
+ function createIsosurfaceTrace(scene, data) {
+ var gl2 = scene.glplot.gl;
+ var mesh = createMesh({ gl: gl2 });
+ var result = new IsosurfaceTrace(scene, mesh, data.uid);
+ mesh._trace = result;
+ result.update(data);
+ scene.glplot.add(mesh);
+ return result;
+ }
+ module.exports = {
+ findNearestOnAxis,
+ generateIsoMeshes,
+ createIsosurfaceTrace
+ };
+ }
+ });
+
+ // src/traces/isosurface/index.js
+ var require_isosurface = __commonJS({
+ "src/traces/isosurface/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes44(),
+ supplyDefaults: require_defaults39().supplyDefaults,
+ calc: require_calc24(),
+ colorbar: {
+ min: "cmin",
+ max: "cmax"
+ },
+ plot: require_convert5().createIsosurfaceTrace,
+ moduleType: "trace",
+ name: "isosurface",
+ basePlotModule: require_gl3d(),
+ categories: ["gl3d", "showLegend"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/isosurface.js
+ var require_isosurface2 = __commonJS({
+ "lib/isosurface.js"(exports, module) {
+ "use strict";
+ module.exports = require_isosurface();
+ }
+ });
+
+ // src/traces/volume/attributes.js
+ var require_attributes45 = __commonJS({
+ "src/traces/volume/attributes.js"(exports, module) {
+ "use strict";
+ var colorScaleAttrs = require_attributes8();
+ var isosurfaceAttrs = require_attributes44();
+ var surfaceAttrs = require_attributes42();
+ var baseAttrs = require_attributes2();
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var attrs = module.exports = overrideAll(extendFlat(
+ {
+ x: isosurfaceAttrs.x,
+ y: isosurfaceAttrs.y,
+ z: isosurfaceAttrs.z,
+ value: isosurfaceAttrs.value,
+ isomin: isosurfaceAttrs.isomin,
+ isomax: isosurfaceAttrs.isomax,
+ surface: isosurfaceAttrs.surface,
+ spaceframe: {
+ show: {
+ valType: "boolean",
+ dflt: false
+ },
+ fill: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1
+ }
+ },
+ slices: isosurfaceAttrs.slices,
+ caps: isosurfaceAttrs.caps,
+ text: isosurfaceAttrs.text,
+ hovertext: isosurfaceAttrs.hovertext,
+ xhoverformat: isosurfaceAttrs.xhoverformat,
+ yhoverformat: isosurfaceAttrs.yhoverformat,
+ zhoverformat: isosurfaceAttrs.zhoverformat,
+ valuehoverformat: isosurfaceAttrs.valuehoverformat,
+ hovertemplate: isosurfaceAttrs.hovertemplate
+ },
+ colorScaleAttrs("", {
+ colorAttr: "`value`",
+ showScaleDflt: true,
+ editTypeOverride: "calc"
+ }),
+ {
+ colorbar: isosurfaceAttrs.colorbar,
+ opacity: isosurfaceAttrs.opacity,
+ opacityscale: surfaceAttrs.opacityscale,
+ lightposition: isosurfaceAttrs.lightposition,
+ lighting: isosurfaceAttrs.lighting,
+ flatshading: isosurfaceAttrs.flatshading,
+ contour: isosurfaceAttrs.contour,
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ }
+ ), "calc", "nested");
+ attrs.x.editType = attrs.y.editType = attrs.z.editType = attrs.value.editType = "calc+clearAxisTypes";
+ }
+ });
+
+ // src/traces/volume/defaults.js
+ var require_defaults40 = __commonJS({
+ "src/traces/volume/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var attributes = require_attributes45();
+ var supplyIsoDefaults = require_defaults39().supplyIsoDefaults;
+ var opacityscaleDefaults = require_defaults38().opacityscaleDefaults;
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ supplyIsoDefaults(traceIn, traceOut, defaultColor, layout, coerce);
+ opacityscaleDefaults(traceIn, traceOut, layout, coerce);
+ };
+ }
+ });
+
+ // src/traces/volume/convert.js
+ var require_convert6 = __commonJS({
+ "src/traces/volume/convert.js"(exports, module) {
+ "use strict";
+ var createMesh = require_stackgl_modules().gl_mesh3d;
+ var parseColorScale = require_gl_format_color().parseColorScale;
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ var str2RgbaArray = require_str2rgbarray();
+ var extractOpts = require_colorscale().extractOpts;
+ var zip3 = require_zip3();
+ var findNearestOnAxis = require_convert5().findNearestOnAxis;
+ var generateIsoMeshes = require_convert5().generateIsoMeshes;
+ function VolumeTrace(scene, mesh, uid) {
+ this.scene = scene;
+ this.uid = uid;
+ this.mesh = mesh;
+ this.name = "";
+ this.data = null;
+ this.showContour = false;
+ }
+ var proto = VolumeTrace.prototype;
+ proto.handlePick = function(selection) {
+ if (selection.object === this.mesh) {
+ var rawId = selection.data.index;
+ var x = this.data._meshX[rawId];
+ var y = this.data._meshY[rawId];
+ var z = this.data._meshZ[rawId];
+ var height = this.data._Ys.length;
+ var depth = this.data._Zs.length;
+ var i = findNearestOnAxis(x, this.data._Xs).id;
+ var j = findNearestOnAxis(y, this.data._Ys).id;
+ var k = findNearestOnAxis(z, this.data._Zs).id;
+ var selectIndex = selection.index = k + depth * j + depth * height * i;
+ selection.traceCoordinate = [
+ this.data._meshX[selectIndex],
+ this.data._meshY[selectIndex],
+ this.data._meshZ[selectIndex],
+ this.data._value[selectIndex]
+ ];
+ var text = this.data.hovertext || this.data.text;
+ if (isArrayOrTypedArray(text) && text[selectIndex] !== void 0) {
+ selection.textLabel = text[selectIndex];
+ } else if (text) {
+ selection.textLabel = text;
+ }
+ return true;
+ }
+ };
+ proto.update = function(data) {
+ var scene = this.scene;
+ var layout = scene.fullSceneLayout;
+ this.data = generateIsoMeshes(data);
+ function toDataCoords(axis, coord, scale, calendar) {
+ return coord.map(function(x) {
+ return axis.d2l(x, 0, calendar) * scale;
+ });
+ }
+ var positions = zip3(
+ toDataCoords(layout.xaxis, data._meshX, scene.dataScale[0], data.xcalendar),
+ toDataCoords(layout.yaxis, data._meshY, scene.dataScale[1], data.ycalendar),
+ toDataCoords(layout.zaxis, data._meshZ, scene.dataScale[2], data.zcalendar)
+ );
+ var cells = zip3(data._meshI, data._meshJ, data._meshK);
+ var config = {
+ positions,
+ cells,
+ lightPosition: [data.lightposition.x, data.lightposition.y, data.lightposition.z],
+ ambient: data.lighting.ambient,
+ diffuse: data.lighting.diffuse,
+ specular: data.lighting.specular,
+ roughness: data.lighting.roughness,
+ fresnel: data.lighting.fresnel,
+ vertexNormalsEpsilon: data.lighting.vertexnormalsepsilon,
+ faceNormalsEpsilon: data.lighting.facenormalsepsilon,
+ opacity: data.opacity,
+ opacityscale: data.opacityscale,
+ contourEnable: data.contour.show,
+ contourColor: str2RgbaArray(data.contour.color).slice(0, 3),
+ contourWidth: data.contour.width,
+ useFacetNormals: data.flatshading
+ };
+ var cOpts = extractOpts(data);
+ config.vertexIntensity = data._meshIntensity;
+ config.vertexIntensityBounds = [cOpts.min, cOpts.max];
+ config.colormap = parseColorScale(data);
+ this.mesh.update(config);
+ };
+ proto.dispose = function() {
+ this.scene.glplot.remove(this.mesh);
+ this.mesh.dispose();
+ };
+ function createVolumeTrace(scene, data) {
+ var gl2 = scene.glplot.gl;
+ var mesh = createMesh({ gl: gl2 });
+ var result = new VolumeTrace(scene, mesh, data.uid);
+ mesh._trace = result;
+ result.update(data);
+ scene.glplot.add(mesh);
+ return result;
+ }
+ module.exports = createVolumeTrace;
+ }
+ });
+
+ // src/traces/volume/index.js
+ var require_volume = __commonJS({
+ "src/traces/volume/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes45(),
+ supplyDefaults: require_defaults40(),
+ calc: require_calc24(),
+ colorbar: {
+ min: "cmin",
+ max: "cmax"
+ },
+ plot: require_convert6(),
+ moduleType: "trace",
+ name: "volume",
+ basePlotModule: require_gl3d(),
+ categories: ["gl3d", "showLegend"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/volume.js
+ var require_volume2 = __commonJS({
+ "lib/volume.js"(exports, module) {
+ "use strict";
+ module.exports = require_volume();
+ }
+ });
+
+ // src/traces/mesh3d/defaults.js
+ var require_defaults41 = __commonJS({
+ "src/traces/mesh3d/defaults.js"(exports, module) {
+ "use strict";
+ var Registry = require_registry();
+ var Lib = require_lib();
+ var colorscaleDefaults = require_defaults2();
+ var attributes = require_attributes43();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ function readComponents(array) {
+ var ret = array.map(function(attr) {
+ var result = coerce(attr);
+ if (result && Lib.isArrayOrTypedArray(result)) return result;
+ return null;
+ });
+ return ret.every(function(x) {
+ return x && x.length === ret[0].length;
+ }) && ret;
+ }
+ var coords = readComponents(["x", "y", "z"]);
+ if (!coords) {
+ traceOut.visible = false;
+ return;
+ }
+ readComponents(["i", "j", "k"]);
+ if (traceOut.i && (!traceOut.j || !traceOut.k) || traceOut.j && (!traceOut.k || !traceOut.i) || traceOut.k && (!traceOut.i || !traceOut.j)) {
+ traceOut.visible = false;
+ return;
+ }
+ var handleCalendarDefaults = Registry.getComponentMethod("calendars", "handleTraceDefaults");
+ handleCalendarDefaults(traceIn, traceOut, ["x", "y", "z"], layout);
+ [
+ "lighting.ambient",
+ "lighting.diffuse",
+ "lighting.specular",
+ "lighting.roughness",
+ "lighting.fresnel",
+ "lighting.vertexnormalsepsilon",
+ "lighting.facenormalsepsilon",
+ "lightposition.x",
+ "lightposition.y",
+ "lightposition.z",
+ "flatshading",
+ "alphahull",
+ "delaunayaxis",
+ "opacity"
+ ].forEach(function(x) {
+ coerce(x);
+ });
+ var showContour = coerce("contour.show");
+ if (showContour) {
+ coerce("contour.color");
+ coerce("contour.width");
+ }
+ if ("intensity" in traceIn) {
+ coerce("intensity");
+ coerce("intensitymode");
+ colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: "", cLetter: "c" });
+ } else {
+ traceOut.showscale = false;
+ if ("facecolor" in traceIn) coerce("facecolor");
+ else if ("vertexcolor" in traceIn) coerce("vertexcolor");
+ else coerce("color", defaultColor);
+ }
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ coerce("xhoverformat");
+ coerce("yhoverformat");
+ coerce("zhoverformat");
+ traceOut._length = null;
+ };
+ }
+ });
+
+ // src/traces/mesh3d/calc.js
+ var require_calc25 = __commonJS({
+ "src/traces/mesh3d/calc.js"(exports, module) {
+ "use strict";
+ var colorscaleCalc = require_calc();
+ module.exports = function calc(gd, trace) {
+ if (trace.intensity) {
+ colorscaleCalc(gd, trace, {
+ vals: trace.intensity,
+ containerStr: "",
+ cLetter: "c"
+ });
+ }
+ };
+ }
+ });
+
+ // src/traces/mesh3d/convert.js
+ var require_convert7 = __commonJS({
+ "src/traces/mesh3d/convert.js"(exports, module) {
+ "use strict";
+ var createMesh = require_stackgl_modules().gl_mesh3d;
+ var triangulate = require_stackgl_modules().delaunay_triangulate;
+ var alphaShape = require_stackgl_modules().alpha_shape;
+ var convexHull = require_stackgl_modules().convex_hull;
+ var parseColorScale = require_gl_format_color().parseColorScale;
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ var str2RgbaArray = require_str2rgbarray();
+ var extractOpts = require_colorscale().extractOpts;
+ var zip3 = require_zip3();
+ function Mesh3DTrace(scene, mesh, uid) {
+ this.scene = scene;
+ this.uid = uid;
+ this.mesh = mesh;
+ this.name = "";
+ this.color = "#fff";
+ this.data = null;
+ this.showContour = false;
+ }
+ var proto = Mesh3DTrace.prototype;
+ proto.handlePick = function(selection) {
+ if (selection.object === this.mesh) {
+ var selectIndex = selection.index = selection.data.index;
+ if (selection.data._cellCenter) {
+ selection.traceCoordinate = selection.data.dataCoordinate;
+ } else {
+ selection.traceCoordinate = [
+ this.data.x[selectIndex],
+ this.data.y[selectIndex],
+ this.data.z[selectIndex]
+ ];
+ }
+ var text = this.data.hovertext || this.data.text;
+ if (isArrayOrTypedArray(text) && text[selectIndex] !== void 0) {
+ selection.textLabel = text[selectIndex];
+ } else if (text) {
+ selection.textLabel = text;
+ }
+ return true;
+ }
+ };
+ function parseColorArray(colors) {
+ var b = [];
+ var len = colors.length;
+ for (var i = 0; i < len; i++) {
+ b[i] = str2RgbaArray(colors[i]);
+ }
+ return b;
+ }
+ function toDataCoords(axis, coord, scale, calendar) {
+ var b = [];
+ var len = coord.length;
+ for (var i = 0; i < len; i++) {
+ b[i] = axis.d2l(coord[i], 0, calendar) * scale;
+ }
+ return b;
+ }
+ function toRoundIndex(a) {
+ var b = [];
+ var len = a.length;
+ for (var i = 0; i < len; i++) {
+ b[i] = Math.round(a[i]);
+ }
+ return b;
+ }
+ function delaunayCells(delaunayaxis, positions) {
+ var d = ["x", "y", "z"].indexOf(delaunayaxis);
+ var b = [];
+ var len = positions.length;
+ for (var i = 0; i < len; i++) {
+ b[i] = [positions[i][(d + 1) % 3], positions[i][(d + 2) % 3]];
+ }
+ return triangulate(b);
+ }
+ function hasValidIndices(list, numVertices) {
+ var len = list.length;
+ for (var i = 0; i < len; i++) {
+ if (list[i] <= -0.5 || list[i] >= numVertices - 0.5) {
+ return false;
+ }
+ }
+ return true;
+ }
+ proto.update = function(data) {
+ var scene = this.scene;
+ var layout = scene.fullSceneLayout;
+ this.data = data;
+ var numVertices = data.x.length;
+ var positions = zip3(
+ toDataCoords(layout.xaxis, data.x, scene.dataScale[0], data.xcalendar),
+ toDataCoords(layout.yaxis, data.y, scene.dataScale[1], data.ycalendar),
+ toDataCoords(layout.zaxis, data.z, scene.dataScale[2], data.zcalendar)
+ );
+ var cells;
+ if (data.i && data.j && data.k) {
+ if (data.i.length !== data.j.length || data.j.length !== data.k.length || !hasValidIndices(data.i, numVertices) || !hasValidIndices(data.j, numVertices) || !hasValidIndices(data.k, numVertices)) {
+ return;
+ }
+ cells = zip3(
+ toRoundIndex(data.i),
+ toRoundIndex(data.j),
+ toRoundIndex(data.k)
+ );
+ } else if (data.alphahull === 0) {
+ cells = convexHull(positions);
+ } else if (data.alphahull > 0) {
+ cells = alphaShape(data.alphahull, positions);
+ } else {
+ cells = delaunayCells(data.delaunayaxis, positions);
+ }
+ var config = {
+ positions,
+ cells,
+ lightPosition: [data.lightposition.x, data.lightposition.y, data.lightposition.z],
+ ambient: data.lighting.ambient,
+ diffuse: data.lighting.diffuse,
+ specular: data.lighting.specular,
+ roughness: data.lighting.roughness,
+ fresnel: data.lighting.fresnel,
+ vertexNormalsEpsilon: data.lighting.vertexnormalsepsilon,
+ faceNormalsEpsilon: data.lighting.facenormalsepsilon,
+ opacity: data.opacity,
+ contourEnable: data.contour.show,
+ contourColor: str2RgbaArray(data.contour.color).slice(0, 3),
+ contourWidth: data.contour.width,
+ useFacetNormals: data.flatshading
+ };
+ if (data.intensity) {
+ var cOpts = extractOpts(data);
+ this.color = "#fff";
+ var mode = data.intensitymode;
+ config[mode + "Intensity"] = data.intensity;
+ config[mode + "IntensityBounds"] = [cOpts.min, cOpts.max];
+ config.colormap = parseColorScale(data);
+ } else if (data.vertexcolor) {
+ this.color = data.vertexcolor[0];
+ config.vertexColors = parseColorArray(data.vertexcolor);
+ } else if (data.facecolor) {
+ this.color = data.facecolor[0];
+ config.cellColors = parseColorArray(data.facecolor);
+ } else {
+ this.color = data.color;
+ config.meshColor = str2RgbaArray(data.color);
+ }
+ this.mesh.update(config);
+ };
+ proto.dispose = function() {
+ this.scene.glplot.remove(this.mesh);
+ this.mesh.dispose();
+ };
+ function createMesh3DTrace(scene, data) {
+ var gl2 = scene.glplot.gl;
+ var mesh = createMesh({ gl: gl2 });
+ var result = new Mesh3DTrace(scene, mesh, data.uid);
+ mesh._trace = result;
+ result.update(data);
+ scene.glplot.add(mesh);
+ return result;
+ }
+ module.exports = createMesh3DTrace;
+ }
+ });
+
+ // src/traces/mesh3d/index.js
+ var require_mesh3d = __commonJS({
+ "src/traces/mesh3d/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes43(),
+ supplyDefaults: require_defaults41(),
+ calc: require_calc25(),
+ colorbar: {
+ min: "cmin",
+ max: "cmax"
+ },
+ plot: require_convert7(),
+ moduleType: "trace",
+ name: "mesh3d",
+ basePlotModule: require_gl3d(),
+ categories: ["gl3d", "showLegend"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/mesh3d.js
+ var require_mesh3d2 = __commonJS({
+ "lib/mesh3d.js"(exports, module) {
+ "use strict";
+ module.exports = require_mesh3d();
+ }
+ });
+
+ // src/traces/cone/attributes.js
+ var require_attributes46 = __commonJS({
+ "src/traces/cone/attributes.js"(exports, module) {
+ "use strict";
+ var colorScaleAttrs = require_attributes8();
+ var axisHoverFormat = require_axis_format_attributes().axisHoverFormat;
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var mesh3dAttrs = require_attributes43();
+ var baseAttrs = require_attributes2();
+ var extendFlat = require_extend().extendFlat;
+ var attrs = {
+ x: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ y: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ z: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ u: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ v: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ w: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ // TODO add way to specify cone positions independently of the vector field
+ // provided, similar to MATLAB's coneplot Cx/Cy/Cz meshgrids,
+ // see https://www.mathworks.com/help/matlab/ref/coneplot.html
+ //
+ // Alternatively, if our goal is only to 'fill in gaps' in the vector data,
+ // we could try to extend the heatmap 'connectgaps' algorithm to 3D.
+ // From AJ: this particular algorithm which amounts to a Poisson equation,
+ // both for interpolation and extrapolation - is the right one to use for
+ // cones too. It makes a field with zero divergence, which is a good
+ // baseline assumption for vector fields.
+ //
+ // cones: {
+ // // potential attributes to add:
+ // //
+ // // - meshmode: 'cartesian-product', 'pts', 'grid'
+ // //
+ // // under `meshmode: 'grid'`
+ // // - (x|y|z)grid.start
+ // // - (x|y|z)grid.end
+ // // - (x|y|z)grid.size
+ //
+ // x: {
+ // valType: 'data_array',
+ // editType: 'calc',
+ //
+ // },
+ // y: {
+ // valType: 'data_array',
+ // editType: 'calc',
+ //
+ // },
+ // z: {
+ // valType: 'data_array',
+ // editType: 'calc',
+ //
+ // },
+ //
+ // editType: 'calc',
+ //
+ // },
+ sizemode: {
+ valType: "enumerated",
+ values: ["scaled", "absolute", "raw"],
+ editType: "calc",
+ dflt: "scaled"
+ },
+ sizeref: {
+ valType: "number",
+ editType: "calc",
+ min: 0
+ },
+ anchor: {
+ valType: "enumerated",
+ editType: "calc",
+ values: ["tip", "tail", "cm", "center"],
+ dflt: "cm"
+ },
+ text: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true,
+ editType: "calc"
+ },
+ hovertext: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true,
+ editType: "calc"
+ },
+ hovertemplate: hovertemplateAttrs({ editType: "calc" }, { keys: ["norm"] }),
+ uhoverformat: axisHoverFormat("u", 1),
+ vhoverformat: axisHoverFormat("v", 1),
+ whoverformat: axisHoverFormat("w", 1),
+ xhoverformat: axisHoverFormat("x"),
+ yhoverformat: axisHoverFormat("y"),
+ zhoverformat: axisHoverFormat("z"),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ };
+ extendFlat(attrs, colorScaleAttrs("", {
+ colorAttr: "u/v/w norm",
+ showScaleDflt: true,
+ editTypeOverride: "calc"
+ }));
+ var fromMesh3d = ["opacity", "lightposition", "lighting"];
+ fromMesh3d.forEach(function(k) {
+ attrs[k] = mesh3dAttrs[k];
+ });
+ attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {
+ editType: "calc",
+ flags: ["x", "y", "z", "u", "v", "w", "norm", "text", "name"],
+ dflt: "x+y+z+norm+text+name"
+ });
+ module.exports = attrs;
+ }
+ });
+
+ // src/traces/cone/defaults.js
+ var require_defaults42 = __commonJS({
+ "src/traces/cone/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var colorscaleDefaults = require_defaults2();
+ var attributes = require_attributes46();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var u = coerce("u");
+ var v = coerce("v");
+ var w = coerce("w");
+ var x = coerce("x");
+ var y = coerce("y");
+ var z = coerce("z");
+ if (!u || !u.length || !v || !v.length || !w || !w.length || !x || !x.length || !y || !y.length || !z || !z.length) {
+ traceOut.visible = false;
+ return;
+ }
+ var sizemode = coerce("sizemode");
+ coerce("sizeref", sizemode === "raw" ? 1 : 0.5);
+ coerce("anchor");
+ coerce("lighting.ambient");
+ coerce("lighting.diffuse");
+ coerce("lighting.specular");
+ coerce("lighting.roughness");
+ coerce("lighting.fresnel");
+ coerce("lightposition.x");
+ coerce("lightposition.y");
+ coerce("lightposition.z");
+ colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: "", cLetter: "c" });
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ coerce("uhoverformat");
+ coerce("vhoverformat");
+ coerce("whoverformat");
+ coerce("xhoverformat");
+ coerce("yhoverformat");
+ coerce("zhoverformat");
+ traceOut._length = null;
+ };
+ }
+ });
+
+ // src/traces/cone/calc.js
+ var require_calc26 = __commonJS({
+ "src/traces/cone/calc.js"(exports, module) {
+ "use strict";
+ var colorscaleCalc = require_calc();
+ module.exports = function calc(gd, trace) {
+ var u = trace.u;
+ var v = trace.v;
+ var w = trace.w;
+ var len = Math.min(
+ trace.x.length,
+ trace.y.length,
+ trace.z.length,
+ u.length,
+ v.length,
+ w.length
+ );
+ var normMax = -Infinity;
+ var normMin = Infinity;
+ for (var i = 0; i < len; i++) {
+ var uu = u[i];
+ var vv = v[i];
+ var ww = w[i];
+ var norm = Math.sqrt(uu * uu + vv * vv + ww * ww);
+ normMax = Math.max(normMax, norm);
+ normMin = Math.min(normMin, norm);
+ }
+ trace._len = len;
+ trace._normMax = normMax;
+ colorscaleCalc(gd, trace, {
+ vals: [normMin, normMax],
+ containerStr: "",
+ cLetter: "c"
+ });
+ };
+ }
+ });
+
+ // src/traces/cone/convert.js
+ var require_convert8 = __commonJS({
+ "src/traces/cone/convert.js"(exports, module) {
+ "use strict";
+ var conePlot = require_stackgl_modules().gl_cone3d;
+ var createConeMesh = require_stackgl_modules().gl_cone3d.createConeMesh;
+ var simpleMap = require_lib().simpleMap;
+ var parseColorScale = require_gl_format_color().parseColorScale;
+ var extractOpts = require_colorscale().extractOpts;
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ var zip3 = require_zip3();
+ function Cone(scene, uid) {
+ this.scene = scene;
+ this.uid = uid;
+ this.mesh = null;
+ this.data = null;
+ }
+ var proto = Cone.prototype;
+ proto.handlePick = function(selection) {
+ if (selection.object === this.mesh) {
+ var selectIndex = selection.index = selection.data.index;
+ var xx = this.data.x[selectIndex];
+ var yy = this.data.y[selectIndex];
+ var zz = this.data.z[selectIndex];
+ var uu = this.data.u[selectIndex];
+ var vv = this.data.v[selectIndex];
+ var ww = this.data.w[selectIndex];
+ selection.traceCoordinate = [
+ xx,
+ yy,
+ zz,
+ uu,
+ vv,
+ ww,
+ Math.sqrt(uu * uu + vv * vv + ww * ww)
+ ];
+ var text = this.data.hovertext || this.data.text;
+ if (isArrayOrTypedArray(text) && text[selectIndex] !== void 0) {
+ selection.textLabel = text[selectIndex];
+ } else if (text) {
+ selection.textLabel = text;
+ }
+ return true;
+ }
+ };
+ var axisName2scaleIndex = { xaxis: 0, yaxis: 1, zaxis: 2 };
+ var anchor2coneOffset = { tip: 1, tail: 0, cm: 0.25, center: 0.5 };
+ var anchor2coneSpan = { tip: 1, tail: 1, cm: 0.75, center: 0.5 };
+ function convert(scene, trace) {
+ var sceneLayout = scene.fullSceneLayout;
+ var dataScale = scene.dataScale;
+ var coneOpts = {};
+ function toDataCoords(arr, axisName) {
+ var ax = sceneLayout[axisName];
+ var scale = dataScale[axisName2scaleIndex[axisName]];
+ return simpleMap(arr, function(v) {
+ return ax.d2l(v) * scale;
+ });
+ }
+ coneOpts.vectors = zip3(
+ toDataCoords(trace.u, "xaxis"),
+ toDataCoords(trace.v, "yaxis"),
+ toDataCoords(trace.w, "zaxis"),
+ trace._len
+ );
+ coneOpts.positions = zip3(
+ toDataCoords(trace.x, "xaxis"),
+ toDataCoords(trace.y, "yaxis"),
+ toDataCoords(trace.z, "zaxis"),
+ trace._len
+ );
+ var cOpts = extractOpts(trace);
+ coneOpts.colormap = parseColorScale(trace);
+ coneOpts.vertexIntensityBounds = [cOpts.min / trace._normMax, cOpts.max / trace._normMax];
+ coneOpts.coneOffset = anchor2coneOffset[trace.anchor];
+ var sizemode = trace.sizemode;
+ if (sizemode === "scaled") {
+ coneOpts.coneSize = trace.sizeref || 0.5;
+ } else if (sizemode === "absolute") {
+ coneOpts.coneSize = trace.sizeref && trace._normMax ? trace.sizeref / trace._normMax : 0.5;
+ } else if (sizemode === "raw") {
+ coneOpts.coneSize = trace.sizeref;
+ }
+ coneOpts.coneSizemode = sizemode;
+ var meshData = conePlot(coneOpts);
+ var lp = trace.lightposition;
+ meshData.lightPosition = [lp.x, lp.y, lp.z];
+ meshData.ambient = trace.lighting.ambient;
+ meshData.diffuse = trace.lighting.diffuse;
+ meshData.specular = trace.lighting.specular;
+ meshData.roughness = trace.lighting.roughness;
+ meshData.fresnel = trace.lighting.fresnel;
+ meshData.opacity = trace.opacity;
+ trace._pad = anchor2coneSpan[trace.anchor] * meshData.vectorScale * meshData.coneScale * trace._normMax;
+ return meshData;
+ }
+ proto.update = function(data) {
+ this.data = data;
+ var meshData = convert(this.scene, data);
+ this.mesh.update(meshData);
+ };
+ proto.dispose = function() {
+ this.scene.glplot.remove(this.mesh);
+ this.mesh.dispose();
+ };
+ function createConeTrace(scene, data) {
+ var gl2 = scene.glplot.gl;
+ var meshData = convert(scene, data);
+ var mesh = createConeMesh(gl2, meshData);
+ var cone = new Cone(scene, data.uid);
+ cone.mesh = mesh;
+ cone.data = data;
+ mesh._trace = cone;
+ scene.glplot.add(mesh);
+ return cone;
+ }
+ module.exports = createConeTrace;
+ }
+ });
+
+ // src/traces/cone/index.js
+ var require_cone = __commonJS({
+ "src/traces/cone/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ moduleType: "trace",
+ name: "cone",
+ basePlotModule: require_gl3d(),
+ categories: ["gl3d", "showLegend"],
+ attributes: require_attributes46(),
+ supplyDefaults: require_defaults42(),
+ colorbar: {
+ min: "cmin",
+ max: "cmax"
+ },
+ calc: require_calc26(),
+ plot: require_convert8(),
+ eventData: function(out, pt) {
+ out.norm = pt.traceCoordinate[6];
+ return out;
+ },
+ meta: {}
+ };
+ }
+ });
+
+ // lib/cone.js
+ var require_cone2 = __commonJS({
+ "lib/cone.js"(exports, module) {
+ "use strict";
+ module.exports = require_cone();
+ }
+ });
+
+ // src/traces/streamtube/attributes.js
+ var require_attributes47 = __commonJS({
+ "src/traces/streamtube/attributes.js"(exports, module) {
+ "use strict";
+ var colorScaleAttrs = require_attributes8();
+ var axisHoverFormat = require_axis_format_attributes().axisHoverFormat;
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var mesh3dAttrs = require_attributes43();
+ var baseAttrs = require_attributes2();
+ var extendFlat = require_extend().extendFlat;
+ var attrs = {
+ x: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ y: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ z: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ u: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ v: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ w: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ starts: {
+ x: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ y: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ z: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ editType: "calc"
+ },
+ maxdisplayed: {
+ valType: "integer",
+ min: 0,
+ dflt: 1e3,
+ editType: "calc"
+ },
+ // TODO
+ //
+ // Should add 'absolute' (like cone traces have), but currently gl-streamtube3d's
+ // `absoluteTubeSize` doesn't behave well enough for our needs.
+ //
+ // 'fixed' would be a nice addition to plot stream 'lines', see
+ // https://github.com/plotly/plotly.js/commit/812be20750e21e0a1831975001c248d365850f73#r29129877
+ //
+ // sizemode: {
+ // valType: 'enumerated',
+ // values: ['scaled', 'absolute', 'fixed'],
+ // dflt: 'scaled',
+ // editType: 'calc',
+ //
+ // },
+ sizeref: {
+ valType: "number",
+ editType: "calc",
+ min: 0,
+ dflt: 1
+ },
+ text: {
+ valType: "string",
+ dflt: "",
+ editType: "calc"
+ },
+ hovertext: {
+ valType: "string",
+ dflt: "",
+ editType: "calc"
+ },
+ hovertemplate: hovertemplateAttrs({ editType: "calc" }, {
+ keys: [
+ "tubex",
+ "tubey",
+ "tubez",
+ "tubeu",
+ "tubev",
+ "tubew",
+ "norm",
+ "divergence"
+ ]
+ }),
+ uhoverformat: axisHoverFormat("u", 1),
+ vhoverformat: axisHoverFormat("v", 1),
+ whoverformat: axisHoverFormat("w", 1),
+ xhoverformat: axisHoverFormat("x"),
+ yhoverformat: axisHoverFormat("y"),
+ zhoverformat: axisHoverFormat("z"),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ };
+ extendFlat(attrs, colorScaleAttrs("", {
+ colorAttr: "u/v/w norm",
+ showScaleDflt: true,
+ editTypeOverride: "calc"
+ }));
+ var fromMesh3d = ["opacity", "lightposition", "lighting"];
+ fromMesh3d.forEach(function(k) {
+ attrs[k] = mesh3dAttrs[k];
+ });
+ attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {
+ editType: "calc",
+ flags: ["x", "y", "z", "u", "v", "w", "norm", "divergence", "text", "name"],
+ dflt: "x+y+z+norm+text+name"
+ });
+ module.exports = attrs;
+ }
+ });
+
+ // src/traces/streamtube/defaults.js
+ var require_defaults43 = __commonJS({
+ "src/traces/streamtube/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var colorscaleDefaults = require_defaults2();
+ var attributes = require_attributes47();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var u = coerce("u");
+ var v = coerce("v");
+ var w = coerce("w");
+ var x = coerce("x");
+ var y = coerce("y");
+ var z = coerce("z");
+ if (!u || !u.length || !v || !v.length || !w || !w.length || !x || !x.length || !y || !y.length || !z || !z.length) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("starts.x");
+ coerce("starts.y");
+ coerce("starts.z");
+ coerce("maxdisplayed");
+ coerce("sizeref");
+ coerce("lighting.ambient");
+ coerce("lighting.diffuse");
+ coerce("lighting.specular");
+ coerce("lighting.roughness");
+ coerce("lighting.fresnel");
+ coerce("lightposition.x");
+ coerce("lightposition.y");
+ coerce("lightposition.z");
+ colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: "", cLetter: "c" });
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ coerce("uhoverformat");
+ coerce("vhoverformat");
+ coerce("whoverformat");
+ coerce("xhoverformat");
+ coerce("yhoverformat");
+ coerce("zhoverformat");
+ traceOut._length = null;
+ };
+ }
+ });
+
+ // src/traces/streamtube/convert.js
+ var require_convert9 = __commonJS({
+ "src/traces/streamtube/convert.js"(exports, module) {
+ "use strict";
+ var tube2mesh = require_stackgl_modules().gl_streamtube3d;
+ var createTubeMesh = tube2mesh.createTubeMesh;
+ var Lib = require_lib();
+ var parseColorScale = require_gl_format_color().parseColorScale;
+ var extractOpts = require_colorscale().extractOpts;
+ var zip3 = require_zip3();
+ var axisName2scaleIndex = { xaxis: 0, yaxis: 1, zaxis: 2 };
+ function Streamtube(scene, uid) {
+ this.scene = scene;
+ this.uid = uid;
+ this.mesh = null;
+ this.data = null;
+ }
+ var proto = Streamtube.prototype;
+ proto.handlePick = function(selection) {
+ var sceneLayout = this.scene.fullSceneLayout;
+ var dataScale = this.scene.dataScale;
+ function fromDataScale(v, axisName) {
+ var ax = sceneLayout[axisName];
+ var scale = dataScale[axisName2scaleIndex[axisName]];
+ return ax.l2c(v) / scale;
+ }
+ if (selection.object === this.mesh) {
+ var pos = selection.data.position;
+ var uvx = selection.data.velocity;
+ selection.traceCoordinate = [
+ fromDataScale(pos[0], "xaxis"),
+ fromDataScale(pos[1], "yaxis"),
+ fromDataScale(pos[2], "zaxis"),
+ fromDataScale(uvx[0], "xaxis"),
+ fromDataScale(uvx[1], "yaxis"),
+ fromDataScale(uvx[2], "zaxis"),
+ // u/v/w norm
+ selection.data.intensity * this.data._normMax,
+ // divergence
+ selection.data.divergence
+ ];
+ selection.textLabel = this.data.hovertext || this.data.text;
+ return true;
+ }
+ };
+ function getDfltStartingPositions(vec) {
+ var len = vec.length;
+ var s;
+ if (len > 2) {
+ s = vec.slice(1, len - 1);
+ } else if (len === 2) {
+ s = [(vec[0] + vec[1]) / 2];
+ } else {
+ s = vec;
+ }
+ return s;
+ }
+ function getBoundPads(vec) {
+ var len = vec.length;
+ if (len === 1) {
+ return [0.5, 0.5];
+ } else {
+ return [vec[1] - vec[0], vec[len - 1] - vec[len - 2]];
+ }
+ }
+ function convert(scene, trace) {
+ var sceneLayout = scene.fullSceneLayout;
+ var dataScale = scene.dataScale;
+ var len = trace._len;
+ var tubeOpts = {};
+ function toDataCoords(arr, axisName) {
+ var ax = sceneLayout[axisName];
+ var scale = dataScale[axisName2scaleIndex[axisName]];
+ return Lib.simpleMap(arr, function(v) {
+ return ax.d2l(v) * scale;
+ });
+ }
+ tubeOpts.vectors = zip3(
+ toDataCoords(trace._u, "xaxis"),
+ toDataCoords(trace._v, "yaxis"),
+ toDataCoords(trace._w, "zaxis"),
+ len
+ );
+ if (!len) {
+ return {
+ positions: [],
+ cells: []
+ };
+ }
+ var meshx = toDataCoords(trace._Xs, "xaxis");
+ var meshy = toDataCoords(trace._Ys, "yaxis");
+ var meshz = toDataCoords(trace._Zs, "zaxis");
+ tubeOpts.meshgrid = [meshx, meshy, meshz];
+ tubeOpts.gridFill = trace._gridFill;
+ var slen = trace._slen;
+ if (slen) {
+ tubeOpts.startingPositions = zip3(
+ toDataCoords(trace._startsX, "xaxis"),
+ toDataCoords(trace._startsY, "yaxis"),
+ toDataCoords(trace._startsZ, "zaxis")
+ );
+ } else {
+ var sy0 = meshy[0];
+ var sx = getDfltStartingPositions(meshx);
+ var sz = getDfltStartingPositions(meshz);
+ var startingPositions = new Array(sx.length * sz.length);
+ var m = 0;
+ for (var i = 0; i < sx.length; i++) {
+ for (var k = 0; k < sz.length; k++) {
+ startingPositions[m++] = [sx[i], sy0, sz[k]];
+ }
+ }
+ tubeOpts.startingPositions = startingPositions;
+ }
+ tubeOpts.colormap = parseColorScale(trace);
+ tubeOpts.tubeSize = trace.sizeref;
+ tubeOpts.maxLength = trace.maxdisplayed;
+ var xbnds = toDataCoords(trace._xbnds, "xaxis");
+ var ybnds = toDataCoords(trace._ybnds, "yaxis");
+ var zbnds = toDataCoords(trace._zbnds, "zaxis");
+ var xpads = getBoundPads(meshx);
+ var ypads = getBoundPads(meshy);
+ var zpads = getBoundPads(meshz);
+ var bounds = [
+ [xbnds[0] - xpads[0], ybnds[0] - ypads[0], zbnds[0] - zpads[0]],
+ [xbnds[1] + xpads[1], ybnds[1] + ypads[1], zbnds[1] + zpads[1]]
+ ];
+ var meshData = tube2mesh(tubeOpts, bounds);
+ var cOpts = extractOpts(trace);
+ meshData.vertexIntensityBounds = [cOpts.min / trace._normMax, cOpts.max / trace._normMax];
+ var lp = trace.lightposition;
+ meshData.lightPosition = [lp.x, lp.y, lp.z];
+ meshData.ambient = trace.lighting.ambient;
+ meshData.diffuse = trace.lighting.diffuse;
+ meshData.specular = trace.lighting.specular;
+ meshData.roughness = trace.lighting.roughness;
+ meshData.fresnel = trace.lighting.fresnel;
+ meshData.opacity = trace.opacity;
+ trace._pad = meshData.tubeScale * trace.sizeref * 2;
+ return meshData;
+ }
+ proto.update = function(data) {
+ this.data = data;
+ var meshData = convert(this.scene, data);
+ this.mesh.update(meshData);
+ };
+ proto.dispose = function() {
+ this.scene.glplot.remove(this.mesh);
+ this.mesh.dispose();
+ };
+ function createStreamtubeTrace(scene, data) {
+ var gl2 = scene.glplot.gl;
+ var meshData = convert(scene, data);
+ var mesh = createTubeMesh(gl2, meshData);
+ var streamtube = new Streamtube(scene, data.uid);
+ streamtube.mesh = mesh;
+ streamtube.data = data;
+ mesh._trace = streamtube;
+ scene.glplot.add(mesh);
+ return streamtube;
+ }
+ module.exports = createStreamtubeTrace;
+ }
+ });
+
+ // src/traces/streamtube/index.js
+ var require_streamtube = __commonJS({
+ "src/traces/streamtube/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ moduleType: "trace",
+ name: "streamtube",
+ basePlotModule: require_gl3d(),
+ categories: ["gl3d", "showLegend"],
+ attributes: require_attributes47(),
+ supplyDefaults: require_defaults43(),
+ colorbar: {
+ min: "cmin",
+ max: "cmax"
+ },
+ calc: require_calc23().calc,
+ plot: require_convert9(),
+ eventData: function(out, pt) {
+ out.tubex = out.x;
+ out.tubey = out.y;
+ out.tubez = out.z;
+ out.tubeu = pt.traceCoordinate[3];
+ out.tubev = pt.traceCoordinate[4];
+ out.tubew = pt.traceCoordinate[5];
+ out.norm = pt.traceCoordinate[6];
+ out.divergence = pt.traceCoordinate[7];
+ delete out.x;
+ delete out.y;
+ delete out.z;
+ return out;
+ },
+ meta: {}
+ };
+ }
+ });
+
+ // lib/streamtube.js
+ var require_streamtube2 = __commonJS({
+ "lib/streamtube.js"(exports, module) {
+ "use strict";
+ module.exports = require_streamtube();
+ }
+ });
+
+ // src/traces/scattergeo/attributes.js
+ var require_attributes48 = __commonJS({
+ "src/traces/scattergeo/attributes.js"(exports, module) {
+ "use strict";
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var texttemplateAttrs = require_template_attributes().texttemplateAttrs;
+ var makeFillcolorAttr = require_fillcolor_attribute();
+ var scatterAttrs = require_attributes12();
+ var baseAttrs = require_attributes2();
+ var colorAttributes = require_attributes8();
+ var dash = require_attributes4().dash;
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var scatterMarkerAttrs = scatterAttrs.marker;
+ var scatterLineAttrs = scatterAttrs.line;
+ var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
+ module.exports = overrideAll({
+ lon: {
+ valType: "data_array"
+ },
+ lat: {
+ valType: "data_array"
+ },
+ locations: {
+ valType: "data_array"
+ },
+ locationmode: {
+ valType: "enumerated",
+ values: ["ISO-3", "USA-states", "country names", "geojson-id"],
+ dflt: "ISO-3"
+ },
+ geojson: {
+ valType: "any",
+ editType: "calc"
+ },
+ featureidkey: {
+ valType: "string",
+ editType: "calc",
+ dflt: "id"
+ },
+ mode: extendFlat({}, scatterAttrs.mode, { dflt: "markers" }),
+ text: extendFlat({}, scatterAttrs.text, {}),
+ texttemplate: texttemplateAttrs({ editType: "plot" }, {
+ keys: ["lat", "lon", "location", "text"]
+ }),
+ hovertext: extendFlat({}, scatterAttrs.hovertext, {}),
+ textfont: scatterAttrs.textfont,
+ textposition: scatterAttrs.textposition,
+ line: {
+ color: scatterLineAttrs.color,
+ width: scatterLineAttrs.width,
+ dash
+ },
+ connectgaps: scatterAttrs.connectgaps,
+ marker: extendFlat(
+ {
+ symbol: scatterMarkerAttrs.symbol,
+ opacity: scatterMarkerAttrs.opacity,
+ angle: scatterMarkerAttrs.angle,
+ angleref: extendFlat({}, scatterMarkerAttrs.angleref, {
+ values: ["previous", "up", "north"]
+ }),
+ standoff: scatterMarkerAttrs.standoff,
+ size: scatterMarkerAttrs.size,
+ sizeref: scatterMarkerAttrs.sizeref,
+ sizemin: scatterMarkerAttrs.sizemin,
+ sizemode: scatterMarkerAttrs.sizemode,
+ colorbar: scatterMarkerAttrs.colorbar,
+ line: extendFlat(
+ {
+ width: scatterMarkerLineAttrs.width
+ },
+ colorAttributes("marker.line")
+ ),
+ gradient: scatterMarkerAttrs.gradient
+ },
+ colorAttributes("marker")
+ ),
+ fill: {
+ valType: "enumerated",
+ values: ["none", "toself"],
+ dflt: "none"
+ },
+ fillcolor: makeFillcolorAttr(),
+ selected: scatterAttrs.selected,
+ unselected: scatterAttrs.unselected,
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ flags: ["lon", "lat", "location", "text", "name"]
+ }),
+ hovertemplate: hovertemplateAttrs()
+ }, "calc", "nested");
+ }
+ });
+
+ // src/traces/scattergeo/defaults.js
+ var require_defaults44 = __commonJS({
+ "src/traces/scattergeo/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var subTypes = require_subtypes();
+ var handleMarkerDefaults = require_marker_defaults();
+ var handleLineDefaults = require_line_defaults();
+ var handleTextDefaults = require_text_defaults();
+ var handleFillColorDefaults = require_fillcolor_defaults();
+ var attributes = require_attributes48();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var locations = coerce("locations");
+ var len;
+ if (locations && locations.length) {
+ var geojson = coerce("geojson");
+ var locationmodeDflt;
+ if (typeof geojson === "string" && geojson !== "" || Lib.isPlainObject(geojson)) {
+ locationmodeDflt = "geojson-id";
+ }
+ var locationMode = coerce("locationmode", locationmodeDflt);
+ if (locationMode === "geojson-id") {
+ coerce("featureidkey");
+ }
+ len = locations.length;
+ } else {
+ var lon = coerce("lon") || [];
+ var lat = coerce("lat") || [];
+ len = Math.min(lon.length, lat.length);
+ }
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ traceOut._length = len;
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ coerce("mode");
+ if (subTypes.hasMarkers(traceOut)) {
+ handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, { gradient: true });
+ }
+ if (subTypes.hasLines(traceOut)) {
+ handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
+ coerce("connectgaps");
+ }
+ if (subTypes.hasText(traceOut)) {
+ coerce("texttemplate");
+ handleTextDefaults(traceIn, traceOut, layout, coerce);
+ }
+ coerce("fill");
+ if (traceOut.fill !== "none") {
+ handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
+ }
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ }
+ });
+
+ // src/traces/scattergeo/format_labels.js
+ var require_format_labels3 = __commonJS({
+ "src/traces/scattergeo/format_labels.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ module.exports = function formatLabels(cdi, trace, fullLayout) {
+ var labels = {};
+ var geo = fullLayout[trace.geo]._subplot;
+ var ax = geo.mockAxis;
+ var lonlat = cdi.lonlat;
+ labels.lonLabel = Axes.tickText(ax, ax.c2l(lonlat[0]), true).text;
+ labels.latLabel = Axes.tickText(ax, ax.c2l(lonlat[1]), true).text;
+ return labels;
+ };
+ }
+ });
+
+ // src/traces/scattergeo/calc.js
+ var require_calc27 = __commonJS({
+ "src/traces/scattergeo/calc.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var BADNUM = require_numerical().BADNUM;
+ var calcMarkerColorscale = require_colorscale_calc();
+ var arraysToCalcdata = require_arrays_to_calcdata();
+ var calcSelection = require_calc_selection();
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ var _ = require_lib()._;
+ function isNonBlankString(v) {
+ return v && typeof v === "string";
+ }
+ module.exports = function calc(gd, trace) {
+ var hasLocationData = isArrayOrTypedArray(trace.locations);
+ var len = hasLocationData ? trace.locations.length : trace._length;
+ var calcTrace = new Array(len);
+ var isValidLoc;
+ if (trace.geojson) {
+ isValidLoc = function(v) {
+ return isNonBlankString(v) || isNumeric(v);
+ };
+ } else {
+ isValidLoc = isNonBlankString;
+ }
+ for (var i = 0; i < len; i++) {
+ var calcPt = calcTrace[i] = {};
+ if (hasLocationData) {
+ var loc = trace.locations[i];
+ calcPt.loc = isValidLoc(loc) ? loc : null;
+ } else {
+ var lon = trace.lon[i];
+ var lat = trace.lat[i];
+ if (isNumeric(lon) && isNumeric(lat)) calcPt.lonlat = [+lon, +lat];
+ else calcPt.lonlat = [BADNUM, BADNUM];
+ }
+ }
+ arraysToCalcdata(calcTrace, trace);
+ calcMarkerColorscale(gd, trace);
+ calcSelection(calcTrace, trace);
+ if (len) {
+ calcTrace[0].t = {
+ labels: {
+ lat: _(gd, "lat:") + " ",
+ lon: _(gd, "lon:") + " "
+ }
+ };
+ }
+ return calcTrace;
+ };
+ }
+ });
+
+ // src/plots/geo/constants.js
+ var require_constants22 = __commonJS({
+ "src/plots/geo/constants.js"(exports) {
+ "use strict";
+ exports.projNames = {
+ airy: "airy",
+ aitoff: "aitoff",
+ "albers usa": "albersUsa",
+ albers: "albers",
+ // 'armadillo': 'armadillo',
+ august: "august",
+ "azimuthal equal area": "azimuthalEqualArea",
+ "azimuthal equidistant": "azimuthalEquidistant",
+ baker: "baker",
+ // 'berghaus': 'berghaus',
+ bertin1953: "bertin1953",
+ boggs: "boggs",
+ bonne: "bonne",
+ bottomley: "bottomley",
+ bromley: "bromley",
+ // 'chamberlin africa': 'chamberlinAfrica',
+ // 'chamberlin': 'chamberlin',
+ collignon: "collignon",
+ "conic conformal": "conicConformal",
+ "conic equal area": "conicEqualArea",
+ "conic equidistant": "conicEquidistant",
+ craig: "craig",
+ craster: "craster",
+ "cylindrical equal area": "cylindricalEqualArea",
+ "cylindrical stereographic": "cylindricalStereographic",
+ eckert1: "eckert1",
+ eckert2: "eckert2",
+ eckert3: "eckert3",
+ eckert4: "eckert4",
+ eckert5: "eckert5",
+ eckert6: "eckert6",
+ eisenlohr: "eisenlohr",
+ "equal earth": "equalEarth",
+ equirectangular: "equirectangular",
+ fahey: "fahey",
+ "foucaut sinusoidal": "foucautSinusoidal",
+ foucaut: "foucaut",
+ // 'gilbert': 'gilbert',
+ // 'gingery': 'gingery',
+ ginzburg4: "ginzburg4",
+ ginzburg5: "ginzburg5",
+ ginzburg6: "ginzburg6",
+ ginzburg8: "ginzburg8",
+ ginzburg9: "ginzburg9",
+ gnomonic: "gnomonic",
+ "gringorten quincuncial": "gringortenQuincuncial",
+ gringorten: "gringorten",
+ guyou: "guyou",
+ // 'hammer retroazimuthal': 'hammerRetroazimuthal',
+ hammer: "hammer",
+ // 'healpix': 'healpix',
+ hill: "hill",
+ homolosine: "homolosine",
+ hufnagel: "hufnagel",
+ hyperelliptical: "hyperelliptical",
+ // 'interrupted boggs': 'interruptedBoggs',
+ // 'interrupted homolosine': 'interruptedHomolosine',
+ // 'interrupted mollweide hemispheres': 'interruptedMollweideHemispheres',
+ // 'interrupted mollweide': 'interruptedMollweide',
+ // 'interrupted quartic authalic': 'interruptedQuarticAuthalic',
+ // 'interrupted sinu mollweide': 'interruptedSinuMollweide',
+ // 'interrupted sinusoidal': 'interruptedSinusoidal',
+ kavrayskiy7: "kavrayskiy7",
+ lagrange: "lagrange",
+ larrivee: "larrivee",
+ laskowski: "laskowski",
+ // 'littrow': 'littrow',
+ loximuthal: "loximuthal",
+ mercator: "mercator",
+ miller: "miller",
+ // 'modified stereographic alaska': 'modifiedStereographicAlaska',
+ // 'modified stereographic gs48': 'modifiedStereographicGs48',
+ // 'modified stereographic gs50': 'modifiedStereographicGs50',
+ // 'modified stereographic lee': 'modifiedStereographicLee',
+ // 'modified stereographic miller': 'modifiedStereographicMiller',
+ // 'modified stereographic': 'modifiedStereographic',
+ mollweide: "mollweide",
+ "mt flat polar parabolic": "mtFlatPolarParabolic",
+ "mt flat polar quartic": "mtFlatPolarQuartic",
+ "mt flat polar sinusoidal": "mtFlatPolarSinusoidal",
+ "natural earth": "naturalEarth",
+ "natural earth1": "naturalEarth1",
+ "natural earth2": "naturalEarth2",
+ "nell hammer": "nellHammer",
+ nicolosi: "nicolosi",
+ orthographic: "orthographic",
+ patterson: "patterson",
+ "peirce quincuncial": "peirceQuincuncial",
+ polyconic: "polyconic",
+ // 'polyhedral butterfly': 'polyhedralButterfly',
+ // 'polyhedral collignon': 'polyhedralCollignon',
+ // 'polyhedral waterman': 'polyhedralWaterman',
+ "rectangular polyconic": "rectangularPolyconic",
+ robinson: "robinson",
+ satellite: "satellite",
+ "sinu mollweide": "sinuMollweide",
+ sinusoidal: "sinusoidal",
+ stereographic: "stereographic",
+ times: "times",
+ "transverse mercator": "transverseMercator",
+ // 'two point azimuthalUsa': 'twoPointAzimuthalUsa',
+ // 'two point azimuthal': 'twoPointAzimuthal',
+ // 'two point equidistantUsa': 'twoPointEquidistantUsa',
+ // 'two point equidistant': 'twoPointEquidistant',
+ "van der grinten": "vanDerGrinten",
+ "van der grinten2": "vanDerGrinten2",
+ "van der grinten3": "vanDerGrinten3",
+ "van der grinten4": "vanDerGrinten4",
+ wagner4: "wagner4",
+ wagner6: "wagner6",
+ // 'wagner7': 'wagner7',
+ // 'wagner': 'wagner',
+ wiechel: "wiechel",
+ "winkel tripel": "winkel3",
+ winkel3: "winkel3"
+ };
+ exports.axesNames = ["lonaxis", "lataxis"];
+ exports.lonaxisSpan = {
+ orthographic: 180,
+ "azimuthal equal area": 360,
+ "azimuthal equidistant": 360,
+ "conic conformal": 180,
+ gnomonic: 160,
+ stereographic: 180,
+ "transverse mercator": 180,
+ "*": 360
+ };
+ exports.lataxisSpan = {
+ "conic conformal": 150,
+ stereographic: 179.5,
+ "*": 180
+ };
+ exports.scopeDefaults = {
+ world: {
+ lonaxisRange: [-180, 180],
+ lataxisRange: [-90, 90],
+ projType: "equirectangular",
+ projRotate: [0, 0, 0]
+ },
+ usa: {
+ lonaxisRange: [-180, -50],
+ lataxisRange: [15, 80],
+ projType: "albers usa"
+ },
+ europe: {
+ lonaxisRange: [-30, 60],
+ lataxisRange: [30, 85],
+ projType: "conic conformal",
+ projRotate: [15, 0, 0],
+ projParallels: [0, 60]
+ },
+ asia: {
+ lonaxisRange: [22, 160],
+ lataxisRange: [-15, 55],
+ projType: "mercator",
+ projRotate: [0, 0, 0]
+ },
+ africa: {
+ lonaxisRange: [-30, 60],
+ lataxisRange: [-40, 40],
+ projType: "mercator",
+ projRotate: [0, 0, 0]
+ },
+ "north america": {
+ lonaxisRange: [-180, -45],
+ lataxisRange: [5, 85],
+ projType: "conic conformal",
+ projRotate: [-100, 0, 0],
+ projParallels: [29.5, 45.5]
+ },
+ "south america": {
+ lonaxisRange: [-100, -30],
+ lataxisRange: [-60, 15],
+ projType: "mercator",
+ projRotate: [0, 0, 0]
+ }
+ };
+ exports.clipPad = 1e-3;
+ exports.precision = 0.1;
+ exports.landColor = "#F0DC82";
+ exports.waterColor = "#3399FF";
+ exports.locationmodeToLayer = {
+ "ISO-3": "countries",
+ "USA-states": "subunits",
+ "country names": "countries"
+ };
+ exports.sphereSVG = { type: "Sphere" };
+ exports.fillLayers = {
+ ocean: 1,
+ land: 1,
+ lakes: 1
+ };
+ exports.lineLayers = {
+ subunits: 1,
+ countries: 1,
+ coastlines: 1,
+ rivers: 1,
+ frame: 1
+ };
+ exports.layers = [
+ "bg",
+ "ocean",
+ "land",
+ "lakes",
+ "subunits",
+ "countries",
+ "coastlines",
+ "rivers",
+ "lataxis",
+ "lonaxis",
+ "frame",
+ "backplot",
+ "frontplot"
+ ];
+ exports.layersForChoropleth = [
+ "bg",
+ "ocean",
+ "land",
+ "subunits",
+ "countries",
+ "coastlines",
+ "lataxis",
+ "lonaxis",
+ "frame",
+ "backplot",
+ "rivers",
+ "lakes",
+ "frontplot"
+ ];
+ exports.layerNameToAdjective = {
+ ocean: "ocean",
+ land: "land",
+ lakes: "lake",
+ subunits: "subunit",
+ countries: "country",
+ coastlines: "coastline",
+ rivers: "river",
+ frame: "frame"
+ };
+ }
+ });
+
+ // node_modules/topojson-client/dist/topojson-client.js
+ var require_topojson_client = __commonJS({
+ "node_modules/topojson-client/dist/topojson-client.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && false ? define(["exports"], factory) : (global2 = global2 || self, factory(global2.topojson = global2.topojson || {}));
+ })(exports, function(exports2) {
+ "use strict";
+ function identity2(x) {
+ return x;
+ }
+ function transform(transform2) {
+ if (transform2 == null) return identity2;
+ var x0, y0, kx = transform2.scale[0], ky = transform2.scale[1], dx = transform2.translate[0], dy = transform2.translate[1];
+ return function(input, i) {
+ if (!i) x0 = y0 = 0;
+ var j = 2, n = input.length, output = new Array(n);
+ output[0] = (x0 += input[0]) * kx + dx;
+ output[1] = (y0 += input[1]) * ky + dy;
+ while (j < n) output[j] = input[j], ++j;
+ return output;
+ };
+ }
+ function bbox(topology) {
+ var t = transform(topology.transform), key, x0 = Infinity, y0 = x0, x1 = -x0, y1 = -x0;
+ function bboxPoint(p) {
+ p = t(p);
+ if (p[0] < x0) x0 = p[0];
+ if (p[0] > x1) x1 = p[0];
+ if (p[1] < y0) y0 = p[1];
+ if (p[1] > y1) y1 = p[1];
+ }
+ function bboxGeometry(o) {
+ switch (o.type) {
+ case "GeometryCollection":
+ o.geometries.forEach(bboxGeometry);
+ break;
+ case "Point":
+ bboxPoint(o.coordinates);
+ break;
+ case "MultiPoint":
+ o.coordinates.forEach(bboxPoint);
+ break;
+ }
+ }
+ topology.arcs.forEach(function(arc) {
+ var i = -1, n = arc.length, p;
+ while (++i < n) {
+ p = t(arc[i], i);
+ if (p[0] < x0) x0 = p[0];
+ if (p[0] > x1) x1 = p[0];
+ if (p[1] < y0) y0 = p[1];
+ if (p[1] > y1) y1 = p[1];
+ }
+ });
+ for (key in topology.objects) {
+ bboxGeometry(topology.objects[key]);
+ }
+ return [x0, y0, x1, y1];
+ }
+ function reverse(array, n) {
+ var t, j = array.length, i = j - n;
+ while (i < --j) t = array[i], array[i++] = array[j], array[j] = t;
+ }
+ function feature(topology, o) {
+ if (typeof o === "string") o = topology.objects[o];
+ return o.type === "GeometryCollection" ? { type: "FeatureCollection", features: o.geometries.map(function(o2) {
+ return feature$1(topology, o2);
+ }) } : feature$1(topology, o);
+ }
+ function feature$1(topology, o) {
+ var id = o.id, bbox2 = o.bbox, properties = o.properties == null ? {} : o.properties, geometry = object(topology, o);
+ return id == null && bbox2 == null ? { type: "Feature", properties, geometry } : bbox2 == null ? { type: "Feature", id, properties, geometry } : { type: "Feature", id, bbox: bbox2, properties, geometry };
+ }
+ function object(topology, o) {
+ var transformPoint = transform(topology.transform), arcs = topology.arcs;
+ function arc(i, points) {
+ if (points.length) points.pop();
+ for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length; k < n; ++k) {
+ points.push(transformPoint(a[k], k));
+ }
+ if (i < 0) reverse(points, n);
+ }
+ function point(p) {
+ return transformPoint(p);
+ }
+ function line(arcs2) {
+ var points = [];
+ for (var i = 0, n = arcs2.length; i < n; ++i) arc(arcs2[i], points);
+ if (points.length < 2) points.push(points[0]);
+ return points;
+ }
+ function ring(arcs2) {
+ var points = line(arcs2);
+ while (points.length < 4) points.push(points[0]);
+ return points;
+ }
+ function polygon(arcs2) {
+ return arcs2.map(ring);
+ }
+ function geometry(o2) {
+ var type = o2.type, coordinates;
+ switch (type) {
+ case "GeometryCollection":
+ return { type, geometries: o2.geometries.map(geometry) };
+ case "Point":
+ coordinates = point(o2.coordinates);
+ break;
+ case "MultiPoint":
+ coordinates = o2.coordinates.map(point);
+ break;
+ case "LineString":
+ coordinates = line(o2.arcs);
+ break;
+ case "MultiLineString":
+ coordinates = o2.arcs.map(line);
+ break;
+ case "Polygon":
+ coordinates = polygon(o2.arcs);
+ break;
+ case "MultiPolygon":
+ coordinates = o2.arcs.map(polygon);
+ break;
+ default:
+ return null;
+ }
+ return { type, coordinates };
+ }
+ return geometry(o);
+ }
+ function stitch(topology, arcs) {
+ var stitchedArcs = {}, fragmentByStart = {}, fragmentByEnd = {}, fragments = [], emptyIndex = -1;
+ arcs.forEach(function(i, j) {
+ var arc = topology.arcs[i < 0 ? ~i : i], t;
+ if (arc.length < 3 && !arc[1][0] && !arc[1][1]) {
+ t = arcs[++emptyIndex], arcs[emptyIndex] = i, arcs[j] = t;
+ }
+ });
+ arcs.forEach(function(i) {
+ var e = ends(i), start = e[0], end = e[1], f, g;
+ if (f = fragmentByEnd[start]) {
+ delete fragmentByEnd[f.end];
+ f.push(i);
+ f.end = end;
+ if (g = fragmentByStart[end]) {
+ delete fragmentByStart[g.start];
+ var fg = g === f ? f : f.concat(g);
+ fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg;
+ } else {
+ fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
+ }
+ } else if (f = fragmentByStart[end]) {
+ delete fragmentByStart[f.start];
+ f.unshift(i);
+ f.start = start;
+ if (g = fragmentByEnd[start]) {
+ delete fragmentByEnd[g.end];
+ var gf = g === f ? f : g.concat(f);
+ fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf;
+ } else {
+ fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
+ }
+ } else {
+ f = [i];
+ fragmentByStart[f.start = start] = fragmentByEnd[f.end = end] = f;
+ }
+ });
+ function ends(i) {
+ var arc = topology.arcs[i < 0 ? ~i : i], p0 = arc[0], p1;
+ if (topology.transform) p1 = [0, 0], arc.forEach(function(dp) {
+ p1[0] += dp[0], p1[1] += dp[1];
+ });
+ else p1 = arc[arc.length - 1];
+ return i < 0 ? [p1, p0] : [p0, p1];
+ }
+ function flush(fragmentByEnd2, fragmentByStart2) {
+ for (var k in fragmentByEnd2) {
+ var f = fragmentByEnd2[k];
+ delete fragmentByStart2[f.start];
+ delete f.start;
+ delete f.end;
+ f.forEach(function(i) {
+ stitchedArcs[i < 0 ? ~i : i] = 1;
+ });
+ fragments.push(f);
+ }
+ }
+ flush(fragmentByEnd, fragmentByStart);
+ flush(fragmentByStart, fragmentByEnd);
+ arcs.forEach(function(i) {
+ if (!stitchedArcs[i < 0 ? ~i : i]) fragments.push([i]);
+ });
+ return fragments;
+ }
+ function mesh(topology) {
+ return object(topology, meshArcs.apply(this, arguments));
+ }
+ function meshArcs(topology, object2, filter) {
+ var arcs, i, n;
+ if (arguments.length > 1) arcs = extractArcs(topology, object2, filter);
+ else for (i = 0, arcs = new Array(n = topology.arcs.length); i < n; ++i) arcs[i] = i;
+ return { type: "MultiLineString", arcs: stitch(topology, arcs) };
+ }
+ function extractArcs(topology, object2, filter) {
+ var arcs = [], geomsByArc = [], geom;
+ function extract0(i) {
+ var j = i < 0 ? ~i : i;
+ (geomsByArc[j] || (geomsByArc[j] = [])).push({ i, g: geom });
+ }
+ function extract1(arcs2) {
+ arcs2.forEach(extract0);
+ }
+ function extract2(arcs2) {
+ arcs2.forEach(extract1);
+ }
+ function extract3(arcs2) {
+ arcs2.forEach(extract2);
+ }
+ function geometry(o) {
+ switch (geom = o, o.type) {
+ case "GeometryCollection":
+ o.geometries.forEach(geometry);
+ break;
+ case "LineString":
+ extract1(o.arcs);
+ break;
+ case "MultiLineString":
+ case "Polygon":
+ extract2(o.arcs);
+ break;
+ case "MultiPolygon":
+ extract3(o.arcs);
+ break;
+ }
+ }
+ geometry(object2);
+ geomsByArc.forEach(filter == null ? function(geoms) {
+ arcs.push(geoms[0].i);
+ } : function(geoms) {
+ if (filter(geoms[0].g, geoms[geoms.length - 1].g)) arcs.push(geoms[0].i);
+ });
+ return arcs;
+ }
+ function planarRingArea(ring) {
+ var i = -1, n = ring.length, a, b = ring[n - 1], area = 0;
+ while (++i < n) a = b, b = ring[i], area += a[0] * b[1] - a[1] * b[0];
+ return Math.abs(area);
+ }
+ function merge(topology) {
+ return object(topology, mergeArcs.apply(this, arguments));
+ }
+ function mergeArcs(topology, objects) {
+ var polygonsByArc = {}, polygons = [], groups = [];
+ objects.forEach(geometry);
+ function geometry(o) {
+ switch (o.type) {
+ case "GeometryCollection":
+ o.geometries.forEach(geometry);
+ break;
+ case "Polygon":
+ extract(o.arcs);
+ break;
+ case "MultiPolygon":
+ o.arcs.forEach(extract);
+ break;
+ }
+ }
+ function extract(polygon) {
+ polygon.forEach(function(ring) {
+ ring.forEach(function(arc) {
+ (polygonsByArc[arc = arc < 0 ? ~arc : arc] || (polygonsByArc[arc] = [])).push(polygon);
+ });
+ });
+ polygons.push(polygon);
+ }
+ function area(ring) {
+ return planarRingArea(object(topology, { type: "Polygon", arcs: [ring] }).coordinates[0]);
+ }
+ polygons.forEach(function(polygon) {
+ if (!polygon._) {
+ var group = [], neighbors2 = [polygon];
+ polygon._ = 1;
+ groups.push(group);
+ while (polygon = neighbors2.pop()) {
+ group.push(polygon);
+ polygon.forEach(function(ring) {
+ ring.forEach(function(arc) {
+ polygonsByArc[arc < 0 ? ~arc : arc].forEach(function(polygon2) {
+ if (!polygon2._) {
+ polygon2._ = 1;
+ neighbors2.push(polygon2);
+ }
+ });
+ });
+ });
+ }
+ }
+ });
+ polygons.forEach(function(polygon) {
+ delete polygon._;
+ });
+ return {
+ type: "MultiPolygon",
+ arcs: groups.map(function(polygons2) {
+ var arcs = [], n;
+ polygons2.forEach(function(polygon) {
+ polygon.forEach(function(ring) {
+ ring.forEach(function(arc) {
+ if (polygonsByArc[arc < 0 ? ~arc : arc].length < 2) {
+ arcs.push(arc);
+ }
+ });
+ });
+ });
+ arcs = stitch(topology, arcs);
+ if ((n = arcs.length) > 1) {
+ for (var i = 1, k = area(arcs[0]), ki, t; i < n; ++i) {
+ if ((ki = area(arcs[i])) > k) {
+ t = arcs[0], arcs[0] = arcs[i], arcs[i] = t, k = ki;
+ }
+ }
+ }
+ return arcs;
+ }).filter(function(arcs) {
+ return arcs.length > 0;
+ })
+ };
+ }
+ function bisect(a, x) {
+ var lo = 0, hi = a.length;
+ while (lo < hi) {
+ var mid = lo + hi >>> 1;
+ if (a[mid] < x) lo = mid + 1;
+ else hi = mid;
+ }
+ return lo;
+ }
+ function neighbors(objects) {
+ var indexesByArc = {}, neighbors2 = objects.map(function() {
+ return [];
+ });
+ function line(arcs, i2) {
+ arcs.forEach(function(a) {
+ if (a < 0) a = ~a;
+ var o = indexesByArc[a];
+ if (o) o.push(i2);
+ else indexesByArc[a] = [i2];
+ });
+ }
+ function polygon(arcs, i2) {
+ arcs.forEach(function(arc) {
+ line(arc, i2);
+ });
+ }
+ function geometry(o, i2) {
+ if (o.type === "GeometryCollection") o.geometries.forEach(function(o2) {
+ geometry(o2, i2);
+ });
+ else if (o.type in geometryType) geometryType[o.type](o.arcs, i2);
+ }
+ var geometryType = {
+ LineString: line,
+ MultiLineString: polygon,
+ Polygon: polygon,
+ MultiPolygon: function(arcs, i2) {
+ arcs.forEach(function(arc) {
+ polygon(arc, i2);
+ });
+ }
+ };
+ objects.forEach(geometry);
+ for (var i in indexesByArc) {
+ for (var indexes = indexesByArc[i], m = indexes.length, j = 0; j < m; ++j) {
+ for (var k = j + 1; k < m; ++k) {
+ var ij = indexes[j], ik = indexes[k], n;
+ if ((n = neighbors2[ij])[i = bisect(n, ik)] !== ik) n.splice(i, 0, ik);
+ if ((n = neighbors2[ik])[i = bisect(n, ij)] !== ij) n.splice(i, 0, ij);
+ }
+ }
+ }
+ return neighbors2;
+ }
+ function untransform(transform2) {
+ if (transform2 == null) return identity2;
+ var x0, y0, kx = transform2.scale[0], ky = transform2.scale[1], dx = transform2.translate[0], dy = transform2.translate[1];
+ return function(input, i) {
+ if (!i) x0 = y0 = 0;
+ var j = 2, n = input.length, output = new Array(n), x1 = Math.round((input[0] - dx) / kx), y1 = Math.round((input[1] - dy) / ky);
+ output[0] = x1 - x0, x0 = x1;
+ output[1] = y1 - y0, y0 = y1;
+ while (j < n) output[j] = input[j], ++j;
+ return output;
+ };
+ }
+ function quantize(topology, transform2) {
+ if (topology.transform) throw new Error("already quantized");
+ if (!transform2 || !transform2.scale) {
+ if (!((n = Math.floor(transform2)) >= 2)) throw new Error("n must be \u22652");
+ box = topology.bbox || bbox(topology);
+ var x0 = box[0], y0 = box[1], x1 = box[2], y1 = box[3], n;
+ transform2 = { scale: [x1 - x0 ? (x1 - x0) / (n - 1) : 1, y1 - y0 ? (y1 - y0) / (n - 1) : 1], translate: [x0, y0] };
+ } else {
+ box = topology.bbox;
+ }
+ var t = untransform(transform2), box, key, inputs = topology.objects, outputs = {};
+ function quantizePoint(point) {
+ return t(point);
+ }
+ function quantizeGeometry(input) {
+ var output;
+ switch (input.type) {
+ case "GeometryCollection":
+ output = { type: "GeometryCollection", geometries: input.geometries.map(quantizeGeometry) };
+ break;
+ case "Point":
+ output = { type: "Point", coordinates: quantizePoint(input.coordinates) };
+ break;
+ case "MultiPoint":
+ output = { type: "MultiPoint", coordinates: input.coordinates.map(quantizePoint) };
+ break;
+ default:
+ return input;
+ }
+ if (input.id != null) output.id = input.id;
+ if (input.bbox != null) output.bbox = input.bbox;
+ if (input.properties != null) output.properties = input.properties;
+ return output;
+ }
+ function quantizeArc(input) {
+ var i = 0, j = 1, n2 = input.length, p, output = new Array(n2);
+ output[0] = t(input[0], 0);
+ while (++i < n2) if ((p = t(input[i], i))[0] || p[1]) output[j++] = p;
+ if (j === 1) output[j++] = [0, 0];
+ output.length = j;
+ return output;
+ }
+ for (key in inputs) outputs[key] = quantizeGeometry(inputs[key]);
+ return {
+ type: "Topology",
+ bbox: box,
+ transform: transform2,
+ objects: outputs,
+ arcs: topology.arcs.map(quantizeArc)
+ };
+ }
+ exports2.bbox = bbox;
+ exports2.feature = feature;
+ exports2.merge = merge;
+ exports2.mergeArcs = mergeArcs;
+ exports2.mesh = mesh;
+ exports2.meshArcs = meshArcs;
+ exports2.neighbors = neighbors;
+ exports2.quantize = quantize;
+ exports2.transform = transform;
+ exports2.untransform = untransform;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // src/lib/topojson_utils.js
+ var require_topojson_utils = __commonJS({
+ "src/lib/topojson_utils.js"(exports, module) {
+ "use strict";
+ var topojsonUtils = module.exports = {};
+ var locationmodeToLayer = require_constants22().locationmodeToLayer;
+ var topojsonFeature = require_topojson_client().feature;
+ topojsonUtils.getTopojsonName = function(geoLayout) {
+ return [
+ geoLayout.scope.replace(/ /g, "-"),
+ "_",
+ geoLayout.resolution.toString(),
+ "m"
+ ].join("");
+ };
+ topojsonUtils.getTopojsonPath = function(topojsonURL, topojsonName) {
+ return topojsonURL + topojsonName + ".json";
+ };
+ topojsonUtils.getTopojsonFeatures = function(trace, topojson) {
+ var layer = locationmodeToLayer[trace.locationmode];
+ var obj = topojson.objects[layer];
+ return topojsonFeature(topojson, obj).features;
+ };
+ }
+ });
+
+ // src/lib/geojson_utils.js
+ var require_geojson_utils = __commonJS({
+ "src/lib/geojson_utils.js"(exports) {
+ "use strict";
+ var BADNUM = require_numerical().BADNUM;
+ exports.calcTraceToLineCoords = function(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var connectgaps = trace.connectgaps;
+ var coords = [];
+ var lineString = [];
+ for (var i = 0; i < calcTrace.length; i++) {
+ var calcPt = calcTrace[i];
+ var lonlat = calcPt.lonlat;
+ if (lonlat[0] !== BADNUM) {
+ lineString.push(lonlat);
+ } else if (!connectgaps && lineString.length > 0) {
+ coords.push(lineString);
+ lineString = [];
+ }
+ }
+ if (lineString.length > 0) {
+ coords.push(lineString);
+ }
+ return coords;
+ };
+ exports.makeLine = function(coords) {
+ if (coords.length === 1) {
+ return {
+ type: "LineString",
+ coordinates: coords[0]
+ };
+ } else {
+ return {
+ type: "MultiLineString",
+ coordinates: coords
+ };
+ }
+ };
+ exports.makePolygon = function(coords) {
+ if (coords.length === 1) {
+ return {
+ type: "Polygon",
+ coordinates: coords
+ };
+ } else {
+ var _coords = new Array(coords.length);
+ for (var i = 0; i < coords.length; i++) {
+ _coords[i] = [coords[i]];
+ }
+ return {
+ type: "MultiPolygon",
+ coordinates: _coords
+ };
+ }
+ };
+ exports.makeBlank = function() {
+ return {
+ type: "Point",
+ coordinates: []
+ };
+ };
+ }
+ });
+
+ // node_modules/country-regex/index.js
+ var require_country_regex = __commonJS({
+ "node_modules/country-regex/index.js"(exports, module) {
+ module.exports = {
+ AFG: "afghan",
+ ALA: "\\b\\wland",
+ ALB: "albania",
+ DZA: "algeria",
+ ASM: "^(?=.*americ).*samoa",
+ AND: "andorra",
+ AGO: "angola",
+ AIA: "anguill?a",
+ ATA: "antarctica",
+ ATG: "antigua",
+ ARG: "argentin",
+ ARM: "armenia",
+ ABW: "^(?!.*bonaire).*\\baruba",
+ AUS: "australia",
+ AUT: "^(?!.*hungary).*austria|\\baustri.*\\bemp",
+ AZE: "azerbaijan",
+ BHS: "bahamas",
+ BHR: "bahrain",
+ BGD: "bangladesh|^(?=.*east).*paki?stan",
+ BRB: "barbados",
+ BLR: "belarus|byelo",
+ BEL: "^(?!.*luxem).*belgium",
+ BLZ: "belize|^(?=.*british).*honduras",
+ BEN: "benin|dahome",
+ BMU: "bermuda",
+ BTN: "bhutan",
+ BOL: "bolivia",
+ BES: "^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",
+ BIH: "herzegovina|bosnia",
+ BWA: "botswana|bechuana",
+ BVT: "bouvet",
+ BRA: "brazil",
+ IOT: "british.?indian.?ocean",
+ BRN: "brunei",
+ BGR: "bulgaria",
+ BFA: "burkina|\\bfaso|upper.?volta",
+ BDI: "burundi",
+ CPV: "verde",
+ KHM: "cambodia|kampuchea|khmer",
+ CMR: "cameroon",
+ CAN: "canada",
+ CYM: "cayman",
+ CAF: "\\bcentral.african.republic",
+ TCD: "\\bchad",
+ CHL: "\\bchile",
+ CHN: "^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai)(?!.*\\brep).*china|^(?=.*peo)(?=.*rep).*china",
+ CXR: "christmas",
+ CCK: "\\bcocos|keeling",
+ COL: "colombia",
+ COM: "comoro",
+ COG: "^(?!.*\\bdem)(?!.*\\bd[\\.]?r)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",
+ COK: "\\bcook",
+ CRI: "costa.?rica",
+ CIV: "ivoire|ivory",
+ HRV: "croatia",
+ CUB: "\\bcuba",
+ CUW: "^(?!.*bonaire).*\\bcura(c|\xE7)ao",
+ CYP: "cyprus",
+ CSK: "czechoslovakia",
+ CZE: "^(?=.*rep).*czech|czechia|bohemia",
+ COD: "\\bdem.*congo|congo.*\\bdem|congo.*\\bd[\\.]?r|\\bd[\\.]?r.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",
+ DNK: "denmark",
+ DJI: "djibouti",
+ DMA: "dominica(?!n)",
+ DOM: "dominican.rep",
+ ECU: "ecuador",
+ EGY: "egypt",
+ SLV: "el.?salvador",
+ GNQ: "guine.*eq|eq.*guine|^(?=.*span).*guinea",
+ ERI: "eritrea",
+ EST: "estonia",
+ ETH: "ethiopia|abyssinia",
+ FLK: "falkland|malvinas",
+ FRO: "faroe|faeroe",
+ FJI: "fiji",
+ FIN: "finland",
+ FRA: "^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",
+ GUF: "^(?=.*french).*guiana",
+ PYF: "french.?polynesia|tahiti",
+ ATF: "french.?southern",
+ GAB: "gabon",
+ GMB: "gambia",
+ GEO: "^(?!.*south).*georgia",
+ DDR: "german.?democratic.?republic|democratic.?republic.*germany|east.germany",
+ DEU: "^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",
+ GHA: "ghana|gold.?coast",
+ GIB: "gibraltar",
+ GRC: "greece|hellenic|hellas",
+ GRL: "greenland",
+ GRD: "grenada",
+ GLP: "guadeloupe",
+ GUM: "\\bguam",
+ GTM: "guatemala",
+ GGY: "guernsey",
+ GIN: "^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",
+ GNB: "bissau|^(?=.*portu).*guinea",
+ GUY: "guyana|british.?guiana",
+ HTI: "haiti",
+ HMD: "heard.*mcdonald",
+ VAT: "holy.?see|vatican|papal.?st",
+ HND: "^(?!.*brit).*honduras",
+ HKG: "hong.?kong",
+ HUN: "^(?!.*austr).*hungary",
+ ISL: "iceland",
+ IND: "india(?!.*ocea)",
+ IDN: "indonesia",
+ IRN: "\\biran|persia",
+ IRQ: "\\biraq|mesopotamia",
+ IRL: "(^ireland)|(^republic.*ireland)",
+ IMN: "^(?=.*isle).*\\bman",
+ ISR: "israel",
+ ITA: "italy",
+ JAM: "jamaica",
+ JPN: "japan",
+ JEY: "jersey",
+ JOR: "jordan",
+ KAZ: "kazak",
+ KEN: "kenya|british.?east.?africa|east.?africa.?prot",
+ KIR: "kiribati",
+ PRK: "^(?=.*democrat|people|north|d.*p.*.r).*\\bkorea|dprk|korea.*(d.*p.*r)",
+ KWT: "kuwait",
+ KGZ: "kyrgyz|kirghiz",
+ LAO: "\\blaos?\\b",
+ LVA: "latvia",
+ LBN: "lebanon",
+ LSO: "lesotho|basuto",
+ LBR: "liberia",
+ LBY: "libya",
+ LIE: "liechtenstein",
+ LTU: "lithuania",
+ LUX: "^(?!.*belg).*luxem",
+ MAC: "maca(o|u)",
+ MDG: "madagascar|malagasy",
+ MWI: "malawi|nyasa",
+ MYS: "malaysia",
+ MDV: "maldive",
+ MLI: "\\bmali\\b",
+ MLT: "\\bmalta",
+ MHL: "marshall",
+ MTQ: "martinique",
+ MRT: "mauritania",
+ MUS: "mauritius",
+ MYT: "\\bmayotte",
+ MEX: "\\bmexic",
+ FSM: "fed.*micronesia|micronesia.*fed",
+ MCO: "monaco",
+ MNG: "mongolia",
+ MNE: "^(?!.*serbia).*montenegro",
+ MSR: "montserrat",
+ MAR: "morocco|\\bmaroc",
+ MOZ: "mozambique",
+ MMR: "myanmar|burma",
+ NAM: "namibia",
+ NRU: "nauru",
+ NPL: "nepal",
+ NLD: "^(?!.*\\bant)(?!.*\\bcarib).*netherlands",
+ ANT: "^(?=.*\\bant).*(nether|dutch)",
+ NCL: "new.?caledonia",
+ NZL: "new.?zealand",
+ NIC: "nicaragua",
+ NER: "\\bniger(?!ia)",
+ NGA: "nigeria",
+ NIU: "niue",
+ NFK: "norfolk",
+ MNP: "mariana",
+ NOR: "norway",
+ OMN: "\\boman|trucial",
+ PAK: "^(?!.*east).*paki?stan",
+ PLW: "palau",
+ PSE: "palestin|\\bgaza|west.?bank",
+ PAN: "panama",
+ PNG: "papua|new.?guinea",
+ PRY: "paraguay",
+ PER: "peru",
+ PHL: "philippines",
+ PCN: "pitcairn",
+ POL: "poland",
+ PRT: "portugal",
+ PRI: "puerto.?rico",
+ QAT: "qatar",
+ KOR: "^(?!.*d.*p.*r)(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea(?!.*d.*p.*r)",
+ MDA: "moldov|b(a|e)ssarabia",
+ REU: "r(e|\xE9)union",
+ ROU: "r(o|u|ou)mania",
+ RUS: "\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",
+ RWA: "rwanda",
+ BLM: "barth(e|\xE9)lemy",
+ SHN: "helena",
+ KNA: "kitts|\\bnevis",
+ LCA: "\\blucia",
+ MAF: "^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",
+ SPM: "miquelon",
+ VCT: "vincent",
+ WSM: "^(?!.*amer).*samoa",
+ SMR: "san.?marino",
+ STP: "\\bs(a|\xE3)o.?tom(e|\xE9)",
+ SAU: "\\bsa\\w*.?arabia",
+ SEN: "senegal",
+ SRB: "^(?!.*monte).*serbia",
+ SYC: "seychell",
+ SLE: "sierra",
+ SGP: "singapore",
+ SXM: "^(?!.*martin)(?!.*saba).*maarten",
+ SVK: "^(?!.*cze).*slovak",
+ SVN: "slovenia",
+ SLB: "solomon",
+ SOM: "somali",
+ ZAF: "south.africa|s\\\\..?africa",
+ SGS: "south.?georgia|sandwich",
+ SSD: "\\bs\\w*.?sudan",
+ ESP: "spain",
+ LKA: "sri.?lanka|ceylon",
+ SDN: "^(?!.*\\bs(?!u)).*sudan",
+ SUR: "surinam|dutch.?guiana",
+ SJM: "svalbard",
+ SWZ: "swaziland",
+ SWE: "sweden",
+ CHE: "switz|swiss",
+ SYR: "syria",
+ TWN: "taiwan|taipei|formosa|^(?!.*peo)(?=.*rep).*china",
+ TJK: "tajik",
+ THA: "thailand|\\bsiam",
+ MKD: "macedonia|fyrom",
+ TLS: "^(?=.*leste).*timor|^(?=.*east).*timor",
+ TGO: "togo",
+ TKL: "tokelau",
+ TON: "tonga",
+ TTO: "trinidad|tobago",
+ TUN: "tunisia",
+ TUR: "turkey",
+ TKM: "turkmen",
+ TCA: "turks",
+ TUV: "tuvalu",
+ UGA: "uganda",
+ UKR: "ukrain",
+ ARE: "emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",
+ GBR: "united.?kingdom|britain|^u\\.?k\\.?$",
+ TZA: "tanzania",
+ USA: "united.?states\\b(?!.*islands)|\\bu\\.?s\\.?a\\.?\\b|^\\s*u\\.?s\\.?\\b(?!.*islands)",
+ UMI: "minor.?outlying.?is",
+ URY: "uruguay",
+ UZB: "uzbek",
+ VUT: "vanuatu|new.?hebrides",
+ VEN: "venezuela",
+ VNM: "^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",
+ VGB: "^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",
+ VIR: "^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",
+ WLF: "futuna|wallis",
+ ESH: "western.sahara",
+ YEM: "^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",
+ YMD: "^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",
+ YUG: "yugoslavia",
+ ZMB: "zambia|northern.?rhodesia",
+ EAZ: "zanzibar",
+ ZWE: "zimbabwe|^(?!.*northern).*rhodesia"
+ };
+ }
+ });
+
+ // node_modules/@turf/helpers/dist/cjs/index.cjs
+ var require_cjs = __commonJS({
+ "node_modules/@turf/helpers/dist/cjs/index.cjs"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ var earthRadius = 63710088e-1;
+ var factors = {
+ centimeters: earthRadius * 100,
+ centimetres: earthRadius * 100,
+ degrees: 360 / (2 * Math.PI),
+ feet: earthRadius * 3.28084,
+ inches: earthRadius * 39.37,
+ kilometers: earthRadius / 1e3,
+ kilometres: earthRadius / 1e3,
+ meters: earthRadius,
+ metres: earthRadius,
+ miles: earthRadius / 1609.344,
+ millimeters: earthRadius * 1e3,
+ millimetres: earthRadius * 1e3,
+ nauticalmiles: earthRadius / 1852,
+ radians: 1,
+ yards: earthRadius * 1.0936
+ };
+ var areaFactors = {
+ acres: 247105e-9,
+ centimeters: 1e4,
+ centimetres: 1e4,
+ feet: 10.763910417,
+ hectares: 1e-4,
+ inches: 1550.003100006,
+ kilometers: 1e-6,
+ kilometres: 1e-6,
+ meters: 1,
+ metres: 1,
+ miles: 386e-9,
+ nauticalmiles: 29155334959812285e-23,
+ millimeters: 1e6,
+ millimetres: 1e6,
+ yards: 1.195990046
+ };
+ function feature(geom, properties, 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 = geom;
+ return feat;
+ }
+ function geometry(type, coordinates, _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");
+ }
+ }
+ function point(coordinates, properties, options = {}) {
+ if (!coordinates) {
+ throw new Error("coordinates is required");
+ }
+ if (!Array.isArray(coordinates)) {
+ throw new Error("coordinates must be an Array");
+ }
+ if (coordinates.length < 2) {
+ throw new Error("coordinates must be at least 2 numbers long");
+ }
+ if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
+ throw new Error("coordinates must contain numbers");
+ }
+ const geom = {
+ type: "Point",
+ coordinates
+ };
+ return feature(geom, properties, options);
+ }
+ function points(coordinates, properties, options = {}) {
+ return featureCollection(
+ coordinates.map((coords) => {
+ return point(coords, properties);
+ }),
+ options
+ );
+ }
+ function polygon(coordinates, properties, options = {}) {
+ for (const ring of coordinates) {
+ if (ring.length < 4) {
+ throw new Error(
+ "Each LinearRing of a Polygon must have 4 or more Positions."
+ );
+ }
+ if (ring[ring.length - 1].length !== ring[0].length) {
+ throw new Error("First and last Position are not equivalent.");
+ }
+ for (let j = 0; j < ring[ring.length - 1].length; j++) {
+ 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);
+ }
+ function polygons(coordinates, properties, options = {}) {
+ return featureCollection(
+ coordinates.map((coords) => {
+ return polygon(coords, properties);
+ }),
+ options
+ );
+ }
+ function lineString(coordinates, properties, 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);
+ }
+ function lineStrings(coordinates, properties, options = {}) {
+ return featureCollection(
+ coordinates.map((coords) => {
+ return lineString(coords, properties);
+ }),
+ options
+ );
+ }
+ function featureCollection(features, options = {}) {
+ const fc = { type: "FeatureCollection" };
+ if (options.id) {
+ fc.id = options.id;
+ }
+ if (options.bbox) {
+ fc.bbox = options.bbox;
+ }
+ fc.features = features;
+ return fc;
+ }
+ function multiLineString(coordinates, properties, options = {}) {
+ const geom = {
+ type: "MultiLineString",
+ coordinates
+ };
+ return feature(geom, properties, options);
+ }
+ function multiPoint(coordinates, properties, options = {}) {
+ const geom = {
+ type: "MultiPoint",
+ coordinates
+ };
+ return feature(geom, properties, options);
+ }
+ function multiPolygon(coordinates, properties, options = {}) {
+ const geom = {
+ type: "MultiPolygon",
+ coordinates
+ };
+ return feature(geom, properties, options);
+ }
+ function geometryCollection(geometries, properties, options = {}) {
+ const geom = {
+ type: "GeometryCollection",
+ geometries
+ };
+ return feature(geom, properties, options);
+ }
+ function round(num, precision = 0) {
+ 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;
+ }
+ function radiansToLength(radians2, units = "kilometers") {
+ const factor = factors[units];
+ if (!factor) {
+ throw new Error(units + " units is invalid");
+ }
+ return radians2 * factor;
+ }
+ function lengthToRadians(distance, units = "kilometers") {
+ const factor = factors[units];
+ if (!factor) {
+ throw new Error(units + " units is invalid");
+ }
+ return distance / factor;
+ }
+ function lengthToDegrees(distance, units) {
+ return radiansToDegrees(lengthToRadians(distance, units));
+ }
+ function bearingToAzimuth(bearing) {
+ let angle = bearing % 360;
+ if (angle < 0) {
+ angle += 360;
+ }
+ return angle;
+ }
+ function azimuthToBearing(angle) {
+ angle = angle % 360;
+ if (angle > 0)
+ return angle > 180 ? angle - 360 : angle;
+ return angle < -180 ? angle + 360 : angle;
+ }
+ function radiansToDegrees(radians2) {
+ const degrees3 = radians2 % (2 * Math.PI);
+ return degrees3 * 180 / Math.PI;
+ }
+ function degreesToRadians(degrees3) {
+ const radians2 = degrees3 % 360;
+ return radians2 * Math.PI / 180;
+ }
+ function convertLength(length, originalUnit = "kilometers", finalUnit = "kilometers") {
+ if (!(length >= 0)) {
+ throw new Error("length must be a positive number");
+ }
+ return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);
+ }
+ function convertArea(area, originalUnit = "meters", finalUnit = "kilometers") {
+ if (!(area >= 0)) {
+ throw new Error("area must be a positive number");
+ }
+ const startFactor = areaFactors[originalUnit];
+ if (!startFactor) {
+ throw new Error("invalid original units");
+ }
+ const finalFactor = areaFactors[finalUnit];
+ if (!finalFactor) {
+ throw new Error("invalid final units");
+ }
+ return area / startFactor * finalFactor;
+ }
+ function isNumber(num) {
+ return !isNaN(num) && num !== null && !Array.isArray(num);
+ }
+ function isObject(input) {
+ return input !== null && typeof input === "object" && !Array.isArray(input);
+ }
+ 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");
+ }
+ });
+ }
+ 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.areaFactors = areaFactors;
+ exports.azimuthToBearing = azimuthToBearing;
+ exports.bearingToAzimuth = bearingToAzimuth;
+ exports.convertArea = convertArea;
+ exports.convertLength = convertLength;
+ exports.degreesToRadians = degreesToRadians;
+ exports.earthRadius = earthRadius;
+ exports.factors = factors;
+ exports.feature = feature;
+ exports.featureCollection = featureCollection;
+ exports.geometry = geometry;
+ exports.geometryCollection = geometryCollection;
+ exports.isNumber = isNumber;
+ exports.isObject = isObject;
+ exports.lengthToDegrees = lengthToDegrees;
+ exports.lengthToRadians = lengthToRadians;
+ exports.lineString = lineString;
+ exports.lineStrings = lineStrings;
+ exports.multiLineString = multiLineString;
+ exports.multiPoint = multiPoint;
+ exports.multiPolygon = multiPolygon;
+ exports.point = point;
+ exports.points = points;
+ exports.polygon = polygon;
+ exports.polygons = polygons;
+ exports.radiansToDegrees = radiansToDegrees;
+ exports.radiansToLength = radiansToLength;
+ exports.round = round;
+ exports.validateBBox = validateBBox;
+ exports.validateId = validateId;
+ }
+ });
+
+ // node_modules/@turf/meta/dist/cjs/index.cjs
+ var require_cjs2 = __commonJS({
+ "node_modules/@turf/meta/dist/cjs/index.cjs"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ var _helpers = require_cjs();
+ function coordEach(geojson, callback, excludeWrapCoord) {
+ 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;
+ 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;
+ 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");
+ }
+ }
+ }
+ }
+ function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
+ var previousValue = initialValue;
+ coordEach(
+ geojson,
+ function(currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
+ if (coordIndex === 0 && initialValue === void 0)
+ previousValue = currentCoord;
+ else
+ previousValue = callback(
+ previousValue,
+ currentCoord,
+ coordIndex,
+ featureIndex,
+ multiFeatureIndex,
+ geometryIndex
+ );
+ },
+ excludeWrapCoord
+ );
+ return previousValue;
+ }
+ 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;
+ }
+ }
+ function propReduce(geojson, callback, initialValue) {
+ var previousValue = initialValue;
+ propEach(geojson, function(currentProperties, featureIndex) {
+ if (featureIndex === 0 && initialValue === void 0)
+ previousValue = currentProperties;
+ else
+ previousValue = callback(previousValue, currentProperties, featureIndex);
+ });
+ return previousValue;
+ }
+ 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;
+ }
+ }
+ }
+ function featureReduce(geojson, callback, initialValue) {
+ var previousValue = initialValue;
+ featureEach(geojson, function(currentFeature, featureIndex) {
+ if (featureIndex === 0 && initialValue === void 0)
+ previousValue = currentFeature;
+ else
+ previousValue = callback(previousValue, currentFeature, featureIndex);
+ });
+ return previousValue;
+ }
+ function coordAll(geojson) {
+ var coords = [];
+ coordEach(geojson, function(coord) {
+ coords.push(coord);
+ });
+ return coords;
+ }
+ 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;
+ 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 : void 0;
+ featureId = isFeatureCollection ? geojson.features[i].id : isFeature ? geojson.id : void 0;
+ isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
+ stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
+ for (g = 0; g < stopG; g++) {
+ geometry = isGeometryCollection ? geometryMaybeCollection.geometries[g] : geometryMaybeCollection;
+ 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");
+ }
+ }
+ featureIndex++;
+ }
+ }
+ function geomReduce(geojson, callback, initialValue) {
+ var previousValue = initialValue;
+ geomEach(
+ geojson,
+ function(currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
+ if (featureIndex === 0 && initialValue === void 0)
+ previousValue = currentGeometry;
+ else
+ previousValue = callback(
+ previousValue,
+ currentGeometry,
+ featureIndex,
+ featureProperties,
+ featureBBox,
+ featureId
+ );
+ }
+ );
+ return previousValue;
+ }
+ function flattenEach(geojson, callback) {
+ geomEach(geojson, function(geometry, featureIndex, properties, bbox, id) {
+ var type = geometry === null ? null : geometry.type;
+ switch (type) {
+ case null:
+ case "Point":
+ case "LineString":
+ case "Polygon":
+ if (callback(
+ _helpers.feature.call(void 0, geometry, properties, { bbox, id }),
+ featureIndex,
+ 0
+ ) === false)
+ return false;
+ return;
+ }
+ var geomType;
+ 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.call(void 0, geom, properties), featureIndex, multiFeatureIndex) === false)
+ return false;
+ }
+ });
+ }
+ function flattenReduce(geojson, callback, initialValue) {
+ var previousValue = initialValue;
+ flattenEach(
+ geojson,
+ function(currentFeature, featureIndex, multiFeatureIndex) {
+ if (featureIndex === 0 && multiFeatureIndex === 0 && initialValue === void 0)
+ previousValue = currentFeature;
+ else
+ previousValue = callback(
+ previousValue,
+ currentFeature,
+ featureIndex,
+ multiFeatureIndex
+ );
+ }
+ );
+ return previousValue;
+ }
+ function segmentEach(geojson, callback) {
+ flattenEach(geojson, function(feature2, featureIndex, multiFeatureIndex) {
+ var segmentIndex = 0;
+ if (!feature2.geometry)
+ return;
+ var type = feature2.geometry.type;
+ if (type === "Point" || type === "MultiPoint")
+ return;
+ var previousCoords;
+ var previousFeatureIndex = 0;
+ var previousMultiIndex = 0;
+ var prevGeomIndex = 0;
+ if (coordEach(
+ feature2,
+ function(currentCoord, coordIndex, featureIndexCoord, multiPartIndexCoord, geometryIndex) {
+ if (previousCoords === void 0 || featureIndex > previousFeatureIndex || multiPartIndexCoord > previousMultiIndex || geometryIndex > prevGeomIndex) {
+ previousCoords = currentCoord;
+ previousFeatureIndex = featureIndex;
+ previousMultiIndex = multiPartIndexCoord;
+ prevGeomIndex = geometryIndex;
+ segmentIndex = 0;
+ return;
+ }
+ var currentSegment = _helpers.lineString.call(
+ void 0,
+ [previousCoords, currentCoord],
+ feature2.properties
+ );
+ if (callback(
+ currentSegment,
+ featureIndex,
+ multiFeatureIndex,
+ geometryIndex,
+ segmentIndex
+ ) === false)
+ return false;
+ segmentIndex++;
+ previousCoords = currentCoord;
+ }
+ ) === false)
+ return false;
+ });
+ }
+ function segmentReduce(geojson, callback, initialValue) {
+ var previousValue = initialValue;
+ var started = false;
+ segmentEach(
+ geojson,
+ function(currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
+ if (started === false && initialValue === void 0)
+ previousValue = currentSegment;
+ else
+ previousValue = callback(
+ previousValue,
+ currentSegment,
+ featureIndex,
+ multiFeatureIndex,
+ geometryIndex,
+ segmentIndex
+ );
+ started = true;
+ }
+ );
+ return previousValue;
+ }
+ function lineEach(geojson, callback) {
+ if (!geojson)
+ throw new Error("geojson is required");
+ flattenEach(geojson, function(feature2, featureIndex, multiFeatureIndex) {
+ if (feature2.geometry === null)
+ return;
+ var type = feature2.geometry.type;
+ var coords = feature2.geometry.coordinates;
+ switch (type) {
+ case "LineString":
+ if (callback(feature2, featureIndex, multiFeatureIndex, 0, 0) === false)
+ return false;
+ break;
+ case "Polygon":
+ for (var geometryIndex = 0; geometryIndex < coords.length; geometryIndex++) {
+ if (callback(
+ _helpers.lineString.call(void 0, coords[geometryIndex], feature2.properties),
+ featureIndex,
+ multiFeatureIndex,
+ geometryIndex
+ ) === false)
+ return false;
+ }
+ break;
+ }
+ });
+ }
+ function lineReduce(geojson, callback, initialValue) {
+ var previousValue = initialValue;
+ lineEach(
+ geojson,
+ function(currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
+ if (featureIndex === 0 && initialValue === void 0)
+ previousValue = currentLine;
+ else
+ previousValue = callback(
+ previousValue,
+ currentLine,
+ featureIndex,
+ multiFeatureIndex,
+ geometryIndex
+ );
+ }
+ );
+ return previousValue;
+ }
+ function findSegment(geojson, options) {
+ options = options || {};
+ if (!_helpers.isObject.call(void 0, 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;
+ 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");
+ }
+ 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.call(
+ void 0,
+ [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.call(
+ void 0,
+ [
+ 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.call(
+ void 0,
+ [
+ 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.call(
+ void 0,
+ [
+ coords[multiFeatureIndex][geometryIndex][segmentIndex],
+ coords[multiFeatureIndex][geometryIndex][segmentIndex + 1]
+ ],
+ properties,
+ options
+ );
+ }
+ throw new Error("geojson is invalid");
+ }
+ function findPoint(geojson, options) {
+ options = options || {};
+ if (!_helpers.isObject.call(void 0, 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;
+ 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");
+ }
+ if (geometry === null)
+ return null;
+ var coords = geometry.coordinates;
+ switch (geometry.type) {
+ case "Point":
+ return _helpers.point.call(void 0, coords, properties, options);
+ case "MultiPoint":
+ if (multiFeatureIndex < 0)
+ multiFeatureIndex = coords.length + multiFeatureIndex;
+ return _helpers.point.call(void 0, coords[multiFeatureIndex], properties, options);
+ case "LineString":
+ if (coordIndex < 0)
+ coordIndex = coords.length + coordIndex;
+ return _helpers.point.call(void 0, coords[coordIndex], properties, options);
+ case "Polygon":
+ if (geometryIndex < 0)
+ geometryIndex = coords.length + geometryIndex;
+ if (coordIndex < 0)
+ coordIndex = coords[geometryIndex].length + coordIndex;
+ return _helpers.point.call(void 0, 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.call(void 0, 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.call(
+ void 0,
+ coords[multiFeatureIndex][geometryIndex][coordIndex],
+ properties,
+ options
+ );
+ }
+ throw new Error("geojson is invalid");
+ }
+ exports.coordAll = coordAll;
+ exports.coordEach = coordEach;
+ exports.coordReduce = coordReduce;
+ exports.featureEach = featureEach;
+ exports.featureReduce = featureReduce;
+ exports.findPoint = findPoint;
+ exports.findSegment = findSegment;
+ exports.flattenEach = flattenEach;
+ exports.flattenReduce = flattenReduce;
+ exports.geomEach = geomEach;
+ exports.geomReduce = geomReduce;
+ exports.lineEach = lineEach;
+ exports.lineReduce = lineReduce;
+ exports.propEach = propEach;
+ exports.propReduce = propReduce;
+ exports.segmentEach = segmentEach;
+ exports.segmentReduce = segmentReduce;
+ }
+ });
+
+ // node_modules/@turf/area/dist/cjs/index.cjs
+ var require_cjs3 = __commonJS({
+ "node_modules/@turf/area/dist/cjs/index.cjs"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ var _helpers = require_cjs();
+ var _meta = require_cjs2();
+ function area(geojson) {
+ return _meta.geomReduce.call(
+ void 0,
+ geojson,
+ (value, geom) => {
+ return value + calculateArea(geom);
+ },
+ 0
+ );
+ }
+ 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;
+ }
+ var FACTOR = _helpers.earthRadius * _helpers.earthRadius / 2;
+ var PI_OVER_180 = Math.PI / 180;
+ function ringArea(coords) {
+ const coordsLength = coords.length - 1;
+ if (coordsLength <= 2)
+ return 0;
+ let total = 0;
+ let i = 0;
+ while (i < coordsLength) {
+ const lower = coords[i];
+ const middle = coords[i + 1 === coordsLength ? 0 : i + 1];
+ const upper = coords[i + 2 >= coordsLength ? (i + 2) % coordsLength : i + 2];
+ const lowerX = lower[0] * PI_OVER_180;
+ const middleY = middle[1] * PI_OVER_180;
+ const upperX = upper[0] * PI_OVER_180;
+ total += (upperX - lowerX) * Math.sin(middleY);
+ i++;
+ }
+ return total * FACTOR;
+ }
+ var turf_area_default = area;
+ exports.area = area;
+ exports.default = turf_area_default;
+ }
+ });
+
+ // node_modules/@turf/centroid/dist/cjs/index.cjs
+ var require_cjs4 = __commonJS({
+ "node_modules/@turf/centroid/dist/cjs/index.cjs"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ var _helpers = require_cjs();
+ var _meta = require_cjs2();
+ function centroid(geojson, options = {}) {
+ let xSum = 0;
+ let ySum = 0;
+ let len = 0;
+ _meta.coordEach.call(
+ void 0,
+ geojson,
+ function(coord) {
+ xSum += coord[0];
+ ySum += coord[1];
+ len++;
+ },
+ true
+ );
+ return _helpers.point.call(void 0, [xSum / len, ySum / len], options.properties);
+ }
+ var turf_centroid_default = centroid;
+ exports.centroid = centroid;
+ exports.default = turf_centroid_default;
+ }
+ });
+
+ // node_modules/@turf/bbox/dist/cjs/index.cjs
+ var require_cjs5 = __commonJS({
+ "node_modules/@turf/bbox/dist/cjs/index.cjs"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ var _meta = require_cjs2();
+ function bbox(geojson, options = {}) {
+ if (geojson.bbox != null && true !== options.recompute) {
+ return geojson.bbox;
+ }
+ const result = [Infinity, Infinity, -Infinity, -Infinity];
+ _meta.coordEach.call(void 0, 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;
+ }
+ var turf_bbox_default = bbox;
+ exports.bbox = bbox;
+ exports.default = turf_bbox_default;
+ }
+ });
+
+ // src/lib/geo_location_utils.js
+ var require_geo_location_utils = __commonJS({
+ "src/lib/geo_location_utils.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var countryRegex = require_country_regex();
+ var { area: turfArea } = require_cjs3();
+ var { centroid: turfCentroid } = require_cjs4();
+ var { bbox: turfBbox } = require_cjs5();
+ var identity2 = require_identity2();
+ var loggers = require_loggers();
+ var isPlainObject = require_is_plain_object();
+ var nestedProperty = require_nested_property();
+ var polygon = require_polygon();
+ var countryIds = Object.keys(countryRegex);
+ var locationmodeToIdFinder = {
+ "ISO-3": identity2,
+ "USA-states": identity2,
+ "country names": countryNameToISO3
+ };
+ function countryNameToISO3(countryName) {
+ for (var i = 0; i < countryIds.length; i++) {
+ var iso3 = countryIds[i];
+ var regex = new RegExp(countryRegex[iso3]);
+ if (regex.test(countryName.trim().toLowerCase())) return iso3;
+ }
+ loggers.log("Unrecognized country name: " + countryName + ".");
+ return false;
+ }
+ function locationToFeature(locationmode, location2, features) {
+ if (!location2 || typeof location2 !== "string") return false;
+ var locationId = locationmodeToIdFinder[locationmode](location2);
+ var filteredFeatures;
+ var f, i;
+ if (locationId) {
+ if (locationmode === "USA-states") {
+ filteredFeatures = [];
+ for (i = 0; i < features.length; i++) {
+ f = features[i];
+ if (f.properties && f.properties.gu && f.properties.gu === "USA") {
+ filteredFeatures.push(f);
+ }
+ }
+ } else {
+ filteredFeatures = features;
+ }
+ for (i = 0; i < filteredFeatures.length; i++) {
+ f = filteredFeatures[i];
+ if (f.id === locationId) return f;
+ }
+ loggers.log([
+ "Location with id",
+ locationId,
+ "does not have a matching topojson feature at this resolution."
+ ].join(" "));
+ }
+ return false;
+ }
+ function feature2polygons(feature) {
+ var geometry = feature.geometry;
+ var coords = geometry.coordinates;
+ var loc = feature.id;
+ var polygons = [];
+ var appendPolygon, j, k, m;
+ function doesCrossAntiMerdian(pts) {
+ for (var l = 0; l < pts.length - 1; l++) {
+ if (pts[l][0] > 0 && pts[l + 1][0] < 0) return l;
+ }
+ return null;
+ }
+ if (loc === "RUS" || loc === "FJI") {
+ appendPolygon = function(_pts) {
+ var pts;
+ if (doesCrossAntiMerdian(_pts) === null) {
+ pts = _pts;
+ } else {
+ pts = new Array(_pts.length);
+ for (m = 0; m < _pts.length; m++) {
+ pts[m] = [
+ _pts[m][0] < 0 ? _pts[m][0] + 360 : _pts[m][0],
+ _pts[m][1]
+ ];
+ }
+ }
+ polygons.push(polygon.tester(pts));
+ };
+ } else if (loc === "ATA") {
+ appendPolygon = function(pts) {
+ var crossAntiMeridianIndex = doesCrossAntiMerdian(pts);
+ if (crossAntiMeridianIndex === null) {
+ return polygons.push(polygon.tester(pts));
+ }
+ var stitch = new Array(pts.length + 1);
+ var si = 0;
+ for (m = 0; m < pts.length; m++) {
+ if (m > crossAntiMeridianIndex) {
+ stitch[si++] = [pts[m][0] + 360, pts[m][1]];
+ } else if (m === crossAntiMeridianIndex) {
+ stitch[si++] = pts[m];
+ stitch[si++] = [pts[m][0], -90];
+ } else {
+ stitch[si++] = pts[m];
+ }
+ }
+ var tester = polygon.tester(stitch);
+ tester.pts.pop();
+ polygons.push(tester);
+ };
+ } else {
+ appendPolygon = function(pts) {
+ polygons.push(polygon.tester(pts));
+ };
+ }
+ switch (geometry.type) {
+ case "MultiPolygon":
+ for (j = 0; j < coords.length; j++) {
+ for (k = 0; k < coords[j].length; k++) {
+ appendPolygon(coords[j][k]);
+ }
+ }
+ break;
+ case "Polygon":
+ for (j = 0; j < coords.length; j++) {
+ appendPolygon(coords[j]);
+ }
+ break;
+ }
+ return polygons;
+ }
+ function getTraceGeojson(trace) {
+ var g = trace.geojson;
+ var PlotlyGeoAssets2 = window.PlotlyGeoAssets || {};
+ var geojsonIn = typeof g === "string" ? PlotlyGeoAssets2[g] : g;
+ if (!isPlainObject(geojsonIn)) {
+ loggers.error("Oops ... something went wrong when fetching " + g);
+ return false;
+ }
+ return geojsonIn;
+ }
+ function extractTraceFeature(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var geojsonIn = getTraceGeojson(trace);
+ if (!geojsonIn) return false;
+ var lookup = {};
+ var featuresOut = [];
+ var i;
+ for (i = 0; i < trace._length; i++) {
+ var cdi = calcTrace[i];
+ if (cdi.loc || cdi.loc === 0) {
+ lookup[cdi.loc] = cdi;
+ }
+ }
+ function appendFeature(fIn) {
+ var id = nestedProperty(fIn, trace.featureidkey || "id").get();
+ var cdi2 = lookup[id];
+ if (cdi2) {
+ var geometry = fIn.geometry;
+ if (geometry.type === "Polygon" || geometry.type === "MultiPolygon") {
+ var fOut = {
+ type: "Feature",
+ id,
+ geometry,
+ properties: {}
+ };
+ if (fOut.geometry.coordinates.length > 0) {
+ fOut.properties.ct = findCentroid(fOut);
+ } else {
+ fOut.properties.ct = [NaN, NaN];
+ }
+ cdi2.fIn = fIn;
+ cdi2.fOut = fOut;
+ featuresOut.push(fOut);
+ } else {
+ loggers.log([
+ "Location",
+ cdi2.loc,
+ "does not have a valid GeoJSON geometry.",
+ "Traces with locationmode *geojson-id* only support",
+ "*Polygon* and *MultiPolygon* geometries."
+ ].join(" "));
+ }
+ }
+ delete lookup[id];
+ }
+ switch (geojsonIn.type) {
+ case "FeatureCollection":
+ var featuresIn = geojsonIn.features;
+ for (i = 0; i < featuresIn.length; i++) {
+ appendFeature(featuresIn[i]);
+ }
+ break;
+ case "Feature":
+ appendFeature(geojsonIn);
+ break;
+ default:
+ loggers.warn([
+ "Invalid GeoJSON type",
+ (geojsonIn.type || "none") + ".",
+ "Traces with locationmode *geojson-id* only support",
+ "*FeatureCollection* and *Feature* types."
+ ].join(" "));
+ return false;
+ }
+ for (var loc in lookup) {
+ loggers.log([
+ "Location *" + loc + "*",
+ "does not have a matching feature with id-key",
+ "*" + trace.featureidkey + "*."
+ ].join(" "));
+ }
+ return featuresOut;
+ }
+ function findCentroid(feature) {
+ var geometry = feature.geometry;
+ var poly;
+ if (geometry.type === "MultiPolygon") {
+ var coords = geometry.coordinates;
+ var maxArea = 0;
+ for (var i = 0; i < coords.length; i++) {
+ var polyi = { type: "Polygon", coordinates: coords[i] };
+ var area = turfArea(polyi);
+ if (area > maxArea) {
+ maxArea = area;
+ poly = polyi;
+ }
+ }
+ } else {
+ poly = geometry;
+ }
+ return turfCentroid(poly).geometry.coordinates;
+ }
+ function fetchTraceGeoData(calcData) {
+ var PlotlyGeoAssets2 = window.PlotlyGeoAssets || {};
+ var promises = [];
+ function fetch2(url2) {
+ return new Promise(function(resolve, reject) {
+ d3.json(url2, function(err, d) {
+ if (err) {
+ delete PlotlyGeoAssets2[url2];
+ var msg = err.status === 404 ? 'GeoJSON at URL "' + url2 + '" does not exist.' : "Unexpected error while fetching from " + url2;
+ return reject(new Error(msg));
+ }
+ PlotlyGeoAssets2[url2] = d;
+ return resolve(d);
+ });
+ });
+ }
+ function wait(url2) {
+ return new Promise(function(resolve, reject) {
+ var cnt = 0;
+ var interval = setInterval(function() {
+ if (PlotlyGeoAssets2[url2] && PlotlyGeoAssets2[url2] !== "pending") {
+ clearInterval(interval);
+ return resolve(PlotlyGeoAssets2[url2]);
+ }
+ if (cnt > 100) {
+ clearInterval(interval);
+ return reject("Unexpected error while fetching from " + url2);
+ }
+ cnt++;
+ }, 50);
+ });
+ }
+ for (var i = 0; i < calcData.length; i++) {
+ var trace = calcData[i][0].trace;
+ var url = trace.geojson;
+ if (typeof url === "string") {
+ if (!PlotlyGeoAssets2[url]) {
+ PlotlyGeoAssets2[url] = "pending";
+ promises.push(fetch2(url));
+ } else if (PlotlyGeoAssets2[url] === "pending") {
+ promises.push(wait(url));
+ }
+ }
+ }
+ return promises;
+ }
+ function computeBbox(d) {
+ return turfBbox(d);
+ }
+ module.exports = {
+ locationToFeature,
+ feature2polygons,
+ getTraceGeojson,
+ extractTraceFeature,
+ fetchTraceGeoData,
+ computeBbox
+ };
+ }
+ });
+
+ // src/traces/scattergeo/style.js
+ var require_style17 = __commonJS({
+ "src/traces/scattergeo/style.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var Drawing = require_drawing();
+ var Color2 = require_color();
+ var scatterStyle = require_style2();
+ var stylePoints = scatterStyle.stylePoints;
+ var styleText = scatterStyle.styleText;
+ module.exports = function style(gd, calcTrace) {
+ if (calcTrace) styleTrace(gd, calcTrace);
+ };
+ function styleTrace(gd, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var s = calcTrace[0].node3;
+ s.style("opacity", calcTrace[0].trace.opacity);
+ stylePoints(s, trace, gd);
+ styleText(s, trace, gd);
+ s.selectAll("path.js-line").style("fill", "none").each(function(d) {
+ var path = d3.select(this);
+ var trace2 = d.trace;
+ var line = trace2.line || {};
+ path.call(Color2.stroke, line.color).call(Drawing.dashLine, line.dash || "", line.width || 0);
+ if (trace2.fill !== "none") {
+ path.call(Color2.fill, trace2.fillcolor);
+ }
+ });
+ }
+ }
+ });
+
+ // src/traces/scattergeo/plot.js
+ var require_plot17 = __commonJS({
+ "src/traces/scattergeo/plot.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var Lib = require_lib();
+ var getTopojsonFeatures = require_topojson_utils().getTopojsonFeatures;
+ var geoJsonUtils = require_geojson_utils();
+ var geoUtils = require_geo_location_utils();
+ var findExtremes = require_autorange().findExtremes;
+ var BADNUM = require_numerical().BADNUM;
+ var calcMarkerSize = require_calc3().calcMarkerSize;
+ var subTypes = require_subtypes();
+ var style = require_style17();
+ function plot(gd, geo, calcData) {
+ var scatterLayer = geo.layers.frontplot.select(".scatterlayer");
+ var gTraces = Lib.makeTraceGroups(scatterLayer, calcData, "trace scattergeo");
+ function removeBADNUM(d, node) {
+ if (d.lonlat[0] === BADNUM) {
+ d3.select(node).remove();
+ }
+ }
+ gTraces.selectAll("*").remove();
+ gTraces.each(function(calcTrace) {
+ var s = d3.select(this);
+ var trace = calcTrace[0].trace;
+ if (subTypes.hasLines(trace) || trace.fill !== "none") {
+ var lineCoords = geoJsonUtils.calcTraceToLineCoords(calcTrace);
+ var lineData = trace.fill !== "none" ? geoJsonUtils.makePolygon(lineCoords) : geoJsonUtils.makeLine(lineCoords);
+ s.selectAll("path.js-line").data([{ geojson: lineData, trace }]).enter().append("path").classed("js-line", true).style("stroke-miterlimit", 2);
+ }
+ if (subTypes.hasMarkers(trace)) {
+ s.selectAll("path.point").data(Lib.identity).enter().append("path").classed("point", true).each(function(calcPt) {
+ removeBADNUM(calcPt, this);
+ });
+ }
+ if (subTypes.hasText(trace)) {
+ s.selectAll("g").data(Lib.identity).enter().append("g").append("text").each(function(calcPt) {
+ removeBADNUM(calcPt, this);
+ });
+ }
+ style(gd, calcTrace);
+ });
+ }
+ function calcGeoJSON(calcTrace, fullLayout) {
+ var trace = calcTrace[0].trace;
+ var geoLayout = fullLayout[trace.geo];
+ var geo = geoLayout._subplot;
+ var len = trace._length;
+ var i, calcPt;
+ if (Lib.isArrayOrTypedArray(trace.locations)) {
+ var locationmode = trace.locationmode;
+ var features = locationmode === "geojson-id" ? geoUtils.extractTraceFeature(calcTrace) : getTopojsonFeatures(trace, geo.topojson);
+ for (i = 0; i < len; i++) {
+ calcPt = calcTrace[i];
+ var feature = locationmode === "geojson-id" ? calcPt.fOut : geoUtils.locationToFeature(locationmode, calcPt.loc, features);
+ calcPt.lonlat = feature ? feature.properties.ct : [BADNUM, BADNUM];
+ }
+ }
+ var opts = { padded: true };
+ var lonArray;
+ var latArray;
+ if (geoLayout.fitbounds === "geojson" && trace.locationmode === "geojson-id") {
+ var bboxGeojson = geoUtils.computeBbox(geoUtils.getTraceGeojson(trace));
+ lonArray = [bboxGeojson[0], bboxGeojson[2]];
+ latArray = [bboxGeojson[1], bboxGeojson[3]];
+ } else {
+ lonArray = new Array(len);
+ latArray = new Array(len);
+ for (i = 0; i < len; i++) {
+ calcPt = calcTrace[i];
+ lonArray[i] = calcPt.lonlat[0];
+ latArray[i] = calcPt.lonlat[1];
+ }
+ opts.ppad = calcMarkerSize(trace, len);
+ }
+ trace._extremes.lon = findExtremes(geoLayout.lonaxis._ax, lonArray, opts);
+ trace._extremes.lat = findExtremes(geoLayout.lataxis._ax, latArray, opts);
+ }
+ module.exports = {
+ calcGeoJSON,
+ plot
+ };
+ }
+ });
+
+ // src/traces/scattergeo/hover.js
+ var require_hover14 = __commonJS({
+ "src/traces/scattergeo/hover.js"(exports, module) {
+ "use strict";
+ var Fx = require_fx();
+ var BADNUM = require_numerical().BADNUM;
+ var getTraceColor = require_get_trace_color();
+ var fillText = require_lib().fillText;
+ var attributes = require_attributes48();
+ module.exports = function hoverPoints(pointData, xval, yval) {
+ var cd = pointData.cd;
+ var trace = cd[0].trace;
+ var xa = pointData.xa;
+ var ya = pointData.ya;
+ var geo = pointData.subplot;
+ var isLonLatOverEdges = geo.projection.isLonLatOverEdges;
+ var project = geo.project;
+ function distFn(d) {
+ var lonlat2 = d.lonlat;
+ if (lonlat2[0] === BADNUM) return Infinity;
+ if (isLonLatOverEdges(lonlat2)) return Infinity;
+ var pt = project(lonlat2);
+ var px = project([xval, yval]);
+ var dx = Math.abs(pt[0] - px[0]);
+ var dy = Math.abs(pt[1] - px[1]);
+ var rad2 = Math.max(3, d.mrc || 0);
+ return Math.max(Math.sqrt(dx * dx + dy * dy) - rad2, 1 - 3 / rad2);
+ }
+ Fx.getClosest(cd, distFn, pointData);
+ if (pointData.index === false) return;
+ var di = cd[pointData.index];
+ var lonlat = di.lonlat;
+ var pos = [xa.c2p(lonlat), ya.c2p(lonlat)];
+ var rad = di.mrc || 1;
+ pointData.x0 = pos[0] - rad;
+ pointData.x1 = pos[0] + rad;
+ pointData.y0 = pos[1] - rad;
+ pointData.y1 = pos[1] + rad;
+ pointData.loc = di.loc;
+ pointData.lon = lonlat[0];
+ pointData.lat = lonlat[1];
+ var fullLayout = {};
+ fullLayout[trace.geo] = { _subplot: geo };
+ var labels = trace._module.formatLabels(di, trace, fullLayout);
+ pointData.lonLabel = labels.lonLabel;
+ pointData.latLabel = labels.latLabel;
+ pointData.color = getTraceColor(trace, di);
+ pointData.extraText = getExtraText(trace, di, pointData, cd[0].t.labels);
+ pointData.hovertemplate = trace.hovertemplate;
+ return [pointData];
+ };
+ function getExtraText(trace, pt, pointData, labels) {
+ if (trace.hovertemplate) return;
+ var hoverinfo = pt.hi || trace.hoverinfo;
+ var parts = hoverinfo === "all" ? attributes.hoverinfo.flags : hoverinfo.split("+");
+ var hasLocation = parts.indexOf("location") !== -1 && Array.isArray(trace.locations);
+ var hasLon = parts.indexOf("lon") !== -1;
+ var hasLat = parts.indexOf("lat") !== -1;
+ var hasText = parts.indexOf("text") !== -1;
+ var text = [];
+ function format(val) {
+ return val + "\xB0";
+ }
+ if (hasLocation) {
+ text.push(pt.loc);
+ } else if (hasLon && hasLat) {
+ text.push("(" + format(pointData.latLabel) + ", " + format(pointData.lonLabel) + ")");
+ } else if (hasLon) {
+ text.push(labels.lon + format(pointData.lonLabel));
+ } else if (hasLat) {
+ text.push(labels.lat + format(pointData.latLabel));
+ }
+ if (hasText) {
+ fillText(pt, trace, text);
+ }
+ return text.join("
");
+ }
+ }
+ });
+
+ // src/traces/scattergeo/event_data.js
+ var require_event_data9 = __commonJS({
+ "src/traces/scattergeo/event_data.js"(exports, module) {
+ "use strict";
+ module.exports = function eventData(out, pt, trace, cd, pointNumber) {
+ out.lon = pt.lon;
+ out.lat = pt.lat;
+ out.location = pt.loc ? pt.loc : null;
+ var cdi = cd[pointNumber];
+ if (cdi.fIn && cdi.fIn.properties) {
+ out.properties = cdi.fIn.properties;
+ }
+ return out;
+ };
+ }
+ });
+
+ // src/traces/scattergeo/select.js
+ var require_select5 = __commonJS({
+ "src/traces/scattergeo/select.js"(exports, module) {
+ "use strict";
+ var subtypes = require_subtypes();
+ var BADNUM = require_numerical().BADNUM;
+ module.exports = function selectPoints(searchInfo, selectionTester) {
+ var cd = searchInfo.cd;
+ var xa = searchInfo.xaxis;
+ var ya = searchInfo.yaxis;
+ var selection = [];
+ var trace = cd[0].trace;
+ var di, lonlat, x, y, i;
+ var hasOnlyLines = !subtypes.hasMarkers(trace) && !subtypes.hasText(trace);
+ if (hasOnlyLines) return [];
+ if (selectionTester === false) {
+ for (i = 0; i < cd.length; i++) {
+ cd[i].selected = 0;
+ }
+ } else {
+ for (i = 0; i < cd.length; i++) {
+ di = cd[i];
+ lonlat = di.lonlat;
+ if (lonlat[0] === BADNUM) continue;
+ x = xa.c2p(lonlat);
+ y = ya.c2p(lonlat);
+ if (selectionTester.contains([x, y], null, i, searchInfo)) {
+ selection.push({
+ pointNumber: i,
+ lon: lonlat[0],
+ lat: lonlat[1]
+ });
+ di.selected = 1;
+ } else {
+ di.selected = 0;
+ }
+ }
+ }
+ return selection;
+ };
+ }
+ });
+
+ // node_modules/d3-array/dist/d3-array.js
+ var require_d3_array = __commonJS({
+ "node_modules/d3-array/dist/d3-array.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && false ? define(["exports"], factory) : factory(global2.d3 = global2.d3 || {});
+ })(exports, function(exports2) {
+ "use strict";
+ function ascending(a, b) {
+ return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
+ }
+ function bisector(compare) {
+ if (compare.length === 1) compare = ascendingComparator(compare);
+ return {
+ left: function(a, x, lo, hi) {
+ if (lo == null) lo = 0;
+ if (hi == null) hi = a.length;
+ while (lo < hi) {
+ var mid = lo + hi >>> 1;
+ if (compare(a[mid], x) < 0) lo = mid + 1;
+ else hi = mid;
+ }
+ return lo;
+ },
+ right: function(a, x, lo, hi) {
+ if (lo == null) lo = 0;
+ if (hi == null) hi = a.length;
+ while (lo < hi) {
+ var mid = lo + hi >>> 1;
+ if (compare(a[mid], x) > 0) hi = mid;
+ else lo = mid + 1;
+ }
+ return lo;
+ }
+ };
+ }
+ function ascendingComparator(f) {
+ return function(d, x) {
+ return ascending(f(d), x);
+ };
+ }
+ var ascendingBisect = bisector(ascending);
+ var bisectRight = ascendingBisect.right;
+ var bisectLeft = ascendingBisect.left;
+ function pairs(array2, f) {
+ if (f == null) f = pair;
+ var i = 0, n = array2.length - 1, p = array2[0], pairs2 = new Array(n < 0 ? 0 : n);
+ while (i < n) pairs2[i] = f(p, p = array2[++i]);
+ return pairs2;
+ }
+ function pair(a, b) {
+ return [a, b];
+ }
+ function cross(values0, values1, reduce) {
+ var n0 = values0.length, n1 = values1.length, values = new Array(n0 * n1), i0, i1, i, value0;
+ if (reduce == null) reduce = pair;
+ for (i0 = i = 0; i0 < n0; ++i0) {
+ for (value0 = values0[i0], i1 = 0; i1 < n1; ++i1, ++i) {
+ values[i] = reduce(value0, values1[i1]);
+ }
+ }
+ return values;
+ }
+ function descending(a, b) {
+ return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
+ }
+ function number(x) {
+ return x === null ? NaN : +x;
+ }
+ function variance(values, valueof) {
+ var n = values.length, m = 0, i = -1, mean2 = 0, value, delta, sum2 = 0;
+ if (valueof == null) {
+ while (++i < n) {
+ if (!isNaN(value = number(values[i]))) {
+ delta = value - mean2;
+ mean2 += delta / ++m;
+ sum2 += delta * (value - mean2);
+ }
+ }
+ } else {
+ while (++i < n) {
+ if (!isNaN(value = number(valueof(values[i], i, values)))) {
+ delta = value - mean2;
+ mean2 += delta / ++m;
+ sum2 += delta * (value - mean2);
+ }
+ }
+ }
+ if (m > 1) return sum2 / (m - 1);
+ }
+ function deviation(array2, f) {
+ var v = variance(array2, f);
+ return v ? Math.sqrt(v) : v;
+ }
+ function extent(values, valueof) {
+ var n = values.length, i = -1, value, min2, max2;
+ if (valueof == null) {
+ while (++i < n) {
+ if ((value = values[i]) != null && value >= value) {
+ min2 = max2 = value;
+ while (++i < n) {
+ if ((value = values[i]) != null) {
+ if (min2 > value) min2 = value;
+ if (max2 < value) max2 = value;
+ }
+ }
+ }
+ }
+ } else {
+ while (++i < n) {
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
+ min2 = max2 = value;
+ while (++i < n) {
+ if ((value = valueof(values[i], i, values)) != null) {
+ if (min2 > value) min2 = value;
+ if (max2 < value) max2 = value;
+ }
+ }
+ }
+ }
+ }
+ return [min2, max2];
+ }
+ var array = Array.prototype;
+ var slice = array.slice;
+ var map = array.map;
+ function constant(x) {
+ return function() {
+ return x;
+ };
+ }
+ function identity2(x) {
+ return x;
+ }
+ function range(start, stop, step) {
+ start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
+ var i = -1, n = Math.max(0, Math.ceil((stop - start) / step)) | 0, range2 = new Array(n);
+ while (++i < n) {
+ range2[i] = start + i * step;
+ }
+ return range2;
+ }
+ var e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2);
+ function ticks(start, stop, count) {
+ var reverse, i = -1, n, ticks2, step;
+ stop = +stop, start = +start, count = +count;
+ if (start === stop && count > 0) return [start];
+ if (reverse = stop < start) n = start, start = stop, stop = n;
+ if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
+ if (step > 0) {
+ start = Math.ceil(start / step);
+ stop = Math.floor(stop / step);
+ ticks2 = new Array(n = Math.ceil(stop - start + 1));
+ while (++i < n) ticks2[i] = (start + i) * step;
+ } else {
+ start = Math.floor(start * step);
+ stop = Math.ceil(stop * step);
+ ticks2 = new Array(n = Math.ceil(start - stop + 1));
+ while (++i < n) ticks2[i] = (start - i) / step;
+ }
+ if (reverse) ticks2.reverse();
+ return ticks2;
+ }
+ function tickIncrement(start, stop, count) {
+ var step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log(step) / Math.LN10), error = step / Math.pow(10, power);
+ return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
+ }
+ function tickStep(start, stop, count) {
+ var step0 = Math.abs(stop - start) / Math.max(0, count), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), error = step0 / step1;
+ if (error >= e10) step1 *= 10;
+ else if (error >= e5) step1 *= 5;
+ else if (error >= e2) step1 *= 2;
+ return stop < start ? -step1 : step1;
+ }
+ function sturges(values) {
+ return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
+ }
+ function histogram() {
+ var value = identity2, domain = extent, threshold = sturges;
+ function histogram2(data) {
+ var i, n = data.length, x, values = new Array(n);
+ for (i = 0; i < n; ++i) {
+ values[i] = value(data[i], i, data);
+ }
+ var xz = domain(values), x0 = xz[0], x1 = xz[1], tz = threshold(values, x0, x1);
+ if (!Array.isArray(tz)) {
+ tz = tickStep(x0, x1, tz);
+ tz = range(Math.ceil(x0 / tz) * tz, x1, tz);
+ }
+ var m = tz.length;
+ while (tz[0] <= x0) tz.shift(), --m;
+ while (tz[m - 1] > x1) tz.pop(), --m;
+ var bins = new Array(m + 1), bin;
+ for (i = 0; i <= m; ++i) {
+ bin = bins[i] = [];
+ bin.x0 = i > 0 ? tz[i - 1] : x0;
+ bin.x1 = i < m ? tz[i] : x1;
+ }
+ for (i = 0; i < n; ++i) {
+ x = values[i];
+ if (x0 <= x && x <= x1) {
+ bins[bisectRight(tz, x, 0, m)].push(data[i]);
+ }
+ }
+ return bins;
+ }
+ histogram2.value = function(_) {
+ return arguments.length ? (value = typeof _ === "function" ? _ : constant(_), histogram2) : value;
+ };
+ histogram2.domain = function(_) {
+ return arguments.length ? (domain = typeof _ === "function" ? _ : constant([_[0], _[1]]), histogram2) : domain;
+ };
+ histogram2.thresholds = function(_) {
+ return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram2) : threshold;
+ };
+ return histogram2;
+ }
+ function quantile(values, p, valueof) {
+ if (valueof == null) valueof = number;
+ if (!(n = values.length)) return;
+ if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
+ if (p >= 1) return +valueof(values[n - 1], n - 1, values);
+ var n, i = (n - 1) * p, i0 = Math.floor(i), value0 = +valueof(values[i0], i0, values), value1 = +valueof(values[i0 + 1], i0 + 1, values);
+ return value0 + (value1 - value0) * (i - i0);
+ }
+ function freedmanDiaconis(values, min2, max2) {
+ values = map.call(values, number).sort(ascending);
+ return Math.ceil((max2 - min2) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3)));
+ }
+ function scott(values, min2, max2) {
+ return Math.ceil((max2 - min2) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
+ }
+ function max(values, valueof) {
+ var n = values.length, i = -1, value, max2;
+ if (valueof == null) {
+ while (++i < n) {
+ if ((value = values[i]) != null && value >= value) {
+ max2 = value;
+ while (++i < n) {
+ if ((value = values[i]) != null && value > max2) {
+ max2 = value;
+ }
+ }
+ }
+ }
+ } else {
+ while (++i < n) {
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
+ max2 = value;
+ while (++i < n) {
+ if ((value = valueof(values[i], i, values)) != null && value > max2) {
+ max2 = value;
+ }
+ }
+ }
+ }
+ }
+ return max2;
+ }
+ function mean(values, valueof) {
+ var n = values.length, m = n, i = -1, value, sum2 = 0;
+ if (valueof == null) {
+ while (++i < n) {
+ if (!isNaN(value = number(values[i]))) sum2 += value;
+ else --m;
+ }
+ } else {
+ while (++i < n) {
+ if (!isNaN(value = number(valueof(values[i], i, values)))) sum2 += value;
+ else --m;
+ }
+ }
+ if (m) return sum2 / m;
+ }
+ function median(values, valueof) {
+ var n = values.length, i = -1, value, numbers = [];
+ if (valueof == null) {
+ while (++i < n) {
+ if (!isNaN(value = number(values[i]))) {
+ numbers.push(value);
+ }
+ }
+ } else {
+ while (++i < n) {
+ if (!isNaN(value = number(valueof(values[i], i, values)))) {
+ numbers.push(value);
+ }
+ }
+ }
+ return quantile(numbers.sort(ascending), 0.5);
+ }
+ function merge(arrays) {
+ var n = arrays.length, m, i = -1, j = 0, merged, array2;
+ while (++i < n) j += arrays[i].length;
+ merged = new Array(j);
+ while (--n >= 0) {
+ array2 = arrays[n];
+ m = array2.length;
+ while (--m >= 0) {
+ merged[--j] = array2[m];
+ }
+ }
+ return merged;
+ }
+ function min(values, valueof) {
+ var n = values.length, i = -1, value, min2;
+ if (valueof == null) {
+ while (++i < n) {
+ if ((value = values[i]) != null && value >= value) {
+ min2 = value;
+ while (++i < n) {
+ if ((value = values[i]) != null && min2 > value) {
+ min2 = value;
+ }
+ }
+ }
+ }
+ } else {
+ while (++i < n) {
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
+ min2 = value;
+ while (++i < n) {
+ if ((value = valueof(values[i], i, values)) != null && min2 > value) {
+ min2 = value;
+ }
+ }
+ }
+ }
+ }
+ return min2;
+ }
+ function permute(array2, indexes) {
+ var i = indexes.length, permutes = new Array(i);
+ while (i--) permutes[i] = array2[indexes[i]];
+ return permutes;
+ }
+ function scan(values, compare) {
+ if (!(n = values.length)) return;
+ var n, i = 0, j = 0, xi, xj = values[j];
+ if (compare == null) compare = ascending;
+ while (++i < n) {
+ if (compare(xi = values[i], xj) < 0 || compare(xj, xj) !== 0) {
+ xj = xi, j = i;
+ }
+ }
+ if (compare(xj, xj) === 0) return j;
+ }
+ function shuffle(array2, i0, i1) {
+ var m = (i1 == null ? array2.length : i1) - (i0 = i0 == null ? 0 : +i0), t, i;
+ while (m) {
+ i = Math.random() * m-- | 0;
+ t = array2[m + i0];
+ array2[m + i0] = array2[i + i0];
+ array2[i + i0] = t;
+ }
+ return array2;
+ }
+ function sum(values, valueof) {
+ var n = values.length, i = -1, value, sum2 = 0;
+ if (valueof == null) {
+ while (++i < n) {
+ if (value = +values[i]) sum2 += value;
+ }
+ } else {
+ while (++i < n) {
+ if (value = +valueof(values[i], i, values)) sum2 += value;
+ }
+ }
+ return sum2;
+ }
+ function transpose(matrix) {
+ if (!(n = matrix.length)) return [];
+ for (var i = -1, m = min(matrix, length), transpose2 = new Array(m); ++i < m; ) {
+ for (var j = -1, n, row = transpose2[i] = new Array(n); ++j < n; ) {
+ row[j] = matrix[j][i];
+ }
+ }
+ return transpose2;
+ }
+ function length(d) {
+ return d.length;
+ }
+ function zip() {
+ return transpose(arguments);
+ }
+ exports2.bisect = bisectRight;
+ exports2.bisectRight = bisectRight;
+ exports2.bisectLeft = bisectLeft;
+ exports2.ascending = ascending;
+ exports2.bisector = bisector;
+ exports2.cross = cross;
+ exports2.descending = descending;
+ exports2.deviation = deviation;
+ exports2.extent = extent;
+ exports2.histogram = histogram;
+ exports2.thresholdFreedmanDiaconis = freedmanDiaconis;
+ exports2.thresholdScott = scott;
+ exports2.thresholdSturges = sturges;
+ exports2.max = max;
+ exports2.mean = mean;
+ exports2.median = median;
+ exports2.merge = merge;
+ exports2.min = min;
+ exports2.pairs = pairs;
+ exports2.permute = permute;
+ exports2.quantile = quantile;
+ exports2.range = range;
+ exports2.scan = scan;
+ exports2.shuffle = shuffle;
+ exports2.sum = sum;
+ exports2.ticks = ticks;
+ exports2.tickIncrement = tickIncrement;
+ exports2.tickStep = tickStep;
+ exports2.transpose = transpose;
+ exports2.variance = variance;
+ exports2.zip = zip;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/d3-geo/dist/d3-geo.js
+ var require_d3_geo = __commonJS({
+ "node_modules/d3-geo/dist/d3-geo.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_d3_array()) : typeof define === "function" && false ? define(["exports", "d3-array"], factory) : (global2 = global2 || self, factory(global2.d3 = global2.d3 || {}, global2.d3));
+ })(exports, function(exports2, d3Array) {
+ "use strict";
+ function adder() {
+ return new Adder();
+ }
+ function Adder() {
+ this.reset();
+ }
+ Adder.prototype = {
+ constructor: Adder,
+ reset: function() {
+ this.s = // rounded value
+ this.t = 0;
+ },
+ add: function(y) {
+ add(temp, y, this.t);
+ add(this, temp.s, this.s);
+ if (this.s) this.t += temp.t;
+ else this.s = temp.t;
+ },
+ valueOf: function() {
+ return this.s;
+ }
+ };
+ var temp = new Adder();
+ function add(adder2, a, b) {
+ var x = adder2.s = a + b, bv = x - a, av = x - bv;
+ adder2.t = a - av + (b - bv);
+ }
+ var epsilon = 1e-6;
+ var epsilon22 = 1e-12;
+ var pi = Math.PI;
+ var halfPi = pi / 2;
+ var quarterPi = pi / 4;
+ var tau = pi * 2;
+ var degrees3 = 180 / pi;
+ var radians2 = pi / 180;
+ var abs = Math.abs;
+ var atan = Math.atan;
+ var atan2 = Math.atan2;
+ var cos = Math.cos;
+ var ceil = Math.ceil;
+ var exp = Math.exp;
+ var log = Math.log;
+ var pow = Math.pow;
+ var sin = Math.sin;
+ var sign = Math.sign || function(x) {
+ return x > 0 ? 1 : x < 0 ? -1 : 0;
+ };
+ var sqrt = Math.sqrt;
+ var tan = Math.tan;
+ function acos(x) {
+ return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
+ }
+ function asin(x) {
+ return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x);
+ }
+ function haversin(x) {
+ return (x = sin(x / 2)) * x;
+ }
+ function noop() {
+ }
+ function streamGeometry(geometry, stream) {
+ if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
+ streamGeometryType[geometry.type](geometry, stream);
+ }
+ }
+ var streamObjectType = {
+ Feature: function(object2, stream) {
+ streamGeometry(object2.geometry, stream);
+ },
+ FeatureCollection: function(object2, stream) {
+ var features = object2.features, i = -1, n = features.length;
+ while (++i < n) streamGeometry(features[i].geometry, stream);
+ }
+ };
+ var streamGeometryType = {
+ Sphere: function(object2, stream) {
+ stream.sphere();
+ },
+ Point: function(object2, stream) {
+ object2 = object2.coordinates;
+ stream.point(object2[0], object2[1], object2[2]);
+ },
+ MultiPoint: function(object2, stream) {
+ var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length;
+ while (++i < n) object2 = coordinates2[i], stream.point(object2[0], object2[1], object2[2]);
+ },
+ LineString: function(object2, stream) {
+ streamLine(object2.coordinates, stream, 0);
+ },
+ MultiLineString: function(object2, stream) {
+ var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length;
+ while (++i < n) streamLine(coordinates2[i], stream, 0);
+ },
+ Polygon: function(object2, stream) {
+ streamPolygon(object2.coordinates, stream);
+ },
+ MultiPolygon: function(object2, stream) {
+ var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length;
+ while (++i < n) streamPolygon(coordinates2[i], stream);
+ },
+ GeometryCollection: function(object2, stream) {
+ var geometries = object2.geometries, i = -1, n = geometries.length;
+ while (++i < n) streamGeometry(geometries[i], stream);
+ }
+ };
+ function streamLine(coordinates2, stream, closed) {
+ var i = -1, n = coordinates2.length - closed, coordinate;
+ stream.lineStart();
+ while (++i < n) coordinate = coordinates2[i], stream.point(coordinate[0], coordinate[1], coordinate[2]);
+ stream.lineEnd();
+ }
+ function streamPolygon(coordinates2, stream) {
+ var i = -1, n = coordinates2.length;
+ stream.polygonStart();
+ while (++i < n) streamLine(coordinates2[i], stream, 1);
+ stream.polygonEnd();
+ }
+ function geoStream(object2, stream) {
+ if (object2 && streamObjectType.hasOwnProperty(object2.type)) {
+ streamObjectType[object2.type](object2, stream);
+ } else {
+ streamGeometry(object2, stream);
+ }
+ }
+ var areaRingSum = adder();
+ var areaSum = adder(), lambda00, phi00, lambda0, cosPhi0, sinPhi0;
+ var areaStream = {
+ point: noop,
+ lineStart: noop,
+ lineEnd: noop,
+ polygonStart: function() {
+ areaRingSum.reset();
+ areaStream.lineStart = areaRingStart;
+ areaStream.lineEnd = areaRingEnd;
+ },
+ polygonEnd: function() {
+ var areaRing = +areaRingSum;
+ areaSum.add(areaRing < 0 ? tau + areaRing : areaRing);
+ this.lineStart = this.lineEnd = this.point = noop;
+ },
+ sphere: function() {
+ areaSum.add(tau);
+ }
+ };
+ function areaRingStart() {
+ areaStream.point = areaPointFirst;
+ }
+ function areaRingEnd() {
+ areaPoint(lambda00, phi00);
+ }
+ function areaPointFirst(lambda, phi) {
+ areaStream.point = areaPoint;
+ lambda00 = lambda, phi00 = phi;
+ lambda *= radians2, phi *= radians2;
+ lambda0 = lambda, cosPhi0 = cos(phi = phi / 2 + quarterPi), sinPhi0 = sin(phi);
+ }
+ function areaPoint(lambda, phi) {
+ lambda *= radians2, phi *= radians2;
+ phi = phi / 2 + quarterPi;
+ var dLambda = lambda - lambda0, sdLambda = dLambda >= 0 ? 1 : -1, adLambda = sdLambda * dLambda, cosPhi = cos(phi), sinPhi = sin(phi), k = sinPhi0 * sinPhi, u = cosPhi0 * cosPhi + k * cos(adLambda), v = k * sdLambda * sin(adLambda);
+ areaRingSum.add(atan2(v, u));
+ lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
+ }
+ function area(object2) {
+ areaSum.reset();
+ geoStream(object2, areaStream);
+ return areaSum * 2;
+ }
+ function spherical(cartesian2) {
+ return [atan2(cartesian2[1], cartesian2[0]), asin(cartesian2[2])];
+ }
+ function cartesian(spherical2) {
+ var lambda = spherical2[0], phi = spherical2[1], cosPhi = cos(phi);
+ return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi)];
+ }
+ function cartesianDot(a, b) {
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
+ }
+ function cartesianCross(a, b) {
+ return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
+ }
+ function cartesianAddInPlace(a, b) {
+ a[0] += b[0], a[1] += b[1], a[2] += b[2];
+ }
+ function cartesianScale(vector, k) {
+ return [vector[0] * k, vector[1] * k, vector[2] * k];
+ }
+ function cartesianNormalizeInPlace(d) {
+ var l = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
+ d[0] /= l, d[1] /= l, d[2] /= l;
+ }
+ var lambda0$1, phi0, lambda1, phi1, lambda2, lambda00$1, phi00$1, p0, deltaSum = adder(), ranges, range;
+ var boundsStream = {
+ point: boundsPoint,
+ lineStart: boundsLineStart,
+ lineEnd: boundsLineEnd,
+ polygonStart: function() {
+ boundsStream.point = boundsRingPoint;
+ boundsStream.lineStart = boundsRingStart;
+ boundsStream.lineEnd = boundsRingEnd;
+ deltaSum.reset();
+ areaStream.polygonStart();
+ },
+ polygonEnd: function() {
+ areaStream.polygonEnd();
+ boundsStream.point = boundsPoint;
+ boundsStream.lineStart = boundsLineStart;
+ boundsStream.lineEnd = boundsLineEnd;
+ if (areaRingSum < 0) lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90);
+ else if (deltaSum > epsilon) phi1 = 90;
+ else if (deltaSum < -epsilon) phi0 = -90;
+ range[0] = lambda0$1, range[1] = lambda1;
+ },
+ sphere: function() {
+ lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90);
+ }
+ };
+ function boundsPoint(lambda, phi) {
+ ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]);
+ if (phi < phi0) phi0 = phi;
+ if (phi > phi1) phi1 = phi;
+ }
+ function linePoint(lambda, phi) {
+ var p = cartesian([lambda * radians2, phi * radians2]);
+ if (p0) {
+ var normal = cartesianCross(p0, p), equatorial = [normal[1], -normal[0], 0], inflection = cartesianCross(equatorial, normal);
+ cartesianNormalizeInPlace(inflection);
+ inflection = spherical(inflection);
+ var delta = lambda - lambda2, sign2 = delta > 0 ? 1 : -1, lambdai = inflection[0] * degrees3 * sign2, phii, antimeridian = abs(delta) > 180;
+ if (antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
+ phii = inflection[1] * degrees3;
+ if (phii > phi1) phi1 = phii;
+ } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
+ phii = -inflection[1] * degrees3;
+ if (phii < phi0) phi0 = phii;
+ } else {
+ if (phi < phi0) phi0 = phi;
+ if (phi > phi1) phi1 = phi;
+ }
+ if (antimeridian) {
+ if (lambda < lambda2) {
+ if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda;
+ } else {
+ if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda;
+ }
+ } else {
+ if (lambda1 >= lambda0$1) {
+ if (lambda < lambda0$1) lambda0$1 = lambda;
+ if (lambda > lambda1) lambda1 = lambda;
+ } else {
+ if (lambda > lambda2) {
+ if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda;
+ } else {
+ if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda;
+ }
+ }
+ }
+ } else {
+ ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]);
+ }
+ if (phi < phi0) phi0 = phi;
+ if (phi > phi1) phi1 = phi;
+ p0 = p, lambda2 = lambda;
+ }
+ function boundsLineStart() {
+ boundsStream.point = linePoint;
+ }
+ function boundsLineEnd() {
+ range[0] = lambda0$1, range[1] = lambda1;
+ boundsStream.point = boundsPoint;
+ p0 = null;
+ }
+ function boundsRingPoint(lambda, phi) {
+ if (p0) {
+ var delta = lambda - lambda2;
+ deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);
+ } else {
+ lambda00$1 = lambda, phi00$1 = phi;
+ }
+ areaStream.point(lambda, phi);
+ linePoint(lambda, phi);
+ }
+ function boundsRingStart() {
+ areaStream.lineStart();
+ }
+ function boundsRingEnd() {
+ boundsRingPoint(lambda00$1, phi00$1);
+ areaStream.lineEnd();
+ if (abs(deltaSum) > epsilon) lambda0$1 = -(lambda1 = 180);
+ range[0] = lambda0$1, range[1] = lambda1;
+ p0 = null;
+ }
+ function angle(lambda02, lambda12) {
+ return (lambda12 -= lambda02) < 0 ? lambda12 + 360 : lambda12;
+ }
+ function rangeCompare(a, b) {
+ return a[0] - b[0];
+ }
+ function rangeContains(range2, x) {
+ return range2[0] <= range2[1] ? range2[0] <= x && x <= range2[1] : x < range2[0] || range2[1] < x;
+ }
+ function bounds(feature) {
+ var i, n, a, b, merged, deltaMax, delta;
+ phi1 = lambda1 = -(lambda0$1 = phi0 = Infinity);
+ ranges = [];
+ geoStream(feature, boundsStream);
+ if (n = ranges.length) {
+ ranges.sort(rangeCompare);
+ for (i = 1, a = ranges[0], merged = [a]; i < n; ++i) {
+ b = ranges[i];
+ if (rangeContains(a, b[0]) || rangeContains(a, b[1])) {
+ if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];
+ if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];
+ } else {
+ merged.push(a = b);
+ }
+ }
+ for (deltaMax = -Infinity, n = merged.length - 1, i = 0, a = merged[n]; i <= n; a = b, ++i) {
+ b = merged[i];
+ if ((delta = angle(a[1], b[0])) > deltaMax) deltaMax = delta, lambda0$1 = b[0], lambda1 = a[1];
+ }
+ }
+ ranges = range = null;
+ return lambda0$1 === Infinity || phi0 === Infinity ? [[NaN, NaN], [NaN, NaN]] : [[lambda0$1, phi0], [lambda1, phi1]];
+ }
+ var W0, W1, X0, Y0, Z0, X1, Y1, Z1, X2, Y2, Z2, lambda00$2, phi00$2, x0, y0, z0;
+ var centroidStream = {
+ sphere: noop,
+ point: centroidPoint,
+ lineStart: centroidLineStart,
+ lineEnd: centroidLineEnd,
+ polygonStart: function() {
+ centroidStream.lineStart = centroidRingStart;
+ centroidStream.lineEnd = centroidRingEnd;
+ },
+ polygonEnd: function() {
+ centroidStream.lineStart = centroidLineStart;
+ centroidStream.lineEnd = centroidLineEnd;
+ }
+ };
+ function centroidPoint(lambda, phi) {
+ lambda *= radians2, phi *= radians2;
+ var cosPhi = cos(phi);
+ centroidPointCartesian(cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi));
+ }
+ function centroidPointCartesian(x, y, z) {
+ ++W0;
+ X0 += (x - X0) / W0;
+ Y0 += (y - Y0) / W0;
+ Z0 += (z - Z0) / W0;
+ }
+ function centroidLineStart() {
+ centroidStream.point = centroidLinePointFirst;
+ }
+ function centroidLinePointFirst(lambda, phi) {
+ lambda *= radians2, phi *= radians2;
+ var cosPhi = cos(phi);
+ x0 = cosPhi * cos(lambda);
+ y0 = cosPhi * sin(lambda);
+ z0 = sin(phi);
+ centroidStream.point = centroidLinePoint;
+ centroidPointCartesian(x0, y0, z0);
+ }
+ function centroidLinePoint(lambda, phi) {
+ lambda *= radians2, phi *= radians2;
+ var cosPhi = cos(phi), x = cosPhi * cos(lambda), y = cosPhi * sin(lambda), z = sin(phi), w = atan2(sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z);
+ W1 += w;
+ X1 += w * (x0 + (x0 = x));
+ Y1 += w * (y0 + (y0 = y));
+ Z1 += w * (z0 + (z0 = z));
+ centroidPointCartesian(x0, y0, z0);
+ }
+ function centroidLineEnd() {
+ centroidStream.point = centroidPoint;
+ }
+ function centroidRingStart() {
+ centroidStream.point = centroidRingPointFirst;
+ }
+ function centroidRingEnd() {
+ centroidRingPoint(lambda00$2, phi00$2);
+ centroidStream.point = centroidPoint;
+ }
+ function centroidRingPointFirst(lambda, phi) {
+ lambda00$2 = lambda, phi00$2 = phi;
+ lambda *= radians2, phi *= radians2;
+ centroidStream.point = centroidRingPoint;
+ var cosPhi = cos(phi);
+ x0 = cosPhi * cos(lambda);
+ y0 = cosPhi * sin(lambda);
+ z0 = sin(phi);
+ centroidPointCartesian(x0, y0, z0);
+ }
+ function centroidRingPoint(lambda, phi) {
+ lambda *= radians2, phi *= radians2;
+ var cosPhi = cos(phi), x = cosPhi * cos(lambda), y = cosPhi * sin(lambda), z = sin(phi), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = sqrt(cx * cx + cy * cy + cz * cz), w = asin(m), v = m && -w / m;
+ X2 += v * cx;
+ Y2 += v * cy;
+ Z2 += v * cz;
+ W1 += w;
+ X1 += w * (x0 + (x0 = x));
+ Y1 += w * (y0 + (y0 = y));
+ Z1 += w * (z0 + (z0 = z));
+ centroidPointCartesian(x0, y0, z0);
+ }
+ function centroid(object2) {
+ W0 = W1 = X0 = Y0 = Z0 = X1 = Y1 = Z1 = X2 = Y2 = Z2 = 0;
+ geoStream(object2, centroidStream);
+ var x = X2, y = Y2, z = Z2, m = x * x + y * y + z * z;
+ if (m < epsilon22) {
+ x = X1, y = Y1, z = Z1;
+ if (W1 < epsilon) x = X0, y = Y0, z = Z0;
+ m = x * x + y * y + z * z;
+ if (m < epsilon22) return [NaN, NaN];
+ }
+ return [atan2(y, x) * degrees3, asin(z / sqrt(m)) * degrees3];
+ }
+ function constant(x) {
+ return function() {
+ return x;
+ };
+ }
+ function compose(a, b) {
+ function compose2(x, y) {
+ return x = a(x, y), b(x[0], x[1]);
+ }
+ if (a.invert && b.invert) compose2.invert = function(x, y) {
+ return x = b.invert(x, y), x && a.invert(x[0], x[1]);
+ };
+ return compose2;
+ }
+ function rotationIdentity(lambda, phi) {
+ return [abs(lambda) > pi ? lambda + Math.round(-lambda / tau) * tau : lambda, phi];
+ }
+ rotationIdentity.invert = rotationIdentity;
+ function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
+ return (deltaLambda %= tau) ? deltaPhi || deltaGamma ? compose(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) : rotationLambda(deltaLambda) : deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) : rotationIdentity;
+ }
+ function forwardRotationLambda(deltaLambda) {
+ return function(lambda, phi) {
+ return lambda += deltaLambda, [lambda > pi ? lambda - tau : lambda < -pi ? lambda + tau : lambda, phi];
+ };
+ }
+ function rotationLambda(deltaLambda) {
+ var rotation2 = forwardRotationLambda(deltaLambda);
+ rotation2.invert = forwardRotationLambda(-deltaLambda);
+ return rotation2;
+ }
+ function rotationPhiGamma(deltaPhi, deltaGamma) {
+ var cosDeltaPhi = cos(deltaPhi), sinDeltaPhi = sin(deltaPhi), cosDeltaGamma = cos(deltaGamma), sinDeltaGamma = sin(deltaGamma);
+ function rotation2(lambda, phi) {
+ var cosPhi = cos(phi), x = cos(lambda) * cosPhi, y = sin(lambda) * cosPhi, z = sin(phi), k = z * cosDeltaPhi + x * sinDeltaPhi;
+ return [
+ atan2(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi),
+ asin(k * cosDeltaGamma + y * sinDeltaGamma)
+ ];
+ }
+ rotation2.invert = function(lambda, phi) {
+ var cosPhi = cos(phi), x = cos(lambda) * cosPhi, y = sin(lambda) * cosPhi, z = sin(phi), k = z * cosDeltaGamma - y * sinDeltaGamma;
+ return [
+ atan2(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi),
+ asin(k * cosDeltaPhi - x * sinDeltaPhi)
+ ];
+ };
+ return rotation2;
+ }
+ function rotation(rotate) {
+ rotate = rotateRadians(rotate[0] * radians2, rotate[1] * radians2, rotate.length > 2 ? rotate[2] * radians2 : 0);
+ function forward(coordinates2) {
+ coordinates2 = rotate(coordinates2[0] * radians2, coordinates2[1] * radians2);
+ return coordinates2[0] *= degrees3, coordinates2[1] *= degrees3, coordinates2;
+ }
+ forward.invert = function(coordinates2) {
+ coordinates2 = rotate.invert(coordinates2[0] * radians2, coordinates2[1] * radians2);
+ return coordinates2[0] *= degrees3, coordinates2[1] *= degrees3, coordinates2;
+ };
+ return forward;
+ }
+ function circleStream(stream, radius, delta, direction, t02, t12) {
+ if (!delta) return;
+ var cosRadius = cos(radius), sinRadius = sin(radius), step = direction * delta;
+ if (t02 == null) {
+ t02 = radius + direction * tau;
+ t12 = radius - step / 2;
+ } else {
+ t02 = circleRadius(cosRadius, t02);
+ t12 = circleRadius(cosRadius, t12);
+ if (direction > 0 ? t02 < t12 : t02 > t12) t02 += direction * tau;
+ }
+ for (var point, t = t02; direction > 0 ? t > t12 : t < t12; t -= step) {
+ point = spherical([cosRadius, -sinRadius * cos(t), -sinRadius * sin(t)]);
+ stream.point(point[0], point[1]);
+ }
+ }
+ function circleRadius(cosRadius, point) {
+ point = cartesian(point), point[0] -= cosRadius;
+ cartesianNormalizeInPlace(point);
+ var radius = acos(-point[1]);
+ return ((-point[2] < 0 ? -radius : radius) + tau - epsilon) % tau;
+ }
+ function circle() {
+ var center = constant([0, 0]), radius = constant(90), precision = constant(6), ring, rotate, stream = { point };
+ function point(x, y) {
+ ring.push(x = rotate(x, y));
+ x[0] *= degrees3, x[1] *= degrees3;
+ }
+ function circle2() {
+ var c = center.apply(this, arguments), r = radius.apply(this, arguments) * radians2, p = precision.apply(this, arguments) * radians2;
+ ring = [];
+ rotate = rotateRadians(-c[0] * radians2, -c[1] * radians2, 0).invert;
+ circleStream(stream, r, p, 1);
+ c = { type: "Polygon", coordinates: [ring] };
+ ring = rotate = null;
+ return c;
+ }
+ circle2.center = function(_) {
+ return arguments.length ? (center = typeof _ === "function" ? _ : constant([+_[0], +_[1]]), circle2) : center;
+ };
+ circle2.radius = function(_) {
+ return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), circle2) : radius;
+ };
+ circle2.precision = function(_) {
+ return arguments.length ? (precision = typeof _ === "function" ? _ : constant(+_), circle2) : precision;
+ };
+ return circle2;
+ }
+ function clipBuffer() {
+ var lines = [], line;
+ return {
+ point: function(x, y, m) {
+ line.push([x, y, m]);
+ },
+ lineStart: function() {
+ lines.push(line = []);
+ },
+ lineEnd: noop,
+ rejoin: function() {
+ if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
+ },
+ result: function() {
+ var result = lines;
+ lines = [];
+ line = null;
+ return result;
+ }
+ };
+ }
+ function pointEqual(a, b) {
+ return abs(a[0] - b[0]) < epsilon && abs(a[1] - b[1]) < epsilon;
+ }
+ function Intersection(point, points, other, entry) {
+ this.x = point;
+ this.z = points;
+ this.o = other;
+ this.e = entry;
+ this.v = false;
+ this.n = this.p = null;
+ }
+ function clipRejoin(segments, compareIntersection2, startInside, interpolate2, stream) {
+ var subject = [], clip2 = [], i, n;
+ segments.forEach(function(segment) {
+ if ((n2 = segment.length - 1) <= 0) return;
+ var n2, p02 = segment[0], p1 = segment[n2], x;
+ if (pointEqual(p02, p1)) {
+ if (!p02[2] && !p1[2]) {
+ stream.lineStart();
+ for (i = 0; i < n2; ++i) stream.point((p02 = segment[i])[0], p02[1]);
+ stream.lineEnd();
+ return;
+ }
+ p1[0] += 2 * epsilon;
+ }
+ subject.push(x = new Intersection(p02, segment, null, true));
+ clip2.push(x.o = new Intersection(p02, null, x, false));
+ subject.push(x = new Intersection(p1, segment, null, false));
+ clip2.push(x.o = new Intersection(p1, null, x, true));
+ });
+ if (!subject.length) return;
+ clip2.sort(compareIntersection2);
+ link(subject);
+ link(clip2);
+ for (i = 0, n = clip2.length; i < n; ++i) {
+ clip2[i].e = startInside = !startInside;
+ }
+ var start = subject[0], points, point;
+ while (1) {
+ var current = start, isSubject = true;
+ while (current.v) if ((current = current.n) === start) return;
+ points = current.z;
+ stream.lineStart();
+ do {
+ current.v = current.o.v = true;
+ if (current.e) {
+ if (isSubject) {
+ for (i = 0, n = points.length; i < n; ++i) stream.point((point = points[i])[0], point[1]);
+ } else {
+ interpolate2(current.x, current.n.x, 1, stream);
+ }
+ current = current.n;
+ } else {
+ if (isSubject) {
+ points = current.p.z;
+ for (i = points.length - 1; i >= 0; --i) stream.point((point = points[i])[0], point[1]);
+ } else {
+ interpolate2(current.x, current.p.x, -1, stream);
+ }
+ current = current.p;
+ }
+ current = current.o;
+ points = current.z;
+ isSubject = !isSubject;
+ } while (!current.v);
+ stream.lineEnd();
+ }
+ }
+ function link(array) {
+ if (!(n = array.length)) return;
+ var n, i = 0, a = array[0], b;
+ while (++i < n) {
+ a.n = b = array[i];
+ b.p = a;
+ a = b;
+ }
+ a.n = b = array[0];
+ b.p = a;
+ }
+ var sum = adder();
+ function longitude(point) {
+ if (abs(point[0]) <= pi)
+ return point[0];
+ else
+ return sign(point[0]) * ((abs(point[0]) + pi) % tau - pi);
+ }
+ function polygonContains(polygon, point) {
+ var lambda = longitude(point), phi = point[1], sinPhi = sin(phi), normal = [sin(lambda), -cos(lambda), 0], angle2 = 0, winding = 0;
+ sum.reset();
+ if (sinPhi === 1) phi = halfPi + epsilon;
+ else if (sinPhi === -1) phi = -halfPi - epsilon;
+ for (var i = 0, n = polygon.length; i < n; ++i) {
+ if (!(m = (ring = polygon[i]).length)) continue;
+ var ring, m, point0 = ring[m - 1], lambda02 = longitude(point0), phi02 = point0[1] / 2 + quarterPi, sinPhi02 = sin(phi02), cosPhi02 = cos(phi02);
+ for (var j = 0; j < m; ++j, lambda02 = lambda12, sinPhi02 = sinPhi1, cosPhi02 = cosPhi1, point0 = point1) {
+ var point1 = ring[j], lambda12 = longitude(point1), phi12 = point1[1] / 2 + quarterPi, sinPhi1 = sin(phi12), cosPhi1 = cos(phi12), delta = lambda12 - lambda02, sign2 = delta >= 0 ? 1 : -1, absDelta = sign2 * delta, antimeridian = absDelta > pi, k = sinPhi02 * sinPhi1;
+ sum.add(atan2(k * sign2 * sin(absDelta), cosPhi02 * cosPhi1 + k * cos(absDelta)));
+ angle2 += antimeridian ? delta + sign2 * tau : delta;
+ if (antimeridian ^ lambda02 >= lambda ^ lambda12 >= lambda) {
+ var arc = cartesianCross(cartesian(point0), cartesian(point1));
+ cartesianNormalizeInPlace(arc);
+ var intersection = cartesianCross(normal, arc);
+ cartesianNormalizeInPlace(intersection);
+ var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection[2]);
+ if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
+ winding += antimeridian ^ delta >= 0 ? 1 : -1;
+ }
+ }
+ }
+ }
+ return (angle2 < -epsilon || angle2 < epsilon && sum < -epsilon) ^ winding & 1;
+ }
+ function clip(pointVisible, clipLine2, interpolate2, start) {
+ return function(sink) {
+ var line = clipLine2(sink), ringBuffer = clipBuffer(), ringSink = clipLine2(ringBuffer), polygonStarted = false, polygon, segments, ring;
+ var clip2 = {
+ point,
+ lineStart,
+ lineEnd,
+ polygonStart: function() {
+ clip2.point = pointRing;
+ clip2.lineStart = ringStart;
+ clip2.lineEnd = ringEnd;
+ segments = [];
+ polygon = [];
+ },
+ polygonEnd: function() {
+ clip2.point = point;
+ clip2.lineStart = lineStart;
+ clip2.lineEnd = lineEnd;
+ segments = d3Array.merge(segments);
+ var startInside = polygonContains(polygon, start);
+ if (segments.length) {
+ if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
+ clipRejoin(segments, compareIntersection, startInside, interpolate2, sink);
+ } else if (startInside) {
+ if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
+ sink.lineStart();
+ interpolate2(null, null, 1, sink);
+ sink.lineEnd();
+ }
+ if (polygonStarted) sink.polygonEnd(), polygonStarted = false;
+ segments = polygon = null;
+ },
+ sphere: function() {
+ sink.polygonStart();
+ sink.lineStart();
+ interpolate2(null, null, 1, sink);
+ sink.lineEnd();
+ sink.polygonEnd();
+ }
+ };
+ function point(lambda, phi) {
+ if (pointVisible(lambda, phi)) sink.point(lambda, phi);
+ }
+ function pointLine(lambda, phi) {
+ line.point(lambda, phi);
+ }
+ function lineStart() {
+ clip2.point = pointLine;
+ line.lineStart();
+ }
+ function lineEnd() {
+ clip2.point = point;
+ line.lineEnd();
+ }
+ function pointRing(lambda, phi) {
+ ring.push([lambda, phi]);
+ ringSink.point(lambda, phi);
+ }
+ function ringStart() {
+ ringSink.lineStart();
+ ring = [];
+ }
+ function ringEnd() {
+ pointRing(ring[0][0], ring[0][1]);
+ ringSink.lineEnd();
+ var clean = ringSink.clean(), ringSegments = ringBuffer.result(), i, n = ringSegments.length, m, segment, point2;
+ ring.pop();
+ polygon.push(ring);
+ ring = null;
+ if (!n) return;
+ if (clean & 1) {
+ segment = ringSegments[0];
+ if ((m = segment.length - 1) > 0) {
+ if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
+ sink.lineStart();
+ for (i = 0; i < m; ++i) sink.point((point2 = segment[i])[0], point2[1]);
+ sink.lineEnd();
+ }
+ return;
+ }
+ if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
+ segments.push(ringSegments.filter(validSegment));
+ }
+ return clip2;
+ };
+ }
+ function validSegment(segment) {
+ return segment.length > 1;
+ }
+ function compareIntersection(a, b) {
+ return ((a = a.x)[0] < 0 ? a[1] - halfPi - epsilon : halfPi - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfPi - epsilon : halfPi - b[1]);
+ }
+ var clipAntimeridian = clip(
+ function() {
+ return true;
+ },
+ clipAntimeridianLine,
+ clipAntimeridianInterpolate,
+ [-pi, -halfPi]
+ );
+ function clipAntimeridianLine(stream) {
+ var lambda02 = NaN, phi02 = NaN, sign0 = NaN, clean;
+ return {
+ lineStart: function() {
+ stream.lineStart();
+ clean = 1;
+ },
+ point: function(lambda12, phi12) {
+ var sign1 = lambda12 > 0 ? pi : -pi, delta = abs(lambda12 - lambda02);
+ if (abs(delta - pi) < epsilon) {
+ stream.point(lambda02, phi02 = (phi02 + phi12) / 2 > 0 ? halfPi : -halfPi);
+ stream.point(sign0, phi02);
+ stream.lineEnd();
+ stream.lineStart();
+ stream.point(sign1, phi02);
+ stream.point(lambda12, phi02);
+ clean = 0;
+ } else if (sign0 !== sign1 && delta >= pi) {
+ if (abs(lambda02 - sign0) < epsilon) lambda02 -= sign0 * epsilon;
+ if (abs(lambda12 - sign1) < epsilon) lambda12 -= sign1 * epsilon;
+ phi02 = clipAntimeridianIntersect(lambda02, phi02, lambda12, phi12);
+ stream.point(sign0, phi02);
+ stream.lineEnd();
+ stream.lineStart();
+ stream.point(sign1, phi02);
+ clean = 0;
+ }
+ stream.point(lambda02 = lambda12, phi02 = phi12);
+ sign0 = sign1;
+ },
+ lineEnd: function() {
+ stream.lineEnd();
+ lambda02 = phi02 = NaN;
+ },
+ clean: function() {
+ return 2 - clean;
+ }
+ };
+ }
+ function clipAntimeridianIntersect(lambda02, phi02, lambda12, phi12) {
+ var cosPhi02, cosPhi1, sinLambda0Lambda1 = sin(lambda02 - lambda12);
+ return abs(sinLambda0Lambda1) > epsilon ? atan((sin(phi02) * (cosPhi1 = cos(phi12)) * sin(lambda12) - sin(phi12) * (cosPhi02 = cos(phi02)) * sin(lambda02)) / (cosPhi02 * cosPhi1 * sinLambda0Lambda1)) : (phi02 + phi12) / 2;
+ }
+ function clipAntimeridianInterpolate(from, to, direction, stream) {
+ var phi;
+ if (from == null) {
+ phi = direction * halfPi;
+ stream.point(-pi, phi);
+ stream.point(0, phi);
+ stream.point(pi, phi);
+ stream.point(pi, 0);
+ stream.point(pi, -phi);
+ stream.point(0, -phi);
+ stream.point(-pi, -phi);
+ stream.point(-pi, 0);
+ stream.point(-pi, phi);
+ } else if (abs(from[0] - to[0]) > epsilon) {
+ var lambda = from[0] < to[0] ? pi : -pi;
+ phi = direction * lambda / 2;
+ stream.point(-lambda, phi);
+ stream.point(0, phi);
+ stream.point(lambda, phi);
+ } else {
+ stream.point(to[0], to[1]);
+ }
+ }
+ function clipCircle(radius) {
+ var cr = cos(radius), delta = 6 * radians2, smallRadius = cr > 0, notHemisphere = abs(cr) > epsilon;
+ function interpolate2(from, to, direction, stream) {
+ circleStream(stream, radius, delta, direction, from, to);
+ }
+ function visible(lambda, phi) {
+ return cos(lambda) * cos(phi) > cr;
+ }
+ function clipLine2(stream) {
+ var point0, c0, v0, v00, clean;
+ return {
+ lineStart: function() {
+ v00 = v0 = false;
+ clean = 1;
+ },
+ point: function(lambda, phi) {
+ var point1 = [lambda, phi], point2, v = visible(lambda, phi), c = smallRadius ? v ? 0 : code(lambda, phi) : v ? code(lambda + (lambda < 0 ? pi : -pi), phi) : 0;
+ if (!point0 && (v00 = v0 = v)) stream.lineStart();
+ if (v !== v0) {
+ point2 = intersect(point0, point1);
+ if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2))
+ point1[2] = 1;
+ }
+ if (v !== v0) {
+ clean = 0;
+ if (v) {
+ stream.lineStart();
+ point2 = intersect(point1, point0);
+ stream.point(point2[0], point2[1]);
+ } else {
+ point2 = intersect(point0, point1);
+ stream.point(point2[0], point2[1], 2);
+ stream.lineEnd();
+ }
+ point0 = point2;
+ } else if (notHemisphere && point0 && smallRadius ^ v) {
+ var t;
+ if (!(c & c0) && (t = intersect(point1, point0, true))) {
+ clean = 0;
+ if (smallRadius) {
+ stream.lineStart();
+ stream.point(t[0][0], t[0][1]);
+ stream.point(t[1][0], t[1][1]);
+ stream.lineEnd();
+ } else {
+ stream.point(t[1][0], t[1][1]);
+ stream.lineEnd();
+ stream.lineStart();
+ stream.point(t[0][0], t[0][1], 3);
+ }
+ }
+ }
+ if (v && (!point0 || !pointEqual(point0, point1))) {
+ stream.point(point1[0], point1[1]);
+ }
+ point0 = point1, v0 = v, c0 = c;
+ },
+ lineEnd: function() {
+ if (v0) stream.lineEnd();
+ point0 = null;
+ },
+ // Rejoin first and last segments if there were intersections and the first
+ // and last points were visible.
+ clean: function() {
+ return clean | (v00 && v0) << 1;
+ }
+ };
+ }
+ function intersect(a, b, two) {
+ var pa = cartesian(a), pb = cartesian(b);
+ var n1 = [1, 0, 0], n2 = cartesianCross(pa, pb), n2n2 = cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;
+ if (!determinant) return !two && a;
+ var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = cartesianCross(n1, n2), A5 = cartesianScale(n1, c1), B2 = cartesianScale(n2, c2);
+ cartesianAddInPlace(A5, B2);
+ var u = n1xn2, w = cartesianDot(A5, u), uu = cartesianDot(u, u), t22 = w * w - uu * (cartesianDot(A5, A5) - 1);
+ if (t22 < 0) return;
+ var t = sqrt(t22), q = cartesianScale(u, (-w - t) / uu);
+ cartesianAddInPlace(q, A5);
+ q = spherical(q);
+ if (!two) return q;
+ var lambda02 = a[0], lambda12 = b[0], phi02 = a[1], phi12 = b[1], z;
+ if (lambda12 < lambda02) z = lambda02, lambda02 = lambda12, lambda12 = z;
+ var delta2 = lambda12 - lambda02, polar = abs(delta2 - pi) < epsilon, meridian = polar || delta2 < epsilon;
+ if (!polar && phi12 < phi02) z = phi02, phi02 = phi12, phi12 = z;
+ if (meridian ? polar ? phi02 + phi12 > 0 ^ q[1] < (abs(q[0] - lambda02) < epsilon ? phi02 : phi12) : phi02 <= q[1] && q[1] <= phi12 : delta2 > pi ^ (lambda02 <= q[0] && q[0] <= lambda12)) {
+ var q1 = cartesianScale(u, (-w + t) / uu);
+ cartesianAddInPlace(q1, A5);
+ return [q, spherical(q1)];
+ }
+ }
+ function code(lambda, phi) {
+ var r = smallRadius ? radius : pi - radius, code2 = 0;
+ if (lambda < -r) code2 |= 1;
+ else if (lambda > r) code2 |= 2;
+ if (phi < -r) code2 |= 4;
+ else if (phi > r) code2 |= 8;
+ return code2;
+ }
+ return clip(visible, clipLine2, interpolate2, smallRadius ? [0, -radius] : [-pi, radius - pi]);
+ }
+ function clipLine(a, b, x02, y02, x12, y12) {
+ var ax = a[0], ay = a[1], bx = b[0], by = b[1], t02 = 0, t12 = 1, dx = bx - ax, dy = by - ay, r;
+ r = x02 - ax;
+ if (!dx && r > 0) return;
+ r /= dx;
+ if (dx < 0) {
+ if (r < t02) return;
+ if (r < t12) t12 = r;
+ } else if (dx > 0) {
+ if (r > t12) return;
+ if (r > t02) t02 = r;
+ }
+ r = x12 - ax;
+ if (!dx && r < 0) return;
+ r /= dx;
+ if (dx < 0) {
+ if (r > t12) return;
+ if (r > t02) t02 = r;
+ } else if (dx > 0) {
+ if (r < t02) return;
+ if (r < t12) t12 = r;
+ }
+ r = y02 - ay;
+ if (!dy && r > 0) return;
+ r /= dy;
+ if (dy < 0) {
+ if (r < t02) return;
+ if (r < t12) t12 = r;
+ } else if (dy > 0) {
+ if (r > t12) return;
+ if (r > t02) t02 = r;
+ }
+ r = y12 - ay;
+ if (!dy && r < 0) return;
+ r /= dy;
+ if (dy < 0) {
+ if (r > t12) return;
+ if (r > t02) t02 = r;
+ } else if (dy > 0) {
+ if (r < t02) return;
+ if (r < t12) t12 = r;
+ }
+ if (t02 > 0) a[0] = ax + t02 * dx, a[1] = ay + t02 * dy;
+ if (t12 < 1) b[0] = ax + t12 * dx, b[1] = ay + t12 * dy;
+ return true;
+ }
+ var clipMax = 1e9, clipMin = -clipMax;
+ function clipRectangle(x02, y02, x12, y12) {
+ function visible(x, y) {
+ return x02 <= x && x <= x12 && y02 <= y && y <= y12;
+ }
+ function interpolate2(from, to, direction, stream) {
+ var a = 0, a1 = 0;
+ if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoint(from, to) < 0 ^ direction > 0) {
+ do
+ stream.point(a === 0 || a === 3 ? x02 : x12, a > 1 ? y12 : y02);
+ while ((a = (a + direction + 4) % 4) !== a1);
+ } else {
+ stream.point(to[0], to[1]);
+ }
+ }
+ function corner(p, direction) {
+ return abs(p[0] - x02) < epsilon ? direction > 0 ? 0 : 3 : abs(p[0] - x12) < epsilon ? direction > 0 ? 2 : 1 : abs(p[1] - y02) < epsilon ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2;
+ }
+ function compareIntersection2(a, b) {
+ return comparePoint(a.x, b.x);
+ }
+ function comparePoint(a, b) {
+ var ca = corner(a, 1), cb = corner(b, 1);
+ return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0];
+ }
+ return function(stream) {
+ var activeStream = stream, bufferStream = clipBuffer(), segments, polygon, ring, x__, y__, v__, x_, y_, v_, first, clean;
+ var clipStream = {
+ point,
+ lineStart,
+ lineEnd,
+ polygonStart,
+ polygonEnd
+ };
+ function point(x, y) {
+ if (visible(x, y)) activeStream.point(x, y);
+ }
+ function polygonInside() {
+ var winding = 0;
+ for (var i = 0, n = polygon.length; i < n; ++i) {
+ for (var ring2 = polygon[i], j = 1, m = ring2.length, point2 = ring2[0], a0, a1, b0 = point2[0], b1 = point2[1]; j < m; ++j) {
+ a0 = b0, a1 = b1, point2 = ring2[j], b0 = point2[0], b1 = point2[1];
+ if (a1 <= y12) {
+ if (b1 > y12 && (b0 - a0) * (y12 - a1) > (b1 - a1) * (x02 - a0)) ++winding;
+ } else {
+ if (b1 <= y12 && (b0 - a0) * (y12 - a1) < (b1 - a1) * (x02 - a0)) --winding;
+ }
+ }
+ }
+ return winding;
+ }
+ function polygonStart() {
+ activeStream = bufferStream, segments = [], polygon = [], clean = true;
+ }
+ function polygonEnd() {
+ var startInside = polygonInside(), cleanInside = clean && startInside, visible2 = (segments = d3Array.merge(segments)).length;
+ if (cleanInside || visible2) {
+ stream.polygonStart();
+ if (cleanInside) {
+ stream.lineStart();
+ interpolate2(null, null, 1, stream);
+ stream.lineEnd();
+ }
+ if (visible2) {
+ clipRejoin(segments, compareIntersection2, startInside, interpolate2, stream);
+ }
+ stream.polygonEnd();
+ }
+ activeStream = stream, segments = polygon = ring = null;
+ }
+ function lineStart() {
+ clipStream.point = linePoint2;
+ if (polygon) polygon.push(ring = []);
+ first = true;
+ v_ = false;
+ x_ = y_ = NaN;
+ }
+ function lineEnd() {
+ if (segments) {
+ linePoint2(x__, y__);
+ if (v__ && v_) bufferStream.rejoin();
+ segments.push(bufferStream.result());
+ }
+ clipStream.point = point;
+ if (v_) activeStream.lineEnd();
+ }
+ function linePoint2(x, y) {
+ var v = visible(x, y);
+ if (polygon) ring.push([x, y]);
+ if (first) {
+ x__ = x, y__ = y, v__ = v;
+ first = false;
+ if (v) {
+ activeStream.lineStart();
+ activeStream.point(x, y);
+ }
+ } else {
+ if (v && v_) activeStream.point(x, y);
+ else {
+ var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))], b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))];
+ if (clipLine(a, b, x02, y02, x12, y12)) {
+ if (!v_) {
+ activeStream.lineStart();
+ activeStream.point(a[0], a[1]);
+ }
+ activeStream.point(b[0], b[1]);
+ if (!v) activeStream.lineEnd();
+ clean = false;
+ } else if (v) {
+ activeStream.lineStart();
+ activeStream.point(x, y);
+ clean = false;
+ }
+ }
+ }
+ x_ = x, y_ = y, v_ = v;
+ }
+ return clipStream;
+ };
+ }
+ function extent() {
+ var x02 = 0, y02 = 0, x12 = 960, y12 = 500, cache, cacheStream, clip2;
+ return clip2 = {
+ stream: function(stream) {
+ return cache && cacheStream === stream ? cache : cache = clipRectangle(x02, y02, x12, y12)(cacheStream = stream);
+ },
+ extent: function(_) {
+ return arguments.length ? (x02 = +_[0][0], y02 = +_[0][1], x12 = +_[1][0], y12 = +_[1][1], cache = cacheStream = null, clip2) : [[x02, y02], [x12, y12]];
+ }
+ };
+ }
+ var lengthSum = adder(), lambda0$2, sinPhi0$1, cosPhi0$1;
+ var lengthStream = {
+ sphere: noop,
+ point: noop,
+ lineStart: lengthLineStart,
+ lineEnd: noop,
+ polygonStart: noop,
+ polygonEnd: noop
+ };
+ function lengthLineStart() {
+ lengthStream.point = lengthPointFirst;
+ lengthStream.lineEnd = lengthLineEnd;
+ }
+ function lengthLineEnd() {
+ lengthStream.point = lengthStream.lineEnd = noop;
+ }
+ function lengthPointFirst(lambda, phi) {
+ lambda *= radians2, phi *= radians2;
+ lambda0$2 = lambda, sinPhi0$1 = sin(phi), cosPhi0$1 = cos(phi);
+ lengthStream.point = lengthPoint;
+ }
+ function lengthPoint(lambda, phi) {
+ lambda *= radians2, phi *= radians2;
+ var sinPhi = sin(phi), cosPhi = cos(phi), delta = abs(lambda - lambda0$2), cosDelta = cos(delta), sinDelta = sin(delta), x = cosPhi * sinDelta, y = cosPhi0$1 * sinPhi - sinPhi0$1 * cosPhi * cosDelta, z = sinPhi0$1 * sinPhi + cosPhi0$1 * cosPhi * cosDelta;
+ lengthSum.add(atan2(sqrt(x * x + y * y), z));
+ lambda0$2 = lambda, sinPhi0$1 = sinPhi, cosPhi0$1 = cosPhi;
+ }
+ function length(object2) {
+ lengthSum.reset();
+ geoStream(object2, lengthStream);
+ return +lengthSum;
+ }
+ var coordinates = [null, null], object = { type: "LineString", coordinates };
+ function distance(a, b) {
+ coordinates[0] = a;
+ coordinates[1] = b;
+ return length(object);
+ }
+ var containsObjectType = {
+ Feature: function(object2, point) {
+ return containsGeometry(object2.geometry, point);
+ },
+ FeatureCollection: function(object2, point) {
+ var features = object2.features, i = -1, n = features.length;
+ while (++i < n) if (containsGeometry(features[i].geometry, point)) return true;
+ return false;
+ }
+ };
+ var containsGeometryType = {
+ Sphere: function() {
+ return true;
+ },
+ Point: function(object2, point) {
+ return containsPoint(object2.coordinates, point);
+ },
+ MultiPoint: function(object2, point) {
+ var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length;
+ while (++i < n) if (containsPoint(coordinates2[i], point)) return true;
+ return false;
+ },
+ LineString: function(object2, point) {
+ return containsLine(object2.coordinates, point);
+ },
+ MultiLineString: function(object2, point) {
+ var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length;
+ while (++i < n) if (containsLine(coordinates2[i], point)) return true;
+ return false;
+ },
+ Polygon: function(object2, point) {
+ return containsPolygon(object2.coordinates, point);
+ },
+ MultiPolygon: function(object2, point) {
+ var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length;
+ while (++i < n) if (containsPolygon(coordinates2[i], point)) return true;
+ return false;
+ },
+ GeometryCollection: function(object2, point) {
+ var geometries = object2.geometries, i = -1, n = geometries.length;
+ while (++i < n) if (containsGeometry(geometries[i], point)) return true;
+ return false;
+ }
+ };
+ function containsGeometry(geometry, point) {
+ return geometry && containsGeometryType.hasOwnProperty(geometry.type) ? containsGeometryType[geometry.type](geometry, point) : false;
+ }
+ function containsPoint(coordinates2, point) {
+ return distance(coordinates2, point) === 0;
+ }
+ function containsLine(coordinates2, point) {
+ var ao, bo, ab;
+ for (var i = 0, n = coordinates2.length; i < n; i++) {
+ bo = distance(coordinates2[i], point);
+ if (bo === 0) return true;
+ if (i > 0) {
+ ab = distance(coordinates2[i], coordinates2[i - 1]);
+ if (ab > 0 && ao <= ab && bo <= ab && (ao + bo - ab) * (1 - Math.pow((ao - bo) / ab, 2)) < epsilon22 * ab)
+ return true;
+ }
+ ao = bo;
+ }
+ return false;
+ }
+ function containsPolygon(coordinates2, point) {
+ return !!polygonContains(coordinates2.map(ringRadians), pointRadians(point));
+ }
+ function ringRadians(ring) {
+ return ring = ring.map(pointRadians), ring.pop(), ring;
+ }
+ function pointRadians(point) {
+ return [point[0] * radians2, point[1] * radians2];
+ }
+ function contains(object2, point) {
+ return (object2 && containsObjectType.hasOwnProperty(object2.type) ? containsObjectType[object2.type] : containsGeometry)(object2, point);
+ }
+ function graticuleX(y02, y12, dy) {
+ var y = d3Array.range(y02, y12 - epsilon, dy).concat(y12);
+ return function(x) {
+ return y.map(function(y2) {
+ return [x, y2];
+ });
+ };
+ }
+ function graticuleY(x02, x12, dx) {
+ var x = d3Array.range(x02, x12 - epsilon, dx).concat(x12);
+ return function(y) {
+ return x.map(function(x2) {
+ return [x2, y];
+ });
+ };
+ }
+ function graticule() {
+ var x12, x02, X12, X02, y12, y02, Y12, Y02, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5;
+ function graticule2() {
+ return { type: "MultiLineString", coordinates: lines() };
+ }
+ function lines() {
+ return d3Array.range(ceil(X02 / DX) * DX, X12, DX).map(X).concat(d3Array.range(ceil(Y02 / DY) * DY, Y12, DY).map(Y)).concat(d3Array.range(ceil(x02 / dx) * dx, x12, dx).filter(function(x2) {
+ return abs(x2 % DX) > epsilon;
+ }).map(x)).concat(d3Array.range(ceil(y02 / dy) * dy, y12, dy).filter(function(y2) {
+ return abs(y2 % DY) > epsilon;
+ }).map(y));
+ }
+ graticule2.lines = function() {
+ return lines().map(function(coordinates2) {
+ return { type: "LineString", coordinates: coordinates2 };
+ });
+ };
+ graticule2.outline = function() {
+ return {
+ type: "Polygon",
+ coordinates: [
+ X(X02).concat(
+ Y(Y12).slice(1),
+ X(X12).reverse().slice(1),
+ Y(Y02).reverse().slice(1)
+ )
+ ]
+ };
+ };
+ graticule2.extent = function(_) {
+ if (!arguments.length) return graticule2.extentMinor();
+ return graticule2.extentMajor(_).extentMinor(_);
+ };
+ graticule2.extentMajor = function(_) {
+ if (!arguments.length) return [[X02, Y02], [X12, Y12]];
+ X02 = +_[0][0], X12 = +_[1][0];
+ Y02 = +_[0][1], Y12 = +_[1][1];
+ if (X02 > X12) _ = X02, X02 = X12, X12 = _;
+ if (Y02 > Y12) _ = Y02, Y02 = Y12, Y12 = _;
+ return graticule2.precision(precision);
+ };
+ graticule2.extentMinor = function(_) {
+ if (!arguments.length) return [[x02, y02], [x12, y12]];
+ x02 = +_[0][0], x12 = +_[1][0];
+ y02 = +_[0][1], y12 = +_[1][1];
+ if (x02 > x12) _ = x02, x02 = x12, x12 = _;
+ if (y02 > y12) _ = y02, y02 = y12, y12 = _;
+ return graticule2.precision(precision);
+ };
+ graticule2.step = function(_) {
+ if (!arguments.length) return graticule2.stepMinor();
+ return graticule2.stepMajor(_).stepMinor(_);
+ };
+ graticule2.stepMajor = function(_) {
+ if (!arguments.length) return [DX, DY];
+ DX = +_[0], DY = +_[1];
+ return graticule2;
+ };
+ graticule2.stepMinor = function(_) {
+ if (!arguments.length) return [dx, dy];
+ dx = +_[0], dy = +_[1];
+ return graticule2;
+ };
+ graticule2.precision = function(_) {
+ if (!arguments.length) return precision;
+ precision = +_;
+ x = graticuleX(y02, y12, 90);
+ y = graticuleY(x02, x12, precision);
+ X = graticuleX(Y02, Y12, 90);
+ Y = graticuleY(X02, X12, precision);
+ return graticule2;
+ };
+ return graticule2.extentMajor([[-180, -90 + epsilon], [180, 90 - epsilon]]).extentMinor([[-180, -80 - epsilon], [180, 80 + epsilon]]);
+ }
+ function graticule10() {
+ return graticule()();
+ }
+ function interpolate(a, b) {
+ var x02 = a[0] * radians2, y02 = a[1] * radians2, x12 = b[0] * radians2, y12 = b[1] * radians2, cy0 = cos(y02), sy0 = sin(y02), cy1 = cos(y12), sy1 = sin(y12), kx0 = cy0 * cos(x02), ky0 = cy0 * sin(x02), kx1 = cy1 * cos(x12), ky1 = cy1 * sin(x12), d = 2 * asin(sqrt(haversin(y12 - y02) + cy0 * cy1 * haversin(x12 - x02))), k = sin(d);
+ var interpolate2 = d ? function(t) {
+ var B2 = sin(t *= d) / k, A5 = sin(d - t) / k, x = A5 * kx0 + B2 * kx1, y = A5 * ky0 + B2 * ky1, z = A5 * sy0 + B2 * sy1;
+ return [
+ atan2(y, x) * degrees3,
+ atan2(z, sqrt(x * x + y * y)) * degrees3
+ ];
+ } : function() {
+ return [x02 * degrees3, y02 * degrees3];
+ };
+ interpolate2.distance = d;
+ return interpolate2;
+ }
+ function identity2(x) {
+ return x;
+ }
+ var areaSum$1 = adder(), areaRingSum$1 = adder(), x00, y00, x0$1, y0$1;
+ var areaStream$1 = {
+ point: noop,
+ lineStart: noop,
+ lineEnd: noop,
+ polygonStart: function() {
+ areaStream$1.lineStart = areaRingStart$1;
+ areaStream$1.lineEnd = areaRingEnd$1;
+ },
+ polygonEnd: function() {
+ areaStream$1.lineStart = areaStream$1.lineEnd = areaStream$1.point = noop;
+ areaSum$1.add(abs(areaRingSum$1));
+ areaRingSum$1.reset();
+ },
+ result: function() {
+ var area2 = areaSum$1 / 2;
+ areaSum$1.reset();
+ return area2;
+ }
+ };
+ function areaRingStart$1() {
+ areaStream$1.point = areaPointFirst$1;
+ }
+ function areaPointFirst$1(x, y) {
+ areaStream$1.point = areaPoint$1;
+ x00 = x0$1 = x, y00 = y0$1 = y;
+ }
+ function areaPoint$1(x, y) {
+ areaRingSum$1.add(y0$1 * x - x0$1 * y);
+ x0$1 = x, y0$1 = y;
+ }
+ function areaRingEnd$1() {
+ areaPoint$1(x00, y00);
+ }
+ var x0$2 = Infinity, y0$2 = x0$2, x1 = -x0$2, y1 = x1;
+ var boundsStream$1 = {
+ point: boundsPoint$1,
+ lineStart: noop,
+ lineEnd: noop,
+ polygonStart: noop,
+ polygonEnd: noop,
+ result: function() {
+ var bounds2 = [[x0$2, y0$2], [x1, y1]];
+ x1 = y1 = -(y0$2 = x0$2 = Infinity);
+ return bounds2;
+ }
+ };
+ function boundsPoint$1(x, y) {
+ if (x < x0$2) x0$2 = x;
+ if (x > x1) x1 = x;
+ if (y < y0$2) y0$2 = y;
+ if (y > y1) y1 = y;
+ }
+ var X0$1 = 0, Y0$1 = 0, Z0$1 = 0, X1$1 = 0, Y1$1 = 0, Z1$1 = 0, X2$1 = 0, Y2$1 = 0, Z2$1 = 0, x00$1, y00$1, x0$3, y0$3;
+ var centroidStream$1 = {
+ point: centroidPoint$1,
+ lineStart: centroidLineStart$1,
+ lineEnd: centroidLineEnd$1,
+ polygonStart: function() {
+ centroidStream$1.lineStart = centroidRingStart$1;
+ centroidStream$1.lineEnd = centroidRingEnd$1;
+ },
+ polygonEnd: function() {
+ centroidStream$1.point = centroidPoint$1;
+ centroidStream$1.lineStart = centroidLineStart$1;
+ centroidStream$1.lineEnd = centroidLineEnd$1;
+ },
+ result: function() {
+ var centroid2 = Z2$1 ? [X2$1 / Z2$1, Y2$1 / Z2$1] : Z1$1 ? [X1$1 / Z1$1, Y1$1 / Z1$1] : Z0$1 ? [X0$1 / Z0$1, Y0$1 / Z0$1] : [NaN, NaN];
+ X0$1 = Y0$1 = Z0$1 = X1$1 = Y1$1 = Z1$1 = X2$1 = Y2$1 = Z2$1 = 0;
+ return centroid2;
+ }
+ };
+ function centroidPoint$1(x, y) {
+ X0$1 += x;
+ Y0$1 += y;
+ ++Z0$1;
+ }
+ function centroidLineStart$1() {
+ centroidStream$1.point = centroidPointFirstLine;
+ }
+ function centroidPointFirstLine(x, y) {
+ centroidStream$1.point = centroidPointLine;
+ centroidPoint$1(x0$3 = x, y0$3 = y);
+ }
+ function centroidPointLine(x, y) {
+ var dx = x - x0$3, dy = y - y0$3, z = sqrt(dx * dx + dy * dy);
+ X1$1 += z * (x0$3 + x) / 2;
+ Y1$1 += z * (y0$3 + y) / 2;
+ Z1$1 += z;
+ centroidPoint$1(x0$3 = x, y0$3 = y);
+ }
+ function centroidLineEnd$1() {
+ centroidStream$1.point = centroidPoint$1;
+ }
+ function centroidRingStart$1() {
+ centroidStream$1.point = centroidPointFirstRing;
+ }
+ function centroidRingEnd$1() {
+ centroidPointRing(x00$1, y00$1);
+ }
+ function centroidPointFirstRing(x, y) {
+ centroidStream$1.point = centroidPointRing;
+ centroidPoint$1(x00$1 = x0$3 = x, y00$1 = y0$3 = y);
+ }
+ function centroidPointRing(x, y) {
+ var dx = x - x0$3, dy = y - y0$3, z = sqrt(dx * dx + dy * dy);
+ X1$1 += z * (x0$3 + x) / 2;
+ Y1$1 += z * (y0$3 + y) / 2;
+ Z1$1 += z;
+ z = y0$3 * x - x0$3 * y;
+ X2$1 += z * (x0$3 + x);
+ Y2$1 += z * (y0$3 + y);
+ Z2$1 += z * 3;
+ centroidPoint$1(x0$3 = x, y0$3 = y);
+ }
+ function PathContext(context) {
+ this._context = context;
+ }
+ PathContext.prototype = {
+ _radius: 4.5,
+ pointRadius: function(_) {
+ return this._radius = _, this;
+ },
+ polygonStart: function() {
+ this._line = 0;
+ },
+ polygonEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._point = 0;
+ },
+ lineEnd: function() {
+ if (this._line === 0) this._context.closePath();
+ this._point = NaN;
+ },
+ point: function(x, y) {
+ switch (this._point) {
+ case 0: {
+ this._context.moveTo(x, y);
+ this._point = 1;
+ break;
+ }
+ case 1: {
+ this._context.lineTo(x, y);
+ break;
+ }
+ default: {
+ this._context.moveTo(x + this._radius, y);
+ this._context.arc(x, y, this._radius, 0, tau);
+ break;
+ }
+ }
+ },
+ result: noop
+ };
+ var lengthSum$1 = adder(), lengthRing, x00$2, y00$2, x0$4, y0$4;
+ var lengthStream$1 = {
+ point: noop,
+ lineStart: function() {
+ lengthStream$1.point = lengthPointFirst$1;
+ },
+ lineEnd: function() {
+ if (lengthRing) lengthPoint$1(x00$2, y00$2);
+ lengthStream$1.point = noop;
+ },
+ polygonStart: function() {
+ lengthRing = true;
+ },
+ polygonEnd: function() {
+ lengthRing = null;
+ },
+ result: function() {
+ var length2 = +lengthSum$1;
+ lengthSum$1.reset();
+ return length2;
+ }
+ };
+ function lengthPointFirst$1(x, y) {
+ lengthStream$1.point = lengthPoint$1;
+ x00$2 = x0$4 = x, y00$2 = y0$4 = y;
+ }
+ function lengthPoint$1(x, y) {
+ x0$4 -= x, y0$4 -= y;
+ lengthSum$1.add(sqrt(x0$4 * x0$4 + y0$4 * y0$4));
+ x0$4 = x, y0$4 = y;
+ }
+ function PathString() {
+ this._string = [];
+ }
+ PathString.prototype = {
+ _radius: 4.5,
+ _circle: circle$1(4.5),
+ pointRadius: function(_) {
+ if ((_ = +_) !== this._radius) this._radius = _, this._circle = null;
+ return this;
+ },
+ polygonStart: function() {
+ this._line = 0;
+ },
+ polygonEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._point = 0;
+ },
+ lineEnd: function() {
+ if (this._line === 0) this._string.push("Z");
+ this._point = NaN;
+ },
+ point: function(x, y) {
+ switch (this._point) {
+ case 0: {
+ this._string.push("M", x, ",", y);
+ this._point = 1;
+ break;
+ }
+ case 1: {
+ this._string.push("L", x, ",", y);
+ break;
+ }
+ default: {
+ if (this._circle == null) this._circle = circle$1(this._radius);
+ this._string.push("M", x, ",", y, this._circle);
+ break;
+ }
+ }
+ },
+ result: function() {
+ if (this._string.length) {
+ var result = this._string.join("");
+ this._string = [];
+ return result;
+ } else {
+ return null;
+ }
+ }
+ };
+ function circle$1(radius) {
+ return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z";
+ }
+ function index(projection2, context) {
+ var pointRadius = 4.5, projectionStream, contextStream;
+ function path(object2) {
+ if (object2) {
+ if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
+ geoStream(object2, projectionStream(contextStream));
+ }
+ return contextStream.result();
+ }
+ path.area = function(object2) {
+ geoStream(object2, projectionStream(areaStream$1));
+ return areaStream$1.result();
+ };
+ path.measure = function(object2) {
+ geoStream(object2, projectionStream(lengthStream$1));
+ return lengthStream$1.result();
+ };
+ path.bounds = function(object2) {
+ geoStream(object2, projectionStream(boundsStream$1));
+ return boundsStream$1.result();
+ };
+ path.centroid = function(object2) {
+ geoStream(object2, projectionStream(centroidStream$1));
+ return centroidStream$1.result();
+ };
+ path.projection = function(_) {
+ return arguments.length ? (projectionStream = _ == null ? (projection2 = null, identity2) : (projection2 = _).stream, path) : projection2;
+ };
+ path.context = function(_) {
+ if (!arguments.length) return context;
+ contextStream = _ == null ? (context = null, new PathString()) : new PathContext(context = _);
+ if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius);
+ return path;
+ };
+ path.pointRadius = function(_) {
+ if (!arguments.length) return pointRadius;
+ pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_);
+ return path;
+ };
+ return path.projection(projection2).context(context);
+ }
+ function transform(methods) {
+ return {
+ stream: transformer(methods)
+ };
+ }
+ function transformer(methods) {
+ return function(stream) {
+ var s = new TransformStream();
+ for (var key in methods) s[key] = methods[key];
+ s.stream = stream;
+ return s;
+ };
+ }
+ function TransformStream() {
+ }
+ TransformStream.prototype = {
+ constructor: TransformStream,
+ point: function(x, y) {
+ this.stream.point(x, y);
+ },
+ 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();
+ }
+ };
+ function fit(projection2, fitBounds, object2) {
+ var clip2 = projection2.clipExtent && projection2.clipExtent();
+ projection2.scale(150).translate([0, 0]);
+ if (clip2 != null) projection2.clipExtent(null);
+ geoStream(object2, projection2.stream(boundsStream$1));
+ fitBounds(boundsStream$1.result());
+ if (clip2 != null) projection2.clipExtent(clip2);
+ return projection2;
+ }
+ function fitExtent(projection2, extent2, object2) {
+ return fit(projection2, function(b) {
+ var w = extent2[1][0] - extent2[0][0], h = extent2[1][1] - extent2[0][1], k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), x = +extent2[0][0] + (w - k * (b[1][0] + b[0][0])) / 2, y = +extent2[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
+ projection2.scale(150 * k).translate([x, y]);
+ }, object2);
+ }
+ function fitSize(projection2, size, object2) {
+ return fitExtent(projection2, [[0, 0], size], object2);
+ }
+ function fitWidth(projection2, width, object2) {
+ return fit(projection2, function(b) {
+ var w = +width, k = w / (b[1][0] - b[0][0]), x = (w - k * (b[1][0] + b[0][0])) / 2, y = -k * b[0][1];
+ projection2.scale(150 * k).translate([x, y]);
+ }, object2);
+ }
+ function fitHeight(projection2, height, object2) {
+ return fit(projection2, function(b) {
+ var h = +height, k = h / (b[1][1] - b[0][1]), x = -k * b[0][0], y = (h - k * (b[1][1] + b[0][1])) / 2;
+ projection2.scale(150 * k).translate([x, y]);
+ }, object2);
+ }
+ var maxDepth = 16, cosMinDistance = cos(30 * radians2);
+ function resample(project, delta2) {
+ return +delta2 ? resample$1(project, delta2) : resampleNone(project);
+ }
+ function resampleNone(project) {
+ return transformer({
+ point: function(x, y) {
+ x = project(x, y);
+ this.stream.point(x[0], x[1]);
+ }
+ });
+ }
+ function resample$1(project, delta2) {
+ function resampleLineTo(x02, y02, lambda02, a0, b0, c0, x12, y12, lambda12, a1, b1, c1, depth, stream) {
+ var dx = x12 - x02, dy = y12 - y02, d2 = dx * dx + dy * dy;
+ if (d2 > 4 * delta2 && depth--) {
+ var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = sqrt(a * a + b * b + c * c), phi2 = asin(c /= m), lambda22 = abs(abs(c) - 1) < epsilon || abs(lambda02 - lambda12) < epsilon ? (lambda02 + lambda12) / 2 : atan2(b, a), p = project(lambda22, phi2), x2 = p[0], y2 = p[1], dx2 = x2 - x02, dy2 = y2 - y02, dz = dy * dx2 - dx * dy2;
+ if (dz * dz / d2 > delta2 || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
+ resampleLineTo(x02, y02, lambda02, a0, b0, c0, x2, y2, lambda22, a /= m, b /= m, c, depth, stream);
+ stream.point(x2, y2);
+ resampleLineTo(x2, y2, lambda22, a, b, c, x12, y12, lambda12, a1, b1, c1, depth, stream);
+ }
+ }
+ }
+ return function(stream) {
+ var lambda002, x002, y002, a00, b00, c00, lambda02, x02, y02, a0, b0, c0;
+ var resampleStream = {
+ point,
+ lineStart,
+ lineEnd,
+ polygonStart: function() {
+ stream.polygonStart();
+ resampleStream.lineStart = ringStart;
+ },
+ polygonEnd: function() {
+ stream.polygonEnd();
+ resampleStream.lineStart = lineStart;
+ }
+ };
+ function point(x, y) {
+ x = project(x, y);
+ stream.point(x[0], x[1]);
+ }
+ function lineStart() {
+ x02 = NaN;
+ resampleStream.point = linePoint2;
+ stream.lineStart();
+ }
+ function linePoint2(lambda, phi) {
+ var c = cartesian([lambda, phi]), p = project(lambda, phi);
+ resampleLineTo(x02, y02, lambda02, a0, b0, c0, x02 = p[0], y02 = p[1], lambda02 = lambda, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);
+ stream.point(x02, y02);
+ }
+ function lineEnd() {
+ resampleStream.point = point;
+ stream.lineEnd();
+ }
+ function ringStart() {
+ lineStart();
+ resampleStream.point = ringPoint;
+ resampleStream.lineEnd = ringEnd;
+ }
+ function ringPoint(lambda, phi) {
+ linePoint2(lambda002 = lambda, phi), x002 = x02, y002 = y02, a00 = a0, b00 = b0, c00 = c0;
+ resampleStream.point = linePoint2;
+ }
+ function ringEnd() {
+ resampleLineTo(x02, y02, lambda02, a0, b0, c0, x002, y002, lambda002, a00, b00, c00, maxDepth, stream);
+ resampleStream.lineEnd = lineEnd;
+ lineEnd();
+ }
+ return resampleStream;
+ };
+ }
+ var transformRadians = transformer({
+ point: function(x, y) {
+ this.stream.point(x * radians2, y * radians2);
+ }
+ });
+ function transformRotate(rotate) {
+ return transformer({
+ point: function(x, y) {
+ var r = rotate(x, y);
+ return this.stream.point(r[0], r[1]);
+ }
+ });
+ }
+ function scaleTranslate(k, dx, dy, sx, sy) {
+ function transform2(x, y) {
+ x *= sx;
+ y *= sy;
+ return [dx + k * x, dy - k * y];
+ }
+ transform2.invert = function(x, y) {
+ return [(x - dx) / k * sx, (dy - y) / k * sy];
+ };
+ return transform2;
+ }
+ function scaleTranslateRotate(k, dx, dy, sx, sy, alpha) {
+ var cosAlpha = cos(alpha), sinAlpha = sin(alpha), a = cosAlpha * k, b = sinAlpha * k, ai = cosAlpha / k, bi = sinAlpha / k, ci = (sinAlpha * dy - cosAlpha * dx) / k, fi = (sinAlpha * dx + cosAlpha * dy) / k;
+ function transform2(x, y) {
+ x *= sx;
+ y *= sy;
+ return [a * x - b * y + dx, dy - b * x - a * y];
+ }
+ transform2.invert = function(x, y) {
+ return [sx * (ai * x - bi * y + ci), sy * (fi - bi * x - ai * y)];
+ };
+ return transform2;
+ }
+ function projection(project) {
+ return projectionMutator(function() {
+ return project;
+ })();
+ }
+ function projectionMutator(projectAt) {
+ var project, k = 150, x = 480, y = 250, lambda = 0, phi = 0, deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, alpha = 0, sx = 1, sy = 1, theta = null, preclip = clipAntimeridian, x02 = null, y02, x12, y12, postclip = identity2, delta2 = 0.5, projectResample, projectTransform, projectRotateTransform, cache, cacheStream;
+ function projection2(point) {
+ return projectRotateTransform(point[0] * radians2, point[1] * radians2);
+ }
+ function invert(point) {
+ point = projectRotateTransform.invert(point[0], point[1]);
+ return point && [point[0] * degrees3, point[1] * degrees3];
+ }
+ projection2.stream = function(stream) {
+ return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));
+ };
+ projection2.preclip = function(_) {
+ return arguments.length ? (preclip = _, theta = void 0, reset()) : preclip;
+ };
+ projection2.postclip = function(_) {
+ return arguments.length ? (postclip = _, x02 = y02 = x12 = y12 = null, reset()) : postclip;
+ };
+ projection2.clipAngle = function(_) {
+ return arguments.length ? (preclip = +_ ? clipCircle(theta = _ * radians2) : (theta = null, clipAntimeridian), reset()) : theta * degrees3;
+ };
+ projection2.clipExtent = function(_) {
+ return arguments.length ? (postclip = _ == null ? (x02 = y02 = x12 = y12 = null, identity2) : clipRectangle(x02 = +_[0][0], y02 = +_[0][1], x12 = +_[1][0], y12 = +_[1][1]), reset()) : x02 == null ? null : [[x02, y02], [x12, y12]];
+ };
+ projection2.scale = function(_) {
+ return arguments.length ? (k = +_, recenter()) : k;
+ };
+ projection2.translate = function(_) {
+ return arguments.length ? (x = +_[0], y = +_[1], recenter()) : [x, y];
+ };
+ projection2.center = function(_) {
+ return arguments.length ? (lambda = _[0] % 360 * radians2, phi = _[1] % 360 * radians2, recenter()) : [lambda * degrees3, phi * degrees3];
+ };
+ projection2.rotate = function(_) {
+ return arguments.length ? (deltaLambda = _[0] % 360 * radians2, deltaPhi = _[1] % 360 * radians2, deltaGamma = _.length > 2 ? _[2] % 360 * radians2 : 0, recenter()) : [deltaLambda * degrees3, deltaPhi * degrees3, deltaGamma * degrees3];
+ };
+ projection2.angle = function(_) {
+ return arguments.length ? (alpha = _ % 360 * radians2, recenter()) : alpha * degrees3;
+ };
+ projection2.reflectX = function(_) {
+ return arguments.length ? (sx = _ ? -1 : 1, recenter()) : sx < 0;
+ };
+ projection2.reflectY = function(_) {
+ return arguments.length ? (sy = _ ? -1 : 1, recenter()) : sy < 0;
+ };
+ projection2.precision = function(_) {
+ return arguments.length ? (projectResample = resample(projectTransform, delta2 = _ * _), reset()) : sqrt(delta2);
+ };
+ projection2.fitExtent = function(extent2, object2) {
+ return fitExtent(projection2, extent2, object2);
+ };
+ projection2.fitSize = function(size, object2) {
+ return fitSize(projection2, size, object2);
+ };
+ projection2.fitWidth = function(width, object2) {
+ return fitWidth(projection2, width, object2);
+ };
+ projection2.fitHeight = function(height, object2) {
+ return fitHeight(projection2, height, object2);
+ };
+ function recenter() {
+ var center = scaleTranslateRotate(k, 0, 0, sx, sy, alpha).apply(null, project(lambda, phi)), transform2 = (alpha ? scaleTranslateRotate : scaleTranslate)(k, x - center[0], y - center[1], sx, sy, alpha);
+ rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
+ projectTransform = compose(project, transform2);
+ projectRotateTransform = compose(rotate, projectTransform);
+ projectResample = resample(projectTransform, delta2);
+ return reset();
+ }
+ function reset() {
+ cache = cacheStream = null;
+ return projection2;
+ }
+ return function() {
+ project = projectAt.apply(this, arguments);
+ projection2.invert = project.invert && invert;
+ return recenter();
+ };
+ }
+ function conicProjection(projectAt) {
+ var phi02 = 0, phi12 = pi / 3, m = projectionMutator(projectAt), p = m(phi02, phi12);
+ p.parallels = function(_) {
+ return arguments.length ? m(phi02 = _[0] * radians2, phi12 = _[1] * radians2) : [phi02 * degrees3, phi12 * degrees3];
+ };
+ return p;
+ }
+ function cylindricalEqualAreaRaw(phi02) {
+ var cosPhi02 = cos(phi02);
+ function forward(lambda, phi) {
+ return [lambda * cosPhi02, sin(phi) / cosPhi02];
+ }
+ forward.invert = function(x, y) {
+ return [x / cosPhi02, asin(y * cosPhi02)];
+ };
+ return forward;
+ }
+ function conicEqualAreaRaw(y02, y12) {
+ var sy0 = sin(y02), n = (sy0 + sin(y12)) / 2;
+ if (abs(n) < epsilon) return cylindricalEqualAreaRaw(y02);
+ var c = 1 + sy0 * (2 * n - sy0), r0 = sqrt(c) / n;
+ function project(x, y) {
+ var r = sqrt(c - 2 * n * sin(y)) / n;
+ return [r * sin(x *= n), r0 - r * cos(x)];
+ }
+ project.invert = function(x, y) {
+ var r0y = r0 - y, l = atan2(x, abs(r0y)) * sign(r0y);
+ if (r0y * n < 0)
+ l -= pi * sign(x) * sign(r0y);
+ return [l / n, asin((c - (x * x + r0y * r0y) * n * n) / (2 * n))];
+ };
+ return project;
+ }
+ function conicEqualArea() {
+ return conicProjection(conicEqualAreaRaw).scale(155.424).center([0, 33.6442]);
+ }
+ function albers() {
+ return conicEqualArea().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]);
+ }
+ function multiplex(streams) {
+ var n = streams.length;
+ return {
+ point: function(x, y) {
+ var i = -1;
+ while (++i < n) streams[i].point(x, y);
+ },
+ sphere: function() {
+ var i = -1;
+ while (++i < n) streams[i].sphere();
+ },
+ lineStart: function() {
+ var i = -1;
+ while (++i < n) streams[i].lineStart();
+ },
+ lineEnd: function() {
+ var i = -1;
+ while (++i < n) streams[i].lineEnd();
+ },
+ polygonStart: function() {
+ var i = -1;
+ while (++i < n) streams[i].polygonStart();
+ },
+ polygonEnd: function() {
+ var i = -1;
+ while (++i < n) streams[i].polygonEnd();
+ }
+ };
+ }
+ function albersUsa() {
+ var cache, cacheStream, lower48 = albers(), lower48Point, alaska = conicEqualArea().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), alaskaPoint, hawaii = conicEqualArea().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), hawaiiPoint, point, pointStream = { point: function(x, y) {
+ point = [x, y];
+ } };
+ function albersUsa2(coordinates2) {
+ var x = coordinates2[0], y = coordinates2[1];
+ return point = null, (lower48Point.point(x, y), point) || (alaskaPoint.point(x, y), point) || (hawaiiPoint.point(x, y), point);
+ }
+ albersUsa2.invert = function(coordinates2) {
+ var k = lower48.scale(), t = lower48.translate(), x = (coordinates2[0] - t[0]) / k, y = (coordinates2[1] - t[1]) / k;
+ return (y >= 0.12 && y < 0.234 && x >= -0.425 && x < -0.214 ? alaska : y >= 0.166 && y < 0.234 && x >= -0.214 && x < -0.115 ? hawaii : lower48).invert(coordinates2);
+ };
+ albersUsa2.stream = function(stream) {
+ return cache && cacheStream === stream ? cache : cache = multiplex([lower48.stream(cacheStream = stream), alaska.stream(stream), hawaii.stream(stream)]);
+ };
+ albersUsa2.precision = function(_) {
+ if (!arguments.length) return lower48.precision();
+ lower48.precision(_), alaska.precision(_), hawaii.precision(_);
+ return reset();
+ };
+ albersUsa2.scale = function(_) {
+ if (!arguments.length) return lower48.scale();
+ lower48.scale(_), alaska.scale(_ * 0.35), hawaii.scale(_);
+ return albersUsa2.translate(lower48.translate());
+ };
+ albersUsa2.translate = function(_) {
+ if (!arguments.length) return lower48.translate();
+ var k = lower48.scale(), x = +_[0], y = +_[1];
+ lower48Point = lower48.translate(_).clipExtent([[x - 0.455 * k, y - 0.238 * k], [x + 0.455 * k, y + 0.238 * k]]).stream(pointStream);
+ alaskaPoint = alaska.translate([x - 0.307 * k, y + 0.201 * k]).clipExtent([[x - 0.425 * k + epsilon, y + 0.12 * k + epsilon], [x - 0.214 * k - epsilon, y + 0.234 * k - epsilon]]).stream(pointStream);
+ hawaiiPoint = hawaii.translate([x - 0.205 * k, y + 0.212 * k]).clipExtent([[x - 0.214 * k + epsilon, y + 0.166 * k + epsilon], [x - 0.115 * k - epsilon, y + 0.234 * k - epsilon]]).stream(pointStream);
+ return reset();
+ };
+ albersUsa2.fitExtent = function(extent2, object2) {
+ return fitExtent(albersUsa2, extent2, object2);
+ };
+ albersUsa2.fitSize = function(size, object2) {
+ return fitSize(albersUsa2, size, object2);
+ };
+ albersUsa2.fitWidth = function(width, object2) {
+ return fitWidth(albersUsa2, width, object2);
+ };
+ albersUsa2.fitHeight = function(height, object2) {
+ return fitHeight(albersUsa2, height, object2);
+ };
+ function reset() {
+ cache = cacheStream = null;
+ return albersUsa2;
+ }
+ return albersUsa2.scale(1070);
+ }
+ function azimuthalRaw(scale) {
+ return function(x, y) {
+ var cx = cos(x), cy = cos(y), k = scale(cx * cy);
+ return [
+ k * cy * sin(x),
+ k * sin(y)
+ ];
+ };
+ }
+ function azimuthalInvert(angle2) {
+ return function(x, y) {
+ var z = sqrt(x * x + y * y), c = angle2(z), sc = sin(c), cc = cos(c);
+ return [
+ atan2(x * sc, z * cc),
+ asin(z && y * sc / z)
+ ];
+ };
+ }
+ var azimuthalEqualAreaRaw = azimuthalRaw(function(cxcy) {
+ return sqrt(2 / (1 + cxcy));
+ });
+ azimuthalEqualAreaRaw.invert = azimuthalInvert(function(z) {
+ return 2 * asin(z / 2);
+ });
+ function azimuthalEqualArea() {
+ return projection(azimuthalEqualAreaRaw).scale(124.75).clipAngle(180 - 1e-3);
+ }
+ var azimuthalEquidistantRaw = azimuthalRaw(function(c) {
+ return (c = acos(c)) && c / sin(c);
+ });
+ azimuthalEquidistantRaw.invert = azimuthalInvert(function(z) {
+ return z;
+ });
+ function azimuthalEquidistant() {
+ return projection(azimuthalEquidistantRaw).scale(79.4188).clipAngle(180 - 1e-3);
+ }
+ function mercatorRaw(lambda, phi) {
+ return [lambda, log(tan((halfPi + phi) / 2))];
+ }
+ mercatorRaw.invert = function(x, y) {
+ return [x, 2 * atan(exp(y)) - halfPi];
+ };
+ function mercator() {
+ return mercatorProjection(mercatorRaw).scale(961 / tau);
+ }
+ function mercatorProjection(project) {
+ var m = projection(project), center = m.center, scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, x02 = null, y02, x12, y12;
+ m.scale = function(_) {
+ return arguments.length ? (scale(_), reclip()) : scale();
+ };
+ m.translate = function(_) {
+ return arguments.length ? (translate(_), reclip()) : translate();
+ };
+ m.center = function(_) {
+ return arguments.length ? (center(_), reclip()) : center();
+ };
+ m.clipExtent = function(_) {
+ return arguments.length ? (_ == null ? x02 = y02 = x12 = y12 = null : (x02 = +_[0][0], y02 = +_[0][1], x12 = +_[1][0], y12 = +_[1][1]), reclip()) : x02 == null ? null : [[x02, y02], [x12, y12]];
+ };
+ function reclip() {
+ var k = pi * scale(), t = m(rotation(m.rotate()).invert([0, 0]));
+ return clipExtent(x02 == null ? [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]] : project === mercatorRaw ? [[Math.max(t[0] - k, x02), y02], [Math.min(t[0] + k, x12), y12]] : [[x02, Math.max(t[1] - k, y02)], [x12, Math.min(t[1] + k, y12)]]);
+ }
+ return reclip();
+ }
+ function tany(y) {
+ return tan((halfPi + y) / 2);
+ }
+ function conicConformalRaw(y02, y12) {
+ var cy0 = cos(y02), n = y02 === y12 ? sin(y02) : log(cy0 / cos(y12)) / log(tany(y12) / tany(y02)), f = cy0 * pow(tany(y02), n) / n;
+ if (!n) return mercatorRaw;
+ function project(x, y) {
+ if (f > 0) {
+ if (y < -halfPi + epsilon) y = -halfPi + epsilon;
+ } else {
+ if (y > halfPi - epsilon) y = halfPi - epsilon;
+ }
+ var r = f / pow(tany(y), n);
+ return [r * sin(n * x), f - r * cos(n * x)];
+ }
+ project.invert = function(x, y) {
+ var fy = f - y, r = sign(n) * sqrt(x * x + fy * fy), l = atan2(x, abs(fy)) * sign(fy);
+ if (fy * n < 0)
+ l -= pi * sign(x) * sign(fy);
+ return [l / n, 2 * atan(pow(f / r, 1 / n)) - halfPi];
+ };
+ return project;
+ }
+ function conicConformal() {
+ return conicProjection(conicConformalRaw).scale(109.5).parallels([30, 30]);
+ }
+ function equirectangularRaw(lambda, phi) {
+ return [lambda, phi];
+ }
+ equirectangularRaw.invert = equirectangularRaw;
+ function equirectangular() {
+ return projection(equirectangularRaw).scale(152.63);
+ }
+ function conicEquidistantRaw(y02, y12) {
+ var cy0 = cos(y02), n = y02 === y12 ? sin(y02) : (cy0 - cos(y12)) / (y12 - y02), g = cy0 / n + y02;
+ if (abs(n) < epsilon) return equirectangularRaw;
+ function project(x, y) {
+ var gy = g - y, nx = n * x;
+ return [gy * sin(nx), g - gy * cos(nx)];
+ }
+ project.invert = function(x, y) {
+ var gy = g - y, l = atan2(x, abs(gy)) * sign(gy);
+ if (gy * n < 0)
+ l -= pi * sign(x) * sign(gy);
+ return [l / n, g - sign(n) * sqrt(x * x + gy * gy)];
+ };
+ return project;
+ }
+ function conicEquidistant() {
+ return conicProjection(conicEquidistantRaw).scale(131.154).center([0, 13.9389]);
+ }
+ var A1 = 1.340264, A2 = -0.081106, A3 = 893e-6, A4 = 3796e-6, M = sqrt(3) / 2, iterations = 12;
+ function equalEarthRaw(lambda, phi) {
+ var l = asin(M * sin(phi)), l2 = l * l, l6 = l2 * l2 * l2;
+ return [
+ lambda * cos(l) / (M * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2))),
+ l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2))
+ ];
+ }
+ equalEarthRaw.invert = function(x, y) {
+ var l = y, l2 = l * l, l6 = l2 * l2 * l2;
+ for (var i = 0, delta, fy, fpy; i < iterations; ++i) {
+ fy = l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2)) - y;
+ fpy = A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2);
+ l -= delta = fy / fpy, l2 = l * l, l6 = l2 * l2 * l2;
+ if (abs(delta) < epsilon22) break;
+ }
+ return [
+ M * x * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2)) / cos(l),
+ asin(sin(l) / M)
+ ];
+ };
+ function equalEarth() {
+ return projection(equalEarthRaw).scale(177.158);
+ }
+ function gnomonicRaw(x, y) {
+ var cy = cos(y), k = cos(x) * cy;
+ return [cy * sin(x) / k, sin(y) / k];
+ }
+ gnomonicRaw.invert = azimuthalInvert(atan);
+ function gnomonic() {
+ return projection(gnomonicRaw).scale(144.049).clipAngle(60);
+ }
+ function identity$1() {
+ var k = 1, tx = 0, ty = 0, sx = 1, sy = 1, alpha = 0, ca, sa, x02 = null, y02, x12, y12, kx = 1, ky = 1, transform2 = transformer({
+ point: function(x, y) {
+ var p = projection2([x, y]);
+ this.stream.point(p[0], p[1]);
+ }
+ }), postclip = identity2, cache, cacheStream;
+ function reset() {
+ kx = k * sx;
+ ky = k * sy;
+ cache = cacheStream = null;
+ return projection2;
+ }
+ function projection2(p) {
+ var x = p[0] * kx, y = p[1] * ky;
+ if (alpha) {
+ var t = y * ca - x * sa;
+ x = x * ca + y * sa;
+ y = t;
+ }
+ return [x + tx, y + ty];
+ }
+ projection2.invert = function(p) {
+ var x = p[0] - tx, y = p[1] - ty;
+ if (alpha) {
+ var t = y * ca + x * sa;
+ x = x * ca - y * sa;
+ y = t;
+ }
+ return [x / kx, y / ky];
+ };
+ projection2.stream = function(stream) {
+ return cache && cacheStream === stream ? cache : cache = transform2(postclip(cacheStream = stream));
+ };
+ projection2.postclip = function(_) {
+ return arguments.length ? (postclip = _, x02 = y02 = x12 = y12 = null, reset()) : postclip;
+ };
+ projection2.clipExtent = function(_) {
+ return arguments.length ? (postclip = _ == null ? (x02 = y02 = x12 = y12 = null, identity2) : clipRectangle(x02 = +_[0][0], y02 = +_[0][1], x12 = +_[1][0], y12 = +_[1][1]), reset()) : x02 == null ? null : [[x02, y02], [x12, y12]];
+ };
+ projection2.scale = function(_) {
+ return arguments.length ? (k = +_, reset()) : k;
+ };
+ projection2.translate = function(_) {
+ return arguments.length ? (tx = +_[0], ty = +_[1], reset()) : [tx, ty];
+ };
+ projection2.angle = function(_) {
+ return arguments.length ? (alpha = _ % 360 * radians2, sa = sin(alpha), ca = cos(alpha), reset()) : alpha * degrees3;
+ };
+ projection2.reflectX = function(_) {
+ return arguments.length ? (sx = _ ? -1 : 1, reset()) : sx < 0;
+ };
+ projection2.reflectY = function(_) {
+ return arguments.length ? (sy = _ ? -1 : 1, reset()) : sy < 0;
+ };
+ projection2.fitExtent = function(extent2, object2) {
+ return fitExtent(projection2, extent2, object2);
+ };
+ projection2.fitSize = function(size, object2) {
+ return fitSize(projection2, size, object2);
+ };
+ projection2.fitWidth = function(width, object2) {
+ return fitWidth(projection2, width, object2);
+ };
+ projection2.fitHeight = function(height, object2) {
+ return fitHeight(projection2, height, object2);
+ };
+ return projection2;
+ }
+ function naturalEarth1Raw(lambda, phi) {
+ var phi2 = phi * phi, phi4 = phi2 * phi2;
+ return [
+ lambda * (0.8707 - 0.131979 * phi2 + phi4 * (-0.013791 + phi4 * (3971e-6 * phi2 - 1529e-6 * phi4))),
+ phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 5916e-6 * phi4)))
+ ];
+ }
+ naturalEarth1Raw.invert = function(x, y) {
+ var phi = y, i = 25, delta;
+ do {
+ var phi2 = phi * phi, phi4 = phi2 * phi2;
+ phi -= delta = (phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 5916e-6 * phi4))) - y) / (1.007226 + phi2 * (0.015085 * 3 + phi4 * (-0.044475 * 7 + 0.028874 * 9 * phi2 - 5916e-6 * 11 * phi4)));
+ } while (abs(delta) > epsilon && --i > 0);
+ return [
+ x / (0.8707 + (phi2 = phi * phi) * (-0.131979 + phi2 * (-0.013791 + phi2 * phi2 * phi2 * (3971e-6 - 1529e-6 * phi2)))),
+ phi
+ ];
+ };
+ function naturalEarth1() {
+ return projection(naturalEarth1Raw).scale(175.295);
+ }
+ function orthographicRaw(x, y) {
+ return [cos(y) * sin(x), sin(y)];
+ }
+ orthographicRaw.invert = azimuthalInvert(asin);
+ function orthographic() {
+ return projection(orthographicRaw).scale(249.5).clipAngle(90 + epsilon);
+ }
+ function stereographicRaw(x, y) {
+ var cy = cos(y), k = 1 + cos(x) * cy;
+ return [cy * sin(x) / k, sin(y) / k];
+ }
+ stereographicRaw.invert = azimuthalInvert(function(z) {
+ return 2 * atan(z);
+ });
+ function stereographic() {
+ return projection(stereographicRaw).scale(250).clipAngle(142);
+ }
+ function transverseMercatorRaw(lambda, phi) {
+ return [log(tan((halfPi + phi) / 2)), -lambda];
+ }
+ transverseMercatorRaw.invert = function(x, y) {
+ return [-y, 2 * atan(exp(x)) - halfPi];
+ };
+ function transverseMercator() {
+ var m = mercatorProjection(transverseMercatorRaw), center = m.center, rotate = m.rotate;
+ m.center = function(_) {
+ return arguments.length ? center([-_[1], _[0]]) : (_ = center(), [_[1], -_[0]]);
+ };
+ m.rotate = function(_) {
+ return arguments.length ? rotate([_[0], _[1], _.length > 2 ? _[2] + 90 : 90]) : (_ = rotate(), [_[0], _[1], _[2] - 90]);
+ };
+ return rotate([0, 0, 90]).scale(159.155);
+ }
+ exports2.geoAlbers = albers;
+ exports2.geoAlbersUsa = albersUsa;
+ exports2.geoArea = area;
+ exports2.geoAzimuthalEqualArea = azimuthalEqualArea;
+ exports2.geoAzimuthalEqualAreaRaw = azimuthalEqualAreaRaw;
+ exports2.geoAzimuthalEquidistant = azimuthalEquidistant;
+ exports2.geoAzimuthalEquidistantRaw = azimuthalEquidistantRaw;
+ exports2.geoBounds = bounds;
+ exports2.geoCentroid = centroid;
+ exports2.geoCircle = circle;
+ exports2.geoClipAntimeridian = clipAntimeridian;
+ exports2.geoClipCircle = clipCircle;
+ exports2.geoClipExtent = extent;
+ exports2.geoClipRectangle = clipRectangle;
+ exports2.geoConicConformal = conicConformal;
+ exports2.geoConicConformalRaw = conicConformalRaw;
+ exports2.geoConicEqualArea = conicEqualArea;
+ exports2.geoConicEqualAreaRaw = conicEqualAreaRaw;
+ exports2.geoConicEquidistant = conicEquidistant;
+ exports2.geoConicEquidistantRaw = conicEquidistantRaw;
+ exports2.geoContains = contains;
+ exports2.geoDistance = distance;
+ exports2.geoEqualEarth = equalEarth;
+ exports2.geoEqualEarthRaw = equalEarthRaw;
+ exports2.geoEquirectangular = equirectangular;
+ exports2.geoEquirectangularRaw = equirectangularRaw;
+ exports2.geoGnomonic = gnomonic;
+ exports2.geoGnomonicRaw = gnomonicRaw;
+ exports2.geoGraticule = graticule;
+ exports2.geoGraticule10 = graticule10;
+ exports2.geoIdentity = identity$1;
+ exports2.geoInterpolate = interpolate;
+ exports2.geoLength = length;
+ exports2.geoMercator = mercator;
+ exports2.geoMercatorRaw = mercatorRaw;
+ exports2.geoNaturalEarth1 = naturalEarth1;
+ exports2.geoNaturalEarth1Raw = naturalEarth1Raw;
+ exports2.geoOrthographic = orthographic;
+ exports2.geoOrthographicRaw = orthographicRaw;
+ exports2.geoPath = index;
+ exports2.geoProjection = projection;
+ exports2.geoProjectionMutator = projectionMutator;
+ exports2.geoRotation = rotation;
+ exports2.geoStereographic = stereographic;
+ exports2.geoStereographicRaw = stereographicRaw;
+ exports2.geoStream = geoStream;
+ exports2.geoTransform = transform;
+ exports2.geoTransverseMercator = transverseMercator;
+ exports2.geoTransverseMercatorRaw = transverseMercatorRaw;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/d3-geo-projection/dist/d3-geo-projection.js
+ var require_d3_geo_projection = __commonJS({
+ "node_modules/d3-geo-projection/dist/d3-geo-projection.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_d3_geo(), require_d3_array()) : typeof define === "function" && false ? define(["exports", "d3-geo", "d3-array"], factory) : factory(global2.d3 = global2.d3 || {}, global2.d3, global2.d3);
+ })(exports, function(exports2, d3Geo, d3Array) {
+ "use strict";
+ var abs = Math.abs;
+ var atan = Math.atan;
+ var atan2 = Math.atan2;
+ var cos = Math.cos;
+ var exp = Math.exp;
+ var floor = Math.floor;
+ var log = Math.log;
+ var max = Math.max;
+ var min = Math.min;
+ var pow = Math.pow;
+ var round = Math.round;
+ var sign = Math.sign || function(x) {
+ return x > 0 ? 1 : x < 0 ? -1 : 0;
+ };
+ var sin = Math.sin;
+ var tan = Math.tan;
+ var epsilon = 1e-6;
+ var epsilon22 = 1e-12;
+ var pi = Math.PI;
+ var halfPi = pi / 2;
+ var quarterPi = pi / 4;
+ var sqrt1_2 = Math.SQRT1_2;
+ var sqrt2 = sqrt(2);
+ var sqrtPi = sqrt(pi);
+ var tau = pi * 2;
+ var degrees3 = 180 / pi;
+ var radians2 = pi / 180;
+ function sinci(x) {
+ return x ? x / Math.sin(x) : 1;
+ }
+ function asin(x) {
+ return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x);
+ }
+ function acos(x) {
+ return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
+ }
+ function sqrt(x) {
+ return x > 0 ? Math.sqrt(x) : 0;
+ }
+ function tanh2(x) {
+ x = exp(2 * x);
+ return (x - 1) / (x + 1);
+ }
+ function sinh2(x) {
+ return (exp(x) - exp(-x)) / 2;
+ }
+ function cosh2(x) {
+ return (exp(x) + exp(-x)) / 2;
+ }
+ function arsinh(x) {
+ return log(x + sqrt(x * x + 1));
+ }
+ function arcosh(x) {
+ return log(x + sqrt(x * x - 1));
+ }
+ function airyRaw(beta) {
+ var tanBeta_2 = tan(beta / 2), b = 2 * log(cos(beta / 2)) / (tanBeta_2 * tanBeta_2);
+ function forward(x, y) {
+ var cosx = cos(x), cosy = cos(y), siny = sin(y), cosz = cosy * cosx, k2 = -((1 - cosz ? log((1 + cosz) / 2) / (1 - cosz) : -0.5) + b / (1 + cosz));
+ return [k2 * cosy * sin(x), k2 * siny];
+ }
+ forward.invert = function(x, y) {
+ var r = sqrt(x * x + y * y), z = -beta / 2, i = 50, delta;
+ if (!r) return [0, 0];
+ do {
+ var z_2 = z / 2, cosz_2 = cos(z_2), sinz_2 = sin(z_2), tanz_2 = sinz_2 / cosz_2, lnsecz_2 = -log(abs(cosz_2));
+ z -= delta = (2 / tanz_2 * lnsecz_2 - b * tanz_2 - r) / (-lnsecz_2 / (sinz_2 * sinz_2) + 1 - b / (2 * cosz_2 * cosz_2)) * (cosz_2 < 0 ? 0.7 : 1);
+ } while (abs(delta) > epsilon && --i > 0);
+ var sinz = sin(z);
+ return [atan2(x * sinz, r * cos(z)), asin(y * sinz / r)];
+ };
+ return forward;
+ }
+ function airy() {
+ var beta = halfPi, m = d3Geo.geoProjectionMutator(airyRaw), p = m(beta);
+ p.radius = function(_) {
+ return arguments.length ? m(beta = _ * radians2) : beta * degrees3;
+ };
+ return p.scale(179.976).clipAngle(147);
+ }
+ function aitoffRaw(x, y) {
+ var cosy = cos(y), sincia = sinci(acos(cosy * cos(x /= 2)));
+ return [2 * cosy * sin(x) * sincia, sin(y) * sincia];
+ }
+ aitoffRaw.invert = function(x, y) {
+ if (x * x + 4 * y * y > pi * pi + epsilon) return;
+ var x12 = x, y12 = y, i = 25;
+ do {
+ var sinx = sin(x12), sinx_2 = sin(x12 / 2), cosx_2 = cos(x12 / 2), siny = sin(y12), cosy = cos(y12), sin_2y = sin(2 * y12), sin2y = siny * siny, cos2y = cosy * cosy, sin2x_2 = sinx_2 * sinx_2, c = 1 - cos2y * cosx_2 * cosx_2, e = c ? acos(cosy * cosx_2) * sqrt(f = 1 / c) : f = 0, f, fx = 2 * e * cosy * sinx_2 - x, fy = e * siny - y, dxdx = f * (cos2y * sin2x_2 + e * cosy * cosx_2 * sin2y), dxdy = f * (0.5 * sinx * sin_2y - e * 2 * siny * sinx_2), dydx = f * 0.25 * (sin_2y * sinx_2 - e * siny * cos2y * sinx), dydy = f * (sin2y * cosx_2 + e * sin2x_2 * cosy), z = dxdy * dydx - dydy * dxdx;
+ if (!z) break;
+ var dx = (fy * dxdy - fx * dydy) / z, dy = (fx * dydx - fy * dxdx) / z;
+ x12 -= dx, y12 -= dy;
+ } while ((abs(dx) > epsilon || abs(dy) > epsilon) && --i > 0);
+ return [x12, y12];
+ };
+ function aitoff() {
+ return d3Geo.geoProjection(aitoffRaw).scale(152.63);
+ }
+ function armadilloRaw(phi02) {
+ var sinPhi0 = sin(phi02), cosPhi0 = cos(phi02), sPhi0 = phi02 >= 0 ? 1 : -1, tanPhi0 = tan(sPhi0 * phi02), k2 = (1 + sinPhi0 - cosPhi0) / 2;
+ function forward(lambda, phi) {
+ var cosPhi = cos(phi), cosLambda = cos(lambda /= 2);
+ return [
+ (1 + cosPhi) * sin(lambda),
+ (sPhi0 * phi > -atan2(cosLambda, tanPhi0) - 1e-3 ? 0 : -sPhi0 * 10) + k2 + sin(phi) * cosPhi0 - (1 + cosPhi) * sinPhi0 * cosLambda
+ // TODO D3 core should allow null or [NaN, NaN] to be returned.
+ ];
+ }
+ forward.invert = function(x, y) {
+ var lambda = 0, phi = 0, i = 50;
+ do {
+ var cosLambda = cos(lambda), sinLambda = sin(lambda), cosPhi = cos(phi), sinPhi = sin(phi), A3 = 1 + cosPhi, fx = A3 * sinLambda - x, fy = k2 + sinPhi * cosPhi0 - A3 * sinPhi0 * cosLambda - y, dxdLambda = A3 * cosLambda / 2, dxdPhi = -sinLambda * sinPhi, dydLambda = sinPhi0 * A3 * sinLambda / 2, dydPhi = cosPhi0 * cosPhi + sinPhi0 * cosLambda * sinPhi, denominator = dxdPhi * dydLambda - dydPhi * dxdLambda, dLambda = (fy * dxdPhi - fx * dydPhi) / denominator / 2, dPhi = (fx * dydLambda - fy * dxdLambda) / denominator;
+ if (abs(dPhi) > 2) dPhi /= 2;
+ lambda -= dLambda, phi -= dPhi;
+ } while ((abs(dLambda) > epsilon || abs(dPhi) > epsilon) && --i > 0);
+ return sPhi0 * phi > -atan2(cos(lambda), tanPhi0) - 1e-3 ? [lambda * 2, phi] : null;
+ };
+ return forward;
+ }
+ function armadillo() {
+ var phi02 = 20 * radians2, sPhi0 = phi02 >= 0 ? 1 : -1, tanPhi0 = tan(sPhi0 * phi02), m = d3Geo.geoProjectionMutator(armadilloRaw), p = m(phi02), stream_ = p.stream;
+ p.parallel = function(_) {
+ if (!arguments.length) return phi02 * degrees3;
+ tanPhi0 = tan((sPhi0 = (phi02 = _ * radians2) >= 0 ? 1 : -1) * phi02);
+ return m(phi02);
+ };
+ p.stream = function(stream) {
+ var rotate = p.rotate(), rotateStream = stream_(stream), sphereStream = (p.rotate([0, 0]), stream_(stream)), precision = p.precision();
+ p.rotate(rotate);
+ rotateStream.sphere = function() {
+ sphereStream.polygonStart(), sphereStream.lineStart();
+ for (var lambda = sPhi0 * -180; sPhi0 * lambda < 180; lambda += sPhi0 * 90)
+ sphereStream.point(lambda, sPhi0 * 90);
+ if (phi02) while (sPhi0 * (lambda -= 3 * sPhi0 * precision) >= -180) {
+ sphereStream.point(lambda, sPhi0 * -atan2(cos(lambda * radians2 / 2), tanPhi0) * degrees3);
+ }
+ sphereStream.lineEnd(), sphereStream.polygonEnd();
+ };
+ return rotateStream;
+ };
+ return p.scale(218.695).center([0, 28.0974]);
+ }
+ function augustRaw(lambda, phi) {
+ var tanPhi = tan(phi / 2), k2 = sqrt(1 - tanPhi * tanPhi), c = 1 + k2 * cos(lambda /= 2), x = sin(lambda) * k2 / c, y = tanPhi / c, x2 = x * x, y2 = y * y;
+ return [
+ 4 / 3 * x * (3 + x2 - 3 * y2),
+ 4 / 3 * y * (3 + 3 * x2 - y2)
+ ];
+ }
+ augustRaw.invert = function(x, y) {
+ x *= 3 / 8, y *= 3 / 8;
+ if (!x && abs(y) > 1) return null;
+ var x2 = x * x, y2 = y * y, s = 1 + x2 + y2, sin3Eta = sqrt((s - sqrt(s * s - 4 * y * y)) / 2), eta = asin(sin3Eta) / 3, xi = sin3Eta ? arcosh(abs(y / sin3Eta)) / 3 : arsinh(abs(x)) / 3, cosEta = cos(eta), coshXi = cosh2(xi), d = coshXi * coshXi - cosEta * cosEta;
+ return [
+ sign(x) * 2 * atan2(sinh2(xi) * cosEta, 0.25 - d),
+ sign(y) * 2 * atan2(coshXi * sin(eta), 0.25 + d)
+ ];
+ };
+ function august() {
+ return d3Geo.geoProjection(augustRaw).scale(66.1603);
+ }
+ var sqrt8 = sqrt(8), phi0 = log(1 + sqrt2);
+ function bakerRaw(lambda, phi) {
+ var phi02 = abs(phi);
+ return phi02 < quarterPi ? [lambda, log(tan(quarterPi + phi / 2))] : [lambda * cos(phi02) * (2 * sqrt2 - 1 / sin(phi02)), sign(phi) * (2 * sqrt2 * (phi02 - quarterPi) - log(tan(phi02 / 2)))];
+ }
+ bakerRaw.invert = function(x, y) {
+ if ((y02 = abs(y)) < phi0) return [x, 2 * atan(exp(y)) - halfPi];
+ var phi = quarterPi, i = 25, delta, y02;
+ do {
+ var cosPhi_2 = cos(phi / 2), tanPhi_2 = tan(phi / 2);
+ phi -= delta = (sqrt8 * (phi - quarterPi) - log(tanPhi_2) - y02) / (sqrt8 - cosPhi_2 * cosPhi_2 / (2 * tanPhi_2));
+ } while (abs(delta) > epsilon22 && --i > 0);
+ return [x / (cos(phi) * (sqrt8 - 1 / sin(phi))), sign(y) * phi];
+ };
+ function baker() {
+ return d3Geo.geoProjection(bakerRaw).scale(112.314);
+ }
+ function berghausRaw(lobes2) {
+ var k2 = 2 * pi / lobes2;
+ function forward(lambda, phi) {
+ var p = d3Geo.geoAzimuthalEquidistantRaw(lambda, phi);
+ if (abs(lambda) > halfPi) {
+ var theta = atan2(p[1], p[0]), r = sqrt(p[0] * p[0] + p[1] * p[1]), theta0 = k2 * round((theta - halfPi) / k2) + halfPi, alpha = atan2(sin(theta -= theta0), 2 - cos(theta));
+ theta = theta0 + asin(pi / r * sin(alpha)) - alpha;
+ p[0] = r * cos(theta);
+ p[1] = r * sin(theta);
+ }
+ return p;
+ }
+ forward.invert = function(x, y) {
+ var r = sqrt(x * x + y * y);
+ if (r > halfPi) {
+ var theta = atan2(y, x), theta0 = k2 * round((theta - halfPi) / k2) + halfPi, s = theta > theta0 ? -1 : 1, A3 = r * cos(theta0 - theta), cotAlpha = 1 / tan(s * acos((A3 - pi) / sqrt(pi * (pi - 2 * A3) + r * r)));
+ theta = theta0 + 2 * atan((cotAlpha + s * sqrt(cotAlpha * cotAlpha - 3)) / 3);
+ x = r * cos(theta), y = r * sin(theta);
+ }
+ return d3Geo.geoAzimuthalEquidistantRaw.invert(x, y);
+ };
+ return forward;
+ }
+ function berghaus() {
+ var lobes2 = 5, m = d3Geo.geoProjectionMutator(berghausRaw), p = m(lobes2), projectionStream = p.stream, epsilon$$1 = 0.01, cr = -cos(epsilon$$1 * radians2), sr = sin(epsilon$$1 * radians2);
+ p.lobes = function(_) {
+ return arguments.length ? m(lobes2 = +_) : lobes2;
+ };
+ p.stream = function(stream) {
+ var rotate = p.rotate(), rotateStream = projectionStream(stream), sphereStream = (p.rotate([0, 0]), projectionStream(stream));
+ p.rotate(rotate);
+ rotateStream.sphere = function() {
+ sphereStream.polygonStart(), sphereStream.lineStart();
+ for (var i = 0, delta = 360 / lobes2, delta0 = 2 * pi / lobes2, phi = 90 - 180 / lobes2, phi02 = halfPi; i < lobes2; ++i, phi -= delta, phi02 -= delta0) {
+ sphereStream.point(atan2(sr * cos(phi02), cr) * degrees3, asin(sr * sin(phi02)) * degrees3);
+ if (phi < -90) {
+ sphereStream.point(-90, -180 - phi - epsilon$$1);
+ sphereStream.point(-90, -180 - phi + epsilon$$1);
+ } else {
+ sphereStream.point(90, phi + epsilon$$1);
+ sphereStream.point(90, phi - epsilon$$1);
+ }
+ }
+ sphereStream.lineEnd(), sphereStream.polygonEnd();
+ };
+ return rotateStream;
+ };
+ return p.scale(87.8076).center([0, 17.1875]).clipAngle(180 - 1e-3);
+ }
+ function hammerRaw(A3, B3) {
+ if (arguments.length < 2) B3 = A3;
+ if (B3 === 1) return d3Geo.geoAzimuthalEqualAreaRaw;
+ if (B3 === Infinity) return hammerQuarticAuthalicRaw;
+ function forward(lambda, phi) {
+ var coordinates = d3Geo.geoAzimuthalEqualAreaRaw(lambda / B3, phi);
+ coordinates[0] *= A3;
+ return coordinates;
+ }
+ forward.invert = function(x, y) {
+ var coordinates = d3Geo.geoAzimuthalEqualAreaRaw.invert(x / A3, y);
+ coordinates[0] *= B3;
+ return coordinates;
+ };
+ return forward;
+ }
+ function hammerQuarticAuthalicRaw(lambda, phi) {
+ return [
+ lambda * cos(phi) / cos(phi /= 2),
+ 2 * sin(phi)
+ ];
+ }
+ hammerQuarticAuthalicRaw.invert = function(x, y) {
+ var phi = 2 * asin(y / 2);
+ return [
+ x * cos(phi / 2) / cos(phi),
+ phi
+ ];
+ };
+ function hammer() {
+ var B3 = 2, m = d3Geo.geoProjectionMutator(hammerRaw), p = m(B3);
+ p.coefficient = function(_) {
+ if (!arguments.length) return B3;
+ return m(B3 = +_);
+ };
+ return p.scale(169.529);
+ }
+ function solve(f, y, x) {
+ var steps = 100, delta, f0, f1;
+ x = x === void 0 ? 0 : +x;
+ y = +y;
+ do {
+ f0 = f(x);
+ f1 = f(x + epsilon);
+ if (f0 === f1) f1 = f0 + epsilon;
+ x -= delta = -1 * epsilon * (f0 - y) / (f0 - f1);
+ } while (steps-- > 0 && abs(delta) > epsilon);
+ return steps < 0 ? NaN : x;
+ }
+ function solve2d(f, MAX_ITERATIONS, eps) {
+ if (MAX_ITERATIONS === void 0) MAX_ITERATIONS = 40;
+ if (eps === void 0) eps = epsilon22;
+ return function(x, y, a, b) {
+ var err2, da, db;
+ a = a === void 0 ? 0 : +a;
+ b = b === void 0 ? 0 : +b;
+ for (var i = 0; i < MAX_ITERATIONS; i++) {
+ var p = f(a, b), tx = p[0] - x, ty = p[1] - y;
+ if (abs(tx) < eps && abs(ty) < eps) break;
+ var h = tx * tx + ty * ty;
+ if (h > err2) {
+ a -= da /= 2;
+ b -= db /= 2;
+ continue;
+ }
+ err2 = h;
+ var ea = (a > 0 ? -1 : 1) * eps, eb = (b > 0 ? -1 : 1) * eps, pa = f(a + ea, b), pb = f(a, b + eb), dxa = (pa[0] - p[0]) / ea, dya = (pa[1] - p[1]) / ea, dxb = (pb[0] - p[0]) / eb, dyb = (pb[1] - p[1]) / eb, D2 = dyb * dxa - dya * dxb, l = (abs(D2) < 0.5 ? 0.5 : 1) / D2;
+ da = (ty * dxb - tx * dyb) * l;
+ db = (tx * dya - ty * dxa) * l;
+ a += da;
+ b += db;
+ if (abs(da) < eps && abs(db) < eps) break;
+ }
+ return [a, b];
+ };
+ }
+ function bertin1953Raw() {
+ var hammer$$1 = hammerRaw(1.68, 2), fu = 1.4, k2 = 12;
+ function forward(lambda, phi) {
+ if (lambda + phi < -fu) {
+ var u = (lambda - phi + 1.6) * (lambda + phi + fu) / 8;
+ lambda += u;
+ phi -= 0.8 * u * sin(phi + pi / 2);
+ }
+ var r = hammer$$1(lambda, phi);
+ var d = (1 - cos(lambda * phi)) / k2;
+ if (r[1] < 0) {
+ r[0] *= 1 + d;
+ }
+ if (r[1] > 0) {
+ r[1] *= 1 + d / 1.5 * r[0] * r[0];
+ }
+ return r;
+ }
+ forward.invert = solve2d(forward);
+ return forward;
+ }
+ function bertin() {
+ return d3Geo.geoProjection(bertin1953Raw()).rotate([-16.5, -42]).scale(176.57).center([7.93, 0.09]);
+ }
+ function mollweideBromleyTheta(cp, phi) {
+ var cpsinPhi = cp * sin(phi), i = 30, delta;
+ do
+ phi -= delta = (phi + sin(phi) - cpsinPhi) / (1 + cos(phi));
+ while (abs(delta) > epsilon && --i > 0);
+ return phi / 2;
+ }
+ function mollweideBromleyRaw(cx, cy, cp) {
+ function forward(lambda, phi) {
+ return [cx * lambda * cos(phi = mollweideBromleyTheta(cp, phi)), cy * sin(phi)];
+ }
+ forward.invert = function(x, y) {
+ return y = asin(y / cy), [x / (cx * cos(y)), asin((2 * y + sin(2 * y)) / cp)];
+ };
+ return forward;
+ }
+ var mollweideRaw = mollweideBromleyRaw(sqrt2 / halfPi, sqrt2, pi);
+ function mollweide() {
+ return d3Geo.geoProjection(mollweideRaw).scale(169.529);
+ }
+ var k = 2.00276, w = 1.11072;
+ function boggsRaw(lambda, phi) {
+ var theta = mollweideBromleyTheta(pi, phi);
+ return [k * lambda / (1 / cos(phi) + w / cos(theta)), (phi + sqrt2 * sin(theta)) / k];
+ }
+ boggsRaw.invert = function(x, y) {
+ var ky = k * y, theta = y < 0 ? -quarterPi : quarterPi, i = 25, delta, phi;
+ do {
+ phi = ky - sqrt2 * sin(theta);
+ theta -= delta = (sin(2 * theta) + 2 * theta - pi * sin(phi)) / (2 * cos(2 * theta) + 2 + pi * cos(phi) * sqrt2 * cos(theta));
+ } while (abs(delta) > epsilon && --i > 0);
+ phi = ky - sqrt2 * sin(theta);
+ return [x * (1 / cos(phi) + w / cos(theta)) / k, phi];
+ };
+ function boggs() {
+ return d3Geo.geoProjection(boggsRaw).scale(160.857);
+ }
+ function parallel1(projectAt) {
+ var phi02 = 0, m = d3Geo.geoProjectionMutator(projectAt), p = m(phi02);
+ p.parallel = function(_) {
+ return arguments.length ? m(phi02 = _ * radians2) : phi02 * degrees3;
+ };
+ return p;
+ }
+ function sinusoidalRaw(lambda, phi) {
+ return [lambda * cos(phi), phi];
+ }
+ sinusoidalRaw.invert = function(x, y) {
+ return [x / cos(y), y];
+ };
+ function sinusoidal() {
+ return d3Geo.geoProjection(sinusoidalRaw).scale(152.63);
+ }
+ function bonneRaw(phi02) {
+ if (!phi02) return sinusoidalRaw;
+ var cotPhi0 = 1 / tan(phi02);
+ function forward(lambda, phi) {
+ var rho = cotPhi0 + phi02 - phi, e = rho ? lambda * cos(phi) / rho : rho;
+ return [rho * sin(e), cotPhi0 - rho * cos(e)];
+ }
+ forward.invert = function(x, y) {
+ var rho = sqrt(x * x + (y = cotPhi0 - y) * y), phi = cotPhi0 + phi02 - rho;
+ return [rho / cos(phi) * atan2(x, y), phi];
+ };
+ return forward;
+ }
+ function bonne() {
+ return parallel1(bonneRaw).scale(123.082).center([0, 26.1441]).parallel(45);
+ }
+ function bottomleyRaw(sinPsi) {
+ function forward(lambda, phi) {
+ var rho = halfPi - phi, eta = rho ? lambda * sinPsi * sin(rho) / rho : rho;
+ return [rho * sin(eta) / sinPsi, halfPi - rho * cos(eta)];
+ }
+ forward.invert = function(x, y) {
+ var x12 = x * sinPsi, y12 = halfPi - y, rho = sqrt(x12 * x12 + y12 * y12), eta = atan2(x12, y12);
+ return [(rho ? rho / sin(rho) : 1) * eta / sinPsi, halfPi - rho];
+ };
+ return forward;
+ }
+ function bottomley() {
+ var sinPsi = 0.5, m = d3Geo.geoProjectionMutator(bottomleyRaw), p = m(sinPsi);
+ p.fraction = function(_) {
+ return arguments.length ? m(sinPsi = +_) : sinPsi;
+ };
+ return p.scale(158.837);
+ }
+ var bromleyRaw = mollweideBromleyRaw(1, 4 / pi, pi);
+ function bromley() {
+ return d3Geo.geoProjection(bromleyRaw).scale(152.63);
+ }
+ function distance(dPhi, c1, s1, c2, s2, dLambda) {
+ var cosdLambda = cos(dLambda), r;
+ if (abs(dPhi) > 1 || abs(dLambda) > 1) {
+ r = acos(s1 * s2 + c1 * c2 * cosdLambda);
+ } else {
+ var sindPhi = sin(dPhi / 2), sindLambda = sin(dLambda / 2);
+ r = 2 * asin(sqrt(sindPhi * sindPhi + c1 * c2 * sindLambda * sindLambda));
+ }
+ return abs(r) > epsilon ? [r, atan2(c2 * sin(dLambda), c1 * s2 - s1 * c2 * cosdLambda)] : [0, 0];
+ }
+ function angle(b, c, a) {
+ return acos((b * b + c * c - a * a) / (2 * b * c));
+ }
+ function longitude(lambda) {
+ return lambda - 2 * pi * floor((lambda + pi) / (2 * pi));
+ }
+ function chamberlinRaw(p0, p1, p2) {
+ var points2 = [
+ [p0[0], p0[1], sin(p0[1]), cos(p0[1])],
+ [p1[0], p1[1], sin(p1[1]), cos(p1[1])],
+ [p2[0], p2[1], sin(p2[1]), cos(p2[1])]
+ ];
+ for (var a = points2[2], b, i = 0; i < 3; ++i, a = b) {
+ b = points2[i];
+ a.v = distance(b[1] - a[1], a[3], a[2], b[3], b[2], b[0] - a[0]);
+ a.point = [0, 0];
+ }
+ var beta0 = angle(points2[0].v[0], points2[2].v[0], points2[1].v[0]), beta1 = angle(points2[0].v[0], points2[1].v[0], points2[2].v[0]), beta2 = pi - beta0;
+ points2[2].point[1] = 0;
+ points2[0].point[0] = -(points2[1].point[0] = points2[0].v[0] / 2);
+ var mean = [
+ points2[2].point[0] = points2[0].point[0] + points2[2].v[0] * cos(beta0),
+ 2 * (points2[0].point[1] = points2[1].point[1] = points2[2].v[0] * sin(beta0))
+ ];
+ function forward(lambda, phi) {
+ var sinPhi = sin(phi), cosPhi = cos(phi), v = new Array(3), i2;
+ for (i2 = 0; i2 < 3; ++i2) {
+ var p = points2[i2];
+ v[i2] = distance(phi - p[1], p[3], p[2], cosPhi, sinPhi, lambda - p[0]);
+ if (!v[i2][0]) return p.point;
+ v[i2][1] = longitude(v[i2][1] - p.v[1]);
+ }
+ var point = mean.slice();
+ for (i2 = 0; i2 < 3; ++i2) {
+ var j = i2 == 2 ? 0 : i2 + 1;
+ var a2 = angle(points2[i2].v[0], v[i2][0], v[j][0]);
+ if (v[i2][1] < 0) a2 = -a2;
+ if (!i2) {
+ point[0] += v[i2][0] * cos(a2);
+ point[1] -= v[i2][0] * sin(a2);
+ } else if (i2 == 1) {
+ a2 = beta1 - a2;
+ point[0] -= v[i2][0] * cos(a2);
+ point[1] -= v[i2][0] * sin(a2);
+ } else {
+ a2 = beta2 - a2;
+ point[0] += v[i2][0] * cos(a2);
+ point[1] += v[i2][0] * sin(a2);
+ }
+ }
+ point[0] /= 3, point[1] /= 3;
+ return point;
+ }
+ return forward;
+ }
+ function pointRadians(p) {
+ return p[0] *= radians2, p[1] *= radians2, p;
+ }
+ function chamberlinAfrica() {
+ return chamberlin([0, 22], [45, 22], [22.5, -22]).scale(380).center([22.5, 2]);
+ }
+ function chamberlin(p0, p1, p2) {
+ var c = d3Geo.geoCentroid({ type: "MultiPoint", coordinates: [p0, p1, p2] }), R = [-c[0], -c[1]], r = d3Geo.geoRotation(R), f = chamberlinRaw(pointRadians(r(p0)), pointRadians(r(p1)), pointRadians(r(p2)));
+ f.invert = solve2d(f);
+ var p = d3Geo.geoProjection(f).rotate(R), center = p.center;
+ delete p.rotate;
+ p.center = function(_) {
+ return arguments.length ? center(r(_)) : r.invert(center());
+ };
+ return p.clipAngle(90);
+ }
+ function collignonRaw(lambda, phi) {
+ var alpha = sqrt(1 - sin(phi));
+ return [2 / sqrtPi * lambda * alpha, sqrtPi * (1 - alpha)];
+ }
+ collignonRaw.invert = function(x, y) {
+ var lambda = (lambda = y / sqrtPi - 1) * lambda;
+ return [lambda > 0 ? x * sqrt(pi / lambda) / 2 : 0, asin(1 - lambda)];
+ };
+ function collignon() {
+ return d3Geo.geoProjection(collignonRaw).scale(95.6464).center([0, 30]);
+ }
+ function craigRaw(phi02) {
+ var tanPhi0 = tan(phi02);
+ function forward(lambda, phi) {
+ return [lambda, (lambda ? lambda / sin(lambda) : 1) * (sin(phi) * cos(lambda) - tanPhi0 * cos(phi))];
+ }
+ forward.invert = tanPhi0 ? function(x, y) {
+ if (x) y *= sin(x) / x;
+ var cosLambda = cos(x);
+ return [x, 2 * atan2(sqrt(cosLambda * cosLambda + tanPhi0 * tanPhi0 - y * y) - cosLambda, tanPhi0 - y)];
+ } : function(x, y) {
+ return [x, asin(x ? y * tan(x) / x : y)];
+ };
+ return forward;
+ }
+ function craig() {
+ return parallel1(craigRaw).scale(249.828).clipAngle(90);
+ }
+ var sqrt3 = sqrt(3);
+ function crasterRaw(lambda, phi) {
+ return [sqrt3 * lambda * (2 * cos(2 * phi / 3) - 1) / sqrtPi, sqrt3 * sqrtPi * sin(phi / 3)];
+ }
+ crasterRaw.invert = function(x, y) {
+ var phi = 3 * asin(y / (sqrt3 * sqrtPi));
+ return [sqrtPi * x / (sqrt3 * (2 * cos(2 * phi / 3) - 1)), phi];
+ };
+ function craster() {
+ return d3Geo.geoProjection(crasterRaw).scale(156.19);
+ }
+ function cylindricalEqualAreaRaw(phi02) {
+ var cosPhi0 = cos(phi02);
+ function forward(lambda, phi) {
+ return [lambda * cosPhi0, sin(phi) / cosPhi0];
+ }
+ forward.invert = function(x, y) {
+ return [x / cosPhi0, asin(y * cosPhi0)];
+ };
+ return forward;
+ }
+ function cylindricalEqualArea() {
+ return parallel1(cylindricalEqualAreaRaw).parallel(38.58).scale(195.044);
+ }
+ function cylindricalStereographicRaw(phi02) {
+ var cosPhi0 = cos(phi02);
+ function forward(lambda, phi) {
+ return [lambda * cosPhi0, (1 + cosPhi0) * tan(phi / 2)];
+ }
+ forward.invert = function(x, y) {
+ return [x / cosPhi0, atan(y / (1 + cosPhi0)) * 2];
+ };
+ return forward;
+ }
+ function cylindricalStereographic() {
+ return parallel1(cylindricalStereographicRaw).scale(124.75);
+ }
+ function eckert1Raw(lambda, phi) {
+ var alpha = sqrt(8 / (3 * pi));
+ return [
+ alpha * lambda * (1 - abs(phi) / pi),
+ alpha * phi
+ ];
+ }
+ eckert1Raw.invert = function(x, y) {
+ var alpha = sqrt(8 / (3 * pi)), phi = y / alpha;
+ return [
+ x / (alpha * (1 - abs(phi) / pi)),
+ phi
+ ];
+ };
+ function eckert1() {
+ return d3Geo.geoProjection(eckert1Raw).scale(165.664);
+ }
+ function eckert2Raw(lambda, phi) {
+ var alpha = sqrt(4 - 3 * sin(abs(phi)));
+ return [
+ 2 / sqrt(6 * pi) * lambda * alpha,
+ sign(phi) * sqrt(2 * pi / 3) * (2 - alpha)
+ ];
+ }
+ eckert2Raw.invert = function(x, y) {
+ var alpha = 2 - abs(y) / sqrt(2 * pi / 3);
+ return [
+ x * sqrt(6 * pi) / (2 * alpha),
+ sign(y) * asin((4 - alpha * alpha) / 3)
+ ];
+ };
+ function eckert2() {
+ return d3Geo.geoProjection(eckert2Raw).scale(165.664);
+ }
+ function eckert3Raw(lambda, phi) {
+ var k2 = sqrt(pi * (4 + pi));
+ return [
+ 2 / k2 * lambda * (1 + sqrt(1 - 4 * phi * phi / (pi * pi))),
+ 4 / k2 * phi
+ ];
+ }
+ eckert3Raw.invert = function(x, y) {
+ var k2 = sqrt(pi * (4 + pi)) / 2;
+ return [
+ x * k2 / (1 + sqrt(1 - y * y * (4 + pi) / (4 * pi))),
+ y * k2 / 2
+ ];
+ };
+ function eckert3() {
+ return d3Geo.geoProjection(eckert3Raw).scale(180.739);
+ }
+ function eckert4Raw(lambda, phi) {
+ var k2 = (2 + halfPi) * sin(phi);
+ phi /= 2;
+ for (var i = 0, delta = Infinity; i < 10 && abs(delta) > epsilon; i++) {
+ var cosPhi = cos(phi);
+ phi -= delta = (phi + sin(phi) * (cosPhi + 2) - k2) / (2 * cosPhi * (1 + cosPhi));
+ }
+ return [
+ 2 / sqrt(pi * (4 + pi)) * lambda * (1 + cos(phi)),
+ 2 * sqrt(pi / (4 + pi)) * sin(phi)
+ ];
+ }
+ eckert4Raw.invert = function(x, y) {
+ var A3 = y * sqrt((4 + pi) / pi) / 2, k2 = asin(A3), c = cos(k2);
+ return [
+ x / (2 / sqrt(pi * (4 + pi)) * (1 + c)),
+ asin((k2 + A3 * (c + 2)) / (2 + halfPi))
+ ];
+ };
+ function eckert4() {
+ return d3Geo.geoProjection(eckert4Raw).scale(180.739);
+ }
+ function eckert5Raw(lambda, phi) {
+ return [
+ lambda * (1 + cos(phi)) / sqrt(2 + pi),
+ 2 * phi / sqrt(2 + pi)
+ ];
+ }
+ eckert5Raw.invert = function(x, y) {
+ var k2 = sqrt(2 + pi), phi = y * k2 / 2;
+ return [
+ k2 * x / (1 + cos(phi)),
+ phi
+ ];
+ };
+ function eckert5() {
+ return d3Geo.geoProjection(eckert5Raw).scale(173.044);
+ }
+ function eckert6Raw(lambda, phi) {
+ var k2 = (1 + halfPi) * sin(phi);
+ for (var i = 0, delta = Infinity; i < 10 && abs(delta) > epsilon; i++) {
+ phi -= delta = (phi + sin(phi) - k2) / (1 + cos(phi));
+ }
+ k2 = sqrt(2 + pi);
+ return [
+ lambda * (1 + cos(phi)) / k2,
+ 2 * phi / k2
+ ];
+ }
+ eckert6Raw.invert = function(x, y) {
+ var j = 1 + halfPi, k2 = sqrt(j / 2);
+ return [
+ x * 2 * k2 / (1 + cos(y *= k2)),
+ asin((y + sin(y)) / j)
+ ];
+ };
+ function eckert6() {
+ return d3Geo.geoProjection(eckert6Raw).scale(173.044);
+ }
+ var eisenlohrK = 3 + 2 * sqrt2;
+ function eisenlohrRaw(lambda, phi) {
+ var s0 = sin(lambda /= 2), c0 = cos(lambda), k2 = sqrt(cos(phi)), c1 = cos(phi /= 2), t = sin(phi) / (c1 + sqrt2 * c0 * k2), c = sqrt(2 / (1 + t * t)), v = sqrt((sqrt2 * c1 + (c0 + s0) * k2) / (sqrt2 * c1 + (c0 - s0) * k2));
+ return [
+ eisenlohrK * (c * (v - 1 / v) - 2 * log(v)),
+ eisenlohrK * (c * t * (v + 1 / v) - 2 * atan(t))
+ ];
+ }
+ eisenlohrRaw.invert = function(x, y) {
+ if (!(p = augustRaw.invert(x / 1.2, y * 1.065))) return null;
+ var lambda = p[0], phi = p[1], i = 20, p;
+ x /= eisenlohrK, y /= eisenlohrK;
+ do {
+ var _0 = lambda / 2, _1 = phi / 2, s0 = sin(_0), c0 = cos(_0), s1 = sin(_1), c1 = cos(_1), cos1 = cos(phi), k2 = sqrt(cos1), t = s1 / (c1 + sqrt2 * c0 * k2), t22 = t * t, c = sqrt(2 / (1 + t22)), v0 = sqrt2 * c1 + (c0 + s0) * k2, v1 = sqrt2 * c1 + (c0 - s0) * k2, v2 = v0 / v1, v = sqrt(v2), vm1v = v - 1 / v, vp1v = v + 1 / v, fx = c * vm1v - 2 * log(v) - x, fy = c * t * vp1v - 2 * atan(t) - y, deltatDeltaLambda = s1 && sqrt1_2 * k2 * s0 * t22 / s1, deltatDeltaPhi = (sqrt2 * c0 * c1 + k2) / (2 * (c1 + sqrt2 * c0 * k2) * (c1 + sqrt2 * c0 * k2) * k2), deltacDeltat = -0.5 * t * c * c * c, deltacDeltaLambda = deltacDeltat * deltatDeltaLambda, deltacDeltaPhi = deltacDeltat * deltatDeltaPhi, A3 = (A3 = 2 * c1 + sqrt2 * k2 * (c0 - s0)) * A3 * v, deltavDeltaLambda = (sqrt2 * c0 * c1 * k2 + cos1) / A3, deltavDeltaPhi = -(sqrt2 * s0 * s1) / (k2 * A3), deltaxDeltaLambda = vm1v * deltacDeltaLambda - 2 * deltavDeltaLambda / v + c * (deltavDeltaLambda + deltavDeltaLambda / v2), deltaxDeltaPhi = vm1v * deltacDeltaPhi - 2 * deltavDeltaPhi / v + c * (deltavDeltaPhi + deltavDeltaPhi / v2), deltayDeltaLambda = t * vp1v * deltacDeltaLambda - 2 * deltatDeltaLambda / (1 + t22) + c * vp1v * deltatDeltaLambda + c * t * (deltavDeltaLambda - deltavDeltaLambda / v2), deltayDeltaPhi = t * vp1v * deltacDeltaPhi - 2 * deltatDeltaPhi / (1 + t22) + c * vp1v * deltatDeltaPhi + c * t * (deltavDeltaPhi - deltavDeltaPhi / v2), denominator = deltaxDeltaPhi * deltayDeltaLambda - deltayDeltaPhi * deltaxDeltaLambda;
+ if (!denominator) break;
+ var deltaLambda = (fy * deltaxDeltaPhi - fx * deltayDeltaPhi) / denominator, deltaPhi = (fx * deltayDeltaLambda - fy * deltaxDeltaLambda) / denominator;
+ lambda -= deltaLambda;
+ phi = max(-halfPi, min(halfPi, phi - deltaPhi));
+ } while ((abs(deltaLambda) > epsilon || abs(deltaPhi) > epsilon) && --i > 0);
+ return abs(abs(phi) - halfPi) < epsilon ? [0, phi] : i && [lambda, phi];
+ };
+ function eisenlohr() {
+ return d3Geo.geoProjection(eisenlohrRaw).scale(62.5271);
+ }
+ var faheyK = cos(35 * radians2);
+ function faheyRaw(lambda, phi) {
+ var t = tan(phi / 2);
+ return [lambda * faheyK * sqrt(1 - t * t), (1 + faheyK) * t];
+ }
+ faheyRaw.invert = function(x, y) {
+ var t = y / (1 + faheyK);
+ return [x && x / (faheyK * sqrt(1 - t * t)), 2 * atan(t)];
+ };
+ function fahey() {
+ return d3Geo.geoProjection(faheyRaw).scale(137.152);
+ }
+ function foucautRaw(lambda, phi) {
+ var k2 = phi / 2, cosk = cos(k2);
+ return [2 * lambda / sqrtPi * cos(phi) * cosk * cosk, sqrtPi * tan(k2)];
+ }
+ foucautRaw.invert = function(x, y) {
+ var k2 = atan(y / sqrtPi), cosk = cos(k2), phi = 2 * k2;
+ return [x * sqrtPi / 2 / (cos(phi) * cosk * cosk), phi];
+ };
+ function foucaut() {
+ return d3Geo.geoProjection(foucautRaw).scale(135.264);
+ }
+ function foucautSinusoidalRaw(alpha) {
+ var beta = 1 - alpha, equatorial = raw(pi, 0)[0] - raw(-pi, 0)[0], polar = raw(0, halfPi)[1] - raw(0, -halfPi)[1], ratio = sqrt(2 * polar / equatorial);
+ function raw(lambda, phi) {
+ var cosphi = cos(phi), sinphi = sin(phi);
+ return [
+ cosphi / (beta + alpha * cosphi) * lambda,
+ beta * phi + alpha * sinphi
+ ];
+ }
+ function forward(lambda, phi) {
+ var p = raw(lambda, phi);
+ return [p[0] * ratio, p[1] / ratio];
+ }
+ function forwardMeridian(phi) {
+ return forward(0, phi)[1];
+ }
+ forward.invert = function(x, y) {
+ var phi = solve(forwardMeridian, y), lambda = x / ratio * (alpha + beta / cos(phi));
+ return [lambda, phi];
+ };
+ return forward;
+ }
+ function foucautSinusoidal() {
+ var alpha = 0.5, m = d3Geo.geoProjectionMutator(foucautSinusoidalRaw), p = m(alpha);
+ p.alpha = function(_) {
+ return arguments.length ? m(alpha = +_) : alpha;
+ };
+ return p.scale(168.725);
+ }
+ function gilbertForward(point) {
+ return [point[0] / 2, asin(tan(point[1] / 2 * radians2)) * degrees3];
+ }
+ function gilbertInvert(point) {
+ return [point[0] * 2, 2 * atan(sin(point[1] * radians2)) * degrees3];
+ }
+ function gilbert(projectionType) {
+ if (projectionType == null) projectionType = d3Geo.geoOrthographic;
+ var projection = projectionType(), equirectangular = d3Geo.geoEquirectangular().scale(degrees3).precision(0).clipAngle(null).translate([0, 0]);
+ function gilbert2(point) {
+ return projection(gilbertForward(point));
+ }
+ if (projection.invert) gilbert2.invert = function(point) {
+ return gilbertInvert(projection.invert(point));
+ };
+ gilbert2.stream = function(stream) {
+ var s1 = projection.stream(stream), s0 = equirectangular.stream({
+ point: function(lambda, phi) {
+ s1.point(lambda / 2, asin(tan(-phi / 2 * radians2)) * degrees3);
+ },
+ lineStart: function() {
+ s1.lineStart();
+ },
+ lineEnd: function() {
+ s1.lineEnd();
+ },
+ polygonStart: function() {
+ s1.polygonStart();
+ },
+ polygonEnd: function() {
+ s1.polygonEnd();
+ }
+ });
+ s0.sphere = s1.sphere;
+ return s0;
+ };
+ function property(name2) {
+ gilbert2[name2] = function() {
+ return arguments.length ? (projection[name2].apply(projection, arguments), gilbert2) : projection[name2]();
+ };
+ }
+ gilbert2.rotate = function(_) {
+ return arguments.length ? (equirectangular.rotate(_), gilbert2) : equirectangular.rotate();
+ };
+ gilbert2.center = function(_) {
+ return arguments.length ? (projection.center(gilbertForward(_)), gilbert2) : gilbertInvert(projection.center());
+ };
+ property("angle");
+ property("clipAngle");
+ property("clipExtent");
+ property("fitExtent");
+ property("fitHeight");
+ property("fitSize");
+ property("fitWidth");
+ property("scale");
+ property("translate");
+ property("precision");
+ return gilbert2.scale(249.5);
+ }
+ function gingeryRaw(rho, n) {
+ var k2 = 2 * pi / n, rho2 = rho * rho;
+ function forward(lambda, phi) {
+ var p = d3Geo.geoAzimuthalEquidistantRaw(lambda, phi), x = p[0], y = p[1], r2 = x * x + y * y;
+ if (r2 > rho2) {
+ var r = sqrt(r2), theta = atan2(y, x), theta0 = k2 * round(theta / k2), alpha = theta - theta0, rhoCosAlpha = rho * cos(alpha), k_ = (rho * sin(alpha) - alpha * sin(rhoCosAlpha)) / (halfPi - rhoCosAlpha), s_ = gingeryLength(alpha, k_), e = (pi - rho) / gingeryIntegrate(s_, rhoCosAlpha, pi);
+ x = r;
+ var i = 50, delta;
+ do {
+ x -= delta = (rho + gingeryIntegrate(s_, rhoCosAlpha, x) * e - r) / (s_(x) * e);
+ } while (abs(delta) > epsilon && --i > 0);
+ y = alpha * sin(x);
+ if (x < halfPi) y -= k_ * (x - halfPi);
+ var s = sin(theta0), c = cos(theta0);
+ p[0] = x * c - y * s;
+ p[1] = x * s + y * c;
+ }
+ return p;
+ }
+ forward.invert = function(x, y) {
+ var r2 = x * x + y * y;
+ if (r2 > rho2) {
+ var r = sqrt(r2), theta = atan2(y, x), theta0 = k2 * round(theta / k2), dTheta = theta - theta0;
+ x = r * cos(dTheta);
+ y = r * sin(dTheta);
+ var x_halfPi = x - halfPi, sinx = sin(x), alpha = y / sinx, delta = x < halfPi ? Infinity : 0, i = 10;
+ while (true) {
+ var rhosinAlpha = rho * sin(alpha), rhoCosAlpha = rho * cos(alpha), sinRhoCosAlpha = sin(rhoCosAlpha), halfPi_RhoCosAlpha = halfPi - rhoCosAlpha, k_ = (rhosinAlpha - alpha * sinRhoCosAlpha) / halfPi_RhoCosAlpha, s_ = gingeryLength(alpha, k_);
+ if (abs(delta) < epsilon22 || !--i) break;
+ alpha -= delta = (alpha * sinx - k_ * x_halfPi - y) / (sinx - x_halfPi * 2 * (halfPi_RhoCosAlpha * (rhoCosAlpha + alpha * rhosinAlpha * cos(rhoCosAlpha) - sinRhoCosAlpha) - rhosinAlpha * (rhosinAlpha - alpha * sinRhoCosAlpha)) / (halfPi_RhoCosAlpha * halfPi_RhoCosAlpha));
+ }
+ r = rho + gingeryIntegrate(s_, rhoCosAlpha, x) * (pi - rho) / gingeryIntegrate(s_, rhoCosAlpha, pi);
+ theta = theta0 + alpha;
+ x = r * cos(theta);
+ y = r * sin(theta);
+ }
+ return d3Geo.geoAzimuthalEquidistantRaw.invert(x, y);
+ };
+ return forward;
+ }
+ function gingeryLength(alpha, k2) {
+ return function(x) {
+ var y_ = alpha * cos(x);
+ if (x < halfPi) y_ -= k2;
+ return sqrt(1 + y_ * y_);
+ };
+ }
+ function gingeryIntegrate(f, a, b) {
+ var n = 50, h = (b - a) / n, s = f(a) + f(b);
+ for (var i = 1, x = a; i < n; ++i) s += 2 * f(x += h);
+ return s * 0.5 * h;
+ }
+ function gingery() {
+ var n = 6, rho = 30 * radians2, cRho = cos(rho), sRho = sin(rho), m = d3Geo.geoProjectionMutator(gingeryRaw), p = m(rho, n), stream_ = p.stream, epsilon$$1 = 0.01, cr = -cos(epsilon$$1 * radians2), sr = sin(epsilon$$1 * radians2);
+ p.radius = function(_) {
+ if (!arguments.length) return rho * degrees3;
+ cRho = cos(rho = _ * radians2);
+ sRho = sin(rho);
+ return m(rho, n);
+ };
+ p.lobes = function(_) {
+ if (!arguments.length) return n;
+ return m(rho, n = +_);
+ };
+ p.stream = function(stream) {
+ var rotate = p.rotate(), rotateStream = stream_(stream), sphereStream = (p.rotate([0, 0]), stream_(stream));
+ p.rotate(rotate);
+ rotateStream.sphere = function() {
+ sphereStream.polygonStart(), sphereStream.lineStart();
+ for (var i = 0, delta = 2 * pi / n, phi = 0; i < n; ++i, phi -= delta) {
+ sphereStream.point(atan2(sr * cos(phi), cr) * degrees3, asin(sr * sin(phi)) * degrees3);
+ sphereStream.point(atan2(sRho * cos(phi - delta / 2), cRho) * degrees3, asin(sRho * sin(phi - delta / 2)) * degrees3);
+ }
+ sphereStream.lineEnd(), sphereStream.polygonEnd();
+ };
+ return rotateStream;
+ };
+ return p.rotate([90, -40]).scale(91.7095).clipAngle(180 - 1e-3);
+ }
+ function ginzburgPolyconicRaw(a, b, c, d, e, f, g, h) {
+ if (arguments.length < 8) h = 0;
+ function forward(lambda, phi) {
+ if (!phi) return [a * lambda / pi, 0];
+ var phi2 = phi * phi, xB = a + phi2 * (b + phi2 * (c + phi2 * d)), yB = phi * (e - 1 + phi2 * (f - h + phi2 * g)), m = (xB * xB + yB * yB) / (2 * yB), alpha = lambda * asin(xB / m) / pi;
+ return [m * sin(alpha), phi * (1 + phi2 * h) + m * (1 - cos(alpha))];
+ }
+ forward.invert = function(x, y) {
+ var lambda = pi * x / a, phi = y, deltaLambda, deltaPhi, i = 50;
+ do {
+ var phi2 = phi * phi, xB = a + phi2 * (b + phi2 * (c + phi2 * d)), yB = phi * (e - 1 + phi2 * (f - h + phi2 * g)), p = xB * xB + yB * yB, q = 2 * yB, m = p / q, m2 = m * m, dAlphadLambda = asin(xB / m) / pi, alpha = lambda * dAlphadLambda, xB2 = xB * xB, dxBdPhi = (2 * b + phi2 * (4 * c + phi2 * 6 * d)) * phi, dyBdPhi = e + phi2 * (3 * f + phi2 * 5 * g), dpdPhi = 2 * (xB * dxBdPhi + yB * (dyBdPhi - 1)), dqdPhi = 2 * (dyBdPhi - 1), dmdPhi = (dpdPhi * q - p * dqdPhi) / (q * q), cosAlpha = cos(alpha), sinAlpha = sin(alpha), mcosAlpha = m * cosAlpha, msinAlpha = m * sinAlpha, dAlphadPhi = lambda / pi * (1 / sqrt(1 - xB2 / m2)) * (dxBdPhi * m - xB * dmdPhi) / m2, fx = msinAlpha - x, fy = phi * (1 + phi2 * h) + m - mcosAlpha - y, deltaxDeltaPhi = dmdPhi * sinAlpha + mcosAlpha * dAlphadPhi, deltaxDeltaLambda = mcosAlpha * dAlphadLambda, deltayDeltaPhi = 1 + dmdPhi - (dmdPhi * cosAlpha - msinAlpha * dAlphadPhi), deltayDeltaLambda = msinAlpha * dAlphadLambda, denominator = deltaxDeltaPhi * deltayDeltaLambda - deltayDeltaPhi * deltaxDeltaLambda;
+ if (!denominator) break;
+ lambda -= deltaLambda = (fy * deltaxDeltaPhi - fx * deltayDeltaPhi) / denominator;
+ phi -= deltaPhi = (fx * deltayDeltaLambda - fy * deltaxDeltaLambda) / denominator;
+ } while ((abs(deltaLambda) > epsilon || abs(deltaPhi) > epsilon) && --i > 0);
+ return [lambda, phi];
+ };
+ return forward;
+ }
+ var ginzburg4Raw = ginzburgPolyconicRaw(2.8284, -1.6988, 0.75432, -0.18071, 1.76003, -0.38914, 0.042555);
+ function ginzburg4() {
+ return d3Geo.geoProjection(ginzburg4Raw).scale(149.995);
+ }
+ var ginzburg5Raw = ginzburgPolyconicRaw(2.583819, -0.835827, 0.170354, -0.038094, 1.543313, -0.411435, 0.082742);
+ function ginzburg5() {
+ return d3Geo.geoProjection(ginzburg5Raw).scale(153.93);
+ }
+ var ginzburg6Raw = ginzburgPolyconicRaw(5 / 6 * pi, -0.62636, -0.0344, 0, 1.3493, -0.05524, 0, 0.045);
+ function ginzburg6() {
+ return d3Geo.geoProjection(ginzburg6Raw).scale(130.945);
+ }
+ function ginzburg8Raw(lambda, phi) {
+ var lambda2 = lambda * lambda, phi2 = phi * phi;
+ return [
+ lambda * (1 - 0.162388 * phi2) * (0.87 - 952426e-9 * lambda2 * lambda2),
+ phi * (1 + phi2 / 12)
+ ];
+ }
+ ginzburg8Raw.invert = function(x, y) {
+ var lambda = x, phi = y, i = 50, delta;
+ do {
+ var phi2 = phi * phi;
+ phi -= delta = (phi * (1 + phi2 / 12) - y) / (1 + phi2 / 4);
+ } while (abs(delta) > epsilon && --i > 0);
+ i = 50;
+ x /= 1 - 0.162388 * phi2;
+ do {
+ var lambda4 = (lambda4 = lambda * lambda) * lambda4;
+ lambda -= delta = (lambda * (0.87 - 952426e-9 * lambda4) - x) / (0.87 - 476213e-8 * lambda4);
+ } while (abs(delta) > epsilon && --i > 0);
+ return [lambda, phi];
+ };
+ function ginzburg8() {
+ return d3Geo.geoProjection(ginzburg8Raw).scale(131.747);
+ }
+ var ginzburg9Raw = ginzburgPolyconicRaw(2.6516, -0.76534, 0.19123, -0.047094, 1.36289, -0.13965, 0.031762);
+ function ginzburg9() {
+ return d3Geo.geoProjection(ginzburg9Raw).scale(131.087);
+ }
+ function squareRaw(project) {
+ var dx = project(halfPi, 0)[0] - project(-halfPi, 0)[0];
+ function projectSquare(lambda, phi) {
+ var s = lambda > 0 ? -0.5 : 0.5, point = project(lambda + s * pi, phi);
+ point[0] -= s * dx;
+ return point;
+ }
+ if (project.invert) projectSquare.invert = function(x, y) {
+ var s = x > 0 ? -0.5 : 0.5, location2 = project.invert(x + s * dx, y), lambda = location2[0] - s * pi;
+ if (lambda < -pi) lambda += 2 * pi;
+ else if (lambda > pi) lambda -= 2 * pi;
+ location2[0] = lambda;
+ return location2;
+ };
+ return projectSquare;
+ }
+ function gringortenRaw(lambda, phi) {
+ var sLambda = sign(lambda), sPhi = sign(phi), cosPhi = cos(phi), x = cos(lambda) * cosPhi, y = sin(lambda) * cosPhi, z = sin(sPhi * phi);
+ lambda = abs(atan2(y, z));
+ phi = asin(x);
+ if (abs(lambda - halfPi) > epsilon) lambda %= halfPi;
+ var point = gringortenHexadecant(lambda > pi / 4 ? halfPi - lambda : lambda, phi);
+ if (lambda > pi / 4) z = point[0], point[0] = -point[1], point[1] = -z;
+ return point[0] *= sLambda, point[1] *= -sPhi, point;
+ }
+ gringortenRaw.invert = function(x, y) {
+ if (abs(x) > 1) x = sign(x) * 2 - x;
+ if (abs(y) > 1) y = sign(y) * 2 - y;
+ var sx = sign(x), sy = sign(y), x02 = -sx * x, y02 = -sy * y, t = y02 / x02 < 1, p = gringortenHexadecantInvert(t ? y02 : x02, t ? x02 : y02), lambda = p[0], phi = p[1], cosPhi = cos(phi);
+ if (t) lambda = -halfPi - lambda;
+ return [sx * (atan2(sin(lambda) * cosPhi, -sin(phi)) + pi), sy * asin(cos(lambda) * cosPhi)];
+ };
+ function gringortenHexadecant(lambda, phi) {
+ if (phi === halfPi) return [0, 0];
+ var sinPhi = sin(phi), r = sinPhi * sinPhi, r2 = r * r, j = 1 + r2, k2 = 1 + 3 * r2, q = 1 - r2, z = asin(1 / sqrt(j)), v = q + r * j * z, p2 = (1 - sinPhi) / v, p = sqrt(p2), a2 = p2 * j, a = sqrt(a2), h = p * q, x, i;
+ if (lambda === 0) return [0, -(h + r * a)];
+ var cosPhi = cos(phi), secPhi = 1 / cosPhi, drdPhi = 2 * sinPhi * cosPhi, dvdPhi = (-3 * r + z * k2) * drdPhi, dp2dPhi = (-v * cosPhi - (1 - sinPhi) * dvdPhi) / (v * v), dpdPhi = 0.5 * dp2dPhi / p, dhdPhi = q * dpdPhi - 2 * r * p * drdPhi, dra2dPhi = r * j * dp2dPhi + p2 * k2 * drdPhi, mu = -secPhi * drdPhi, nu = -secPhi * dra2dPhi, zeta = -2 * secPhi * dhdPhi, lambda1 = 4 * lambda / pi, delta;
+ if (lambda > 0.222 * pi || phi < pi / 4 && lambda > 0.175 * pi) {
+ x = (h + r * sqrt(a2 * (1 + r2) - h * h)) / (1 + r2);
+ if (lambda > pi / 4) return [x, x];
+ var x12 = x, x02 = 0.5 * x;
+ x = 0.5 * (x02 + x12), i = 50;
+ do {
+ var g = sqrt(a2 - x * x), f = x * (zeta + mu * g) + nu * asin(x / a) - lambda1;
+ if (!f) break;
+ if (f < 0) x02 = x;
+ else x12 = x;
+ x = 0.5 * (x02 + x12);
+ } while (abs(x12 - x02) > epsilon && --i > 0);
+ } else {
+ x = epsilon, i = 25;
+ do {
+ var x2 = x * x, g2 = sqrt(a2 - x2), zetaMug = zeta + mu * g2, f2 = x * zetaMug + nu * asin(x / a) - lambda1, df = zetaMug + (nu - mu * x2) / g2;
+ x -= delta = g2 ? f2 / df : 0;
+ } while (abs(delta) > epsilon && --i > 0);
+ }
+ return [x, -h - r * sqrt(a2 - x * x)];
+ }
+ function gringortenHexadecantInvert(x, y) {
+ var x02 = 0, x12 = 1, r = 0.5, i = 50;
+ while (true) {
+ var r2 = r * r, sinPhi = sqrt(r), z = asin(1 / sqrt(1 + r2)), v = 1 - r2 + r * (1 + r2) * z, p2 = (1 - sinPhi) / v, p = sqrt(p2), a2 = p2 * (1 + r2), h = p * (1 - r2), g2 = a2 - x * x, g = sqrt(g2), y02 = y + h + r * g;
+ if (abs(x12 - x02) < epsilon22 || --i === 0 || y02 === 0) break;
+ if (y02 > 0) x02 = r;
+ else x12 = r;
+ r = 0.5 * (x02 + x12);
+ }
+ if (!i) return null;
+ var phi = asin(sinPhi), cosPhi = cos(phi), secPhi = 1 / cosPhi, drdPhi = 2 * sinPhi * cosPhi, dvdPhi = (-3 * r + z * (1 + 3 * r2)) * drdPhi, dp2dPhi = (-v * cosPhi - (1 - sinPhi) * dvdPhi) / (v * v), dpdPhi = 0.5 * dp2dPhi / p, dhdPhi = (1 - r2) * dpdPhi - 2 * r * p * drdPhi, zeta = -2 * secPhi * dhdPhi, mu = -secPhi * drdPhi, nu = -secPhi * (r * (1 + r2) * dp2dPhi + p2 * (1 + 3 * r2) * drdPhi);
+ return [pi / 4 * (x * (zeta + mu * g) + nu * asin(x / sqrt(a2))), phi];
+ }
+ function gringorten() {
+ return d3Geo.geoProjection(squareRaw(gringortenRaw)).scale(239.75);
+ }
+ function ellipticJi(u, v, m) {
+ var a, b, c;
+ if (!u) {
+ b = ellipticJ(v, 1 - m);
+ return [
+ [0, b[0] / b[1]],
+ [1 / b[1], 0],
+ [b[2] / b[1], 0]
+ ];
+ }
+ a = ellipticJ(u, m);
+ if (!v) return [[a[0], 0], [a[1], 0], [a[2], 0]];
+ b = ellipticJ(v, 1 - m);
+ c = b[1] * b[1] + m * a[0] * a[0] * b[0] * b[0];
+ return [
+ [a[0] * b[2] / c, a[1] * a[2] * b[0] * b[1] / c],
+ [a[1] * b[1] / c, -a[0] * a[2] * b[0] * b[2] / c],
+ [a[2] * b[1] * b[2] / c, -m * a[0] * a[1] * b[0] / c]
+ ];
+ }
+ function ellipticJ(u, m) {
+ var ai, b, phi, t, twon;
+ if (m < epsilon) {
+ t = sin(u);
+ b = cos(u);
+ ai = m * (u - t * b) / 4;
+ return [
+ t - ai * b,
+ b + ai * t,
+ 1 - m * t * t / 2,
+ u - ai
+ ];
+ }
+ if (m >= 1 - epsilon) {
+ ai = (1 - m) / 4;
+ b = cosh2(u);
+ t = tanh2(u);
+ phi = 1 / b;
+ twon = b * sinh2(u);
+ return [
+ t + ai * (twon - u) / (b * b),
+ phi - ai * t * phi * (twon - u),
+ phi + ai * t * phi * (twon + u),
+ 2 * atan(exp(u)) - halfPi + ai * (twon - u) / b
+ ];
+ }
+ var a = [1, 0, 0, 0, 0, 0, 0, 0, 0], c = [sqrt(m), 0, 0, 0, 0, 0, 0, 0, 0], i = 0;
+ b = sqrt(1 - m);
+ twon = 1;
+ while (abs(c[i] / a[i]) > epsilon && i < 8) {
+ ai = a[i++];
+ c[i] = (ai - b) / 2;
+ a[i] = (ai + b) / 2;
+ b = sqrt(ai * b);
+ twon *= 2;
+ }
+ phi = twon * a[i] * u;
+ do {
+ t = c[i] * sin(b = phi) / a[i];
+ phi = (asin(t) + phi) / 2;
+ } while (--i);
+ return [sin(phi), t = cos(phi), t / cos(phi - b), phi];
+ }
+ function ellipticFi(phi, psi, m) {
+ var r = abs(phi), i = abs(psi), sinhPsi = sinh2(i);
+ if (r) {
+ var cscPhi = 1 / sin(r), cotPhi2 = 1 / (tan(r) * tan(r)), b = -(cotPhi2 + m * (sinhPsi * sinhPsi * cscPhi * cscPhi) - 1 + m), c = (m - 1) * cotPhi2, cotLambda2 = (-b + sqrt(b * b - 4 * c)) / 2;
+ return [
+ ellipticF(atan(1 / sqrt(cotLambda2)), m) * sign(phi),
+ ellipticF(atan(sqrt((cotLambda2 / cotPhi2 - 1) / m)), 1 - m) * sign(psi)
+ ];
+ }
+ return [
+ 0,
+ ellipticF(atan(sinhPsi), 1 - m) * sign(psi)
+ ];
+ }
+ function ellipticF(phi, m) {
+ if (!m) return phi;
+ if (m === 1) return log(tan(phi / 2 + quarterPi));
+ var a = 1, b = sqrt(1 - m), c = sqrt(m);
+ for (var i = 0; abs(c) > epsilon; i++) {
+ if (phi % pi) {
+ var dPhi = atan(b * tan(phi) / a);
+ if (dPhi < 0) dPhi += pi;
+ phi += dPhi + ~~(phi / pi) * pi;
+ } else phi += phi;
+ c = (a + b) / 2;
+ b = sqrt(a * b);
+ c = ((a = c) - b) / 2;
+ }
+ return phi / (pow(2, i) * a);
+ }
+ function guyouRaw(lambda, phi) {
+ var k_ = (sqrt2 - 1) / (sqrt2 + 1), k2 = sqrt(1 - k_ * k_), K3 = ellipticF(halfPi, k2 * k2), f = -1, psi = log(tan(pi / 4 + abs(phi) / 2)), r = exp(f * psi) / sqrt(k_), at = guyouComplexAtan(r * cos(f * lambda), r * sin(f * lambda)), t = ellipticFi(at[0], at[1], k2 * k2);
+ return [-t[1], (phi >= 0 ? 1 : -1) * (0.5 * K3 - t[0])];
+ }
+ function guyouComplexAtan(x, y) {
+ var x2 = x * x, y_1 = y + 1, t = 1 - x2 - y * y;
+ return [
+ 0.5 * ((x >= 0 ? halfPi : -halfPi) - atan2(t, 2 * x)),
+ -0.25 * log(t * t + 4 * x2) + 0.5 * log(y_1 * y_1 + x2)
+ ];
+ }
+ function guyouComplexDivide(a, b) {
+ var denominator = b[0] * b[0] + b[1] * b[1];
+ return [
+ (a[0] * b[0] + a[1] * b[1]) / denominator,
+ (a[1] * b[0] - a[0] * b[1]) / denominator
+ ];
+ }
+ guyouRaw.invert = function(x, y) {
+ var k_ = (sqrt2 - 1) / (sqrt2 + 1), k2 = sqrt(1 - k_ * k_), K3 = ellipticF(halfPi, k2 * k2), f = -1, j = ellipticJi(0.5 * K3 - y, -x, k2 * k2), tn = guyouComplexDivide(j[0], j[1]), lambda = atan2(tn[1], tn[0]) / f;
+ return [
+ lambda,
+ 2 * atan(exp(0.5 / f * log(k_ * tn[0] * tn[0] + k_ * tn[1] * tn[1]))) - halfPi
+ ];
+ };
+ function guyou() {
+ return d3Geo.geoProjection(squareRaw(guyouRaw)).scale(151.496);
+ }
+ function hammerRetroazimuthalRaw(phi02) {
+ var sinPhi0 = sin(phi02), cosPhi0 = cos(phi02), rotate = hammerRetroazimuthalRotation(phi02);
+ rotate.invert = hammerRetroazimuthalRotation(-phi02);
+ function forward(lambda, phi) {
+ var p = rotate(lambda, phi);
+ lambda = p[0], phi = p[1];
+ var sinPhi = sin(phi), cosPhi = cos(phi), cosLambda = cos(lambda), z = acos(sinPhi0 * sinPhi + cosPhi0 * cosPhi * cosLambda), sinz = sin(z), K3 = abs(sinz) > epsilon ? z / sinz : 1;
+ return [
+ K3 * cosPhi0 * sin(lambda),
+ (abs(lambda) > halfPi ? K3 : -K3) * (sinPhi0 * cosPhi - cosPhi0 * sinPhi * cosLambda)
+ ];
+ }
+ forward.invert = function(x, y) {
+ var rho = sqrt(x * x + y * y), sinz = -sin(rho), cosz = cos(rho), a = rho * cosz, b = -y * sinz, c = rho * sinPhi0, d = sqrt(a * a + b * b - c * c), phi = atan2(a * c + b * d, b * c - a * d), lambda = (rho > halfPi ? -1 : 1) * atan2(x * sinz, rho * cos(phi) * cosz + y * sin(phi) * sinz);
+ return rotate.invert(lambda, phi);
+ };
+ return forward;
+ }
+ function hammerRetroazimuthalRotation(phi02) {
+ var sinPhi0 = sin(phi02), cosPhi0 = cos(phi02);
+ return function(lambda, phi) {
+ var cosPhi = cos(phi), x = cos(lambda) * cosPhi, y = sin(lambda) * cosPhi, z = sin(phi);
+ return [
+ atan2(y, x * cosPhi0 - z * sinPhi0),
+ asin(z * cosPhi0 + x * sinPhi0)
+ ];
+ };
+ }
+ function hammerRetroazimuthal() {
+ var phi02 = 0, m = d3Geo.geoProjectionMutator(hammerRetroazimuthalRaw), p = m(phi02), rotate_ = p.rotate, stream_ = p.stream, circle = d3Geo.geoCircle();
+ p.parallel = function(_) {
+ if (!arguments.length) return phi02 * degrees3;
+ var r = p.rotate();
+ return m(phi02 = _ * radians2).rotate(r);
+ };
+ p.rotate = function(_) {
+ if (!arguments.length) return _ = rotate_.call(p), _[1] += phi02 * degrees3, _;
+ rotate_.call(p, [_[0], _[1] - phi02 * degrees3]);
+ circle.center([-_[0], -_[1]]);
+ return p;
+ };
+ p.stream = function(stream) {
+ stream = stream_(stream);
+ stream.sphere = function() {
+ stream.polygonStart();
+ var epsilon$$1 = 0.01, ring = circle.radius(90 - epsilon$$1)().coordinates[0], n = ring.length - 1, i = -1, p2;
+ stream.lineStart();
+ while (++i < n) stream.point((p2 = ring[i])[0], p2[1]);
+ stream.lineEnd();
+ ring = circle.radius(90 + epsilon$$1)().coordinates[0];
+ n = ring.length - 1;
+ stream.lineStart();
+ while (--i >= 0) stream.point((p2 = ring[i])[0], p2[1]);
+ stream.lineEnd();
+ stream.polygonEnd();
+ };
+ return stream;
+ };
+ return p.scale(79.4187).parallel(45).clipAngle(180 - 1e-3);
+ }
+ var K2 = 3, healpixParallel = asin(1 - 1 / K2) * degrees3, healpixLambert = cylindricalEqualAreaRaw(0);
+ function healpixRaw(H) {
+ var phi02 = healpixParallel * radians2, dx = collignonRaw(pi, phi02)[0] - collignonRaw(-pi, phi02)[0], y02 = healpixLambert(0, phi02)[1], y12 = collignonRaw(0, phi02)[1], dy1 = sqrtPi - y12, k2 = tau / H, w2 = 4 / tau, h = y02 + dy1 * dy1 * 4 / tau;
+ function forward(lambda, phi) {
+ var point, phi2 = abs(phi);
+ if (phi2 > phi02) {
+ var i = min(H - 1, max(0, floor((lambda + pi) / k2)));
+ lambda += pi * (H - 1) / H - i * k2;
+ point = collignonRaw(lambda, phi2);
+ point[0] = point[0] * tau / dx - tau * (H - 1) / (2 * H) + i * tau / H;
+ point[1] = y02 + (point[1] - y12) * 4 * dy1 / tau;
+ if (phi < 0) point[1] = -point[1];
+ } else {
+ point = healpixLambert(lambda, phi);
+ }
+ point[0] *= w2, point[1] /= h;
+ return point;
+ }
+ forward.invert = function(x, y) {
+ x /= w2, y *= h;
+ var y2 = abs(y);
+ if (y2 > y02) {
+ var i = min(H - 1, max(0, floor((x + pi) / k2)));
+ x = (x + pi * (H - 1) / H - i * k2) * dx / tau;
+ var point = collignonRaw.invert(x, 0.25 * (y2 - y02) * tau / dy1 + y12);
+ point[0] -= pi * (H - 1) / H - i * k2;
+ if (y < 0) point[1] = -point[1];
+ return point;
+ }
+ return healpixLambert.invert(x, y);
+ };
+ return forward;
+ }
+ function sphereTop(x, i) {
+ return [x, i & 1 ? 90 - epsilon : healpixParallel];
+ }
+ function sphereBottom(x, i) {
+ return [x, i & 1 ? -90 + epsilon : -healpixParallel];
+ }
+ function sphereNudge(d) {
+ return [d[0] * (1 - epsilon), d[1]];
+ }
+ function sphere(step) {
+ var c = [].concat(
+ d3Array.range(-180, 180 + step / 2, step).map(sphereTop),
+ d3Array.range(180, -180 - step / 2, -step).map(sphereBottom)
+ );
+ return {
+ type: "Polygon",
+ coordinates: [step === 180 ? c.map(sphereNudge) : c]
+ };
+ }
+ function healpix() {
+ var H = 4, m = d3Geo.geoProjectionMutator(healpixRaw), p = m(H), stream_ = p.stream;
+ p.lobes = function(_) {
+ return arguments.length ? m(H = +_) : H;
+ };
+ p.stream = function(stream) {
+ var rotate = p.rotate(), rotateStream = stream_(stream), sphereStream = (p.rotate([0, 0]), stream_(stream));
+ p.rotate(rotate);
+ rotateStream.sphere = function() {
+ d3Geo.geoStream(sphere(180 / H), sphereStream);
+ };
+ return rotateStream;
+ };
+ return p.scale(239.75);
+ }
+ function hillRaw(K3) {
+ var L = 1 + K3, sinBt = sin(1 / L), Bt = asin(sinBt), A3 = 2 * sqrt(pi / (B3 = pi + 4 * Bt * L)), B3, rho0 = 0.5 * A3 * (L + sqrt(K3 * (2 + K3))), K22 = K3 * K3, L2 = L * L;
+ function forward(lambda, phi) {
+ var t = 1 - sin(phi), rho, omega;
+ if (t && t < 2) {
+ var theta = halfPi - phi, i = 25, delta;
+ do {
+ var sinTheta = sin(theta), cosTheta = cos(theta), Bt_Bt1 = Bt + atan2(sinTheta, L - cosTheta), C2 = 1 + L2 - 2 * L * cosTheta;
+ theta -= delta = (theta - K22 * Bt - L * sinTheta + C2 * Bt_Bt1 - 0.5 * t * B3) / (2 * L * sinTheta * Bt_Bt1);
+ } while (abs(delta) > epsilon22 && --i > 0);
+ rho = A3 * sqrt(C2);
+ omega = lambda * Bt_Bt1 / pi;
+ } else {
+ rho = A3 * (K3 + t);
+ omega = lambda * Bt / pi;
+ }
+ return [
+ rho * sin(omega),
+ rho0 - rho * cos(omega)
+ ];
+ }
+ forward.invert = function(x, y) {
+ var rho2 = x * x + (y -= rho0) * y, cosTheta = (1 + L2 - rho2 / (A3 * A3)) / (2 * L), theta = acos(cosTheta), sinTheta = sin(theta), Bt_Bt1 = Bt + atan2(sinTheta, L - cosTheta);
+ return [
+ asin(x / sqrt(rho2)) * pi / Bt_Bt1,
+ asin(1 - 2 * (theta - K22 * Bt - L * sinTheta + (1 + L2 - 2 * L * cosTheta) * Bt_Bt1) / B3)
+ ];
+ };
+ return forward;
+ }
+ function hill() {
+ var K3 = 1, m = d3Geo.geoProjectionMutator(hillRaw), p = m(K3);
+ p.ratio = function(_) {
+ return arguments.length ? m(K3 = +_) : K3;
+ };
+ return p.scale(167.774).center([0, 18.67]);
+ }
+ var sinuMollweidePhi = 0.7109889596207567;
+ var sinuMollweideY = 0.0528035274542;
+ function sinuMollweideRaw(lambda, phi) {
+ return phi > -sinuMollweidePhi ? (lambda = mollweideRaw(lambda, phi), lambda[1] += sinuMollweideY, lambda) : sinusoidalRaw(lambda, phi);
+ }
+ sinuMollweideRaw.invert = function(x, y) {
+ return y > -sinuMollweidePhi ? mollweideRaw.invert(x, y - sinuMollweideY) : sinusoidalRaw.invert(x, y);
+ };
+ function sinuMollweide() {
+ return d3Geo.geoProjection(sinuMollweideRaw).rotate([-20, -55]).scale(164.263).center([0, -5.4036]);
+ }
+ function homolosineRaw(lambda, phi) {
+ return abs(phi) > sinuMollweidePhi ? (lambda = mollweideRaw(lambda, phi), lambda[1] -= phi > 0 ? sinuMollweideY : -sinuMollweideY, lambda) : sinusoidalRaw(lambda, phi);
+ }
+ homolosineRaw.invert = function(x, y) {
+ return abs(y) > sinuMollweidePhi ? mollweideRaw.invert(x, y + (y > 0 ? sinuMollweideY : -sinuMollweideY)) : sinusoidalRaw.invert(x, y);
+ };
+ function homolosine() {
+ return d3Geo.geoProjection(homolosineRaw).scale(152.63);
+ }
+ function hufnagelRaw(a, b, psiMax, ratio) {
+ var k2 = sqrt(
+ 4 * pi / (2 * psiMax + (1 + a - b / 2) * sin(2 * psiMax) + (a + b) / 2 * sin(4 * psiMax) + b / 2 * sin(6 * psiMax))
+ ), c = sqrt(
+ ratio * sin(psiMax) * sqrt((1 + a * cos(2 * psiMax) + b * cos(4 * psiMax)) / (1 + a + b))
+ ), M = psiMax * mapping(1);
+ function radius(psi) {
+ return sqrt(1 + a * cos(2 * psi) + b * cos(4 * psi));
+ }
+ function mapping(t) {
+ var psi = t * psiMax;
+ return (2 * psi + (1 + a - b / 2) * sin(2 * psi) + (a + b) / 2 * sin(4 * psi) + b / 2 * sin(6 * psi)) / psiMax;
+ }
+ function inversemapping(psi) {
+ return radius(psi) * sin(psi);
+ }
+ var forward = function(lambda, phi) {
+ var psi = psiMax * solve(mapping, M * sin(phi) / psiMax, phi / pi);
+ if (isNaN(psi)) psi = psiMax * sign(phi);
+ var kr = k2 * radius(psi);
+ return [kr * c * lambda / pi * cos(psi), kr / c * sin(psi)];
+ };
+ forward.invert = function(x, y) {
+ var psi = solve(inversemapping, y * c / k2);
+ return [
+ x * pi / (cos(psi) * k2 * c * radius(psi)),
+ asin(psiMax * mapping(psi / psiMax) / M)
+ ];
+ };
+ if (psiMax === 0) {
+ k2 = sqrt(ratio / pi);
+ forward = function(lambda, phi) {
+ return [lambda * k2, sin(phi) / k2];
+ };
+ forward.invert = function(x, y) {
+ return [x / k2, asin(y * k2)];
+ };
+ }
+ return forward;
+ }
+ function hufnagel() {
+ var a = 1, b = 0, psiMax = 45 * radians2, ratio = 2, mutate = d3Geo.geoProjectionMutator(hufnagelRaw), projection = mutate(a, b, psiMax, ratio);
+ projection.a = function(_) {
+ return arguments.length ? mutate(a = +_, b, psiMax, ratio) : a;
+ };
+ projection.b = function(_) {
+ return arguments.length ? mutate(a, b = +_, psiMax, ratio) : b;
+ };
+ projection.psiMax = function(_) {
+ return arguments.length ? mutate(a, b, psiMax = +_ * radians2, ratio) : psiMax * degrees3;
+ };
+ projection.ratio = function(_) {
+ return arguments.length ? mutate(a, b, psiMax, ratio = +_) : ratio;
+ };
+ return projection.scale(180.739);
+ }
+ function adsimp(f, a, b, fa, fm, fb, V0, tol, maxdepth, depth, state) {
+ if (state.nanEncountered) {
+ return NaN;
+ }
+ var h, f1, f2, sl, sr, s2, m, V1, V2, err;
+ h = b - a;
+ f1 = f(a + h * 0.25);
+ f2 = f(b - h * 0.25);
+ if (isNaN(f1)) {
+ state.nanEncountered = true;
+ return;
+ }
+ if (isNaN(f2)) {
+ state.nanEncountered = true;
+ return;
+ }
+ sl = h * (fa + 4 * f1 + fm) / 12;
+ sr = h * (fm + 4 * f2 + fb) / 12;
+ s2 = sl + sr;
+ err = (s2 - V0) / 15;
+ if (depth > maxdepth) {
+ state.maxDepthCount++;
+ return s2 + err;
+ } else if (Math.abs(err) < tol) {
+ return s2 + err;
+ } else {
+ m = a + h * 0.5;
+ V1 = adsimp(f, a, m, fa, f1, fm, sl, tol * 0.5, maxdepth, depth + 1, state);
+ if (isNaN(V1)) {
+ state.nanEncountered = true;
+ return NaN;
+ }
+ V2 = adsimp(f, m, b, fm, f2, fb, sr, tol * 0.5, maxdepth, depth + 1, state);
+ if (isNaN(V2)) {
+ state.nanEncountered = true;
+ return NaN;
+ }
+ return V1 + V2;
+ }
+ }
+ function integrate(f, a, b, tol, maxdepth) {
+ var state = {
+ maxDepthCount: 0,
+ nanEncountered: false
+ };
+ if (tol === void 0) {
+ tol = 1e-8;
+ }
+ if (maxdepth === void 0) {
+ maxdepth = 20;
+ }
+ var fa = f(a);
+ var fm = f(0.5 * (a + b));
+ var fb = f(b);
+ var V0 = (fa + 4 * fm + fb) * (b - a) / 6;
+ var result = adsimp(f, a, b, fa, fm, fb, V0, tol, maxdepth, 1, state);
+ return result;
+ }
+ function hyperellipticalRaw(alpha, k2, gamma2) {
+ function elliptic(f) {
+ return alpha + (1 - alpha) * pow(1 - pow(f, k2), 1 / k2);
+ }
+ function z(f) {
+ return integrate(elliptic, 0, f, 1e-4);
+ }
+ var G = 1 / z(1), n = 1e3, m = (1 + 1e-8) * G, approx = [];
+ for (var i = 0; i <= n; i++)
+ approx.push(z(i / n) * m);
+ function Y(sinphi) {
+ var rmin = 0, rmax = n, r = n >> 1;
+ do {
+ if (approx[r] > sinphi) rmax = r;
+ else rmin = r;
+ r = rmin + rmax >> 1;
+ } while (r > rmin);
+ var u = approx[r + 1] - approx[r];
+ if (u) u = (sinphi - approx[r + 1]) / u;
+ return (r + 1 + u) / n;
+ }
+ var ratio = 2 * Y(1) / pi * G / gamma2;
+ var forward = function(lambda, phi) {
+ var y = Y(abs(sin(phi))), x = elliptic(y) * lambda;
+ y /= ratio;
+ return [x, phi >= 0 ? y : -y];
+ };
+ forward.invert = function(x, y) {
+ var phi;
+ y *= ratio;
+ if (abs(y) < 1) phi = sign(y) * asin(z(abs(y)) * G);
+ return [x / elliptic(abs(y)), phi];
+ };
+ return forward;
+ }
+ function hyperelliptical() {
+ var alpha = 0, k2 = 2.5, gamma2 = 1.183136, m = d3Geo.geoProjectionMutator(hyperellipticalRaw), p = m(alpha, k2, gamma2);
+ p.alpha = function(_) {
+ return arguments.length ? m(alpha = +_, k2, gamma2) : alpha;
+ };
+ p.k = function(_) {
+ return arguments.length ? m(alpha, k2 = +_, gamma2) : k2;
+ };
+ p.gamma = function(_) {
+ return arguments.length ? m(alpha, k2, gamma2 = +_) : gamma2;
+ };
+ return p.scale(152.63);
+ }
+ function pointEqual(a, b) {
+ return abs(a[0] - b[0]) < epsilon && abs(a[1] - b[1]) < epsilon;
+ }
+ function interpolateLine(coordinates, m) {
+ var i = -1, n = coordinates.length, p0 = coordinates[0], p1, dx, dy, resampled = [];
+ while (++i < n) {
+ p1 = coordinates[i];
+ dx = (p1[0] - p0[0]) / m;
+ dy = (p1[1] - p0[1]) / m;
+ for (var j = 0; j < m; ++j) resampled.push([p0[0] + j * dx, p0[1] + j * dy]);
+ p0 = p1;
+ }
+ resampled.push(p1);
+ return resampled;
+ }
+ function interpolateSphere(lobes2) {
+ var coordinates = [], lobe, lambda0, phi02, phi1, lambda2, phi2, i, n = lobes2[0].length;
+ for (i = 0; i < n; ++i) {
+ lobe = lobes2[0][i];
+ lambda0 = lobe[0][0], phi02 = lobe[0][1], phi1 = lobe[1][1];
+ lambda2 = lobe[2][0], phi2 = lobe[2][1];
+ coordinates.push(interpolateLine([
+ [lambda0 + epsilon, phi02 + epsilon],
+ [lambda0 + epsilon, phi1 - epsilon],
+ [lambda2 - epsilon, phi1 - epsilon],
+ [lambda2 - epsilon, phi2 + epsilon]
+ ], 30));
+ }
+ for (i = lobes2[1].length - 1; i >= 0; --i) {
+ lobe = lobes2[1][i];
+ lambda0 = lobe[0][0], phi02 = lobe[0][1], phi1 = lobe[1][1];
+ lambda2 = lobe[2][0], phi2 = lobe[2][1];
+ coordinates.push(interpolateLine([
+ [lambda2 - epsilon, phi2 - epsilon],
+ [lambda2 - epsilon, phi1 + epsilon],
+ [lambda0 + epsilon, phi1 + epsilon],
+ [lambda0 + epsilon, phi02 - epsilon]
+ ], 30));
+ }
+ return {
+ type: "Polygon",
+ coordinates: [d3Array.merge(coordinates)]
+ };
+ }
+ function interrupt(project, lobes2, inverse2) {
+ var sphere2, bounds;
+ function forward(lambda, phi) {
+ var sign$$1 = phi < 0 ? -1 : 1, lobe = lobes2[+(phi < 0)];
+ for (var i = 0, n = lobe.length - 1; i < n && lambda > lobe[i][2][0]; ++i) ;
+ var p2 = project(lambda - lobe[i][1][0], phi);
+ p2[0] += project(lobe[i][1][0], sign$$1 * phi > sign$$1 * lobe[i][0][1] ? lobe[i][0][1] : phi)[0];
+ return p2;
+ }
+ if (inverse2) {
+ forward.invert = inverse2(forward);
+ } else if (project.invert) {
+ forward.invert = function(x, y) {
+ var bound = bounds[+(y < 0)], lobe = lobes2[+(y < 0)];
+ for (var i = 0, n = bound.length; i < n; ++i) {
+ var b = bound[i];
+ if (b[0][0] <= x && x < b[1][0] && b[0][1] <= y && y < b[1][1]) {
+ var p2 = project.invert(x - project(lobe[i][1][0], 0)[0], y);
+ p2[0] += lobe[i][1][0];
+ return pointEqual(forward(p2[0], p2[1]), [x, y]) ? p2 : null;
+ }
+ }
+ };
+ }
+ var p = d3Geo.geoProjection(forward), stream_ = p.stream;
+ p.stream = function(stream) {
+ var rotate = p.rotate(), rotateStream = stream_(stream), sphereStream = (p.rotate([0, 0]), stream_(stream));
+ p.rotate(rotate);
+ rotateStream.sphere = function() {
+ d3Geo.geoStream(sphere2, sphereStream);
+ };
+ return rotateStream;
+ };
+ p.lobes = function(_) {
+ if (!arguments.length) return lobes2.map(function(lobe) {
+ return lobe.map(function(l) {
+ return [
+ [l[0][0] * degrees3, l[0][1] * degrees3],
+ [l[1][0] * degrees3, l[1][1] * degrees3],
+ [l[2][0] * degrees3, l[2][1] * degrees3]
+ ];
+ });
+ });
+ sphere2 = interpolateSphere(_);
+ lobes2 = _.map(function(lobe) {
+ return lobe.map(function(l) {
+ return [
+ [l[0][0] * radians2, l[0][1] * radians2],
+ [l[1][0] * radians2, l[1][1] * radians2],
+ [l[2][0] * radians2, l[2][1] * radians2]
+ ];
+ });
+ });
+ bounds = lobes2.map(function(lobe) {
+ return lobe.map(function(l) {
+ var x02 = project(l[0][0], l[0][1])[0], x12 = project(l[2][0], l[2][1])[0], y02 = project(l[1][0], l[0][1])[1], y12 = project(l[1][0], l[1][1])[1], t;
+ if (y02 > y12) t = y02, y02 = y12, y12 = t;
+ return [[x02, y02], [x12, y12]];
+ });
+ });
+ return p;
+ };
+ if (lobes2 != null) p.lobes(lobes2);
+ return p;
+ }
+ var lobes = [[
+ // northern hemisphere
+ [[-180, 0], [-100, 90], [-40, 0]],
+ [[-40, 0], [30, 90], [180, 0]]
+ ], [
+ // southern hemisphere
+ [[-180, 0], [-160, -90], [-100, 0]],
+ [[-100, 0], [-60, -90], [-20, 0]],
+ [[-20, 0], [20, -90], [80, 0]],
+ [[80, 0], [140, -90], [180, 0]]
+ ]];
+ function boggs$1() {
+ return interrupt(boggsRaw, lobes).scale(160.857);
+ }
+ var lobes$1 = [[
+ // northern hemisphere
+ [[-180, 0], [-100, 90], [-40, 0]],
+ [[-40, 0], [30, 90], [180, 0]]
+ ], [
+ // southern hemisphere
+ [[-180, 0], [-160, -90], [-100, 0]],
+ [[-100, 0], [-60, -90], [-20, 0]],
+ [[-20, 0], [20, -90], [80, 0]],
+ [[80, 0], [140, -90], [180, 0]]
+ ]];
+ function homolosine$1() {
+ return interrupt(homolosineRaw, lobes$1).scale(152.63);
+ }
+ var lobes$2 = [[
+ // northern hemisphere
+ [[-180, 0], [-100, 90], [-40, 0]],
+ [[-40, 0], [30, 90], [180, 0]]
+ ], [
+ // southern hemisphere
+ [[-180, 0], [-160, -90], [-100, 0]],
+ [[-100, 0], [-60, -90], [-20, 0]],
+ [[-20, 0], [20, -90], [80, 0]],
+ [[80, 0], [140, -90], [180, 0]]
+ ]];
+ function mollweide$1() {
+ return interrupt(mollweideRaw, lobes$2).scale(169.529);
+ }
+ var lobes$3 = [[
+ // northern hemisphere
+ [[-180, 0], [-90, 90], [0, 0]],
+ [[0, 0], [90, 90], [180, 0]]
+ ], [
+ // southern hemisphere
+ [[-180, 0], [-90, -90], [0, 0]],
+ [[0, 0], [90, -90], [180, 0]]
+ ]];
+ function mollweideHemispheres() {
+ return interrupt(mollweideRaw, lobes$3).scale(169.529).rotate([20, 0]);
+ }
+ var lobes$4 = [[
+ // northern hemisphere
+ [[-180, 35], [-30, 90], [0, 35]],
+ [[0, 35], [30, 90], [180, 35]]
+ ], [
+ // southern hemisphere
+ [[-180, -10], [-102, -90], [-65, -10]],
+ [[-65, -10], [5, -90], [77, -10]],
+ [[77, -10], [103, -90], [180, -10]]
+ ]];
+ function sinuMollweide$1() {
+ return interrupt(sinuMollweideRaw, lobes$4, solve2d).rotate([-20, -55]).scale(164.263).center([0, -5.4036]);
+ }
+ var lobes$5 = [[
+ // northern hemisphere
+ [[-180, 0], [-110, 90], [-40, 0]],
+ [[-40, 0], [0, 90], [40, 0]],
+ [[40, 0], [110, 90], [180, 0]]
+ ], [
+ // southern hemisphere
+ [[-180, 0], [-110, -90], [-40, 0]],
+ [[-40, 0], [0, -90], [40, 0]],
+ [[40, 0], [110, -90], [180, 0]]
+ ]];
+ function sinusoidal$1() {
+ return interrupt(sinusoidalRaw, lobes$5).scale(152.63).rotate([-20, 0]);
+ }
+ function kavrayskiy7Raw(lambda, phi) {
+ return [3 / tau * lambda * sqrt(pi * pi / 3 - phi * phi), phi];
+ }
+ kavrayskiy7Raw.invert = function(x, y) {
+ return [tau / 3 * x / sqrt(pi * pi / 3 - y * y), y];
+ };
+ function kavrayskiy7() {
+ return d3Geo.geoProjection(kavrayskiy7Raw).scale(158.837);
+ }
+ function lagrangeRaw(n) {
+ function forward(lambda, phi) {
+ if (abs(abs(phi) - halfPi) < epsilon) return [0, phi < 0 ? -2 : 2];
+ var sinPhi = sin(phi), v = pow((1 + sinPhi) / (1 - sinPhi), n / 2), c = 0.5 * (v + 1 / v) + cos(lambda *= n);
+ return [
+ 2 * sin(lambda) / c,
+ (v - 1 / v) / c
+ ];
+ }
+ forward.invert = function(x, y) {
+ var y02 = abs(y);
+ if (abs(y02 - 2) < epsilon) return x ? null : [0, sign(y) * halfPi];
+ if (y02 > 2) return null;
+ x /= 2, y /= 2;
+ var x2 = x * x, y2 = y * y, t = 2 * y / (1 + x2 + y2);
+ t = pow((1 + t) / (1 - t), 1 / n);
+ return [
+ atan2(2 * x, 1 - x2 - y2) / n,
+ asin((t - 1) / (t + 1))
+ ];
+ };
+ return forward;
+ }
+ function lagrange() {
+ var n = 0.5, m = d3Geo.geoProjectionMutator(lagrangeRaw), p = m(n);
+ p.spacing = function(_) {
+ return arguments.length ? m(n = +_) : n;
+ };
+ return p.scale(124.75);
+ }
+ var pi_sqrt2 = pi / sqrt2;
+ function larriveeRaw(lambda, phi) {
+ return [
+ lambda * (1 + sqrt(cos(phi))) / 2,
+ phi / (cos(phi / 2) * cos(lambda / 6))
+ ];
+ }
+ larriveeRaw.invert = function(x, y) {
+ var x02 = abs(x), y02 = abs(y), lambda = epsilon, phi = halfPi;
+ if (y02 < pi_sqrt2) phi *= y02 / pi_sqrt2;
+ else lambda += 6 * acos(pi_sqrt2 / y02);
+ for (var i = 0; i < 25; i++) {
+ var sinPhi = sin(phi), sqrtcosPhi = sqrt(cos(phi)), sinPhi_2 = sin(phi / 2), cosPhi_2 = cos(phi / 2), sinLambda_6 = sin(lambda / 6), cosLambda_6 = cos(lambda / 6), f0 = 0.5 * lambda * (1 + sqrtcosPhi) - x02, f1 = phi / (cosPhi_2 * cosLambda_6) - y02, df0dPhi = sqrtcosPhi ? -0.25 * lambda * sinPhi / sqrtcosPhi : 0, df0dLambda = 0.5 * (1 + sqrtcosPhi), df1dPhi = (1 + 0.5 * phi * sinPhi_2 / cosPhi_2) / (cosPhi_2 * cosLambda_6), df1dLambda = phi / cosPhi_2 * (sinLambda_6 / 6) / (cosLambda_6 * cosLambda_6), denom = df0dPhi * df1dLambda - df1dPhi * df0dLambda, dPhi = (f0 * df1dLambda - f1 * df0dLambda) / denom, dLambda = (f1 * df0dPhi - f0 * df1dPhi) / denom;
+ phi -= dPhi;
+ lambda -= dLambda;
+ if (abs(dPhi) < epsilon && abs(dLambda) < epsilon) break;
+ }
+ return [x < 0 ? -lambda : lambda, y < 0 ? -phi : phi];
+ };
+ function larrivee() {
+ return d3Geo.geoProjection(larriveeRaw).scale(97.2672);
+ }
+ function laskowskiRaw(lambda, phi) {
+ var lambda2 = lambda * lambda, phi2 = phi * phi;
+ return [
+ lambda * (0.975534 + phi2 * (-0.119161 + lambda2 * -0.0143059 + phi2 * -0.0547009)),
+ phi * (1.00384 + lambda2 * (0.0802894 + phi2 * -0.02855 + lambda2 * 199025e-9) + phi2 * (0.0998909 + phi2 * -0.0491032))
+ ];
+ }
+ laskowskiRaw.invert = function(x, y) {
+ var lambda = sign(x) * pi, phi = y / 2, i = 50;
+ do {
+ var lambda2 = lambda * lambda, phi2 = phi * phi, lambdaPhi = lambda * phi, fx = lambda * (0.975534 + phi2 * (-0.119161 + lambda2 * -0.0143059 + phi2 * -0.0547009)) - x, fy = phi * (1.00384 + lambda2 * (0.0802894 + phi2 * -0.02855 + lambda2 * 199025e-9) + phi2 * (0.0998909 + phi2 * -0.0491032)) - y, deltaxDeltaLambda = 0.975534 - phi2 * (0.119161 + 3 * lambda2 * 0.0143059 + phi2 * 0.0547009), deltaxDeltaPhi = -lambdaPhi * (2 * 0.119161 + 4 * 0.0547009 * phi2 + 2 * 0.0143059 * lambda2), deltayDeltaLambda = lambdaPhi * (2 * 0.0802894 + 4 * 199025e-9 * lambda2 + 2 * -0.02855 * phi2), deltayDeltaPhi = 1.00384 + lambda2 * (0.0802894 + 199025e-9 * lambda2) + phi2 * (3 * (0.0998909 - 0.02855 * lambda2) - 5 * 0.0491032 * phi2), denominator = deltaxDeltaPhi * deltayDeltaLambda - deltayDeltaPhi * deltaxDeltaLambda, deltaLambda = (fy * deltaxDeltaPhi - fx * deltayDeltaPhi) / denominator, deltaPhi = (fx * deltayDeltaLambda - fy * deltaxDeltaLambda) / denominator;
+ lambda -= deltaLambda, phi -= deltaPhi;
+ } while ((abs(deltaLambda) > epsilon || abs(deltaPhi) > epsilon) && --i > 0);
+ return i && [lambda, phi];
+ };
+ function laskowski() {
+ return d3Geo.geoProjection(laskowskiRaw).scale(139.98);
+ }
+ function littrowRaw(lambda, phi) {
+ return [
+ sin(lambda) / cos(phi),
+ tan(phi) * cos(lambda)
+ ];
+ }
+ littrowRaw.invert = function(x, y) {
+ var x2 = x * x, y2 = y * y, y2_1 = y2 + 1, x2_y2_1 = x2 + y2_1, cosPhi = x ? sqrt1_2 * sqrt((x2_y2_1 - sqrt(x2_y2_1 * x2_y2_1 - 4 * x2)) / x2) : 1 / sqrt(y2_1);
+ return [
+ asin(x * cosPhi),
+ sign(y) * acos(cosPhi)
+ ];
+ };
+ function littrow() {
+ return d3Geo.geoProjection(littrowRaw).scale(144.049).clipAngle(90 - 1e-3);
+ }
+ function loximuthalRaw(phi02) {
+ var cosPhi0 = cos(phi02), tanPhi0 = tan(quarterPi + phi02 / 2);
+ function forward(lambda, phi) {
+ var y = phi - phi02, x = abs(y) < epsilon ? lambda * cosPhi0 : abs(x = quarterPi + phi / 2) < epsilon || abs(abs(x) - halfPi) < epsilon ? 0 : lambda * y / log(tan(x) / tanPhi0);
+ return [x, y];
+ }
+ forward.invert = function(x, y) {
+ var lambda, phi = y + phi02;
+ return [
+ abs(y) < epsilon ? x / cosPhi0 : abs(lambda = quarterPi + phi / 2) < epsilon || abs(abs(lambda) - halfPi) < epsilon ? 0 : x * log(tan(lambda) / tanPhi0) / y,
+ phi
+ ];
+ };
+ return forward;
+ }
+ function loximuthal() {
+ return parallel1(loximuthalRaw).parallel(40).scale(158.837);
+ }
+ function millerRaw(lambda, phi) {
+ return [lambda, 1.25 * log(tan(quarterPi + 0.4 * phi))];
+ }
+ millerRaw.invert = function(x, y) {
+ return [x, 2.5 * atan(exp(0.8 * y)) - 0.625 * pi];
+ };
+ function miller() {
+ return d3Geo.geoProjection(millerRaw).scale(108.318);
+ }
+ function modifiedStereographicRaw(C2) {
+ var m = C2.length - 1;
+ function forward(lambda, phi) {
+ var cosPhi = cos(phi), k2 = 2 / (1 + cosPhi * cos(lambda)), zr = k2 * cosPhi * sin(lambda), zi = k2 * sin(phi), i = m, w2 = C2[i], ar = w2[0], ai = w2[1], t;
+ while (--i >= 0) {
+ w2 = C2[i];
+ ar = w2[0] + zr * (t = ar) - zi * ai;
+ ai = w2[1] + zr * ai + zi * t;
+ }
+ ar = zr * (t = ar) - zi * ai;
+ ai = zr * ai + zi * t;
+ return [ar, ai];
+ }
+ forward.invert = function(x, y) {
+ var i = 20, zr = x, zi = y;
+ do {
+ var j = m, w2 = C2[j], ar = w2[0], ai = w2[1], br = 0, bi = 0, t;
+ while (--j >= 0) {
+ w2 = C2[j];
+ br = ar + zr * (t = br) - zi * bi;
+ bi = ai + zr * bi + zi * t;
+ ar = w2[0] + zr * (t = ar) - zi * ai;
+ ai = w2[1] + zr * ai + zi * t;
+ }
+ br = ar + zr * (t = br) - zi * bi;
+ bi = ai + zr * bi + zi * t;
+ ar = zr * (t = ar) - zi * ai - x;
+ ai = zr * ai + zi * t - y;
+ var denominator = br * br + bi * bi, deltar, deltai;
+ zr -= deltar = (ar * br + ai * bi) / denominator;
+ zi -= deltai = (ai * br - ar * bi) / denominator;
+ } while (abs(deltar) + abs(deltai) > epsilon * epsilon && --i > 0);
+ if (i) {
+ var rho = sqrt(zr * zr + zi * zi), c = 2 * atan(rho * 0.5), sinc = sin(c);
+ return [atan2(zr * sinc, rho * cos(c)), rho ? asin(zi * sinc / rho) : 0];
+ }
+ };
+ return forward;
+ }
+ var alaska = [[0.9972523, 0], [52513e-7, -41175e-7], [74606e-7, 48125e-7], [-0.0153783, -0.1968253], [0.0636871, -0.1408027], [0.3660976, -0.2937382]], gs48 = [[0.98879, 0], [0, 0], [-0.050909, 0], [0, 0], [0.075528, 0]], gs50 = [[0.984299, 0], [0.0211642, 37608e-7], [-0.1036018, -0.0575102], [-0.0329095, -0.0320119], [0.0499471, 0.1223335], [0.026046, 0.0899805], [7388e-7, -0.1435792], [75848e-7, -0.1334108], [-0.0216473, 0.0776645], [-0.0225161, 0.0853673]], miller$1 = [[0.9245, 0], [0, 0], [0.01943, 0]], lee = [[0.721316, 0], [0, 0], [-881625e-8, -617325e-8]];
+ function modifiedStereographicAlaska() {
+ return modifiedStereographic(alaska, [152, -64]).scale(1400).center([-160.908, 62.4864]).clipAngle(30).angle(7.8);
+ }
+ function modifiedStereographicGs48() {
+ return modifiedStereographic(gs48, [95, -38]).scale(1e3).clipAngle(55).center([-96.5563, 38.8675]);
+ }
+ function modifiedStereographicGs50() {
+ return modifiedStereographic(gs50, [120, -45]).scale(359.513).clipAngle(55).center([-117.474, 53.0628]);
+ }
+ function modifiedStereographicMiller() {
+ return modifiedStereographic(miller$1, [-20, -18]).scale(209.091).center([20, 16.7214]).clipAngle(82);
+ }
+ function modifiedStereographicLee() {
+ return modifiedStereographic(lee, [165, 10]).scale(250).clipAngle(130).center([-165, -10]);
+ }
+ function modifiedStereographic(coefficients, rotate) {
+ var p = d3Geo.geoProjection(modifiedStereographicRaw(coefficients)).rotate(rotate).clipAngle(90), r = d3Geo.geoRotation(rotate), center = p.center;
+ delete p.rotate;
+ p.center = function(_) {
+ return arguments.length ? center(r(_)) : r.invert(center());
+ };
+ return p;
+ }
+ var sqrt6 = sqrt(6), sqrt7 = sqrt(7);
+ function mtFlatPolarParabolicRaw(lambda, phi) {
+ var theta = asin(7 * sin(phi) / (3 * sqrt6));
+ return [
+ sqrt6 * lambda * (2 * cos(2 * theta / 3) - 1) / sqrt7,
+ 9 * sin(theta / 3) / sqrt7
+ ];
+ }
+ mtFlatPolarParabolicRaw.invert = function(x, y) {
+ var theta = 3 * asin(y * sqrt7 / 9);
+ return [
+ x * sqrt7 / (sqrt6 * (2 * cos(2 * theta / 3) - 1)),
+ asin(sin(theta) * 3 * sqrt6 / 7)
+ ];
+ };
+ function mtFlatPolarParabolic() {
+ return d3Geo.geoProjection(mtFlatPolarParabolicRaw).scale(164.859);
+ }
+ function mtFlatPolarQuarticRaw(lambda, phi) {
+ var k2 = (1 + sqrt1_2) * sin(phi), theta = phi;
+ for (var i = 0, delta; i < 25; i++) {
+ theta -= delta = (sin(theta / 2) + sin(theta) - k2) / (0.5 * cos(theta / 2) + cos(theta));
+ if (abs(delta) < epsilon) break;
+ }
+ return [
+ lambda * (1 + 2 * cos(theta) / cos(theta / 2)) / (3 * sqrt2),
+ 2 * sqrt(3) * sin(theta / 2) / sqrt(2 + sqrt2)
+ ];
+ }
+ mtFlatPolarQuarticRaw.invert = function(x, y) {
+ var sinTheta_2 = y * sqrt(2 + sqrt2) / (2 * sqrt(3)), theta = 2 * asin(sinTheta_2);
+ return [
+ 3 * sqrt2 * x / (1 + 2 * cos(theta) / cos(theta / 2)),
+ asin((sinTheta_2 + sin(theta)) / (1 + sqrt1_2))
+ ];
+ };
+ function mtFlatPolarQuartic() {
+ return d3Geo.geoProjection(mtFlatPolarQuarticRaw).scale(188.209);
+ }
+ function mtFlatPolarSinusoidalRaw(lambda, phi) {
+ var A3 = sqrt(6 / (4 + pi)), k2 = (1 + pi / 4) * sin(phi), theta = phi / 2;
+ for (var i = 0, delta; i < 25; i++) {
+ theta -= delta = (theta / 2 + sin(theta) - k2) / (0.5 + cos(theta));
+ if (abs(delta) < epsilon) break;
+ }
+ return [
+ A3 * (0.5 + cos(theta)) * lambda / 1.5,
+ A3 * theta
+ ];
+ }
+ mtFlatPolarSinusoidalRaw.invert = function(x, y) {
+ var A3 = sqrt(6 / (4 + pi)), theta = y / A3;
+ if (abs(abs(theta) - halfPi) < epsilon) theta = theta < 0 ? -halfPi : halfPi;
+ return [
+ 1.5 * x / (A3 * (0.5 + cos(theta))),
+ asin((theta / 2 + sin(theta)) / (1 + pi / 4))
+ ];
+ };
+ function mtFlatPolarSinusoidal() {
+ return d3Geo.geoProjection(mtFlatPolarSinusoidalRaw).scale(166.518);
+ }
+ function naturalEarth2Raw(lambda, phi) {
+ var phi2 = phi * phi, phi4 = phi2 * phi2, phi6 = phi2 * phi4;
+ return [
+ lambda * (0.84719 - 0.13063 * phi2 + phi6 * phi6 * (-0.04515 + 0.05494 * phi2 - 0.02326 * phi4 + 331e-5 * phi6)),
+ phi * (1.01183 + phi4 * phi4 * (-0.02625 + 0.01926 * phi2 - 396e-5 * phi4))
+ ];
+ }
+ naturalEarth2Raw.invert = function(x, y) {
+ var phi = y, i = 25, delta, phi2, phi4, phi6;
+ do {
+ phi2 = phi * phi;
+ phi4 = phi2 * phi2;
+ phi -= delta = (phi * (1.01183 + phi4 * phi4 * (-0.02625 + 0.01926 * phi2 - 396e-5 * phi4)) - y) / (1.01183 + phi4 * phi4 * (9 * -0.02625 + 11 * 0.01926 * phi2 + 13 * -396e-5 * phi4));
+ } while (abs(delta) > epsilon22 && --i > 0);
+ phi2 = phi * phi;
+ phi4 = phi2 * phi2;
+ phi6 = phi2 * phi4;
+ return [
+ x / (0.84719 - 0.13063 * phi2 + phi6 * phi6 * (-0.04515 + 0.05494 * phi2 - 0.02326 * phi4 + 331e-5 * phi6)),
+ phi
+ ];
+ };
+ function naturalEarth2() {
+ return d3Geo.geoProjection(naturalEarth2Raw).scale(175.295);
+ }
+ function nellHammerRaw(lambda, phi) {
+ return [
+ lambda * (1 + cos(phi)) / 2,
+ 2 * (phi - tan(phi / 2))
+ ];
+ }
+ nellHammerRaw.invert = function(x, y) {
+ var p = y / 2;
+ for (var i = 0, delta = Infinity; i < 10 && abs(delta) > epsilon; ++i) {
+ var c = cos(y / 2);
+ y -= delta = (y - tan(y / 2) - p) / (1 - 0.5 / (c * c));
+ }
+ return [
+ 2 * x / (1 + cos(y)),
+ y
+ ];
+ };
+ function nellHammer() {
+ return d3Geo.geoProjection(nellHammerRaw).scale(152.63);
+ }
+ var lobes$6 = [[
+ // northern hemisphere
+ [[-180, 0], [-90, 90], [0, 0]],
+ [[0, 0], [90, 90], [180, 0]]
+ ], [
+ // southern hemisphere
+ [[-180, 0], [-90, -90], [0, 0]],
+ [[0, 0], [90, -90], [180, 0]]
+ ]];
+ function quarticAuthalic() {
+ return interrupt(hammerRaw(Infinity), lobes$6).rotate([20, 0]).scale(152.63);
+ }
+ function nicolosiRaw(lambda, phi) {
+ var sinPhi = sin(phi), q = cos(phi), s = sign(lambda);
+ if (lambda === 0 || abs(phi) === halfPi) return [0, phi];
+ else if (phi === 0) return [lambda, 0];
+ else if (abs(lambda) === halfPi) return [lambda * q, halfPi * sinPhi];
+ var b = pi / (2 * lambda) - 2 * lambda / pi, c = 2 * phi / pi, d = (1 - c * c) / (sinPhi - c);
+ var b2 = b * b, d2 = d * d, b2d2 = 1 + b2 / d2, d2b2 = 1 + d2 / b2;
+ var M = (b * sinPhi / d - b / 2) / b2d2, N = (d2 * sinPhi / b2 + d / 2) / d2b2, m = M * M + q * q / b2d2, n = N * N - (d2 * sinPhi * sinPhi / b2 + d * sinPhi - 1) / d2b2;
+ return [
+ halfPi * (M + sqrt(m) * s),
+ halfPi * (N + sqrt(n < 0 ? 0 : n) * sign(-phi * b) * s)
+ ];
+ }
+ nicolosiRaw.invert = function(x, y) {
+ x /= halfPi;
+ y /= halfPi;
+ var x2 = x * x, y2 = y * y, x2y2 = x2 + y2, pi2 = pi * pi;
+ return [
+ x ? (x2y2 - 1 + sqrt((1 - x2y2) * (1 - x2y2) + 4 * x2)) / (2 * x) * halfPi : 0,
+ solve(function(phi) {
+ return x2y2 * (pi * sin(phi) - 2 * phi) * pi + 4 * phi * phi * (y - sin(phi)) + 2 * pi * phi - pi2 * y;
+ }, 0)
+ ];
+ };
+ function nicolosi() {
+ return d3Geo.geoProjection(nicolosiRaw).scale(127.267);
+ }
+ var pattersonK1 = 1.0148, pattersonK2 = 0.23185, pattersonK3 = -0.14499, pattersonK4 = 0.02406, pattersonC1 = pattersonK1, pattersonC2 = 5 * pattersonK2, pattersonC3 = 7 * pattersonK3, pattersonC4 = 9 * pattersonK4, pattersonYmax = 1.790857183;
+ function pattersonRaw(lambda, phi) {
+ var phi2 = phi * phi;
+ return [
+ lambda,
+ phi * (pattersonK1 + phi2 * phi2 * (pattersonK2 + phi2 * (pattersonK3 + pattersonK4 * phi2)))
+ ];
+ }
+ pattersonRaw.invert = function(x, y) {
+ if (y > pattersonYmax) y = pattersonYmax;
+ else if (y < -pattersonYmax) y = -pattersonYmax;
+ var yc = y, delta;
+ do {
+ var y2 = yc * yc;
+ yc -= delta = (yc * (pattersonK1 + y2 * y2 * (pattersonK2 + y2 * (pattersonK3 + pattersonK4 * y2))) - y) / (pattersonC1 + y2 * y2 * (pattersonC2 + y2 * (pattersonC3 + pattersonC4 * y2)));
+ } while (abs(delta) > epsilon);
+ return [x, yc];
+ };
+ function patterson() {
+ return d3Geo.geoProjection(pattersonRaw).scale(139.319);
+ }
+ function polyconicRaw(lambda, phi) {
+ if (abs(phi) < epsilon) return [lambda, 0];
+ var tanPhi = tan(phi), k2 = lambda * sin(phi);
+ return [
+ sin(k2) / tanPhi,
+ phi + (1 - cos(k2)) / tanPhi
+ ];
+ }
+ polyconicRaw.invert = function(x, y) {
+ if (abs(y) < epsilon) return [x, 0];
+ var k2 = x * x + y * y, phi = y * 0.5, i = 10, delta;
+ do {
+ var tanPhi = tan(phi), secPhi = 1 / cos(phi), j = k2 - 2 * y * phi + phi * phi;
+ phi -= delta = (tanPhi * j + 2 * (phi - y)) / (2 + j * secPhi * secPhi + 2 * (phi - y) * tanPhi);
+ } while (abs(delta) > epsilon && --i > 0);
+ tanPhi = tan(phi);
+ return [
+ (abs(y) < abs(phi + 1 / tanPhi) ? asin(x * tanPhi) : sign(y) * sign(x) * (acos(abs(x * tanPhi)) + halfPi)) / sin(phi),
+ phi
+ ];
+ };
+ function polyconic() {
+ return d3Geo.geoProjection(polyconicRaw).scale(103.74);
+ }
+ function matrix(a, b) {
+ var u = subtract(a[1], a[0]), v = subtract(b[1], b[0]), phi = angle$1(u, v), s = length(u) / length(v);
+ return multiply([
+ 1,
+ 0,
+ a[0][0],
+ 0,
+ 1,
+ a[0][1]
+ ], multiply([
+ s,
+ 0,
+ 0,
+ 0,
+ s,
+ 0
+ ], multiply([
+ cos(phi),
+ sin(phi),
+ 0,
+ -sin(phi),
+ cos(phi),
+ 0
+ ], [
+ 1,
+ 0,
+ -b[0][0],
+ 0,
+ 1,
+ -b[0][1]
+ ])));
+ }
+ function inverse(m) {
+ var k2 = 1 / (m[0] * m[4] - m[1] * m[3]);
+ return [
+ k2 * m[4],
+ -k2 * m[1],
+ k2 * (m[1] * m[5] - m[2] * m[4]),
+ -k2 * m[3],
+ k2 * m[0],
+ k2 * (m[2] * m[3] - m[0] * m[5])
+ ];
+ }
+ function multiply(a, b) {
+ return [
+ a[0] * b[0] + a[1] * b[3],
+ a[0] * b[1] + a[1] * b[4],
+ a[0] * b[2] + a[1] * b[5] + a[2],
+ a[3] * b[0] + a[4] * b[3],
+ a[3] * b[1] + a[4] * b[4],
+ a[3] * b[2] + a[4] * b[5] + a[5]
+ ];
+ }
+ function subtract(a, b) {
+ return [a[0] - b[0], a[1] - b[1]];
+ }
+ function length(v) {
+ return sqrt(v[0] * v[0] + v[1] * v[1]);
+ }
+ function angle$1(a, b) {
+ return atan2(a[0] * b[1] - a[1] * b[0], a[0] * b[0] + a[1] * b[1]);
+ }
+ function polyhedral(root, face, r) {
+ recurse(root, { transform: null });
+ function recurse(node, parent) {
+ node.edges = faceEdges(node.face);
+ if (parent.face) {
+ var shared = node.shared = sharedEdge(node.face, parent.face), m = matrix(shared.map(parent.project), shared.map(node.project));
+ node.transform = parent.transform ? multiply(parent.transform, m) : m;
+ var edges = parent.edges;
+ for (var i = 0, n = edges.length; i < n; ++i) {
+ if (pointEqual$1(shared[0], edges[i][1]) && pointEqual$1(shared[1], edges[i][0])) edges[i] = node;
+ if (pointEqual$1(shared[0], edges[i][0]) && pointEqual$1(shared[1], edges[i][1])) edges[i] = node;
+ }
+ edges = node.edges;
+ for (i = 0, n = edges.length; i < n; ++i) {
+ if (pointEqual$1(shared[0], edges[i][0]) && pointEqual$1(shared[1], edges[i][1])) edges[i] = parent;
+ if (pointEqual$1(shared[0], edges[i][1]) && pointEqual$1(shared[1], edges[i][0])) edges[i] = parent;
+ }
+ } else {
+ node.transform = parent.transform;
+ }
+ if (node.children) {
+ node.children.forEach(function(child) {
+ recurse(child, node);
+ });
+ }
+ return node;
+ }
+ function forward(lambda, phi) {
+ var node = face(lambda, phi), point = node.project([lambda * degrees3, phi * degrees3]), t;
+ if (t = node.transform) {
+ return [
+ t[0] * point[0] + t[1] * point[1] + t[2],
+ -(t[3] * point[0] + t[4] * point[1] + t[5])
+ ];
+ }
+ point[1] = -point[1];
+ return point;
+ }
+ if (hasInverse(root)) forward.invert = function(x, y) {
+ var coordinates = faceInvert(root, [x, -y]);
+ return coordinates && (coordinates[0] *= radians2, coordinates[1] *= radians2, coordinates);
+ };
+ function faceInvert(node, coordinates) {
+ var invert = node.project.invert, t = node.transform, point = coordinates;
+ if (t) {
+ t = inverse(t);
+ point = [
+ t[0] * point[0] + t[1] * point[1] + t[2],
+ t[3] * point[0] + t[4] * point[1] + t[5]
+ ];
+ }
+ if (invert && node === faceDegrees(p = invert(point))) return p;
+ var p, children = node.children;
+ for (var i = 0, n = children && children.length; i < n; ++i) {
+ if (p = faceInvert(children[i], coordinates)) return p;
+ }
+ }
+ function faceDegrees(coordinates) {
+ return face(coordinates[0] * radians2, coordinates[1] * radians2);
+ }
+ var proj = d3Geo.geoProjection(forward), stream_ = proj.stream;
+ proj.stream = function(stream) {
+ var rotate = proj.rotate(), rotateStream = stream_(stream), sphereStream = (proj.rotate([0, 0]), stream_(stream));
+ proj.rotate(rotate);
+ rotateStream.sphere = function() {
+ sphereStream.polygonStart();
+ sphereStream.lineStart();
+ outline(sphereStream, root);
+ sphereStream.lineEnd();
+ sphereStream.polygonEnd();
+ };
+ return rotateStream;
+ };
+ return proj.angle(r == null ? -30 : r * degrees3);
+ }
+ function outline(stream, node, parent) {
+ var point, edges = node.edges, n = edges.length, edge, multiPoint = { type: "MultiPoint", coordinates: node.face }, notPoles = node.face.filter(function(d) {
+ return abs(d[1]) !== 90;
+ }), b = d3Geo.geoBounds({ type: "MultiPoint", coordinates: notPoles }), inside = false, j = -1, dx = b[1][0] - b[0][0];
+ var c = dx === 180 || dx === 360 ? [(b[0][0] + b[1][0]) / 2, (b[0][1] + b[1][1]) / 2] : d3Geo.geoCentroid(multiPoint);
+ if (parent) while (++j < n) {
+ if (edges[j] === parent) break;
+ }
+ ++j;
+ for (var i = 0; i < n; ++i) {
+ edge = edges[(i + j) % n];
+ if (Array.isArray(edge)) {
+ if (!inside) {
+ stream.point((point = d3Geo.geoInterpolate(edge[0], c)(epsilon))[0], point[1]);
+ inside = true;
+ }
+ stream.point((point = d3Geo.geoInterpolate(edge[1], c)(epsilon))[0], point[1]);
+ } else {
+ inside = false;
+ if (edge !== parent) outline(stream, edge, node);
+ }
+ }
+ }
+ function pointEqual$1(a, b) {
+ return a && b && a[0] === b[0] && a[1] === b[1];
+ }
+ function sharedEdge(a, b) {
+ var x, y, n = a.length, found = null;
+ for (var i = 0; i < n; ++i) {
+ x = a[i];
+ for (var j = b.length; --j >= 0; ) {
+ y = b[j];
+ if (x[0] === y[0] && x[1] === y[1]) {
+ if (found) return [found, x];
+ found = x;
+ }
+ }
+ }
+ }
+ function faceEdges(face) {
+ var n = face.length, edges = [];
+ for (var a = face[n - 1], i = 0; i < n; ++i) edges.push([a, a = face[i]]);
+ return edges;
+ }
+ function hasInverse(node) {
+ return node.project.invert || node.children && node.children.some(hasInverse);
+ }
+ var octahedron = [
+ [0, 90],
+ [-90, 0],
+ [0, 0],
+ [90, 0],
+ [180, 0],
+ [0, -90]
+ ];
+ var octahedron$1 = [
+ [0, 2, 1],
+ [0, 3, 2],
+ [5, 1, 2],
+ [5, 2, 3],
+ [0, 1, 4],
+ [0, 4, 3],
+ [5, 4, 1],
+ [5, 3, 4]
+ ].map(function(face) {
+ return face.map(function(i) {
+ return octahedron[i];
+ });
+ });
+ function butterfly(faceProjection) {
+ faceProjection = faceProjection || function(face) {
+ var c = d3Geo.geoCentroid({ type: "MultiPoint", coordinates: face });
+ return d3Geo.geoGnomonic().scale(1).translate([0, 0]).rotate([-c[0], -c[1]]);
+ };
+ var faces = octahedron$1.map(function(face) {
+ return { face, project: faceProjection(face) };
+ });
+ [-1, 0, 0, 1, 0, 1, 4, 5].forEach(function(d, i) {
+ var node = faces[d];
+ node && (node.children || (node.children = [])).push(faces[i]);
+ });
+ return polyhedral(faces[0], function(lambda, phi) {
+ return faces[lambda < -pi / 2 ? phi < 0 ? 6 : 4 : lambda < 0 ? phi < 0 ? 2 : 0 : lambda < pi / 2 ? phi < 0 ? 3 : 1 : phi < 0 ? 7 : 5];
+ }).angle(-30).scale(101.858).center([0, 45]);
+ }
+ var kx = 2 / sqrt(3);
+ function collignonK(a, b) {
+ var p = collignonRaw(a, b);
+ return [p[0] * kx, p[1]];
+ }
+ collignonK.invert = function(x, y) {
+ return collignonRaw.invert(x / kx, y);
+ };
+ function collignon$1(faceProjection) {
+ faceProjection = faceProjection || function(face) {
+ var c = d3Geo.geoCentroid({ type: "MultiPoint", coordinates: face });
+ return d3Geo.geoProjection(collignonK).translate([0, 0]).scale(1).rotate(c[1] > 0 ? [-c[0], 0] : [180 - c[0], 180]);
+ };
+ var faces = octahedron$1.map(function(face) {
+ return { face, project: faceProjection(face) };
+ });
+ [-1, 0, 0, 1, 0, 1, 4, 5].forEach(function(d, i) {
+ var node = faces[d];
+ node && (node.children || (node.children = [])).push(faces[i]);
+ });
+ return polyhedral(faces[0], function(lambda, phi) {
+ return faces[lambda < -pi / 2 ? phi < 0 ? 6 : 4 : lambda < 0 ? phi < 0 ? 2 : 0 : lambda < pi / 2 ? phi < 0 ? 3 : 1 : phi < 0 ? 7 : 5];
+ }).angle(-30).scale(121.906).center([0, 48.5904]);
+ }
+ function waterman(faceProjection) {
+ faceProjection = faceProjection || function(face2) {
+ var c = face2.length === 6 ? d3Geo.geoCentroid({ type: "MultiPoint", coordinates: face2 }) : face2[0];
+ return d3Geo.geoGnomonic().scale(1).translate([0, 0]).rotate([-c[0], -c[1]]);
+ };
+ var w5 = octahedron$1.map(function(face2) {
+ var xyz = face2.map(cartesian), n = xyz.length, a = xyz[n - 1], b, hexagon = [];
+ for (var i = 0; i < n; ++i) {
+ b = xyz[i];
+ hexagon.push(spherical([
+ a[0] * 0.9486832980505138 + b[0] * 0.31622776601683794,
+ a[1] * 0.9486832980505138 + b[1] * 0.31622776601683794,
+ a[2] * 0.9486832980505138 + b[2] * 0.31622776601683794
+ ]), spherical([
+ b[0] * 0.9486832980505138 + a[0] * 0.31622776601683794,
+ b[1] * 0.9486832980505138 + a[1] * 0.31622776601683794,
+ b[2] * 0.9486832980505138 + a[2] * 0.31622776601683794
+ ]));
+ a = b;
+ }
+ return hexagon;
+ });
+ var cornerNormals = [];
+ var parents = [-1, 0, 0, 1, 0, 1, 4, 5];
+ w5.forEach(function(hexagon, j) {
+ var face2 = octahedron$1[j], n = face2.length, normals = cornerNormals[j] = [];
+ for (var i = 0; i < n; ++i) {
+ w5.push([
+ face2[i],
+ hexagon[(i * 2 + 2) % (2 * n)],
+ hexagon[(i * 2 + 1) % (2 * n)]
+ ]);
+ parents.push(j);
+ normals.push(cross(
+ cartesian(hexagon[(i * 2 + 2) % (2 * n)]),
+ cartesian(hexagon[(i * 2 + 1) % (2 * n)])
+ ));
+ }
+ });
+ var faces = w5.map(function(face2) {
+ return {
+ project: faceProjection(face2),
+ face: face2
+ };
+ });
+ parents.forEach(function(d, i) {
+ var parent = faces[d];
+ parent && (parent.children || (parent.children = [])).push(faces[i]);
+ });
+ function face(lambda, phi) {
+ var cosphi = cos(phi), p = [cosphi * cos(lambda), cosphi * sin(lambda), sin(phi)];
+ var hexagon = lambda < -pi / 2 ? phi < 0 ? 6 : 4 : lambda < 0 ? phi < 0 ? 2 : 0 : lambda < pi / 2 ? phi < 0 ? 3 : 1 : phi < 0 ? 7 : 5;
+ var n = cornerNormals[hexagon];
+ return faces[dot(n[0], p) < 0 ? 8 + 3 * hexagon : dot(n[1], p) < 0 ? 8 + 3 * hexagon + 1 : dot(n[2], p) < 0 ? 8 + 3 * hexagon + 2 : hexagon];
+ }
+ return polyhedral(faces[0], face).angle(-30).scale(110.625).center([0, 45]);
+ }
+ function dot(a, b) {
+ for (var i = 0, n = a.length, s = 0; i < n; ++i) s += a[i] * b[i];
+ return s;
+ }
+ function cross(a, b) {
+ return [
+ a[1] * b[2] - a[2] * b[1],
+ a[2] * b[0] - a[0] * b[2],
+ a[0] * b[1] - a[1] * b[0]
+ ];
+ }
+ function spherical(cartesian2) {
+ return [
+ atan2(cartesian2[1], cartesian2[0]) * degrees3,
+ asin(max(-1, min(1, cartesian2[2]))) * degrees3
+ ];
+ }
+ function cartesian(coordinates) {
+ var lambda = coordinates[0] * radians2, phi = coordinates[1] * radians2, cosphi = cos(phi);
+ return [
+ cosphi * cos(lambda),
+ cosphi * sin(lambda),
+ sin(phi)
+ ];
+ }
+ function noop() {
+ }
+ function clockwise(ring) {
+ if ((n = ring.length) < 4) return false;
+ var i = 0, n, area = ring[n - 1][1] * ring[0][0] - ring[n - 1][0] * ring[0][1];
+ while (++i < n) area += ring[i - 1][1] * ring[i][0] - ring[i - 1][0] * ring[i][1];
+ return area <= 0;
+ }
+ function contains(ring, point) {
+ var x = point[0], y = point[1], contains2 = false;
+ for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) {
+ var pi2 = ring[i], xi = pi2[0], yi = pi2[1], pj = ring[j], xj = pj[0], yj = pj[1];
+ if (yi > y ^ yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) contains2 = !contains2;
+ }
+ return contains2;
+ }
+ function index(object, projection) {
+ var stream = projection.stream, project;
+ if (!stream) throw new Error("invalid projection");
+ switch (object && object.type) {
+ case "Feature":
+ project = projectFeature;
+ break;
+ case "FeatureCollection":
+ project = projectFeatureCollection;
+ break;
+ default:
+ project = projectGeometry;
+ break;
+ }
+ return project(object, stream);
+ }
+ function projectFeatureCollection(o, stream) {
+ return {
+ type: "FeatureCollection",
+ features: o.features.map(function(f) {
+ return projectFeature(f, stream);
+ })
+ };
+ }
+ function projectFeature(o, stream) {
+ return {
+ type: "Feature",
+ id: o.id,
+ properties: o.properties,
+ geometry: projectGeometry(o.geometry, stream)
+ };
+ }
+ function projectGeometryCollection(o, stream) {
+ return {
+ type: "GeometryCollection",
+ geometries: o.geometries.map(function(o2) {
+ return projectGeometry(o2, stream);
+ })
+ };
+ }
+ function projectGeometry(o, stream) {
+ if (!o) return null;
+ if (o.type === "GeometryCollection") return projectGeometryCollection(o, stream);
+ var sink;
+ switch (o.type) {
+ case "Point":
+ sink = sinkPoint;
+ break;
+ case "MultiPoint":
+ sink = sinkPoint;
+ break;
+ case "LineString":
+ sink = sinkLine;
+ break;
+ case "MultiLineString":
+ sink = sinkLine;
+ break;
+ case "Polygon":
+ sink = sinkPolygon;
+ break;
+ case "MultiPolygon":
+ sink = sinkPolygon;
+ break;
+ case "Sphere":
+ sink = sinkPolygon;
+ break;
+ default:
+ return null;
+ }
+ d3Geo.geoStream(o, stream(sink));
+ return sink.result();
+ }
+ var points = [], lines = [];
+ var sinkPoint = {
+ point: function(x, y) {
+ points.push([x, y]);
+ },
+ result: function() {
+ var result = !points.length ? null : points.length < 2 ? { type: "Point", coordinates: points[0] } : { type: "MultiPoint", coordinates: points };
+ points = [];
+ return result;
+ }
+ };
+ var sinkLine = {
+ lineStart: noop,
+ point: function(x, y) {
+ points.push([x, y]);
+ },
+ lineEnd: function() {
+ if (points.length) lines.push(points), points = [];
+ },
+ result: function() {
+ var result = !lines.length ? null : lines.length < 2 ? { type: "LineString", coordinates: lines[0] } : { type: "MultiLineString", coordinates: lines };
+ lines = [];
+ return result;
+ }
+ };
+ var sinkPolygon = {
+ polygonStart: noop,
+ lineStart: noop,
+ point: function(x, y) {
+ points.push([x, y]);
+ },
+ lineEnd: function() {
+ var n = points.length;
+ if (n) {
+ do
+ points.push(points[0].slice());
+ while (++n < 4);
+ lines.push(points), points = [];
+ }
+ },
+ polygonEnd: noop,
+ result: function() {
+ if (!lines.length) return null;
+ var polygons = [], holes = [];
+ lines.forEach(function(ring) {
+ if (clockwise(ring)) polygons.push([ring]);
+ else holes.push(ring);
+ });
+ holes.forEach(function(hole) {
+ var point = hole[0];
+ polygons.some(function(polygon) {
+ if (contains(polygon[0], point)) {
+ polygon.push(hole);
+ return true;
+ }
+ }) || polygons.push([hole]);
+ });
+ lines = [];
+ return !polygons.length ? null : polygons.length > 1 ? { type: "MultiPolygon", coordinates: polygons } : { type: "Polygon", coordinates: polygons[0] };
+ }
+ };
+ function quincuncial(project) {
+ var dx = project(halfPi, 0)[0] - project(-halfPi, 0)[0];
+ function projectQuincuncial(lambda, phi) {
+ var t = abs(lambda) < halfPi, p = project(t ? lambda : lambda > 0 ? lambda - pi : lambda + pi, phi), x = (p[0] - p[1]) * sqrt1_2, y = (p[0] + p[1]) * sqrt1_2;
+ if (t) return [x, y];
+ var d = dx * sqrt1_2, s = x > 0 ^ y > 0 ? -1 : 1;
+ return [s * x - sign(y) * d, s * y - sign(x) * d];
+ }
+ if (project.invert) projectQuincuncial.invert = function(x02, y02) {
+ var x = (x02 + y02) * sqrt1_2, y = (y02 - x02) * sqrt1_2, t = abs(x) < 0.5 * dx && abs(y) < 0.5 * dx;
+ if (!t) {
+ var d = dx * sqrt1_2, s = x > 0 ^ y > 0 ? -1 : 1, x12 = -s * x02 + (y > 0 ? 1 : -1) * d, y12 = -s * y02 + (x > 0 ? 1 : -1) * d;
+ x = (-x12 - y12) * sqrt1_2;
+ y = (x12 - y12) * sqrt1_2;
+ }
+ var p = project.invert(x, y);
+ if (!t) p[0] += x > 0 ? pi : -pi;
+ return p;
+ };
+ return d3Geo.geoProjection(projectQuincuncial).rotate([-90, -90, 45]).clipAngle(180 - 1e-3);
+ }
+ function gringorten$1() {
+ return quincuncial(gringortenRaw).scale(176.423);
+ }
+ function peirce() {
+ return quincuncial(guyouRaw).scale(111.48);
+ }
+ function quantize(input, digits) {
+ if (!(0 <= (digits = +digits) && digits <= 20)) throw new Error("invalid digits");
+ function quantizePoint(input2) {
+ var n = input2.length, i = 2, output2 = new Array(n);
+ output2[0] = +input2[0].toFixed(digits);
+ output2[1] = +input2[1].toFixed(digits);
+ while (i < n) output2[i] = input2[i], ++i;
+ return output2;
+ }
+ function quantizePoints(input2) {
+ return input2.map(quantizePoint);
+ }
+ function quantizePointsNoDuplicates(input2) {
+ var point0 = quantizePoint(input2[0]);
+ var output2 = [point0];
+ for (var i = 1; i < input2.length; i++) {
+ var point = quantizePoint(input2[i]);
+ if (point.length > 2 || point[0] != point0[0] || point[1] != point0[1]) {
+ output2.push(point);
+ point0 = point;
+ }
+ }
+ if (output2.length === 1 && input2.length > 1) {
+ output2.push(quantizePoint(input2[input2.length - 1]));
+ }
+ return output2;
+ }
+ function quantizePolygon(input2) {
+ return input2.map(quantizePointsNoDuplicates);
+ }
+ function quantizeGeometry(input2) {
+ if (input2 == null) return input2;
+ var output2;
+ switch (input2.type) {
+ case "GeometryCollection":
+ output2 = { type: "GeometryCollection", geometries: input2.geometries.map(quantizeGeometry) };
+ break;
+ case "Point":
+ output2 = { type: "Point", coordinates: quantizePoint(input2.coordinates) };
+ break;
+ case "MultiPoint":
+ output2 = { type: input2.type, coordinates: quantizePoints(input2.coordinates) };
+ break;
+ case "LineString":
+ output2 = { type: input2.type, coordinates: quantizePointsNoDuplicates(input2.coordinates) };
+ break;
+ case "MultiLineString":
+ case "Polygon":
+ output2 = { type: input2.type, coordinates: quantizePolygon(input2.coordinates) };
+ break;
+ case "MultiPolygon":
+ output2 = { type: "MultiPolygon", coordinates: input2.coordinates.map(quantizePolygon) };
+ break;
+ default:
+ return input2;
+ }
+ if (input2.bbox != null) output2.bbox = input2.bbox;
+ return output2;
+ }
+ function quantizeFeature(input2) {
+ var output2 = { type: "Feature", properties: input2.properties, geometry: quantizeGeometry(input2.geometry) };
+ if (input2.id != null) output2.id = input2.id;
+ if (input2.bbox != null) output2.bbox = input2.bbox;
+ return output2;
+ }
+ if (input != null) switch (input.type) {
+ case "Feature":
+ return quantizeFeature(input);
+ case "FeatureCollection": {
+ var output = { type: "FeatureCollection", features: input.features.map(quantizeFeature) };
+ if (input.bbox != null) output.bbox = input.bbox;
+ return output;
+ }
+ default:
+ return quantizeGeometry(input);
+ }
+ return input;
+ }
+ function rectangularPolyconicRaw(phi02) {
+ var sinPhi0 = sin(phi02);
+ function forward(lambda, phi) {
+ var A3 = sinPhi0 ? tan(lambda * sinPhi0 / 2) / sinPhi0 : lambda / 2;
+ if (!phi) return [2 * A3, -phi02];
+ var E2 = 2 * atan(A3 * sin(phi)), cotPhi = 1 / tan(phi);
+ return [
+ sin(E2) * cotPhi,
+ phi + (1 - cos(E2)) * cotPhi - phi02
+ ];
+ }
+ forward.invert = function(x, y) {
+ if (abs(y += phi02) < epsilon) return [sinPhi0 ? 2 * atan(sinPhi0 * x / 2) / sinPhi0 : x, 0];
+ var k2 = x * x + y * y, phi = 0, i = 10, delta;
+ do {
+ var tanPhi = tan(phi), secPhi = 1 / cos(phi), j = k2 - 2 * y * phi + phi * phi;
+ phi -= delta = (tanPhi * j + 2 * (phi - y)) / (2 + j * secPhi * secPhi + 2 * (phi - y) * tanPhi);
+ } while (abs(delta) > epsilon && --i > 0);
+ var E2 = x * (tanPhi = tan(phi)), A3 = tan(abs(y) < abs(phi + 1 / tanPhi) ? asin(E2) * 0.5 : acos(E2) * 0.5 + pi / 4) / sin(phi);
+ return [
+ sinPhi0 ? 2 * atan(sinPhi0 * A3) / sinPhi0 : 2 * A3,
+ phi
+ ];
+ };
+ return forward;
+ }
+ function rectangularPolyconic() {
+ return parallel1(rectangularPolyconicRaw).scale(131.215);
+ }
+ var K$1 = [
+ [0.9986, -0.062],
+ [1, 0],
+ [0.9986, 0.062],
+ [0.9954, 0.124],
+ [0.99, 0.186],
+ [0.9822, 0.248],
+ [0.973, 0.31],
+ [0.96, 0.372],
+ [0.9427, 0.434],
+ [0.9216, 0.4958],
+ [0.8962, 0.5571],
+ [0.8679, 0.6176],
+ [0.835, 0.6769],
+ [0.7986, 0.7346],
+ [0.7597, 0.7903],
+ [0.7186, 0.8435],
+ [0.6732, 0.8936],
+ [0.6213, 0.9394],
+ [0.5722, 0.9761],
+ [0.5322, 1]
+ ];
+ K$1.forEach(function(d) {
+ d[1] *= 1.0144;
+ });
+ function robinsonRaw(lambda, phi) {
+ var i = min(18, abs(phi) * 36 / pi), i0 = floor(i), di = i - i0, ax = (k2 = K$1[i0])[0], ay = k2[1], bx = (k2 = K$1[++i0])[0], by = k2[1], cx = (k2 = K$1[min(19, ++i0)])[0], cy = k2[1], k2;
+ return [
+ lambda * (bx + di * (cx - ax) / 2 + di * di * (cx - 2 * bx + ax) / 2),
+ (phi > 0 ? halfPi : -halfPi) * (by + di * (cy - ay) / 2 + di * di * (cy - 2 * by + ay) / 2)
+ ];
+ }
+ robinsonRaw.invert = function(x, y) {
+ var yy = y / halfPi, phi = yy * 90, i = min(18, abs(phi / 5)), i0 = max(0, floor(i));
+ do {
+ var ay = K$1[i0][1], by = K$1[i0 + 1][1], cy = K$1[min(19, i0 + 2)][1], u = cy - ay, v = cy - 2 * by + ay, t = 2 * (abs(yy) - by) / u, c = v / u, di = t * (1 - c * t * (1 - 2 * c * t));
+ if (di >= 0 || i0 === 1) {
+ phi = (y >= 0 ? 5 : -5) * (di + i);
+ var j = 50, delta;
+ do {
+ i = min(18, abs(phi) / 5);
+ i0 = floor(i);
+ di = i - i0;
+ ay = K$1[i0][1];
+ by = K$1[i0 + 1][1];
+ cy = K$1[min(19, i0 + 2)][1];
+ phi -= (delta = (y >= 0 ? halfPi : -halfPi) * (by + di * (cy - ay) / 2 + di * di * (cy - 2 * by + ay) / 2) - y) * degrees3;
+ } while (abs(delta) > epsilon22 && --j > 0);
+ break;
+ }
+ } while (--i0 >= 0);
+ var ax = K$1[i0][0], bx = K$1[i0 + 1][0], cx = K$1[min(19, i0 + 2)][0];
+ return [
+ x / (bx + di * (cx - ax) / 2 + di * di * (cx - 2 * bx + ax) / 2),
+ phi * radians2
+ ];
+ };
+ function robinson() {
+ return d3Geo.geoProjection(robinsonRaw).scale(152.63);
+ }
+ function satelliteVerticalRaw(P) {
+ function forward(lambda, phi) {
+ var cosPhi = cos(phi), k2 = (P - 1) / (P - cosPhi * cos(lambda));
+ return [
+ k2 * cosPhi * sin(lambda),
+ k2 * sin(phi)
+ ];
+ }
+ forward.invert = function(x, y) {
+ var rho2 = x * x + y * y, rho = sqrt(rho2), sinc = (P - sqrt(1 - rho2 * (P + 1) / (P - 1))) / ((P - 1) / rho + rho / (P - 1));
+ return [
+ atan2(x * sinc, rho * sqrt(1 - sinc * sinc)),
+ rho ? asin(y * sinc / rho) : 0
+ ];
+ };
+ return forward;
+ }
+ function satelliteRaw(P, omega) {
+ var vertical = satelliteVerticalRaw(P);
+ if (!omega) return vertical;
+ var cosOmega = cos(omega), sinOmega = sin(omega);
+ function forward(lambda, phi) {
+ var coordinates = vertical(lambda, phi), y = coordinates[1], A3 = y * sinOmega / (P - 1) + cosOmega;
+ return [
+ coordinates[0] * cosOmega / A3,
+ y / A3
+ ];
+ }
+ forward.invert = function(x, y) {
+ var k2 = (P - 1) / (P - 1 - y * sinOmega);
+ return vertical.invert(k2 * x, k2 * y * cosOmega);
+ };
+ return forward;
+ }
+ function satellite() {
+ var distance2 = 2, omega = 0, m = d3Geo.geoProjectionMutator(satelliteRaw), p = m(distance2, omega);
+ p.distance = function(_) {
+ if (!arguments.length) return distance2;
+ return m(distance2 = +_, omega);
+ };
+ p.tilt = function(_) {
+ if (!arguments.length) return omega * degrees3;
+ return m(distance2, omega = _ * radians2);
+ };
+ return p.scale(432.147).clipAngle(acos(1 / distance2) * degrees3 - 1e-6);
+ }
+ var epsilon$1 = 1e-4, epsilonInverse = 1e4, x0 = -180, x0e = x0 + epsilon$1, x1 = 180, x1e = x1 - epsilon$1, y0 = -90, y0e = y0 + epsilon$1, y1 = 90, y1e = y1 - epsilon$1;
+ function nonempty(coordinates) {
+ return coordinates.length > 0;
+ }
+ function quantize$1(x) {
+ return Math.floor(x * epsilonInverse) / epsilonInverse;
+ }
+ function normalizePoint(y) {
+ return y === y0 || y === y1 ? [0, y] : [x0, quantize$1(y)];
+ }
+ function clampPoint(p) {
+ var x = p[0], y = p[1], clamped = false;
+ if (x <= x0e) x = x0, clamped = true;
+ else if (x >= x1e) x = x1, clamped = true;
+ if (y <= y0e) y = y0, clamped = true;
+ else if (y >= y1e) y = y1, clamped = true;
+ return clamped ? [x, y] : p;
+ }
+ function clampPoints(points2) {
+ return points2.map(clampPoint);
+ }
+ function extractFragments(rings, polygon, fragments) {
+ for (var j = 0, m = rings.length; j < m; ++j) {
+ var ring = rings[j].slice();
+ fragments.push({ index: -1, polygon, ring });
+ for (var i = 0, n = ring.length; i < n; ++i) {
+ var point = ring[i], x = point[0], y = point[1];
+ if (x <= x0e || x >= x1e || y <= y0e || y >= y1e) {
+ ring[i] = clampPoint(point);
+ for (var k2 = i + 1; k2 < n; ++k2) {
+ var pointk = ring[k2], xk = pointk[0], yk = pointk[1];
+ if (xk > x0e && xk < x1e && yk > y0e && yk < y1e) break;
+ }
+ if (k2 === i + 1) continue;
+ if (i) {
+ var fragmentBefore = { index: -1, polygon, ring: ring.slice(0, i + 1) };
+ fragmentBefore.ring[fragmentBefore.ring.length - 1] = normalizePoint(y);
+ fragments[fragments.length - 1] = fragmentBefore;
+ } else fragments.pop();
+ if (k2 >= n) break;
+ fragments.push({ index: -1, polygon, ring: ring = ring.slice(k2 - 1) });
+ ring[0] = normalizePoint(ring[0][1]);
+ i = -1;
+ n = ring.length;
+ }
+ }
+ }
+ }
+ function stitchFragments(fragments) {
+ var i, n = fragments.length;
+ var fragmentByStart = {}, fragmentByEnd = {}, fragment, start, startFragment, end, endFragment;
+ for (i = 0; i < n; ++i) {
+ fragment = fragments[i];
+ start = fragment.ring[0];
+ end = fragment.ring[fragment.ring.length - 1];
+ if (start[0] === end[0] && start[1] === end[1]) {
+ fragment.polygon.push(fragment.ring);
+ fragments[i] = null;
+ continue;
+ }
+ fragment.index = i;
+ fragmentByStart[start] = fragmentByEnd[end] = fragment;
+ }
+ for (i = 0; i < n; ++i) {
+ fragment = fragments[i];
+ if (fragment) {
+ start = fragment.ring[0];
+ end = fragment.ring[fragment.ring.length - 1];
+ startFragment = fragmentByEnd[start];
+ endFragment = fragmentByStart[end];
+ delete fragmentByStart[start];
+ delete fragmentByEnd[end];
+ if (start[0] === end[0] && start[1] === end[1]) {
+ fragment.polygon.push(fragment.ring);
+ continue;
+ }
+ if (startFragment) {
+ delete fragmentByEnd[start];
+ delete fragmentByStart[startFragment.ring[0]];
+ startFragment.ring.pop();
+ fragments[startFragment.index] = null;
+ fragment = { index: -1, polygon: startFragment.polygon, ring: startFragment.ring.concat(fragment.ring) };
+ if (startFragment === endFragment) {
+ fragment.polygon.push(fragment.ring);
+ } else {
+ fragment.index = n++;
+ fragments.push(fragmentByStart[fragment.ring[0]] = fragmentByEnd[fragment.ring[fragment.ring.length - 1]] = fragment);
+ }
+ } else if (endFragment) {
+ delete fragmentByStart[end];
+ delete fragmentByEnd[endFragment.ring[endFragment.ring.length - 1]];
+ fragment.ring.pop();
+ fragment = { index: n++, polygon: endFragment.polygon, ring: fragment.ring.concat(endFragment.ring) };
+ fragments[endFragment.index] = null;
+ fragments.push(fragmentByStart[fragment.ring[0]] = fragmentByEnd[fragment.ring[fragment.ring.length - 1]] = fragment);
+ } else {
+ fragment.ring.push(fragment.ring[0]);
+ fragment.polygon.push(fragment.ring);
+ }
+ }
+ }
+ }
+ function stitchFeature(input) {
+ var output = { type: "Feature", geometry: stitchGeometry(input.geometry) };
+ if (input.id != null) output.id = input.id;
+ if (input.bbox != null) output.bbox = input.bbox;
+ if (input.properties != null) output.properties = input.properties;
+ return output;
+ }
+ function stitchGeometry(input) {
+ if (input == null) return input;
+ var output, fragments, i, n;
+ switch (input.type) {
+ case "GeometryCollection":
+ output = { type: "GeometryCollection", geometries: input.geometries.map(stitchGeometry) };
+ break;
+ case "Point":
+ output = { type: "Point", coordinates: clampPoint(input.coordinates) };
+ break;
+ case "MultiPoint":
+ case "LineString":
+ output = { type: input.type, coordinates: clampPoints(input.coordinates) };
+ break;
+ case "MultiLineString":
+ output = { type: "MultiLineString", coordinates: input.coordinates.map(clampPoints) };
+ break;
+ case "Polygon": {
+ var polygon = [];
+ extractFragments(input.coordinates, polygon, fragments = []);
+ stitchFragments(fragments);
+ output = { type: "Polygon", coordinates: polygon };
+ break;
+ }
+ case "MultiPolygon": {
+ fragments = [], i = -1, n = input.coordinates.length;
+ var polygons = new Array(n);
+ while (++i < n) extractFragments(input.coordinates[i], polygons[i] = [], fragments);
+ stitchFragments(fragments);
+ output = { type: "MultiPolygon", coordinates: polygons.filter(nonempty) };
+ break;
+ }
+ default:
+ return input;
+ }
+ if (input.bbox != null) output.bbox = input.bbox;
+ return output;
+ }
+ function stitch(input) {
+ if (input == null) return input;
+ switch (input.type) {
+ case "Feature":
+ return stitchFeature(input);
+ case "FeatureCollection": {
+ var output = { type: "FeatureCollection", features: input.features.map(stitchFeature) };
+ if (input.bbox != null) output.bbox = input.bbox;
+ return output;
+ }
+ default:
+ return stitchGeometry(input);
+ }
+ }
+ function timesRaw(lambda, phi) {
+ var t = tan(phi / 2), s = sin(quarterPi * t);
+ return [
+ lambda * (0.74482 - 0.34588 * s * s),
+ 1.70711 * t
+ ];
+ }
+ timesRaw.invert = function(x, y) {
+ var t = y / 1.70711, s = sin(quarterPi * t);
+ return [
+ x / (0.74482 - 0.34588 * s * s),
+ 2 * atan(t)
+ ];
+ };
+ function times() {
+ return d3Geo.geoProjection(timesRaw).scale(146.153);
+ }
+ function twoPoint(raw, p0, p1) {
+ var i = d3Geo.geoInterpolate(p0, p1), o = i(0.5), a = d3Geo.geoRotation([-o[0], -o[1]])(p0), b = i.distance / 2, y = -asin(sin(a[1] * radians2) / sin(b)), R = [-o[0], -o[1], -(a[0] > 0 ? pi - y : y) * degrees3], p = d3Geo.geoProjection(raw(b)).rotate(R), r = d3Geo.geoRotation(R), center = p.center;
+ delete p.rotate;
+ p.center = function(_) {
+ return arguments.length ? center(r(_)) : r.invert(center());
+ };
+ return p.clipAngle(90);
+ }
+ function twoPointAzimuthalRaw(d) {
+ var cosd = cos(d);
+ function forward(lambda, phi) {
+ var coordinates = d3Geo.geoGnomonicRaw(lambda, phi);
+ coordinates[0] *= cosd;
+ return coordinates;
+ }
+ forward.invert = function(x, y) {
+ return d3Geo.geoGnomonicRaw.invert(x / cosd, y);
+ };
+ return forward;
+ }
+ function twoPointAzimuthalUsa() {
+ return twoPointAzimuthal([-158, 21.5], [-77, 39]).clipAngle(60).scale(400);
+ }
+ function twoPointAzimuthal(p0, p1) {
+ return twoPoint(twoPointAzimuthalRaw, p0, p1);
+ }
+ function twoPointEquidistantRaw(z0) {
+ if (!(z0 *= 2)) return d3Geo.geoAzimuthalEquidistantRaw;
+ var lambdaa = -z0 / 2, lambdab = -lambdaa, z02 = z0 * z0, tanLambda0 = tan(lambdab), S = 0.5 / sin(lambdab);
+ function forward(lambda, phi) {
+ var za = acos(cos(phi) * cos(lambda - lambdaa)), zb = acos(cos(phi) * cos(lambda - lambdab)), ys = phi < 0 ? -1 : 1;
+ za *= za, zb *= zb;
+ return [
+ (za - zb) / (2 * z0),
+ ys * sqrt(4 * z02 * zb - (z02 - za + zb) * (z02 - za + zb)) / (2 * z0)
+ ];
+ }
+ forward.invert = function(x, y) {
+ var y2 = y * y, cosza = cos(sqrt(y2 + (t = x + lambdaa) * t)), coszb = cos(sqrt(y2 + (t = x + lambdab) * t)), t, d;
+ return [
+ atan2(d = cosza - coszb, t = (cosza + coszb) * tanLambda0),
+ (y < 0 ? -1 : 1) * acos(sqrt(t * t + d * d) * S)
+ ];
+ };
+ return forward;
+ }
+ function twoPointEquidistantUsa() {
+ return twoPointEquidistant([-158, 21.5], [-77, 39]).clipAngle(130).scale(122.571);
+ }
+ function twoPointEquidistant(p0, p1) {
+ return twoPoint(twoPointEquidistantRaw, p0, p1);
+ }
+ function vanDerGrintenRaw(lambda, phi) {
+ if (abs(phi) < epsilon) return [lambda, 0];
+ var sinTheta = abs(phi / halfPi), theta = asin(sinTheta);
+ if (abs(lambda) < epsilon || abs(abs(phi) - halfPi) < epsilon) return [0, sign(phi) * pi * tan(theta / 2)];
+ var cosTheta = cos(theta), A3 = abs(pi / lambda - lambda / pi) / 2, A22 = A3 * A3, G = cosTheta / (sinTheta + cosTheta - 1), P = G * (2 / sinTheta - 1), P2 = P * P, P2_A2 = P2 + A22, G_P2 = G - P2, Q = A22 + G;
+ return [
+ sign(lambda) * pi * (A3 * G_P2 + sqrt(A22 * G_P2 * G_P2 - P2_A2 * (G * G - P2))) / P2_A2,
+ sign(phi) * pi * (P * Q - A3 * sqrt((A22 + 1) * P2_A2 - Q * Q)) / P2_A2
+ ];
+ }
+ vanDerGrintenRaw.invert = function(x, y) {
+ if (abs(y) < epsilon) return [x, 0];
+ if (abs(x) < epsilon) return [0, halfPi * sin(2 * atan(y / pi))];
+ var x2 = (x /= pi) * x, y2 = (y /= pi) * y, x2_y2 = x2 + y2, z = x2_y2 * x2_y2, c1 = -abs(y) * (1 + x2_y2), c2 = c1 - 2 * y2 + x2, c3 = -2 * c1 + 1 + 2 * y2 + z, d = y2 / c3 + (2 * c2 * c2 * c2 / (c3 * c3 * c3) - 9 * c1 * c2 / (c3 * c3)) / 27, a1 = (c1 - c2 * c2 / (3 * c3)) / c3, m1 = 2 * sqrt(-a1 / 3), theta1 = acos(3 * d / (a1 * m1)) / 3;
+ return [
+ pi * (x2_y2 - 1 + sqrt(1 + 2 * (x2 - y2) + z)) / (2 * x),
+ sign(y) * pi * (-m1 * cos(theta1 + pi / 3) - c2 / (3 * c3))
+ ];
+ };
+ function vanDerGrinten() {
+ return d3Geo.geoProjection(vanDerGrintenRaw).scale(79.4183);
+ }
+ function vanDerGrinten2Raw(lambda, phi) {
+ if (abs(phi) < epsilon) return [lambda, 0];
+ var sinTheta = abs(phi / halfPi), theta = asin(sinTheta);
+ if (abs(lambda) < epsilon || abs(abs(phi) - halfPi) < epsilon) return [0, sign(phi) * pi * tan(theta / 2)];
+ var cosTheta = cos(theta), A3 = abs(pi / lambda - lambda / pi) / 2, A22 = A3 * A3, x12 = cosTheta * (sqrt(1 + A22) - A3 * cosTheta) / (1 + A22 * sinTheta * sinTheta);
+ return [
+ sign(lambda) * pi * x12,
+ sign(phi) * pi * sqrt(1 - x12 * (2 * A3 + x12))
+ ];
+ }
+ vanDerGrinten2Raw.invert = function(x, y) {
+ if (!x) return [0, halfPi * sin(2 * atan(y / pi))];
+ var x12 = abs(x / pi), A3 = (1 - x12 * x12 - (y /= pi) * y) / (2 * x12), A22 = A3 * A3, B3 = sqrt(A22 + 1);
+ return [
+ sign(x) * pi * (B3 - A3),
+ sign(y) * halfPi * sin(2 * atan2(sqrt((1 - 2 * A3 * x12) * (A3 + B3) - x12), sqrt(B3 + A3 + x12)))
+ ];
+ };
+ function vanDerGrinten2() {
+ return d3Geo.geoProjection(vanDerGrinten2Raw).scale(79.4183);
+ }
+ function vanDerGrinten3Raw(lambda, phi) {
+ if (abs(phi) < epsilon) return [lambda, 0];
+ var sinTheta = phi / halfPi, theta = asin(sinTheta);
+ if (abs(lambda) < epsilon || abs(abs(phi) - halfPi) < epsilon) return [0, pi * tan(theta / 2)];
+ var A3 = (pi / lambda - lambda / pi) / 2, y12 = sinTheta / (1 + cos(theta));
+ return [
+ pi * (sign(lambda) * sqrt(A3 * A3 + 1 - y12 * y12) - A3),
+ pi * y12
+ ];
+ }
+ vanDerGrinten3Raw.invert = function(x, y) {
+ if (!y) return [x, 0];
+ var y12 = y / pi, A3 = (pi * pi * (1 - y12 * y12) - x * x) / (2 * pi * x);
+ return [
+ x ? pi * (sign(x) * sqrt(A3 * A3 + 1) - A3) : 0,
+ halfPi * sin(2 * atan(y12))
+ ];
+ };
+ function vanDerGrinten3() {
+ return d3Geo.geoProjection(vanDerGrinten3Raw).scale(79.4183);
+ }
+ function vanDerGrinten4Raw(lambda, phi) {
+ if (!phi) return [lambda, 0];
+ var phi02 = abs(phi);
+ if (!lambda || phi02 === halfPi) return [0, phi];
+ var B3 = phi02 / halfPi, B22 = B3 * B3, C2 = (8 * B3 - B22 * (B22 + 2) - 5) / (2 * B22 * (B3 - 1)), C22 = C2 * C2, BC = B3 * C2, B_C2 = B22 + C22 + 2 * BC, B_3C = B3 + 3 * C2, lambda0 = lambda / halfPi, lambda1 = lambda0 + 1 / lambda0, D2 = sign(abs(lambda) - halfPi) * sqrt(lambda1 * lambda1 - 4), D22 = D2 * D2, F = B_C2 * (B22 + C22 * D22 - 1) + (1 - B22) * (B22 * (B_3C * B_3C + 4 * C22) + 12 * BC * C22 + 4 * C22 * C22), x12 = (D2 * (B_C2 + C22 - 1) + 2 * sqrt(F)) / (4 * B_C2 + D22);
+ return [
+ sign(lambda) * halfPi * x12,
+ sign(phi) * halfPi * sqrt(1 + D2 * abs(x12) - x12 * x12)
+ ];
+ }
+ vanDerGrinten4Raw.invert = function(x, y) {
+ var delta;
+ if (!x || !y) return [x, y];
+ y /= pi;
+ var x12 = sign(x) * x / halfPi, D2 = (x12 * x12 - 1 + 4 * y * y) / abs(x12), D22 = D2 * D2, B3 = 2 * y, i = 50;
+ do {
+ var B22 = B3 * B3, C2 = (8 * B3 - B22 * (B22 + 2) - 5) / (2 * B22 * (B3 - 1)), C_ = (3 * B3 - B22 * B3 - 10) / (2 * B22 * B3), C22 = C2 * C2, BC = B3 * C2, B_C = B3 + C2, B_C2 = B_C * B_C, B_3C = B3 + 3 * C2, F = B_C2 * (B22 + C22 * D22 - 1) + (1 - B22) * (B22 * (B_3C * B_3C + 4 * C22) + C22 * (12 * BC + 4 * C22)), F_ = -2 * B_C * (4 * BC * C22 + (1 - 4 * B22 + 3 * B22 * B22) * (1 + C_) + C22 * (-6 + 14 * B22 - D22 + (-8 + 8 * B22 - 2 * D22) * C_) + BC * (-8 + 12 * B22 + (-10 + 10 * B22 - D22) * C_)), sqrtF = sqrt(F), f = D2 * (B_C2 + C22 - 1) + 2 * sqrtF - x12 * (4 * B_C2 + D22), f_ = D2 * (2 * C2 * C_ + 2 * B_C * (1 + C_)) + F_ / sqrtF - 8 * B_C * (D2 * (-1 + C22 + B_C2) + 2 * sqrtF) * (1 + C_) / (D22 + 4 * B_C2);
+ B3 -= delta = f / f_;
+ } while (delta > epsilon && --i > 0);
+ return [
+ sign(x) * (sqrt(D2 * D2 + 4) + D2) * pi / 4,
+ halfPi * B3
+ ];
+ };
+ function vanDerGrinten4() {
+ return d3Geo.geoProjection(vanDerGrinten4Raw).scale(127.16);
+ }
+ function wagnerFormula(cx, cy, m1, m2, n) {
+ function forward(lambda, phi) {
+ var s = m1 * sin(m2 * phi), c0 = sqrt(1 - s * s), c1 = sqrt(2 / (1 + c0 * cos(lambda *= n)));
+ return [
+ cx * c0 * c1 * sin(lambda),
+ cy * s * c1
+ ];
+ }
+ forward.invert = function(x, y) {
+ var t12 = x / cx, t22 = y / cy, p = sqrt(t12 * t12 + t22 * t22), c = 2 * asin(p / 2);
+ return [
+ atan2(x * tan(c), cx * p) / n,
+ p && asin(y * sin(c) / (cy * m1 * p)) / m2
+ ];
+ };
+ return forward;
+ }
+ function wagnerRaw(poleline, parallels, inflation, ratio) {
+ var phi1 = pi / 3;
+ poleline = max(poleline, epsilon);
+ parallels = max(parallels, epsilon);
+ poleline = min(poleline, halfPi);
+ parallels = min(parallels, pi - epsilon);
+ inflation = max(inflation, 0);
+ inflation = min(inflation, 100 - epsilon);
+ ratio = max(ratio, epsilon);
+ var vinflation = inflation / 100 + 1;
+ var vratio = ratio / 100;
+ var m2 = acos(vinflation * cos(phi1)) / phi1, m1 = sin(poleline) / sin(m2 * halfPi), n = parallels / pi, k2 = sqrt(vratio * sin(poleline / 2) / sin(parallels / 2)), cx = k2 / sqrt(n * m1 * m2), cy = 1 / (k2 * sqrt(n * m1 * m2));
+ return wagnerFormula(cx, cy, m1, m2, n);
+ }
+ function wagner() {
+ var poleline = 65 * radians2, parallels = 60 * radians2, inflation = 20, ratio = 200, mutate = d3Geo.geoProjectionMutator(wagnerRaw), projection = mutate(poleline, parallels, inflation, ratio);
+ projection.poleline = function(_) {
+ return arguments.length ? mutate(poleline = +_ * radians2, parallels, inflation, ratio) : poleline * degrees3;
+ };
+ projection.parallels = function(_) {
+ return arguments.length ? mutate(poleline, parallels = +_ * radians2, inflation, ratio) : parallels * degrees3;
+ };
+ projection.inflation = function(_) {
+ return arguments.length ? mutate(poleline, parallels, inflation = +_, ratio) : inflation;
+ };
+ projection.ratio = function(_) {
+ return arguments.length ? mutate(poleline, parallels, inflation, ratio = +_) : ratio;
+ };
+ return projection.scale(163.775);
+ }
+ function wagner7() {
+ return wagner().poleline(65).parallels(60).inflation(0).ratio(200).scale(172.633);
+ }
+ var A2 = 4 * pi + 3 * sqrt(3), B2 = 2 * sqrt(2 * pi * sqrt(3) / A2);
+ var wagner4Raw = mollweideBromleyRaw(B2 * sqrt(3) / pi, B2, A2 / 6);
+ function wagner4() {
+ return d3Geo.geoProjection(wagner4Raw).scale(176.84);
+ }
+ function wagner6Raw(lambda, phi) {
+ return [lambda * sqrt(1 - 3 * phi * phi / (pi * pi)), phi];
+ }
+ wagner6Raw.invert = function(x, y) {
+ return [x / sqrt(1 - 3 * y * y / (pi * pi)), y];
+ };
+ function wagner6() {
+ return d3Geo.geoProjection(wagner6Raw).scale(152.63);
+ }
+ function wiechelRaw(lambda, phi) {
+ var cosPhi = cos(phi), sinPhi = cos(lambda) * cosPhi, sin1_Phi = 1 - sinPhi, cosLambda = cos(lambda = atan2(sin(lambda) * cosPhi, -sin(phi))), sinLambda = sin(lambda);
+ cosPhi = sqrt(1 - sinPhi * sinPhi);
+ return [
+ sinLambda * cosPhi - cosLambda * sin1_Phi,
+ -cosLambda * cosPhi - sinLambda * sin1_Phi
+ ];
+ }
+ wiechelRaw.invert = function(x, y) {
+ var w2 = (x * x + y * y) / -2, k2 = sqrt(-w2 * (2 + w2)), b = y * w2 + x * k2, a = x * w2 - y * k2, D2 = sqrt(a * a + b * b);
+ return [
+ atan2(k2 * b, D2 * (1 + w2)),
+ D2 ? -asin(k2 * a / D2) : 0
+ ];
+ };
+ function wiechel() {
+ return d3Geo.geoProjection(wiechelRaw).rotate([0, -90, 45]).scale(124.75).clipAngle(180 - 1e-3);
+ }
+ function winkel3Raw(lambda, phi) {
+ var coordinates = aitoffRaw(lambda, phi);
+ return [
+ (coordinates[0] + lambda / halfPi) / 2,
+ (coordinates[1] + phi) / 2
+ ];
+ }
+ winkel3Raw.invert = function(x, y) {
+ var lambda = x, phi = y, i = 25;
+ do {
+ var cosphi = cos(phi), sinphi = sin(phi), sin_2phi = sin(2 * phi), sin2phi = sinphi * sinphi, cos2phi = cosphi * cosphi, sinlambda = sin(lambda), coslambda_2 = cos(lambda / 2), sinlambda_2 = sin(lambda / 2), sin2lambda_2 = sinlambda_2 * sinlambda_2, C2 = 1 - cos2phi * coslambda_2 * coslambda_2, E2 = C2 ? acos(cosphi * coslambda_2) * sqrt(F = 1 / C2) : F = 0, F, fx = 0.5 * (2 * E2 * cosphi * sinlambda_2 + lambda / halfPi) - x, fy = 0.5 * (E2 * sinphi + phi) - y, dxdlambda = 0.5 * F * (cos2phi * sin2lambda_2 + E2 * cosphi * coslambda_2 * sin2phi) + 0.5 / halfPi, dxdphi = F * (sinlambda * sin_2phi / 4 - E2 * sinphi * sinlambda_2), dydlambda = 0.125 * F * (sin_2phi * sinlambda_2 - E2 * sinphi * cos2phi * sinlambda), dydphi = 0.5 * F * (sin2phi * coslambda_2 + E2 * sin2lambda_2 * cosphi) + 0.5, denominator = dxdphi * dydlambda - dydphi * dxdlambda, dlambda = (fy * dxdphi - fx * dydphi) / denominator, dphi = (fx * dydlambda - fy * dxdlambda) / denominator;
+ lambda -= dlambda, phi -= dphi;
+ } while ((abs(dlambda) > epsilon || abs(dphi) > epsilon) && --i > 0);
+ return [lambda, phi];
+ };
+ function winkel3() {
+ return d3Geo.geoProjection(winkel3Raw).scale(158.837);
+ }
+ exports2.geoNaturalEarth = d3Geo.geoNaturalEarth1;
+ exports2.geoNaturalEarthRaw = d3Geo.geoNaturalEarth1Raw;
+ exports2.geoAiry = airy;
+ exports2.geoAiryRaw = airyRaw;
+ exports2.geoAitoff = aitoff;
+ exports2.geoAitoffRaw = aitoffRaw;
+ exports2.geoArmadillo = armadillo;
+ exports2.geoArmadilloRaw = armadilloRaw;
+ exports2.geoAugust = august;
+ exports2.geoAugustRaw = augustRaw;
+ exports2.geoBaker = baker;
+ exports2.geoBakerRaw = bakerRaw;
+ exports2.geoBerghaus = berghaus;
+ exports2.geoBerghausRaw = berghausRaw;
+ exports2.geoBertin1953 = bertin;
+ exports2.geoBertin1953Raw = bertin1953Raw;
+ exports2.geoBoggs = boggs;
+ exports2.geoBoggsRaw = boggsRaw;
+ exports2.geoBonne = bonne;
+ exports2.geoBonneRaw = bonneRaw;
+ exports2.geoBottomley = bottomley;
+ exports2.geoBottomleyRaw = bottomleyRaw;
+ exports2.geoBromley = bromley;
+ exports2.geoBromleyRaw = bromleyRaw;
+ exports2.geoChamberlin = chamberlin;
+ exports2.geoChamberlinRaw = chamberlinRaw;
+ exports2.geoChamberlinAfrica = chamberlinAfrica;
+ exports2.geoCollignon = collignon;
+ exports2.geoCollignonRaw = collignonRaw;
+ exports2.geoCraig = craig;
+ exports2.geoCraigRaw = craigRaw;
+ exports2.geoCraster = craster;
+ exports2.geoCrasterRaw = crasterRaw;
+ exports2.geoCylindricalEqualArea = cylindricalEqualArea;
+ exports2.geoCylindricalEqualAreaRaw = cylindricalEqualAreaRaw;
+ exports2.geoCylindricalStereographic = cylindricalStereographic;
+ exports2.geoCylindricalStereographicRaw = cylindricalStereographicRaw;
+ exports2.geoEckert1 = eckert1;
+ exports2.geoEckert1Raw = eckert1Raw;
+ exports2.geoEckert2 = eckert2;
+ exports2.geoEckert2Raw = eckert2Raw;
+ exports2.geoEckert3 = eckert3;
+ exports2.geoEckert3Raw = eckert3Raw;
+ exports2.geoEckert4 = eckert4;
+ exports2.geoEckert4Raw = eckert4Raw;
+ exports2.geoEckert5 = eckert5;
+ exports2.geoEckert5Raw = eckert5Raw;
+ exports2.geoEckert6 = eckert6;
+ exports2.geoEckert6Raw = eckert6Raw;
+ exports2.geoEisenlohr = eisenlohr;
+ exports2.geoEisenlohrRaw = eisenlohrRaw;
+ exports2.geoFahey = fahey;
+ exports2.geoFaheyRaw = faheyRaw;
+ exports2.geoFoucaut = foucaut;
+ exports2.geoFoucautRaw = foucautRaw;
+ exports2.geoFoucautSinusoidal = foucautSinusoidal;
+ exports2.geoFoucautSinusoidalRaw = foucautSinusoidalRaw;
+ exports2.geoGilbert = gilbert;
+ exports2.geoGingery = gingery;
+ exports2.geoGingeryRaw = gingeryRaw;
+ exports2.geoGinzburg4 = ginzburg4;
+ exports2.geoGinzburg4Raw = ginzburg4Raw;
+ exports2.geoGinzburg5 = ginzburg5;
+ exports2.geoGinzburg5Raw = ginzburg5Raw;
+ exports2.geoGinzburg6 = ginzburg6;
+ exports2.geoGinzburg6Raw = ginzburg6Raw;
+ exports2.geoGinzburg8 = ginzburg8;
+ exports2.geoGinzburg8Raw = ginzburg8Raw;
+ exports2.geoGinzburg9 = ginzburg9;
+ exports2.geoGinzburg9Raw = ginzburg9Raw;
+ exports2.geoGringorten = gringorten;
+ exports2.geoGringortenRaw = gringortenRaw;
+ exports2.geoGuyou = guyou;
+ exports2.geoGuyouRaw = guyouRaw;
+ exports2.geoHammer = hammer;
+ exports2.geoHammerRaw = hammerRaw;
+ exports2.geoHammerRetroazimuthal = hammerRetroazimuthal;
+ exports2.geoHammerRetroazimuthalRaw = hammerRetroazimuthalRaw;
+ exports2.geoHealpix = healpix;
+ exports2.geoHealpixRaw = healpixRaw;
+ exports2.geoHill = hill;
+ exports2.geoHillRaw = hillRaw;
+ exports2.geoHomolosine = homolosine;
+ exports2.geoHomolosineRaw = homolosineRaw;
+ exports2.geoHufnagel = hufnagel;
+ exports2.geoHufnagelRaw = hufnagelRaw;
+ exports2.geoHyperelliptical = hyperelliptical;
+ exports2.geoHyperellipticalRaw = hyperellipticalRaw;
+ exports2.geoInterrupt = interrupt;
+ exports2.geoInterruptedBoggs = boggs$1;
+ exports2.geoInterruptedHomolosine = homolosine$1;
+ exports2.geoInterruptedMollweide = mollweide$1;
+ exports2.geoInterruptedMollweideHemispheres = mollweideHemispheres;
+ exports2.geoInterruptedSinuMollweide = sinuMollweide$1;
+ exports2.geoInterruptedSinusoidal = sinusoidal$1;
+ exports2.geoKavrayskiy7 = kavrayskiy7;
+ exports2.geoKavrayskiy7Raw = kavrayskiy7Raw;
+ exports2.geoLagrange = lagrange;
+ exports2.geoLagrangeRaw = lagrangeRaw;
+ exports2.geoLarrivee = larrivee;
+ exports2.geoLarriveeRaw = larriveeRaw;
+ exports2.geoLaskowski = laskowski;
+ exports2.geoLaskowskiRaw = laskowskiRaw;
+ exports2.geoLittrow = littrow;
+ exports2.geoLittrowRaw = littrowRaw;
+ exports2.geoLoximuthal = loximuthal;
+ exports2.geoLoximuthalRaw = loximuthalRaw;
+ exports2.geoMiller = miller;
+ exports2.geoMillerRaw = millerRaw;
+ exports2.geoModifiedStereographic = modifiedStereographic;
+ exports2.geoModifiedStereographicRaw = modifiedStereographicRaw;
+ exports2.geoModifiedStereographicAlaska = modifiedStereographicAlaska;
+ exports2.geoModifiedStereographicGs48 = modifiedStereographicGs48;
+ exports2.geoModifiedStereographicGs50 = modifiedStereographicGs50;
+ exports2.geoModifiedStereographicMiller = modifiedStereographicMiller;
+ exports2.geoModifiedStereographicLee = modifiedStereographicLee;
+ exports2.geoMollweide = mollweide;
+ exports2.geoMollweideRaw = mollweideRaw;
+ exports2.geoMtFlatPolarParabolic = mtFlatPolarParabolic;
+ exports2.geoMtFlatPolarParabolicRaw = mtFlatPolarParabolicRaw;
+ exports2.geoMtFlatPolarQuartic = mtFlatPolarQuartic;
+ exports2.geoMtFlatPolarQuarticRaw = mtFlatPolarQuarticRaw;
+ exports2.geoMtFlatPolarSinusoidal = mtFlatPolarSinusoidal;
+ exports2.geoMtFlatPolarSinusoidalRaw = mtFlatPolarSinusoidalRaw;
+ exports2.geoNaturalEarth2 = naturalEarth2;
+ exports2.geoNaturalEarth2Raw = naturalEarth2Raw;
+ exports2.geoNellHammer = nellHammer;
+ exports2.geoNellHammerRaw = nellHammerRaw;
+ exports2.geoInterruptedQuarticAuthalic = quarticAuthalic;
+ exports2.geoNicolosi = nicolosi;
+ exports2.geoNicolosiRaw = nicolosiRaw;
+ exports2.geoPatterson = patterson;
+ exports2.geoPattersonRaw = pattersonRaw;
+ exports2.geoPolyconic = polyconic;
+ exports2.geoPolyconicRaw = polyconicRaw;
+ exports2.geoPolyhedral = polyhedral;
+ exports2.geoPolyhedralButterfly = butterfly;
+ exports2.geoPolyhedralCollignon = collignon$1;
+ exports2.geoPolyhedralWaterman = waterman;
+ exports2.geoProject = index;
+ exports2.geoGringortenQuincuncial = gringorten$1;
+ exports2.geoPeirceQuincuncial = peirce;
+ exports2.geoPierceQuincuncial = peirce;
+ exports2.geoQuantize = quantize;
+ exports2.geoQuincuncial = quincuncial;
+ exports2.geoRectangularPolyconic = rectangularPolyconic;
+ exports2.geoRectangularPolyconicRaw = rectangularPolyconicRaw;
+ exports2.geoRobinson = robinson;
+ exports2.geoRobinsonRaw = robinsonRaw;
+ exports2.geoSatellite = satellite;
+ exports2.geoSatelliteRaw = satelliteRaw;
+ exports2.geoSinuMollweide = sinuMollweide;
+ exports2.geoSinuMollweideRaw = sinuMollweideRaw;
+ exports2.geoSinusoidal = sinusoidal;
+ exports2.geoSinusoidalRaw = sinusoidalRaw;
+ exports2.geoStitch = stitch;
+ exports2.geoTimes = times;
+ exports2.geoTimesRaw = timesRaw;
+ exports2.geoTwoPointAzimuthal = twoPointAzimuthal;
+ exports2.geoTwoPointAzimuthalRaw = twoPointAzimuthalRaw;
+ exports2.geoTwoPointAzimuthalUsa = twoPointAzimuthalUsa;
+ exports2.geoTwoPointEquidistant = twoPointEquidistant;
+ exports2.geoTwoPointEquidistantRaw = twoPointEquidistantRaw;
+ exports2.geoTwoPointEquidistantUsa = twoPointEquidistantUsa;
+ exports2.geoVanDerGrinten = vanDerGrinten;
+ exports2.geoVanDerGrintenRaw = vanDerGrintenRaw;
+ exports2.geoVanDerGrinten2 = vanDerGrinten2;
+ exports2.geoVanDerGrinten2Raw = vanDerGrinten2Raw;
+ exports2.geoVanDerGrinten3 = vanDerGrinten3;
+ exports2.geoVanDerGrinten3Raw = vanDerGrinten3Raw;
+ exports2.geoVanDerGrinten4 = vanDerGrinten4;
+ exports2.geoVanDerGrinten4Raw = vanDerGrinten4Raw;
+ exports2.geoWagner = wagner;
+ exports2.geoWagner7 = wagner7;
+ exports2.geoWagnerRaw = wagnerRaw;
+ exports2.geoWagner4 = wagner4;
+ exports2.geoWagner4Raw = wagner4Raw;
+ exports2.geoWagner6 = wagner6;
+ exports2.geoWagner6Raw = wagner6Raw;
+ exports2.geoWiechel = wiechel;
+ exports2.geoWiechelRaw = wiechelRaw;
+ exports2.geoWinkel3 = winkel3;
+ exports2.geoWinkel3Raw = winkel3Raw;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // src/plots/geo/zoom.js
+ var require_zoom = __commonJS({
+ "src/plots/geo/zoom.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var Lib = require_lib();
+ var Registry = require_registry();
+ var radians2 = Math.PI / 180;
+ var degrees3 = 180 / Math.PI;
+ var zoomstartStyle = { cursor: "pointer" };
+ var zoomendStyle = { cursor: "auto" };
+ function createGeoZoom(geo, geoLayout) {
+ var projection = geo.projection;
+ var zoomConstructor;
+ if (geoLayout._isScoped) {
+ zoomConstructor = zoomScoped;
+ } else if (geoLayout._isClipped) {
+ zoomConstructor = zoomClipped;
+ } else {
+ zoomConstructor = zoomNonClipped;
+ }
+ return zoomConstructor(geo, projection);
+ }
+ module.exports = createGeoZoom;
+ function initZoom(geo, projection) {
+ return d3.behavior.zoom().translate(projection.translate()).scale(projection.scale());
+ }
+ function sync(geo, projection, cb) {
+ var id = geo.id;
+ var gd = geo.graphDiv;
+ var layout = gd.layout;
+ var userOpts = layout[id];
+ var fullLayout = gd._fullLayout;
+ var fullOpts = fullLayout[id];
+ var preGUI = {};
+ var eventData = {};
+ function set(propStr, val) {
+ preGUI[id + "." + propStr] = Lib.nestedProperty(userOpts, propStr).get();
+ Registry.call("_storeDirectGUIEdit", layout, fullLayout._preGUI, preGUI);
+ var fullNp = Lib.nestedProperty(fullOpts, propStr);
+ if (fullNp.get() !== val) {
+ fullNp.set(val);
+ Lib.nestedProperty(userOpts, propStr).set(val);
+ eventData[id + "." + propStr] = val;
+ }
+ }
+ cb(set);
+ set("projection.scale", projection.scale() / geo.fitScale);
+ set("fitbounds", false);
+ gd.emit("plotly_relayout", eventData);
+ }
+ function zoomScoped(geo, projection) {
+ var zoom = initZoom(geo, projection);
+ function handleZoomstart() {
+ d3.select(this).style(zoomstartStyle);
+ }
+ function handleZoom() {
+ projection.scale(d3.event.scale).translate(d3.event.translate);
+ geo.render(true);
+ var center = projection.invert(geo.midPt);
+ geo.graphDiv.emit("plotly_relayouting", {
+ "geo.projection.scale": projection.scale() / geo.fitScale,
+ "geo.center.lon": center[0],
+ "geo.center.lat": center[1]
+ });
+ }
+ function syncCb(set) {
+ var center = projection.invert(geo.midPt);
+ set("center.lon", center[0]);
+ set("center.lat", center[1]);
+ }
+ function handleZoomend() {
+ d3.select(this).style(zoomendStyle);
+ sync(geo, projection, syncCb);
+ }
+ zoom.on("zoomstart", handleZoomstart).on("zoom", handleZoom).on("zoomend", handleZoomend);
+ return zoom;
+ }
+ function zoomNonClipped(geo, projection) {
+ var zoom = initZoom(geo, projection);
+ var INSIDETOLORANCEPXS = 2;
+ var mouse0, rotate0, translate0, lastRotate, zoomPoint, mouse1, rotate1, point1, didZoom;
+ function position2(x) {
+ return projection.invert(x);
+ }
+ function outside(x) {
+ var pos = position2(x);
+ if (!pos) return true;
+ var pt = projection(pos);
+ return Math.abs(pt[0] - x[0]) > INSIDETOLORANCEPXS || Math.abs(pt[1] - x[1]) > INSIDETOLORANCEPXS;
+ }
+ function handleZoomstart() {
+ d3.select(this).style(zoomstartStyle);
+ mouse0 = d3.mouse(this);
+ rotate0 = projection.rotate();
+ translate0 = projection.translate();
+ lastRotate = rotate0;
+ zoomPoint = position2(mouse0);
+ }
+ function handleZoom() {
+ mouse1 = d3.mouse(this);
+ if (outside(mouse0)) {
+ zoom.scale(projection.scale());
+ zoom.translate(projection.translate());
+ return;
+ }
+ projection.scale(d3.event.scale);
+ projection.translate([translate0[0], d3.event.translate[1]]);
+ if (!zoomPoint) {
+ mouse0 = mouse1;
+ zoomPoint = position2(mouse0);
+ } else if (position2(mouse1)) {
+ point1 = position2(mouse1);
+ rotate1 = [lastRotate[0] + (point1[0] - zoomPoint[0]), rotate0[1], rotate0[2]];
+ projection.rotate(rotate1);
+ lastRotate = rotate1;
+ }
+ didZoom = true;
+ geo.render(true);
+ var rotate = projection.rotate();
+ var center = projection.invert(geo.midPt);
+ geo.graphDiv.emit("plotly_relayouting", {
+ "geo.projection.scale": projection.scale() / geo.fitScale,
+ "geo.center.lon": center[0],
+ "geo.center.lat": center[1],
+ "geo.projection.rotation.lon": -rotate[0]
+ });
+ }
+ function handleZoomend() {
+ d3.select(this).style(zoomendStyle);
+ if (didZoom) sync(geo, projection, syncCb);
+ }
+ function syncCb(set) {
+ var rotate = projection.rotate();
+ var center = projection.invert(geo.midPt);
+ set("projection.rotation.lon", -rotate[0]);
+ set("center.lon", center[0]);
+ set("center.lat", center[1]);
+ }
+ zoom.on("zoomstart", handleZoomstart).on("zoom", handleZoom).on("zoomend", handleZoomend);
+ return zoom;
+ }
+ function zoomClipped(geo, projection) {
+ var view = { r: projection.rotate(), k: projection.scale() };
+ var zoom = initZoom(geo, projection);
+ var event = d3eventDispatch(zoom, "zoomstart", "zoom", "zoomend");
+ var zooming = 0;
+ var zoomOn = zoom.on;
+ var zoomPoint;
+ zoom.on("zoomstart", function() {
+ d3.select(this).style(zoomstartStyle);
+ var mouse0 = d3.mouse(this);
+ var rotate0 = projection.rotate();
+ var lastRotate = rotate0;
+ var translate0 = projection.translate();
+ var q = quaternionFromEuler(rotate0);
+ zoomPoint = position(projection, mouse0);
+ zoomOn.call(zoom, "zoom", function() {
+ var mouse1 = d3.mouse(this);
+ projection.scale(view.k = d3.event.scale);
+ if (!zoomPoint) {
+ mouse0 = mouse1;
+ zoomPoint = position(projection, mouse0);
+ } else if (position(projection, mouse1)) {
+ projection.rotate(rotate0).translate(translate0);
+ var point1 = position(projection, mouse1);
+ var between = rotateBetween(zoomPoint, point1);
+ var newEuler = eulerFromQuaternion(multiply(q, between));
+ var rotateAngles = view.r = unRoll(newEuler, zoomPoint, lastRotate);
+ if (!isFinite(rotateAngles[0]) || !isFinite(rotateAngles[1]) || !isFinite(rotateAngles[2])) {
+ rotateAngles = lastRotate;
+ }
+ projection.rotate(rotateAngles);
+ lastRotate = rotateAngles;
+ }
+ zoomed(event.of(this, arguments));
+ });
+ zoomstarted(event.of(this, arguments));
+ }).on("zoomend", function() {
+ d3.select(this).style(zoomendStyle);
+ zoomOn.call(zoom, "zoom", null);
+ zoomended(event.of(this, arguments));
+ sync(geo, projection, syncCb);
+ }).on("zoom.redraw", function() {
+ geo.render(true);
+ var _rotate = projection.rotate();
+ geo.graphDiv.emit("plotly_relayouting", {
+ "geo.projection.scale": projection.scale() / geo.fitScale,
+ "geo.projection.rotation.lon": -_rotate[0],
+ "geo.projection.rotation.lat": -_rotate[1]
+ });
+ });
+ function zoomstarted(dispatch) {
+ if (!zooming++) dispatch({ type: "zoomstart" });
+ }
+ function zoomed(dispatch) {
+ dispatch({ type: "zoom" });
+ }
+ function zoomended(dispatch) {
+ if (!--zooming) dispatch({ type: "zoomend" });
+ }
+ function syncCb(set) {
+ var _rotate = projection.rotate();
+ set("projection.rotation.lon", -_rotate[0]);
+ set("projection.rotation.lat", -_rotate[1]);
+ }
+ return d3.rebind(zoom, event, "on");
+ }
+ function position(projection, point) {
+ var spherical = projection.invert(point);
+ return spherical && isFinite(spherical[0]) && isFinite(spherical[1]) && cartesian(spherical);
+ }
+ function quaternionFromEuler(euler) {
+ var lambda = 0.5 * euler[0] * radians2;
+ var phi = 0.5 * euler[1] * radians2;
+ var gamma2 = 0.5 * euler[2] * radians2;
+ var sinLambda = Math.sin(lambda);
+ var cosLambda = Math.cos(lambda);
+ var sinPhi = Math.sin(phi);
+ var cosPhi = Math.cos(phi);
+ var sinGamma = Math.sin(gamma2);
+ var cosGamma = Math.cos(gamma2);
+ return [
+ cosLambda * cosPhi * cosGamma + sinLambda * sinPhi * sinGamma,
+ sinLambda * cosPhi * cosGamma - cosLambda * sinPhi * sinGamma,
+ cosLambda * sinPhi * cosGamma + sinLambda * cosPhi * sinGamma,
+ cosLambda * cosPhi * sinGamma - sinLambda * sinPhi * cosGamma
+ ];
+ }
+ function multiply(a, b) {
+ var a0 = a[0];
+ var a1 = a[1];
+ var a2 = a[2];
+ var a3 = a[3];
+ var b0 = b[0];
+ var b1 = b[1];
+ var b2 = b[2];
+ var b3 = b[3];
+ return [
+ a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3,
+ a0 * b1 + a1 * b0 + a2 * b3 - a3 * b2,
+ a0 * b2 - a1 * b3 + a2 * b0 + a3 * b1,
+ a0 * b3 + a1 * b2 - a2 * b1 + a3 * b0
+ ];
+ }
+ function rotateBetween(a, b) {
+ if (!a || !b) return;
+ var axis = cross(a, b);
+ var norm = Math.sqrt(dot(axis, axis));
+ var halfgamma = 0.5 * Math.acos(Math.max(-1, Math.min(1, dot(a, b))));
+ var k = Math.sin(halfgamma) / norm;
+ return norm && [Math.cos(halfgamma), axis[2] * k, -axis[1] * k, axis[0] * k];
+ }
+ function unRoll(rotateAngles, pt, lastRotate) {
+ var ptRotated = rotateCartesian(pt, 2, rotateAngles[0]);
+ ptRotated = rotateCartesian(ptRotated, 1, rotateAngles[1]);
+ ptRotated = rotateCartesian(ptRotated, 0, rotateAngles[2] - lastRotate[2]);
+ var x = pt[0];
+ var y = pt[1];
+ var z = pt[2];
+ var f = ptRotated[0];
+ var g = ptRotated[1];
+ var h = ptRotated[2];
+ var theta = Math.atan2(y, x) * degrees3;
+ var a = Math.sqrt(x * x + y * y);
+ var b;
+ var newYaw1;
+ if (Math.abs(g) > a) {
+ newYaw1 = (g > 0 ? 90 : -90) - theta;
+ b = 0;
+ } else {
+ newYaw1 = Math.asin(g / a) * degrees3 - theta;
+ b = Math.sqrt(a * a - g * g);
+ }
+ var newYaw2 = 180 - newYaw1 - 2 * theta;
+ var newPitch1 = (Math.atan2(h, f) - Math.atan2(z, b)) * degrees3;
+ var newPitch2 = (Math.atan2(h, f) - Math.atan2(z, -b)) * degrees3;
+ var dist1 = angleDistance(lastRotate[0], lastRotate[1], newYaw1, newPitch1);
+ var dist2 = angleDistance(lastRotate[0], lastRotate[1], newYaw2, newPitch2);
+ if (dist1 <= dist2) return [newYaw1, newPitch1, lastRotate[2]];
+ else return [newYaw2, newPitch2, lastRotate[2]];
+ }
+ function angleDistance(yaw0, pitch0, yaw1, pitch1) {
+ var dYaw = angleMod(yaw1 - yaw0);
+ var dPitch = angleMod(pitch1 - pitch0);
+ return Math.sqrt(dYaw * dYaw + dPitch * dPitch);
+ }
+ function angleMod(angle) {
+ return (angle % 360 + 540) % 360 - 180;
+ }
+ function rotateCartesian(vector, axis, angle) {
+ var angleRads = angle * radians2;
+ var vectorOut = vector.slice();
+ var ax1 = axis === 0 ? 1 : 0;
+ var ax2 = axis === 2 ? 1 : 2;
+ var cosa = Math.cos(angleRads);
+ var sina = Math.sin(angleRads);
+ vectorOut[ax1] = vector[ax1] * cosa - vector[ax2] * sina;
+ vectorOut[ax2] = vector[ax2] * cosa + vector[ax1] * sina;
+ return vectorOut;
+ }
+ function eulerFromQuaternion(q) {
+ return [
+ Math.atan2(2 * (q[0] * q[1] + q[2] * q[3]), 1 - 2 * (q[1] * q[1] + q[2] * q[2])) * degrees3,
+ Math.asin(Math.max(-1, Math.min(1, 2 * (q[0] * q[2] - q[3] * q[1])))) * degrees3,
+ Math.atan2(2 * (q[0] * q[3] + q[1] * q[2]), 1 - 2 * (q[2] * q[2] + q[3] * q[3])) * degrees3
+ ];
+ }
+ function cartesian(spherical) {
+ var lambda = spherical[0] * radians2;
+ var phi = spherical[1] * radians2;
+ var cosPhi = Math.cos(phi);
+ return [
+ cosPhi * Math.cos(lambda),
+ cosPhi * Math.sin(lambda),
+ Math.sin(phi)
+ ];
+ }
+ function dot(a, b) {
+ var s = 0;
+ for (var i = 0, n = a.length; i < n; ++i) s += a[i] * b[i];
+ return s;
+ }
+ function cross(a, b) {
+ return [
+ a[1] * b[2] - a[2] * b[1],
+ a[2] * b[0] - a[0] * b[2],
+ a[0] * b[1] - a[1] * b[0]
+ ];
+ }
+ function d3eventDispatch(target) {
+ var i = 0;
+ var n = arguments.length;
+ var argumentz = [];
+ while (++i < n) argumentz.push(arguments[i]);
+ var dispatch = d3.dispatch.apply(null, argumentz);
+ dispatch.of = function(thiz, argumentz2) {
+ return function(e1) {
+ var e0;
+ try {
+ e0 = e1.sourceEvent = d3.event;
+ e1.target = target;
+ d3.event = e1;
+ dispatch[e1.type].apply(thiz, argumentz2);
+ } finally {
+ d3.event = e0;
+ }
+ };
+ };
+ return dispatch;
+ }
+ }
+ });
+
+ // src/plots/geo/geo.js
+ var require_geo = __commonJS({
+ "src/plots/geo/geo.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var geo = require_d3_geo();
+ var geoPath = geo.geoPath;
+ var geoDistance = geo.geoDistance;
+ var geoProjection = require_d3_geo_projection();
+ var Registry = require_registry();
+ var Lib = require_lib();
+ var strTranslate = Lib.strTranslate;
+ var Color2 = require_color();
+ var Drawing = require_drawing();
+ var Fx = require_fx();
+ var Plots = require_plots();
+ var Axes = require_axes();
+ var getAutoRange = require_autorange().getAutoRange;
+ var dragElement = require_dragelement();
+ var prepSelect = require_selections().prepSelect;
+ var clearOutline = require_selections().clearOutline;
+ var selectOnClick = require_selections().selectOnClick;
+ var createGeoZoom = require_zoom();
+ var constants = require_constants22();
+ var geoUtils = require_geo_location_utils();
+ var topojsonUtils = require_topojson_utils();
+ var topojsonFeature = require_topojson_client().feature;
+ function Geo(opts) {
+ this.id = opts.id;
+ this.graphDiv = opts.graphDiv;
+ this.container = opts.container;
+ this.topojsonURL = opts.topojsonURL;
+ this.isStatic = opts.staticPlot;
+ this.topojsonName = null;
+ this.topojson = null;
+ this.projection = null;
+ this.scope = null;
+ this.viewInitial = null;
+ this.fitScale = null;
+ this.bounds = null;
+ this.midPt = null;
+ this.hasChoropleth = false;
+ this.traceHash = {};
+ this.layers = {};
+ this.basePaths = {};
+ this.dataPaths = {};
+ this.dataPoints = {};
+ this.clipDef = null;
+ this.clipRect = null;
+ this.bgRect = null;
+ this.makeFramework();
+ }
+ var proto = Geo.prototype;
+ module.exports = function createGeo(opts) {
+ return new Geo(opts);
+ };
+ proto.plot = function(geoCalcData, fullLayout, promises, replot) {
+ var _this = this;
+ if (replot) return _this.update(geoCalcData, fullLayout, true);
+ _this._geoCalcData = geoCalcData;
+ _this._fullLayout = fullLayout;
+ var geoLayout = fullLayout[this.id];
+ var geoPromises = [];
+ var needsTopojson = false;
+ for (var k in constants.layerNameToAdjective) {
+ if (k !== "frame" && geoLayout["show" + k]) {
+ needsTopojson = true;
+ break;
+ }
+ }
+ var hasMarkerAngles = false;
+ for (var i = 0; i < geoCalcData.length; i++) {
+ var trace = geoCalcData[0][0].trace;
+ trace._geo = _this;
+ if (trace.locationmode) {
+ needsTopojson = true;
+ }
+ var marker = trace.marker;
+ if (marker) {
+ var angle = marker.angle;
+ var angleref = marker.angleref;
+ if (angle || angleref === "north" || angleref === "previous") hasMarkerAngles = true;
+ }
+ }
+ this._hasMarkerAngles = hasMarkerAngles;
+ if (needsTopojson) {
+ var topojsonNameNew = topojsonUtils.getTopojsonName(geoLayout);
+ if (_this.topojson === null || topojsonNameNew !== _this.topojsonName) {
+ _this.topojsonName = topojsonNameNew;
+ if (PlotlyGeoAssets.topojson[_this.topojsonName] === void 0) {
+ geoPromises.push(_this.fetchTopojson());
+ }
+ }
+ }
+ geoPromises = geoPromises.concat(geoUtils.fetchTraceGeoData(geoCalcData));
+ promises.push(new Promise(function(resolve, reject) {
+ Promise.all(geoPromises).then(function() {
+ _this.topojson = PlotlyGeoAssets.topojson[_this.topojsonName];
+ _this.update(geoCalcData, fullLayout);
+ resolve();
+ }).catch(reject);
+ }));
+ };
+ proto.fetchTopojson = function() {
+ var _this = this;
+ var topojsonPath = topojsonUtils.getTopojsonPath(_this.topojsonURL, _this.topojsonName);
+ return new Promise(function(resolve, reject) {
+ d3.json(topojsonPath, function(err, topojson) {
+ if (err) {
+ if (err.status === 404) {
+ return reject(new Error([
+ "plotly.js could not find topojson file at",
+ topojsonPath + ".",
+ "Make sure the *topojsonURL* plot config option",
+ "is set properly."
+ ].join(" ")));
+ } else {
+ return reject(new Error([
+ "unexpected error while fetching topojson file at",
+ topojsonPath
+ ].join(" ")));
+ }
+ }
+ PlotlyGeoAssets.topojson[_this.topojsonName] = topojson;
+ resolve();
+ });
+ });
+ };
+ proto.update = function(geoCalcData, fullLayout, replot) {
+ var geoLayout = fullLayout[this.id];
+ this.hasChoropleth = false;
+ for (var i = 0; i < geoCalcData.length; i++) {
+ var calcTrace = geoCalcData[i];
+ var trace = calcTrace[0].trace;
+ if (trace.type === "choropleth") {
+ this.hasChoropleth = true;
+ }
+ if (trace.visible === true && trace._length > 0) {
+ trace._module.calcGeoJSON(calcTrace, fullLayout);
+ }
+ }
+ if (!replot) {
+ var hasInvalidBounds = this.updateProjection(geoCalcData, fullLayout);
+ if (hasInvalidBounds) return;
+ if (!this.viewInitial || this.scope !== geoLayout.scope) {
+ this.saveViewInitial(geoLayout);
+ }
+ }
+ this.scope = geoLayout.scope;
+ this.updateBaseLayers(fullLayout, geoLayout);
+ this.updateDims(fullLayout, geoLayout);
+ this.updateFx(fullLayout, geoLayout);
+ Plots.generalUpdatePerTraceModule(this.graphDiv, this, geoCalcData, geoLayout);
+ var scatterLayer = this.layers.frontplot.select(".scatterlayer");
+ this.dataPoints.point = scatterLayer.selectAll(".point");
+ this.dataPoints.text = scatterLayer.selectAll("text");
+ this.dataPaths.line = scatterLayer.selectAll(".js-line");
+ var choroplethLayer = this.layers.backplot.select(".choroplethlayer");
+ this.dataPaths.choropleth = choroplethLayer.selectAll("path");
+ this._render();
+ };
+ proto.updateProjection = function(geoCalcData, fullLayout) {
+ var gd = this.graphDiv;
+ var geoLayout = fullLayout[this.id];
+ var gs = fullLayout._size;
+ var domain = geoLayout.domain;
+ var projLayout = geoLayout.projection;
+ var lonaxis = geoLayout.lonaxis;
+ var lataxis = geoLayout.lataxis;
+ var axLon = lonaxis._ax;
+ var axLat = lataxis._ax;
+ var projection = this.projection = getProjection(geoLayout);
+ var extent = [[
+ gs.l + gs.w * domain.x[0],
+ gs.t + gs.h * (1 - domain.y[1])
+ ], [
+ gs.l + gs.w * domain.x[1],
+ gs.t + gs.h * (1 - domain.y[0])
+ ]];
+ var center = geoLayout.center || {};
+ var rotation = projLayout.rotation || {};
+ var lonaxisRange = lonaxis.range || [];
+ var lataxisRange = lataxis.range || [];
+ if (geoLayout.fitbounds) {
+ axLon._length = extent[1][0] - extent[0][0];
+ axLat._length = extent[1][1] - extent[0][1];
+ axLon.range = getAutoRange(gd, axLon);
+ axLat.range = getAutoRange(gd, axLat);
+ var midLon = (axLon.range[0] + axLon.range[1]) / 2;
+ var midLat = (axLat.range[0] + axLat.range[1]) / 2;
+ if (geoLayout._isScoped) {
+ center = { lon: midLon, lat: midLat };
+ } else if (geoLayout._isClipped) {
+ center = { lon: midLon, lat: midLat };
+ rotation = { lon: midLon, lat: midLat, roll: rotation.roll };
+ var projType = projLayout.type;
+ var lonHalfSpan = constants.lonaxisSpan[projType] / 2 || 180;
+ var latHalfSpan = constants.lataxisSpan[projType] / 2 || 90;
+ lonaxisRange = [midLon - lonHalfSpan, midLon + lonHalfSpan];
+ lataxisRange = [midLat - latHalfSpan, midLat + latHalfSpan];
+ } else {
+ center = { lon: midLon, lat: midLat };
+ rotation = { lon: midLon, lat: rotation.lat, roll: rotation.roll };
+ }
+ }
+ projection.center([center.lon - rotation.lon, center.lat - rotation.lat]).rotate([-rotation.lon, -rotation.lat, rotation.roll]).parallels(projLayout.parallels);
+ var rangeBox = makeRangeBox(lonaxisRange, lataxisRange);
+ projection.fitExtent(extent, rangeBox);
+ var b = this.bounds = projection.getBounds(rangeBox);
+ var s = this.fitScale = projection.scale();
+ var t = projection.translate();
+ if (geoLayout.fitbounds) {
+ var b2 = projection.getBounds(makeRangeBox(axLon.range, axLat.range));
+ var k2 = Math.min(
+ (b[1][0] - b[0][0]) / (b2[1][0] - b2[0][0]),
+ (b[1][1] - b[0][1]) / (b2[1][1] - b2[0][1])
+ );
+ if (isFinite(k2)) {
+ projection.scale(k2 * s);
+ } else {
+ Lib.warn("Something went wrong during" + this.id + "fitbounds computations.");
+ }
+ } else {
+ projection.scale(projLayout.scale * s);
+ }
+ var midPt = this.midPt = [
+ (b[0][0] + b[1][0]) / 2,
+ (b[0][1] + b[1][1]) / 2
+ ];
+ projection.translate([t[0] + (midPt[0] - t[0]), t[1] + (midPt[1] - t[1])]).clipExtent(b);
+ if (geoLayout._isAlbersUsa) {
+ var centerPx = projection([center.lon, center.lat]);
+ var tt = projection.translate();
+ projection.translate([
+ tt[0] - (centerPx[0] - tt[0]),
+ tt[1] - (centerPx[1] - tt[1])
+ ]);
+ }
+ };
+ proto.updateBaseLayers = function(fullLayout, geoLayout) {
+ var _this = this;
+ var topojson = _this.topojson;
+ var layers = _this.layers;
+ var basePaths = _this.basePaths;
+ function isAxisLayer(d) {
+ return d === "lonaxis" || d === "lataxis";
+ }
+ function isLineLayer(d) {
+ return Boolean(constants.lineLayers[d]);
+ }
+ function isFillLayer(d) {
+ return Boolean(constants.fillLayers[d]);
+ }
+ var allLayers = this.hasChoropleth ? constants.layersForChoropleth : constants.layers;
+ var layerData = allLayers.filter(function(d) {
+ return isLineLayer(d) || isFillLayer(d) ? geoLayout["show" + d] : isAxisLayer(d) ? geoLayout[d].showgrid : true;
+ });
+ var join = _this.framework.selectAll(".layer").data(layerData, String);
+ join.exit().each(function(d) {
+ delete layers[d];
+ delete basePaths[d];
+ d3.select(this).remove();
+ });
+ join.enter().append("g").attr("class", function(d) {
+ return "layer " + d;
+ }).each(function(d) {
+ var layer = layers[d] = d3.select(this);
+ if (d === "bg") {
+ _this.bgRect = layer.append("rect").style("pointer-events", "all");
+ } else if (isAxisLayer(d)) {
+ basePaths[d] = layer.append("path").style("fill", "none");
+ } else if (d === "backplot") {
+ layer.append("g").classed("choroplethlayer", true);
+ } else if (d === "frontplot") {
+ layer.append("g").classed("scatterlayer", true);
+ } else if (isLineLayer(d)) {
+ basePaths[d] = layer.append("path").style("fill", "none").style("stroke-miterlimit", 2);
+ } else if (isFillLayer(d)) {
+ basePaths[d] = layer.append("path").style("stroke", "none");
+ }
+ });
+ join.order();
+ join.each(function(d) {
+ var path = basePaths[d];
+ var adj = constants.layerNameToAdjective[d];
+ if (d === "frame") {
+ path.datum(constants.sphereSVG);
+ } else if (isLineLayer(d) || isFillLayer(d)) {
+ path.datum(topojsonFeature(topojson, topojson.objects[d]));
+ } else if (isAxisLayer(d)) {
+ path.datum(makeGraticule(d, geoLayout, fullLayout)).call(Color2.stroke, geoLayout[d].gridcolor).call(Drawing.dashLine, geoLayout[d].griddash, geoLayout[d].gridwidth);
+ }
+ if (isLineLayer(d)) {
+ path.call(Color2.stroke, geoLayout[adj + "color"]).call(Drawing.dashLine, "", geoLayout[adj + "width"]);
+ } else if (isFillLayer(d)) {
+ path.call(Color2.fill, geoLayout[adj + "color"]);
+ }
+ });
+ };
+ proto.updateDims = function(fullLayout, geoLayout) {
+ var b = this.bounds;
+ var hFrameWidth = (geoLayout.framewidth || 0) / 2;
+ var l = b[0][0] - hFrameWidth;
+ var t = b[0][1] - hFrameWidth;
+ var w = b[1][0] - l + hFrameWidth;
+ var h = b[1][1] - t + hFrameWidth;
+ Drawing.setRect(this.clipRect, l, t, w, h);
+ this.bgRect.call(Drawing.setRect, l, t, w, h).call(Color2.fill, geoLayout.bgcolor);
+ this.xaxis._offset = l;
+ this.xaxis._length = w;
+ this.yaxis._offset = t;
+ this.yaxis._length = h;
+ };
+ proto.updateFx = function(fullLayout, geoLayout) {
+ var _this = this;
+ var gd = _this.graphDiv;
+ var bgRect = _this.bgRect;
+ var dragMode = fullLayout.dragmode;
+ var clickMode = fullLayout.clickmode;
+ if (_this.isStatic) return;
+ function zoomReset() {
+ var viewInitial = _this.viewInitial;
+ var updateObj = {};
+ for (var k in viewInitial) {
+ updateObj[_this.id + "." + k] = viewInitial[k];
+ }
+ Registry.call("_guiRelayout", gd, updateObj);
+ gd.emit("plotly_doubleclick", null);
+ }
+ function invert(lonlat) {
+ return _this.projection.invert([
+ lonlat[0] + _this.xaxis._offset,
+ lonlat[1] + _this.yaxis._offset
+ ]);
+ }
+ var fillRangeItems = function(eventData, poly) {
+ if (poly.isRect) {
+ var ranges = eventData.range = {};
+ ranges[_this.id] = [
+ invert([poly.xmin, poly.ymin]),
+ invert([poly.xmax, poly.ymax])
+ ];
+ } else {
+ var dataPts = eventData.lassoPoints = {};
+ dataPts[_this.id] = poly.map(invert);
+ }
+ };
+ var dragOptions = {
+ element: _this.bgRect.node(),
+ gd,
+ plotinfo: {
+ id: _this.id,
+ xaxis: _this.xaxis,
+ yaxis: _this.yaxis,
+ fillRangeItems
+ },
+ xaxes: [_this.xaxis],
+ yaxes: [_this.yaxis],
+ subplot: _this.id,
+ clickFn: function(numClicks) {
+ if (numClicks === 2) {
+ clearOutline(gd);
+ }
+ }
+ };
+ if (dragMode === "pan") {
+ bgRect.node().onmousedown = null;
+ bgRect.call(createGeoZoom(_this, geoLayout));
+ bgRect.on("dblclick.zoom", zoomReset);
+ if (!gd._context._scrollZoom.geo) {
+ bgRect.on("wheel.zoom", null);
+ }
+ } else if (dragMode === "select" || dragMode === "lasso") {
+ bgRect.on(".zoom", null);
+ dragOptions.prepFn = function(e, startX, startY) {
+ prepSelect(e, startX, startY, dragOptions, dragMode);
+ };
+ dragElement.init(dragOptions);
+ }
+ bgRect.on("mousemove", function() {
+ var lonlat = _this.projection.invert(Lib.getPositionFromD3Event());
+ if (!lonlat) {
+ return dragElement.unhover(gd, d3.event);
+ }
+ _this.xaxis.p2c = function() {
+ return lonlat[0];
+ };
+ _this.yaxis.p2c = function() {
+ return lonlat[1];
+ };
+ Fx.hover(gd, d3.event, _this.id);
+ });
+ bgRect.on("mouseout", function() {
+ if (gd._dragging) return;
+ dragElement.unhover(gd, d3.event);
+ });
+ bgRect.on("click", function() {
+ if (dragMode !== "select" && dragMode !== "lasso") {
+ if (clickMode.indexOf("select") > -1) {
+ selectOnClick(
+ d3.event,
+ gd,
+ [_this.xaxis],
+ [_this.yaxis],
+ _this.id,
+ dragOptions
+ );
+ }
+ if (clickMode.indexOf("event") > -1) {
+ Fx.click(gd, d3.event);
+ }
+ }
+ });
+ };
+ proto.makeFramework = function() {
+ var _this = this;
+ var gd = _this.graphDiv;
+ var fullLayout = gd._fullLayout;
+ var clipId = "clip" + fullLayout._uid + _this.id;
+ _this.clipDef = fullLayout._clips.append("clipPath").attr("id", clipId);
+ _this.clipRect = _this.clipDef.append("rect");
+ _this.framework = d3.select(_this.container).append("g").attr("class", "geo " + _this.id).call(Drawing.setClipUrl, clipId, gd);
+ _this.project = function(v) {
+ var px = _this.projection(v);
+ return px ? [px[0] - _this.xaxis._offset, px[1] - _this.yaxis._offset] : [null, null];
+ };
+ _this.xaxis = {
+ _id: "x",
+ c2p: function(v) {
+ return _this.project(v)[0];
+ }
+ };
+ _this.yaxis = {
+ _id: "y",
+ c2p: function(v) {
+ return _this.project(v)[1];
+ }
+ };
+ _this.mockAxis = {
+ type: "linear",
+ showexponent: "all",
+ exponentformat: "B"
+ };
+ Axes.setConvert(_this.mockAxis, fullLayout);
+ };
+ proto.saveViewInitial = function(geoLayout) {
+ var center = geoLayout.center || {};
+ var projLayout = geoLayout.projection;
+ var rotation = projLayout.rotation || {};
+ this.viewInitial = {
+ fitbounds: geoLayout.fitbounds,
+ "projection.scale": projLayout.scale
+ };
+ var extra;
+ if (geoLayout._isScoped) {
+ extra = {
+ "center.lon": center.lon,
+ "center.lat": center.lat
+ };
+ } else if (geoLayout._isClipped) {
+ extra = {
+ "projection.rotation.lon": rotation.lon,
+ "projection.rotation.lat": rotation.lat
+ };
+ } else {
+ extra = {
+ "center.lon": center.lon,
+ "center.lat": center.lat,
+ "projection.rotation.lon": rotation.lon
+ };
+ }
+ Lib.extendFlat(this.viewInitial, extra);
+ };
+ proto.render = function(mayRedrawOnUpdates) {
+ if (this._hasMarkerAngles && mayRedrawOnUpdates) {
+ this.plot(this._geoCalcData, this._fullLayout, [], true);
+ } else {
+ this._render();
+ }
+ };
+ proto._render = function() {
+ var projection = this.projection;
+ var pathFn = projection.getPath();
+ var k;
+ function translatePoints(d) {
+ var lonlatPx = projection(d.lonlat);
+ return lonlatPx ? strTranslate(lonlatPx[0], lonlatPx[1]) : null;
+ }
+ function hideShowPoints(d) {
+ return projection.isLonLatOverEdges(d.lonlat) ? "none" : null;
+ }
+ for (k in this.basePaths) {
+ this.basePaths[k].attr("d", pathFn);
+ }
+ for (k in this.dataPaths) {
+ this.dataPaths[k].attr("d", function(d) {
+ return pathFn(d.geojson);
+ });
+ }
+ for (k in this.dataPoints) {
+ this.dataPoints[k].attr("display", hideShowPoints).attr("transform", translatePoints);
+ }
+ };
+ function getProjection(geoLayout) {
+ var projLayout = geoLayout.projection;
+ var projType = projLayout.type;
+ var projName = constants.projNames[projType];
+ projName = "geo" + Lib.titleCase(projName);
+ var projFn = geo[projName] || geoProjection[projName];
+ var projection = projFn();
+ var clipAngle = geoLayout._isSatellite ? Math.acos(1 / projLayout.distance) * 180 / Math.PI : geoLayout._isClipped ? constants.lonaxisSpan[projType] / 2 : null;
+ var methods = ["center", "rotate", "parallels", "clipExtent"];
+ var dummyFn = function(_) {
+ return _ ? projection : [];
+ };
+ for (var i = 0; i < methods.length; i++) {
+ var m = methods[i];
+ if (typeof projection[m] !== "function") {
+ projection[m] = dummyFn;
+ }
+ }
+ projection.isLonLatOverEdges = function(lonlat) {
+ if (projection(lonlat) === null) {
+ return true;
+ }
+ if (clipAngle) {
+ var r = projection.rotate();
+ var angle = geoDistance(lonlat, [-r[0], -r[1]]);
+ var maxAngle = clipAngle * Math.PI / 180;
+ return angle > maxAngle;
+ } else {
+ return false;
+ }
+ };
+ projection.getPath = function() {
+ return geoPath().projection(projection);
+ };
+ projection.getBounds = function(object) {
+ return projection.getPath().bounds(object);
+ };
+ projection.precision(constants.precision);
+ if (geoLayout._isSatellite) {
+ projection.tilt(projLayout.tilt).distance(projLayout.distance);
+ }
+ if (clipAngle) {
+ projection.clipAngle(clipAngle - constants.clipPad);
+ }
+ return projection;
+ }
+ function makeGraticule(axisName, geoLayout, fullLayout) {
+ var epsilon = 1e-6;
+ var precision = 2.5;
+ var axLayout = geoLayout[axisName];
+ var scopeDefaults = constants.scopeDefaults[geoLayout.scope];
+ var rng;
+ var oppRng;
+ var coordFn;
+ if (axisName === "lonaxis") {
+ rng = scopeDefaults.lonaxisRange;
+ oppRng = scopeDefaults.lataxisRange;
+ coordFn = function(v2, l2) {
+ return [v2, l2];
+ };
+ } else if (axisName === "lataxis") {
+ rng = scopeDefaults.lataxisRange;
+ oppRng = scopeDefaults.lonaxisRange;
+ coordFn = function(v2, l2) {
+ return [l2, v2];
+ };
+ }
+ var dummyAx = {
+ type: "linear",
+ range: [rng[0], rng[1] - epsilon],
+ tick0: axLayout.tick0,
+ dtick: axLayout.dtick
+ };
+ Axes.setConvert(dummyAx, fullLayout);
+ var vals = Axes.calcTicks(dummyAx);
+ if (!geoLayout.isScoped && axisName === "lonaxis") {
+ vals.pop();
+ }
+ var len = vals.length;
+ var coords = new Array(len);
+ for (var i = 0; i < len; i++) {
+ var v = vals[i].x;
+ var line = coords[i] = [];
+ for (var l = oppRng[0]; l < oppRng[1] + precision; l += precision) {
+ line.push(coordFn(v, l));
+ }
+ }
+ return {
+ type: "MultiLineString",
+ coordinates: coords
+ };
+ }
+ function makeRangeBox(lon, lat) {
+ var clipPad = constants.clipPad;
+ var lon0 = lon[0] + clipPad;
+ var lon1 = lon[1] - clipPad;
+ var lat0 = lat[0] + clipPad;
+ var lat1 = lat[1] - clipPad;
+ if (lon0 > 0 && lon1 < 0) lon1 += 360;
+ var dlon4 = (lon1 - lon0) / 4;
+ return {
+ type: "Polygon",
+ coordinates: [[
+ [lon0, lat0],
+ [lon0, lat1],
+ [lon0 + dlon4, lat1],
+ [lon0 + 2 * dlon4, lat1],
+ [lon0 + 3 * dlon4, lat1],
+ [lon1, lat1],
+ [lon1, lat0],
+ [lon1 - dlon4, lat0],
+ [lon1 - 2 * dlon4, lat0],
+ [lon1 - 3 * dlon4, lat0],
+ [lon0, lat0]
+ ]]
+ };
+ }
+ }
+ });
+
+ // src/plots/geo/layout_attributes.js
+ var require_layout_attributes18 = __commonJS({
+ "src/plots/geo/layout_attributes.js"(exports, module) {
+ "use strict";
+ var colorAttrs = require_attributes3();
+ var domainAttrs = require_domain().attributes;
+ var dash = require_attributes4().dash;
+ var constants = require_constants22();
+ var overrideAll = require_edit_types().overrideAll;
+ var sortObjectKeys = require_sort_object_keys();
+ var geoAxesAttrs = {
+ range: {
+ valType: "info_array",
+ items: [
+ { valType: "number" },
+ { valType: "number" }
+ ]
+ },
+ showgrid: {
+ valType: "boolean",
+ dflt: false
+ },
+ tick0: {
+ valType: "number",
+ dflt: 0
+ },
+ dtick: {
+ valType: "number"
+ },
+ gridcolor: {
+ valType: "color",
+ dflt: colorAttrs.lightLine
+ },
+ gridwidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1
+ },
+ griddash: dash
+ };
+ var attrs = module.exports = overrideAll({
+ domain: domainAttrs({ name: "geo" }, {}),
+ fitbounds: {
+ valType: "enumerated",
+ values: [false, "locations", "geojson"],
+ dflt: false,
+ editType: "plot"
+ },
+ resolution: {
+ valType: "enumerated",
+ values: [110, 50],
+ dflt: 110,
+ coerceNumber: true
+ },
+ scope: {
+ valType: "enumerated",
+ values: sortObjectKeys(constants.scopeDefaults),
+ dflt: "world"
+ },
+ projection: {
+ type: {
+ valType: "enumerated",
+ values: sortObjectKeys(constants.projNames)
+ },
+ rotation: {
+ lon: {
+ valType: "number"
+ },
+ lat: {
+ valType: "number"
+ },
+ roll: {
+ valType: "number"
+ }
+ },
+ tilt: {
+ valType: "number",
+ dflt: 0
+ },
+ distance: {
+ valType: "number",
+ min: 1.001,
+ dflt: 2
+ },
+ parallels: {
+ valType: "info_array",
+ items: [
+ { valType: "number" },
+ { valType: "number" }
+ ]
+ },
+ scale: {
+ valType: "number",
+ min: 0,
+ dflt: 1
+ }
+ },
+ center: {
+ lon: {
+ valType: "number"
+ },
+ lat: {
+ valType: "number"
+ }
+ },
+ visible: {
+ valType: "boolean",
+ dflt: true
+ },
+ showcoastlines: {
+ valType: "boolean"
+ },
+ coastlinecolor: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine
+ },
+ coastlinewidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1
+ },
+ showland: {
+ valType: "boolean",
+ dflt: false
+ },
+ landcolor: {
+ valType: "color",
+ dflt: constants.landColor
+ },
+ showocean: {
+ valType: "boolean",
+ dflt: false
+ },
+ oceancolor: {
+ valType: "color",
+ dflt: constants.waterColor
+ },
+ showlakes: {
+ valType: "boolean",
+ dflt: false
+ },
+ lakecolor: {
+ valType: "color",
+ dflt: constants.waterColor
+ },
+ showrivers: {
+ valType: "boolean",
+ dflt: false
+ },
+ rivercolor: {
+ valType: "color",
+ dflt: constants.waterColor
+ },
+ riverwidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1
+ },
+ showcountries: {
+ valType: "boolean"
+ },
+ countrycolor: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine
+ },
+ countrywidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1
+ },
+ showsubunits: {
+ valType: "boolean"
+ },
+ subunitcolor: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine
+ },
+ subunitwidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1
+ },
+ showframe: {
+ valType: "boolean"
+ },
+ framecolor: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine
+ },
+ framewidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1
+ },
+ bgcolor: {
+ valType: "color",
+ dflt: colorAttrs.background
+ },
+ lonaxis: geoAxesAttrs,
+ lataxis: geoAxesAttrs
+ }, "plot", "from-root");
+ attrs.uirevision = {
+ valType: "any",
+ editType: "none"
+ };
+ }
+ });
+
+ // src/plots/geo/layout_defaults.js
+ var require_layout_defaults16 = __commonJS({
+ "src/plots/geo/layout_defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var handleSubplotDefaults = require_subplot_defaults();
+ var getSubplotData = require_get_data().getSubplotData;
+ var constants = require_constants22();
+ var layoutAttributes = require_layout_attributes18();
+ var axesNames = constants.axesNames;
+ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
+ handleSubplotDefaults(layoutIn, layoutOut, fullData, {
+ type: "geo",
+ attributes: layoutAttributes,
+ handleDefaults: handleGeoDefaults,
+ fullData,
+ partition: "y"
+ });
+ };
+ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
+ var subplotData = getSubplotData(opts.fullData, "geo", opts.id);
+ var traceIndices = subplotData.map(function(t) {
+ return t.index;
+ });
+ var resolution = coerce("resolution");
+ var scope = coerce("scope");
+ var scopeParams = constants.scopeDefaults[scope];
+ var projType = coerce("projection.type", scopeParams.projType);
+ var isAlbersUsa = geoLayoutOut._isAlbersUsa = projType === "albers usa";
+ if (isAlbersUsa) scope = geoLayoutOut.scope = "usa";
+ var isScoped = geoLayoutOut._isScoped = scope !== "world";
+ var isSatellite = geoLayoutOut._isSatellite = projType === "satellite";
+ var isConic = geoLayoutOut._isConic = projType.indexOf("conic") !== -1 || projType === "albers";
+ var isClipped = geoLayoutOut._isClipped = !!constants.lonaxisSpan[projType];
+ if (geoLayoutIn.visible === false) {
+ var newTemplate = Lib.extendDeep({}, geoLayoutOut._template);
+ newTemplate.showcoastlines = false;
+ newTemplate.showcountries = false;
+ newTemplate.showframe = false;
+ newTemplate.showlakes = false;
+ newTemplate.showland = false;
+ newTemplate.showocean = false;
+ newTemplate.showrivers = false;
+ newTemplate.showsubunits = false;
+ if (newTemplate.lonaxis) newTemplate.lonaxis.showgrid = false;
+ if (newTemplate.lataxis) newTemplate.lataxis.showgrid = false;
+ geoLayoutOut._template = newTemplate;
+ }
+ var visible = coerce("visible");
+ var show;
+ for (var i = 0; i < axesNames.length; i++) {
+ var axisName = axesNames[i];
+ var dtickDflt = [30, 10][i];
+ var rangeDflt;
+ if (isScoped) {
+ rangeDflt = scopeParams[axisName + "Range"];
+ } else {
+ var dfltSpans = constants[axisName + "Span"];
+ var hSpan = (dfltSpans[projType] || dfltSpans["*"]) / 2;
+ var rot = coerce(
+ "projection.rotation." + axisName.substr(0, 3),
+ scopeParams.projRotate[i]
+ );
+ rangeDflt = [rot - hSpan, rot + hSpan];
+ }
+ var range = coerce(axisName + ".range", rangeDflt);
+ coerce(axisName + ".tick0");
+ coerce(axisName + ".dtick", dtickDflt);
+ show = coerce(axisName + ".showgrid", !visible ? false : void 0);
+ if (show) {
+ coerce(axisName + ".gridcolor");
+ coerce(axisName + ".gridwidth");
+ coerce(axisName + ".griddash");
+ }
+ geoLayoutOut[axisName]._ax = {
+ type: "linear",
+ _id: axisName.slice(0, 3),
+ _traceIndices: traceIndices,
+ setScale: Lib.identity,
+ c2l: Lib.identity,
+ r2l: Lib.identity,
+ autorange: true,
+ range: range.slice(),
+ _m: 1,
+ _input: {}
+ };
+ }
+ var lonRange = geoLayoutOut.lonaxis.range;
+ var latRange = geoLayoutOut.lataxis.range;
+ var lon0 = lonRange[0];
+ var lon1 = lonRange[1];
+ if (lon0 > 0 && lon1 < 0) lon1 += 360;
+ var centerLon = (lon0 + lon1) / 2;
+ var projLon;
+ if (!isAlbersUsa) {
+ var dfltProjRotate = isScoped ? scopeParams.projRotate : [centerLon, 0, 0];
+ projLon = coerce("projection.rotation.lon", dfltProjRotate[0]);
+ coerce("projection.rotation.lat", dfltProjRotate[1]);
+ coerce("projection.rotation.roll", dfltProjRotate[2]);
+ show = coerce("showcoastlines", !isScoped && visible);
+ if (show) {
+ coerce("coastlinecolor");
+ coerce("coastlinewidth");
+ }
+ show = coerce("showocean", !visible ? false : void 0);
+ if (show) coerce("oceancolor");
+ }
+ var centerLonDflt;
+ var centerLatDflt;
+ if (isAlbersUsa) {
+ centerLonDflt = -96.6;
+ centerLatDflt = 38.7;
+ } else {
+ centerLonDflt = isScoped ? centerLon : projLon;
+ centerLatDflt = (latRange[0] + latRange[1]) / 2;
+ }
+ coerce("center.lon", centerLonDflt);
+ coerce("center.lat", centerLatDflt);
+ if (isSatellite) {
+ coerce("projection.tilt");
+ coerce("projection.distance");
+ }
+ if (isConic) {
+ var dfltProjParallels = scopeParams.projParallels || [0, 60];
+ coerce("projection.parallels", dfltProjParallels);
+ }
+ coerce("projection.scale");
+ show = coerce("showland", !visible ? false : void 0);
+ if (show) coerce("landcolor");
+ show = coerce("showlakes", !visible ? false : void 0);
+ if (show) coerce("lakecolor");
+ show = coerce("showrivers", !visible ? false : void 0);
+ if (show) {
+ coerce("rivercolor");
+ coerce("riverwidth");
+ }
+ show = coerce("showcountries", isScoped && scope !== "usa" && visible);
+ if (show) {
+ coerce("countrycolor");
+ coerce("countrywidth");
+ }
+ if (scope === "usa" || scope === "north america" && resolution === 50) {
+ coerce("showsubunits", visible);
+ coerce("subunitcolor");
+ coerce("subunitwidth");
+ }
+ if (!isScoped) {
+ show = coerce("showframe", visible);
+ if (show) {
+ coerce("framecolor");
+ coerce("framewidth");
+ }
+ }
+ coerce("bgcolor");
+ var fitBounds = coerce("fitbounds");
+ if (fitBounds) {
+ delete geoLayoutOut.projection.scale;
+ if (isScoped) {
+ delete geoLayoutOut.center.lon;
+ delete geoLayoutOut.center.lat;
+ } else if (isClipped) {
+ delete geoLayoutOut.center.lon;
+ delete geoLayoutOut.center.lat;
+ delete geoLayoutOut.projection.rotation.lon;
+ delete geoLayoutOut.projection.rotation.lat;
+ delete geoLayoutOut.lonaxis.range;
+ delete geoLayoutOut.lataxis.range;
+ } else {
+ delete geoLayoutOut.center.lon;
+ delete geoLayoutOut.center.lat;
+ delete geoLayoutOut.projection.rotation.lon;
+ }
+ }
+ }
+ }
+ });
+
+ // src/plots/geo/index.js
+ var require_geo2 = __commonJS({
+ "src/plots/geo/index.js"(exports, module) {
+ "use strict";
+ var getSubplotCalcData = require_get_data().getSubplotCalcData;
+ var counterRegex = require_lib().counterRegex;
+ var createGeo = require_geo();
+ var GEO = "geo";
+ var counter = counterRegex(GEO);
+ var attributes = {};
+ attributes[GEO] = {
+ valType: "subplotid",
+ dflt: GEO,
+ editType: "calc"
+ };
+ function plotGeo(gd) {
+ var fullLayout = gd._fullLayout;
+ var calcData = gd.calcdata;
+ var geoIds = fullLayout._subplots[GEO];
+ for (var i = 0; i < geoIds.length; i++) {
+ var geoId = geoIds[i];
+ var geoCalcData = getSubplotCalcData(calcData, GEO, geoId);
+ var geoLayout = fullLayout[geoId];
+ var geo = geoLayout._subplot;
+ if (!geo) {
+ geo = createGeo({
+ id: geoId,
+ graphDiv: gd,
+ container: fullLayout._geolayer.node(),
+ topojsonURL: gd._context.topojsonURL,
+ staticPlot: gd._context.staticPlot
+ });
+ fullLayout[geoId]._subplot = geo;
+ }
+ geo.plot(geoCalcData, fullLayout, gd._promises);
+ }
+ }
+ function clean(newFullData, newFullLayout, oldFullData, oldFullLayout) {
+ var oldGeoKeys = oldFullLayout._subplots[GEO] || [];
+ for (var i = 0; i < oldGeoKeys.length; i++) {
+ var oldGeoKey = oldGeoKeys[i];
+ var oldGeo = oldFullLayout[oldGeoKey]._subplot;
+ if (!newFullLayout[oldGeoKey] && !!oldGeo) {
+ oldGeo.framework.remove();
+ oldGeo.clipDef.remove();
+ }
+ }
+ }
+ function updateFx(gd) {
+ var fullLayout = gd._fullLayout;
+ var subplotIds = fullLayout._subplots[GEO];
+ for (var i = 0; i < subplotIds.length; i++) {
+ var subplotLayout = fullLayout[subplotIds[i]];
+ var subplotObj = subplotLayout._subplot;
+ subplotObj.updateFx(fullLayout, subplotLayout);
+ }
+ }
+ module.exports = {
+ attr: GEO,
+ name: GEO,
+ idRoot: GEO,
+ idRegex: counter,
+ attrRegex: counter,
+ attributes,
+ layoutAttributes: require_layout_attributes18(),
+ supplyLayoutDefaults: require_layout_defaults16(),
+ plot: plotGeo,
+ updateFx,
+ clean
+ };
+ }
+ });
+
+ // src/traces/scattergeo/index.js
+ var require_scattergeo = __commonJS({
+ "src/traces/scattergeo/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes48(),
+ supplyDefaults: require_defaults44(),
+ colorbar: require_marker_colorbar(),
+ formatLabels: require_format_labels3(),
+ calc: require_calc27(),
+ calcGeoJSON: require_plot17().calcGeoJSON,
+ plot: require_plot17().plot,
+ style: require_style17(),
+ styleOnSelect: require_style2().styleOnSelect,
+ hoverPoints: require_hover14(),
+ eventData: require_event_data9(),
+ selectPoints: require_select5(),
+ moduleType: "trace",
+ name: "scattergeo",
+ basePlotModule: require_geo2(),
+ categories: ["geo", "symbols", "showLegend", "scatter-like"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/scattergeo.js
+ var require_scattergeo2 = __commonJS({
+ "lib/scattergeo.js"(exports, module) {
+ "use strict";
+ module.exports = require_scattergeo();
+ }
+ });
+
+ // src/traces/choropleth/attributes.js
+ var require_attributes49 = __commonJS({
+ "src/traces/choropleth/attributes.js"(exports, module) {
+ "use strict";
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var scatterGeoAttrs = require_attributes48();
+ var colorScaleAttrs = require_attributes8();
+ var baseAttrs = require_attributes2();
+ var defaultLine = require_attributes3().defaultLine;
+ var extendFlat = require_extend().extendFlat;
+ var scatterGeoMarkerLineAttrs = scatterGeoAttrs.marker.line;
+ module.exports = extendFlat(
+ {
+ locations: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ locationmode: scatterGeoAttrs.locationmode,
+ z: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ geojson: extendFlat({}, scatterGeoAttrs.geojson, {}),
+ featureidkey: scatterGeoAttrs.featureidkey,
+ text: extendFlat({}, scatterGeoAttrs.text, {}),
+ hovertext: extendFlat({}, scatterGeoAttrs.hovertext, {}),
+ marker: {
+ line: {
+ color: extendFlat({}, scatterGeoMarkerLineAttrs.color, { dflt: defaultLine }),
+ width: extendFlat({}, scatterGeoMarkerLineAttrs.width, { dflt: 1 }),
+ editType: "calc"
+ },
+ opacity: {
+ valType: "number",
+ arrayOk: true,
+ min: 0,
+ max: 1,
+ dflt: 1,
+ editType: "style"
+ },
+ editType: "calc"
+ },
+ selected: {
+ marker: {
+ opacity: scatterGeoAttrs.selected.marker.opacity,
+ editType: "plot"
+ },
+ editType: "plot"
+ },
+ unselected: {
+ marker: {
+ opacity: scatterGeoAttrs.unselected.marker.opacity,
+ editType: "plot"
+ },
+ editType: "plot"
+ },
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ editType: "calc",
+ flags: ["location", "z", "text", "name"]
+ }),
+ hovertemplate: hovertemplateAttrs(),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ },
+ colorScaleAttrs("", {
+ cLetter: "z",
+ editTypeOverride: "calc"
+ })
+ );
+ }
+ });
+
+ // src/traces/choropleth/defaults.js
+ var require_defaults45 = __commonJS({
+ "src/traces/choropleth/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var colorscaleDefaults = require_defaults2();
+ var attributes = require_attributes49();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var locations = coerce("locations");
+ var z = coerce("z");
+ if (!(locations && locations.length && Lib.isArrayOrTypedArray(z) && z.length)) {
+ traceOut.visible = false;
+ return;
+ }
+ traceOut._length = Math.min(locations.length, z.length);
+ var geojson = coerce("geojson");
+ var locationmodeDflt;
+ if (typeof geojson === "string" && geojson !== "" || Lib.isPlainObject(geojson)) {
+ locationmodeDflt = "geojson-id";
+ }
+ var locationMode = coerce("locationmode", locationmodeDflt);
+ if (locationMode === "geojson-id") {
+ coerce("featureidkey");
+ }
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ var mlw = coerce("marker.line.width");
+ if (mlw) coerce("marker.line.color");
+ coerce("marker.opacity");
+ colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: "", cLetter: "z" });
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ }
+ });
+
+ // src/traces/choropleth/calc.js
+ var require_calc28 = __commonJS({
+ "src/traces/choropleth/calc.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var BADNUM = require_numerical().BADNUM;
+ var colorscaleCalc = require_calc();
+ var arraysToCalcdata = require_arrays_to_calcdata();
+ var calcSelection = require_calc_selection();
+ function isNonBlankString(v) {
+ return v && typeof v === "string";
+ }
+ module.exports = function calc(gd, trace) {
+ var len = trace._length;
+ var calcTrace = new Array(len);
+ var isValidLoc;
+ if (trace.geojson) {
+ isValidLoc = function(v) {
+ return isNonBlankString(v) || isNumeric(v);
+ };
+ } else {
+ isValidLoc = isNonBlankString;
+ }
+ for (var i = 0; i < len; i++) {
+ var calcPt = calcTrace[i] = {};
+ var loc = trace.locations[i];
+ var z = trace.z[i];
+ if (isValidLoc(loc) && isNumeric(z)) {
+ calcPt.loc = loc;
+ calcPt.z = z;
+ } else {
+ calcPt.loc = null;
+ calcPt.z = BADNUM;
+ }
+ calcPt.index = i;
+ }
+ arraysToCalcdata(calcTrace, trace);
+ colorscaleCalc(gd, trace, {
+ vals: trace.z,
+ containerStr: "",
+ cLetter: "z"
+ });
+ calcSelection(calcTrace, trace);
+ return calcTrace;
+ };
+ }
+ });
+
+ // src/traces/choropleth/style.js
+ var require_style18 = __commonJS({
+ "src/traces/choropleth/style.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var Color2 = require_color();
+ var Drawing = require_drawing();
+ var Colorscale = require_colorscale();
+ function style(gd, calcTrace) {
+ if (calcTrace) styleTrace(gd, calcTrace);
+ }
+ function styleTrace(gd, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var s = calcTrace[0].node3;
+ var locs = s.selectAll(".choroplethlocation");
+ var marker = trace.marker || {};
+ var markerLine = marker.line || {};
+ var sclFunc = Colorscale.makeColorScaleFuncFromTrace(trace);
+ locs.each(function(d) {
+ d3.select(this).attr("fill", sclFunc(d.z)).call(Color2.stroke, d.mlc || markerLine.color).call(Drawing.dashLine, "", d.mlw || markerLine.width || 0).style("opacity", marker.opacity);
+ });
+ Drawing.selectedPointStyle(locs, trace);
+ }
+ function styleOnSelect(gd, calcTrace) {
+ var s = calcTrace[0].node3;
+ var trace = calcTrace[0].trace;
+ if (trace.selectedpoints) {
+ Drawing.selectedPointStyle(s.selectAll(".choroplethlocation"), trace);
+ } else {
+ styleTrace(gd, calcTrace);
+ }
+ }
+ module.exports = {
+ style,
+ styleOnSelect
+ };
+ }
+ });
+
+ // src/traces/choropleth/plot.js
+ var require_plot18 = __commonJS({
+ "src/traces/choropleth/plot.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var Lib = require_lib();
+ var geoUtils = require_geo_location_utils();
+ var getTopojsonFeatures = require_topojson_utils().getTopojsonFeatures;
+ var findExtremes = require_autorange().findExtremes;
+ var style = require_style18().style;
+ function plot(gd, geo, calcData) {
+ var choroplethLayer = geo.layers.backplot.select(".choroplethlayer");
+ Lib.makeTraceGroups(choroplethLayer, calcData, "trace choropleth").each(function(calcTrace) {
+ var sel = d3.select(this);
+ var paths = sel.selectAll("path.choroplethlocation").data(Lib.identity);
+ paths.enter().append("path").classed("choroplethlocation", true);
+ paths.exit().remove();
+ style(gd, calcTrace);
+ });
+ }
+ function calcGeoJSON(calcTrace, fullLayout) {
+ var trace = calcTrace[0].trace;
+ var geoLayout = fullLayout[trace.geo];
+ var geo = geoLayout._subplot;
+ var locationmode = trace.locationmode;
+ var len = trace._length;
+ var features = locationmode === "geojson-id" ? geoUtils.extractTraceFeature(calcTrace) : getTopojsonFeatures(trace, geo.topojson);
+ var lonArray = [];
+ var latArray = [];
+ for (var i = 0; i < len; i++) {
+ var calcPt = calcTrace[i];
+ var feature = locationmode === "geojson-id" ? calcPt.fOut : geoUtils.locationToFeature(locationmode, calcPt.loc, features);
+ if (feature) {
+ calcPt.geojson = feature;
+ calcPt.ct = feature.properties.ct;
+ calcPt._polygons = geoUtils.feature2polygons(feature);
+ var bboxFeature = geoUtils.computeBbox(feature);
+ lonArray.push(bboxFeature[0], bboxFeature[2]);
+ latArray.push(bboxFeature[1], bboxFeature[3]);
+ } else {
+ calcPt.geojson = null;
+ }
+ }
+ if (geoLayout.fitbounds === "geojson" && locationmode === "geojson-id") {
+ var bboxGeojson = geoUtils.computeBbox(geoUtils.getTraceGeojson(trace));
+ lonArray = [bboxGeojson[0], bboxGeojson[2]];
+ latArray = [bboxGeojson[1], bboxGeojson[3]];
+ }
+ var opts = { padded: true };
+ trace._extremes.lon = findExtremes(geoLayout.lonaxis._ax, lonArray, opts);
+ trace._extremes.lat = findExtremes(geoLayout.lataxis._ax, latArray, opts);
+ }
+ module.exports = {
+ calcGeoJSON,
+ plot
+ };
+ }
+ });
+
+ // src/traces/choropleth/hover.js
+ var require_hover15 = __commonJS({
+ "src/traces/choropleth/hover.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ var attributes = require_attributes49();
+ var fillText = require_lib().fillText;
+ module.exports = function hoverPoints(pointData, xval, yval) {
+ var cd = pointData.cd;
+ var trace = cd[0].trace;
+ var geo = pointData.subplot;
+ var pt, i, j, isInside;
+ var xy = [xval, yval];
+ var altXy = [xval + 360, yval];
+ for (i = 0; i < cd.length; i++) {
+ pt = cd[i];
+ isInside = false;
+ if (pt._polygons) {
+ for (j = 0; j < pt._polygons.length; j++) {
+ if (pt._polygons[j].contains(xy)) {
+ isInside = !isInside;
+ }
+ if (pt._polygons[j].contains(altXy)) {
+ isInside = !isInside;
+ }
+ }
+ if (isInside) break;
+ }
+ }
+ if (!isInside || !pt) return;
+ pointData.x0 = pointData.x1 = pointData.xa.c2p(pt.ct);
+ pointData.y0 = pointData.y1 = pointData.ya.c2p(pt.ct);
+ pointData.index = pt.index;
+ pointData.location = pt.loc;
+ pointData.z = pt.z;
+ pointData.zLabel = Axes.tickText(geo.mockAxis, geo.mockAxis.c2l(pt.z), "hover").text;
+ pointData.hovertemplate = pt.hovertemplate;
+ makeHoverInfo(pointData, trace, pt);
+ return [pointData];
+ };
+ function makeHoverInfo(pointData, trace, pt) {
+ if (trace.hovertemplate) return;
+ var hoverinfo = pt.hi || trace.hoverinfo;
+ var loc = String(pt.loc);
+ var parts = hoverinfo === "all" ? attributes.hoverinfo.flags : hoverinfo.split("+");
+ var hasName = parts.indexOf("name") !== -1;
+ var hasLocation = parts.indexOf("location") !== -1;
+ var hasZ = parts.indexOf("z") !== -1;
+ var hasText = parts.indexOf("text") !== -1;
+ var hasIdAsNameLabel = !hasName && hasLocation;
+ var text = [];
+ if (hasIdAsNameLabel) {
+ pointData.nameOverride = loc;
+ } else {
+ if (hasName) pointData.nameOverride = trace.name;
+ if (hasLocation) text.push(loc);
+ }
+ if (hasZ) {
+ text.push(pointData.zLabel);
+ }
+ if (hasText) {
+ fillText(pt, trace, text);
+ }
+ pointData.extraText = text.join("
");
+ }
+ }
+ });
+
+ // src/traces/choropleth/event_data.js
+ var require_event_data10 = __commonJS({
+ "src/traces/choropleth/event_data.js"(exports, module) {
+ "use strict";
+ module.exports = function eventData(out, pt, trace, cd, pointNumber) {
+ out.location = pt.location;
+ out.z = pt.z;
+ var cdi = cd[pointNumber];
+ if (cdi.fIn && cdi.fIn.properties) {
+ out.properties = cdi.fIn.properties;
+ }
+ out.ct = cdi.ct;
+ return out;
+ };
+ }
+ });
+
+ // src/traces/choropleth/select.js
+ var require_select6 = __commonJS({
+ "src/traces/choropleth/select.js"(exports, module) {
+ "use strict";
+ module.exports = function selectPoints(searchInfo, selectionTester) {
+ var cd = searchInfo.cd;
+ var xa = searchInfo.xaxis;
+ var ya = searchInfo.yaxis;
+ var selection = [];
+ var i, di, ct, x, y;
+ if (selectionTester === false) {
+ for (i = 0; i < cd.length; i++) {
+ cd[i].selected = 0;
+ }
+ } else {
+ for (i = 0; i < cd.length; i++) {
+ di = cd[i];
+ ct = di.ct;
+ if (!ct) continue;
+ x = xa.c2p(ct);
+ y = ya.c2p(ct);
+ if (selectionTester.contains([x, y], null, i, searchInfo)) {
+ selection.push({
+ pointNumber: i,
+ lon: ct[0],
+ lat: ct[1]
+ });
+ di.selected = 1;
+ } else {
+ di.selected = 0;
+ }
+ }
+ }
+ return selection;
+ };
+ }
+ });
+
+ // src/traces/choropleth/index.js
+ var require_choropleth = __commonJS({
+ "src/traces/choropleth/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes49(),
+ supplyDefaults: require_defaults45(),
+ colorbar: require_colorbar2(),
+ calc: require_calc28(),
+ calcGeoJSON: require_plot18().calcGeoJSON,
+ plot: require_plot18().plot,
+ style: require_style18().style,
+ styleOnSelect: require_style18().styleOnSelect,
+ hoverPoints: require_hover15(),
+ eventData: require_event_data10(),
+ selectPoints: require_select6(),
+ moduleType: "trace",
+ name: "choropleth",
+ basePlotModule: require_geo2(),
+ categories: ["geo", "noOpacity", "showLegend"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/choropleth.js
+ var require_choropleth2 = __commonJS({
+ "lib/choropleth.js"(exports, module) {
+ "use strict";
+ module.exports = require_choropleth();
+ }
+ });
+
+ // src/traces/scattergl/hover.js
+ var require_hover16 = __commonJS({
+ "src/traces/scattergl/hover.js"(exports, module) {
+ "use strict";
+ var Registry = require_registry();
+ var Lib = require_lib();
+ var getTraceColor = require_get_trace_color();
+ function hoverPoints(pointData, xval, yval, hovermode) {
+ var cd = pointData.cd;
+ var stash = cd[0].t;
+ var trace = cd[0].trace;
+ var xa = pointData.xa;
+ var ya = pointData.ya;
+ var x = stash.x;
+ var y = stash.y;
+ var xpx = xa.c2p(xval);
+ var ypx = ya.c2p(yval);
+ var maxDistance = pointData.distance;
+ var ids;
+ if (stash.tree) {
+ var xl = xa.p2c(xpx - maxDistance);
+ var xr = xa.p2c(xpx + maxDistance);
+ var yl = ya.p2c(ypx - maxDistance);
+ var yr = ya.p2c(ypx + maxDistance);
+ if (hovermode === "x") {
+ ids = stash.tree.range(
+ Math.min(xl, xr),
+ Math.min(ya._rl[0], ya._rl[1]),
+ Math.max(xl, xr),
+ Math.max(ya._rl[0], ya._rl[1])
+ );
+ } else {
+ ids = stash.tree.range(
+ Math.min(xl, xr),
+ Math.min(yl, yr),
+ Math.max(xl, xr),
+ Math.max(yl, yr)
+ );
+ }
+ } else {
+ ids = stash.ids;
+ }
+ var k, closestId, ptx, pty, i, dx, dy, dist, dxy;
+ var minDist = maxDistance;
+ if (hovermode === "x") {
+ var xPeriod = !!trace.xperiodalignment;
+ var yPeriod = !!trace.yperiodalignment;
+ for (i = 0; i < ids.length; i++) {
+ k = ids[i];
+ ptx = x[k];
+ dx = Math.abs(xa.c2p(ptx) - xpx);
+ if (xPeriod) {
+ var x0 = xa.c2p(trace._xStarts[k]);
+ var x1 = xa.c2p(trace._xEnds[k]);
+ dx = xpx >= Math.min(x0, x1) && xpx <= Math.max(x0, x1) ? 0 : Infinity;
+ }
+ if (dx < minDist) {
+ minDist = dx;
+ pty = y[k];
+ dy = ya.c2p(pty) - ypx;
+ if (yPeriod) {
+ var y0 = ya.c2p(trace._yStarts[k]);
+ var y1 = ya.c2p(trace._yEnds[k]);
+ dy = ypx >= Math.min(y0, y1) && ypx <= Math.max(y0, y1) ? 0 : Infinity;
+ }
+ dxy = Math.sqrt(dx * dx + dy * dy);
+ closestId = ids[i];
+ }
+ }
+ } else {
+ for (i = ids.length - 1; i > -1; i--) {
+ k = ids[i];
+ ptx = x[k];
+ pty = y[k];
+ dx = xa.c2p(ptx) - xpx;
+ dy = ya.c2p(pty) - ypx;
+ dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist < minDist) {
+ minDist = dxy = dist;
+ closestId = k;
+ }
+ }
+ }
+ pointData.index = closestId;
+ pointData.distance = minDist;
+ pointData.dxy = dxy;
+ if (closestId === void 0) return [pointData];
+ return [calcHover(pointData, x, y, trace)];
+ }
+ function calcHover(pointData, x, y, trace) {
+ var xa = pointData.xa;
+ var ya = pointData.ya;
+ var minDist = pointData.distance;
+ var dxy = pointData.dxy;
+ var id = pointData.index;
+ var di = {
+ pointNumber: id,
+ x: x[id],
+ y: y[id]
+ };
+ di.tx = Lib.isArrayOrTypedArray(trace.text) ? trace.text[id] : trace.text;
+ di.htx = Array.isArray(trace.hovertext) ? trace.hovertext[id] : trace.hovertext;
+ di.data = Array.isArray(trace.customdata) ? trace.customdata[id] : trace.customdata;
+ di.tp = Array.isArray(trace.textposition) ? trace.textposition[id] : trace.textposition;
+ var font = trace.textfont;
+ if (font) {
+ di.ts = Lib.isArrayOrTypedArray(font.size) ? font.size[id] : font.size;
+ di.tc = Lib.isArrayOrTypedArray(font.color) ? font.color[id] : font.color;
+ di.tf = Array.isArray(font.family) ? font.family[id] : font.family;
+ di.tw = Array.isArray(font.weight) ? font.weight[id] : font.weight;
+ di.ty = Array.isArray(font.style) ? font.style[id] : font.style;
+ di.tv = Array.isArray(font.variant) ? font.variant[id] : font.variant;
+ }
+ var marker = trace.marker;
+ if (marker) {
+ di.ms = Lib.isArrayOrTypedArray(marker.size) ? marker.size[id] : marker.size;
+ di.mo = Lib.isArrayOrTypedArray(marker.opacity) ? marker.opacity[id] : marker.opacity;
+ di.mx = Lib.isArrayOrTypedArray(marker.symbol) ? marker.symbol[id] : marker.symbol;
+ di.ma = Lib.isArrayOrTypedArray(marker.angle) ? marker.angle[id] : marker.angle;
+ di.mc = Lib.isArrayOrTypedArray(marker.color) ? marker.color[id] : marker.color;
+ }
+ var line = marker && marker.line;
+ if (line) {
+ di.mlc = Array.isArray(line.color) ? line.color[id] : line.color;
+ di.mlw = Lib.isArrayOrTypedArray(line.width) ? line.width[id] : line.width;
+ }
+ var grad = marker && marker.gradient;
+ if (grad && grad.type !== "none") {
+ di.mgt = Array.isArray(grad.type) ? grad.type[id] : grad.type;
+ di.mgc = Array.isArray(grad.color) ? grad.color[id] : grad.color;
+ }
+ var xp = xa.c2p(di.x, true);
+ var yp = ya.c2p(di.y, true);
+ var rad = di.mrc || 1;
+ var hoverlabel = trace.hoverlabel;
+ if (hoverlabel) {
+ di.hbg = Array.isArray(hoverlabel.bgcolor) ? hoverlabel.bgcolor[id] : hoverlabel.bgcolor;
+ di.hbc = Array.isArray(hoverlabel.bordercolor) ? hoverlabel.bordercolor[id] : hoverlabel.bordercolor;
+ di.hts = Lib.isArrayOrTypedArray(hoverlabel.font.size) ? hoverlabel.font.size[id] : hoverlabel.font.size;
+ di.htc = Array.isArray(hoverlabel.font.color) ? hoverlabel.font.color[id] : hoverlabel.font.color;
+ di.htf = Array.isArray(hoverlabel.font.family) ? hoverlabel.font.family[id] : hoverlabel.font.family;
+ di.hnl = Lib.isArrayOrTypedArray(hoverlabel.namelength) ? hoverlabel.namelength[id] : hoverlabel.namelength;
+ }
+ var hoverinfo = trace.hoverinfo;
+ if (hoverinfo) {
+ di.hi = Array.isArray(hoverinfo) ? hoverinfo[id] : hoverinfo;
+ }
+ var hovertemplate = trace.hovertemplate;
+ if (hovertemplate) {
+ di.ht = Array.isArray(hovertemplate) ? hovertemplate[id] : hovertemplate;
+ }
+ var fakeCd = {};
+ fakeCd[pointData.index] = di;
+ var origX = trace._origX;
+ var origY = trace._origY;
+ var pointData2 = Lib.extendFlat({}, pointData, {
+ color: getTraceColor(trace, di),
+ x0: xp - rad,
+ x1: xp + rad,
+ xLabelVal: origX ? origX[id] : di.x,
+ y0: yp - rad,
+ y1: yp + rad,
+ yLabelVal: origY ? origY[id] : di.y,
+ cd: fakeCd,
+ distance: minDist,
+ spikeDistance: dxy,
+ hovertemplate: di.ht
+ });
+ if (di.htx) pointData2.text = di.htx;
+ else if (di.tx) pointData2.text = di.tx;
+ else if (trace.text) pointData2.text = trace.text;
+ Lib.fillText(di, trace, pointData2);
+ Registry.getComponentMethod("errorbars", "hoverInfo")(di, trace, pointData2);
+ return pointData2;
+ }
+ module.exports = {
+ hoverPoints,
+ calcHover
+ };
+ }
+ });
+
+ // src/traces/scattergl/constants.js
+ var require_constants23 = __commonJS({
+ "src/traces/scattergl/constants.js"(exports, module) {
+ "use strict";
+ var SYMBOL_SIZE = 20;
+ module.exports = {
+ TOO_MANY_POINTS: 1e5,
+ SYMBOL_SDF_SIZE: 200,
+ SYMBOL_SIZE,
+ SYMBOL_STROKE: SYMBOL_SIZE / 20,
+ DOT_RE: /-dot/,
+ OPEN_RE: /-open/,
+ DASHES: {
+ solid: [1],
+ dot: [1, 1],
+ dash: [4, 1],
+ longdash: [8, 1],
+ dashdot: [4, 1, 1, 1],
+ longdashdot: [8, 1, 1, 1]
+ }
+ };
+ }
+ });
+
+ // src/traces/scattergl/attributes.js
+ var require_attributes50 = __commonJS({
+ "src/traces/scattergl/attributes.js"(exports, module) {
+ "use strict";
+ var baseAttrs = require_attributes2();
+ var fontAttrs = require_font_attributes();
+ var makeFillcolorAttr = require_fillcolor_attribute();
+ var scatterAttrs = require_attributes12();
+ var axisHoverFormat = require_axis_format_attributes().axisHoverFormat;
+ var colorScaleAttrs = require_attributes8();
+ var sortObjectKeys = require_sort_object_keys();
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var DASHES = require_constants23().DASHES;
+ var scatterLineAttrs = scatterAttrs.line;
+ var scatterMarkerAttrs = scatterAttrs.marker;
+ var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
+ var attrs = module.exports = overrideAll({
+ x: scatterAttrs.x,
+ x0: scatterAttrs.x0,
+ dx: scatterAttrs.dx,
+ y: scatterAttrs.y,
+ y0: scatterAttrs.y0,
+ dy: scatterAttrs.dy,
+ xperiod: scatterAttrs.xperiod,
+ yperiod: scatterAttrs.yperiod,
+ xperiod0: scatterAttrs.xperiod0,
+ yperiod0: scatterAttrs.yperiod0,
+ xperiodalignment: scatterAttrs.xperiodalignment,
+ yperiodalignment: scatterAttrs.yperiodalignment,
+ xhoverformat: axisHoverFormat("x"),
+ yhoverformat: axisHoverFormat("y"),
+ text: scatterAttrs.text,
+ hovertext: scatterAttrs.hovertext,
+ textposition: scatterAttrs.textposition,
+ textfont: fontAttrs({
+ noFontShadow: true,
+ noFontLineposition: true,
+ noFontTextcase: true,
+ editType: "calc",
+ colorEditType: "style",
+ arrayOk: true,
+ noNumericWeightValues: true,
+ variantValues: ["normal", "small-caps"]
+ }),
+ mode: {
+ valType: "flaglist",
+ flags: ["lines", "markers", "text"],
+ extras: ["none"]
+ },
+ line: {
+ color: scatterLineAttrs.color,
+ width: scatterLineAttrs.width,
+ shape: {
+ valType: "enumerated",
+ values: ["linear", "hv", "vh", "hvh", "vhv"],
+ dflt: "linear",
+ editType: "plot"
+ },
+ dash: {
+ valType: "enumerated",
+ values: sortObjectKeys(DASHES),
+ dflt: "solid"
+ }
+ },
+ marker: extendFlat({}, colorScaleAttrs("marker"), {
+ symbol: scatterMarkerAttrs.symbol,
+ angle: scatterMarkerAttrs.angle,
+ size: scatterMarkerAttrs.size,
+ sizeref: scatterMarkerAttrs.sizeref,
+ sizemin: scatterMarkerAttrs.sizemin,
+ sizemode: scatterMarkerAttrs.sizemode,
+ opacity: scatterMarkerAttrs.opacity,
+ colorbar: scatterMarkerAttrs.colorbar,
+ line: extendFlat({}, colorScaleAttrs("marker.line"), {
+ width: scatterMarkerLineAttrs.width
+ })
+ }),
+ connectgaps: scatterAttrs.connectgaps,
+ fill: extendFlat({}, scatterAttrs.fill, { dflt: "none" }),
+ fillcolor: makeFillcolorAttr(),
+ // no hoveron
+ selected: {
+ marker: scatterAttrs.selected.marker,
+ textfont: scatterAttrs.selected.textfont
+ },
+ unselected: {
+ marker: scatterAttrs.unselected.marker,
+ textfont: scatterAttrs.unselected.textfont
+ },
+ opacity: baseAttrs.opacity
+ }, "calc", "nested");
+ attrs.x.editType = attrs.y.editType = attrs.x0.editType = attrs.y0.editType = "calc+clearAxisTypes";
+ attrs.hovertemplate = scatterAttrs.hovertemplate;
+ attrs.texttemplate = scatterAttrs.texttemplate;
+ }
+ });
+
+ // src/traces/scattergl/helpers.js
+ var require_helpers16 = __commonJS({
+ "src/traces/scattergl/helpers.js"(exports) {
+ "use strict";
+ var constants = require_constants23();
+ exports.isOpenSymbol = function(symbol) {
+ return typeof symbol === "string" ? constants.OPEN_RE.test(symbol) : symbol % 200 > 100;
+ };
+ exports.isDotSymbol = function(symbol) {
+ return typeof symbol === "string" ? constants.DOT_RE.test(symbol) : symbol > 200;
+ };
+ }
+ });
+
+ // src/traces/scattergl/defaults.js
+ var require_defaults46 = __commonJS({
+ "src/traces/scattergl/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var Registry = require_registry();
+ var helpers = require_helpers16();
+ var attributes = require_attributes50();
+ var constants = require_constants8();
+ var subTypes = require_subtypes();
+ var handleXYDefaults = require_xy_defaults();
+ var handlePeriodDefaults = require_period_defaults();
+ var handleMarkerDefaults = require_marker_defaults();
+ var handleLineDefaults = require_line_defaults();
+ var handleFillColorDefaults = require_fillcolor_defaults();
+ var handleTextDefaults = require_text_defaults();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var isOpen = traceIn.marker ? helpers.isOpenSymbol(traceIn.marker.symbol) : false;
+ var isBubble = subTypes.isBubble(traceIn);
+ var len = handleXYDefaults(traceIn, traceOut, layout, coerce);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ handlePeriodDefaults(traceIn, traceOut, layout, coerce);
+ coerce("xhoverformat");
+ coerce("yhoverformat");
+ var defaultMode = len < constants.PTS_LINESONLY ? "lines+markers" : "lines";
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ coerce("mode", defaultMode);
+ if (subTypes.hasMarkers(traceOut)) {
+ handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, { noAngleRef: true, noStandOff: true });
+ coerce("marker.line.width", isOpen || isBubble ? 1 : 0);
+ }
+ if (subTypes.hasLines(traceOut)) {
+ coerce("connectgaps");
+ handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
+ coerce("line.shape");
+ }
+ if (subTypes.hasText(traceOut)) {
+ coerce("texttemplate");
+ handleTextDefaults(traceIn, traceOut, layout, coerce, {
+ noFontShadow: true,
+ noFontLineposition: true,
+ noFontTextcase: true
+ });
+ }
+ var lineColor = (traceOut.line || {}).color;
+ var markerColor = (traceOut.marker || {}).color;
+ coerce("fill");
+ if (traceOut.fill !== "none") {
+ handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
+ }
+ var errorBarsSupplyDefaults = Registry.getComponentMethod("errorbars", "supplyDefaults");
+ errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, { axis: "y" });
+ errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, { axis: "x", inherit: "y" });
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ }
+ });
+
+ // src/traces/scattergl/format_labels.js
+ var require_format_labels4 = __commonJS({
+ "src/traces/scattergl/format_labels.js"(exports, module) {
+ "use strict";
+ var scatterFormatLabels = require_format_labels();
+ module.exports = function formatLabels(cdi, trace, fullLayout) {
+ var i = cdi.i;
+ if (!("x" in cdi)) cdi.x = trace._x[i];
+ if (!("y" in cdi)) cdi.y = trace._y[i];
+ return scatterFormatLabels(cdi, trace, fullLayout);
+ };
+ }
+ });
+
+ // node_modules/binary-search-bounds/search-bounds.js
+ var require_search_bounds = __commonJS({
+ "node_modules/binary-search-bounds/search-bounds.js"(exports, module) {
+ "use strict";
+ function ge(a, y, c, l, h) {
+ var i = h + 1;
+ while (l <= h) {
+ var m = l + h >>> 1, x = a[m];
+ var p = c !== void 0 ? c(x, y) : x - y;
+ if (p >= 0) {
+ i = m;
+ h = m - 1;
+ } else {
+ l = m + 1;
+ }
+ }
+ return i;
+ }
+ function gt(a, y, c, l, h) {
+ var i = h + 1;
+ while (l <= h) {
+ var m = l + h >>> 1, x = a[m];
+ var p = c !== void 0 ? c(x, y) : x - y;
+ if (p > 0) {
+ i = m;
+ h = m - 1;
+ } else {
+ l = m + 1;
+ }
+ }
+ return i;
+ }
+ function lt(a, y, c, l, h) {
+ var i = l - 1;
+ while (l <= h) {
+ var m = l + h >>> 1, x = a[m];
+ var p = c !== void 0 ? c(x, y) : x - y;
+ if (p < 0) {
+ i = m;
+ l = m + 1;
+ } else {
+ h = m - 1;
+ }
+ }
+ return i;
+ }
+ function le(a, y, c, l, h) {
+ var i = l - 1;
+ while (l <= h) {
+ var m = l + h >>> 1, x = a[m];
+ var p = c !== void 0 ? c(x, y) : x - y;
+ if (p <= 0) {
+ i = m;
+ l = m + 1;
+ } else {
+ h = m - 1;
+ }
+ }
+ return i;
+ }
+ function eq(a, y, c, l, h) {
+ while (l <= h) {
+ var m = l + h >>> 1, x = a[m];
+ var p = c !== void 0 ? c(x, y) : x - y;
+ if (p === 0) {
+ return m;
+ }
+ if (p <= 0) {
+ l = m + 1;
+ } else {
+ h = m - 1;
+ }
+ }
+ return -1;
+ }
+ function norm(a, y, c, l, h, f) {
+ if (typeof c === "function") {
+ return f(a, y, c, l === void 0 ? 0 : l | 0, h === void 0 ? a.length - 1 : h | 0);
+ }
+ return f(a, y, void 0, c === void 0 ? 0 : c | 0, l === void 0 ? a.length - 1 : l | 0);
+ }
+ module.exports = {
+ ge: function(a, y, c, l, h) {
+ return norm(a, y, c, l, h, ge);
+ },
+ gt: function(a, y, c, l, h) {
+ return norm(a, y, c, l, h, gt);
+ },
+ lt: function(a, y, c, l, h) {
+ return norm(a, y, c, l, h, lt);
+ },
+ le: function(a, y, c, l, h) {
+ return norm(a, y, c, l, h, le);
+ },
+ eq: function(a, y, c, l, h) {
+ return norm(a, y, c, l, h, eq);
+ }
+ };
+ }
+ });
+
+ // node_modules/pick-by-alias/index.js
+ var require_pick_by_alias = __commonJS({
+ "node_modules/pick-by-alias/index.js"(exports, module) {
+ "use strict";
+ module.exports = function pick(src, props, keepRest) {
+ var result = {}, prop, i;
+ if (typeof props === "string") props = toList(props);
+ if (Array.isArray(props)) {
+ var res = {};
+ for (i = 0; i < props.length; i++) {
+ res[props[i]] = true;
+ }
+ props = res;
+ }
+ for (prop in props) {
+ props[prop] = toList(props[prop]);
+ }
+ var occupied = {};
+ for (prop in props) {
+ var aliases = props[prop];
+ if (Array.isArray(aliases)) {
+ for (i = 0; i < aliases.length; i++) {
+ var alias = aliases[i];
+ if (keepRest) {
+ occupied[alias] = true;
+ }
+ if (alias in src) {
+ result[prop] = src[alias];
+ if (keepRest) {
+ for (var j = i; j < aliases.length; j++) {
+ occupied[aliases[j]] = true;
+ }
+ }
+ break;
+ }
+ }
+ } else if (prop in src) {
+ if (props[prop]) {
+ result[prop] = src[prop];
+ }
+ if (keepRest) {
+ occupied[prop] = true;
+ }
+ }
+ }
+ if (keepRest) {
+ for (prop in src) {
+ if (occupied[prop]) continue;
+ result[prop] = src[prop];
+ }
+ }
+ return result;
+ };
+ var CACHE = {};
+ function toList(arg) {
+ if (CACHE[arg]) return CACHE[arg];
+ if (typeof arg === "string") {
+ arg = CACHE[arg] = arg.split(/\s*,\s*|\s+/);
+ }
+ return arg;
+ }
+ }
+ });
+
+ // node_modules/parse-rect/index.js
+ var require_parse_rect = __commonJS({
+ "node_modules/parse-rect/index.js"(exports, module) {
+ "use strict";
+ var pick = require_pick_by_alias();
+ module.exports = parseRect;
+ function parseRect(arg) {
+ var rect;
+ if (arguments.length > 1) {
+ arg = arguments;
+ }
+ if (typeof arg === "string") {
+ arg = arg.split(/\s/).map(parseFloat);
+ } else if (typeof arg === "number") {
+ arg = [arg];
+ }
+ if (arg.length && typeof arg[0] === "number") {
+ if (arg.length === 1) {
+ rect = {
+ width: arg[0],
+ height: arg[0],
+ x: 0,
+ y: 0
+ };
+ } else if (arg.length === 2) {
+ rect = {
+ width: arg[0],
+ height: arg[1],
+ x: 0,
+ y: 0
+ };
+ } else {
+ rect = {
+ x: arg[0],
+ y: arg[1],
+ width: arg[2] - arg[0] || 0,
+ height: arg[3] - arg[1] || 0
+ };
+ }
+ } else if (arg) {
+ arg = pick(arg, {
+ left: "x l left Left",
+ top: "y t top Top",
+ width: "w width W Width",
+ height: "h height W Width",
+ bottom: "b bottom Bottom",
+ right: "r right Right"
+ });
+ rect = {
+ x: arg.left || 0,
+ y: arg.top || 0
+ };
+ if (arg.width == null) {
+ if (arg.right) rect.width = arg.right - rect.x;
+ else rect.width = 0;
+ } else {
+ rect.width = arg.width;
+ }
+ if (arg.height == null) {
+ if (arg.bottom) rect.height = arg.bottom - rect.y;
+ else rect.height = 0;
+ } else {
+ rect.height = arg.height;
+ }
+ }
+ return rect;
+ }
+ }
+ });
+
+ // node_modules/array-bounds/index.js
+ var require_array_bounds = __commonJS({
+ "node_modules/array-bounds/index.js"(exports, module) {
+ "use strict";
+ module.exports = normalize;
+ function normalize(arr, dim) {
+ if (!arr || arr.length == null) throw Error("Argument should be an array");
+ if (dim == null) dim = 1;
+ else dim = Math.floor(dim);
+ var bounds = Array(dim * 2);
+ for (var offset = 0; offset < dim; offset++) {
+ var max = -Infinity, min = Infinity, i = offset, l = arr.length;
+ for (; i < l; i += dim) {
+ if (arr[i] > max) max = arr[i];
+ if (arr[i] < min) min = arr[i];
+ }
+ bounds[offset] = min;
+ bounds[dim + offset] = max;
+ }
+ return bounds;
+ }
+ }
+ });
+
+ // node_modules/defined/index.js
+ var require_defined = __commonJS({
+ "node_modules/defined/index.js"(exports, module) {
+ module.exports = function() {
+ for (var i = 0; i < arguments.length; i++) {
+ if (arguments[i] !== void 0) return arguments[i];
+ }
+ };
+ }
+ });
+
+ // node_modules/flatten-vertex-data/index.js
+ var require_flatten_vertex_data = __commonJS({
+ "node_modules/flatten-vertex-data/index.js"(exports, module) {
+ var dtype = require_dtype();
+ module.exports = flattenVertexData;
+ function flattenVertexData(data, output, offset) {
+ if (!data) throw new TypeError("must specify data as first parameter");
+ offset = +(offset || 0) | 0;
+ if (Array.isArray(data) && (data[0] && typeof data[0][0] === "number")) {
+ var dim = data[0].length;
+ var length = data.length * dim;
+ var i, j, k, l;
+ if (!output || typeof output === "string") {
+ output = new (dtype(output || "float32"))(length + offset);
+ }
+ var dstLength = output.length - offset;
+ if (length !== dstLength) {
+ throw new Error("source length " + length + " (" + dim + "x" + data.length + ") does not match destination length " + dstLength);
+ }
+ for (i = 0, k = offset; i < data.length; i++) {
+ for (j = 0; j < dim; j++) {
+ output[k++] = data[i][j] === null ? NaN : data[i][j];
+ }
+ }
+ } else {
+ if (!output || typeof output === "string") {
+ var Ctor = dtype(output || "float32");
+ if (Array.isArray(data) || output === "array") {
+ output = new Ctor(data.length + offset);
+ for (i = 0, k = offset, l = output.length; k < l; k++, i++) {
+ output[k] = data[i] === null ? NaN : data[i];
+ }
+ } else {
+ if (offset === 0) {
+ output = new Ctor(data);
+ } else {
+ output = new Ctor(data.length + offset);
+ output.set(data, offset);
+ }
+ }
+ } else {
+ output.set(data, offset);
+ }
+ }
+ return output;
+ }
+ }
+ });
+
+ // node_modules/is-obj/index.js
+ var require_is_obj = __commonJS({
+ "node_modules/is-obj/index.js"(exports, module) {
+ "use strict";
+ module.exports = function(x) {
+ var type = typeof x;
+ return x !== null && (type === "object" || type === "function");
+ };
+ }
+ });
+
+ // node_modules/math-log2/index.js
+ var require_math_log2 = __commonJS({
+ "node_modules/math-log2/index.js"(exports, module) {
+ "use strict";
+ module.exports = Math.log2 || function(x) {
+ return Math.log(x) * Math.LOG2E;
+ };
+ }
+ });
+
+ // node_modules/@plotly/point-cluster/quad.js
+ var require_quad = __commonJS({
+ "node_modules/@plotly/point-cluster/quad.js"(exports, module) {
+ "use strict";
+ var search = require_search_bounds();
+ var clamp = require_clamp();
+ var rect = require_parse_rect();
+ var getBounds = require_array_bounds();
+ var pick = require_pick_by_alias();
+ var defined = require_defined();
+ var flatten = require_flatten_vertex_data();
+ var isObj = require_is_obj();
+ var dtype = require_dtype();
+ var log2 = require_math_log2();
+ var MAX_GROUP_ID = 1073741824;
+ module.exports = function cluster(srcPoints, options) {
+ if (!options) options = {};
+ srcPoints = flatten(srcPoints, "float64");
+ options = pick(options, {
+ bounds: "range bounds dataBox databox",
+ maxDepth: "depth maxDepth maxdepth level maxLevel maxlevel levels",
+ dtype: "type dtype format out dst output destination"
+ // sort: 'sortBy sortby sort',
+ // pick: 'pick levelPoint',
+ // nodeSize: 'node nodeSize minNodeSize minSize size'
+ });
+ let maxDepth = defined(options.maxDepth, 255);
+ let bounds = defined(options.bounds, getBounds(srcPoints, 2));
+ if (bounds[0] === bounds[2]) bounds[2]++;
+ if (bounds[1] === bounds[3]) bounds[3]++;
+ let points = normalize(srcPoints, bounds);
+ let n = srcPoints.length >>> 1;
+ let ids;
+ if (!options.dtype) options.dtype = "array";
+ if (typeof options.dtype === "string") {
+ ids = new (dtype(options.dtype))(n);
+ } else if (options.dtype) {
+ ids = options.dtype;
+ if (Array.isArray(ids)) ids.length = n;
+ }
+ for (let i = 0; i < n; ++i) {
+ ids[i] = i;
+ }
+ let levels = [];
+ let sublevels = [];
+ let groups = [];
+ let offsets = [];
+ sort(0, 0, 1, ids, 0, 1);
+ let offset = 0;
+ for (let level = 0; level < levels.length; level++) {
+ let levelItems = levels[level];
+ if (ids.set) ids.set(levelItems, offset);
+ else {
+ for (let i = 0, l = levelItems.length; i < l; i++) {
+ ids[i + offset] = levelItems[i];
+ }
+ }
+ let nextOffset = offset + levels[level].length;
+ offsets[level] = [offset, nextOffset];
+ offset = nextOffset;
+ }
+ ids.range = range;
+ return ids;
+ function sort(x, y, diam, ids2, level, group2) {
+ if (!ids2.length) return null;
+ let levelItems = levels[level] || (levels[level] = []);
+ let levelGroups = groups[level] || (groups[level] = []);
+ let sublevel = sublevels[level] || (sublevels[level] = []);
+ let offset2 = levelItems.length;
+ level++;
+ if (level > maxDepth || group2 > MAX_GROUP_ID) {
+ for (let i = 0; i < ids2.length; i++) {
+ levelItems.push(ids2[i]);
+ levelGroups.push(group2);
+ sublevel.push(null, null, null, null);
+ }
+ return offset2;
+ }
+ levelItems.push(ids2[0]);
+ levelGroups.push(group2);
+ if (ids2.length <= 1) {
+ sublevel.push(null, null, null, null);
+ return offset2;
+ }
+ let d2 = diam * 0.5;
+ let cx = x + d2, cy = y + d2;
+ let lolo = [], lohi = [], hilo = [], hihi = [];
+ for (let i = 1, l = ids2.length; i < l; i++) {
+ let idx = ids2[i], x2 = points[idx * 2], y2 = points[idx * 2 + 1];
+ x2 < cx ? y2 < cy ? lolo.push(idx) : lohi.push(idx) : y2 < cy ? hilo.push(idx) : hihi.push(idx);
+ }
+ group2 <<= 2;
+ sublevel.push(
+ sort(x, y, d2, lolo, level, group2),
+ sort(x, cy, d2, lohi, level, group2 + 1),
+ sort(cx, y, d2, hilo, level, group2 + 2),
+ sort(cx, cy, d2, hihi, level, group2 + 3)
+ );
+ return offset2;
+ }
+ function range(...args) {
+ let options2;
+ if (isObj(args[args.length - 1])) {
+ let arg = args.pop();
+ if (!args.length && (arg.x != null || arg.l != null || arg.left != null)) {
+ args = [arg];
+ options2 = {};
+ }
+ options2 = pick(arg, {
+ level: "level maxLevel",
+ d: "d diam diameter r radius px pxSize pixel pixelSize maxD size minSize",
+ lod: "lod details ranges offsets"
+ });
+ } else {
+ options2 = {};
+ }
+ if (!args.length) args = bounds;
+ let box = rect(...args);
+ let [minX, minY, maxX, maxY] = [
+ Math.min(box.x, box.x + box.width),
+ Math.min(box.y, box.y + box.height),
+ Math.max(box.x, box.x + box.width),
+ Math.max(box.y, box.y + box.height)
+ ];
+ let [nminX, nminY, nmaxX, nmaxY] = normalize([minX, minY, maxX, maxY], bounds);
+ let maxLevel = defined(options2.level, levels.length);
+ if (options2.d != null) {
+ let d;
+ if (typeof options2.d === "number") d = [options2.d, options2.d];
+ else if (options2.d.length) d = options2.d;
+ maxLevel = Math.min(
+ Math.max(
+ Math.ceil(-log2(Math.abs(d[0]) / (bounds[2] - bounds[0]))),
+ Math.ceil(-log2(Math.abs(d[1]) / (bounds[3] - bounds[1])))
+ ),
+ maxLevel
+ );
+ }
+ maxLevel = Math.min(maxLevel, levels.length);
+ if (options2.lod) {
+ return lod(nminX, nminY, nmaxX, nmaxY, maxLevel);
+ }
+ let selection = [];
+ select(0, 0, 1, 0, 0, 1);
+ function select(lox, loy, d, level, from, to) {
+ if (from === null || to === null) return;
+ let hix = lox + d;
+ let hiy = loy + d;
+ if (nminX > hix || nminY > hiy || nmaxX < lox || nmaxY < loy) return;
+ if (level >= maxLevel) return;
+ if (from === to) return;
+ let levelItems = levels[level];
+ if (to === void 0) to = levelItems.length;
+ for (let i = from; i < to; i++) {
+ let id = levelItems[i];
+ let px = srcPoints[id * 2];
+ let py = srcPoints[id * 2 + 1];
+ if (px >= minX && px <= maxX && py >= minY && py <= maxY) {
+ selection.push(id);
+ }
+ }
+ let offsets2 = sublevels[level];
+ let off0 = offsets2[from * 4 + 0];
+ let off1 = offsets2[from * 4 + 1];
+ let off2 = offsets2[from * 4 + 2];
+ let off3 = offsets2[from * 4 + 3];
+ let end = nextOffset(offsets2, from + 1);
+ let d2 = d * 0.5;
+ let nextLevel = level + 1;
+ select(lox, loy, d2, nextLevel, off0, off1 || off2 || off3 || end);
+ select(lox, loy + d2, d2, nextLevel, off1, off2 || off3 || end);
+ select(lox + d2, loy, d2, nextLevel, off2, off3 || end);
+ select(lox + d2, loy + d2, d2, nextLevel, off3, end);
+ }
+ function nextOffset(offsets2, from) {
+ let offset2 = null, i = 0;
+ while (offset2 === null) {
+ offset2 = offsets2[from * 4 + i];
+ i++;
+ if (i > offsets2.length) return null;
+ }
+ return offset2;
+ }
+ return selection;
+ }
+ function lod(lox, loy, hix, hiy, maxLevel) {
+ let ranges = [];
+ for (let level = 0; level < maxLevel; level++) {
+ let levelGroups = groups[level];
+ let from = offsets[level][0];
+ let levelGroupStart = group(lox, loy, level);
+ let levelGroupEnd = group(hix, hiy, level);
+ let startOffset = search.ge(levelGroups, levelGroupStart);
+ let endOffset = search.gt(levelGroups, levelGroupEnd, startOffset, levelGroups.length - 1);
+ ranges[level] = [startOffset + from, endOffset + from];
+ }
+ return ranges;
+ }
+ function group(x, y, level) {
+ let group2 = 1;
+ let cx = 0.5, cy = 0.5;
+ let diam = 0.5;
+ for (let i = 0; i < level; i++) {
+ group2 <<= 2;
+ group2 += x < cx ? y < cy ? 0 : 1 : y < cy ? 2 : 3;
+ diam *= 0.5;
+ cx += x < cx ? -diam : diam;
+ cy += y < cy ? -diam : diam;
+ }
+ return group2;
+ }
+ };
+ function normalize(pts, bounds) {
+ let [lox, loy, hix, hiy] = bounds;
+ let scaleX = 1 / (hix - lox);
+ let scaleY = 1 / (hiy - loy);
+ let result = new Array(pts.length);
+ for (let i = 0, n = pts.length / 2; i < n; i++) {
+ result[2 * i] = clamp((pts[2 * i] - lox) * scaleX, 0, 1);
+ result[2 * i + 1] = clamp((pts[2 * i + 1] - loy) * scaleY, 0, 1);
+ }
+ return result;
+ }
+ }
+ });
+
+ // node_modules/@plotly/point-cluster/index.js
+ var require_point_cluster = __commonJS({
+ "node_modules/@plotly/point-cluster/index.js"(exports, module) {
+ "use strict";
+ module.exports = require_quad();
+ }
+ });
+
+ // node_modules/abs-svg-path/index.js
+ var require_abs_svg_path = __commonJS({
+ "node_modules/abs-svg-path/index.js"(exports, module) {
+ module.exports = absolutize;
+ function absolutize(path) {
+ var startX = 0;
+ var startY = 0;
+ var x = 0;
+ var y = 0;
+ return path.map(function(seg) {
+ seg = seg.slice();
+ var type = seg[0];
+ var command = type.toUpperCase();
+ if (type != command) {
+ seg[0] = command;
+ switch (type) {
+ case "a":
+ seg[6] += x;
+ seg[7] += y;
+ break;
+ case "v":
+ seg[1] += y;
+ break;
+ case "h":
+ seg[1] += x;
+ break;
+ default:
+ for (var i = 1; i < seg.length; ) {
+ seg[i++] += x;
+ seg[i++] += y;
+ }
+ }
+ }
+ switch (command) {
+ case "Z":
+ x = startX;
+ y = startY;
+ break;
+ case "H":
+ x = seg[1];
+ break;
+ case "V":
+ y = seg[1];
+ break;
+ case "M":
+ x = startX = seg[1];
+ y = startY = seg[2];
+ break;
+ default:
+ x = seg[seg.length - 2];
+ y = seg[seg.length - 1];
+ }
+ return seg;
+ });
+ }
+ }
+ });
+
+ // node_modules/svg-arc-to-cubic-bezier/cjs/index.js
+ var require_cjs6 = __commonJS({
+ "node_modules/svg-arc-to-cubic-bezier/cjs/index.js"(exports, module) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ var _slicedToArray = /* @__PURE__ */ function() {
+ function sliceIterator(arr, i) {
+ var _arr = [];
+ var _n = true;
+ var _d = false;
+ var _e = void 0;
+ try {
+ for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
+ _arr.push(_s.value);
+ if (i && _arr.length === i) break;
+ }
+ } catch (err) {
+ _d = true;
+ _e = err;
+ } finally {
+ try {
+ if (!_n && _i["return"]) _i["return"]();
+ } finally {
+ if (_d) throw _e;
+ }
+ }
+ return _arr;
+ }
+ return function(arr, i) {
+ if (Array.isArray(arr)) {
+ return arr;
+ } else if (Symbol.iterator in Object(arr)) {
+ return sliceIterator(arr, i);
+ } else {
+ throw new TypeError("Invalid attempt to destructure non-iterable instance");
+ }
+ };
+ }();
+ var TAU = Math.PI * 2;
+ var mapToEllipse = function mapToEllipse2(_ref, rx, ry, cosphi, sinphi, centerx, centery) {
+ var x = _ref.x, y = _ref.y;
+ x *= rx;
+ y *= ry;
+ var xp = cosphi * x - sinphi * y;
+ var yp = sinphi * x + cosphi * y;
+ return {
+ x: xp + centerx,
+ y: yp + centery
+ };
+ };
+ var approxUnitArc = function approxUnitArc2(ang1, ang2) {
+ var a = ang2 === 1.5707963267948966 ? 0.551915024494 : ang2 === -1.5707963267948966 ? -0.551915024494 : 4 / 3 * Math.tan(ang2 / 4);
+ var x1 = Math.cos(ang1);
+ var y1 = Math.sin(ang1);
+ var x2 = Math.cos(ang1 + ang2);
+ var y2 = Math.sin(ang1 + ang2);
+ return [{
+ x: x1 - y1 * a,
+ y: y1 + x1 * a
+ }, {
+ x: x2 + y2 * a,
+ y: y2 - x2 * a
+ }, {
+ x: x2,
+ y: y2
+ }];
+ };
+ var vectorAngle = function vectorAngle2(ux, uy, vx, vy) {
+ var sign = ux * vy - uy * vx < 0 ? -1 : 1;
+ var dot = ux * vx + uy * vy;
+ if (dot > 1) {
+ dot = 1;
+ }
+ if (dot < -1) {
+ dot = -1;
+ }
+ return sign * Math.acos(dot);
+ };
+ var getArcCenter = function getArcCenter2(px, py, cx, cy, rx, ry, largeArcFlag, sweepFlag, sinphi, cosphi, pxp, pyp) {
+ var rxsq = Math.pow(rx, 2);
+ var rysq = Math.pow(ry, 2);
+ var pxpsq = Math.pow(pxp, 2);
+ var pypsq = Math.pow(pyp, 2);
+ var radicant = rxsq * rysq - rxsq * pypsq - rysq * pxpsq;
+ if (radicant < 0) {
+ radicant = 0;
+ }
+ radicant /= rxsq * pypsq + rysq * pxpsq;
+ radicant = Math.sqrt(radicant) * (largeArcFlag === sweepFlag ? -1 : 1);
+ var centerxp = radicant * rx / ry * pyp;
+ var centeryp = radicant * -ry / rx * pxp;
+ var centerx = cosphi * centerxp - sinphi * centeryp + (px + cx) / 2;
+ var centery = sinphi * centerxp + cosphi * centeryp + (py + cy) / 2;
+ var vx1 = (pxp - centerxp) / rx;
+ var vy1 = (pyp - centeryp) / ry;
+ var vx2 = (-pxp - centerxp) / rx;
+ var vy2 = (-pyp - centeryp) / ry;
+ var ang1 = vectorAngle(1, 0, vx1, vy1);
+ var ang2 = vectorAngle(vx1, vy1, vx2, vy2);
+ if (sweepFlag === 0 && ang2 > 0) {
+ ang2 -= TAU;
+ }
+ if (sweepFlag === 1 && ang2 < 0) {
+ ang2 += TAU;
+ }
+ return [centerx, centery, ang1, ang2];
+ };
+ var arcToBezier = function arcToBezier2(_ref2) {
+ var px = _ref2.px, py = _ref2.py, cx = _ref2.cx, cy = _ref2.cy, rx = _ref2.rx, ry = _ref2.ry, _ref2$xAxisRotation = _ref2.xAxisRotation, xAxisRotation = _ref2$xAxisRotation === void 0 ? 0 : _ref2$xAxisRotation, _ref2$largeArcFlag = _ref2.largeArcFlag, largeArcFlag = _ref2$largeArcFlag === void 0 ? 0 : _ref2$largeArcFlag, _ref2$sweepFlag = _ref2.sweepFlag, sweepFlag = _ref2$sweepFlag === void 0 ? 0 : _ref2$sweepFlag;
+ var curves = [];
+ if (rx === 0 || ry === 0) {
+ return [];
+ }
+ var sinphi = Math.sin(xAxisRotation * TAU / 360);
+ var cosphi = Math.cos(xAxisRotation * TAU / 360);
+ var pxp = cosphi * (px - cx) / 2 + sinphi * (py - cy) / 2;
+ var pyp = -sinphi * (px - cx) / 2 + cosphi * (py - cy) / 2;
+ if (pxp === 0 && pyp === 0) {
+ return [];
+ }
+ rx = Math.abs(rx);
+ ry = Math.abs(ry);
+ var lambda = Math.pow(pxp, 2) / Math.pow(rx, 2) + Math.pow(pyp, 2) / Math.pow(ry, 2);
+ if (lambda > 1) {
+ rx *= Math.sqrt(lambda);
+ ry *= Math.sqrt(lambda);
+ }
+ var _getArcCenter = getArcCenter(px, py, cx, cy, rx, ry, largeArcFlag, sweepFlag, sinphi, cosphi, pxp, pyp), _getArcCenter2 = _slicedToArray(_getArcCenter, 4), centerx = _getArcCenter2[0], centery = _getArcCenter2[1], ang1 = _getArcCenter2[2], ang2 = _getArcCenter2[3];
+ var ratio = Math.abs(ang2) / (TAU / 4);
+ if (Math.abs(1 - ratio) < 1e-7) {
+ ratio = 1;
+ }
+ var segments = Math.max(Math.ceil(ratio), 1);
+ ang2 /= segments;
+ for (var i = 0; i < segments; i++) {
+ curves.push(approxUnitArc(ang1, ang2));
+ ang1 += ang2;
+ }
+ return curves.map(function(curve) {
+ var _mapToEllipse = mapToEllipse(curve[0], rx, ry, cosphi, sinphi, centerx, centery), x1 = _mapToEllipse.x, y1 = _mapToEllipse.y;
+ var _mapToEllipse2 = mapToEllipse(curve[1], rx, ry, cosphi, sinphi, centerx, centery), x2 = _mapToEllipse2.x, y2 = _mapToEllipse2.y;
+ var _mapToEllipse3 = mapToEllipse(curve[2], rx, ry, cosphi, sinphi, centerx, centery), x = _mapToEllipse3.x, y = _mapToEllipse3.y;
+ return { x1, y1, x2, y2, x, y };
+ });
+ };
+ exports.default = arcToBezier;
+ module.exports = exports.default;
+ }
+ });
+
+ // node_modules/svg-path-bounds/node_modules/normalize-svg-path/index.js
+ var require_normalize_svg_path = __commonJS({
+ "node_modules/svg-path-bounds/node_modules/normalize-svg-path/index.js"(exports, module) {
+ "use strict";
+ module.exports = normalize;
+ var arcToCurve = require_cjs6();
+ function normalize(path) {
+ var prev;
+ var result = [];
+ var bezierX = 0;
+ var bezierY = 0;
+ var startX = 0;
+ var startY = 0;
+ var quadX = null;
+ var quadY = null;
+ var x = 0;
+ var y = 0;
+ for (var i = 0, len = path.length; i < len; i++) {
+ var seg = path[i];
+ var command = seg[0];
+ switch (command) {
+ case "M":
+ startX = seg[1];
+ startY = seg[2];
+ break;
+ case "A":
+ var curves = arcToCurve({
+ px: x,
+ py: y,
+ cx: seg[6],
+ cy: seg[7],
+ rx: seg[1],
+ ry: seg[2],
+ xAxisRotation: seg[3],
+ largeArcFlag: seg[4],
+ sweepFlag: seg[5]
+ });
+ if (!curves.length) continue;
+ for (var j = 0, c; j < curves.length; j++) {
+ c = curves[j];
+ seg = ["C", c.x1, c.y1, c.x2, c.y2, c.x, c.y];
+ if (j < curves.length - 1) result.push(seg);
+ }
+ break;
+ case "S":
+ var cx = x;
+ var cy = y;
+ if (prev == "C" || prev == "S") {
+ cx += cx - bezierX;
+ cy += cy - bezierY;
+ }
+ seg = ["C", cx, cy, seg[1], seg[2], seg[3], seg[4]];
+ break;
+ case "T":
+ if (prev == "Q" || prev == "T") {
+ quadX = x * 2 - quadX;
+ quadY = y * 2 - quadY;
+ } else {
+ quadX = x;
+ quadY = y;
+ }
+ seg = quadratic(x, y, quadX, quadY, seg[1], seg[2]);
+ break;
+ case "Q":
+ quadX = seg[1];
+ quadY = seg[2];
+ seg = quadratic(x, y, seg[1], seg[2], seg[3], seg[4]);
+ break;
+ case "L":
+ seg = line(x, y, seg[1], seg[2]);
+ break;
+ case "H":
+ seg = line(x, y, seg[1], y);
+ break;
+ case "V":
+ seg = line(x, y, x, seg[1]);
+ break;
+ case "Z":
+ seg = line(x, y, startX, startY);
+ break;
+ }
+ prev = command;
+ x = seg[seg.length - 2];
+ y = seg[seg.length - 1];
+ if (seg.length > 4) {
+ bezierX = seg[seg.length - 4];
+ bezierY = seg[seg.length - 3];
+ } else {
+ bezierX = x;
+ bezierY = y;
+ }
+ result.push(seg);
+ }
+ return result;
+ }
+ function line(x1, y1, x2, y2) {
+ return ["C", x1, y1, x2, y2, x2, y2];
+ }
+ function quadratic(x1, y1, cx, cy, x2, y2) {
+ return [
+ "C",
+ x1 / 3 + 2 / 3 * cx,
+ y1 / 3 + 2 / 3 * cy,
+ x2 / 3 + 2 / 3 * cx,
+ y2 / 3 + 2 / 3 * cy,
+ x2,
+ y2
+ ];
+ }
+ }
+ });
+
+ // node_modules/is-svg-path/index.js
+ var require_is_svg_path = __commonJS({
+ "node_modules/is-svg-path/index.js"(exports, module) {
+ "use strict";
+ module.exports = function isPath(str) {
+ if (typeof str !== "string") return false;
+ str = str.trim();
+ if (/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(str) && /[\dz]$/i.test(str) && str.length > 4) return true;
+ return false;
+ };
+ }
+ });
+
+ // node_modules/svg-path-bounds/index.js
+ var require_svg_path_bounds = __commonJS({
+ "node_modules/svg-path-bounds/index.js"(exports, module) {
+ "use strict";
+ var parse2 = require_parse_svg_path();
+ var abs = require_abs_svg_path();
+ var normalize = require_normalize_svg_path();
+ var isSvgPath = require_is_svg_path();
+ var assert = require_assert();
+ module.exports = pathBounds;
+ function pathBounds(path) {
+ if (Array.isArray(path) && path.length === 1 && typeof path[0] === "string") path = path[0];
+ if (typeof path === "string") {
+ assert(isSvgPath(path), "String is not an SVG path.");
+ path = parse2(path);
+ }
+ assert(Array.isArray(path), "Argument should be a string or an array of path segments.");
+ path = abs(path);
+ path = normalize(path);
+ if (!path.length) return [0, 0, 0, 0];
+ var bounds = [Infinity, Infinity, -Infinity, -Infinity];
+ for (var i = 0, l = path.length; i < l; i++) {
+ var points = path[i].slice(1);
+ for (var j = 0; j < points.length; j += 2) {
+ if (points[j + 0] < bounds[0]) bounds[0] = points[j + 0];
+ if (points[j + 1] < bounds[1]) bounds[1] = points[j + 1];
+ if (points[j + 0] > bounds[2]) bounds[2] = points[j + 0];
+ if (points[j + 1] > bounds[3]) bounds[3] = points[j + 1];
+ }
+ }
+ return bounds;
+ }
+ }
+ });
+
+ // node_modules/normalize-svg-path/index.js
+ var require_normalize_svg_path2 = __commonJS({
+ "node_modules/normalize-svg-path/index.js"(exports, module) {
+ var \u03C0 = Math.PI;
+ var _120 = radians2(120);
+ module.exports = normalize;
+ function normalize(path) {
+ var prev;
+ var result = [];
+ var bezierX = 0;
+ var bezierY = 0;
+ var startX = 0;
+ var startY = 0;
+ var quadX = null;
+ var quadY = null;
+ var x = 0;
+ var y = 0;
+ for (var i = 0, len = path.length; i < len; i++) {
+ var seg = path[i];
+ var command = seg[0];
+ switch (command) {
+ case "M":
+ startX = seg[1];
+ startY = seg[2];
+ break;
+ case "A":
+ seg = arc(x, y, seg[1], seg[2], radians2(seg[3]), seg[4], seg[5], seg[6], seg[7]);
+ seg.unshift("C");
+ if (seg.length > 7) {
+ result.push(seg.splice(0, 7));
+ seg.unshift("C");
+ }
+ break;
+ case "S":
+ var cx = x;
+ var cy = y;
+ if (prev == "C" || prev == "S") {
+ cx += cx - bezierX;
+ cy += cy - bezierY;
+ }
+ seg = ["C", cx, cy, seg[1], seg[2], seg[3], seg[4]];
+ break;
+ case "T":
+ if (prev == "Q" || prev == "T") {
+ quadX = x * 2 - quadX;
+ quadY = y * 2 - quadY;
+ } else {
+ quadX = x;
+ quadY = y;
+ }
+ seg = quadratic(x, y, quadX, quadY, seg[1], seg[2]);
+ break;
+ case "Q":
+ quadX = seg[1];
+ quadY = seg[2];
+ seg = quadratic(x, y, seg[1], seg[2], seg[3], seg[4]);
+ break;
+ case "L":
+ seg = line(x, y, seg[1], seg[2]);
+ break;
+ case "H":
+ seg = line(x, y, seg[1], y);
+ break;
+ case "V":
+ seg = line(x, y, x, seg[1]);
+ break;
+ case "Z":
+ seg = line(x, y, startX, startY);
+ break;
+ }
+ prev = command;
+ x = seg[seg.length - 2];
+ y = seg[seg.length - 1];
+ if (seg.length > 4) {
+ bezierX = seg[seg.length - 4];
+ bezierY = seg[seg.length - 3];
+ } else {
+ bezierX = x;
+ bezierY = y;
+ }
+ result.push(seg);
+ }
+ return result;
+ }
+ function line(x1, y1, x2, y2) {
+ return ["C", x1, y1, x2, y2, x2, y2];
+ }
+ function quadratic(x1, y1, cx, cy, x2, y2) {
+ return [
+ "C",
+ x1 / 3 + 2 / 3 * cx,
+ y1 / 3 + 2 / 3 * cy,
+ x2 / 3 + 2 / 3 * cx,
+ y2 / 3 + 2 / 3 * cy,
+ x2,
+ y2
+ ];
+ }
+ function arc(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
+ if (!recursive) {
+ var xy = rotate(x1, y1, -angle);
+ x1 = xy.x;
+ y1 = xy.y;
+ xy = rotate(x2, y2, -angle);
+ x2 = xy.x;
+ y2 = xy.y;
+ var x = (x1 - x2) / 2;
+ var y = (y1 - y2) / 2;
+ var h = x * x / (rx * rx) + y * y / (ry * ry);
+ if (h > 1) {
+ h = Math.sqrt(h);
+ rx = h * rx;
+ ry = h * ry;
+ }
+ var rx2 = rx * rx;
+ var ry2 = ry * ry;
+ var k = (large_arc_flag == sweep_flag ? -1 : 1) * Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
+ if (k == Infinity) k = 1;
+ var cx = k * rx * y / ry + (x1 + x2) / 2;
+ var cy = k * -ry * x / rx + (y1 + y2) / 2;
+ var f1 = Math.asin(((y1 - cy) / ry).toFixed(9));
+ var f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
+ f1 = x1 < cx ? \u03C0 - f1 : f1;
+ f2 = x2 < cx ? \u03C0 - f2 : f2;
+ if (f1 < 0) f1 = \u03C0 * 2 + f1;
+ if (f2 < 0) f2 = \u03C0 * 2 + f2;
+ if (sweep_flag && f1 > f2) f1 = f1 - \u03C0 * 2;
+ if (!sweep_flag && f2 > f1) f2 = f2 - \u03C0 * 2;
+ } else {
+ f1 = recursive[0];
+ f2 = recursive[1];
+ cx = recursive[2];
+ cy = recursive[3];
+ }
+ if (Math.abs(f2 - f1) > _120) {
+ var f2old = f2;
+ var x2old = x2;
+ var y2old = y2;
+ f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
+ x2 = cx + rx * Math.cos(f2);
+ y2 = cy + ry * Math.sin(f2);
+ var res = arc(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
+ }
+ var t = Math.tan((f2 - f1) / 4);
+ var hx = 4 / 3 * rx * t;
+ var hy = 4 / 3 * ry * t;
+ var curve = [
+ 2 * x1 - (x1 + hx * Math.sin(f1)),
+ 2 * y1 - (y1 - hy * Math.cos(f1)),
+ x2 + hx * Math.sin(f2),
+ y2 - hy * Math.cos(f2),
+ x2,
+ y2
+ ];
+ if (recursive) return curve;
+ if (res) curve = curve.concat(res);
+ for (var i = 0; i < curve.length; ) {
+ var rot = rotate(curve[i], curve[i + 1], angle);
+ curve[i++] = rot.x;
+ curve[i++] = rot.y;
+ }
+ return curve;
+ }
+ function rotate(x, y, rad) {
+ return {
+ x: x * Math.cos(rad) - y * Math.sin(rad),
+ y: x * Math.sin(rad) + y * Math.cos(rad)
+ };
+ }
+ function radians2(degress) {
+ return degress * (\u03C0 / 180);
+ }
+ }
+ });
+
+ // node_modules/draw-svg-path/index.js
+ var require_draw_svg_path = __commonJS({
+ "node_modules/draw-svg-path/index.js"(exports, module) {
+ var abs = require_abs_svg_path();
+ var normalize = require_normalize_svg_path2();
+ var methods = {
+ "M": "moveTo",
+ "C": "bezierCurveTo"
+ };
+ module.exports = function(context, segments) {
+ context.beginPath();
+ normalize(abs(segments)).forEach(
+ function(segment) {
+ var command = segment[0];
+ var args = segment.slice(1);
+ context[methods[command]].apply(context, args);
+ }
+ );
+ context.closePath();
+ };
+ }
+ });
+
+ // node_modules/bitmap-sdf/index.js
+ var require_bitmap_sdf = __commonJS({
+ "node_modules/bitmap-sdf/index.js"(exports, module) {
+ "use strict";
+ var clamp = require_clamp();
+ module.exports = calcSDF;
+ var INF = 1e20;
+ function calcSDF(src, options) {
+ if (!options) options = {};
+ var cutoff = options.cutoff == null ? 0.25 : options.cutoff;
+ var radius = options.radius == null ? 8 : options.radius;
+ var channel = options.channel || 0;
+ var w, h, size, data, intData, stride, ctx, canvas, imgData, i, l;
+ if (ArrayBuffer.isView(src) || Array.isArray(src)) {
+ if (!options.width || !options.height) throw Error("For raw data width and height should be provided by options");
+ w = options.width, h = options.height;
+ data = src;
+ if (!options.stride) stride = Math.floor(src.length / w / h);
+ else stride = options.stride;
+ } else {
+ if (window.HTMLCanvasElement && src instanceof window.HTMLCanvasElement) {
+ canvas = src;
+ ctx = canvas.getContext("2d");
+ w = canvas.width, h = canvas.height;
+ imgData = ctx.getImageData(0, 0, w, h);
+ data = imgData.data;
+ stride = 4;
+ } else if (window.CanvasRenderingContext2D && src instanceof window.CanvasRenderingContext2D) {
+ canvas = src.canvas;
+ ctx = src;
+ w = canvas.width, h = canvas.height;
+ imgData = ctx.getImageData(0, 0, w, h);
+ data = imgData.data;
+ stride = 4;
+ } else if (window.ImageData && src instanceof window.ImageData) {
+ imgData = src;
+ w = src.width, h = src.height;
+ data = imgData.data;
+ stride = 4;
+ }
+ }
+ size = Math.max(w, h);
+ if (window.Uint8ClampedArray && data instanceof window.Uint8ClampedArray || window.Uint8Array && data instanceof window.Uint8Array) {
+ intData = data;
+ data = Array(w * h);
+ for (i = 0, l = intData.length; i < l; i++) {
+ data[i] = intData[i * stride + channel] / 255;
+ }
+ } else {
+ if (stride !== 1) throw Error("Raw data can have only 1 value per pixel");
+ }
+ var gridOuter = Array(w * h);
+ var gridInner = Array(w * h);
+ var f = Array(size);
+ var d = Array(size);
+ var z = Array(size + 1);
+ var v = Array(size);
+ for (i = 0, l = w * h; i < l; i++) {
+ var a = data[i];
+ gridOuter[i] = a === 1 ? 0 : a === 0 ? INF : Math.pow(Math.max(0, 0.5 - a), 2);
+ gridInner[i] = a === 1 ? INF : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);
+ }
+ edt(gridOuter, w, h, f, d, v, z);
+ edt(gridInner, w, h, f, d, v, z);
+ var dist = window.Float32Array ? new Float32Array(w * h) : new Array(w * h);
+ for (i = 0, l = w * h; i < l; i++) {
+ dist[i] = clamp(1 - ((gridOuter[i] - gridInner[i]) / radius + cutoff), 0, 1);
+ }
+ return dist;
+ }
+ function edt(data, width, height, f, d, v, z) {
+ for (var x = 0; x < width; x++) {
+ for (var y = 0; y < height; y++) {
+ f[y] = data[y * width + x];
+ }
+ edt1d(f, d, v, z, height);
+ for (y = 0; y < height; y++) {
+ data[y * width + x] = d[y];
+ }
+ }
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ f[x] = data[y * width + x];
+ }
+ edt1d(f, d, v, z, width);
+ for (x = 0; x < width; x++) {
+ data[y * width + x] = Math.sqrt(d[x]);
+ }
+ }
+ }
+ function edt1d(f, d, v, z, n) {
+ v[0] = 0;
+ z[0] = -INF;
+ z[1] = +INF;
+ for (var q = 1, k = 0; q < n; q++) {
+ var s = (f[q] + q * q - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k]);
+ while (s <= z[k]) {
+ k--;
+ s = (f[q] + q * q - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k]);
+ }
+ k++;
+ v[k] = q;
+ z[k] = s;
+ z[k + 1] = +INF;
+ }
+ for (q = 0, k = 0; q < n; q++) {
+ while (z[k + 1] < q) k++;
+ d[q] = (q - v[k]) * (q - v[k]) + f[v[k]];
+ }
+ }
+ }
+ });
+
+ // node_modules/svg-path-sdf/index.js
+ var require_svg_path_sdf = __commonJS({
+ "node_modules/svg-path-sdf/index.js"(exports, module) {
+ "use strict";
+ var pathBounds = require_svg_path_bounds();
+ var parsePath = require_parse_svg_path();
+ var drawPath = require_draw_svg_path();
+ var isSvgPath = require_is_svg_path();
+ var bitmapSdf = require_bitmap_sdf();
+ var canvas = document.createElement("canvas");
+ var ctx = canvas.getContext("2d");
+ module.exports = pathSdf;
+ function pathSdf(path, options) {
+ if (!isSvgPath(path)) throw Error("Argument should be valid svg path string");
+ if (!options) options = {};
+ var w, h;
+ if (options.shape) {
+ w = options.shape[0];
+ h = options.shape[1];
+ } else {
+ w = canvas.width = options.w || options.width || 200;
+ h = canvas.height = options.h || options.height || 200;
+ }
+ var size = Math.min(w, h);
+ var stroke = options.stroke || 0;
+ var viewbox = options.viewbox || options.viewBox || pathBounds(path);
+ var scale = [w / (viewbox[2] - viewbox[0]), h / (viewbox[3] - viewbox[1])];
+ var maxScale = Math.min(scale[0] || 0, scale[1] || 0) / 2;
+ ctx.fillStyle = "black";
+ ctx.fillRect(0, 0, w, h);
+ ctx.fillStyle = "white";
+ if (stroke) {
+ if (typeof stroke != "number") stroke = 1;
+ if (stroke > 0) {
+ ctx.strokeStyle = "white";
+ } else {
+ ctx.strokeStyle = "black";
+ }
+ ctx.lineWidth = Math.abs(stroke);
+ }
+ ctx.translate(w * 0.5, h * 0.5);
+ ctx.scale(maxScale, maxScale);
+ if (isPath2DSupported()) {
+ var path2d = new Path2D(path);
+ ctx.fill(path2d);
+ stroke && ctx.stroke(path2d);
+ } else {
+ var segments = parsePath(path);
+ drawPath(ctx, segments);
+ ctx.fill();
+ stroke && ctx.stroke();
+ }
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ var data = bitmapSdf(ctx, {
+ cutoff: options.cutoff != null ? options.cutoff : 0.5,
+ radius: options.radius != null ? options.radius : size * 0.5
+ });
+ return data;
+ }
+ var path2DSupported;
+ function isPath2DSupported() {
+ if (path2DSupported != null) return path2DSupported;
+ var ctx2 = document.createElement("canvas").getContext("2d");
+ ctx2.canvas.width = ctx2.canvas.height = 1;
+ if (!window.Path2D) return path2DSupported = false;
+ var path = new Path2D("M0,0h1v1h-1v-1Z");
+ ctx2.fillStyle = "black";
+ ctx2.fill(path);
+ var idata = ctx2.getImageData(0, 0, 1, 1);
+ return path2DSupported = idata && idata.data && idata.data[3] === 255;
+ }
+ }
+ });
+
+ // src/traces/scattergl/convert.js
+ var require_convert10 = __commonJS({
+ "src/traces/scattergl/convert.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var svgSdf = require_svg_path_sdf();
+ var rgba3 = require_color_normalize();
+ var Registry = require_registry();
+ var Lib = require_lib();
+ var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
+ var Drawing = require_drawing();
+ var AxisIDs = require_axis_ids();
+ var formatColor = require_gl_format_color().formatColor;
+ var subTypes = require_subtypes();
+ var makeBubbleSizeFn = require_make_bubble_size_func();
+ var helpers = require_helpers16();
+ var constants = require_constants23();
+ var DESELECTDIM = require_interactions().DESELECTDIM;
+ var TEXTOFFSETSIGN = {
+ start: 1,
+ left: 1,
+ end: -1,
+ right: -1,
+ middle: 0,
+ center: 0,
+ bottom: 1,
+ top: -1
+ };
+ var appendArrayPointValue = require_helpers2().appendArrayPointValue;
+ function convertStyle(gd, trace) {
+ var i;
+ var opts = {
+ marker: void 0,
+ markerSel: void 0,
+ markerUnsel: void 0,
+ line: void 0,
+ fill: void 0,
+ errorX: void 0,
+ errorY: void 0,
+ text: void 0,
+ textSel: void 0,
+ textUnsel: void 0
+ };
+ var plotGlPixelRatio = gd._context.plotGlPixelRatio;
+ if (trace.visible !== true) return opts;
+ if (subTypes.hasText(trace)) {
+ opts.text = convertTextStyle(gd, trace);
+ opts.textSel = convertTextSelection(gd, trace, trace.selected);
+ opts.textUnsel = convertTextSelection(gd, trace, trace.unselected);
+ }
+ if (subTypes.hasMarkers(trace)) {
+ opts.marker = convertMarkerStyle(gd, trace);
+ opts.markerSel = convertMarkerSelection(gd, trace, trace.selected);
+ opts.markerUnsel = convertMarkerSelection(gd, trace, trace.unselected);
+ if (!trace.unselected && isArrayOrTypedArray(trace.marker.opacity)) {
+ var mo = trace.marker.opacity;
+ opts.markerUnsel.opacity = new Array(mo.length);
+ for (i = 0; i < mo.length; i++) {
+ opts.markerUnsel.opacity[i] = DESELECTDIM * mo[i];
+ }
+ }
+ }
+ if (subTypes.hasLines(trace)) {
+ opts.line = {
+ overlay: true,
+ thickness: trace.line.width * plotGlPixelRatio,
+ color: trace.line.color,
+ opacity: trace.opacity
+ };
+ var dashes = (constants.DASHES[trace.line.dash] || [1]).slice();
+ for (i = 0; i < dashes.length; ++i) {
+ dashes[i] *= trace.line.width * plotGlPixelRatio;
+ }
+ opts.line.dashes = dashes;
+ }
+ if (trace.error_x && trace.error_x.visible) {
+ opts.errorX = convertErrorBarStyle(trace, trace.error_x, plotGlPixelRatio);
+ }
+ if (trace.error_y && trace.error_y.visible) {
+ opts.errorY = convertErrorBarStyle(trace, trace.error_y, plotGlPixelRatio);
+ }
+ if (!!trace.fill && trace.fill !== "none") {
+ opts.fill = {
+ closed: true,
+ fill: trace.fillcolor,
+ thickness: 0
+ };
+ }
+ return opts;
+ }
+ function convertTextStyle(gd, trace) {
+ var fullLayout = gd._fullLayout;
+ var count = trace._length;
+ var textfontIn = trace.textfont;
+ var textpositionIn = trace.textposition;
+ var textPos = isArrayOrTypedArray(textpositionIn) ? textpositionIn : [textpositionIn];
+ var tfc = textfontIn.color;
+ var tfs = textfontIn.size;
+ var tff = textfontIn.family;
+ var tfw = textfontIn.weight;
+ var tfy = textfontIn.style;
+ var tfv = textfontIn.variant;
+ var optsOut = {};
+ var i;
+ var plotGlPixelRatio = gd._context.plotGlPixelRatio;
+ var texttemplate = trace.texttemplate;
+ if (texttemplate) {
+ optsOut.text = [];
+ var d3locale = fullLayout._d3locale;
+ var isArray = Array.isArray(texttemplate);
+ var N = isArray ? Math.min(texttemplate.length, count) : count;
+ var txt = isArray ? function(i2) {
+ return texttemplate[i2];
+ } : function() {
+ return texttemplate;
+ };
+ for (i = 0; i < N; i++) {
+ var d = { i };
+ var labels = trace._module.formatLabels(d, trace, fullLayout);
+ var pointValues = {};
+ appendArrayPointValue(pointValues, trace, i);
+ var meta = trace._meta || {};
+ optsOut.text.push(Lib.texttemplateString(txt(i), labels, d3locale, pointValues, d, meta));
+ }
+ } else {
+ if (isArrayOrTypedArray(trace.text) && trace.text.length < count) {
+ optsOut.text = trace.text.slice();
+ } else {
+ optsOut.text = trace.text;
+ }
+ }
+ if (isArrayOrTypedArray(optsOut.text)) {
+ for (i = optsOut.text.length; i < count; i++) {
+ optsOut.text[i] = "";
+ }
+ }
+ optsOut.opacity = trace.opacity;
+ optsOut.font = {};
+ optsOut.align = [];
+ optsOut.baseline = [];
+ for (i = 0; i < textPos.length; i++) {
+ var tp = textPos[i].split(/\s+/);
+ switch (tp[1]) {
+ case "left":
+ optsOut.align.push("right");
+ break;
+ case "right":
+ optsOut.align.push("left");
+ break;
+ default:
+ optsOut.align.push(tp[1]);
+ }
+ switch (tp[0]) {
+ case "top":
+ optsOut.baseline.push("bottom");
+ break;
+ case "bottom":
+ optsOut.baseline.push("top");
+ break;
+ default:
+ optsOut.baseline.push(tp[0]);
+ }
+ }
+ if (isArrayOrTypedArray(tfc)) {
+ optsOut.color = new Array(count);
+ for (i = 0; i < count; i++) {
+ optsOut.color[i] = tfc[i];
+ }
+ } else {
+ optsOut.color = tfc;
+ }
+ if (isArrayOrTypedArray(tfs) || Array.isArray(tff) || isArrayOrTypedArray(tfw) || Array.isArray(tfy) || Array.isArray(tfv)) {
+ optsOut.font = new Array(count);
+ for (i = 0; i < count; i++) {
+ var fonti = optsOut.font[i] = {};
+ fonti.size = (Lib.isTypedArray(tfs) ? tfs[i] : isArrayOrTypedArray(tfs) ? isNumeric(tfs[i]) ? tfs[i] : 0 : tfs) * plotGlPixelRatio;
+ fonti.family = Array.isArray(tff) ? tff[i] : tff;
+ fonti.weight = weightFallBack(isArrayOrTypedArray(tfw) ? tfw[i] : tfw);
+ fonti.style = Array.isArray(tfy) ? tfy[i] : tfy;
+ fonti.variant = Array.isArray(tfv) ? tfv[i] : tfv;
+ }
+ } else {
+ optsOut.font = {
+ size: tfs * plotGlPixelRatio,
+ family: tff,
+ weight: weightFallBack(tfw),
+ style: tfy,
+ variant: tfv
+ };
+ }
+ return optsOut;
+ }
+ function weightFallBack(w) {
+ if (w <= 1e3) {
+ return w > 500 ? "bold" : "normal";
+ }
+ return w;
+ }
+ function convertMarkerStyle(gd, trace) {
+ var count = trace._length;
+ var optsIn = trace.marker;
+ var optsOut = {};
+ var i;
+ var multiSymbol = isArrayOrTypedArray(optsIn.symbol);
+ var multiAngle = isArrayOrTypedArray(optsIn.angle);
+ var multiColor = isArrayOrTypedArray(optsIn.color);
+ var multiLineColor = isArrayOrTypedArray(optsIn.line.color);
+ var multiOpacity = isArrayOrTypedArray(optsIn.opacity);
+ var multiSize = isArrayOrTypedArray(optsIn.size);
+ var multiLineWidth = isArrayOrTypedArray(optsIn.line.width);
+ var isOpen;
+ if (!multiSymbol) isOpen = helpers.isOpenSymbol(optsIn.symbol);
+ if (multiSymbol || multiColor || multiLineColor || multiOpacity || multiAngle) {
+ optsOut.symbols = new Array(count);
+ optsOut.angles = new Array(count);
+ optsOut.colors = new Array(count);
+ optsOut.borderColors = new Array(count);
+ var symbols = optsIn.symbol;
+ var angles = optsIn.angle;
+ var colors = formatColor(optsIn, optsIn.opacity, count);
+ var borderColors = formatColor(optsIn.line, optsIn.opacity, count);
+ if (!isArrayOrTypedArray(borderColors[0])) {
+ var borderColor = borderColors;
+ borderColors = Array(count);
+ for (i = 0; i < count; i++) {
+ borderColors[i] = borderColor;
+ }
+ }
+ if (!isArrayOrTypedArray(colors[0])) {
+ var color2 = colors;
+ colors = Array(count);
+ for (i = 0; i < count; i++) {
+ colors[i] = color2;
+ }
+ }
+ if (!isArrayOrTypedArray(symbols)) {
+ var symbol = symbols;
+ symbols = Array(count);
+ for (i = 0; i < count; i++) {
+ symbols[i] = symbol;
+ }
+ }
+ if (!isArrayOrTypedArray(angles)) {
+ var angle = angles;
+ angles = Array(count);
+ for (i = 0; i < count; i++) {
+ angles[i] = angle;
+ }
+ }
+ optsOut.symbols = symbols;
+ optsOut.angles = angles;
+ optsOut.colors = colors;
+ optsOut.borderColors = borderColors;
+ for (i = 0; i < count; i++) {
+ if (multiSymbol) {
+ isOpen = helpers.isOpenSymbol(optsIn.symbol[i]);
+ }
+ if (isOpen) {
+ borderColors[i] = colors[i].slice();
+ colors[i] = colors[i].slice();
+ colors[i][3] = 0;
+ }
+ }
+ optsOut.opacity = trace.opacity;
+ optsOut.markers = new Array(count);
+ for (i = 0; i < count; i++) {
+ optsOut.markers[i] = getSymbolSdf({
+ mx: optsOut.symbols[i],
+ ma: optsOut.angles[i]
+ }, trace);
+ }
+ } else {
+ if (isOpen) {
+ optsOut.color = rgba3(optsIn.color, "uint8");
+ optsOut.color[3] = 0;
+ optsOut.borderColor = rgba3(optsIn.color, "uint8");
+ } else {
+ optsOut.color = rgba3(optsIn.color, "uint8");
+ optsOut.borderColor = rgba3(optsIn.line.color, "uint8");
+ }
+ optsOut.opacity = trace.opacity * optsIn.opacity;
+ optsOut.marker = getSymbolSdf({
+ mx: optsIn.symbol,
+ ma: optsIn.angle
+ }, trace);
+ }
+ var sizeFactor = 1;
+ var markerSizeFunc = makeBubbleSizeFn(trace, sizeFactor);
+ var s;
+ if (multiSize || multiLineWidth) {
+ var sizes = optsOut.sizes = new Array(count);
+ var borderSizes = optsOut.borderSizes = new Array(count);
+ var sizeTotal = 0;
+ var sizeAvg;
+ if (multiSize) {
+ for (i = 0; i < count; i++) {
+ sizes[i] = markerSizeFunc(optsIn.size[i]);
+ sizeTotal += sizes[i];
+ }
+ sizeAvg = sizeTotal / count;
+ } else {
+ s = markerSizeFunc(optsIn.size);
+ for (i = 0; i < count; i++) {
+ sizes[i] = s;
+ }
+ }
+ if (multiLineWidth) {
+ for (i = 0; i < count; i++) {
+ borderSizes[i] = optsIn.line.width[i];
+ }
+ } else {
+ s = optsIn.line.width;
+ for (i = 0; i < count; i++) {
+ borderSizes[i] = s;
+ }
+ }
+ optsOut.sizeAvg = sizeAvg;
+ } else {
+ optsOut.size = markerSizeFunc(optsIn && optsIn.size || 10);
+ optsOut.borderSizes = markerSizeFunc(optsIn.line.width);
+ }
+ return optsOut;
+ }
+ function convertMarkerSelection(gd, trace, target) {
+ var optsIn = trace.marker;
+ var optsOut = {};
+ if (!target) return optsOut;
+ if (target.marker && target.marker.symbol) {
+ optsOut = convertMarkerStyle(gd, Lib.extendFlat({}, optsIn, target.marker));
+ } else if (target.marker) {
+ if (target.marker.size) optsOut.size = target.marker.size;
+ if (target.marker.color) optsOut.colors = target.marker.color;
+ if (target.marker.opacity !== void 0) optsOut.opacity = target.marker.opacity;
+ }
+ return optsOut;
+ }
+ function convertTextSelection(gd, trace, target) {
+ var optsOut = {};
+ if (!target) return optsOut;
+ if (target.textfont) {
+ var optsIn = {
+ opacity: 1,
+ text: trace.text,
+ texttemplate: trace.texttemplate,
+ textposition: trace.textposition,
+ textfont: Lib.extendFlat({}, trace.textfont)
+ };
+ if (target.textfont) {
+ Lib.extendFlat(optsIn.textfont, target.textfont);
+ }
+ optsOut = convertTextStyle(gd, optsIn);
+ }
+ return optsOut;
+ }
+ function convertErrorBarStyle(trace, target, plotGlPixelRatio) {
+ var optsOut = {
+ capSize: target.width * 2 * plotGlPixelRatio,
+ lineWidth: target.thickness * plotGlPixelRatio,
+ color: target.color
+ };
+ if (target.copy_ystyle) {
+ optsOut = trace.error_y;
+ }
+ return optsOut;
+ }
+ var SYMBOL_SDF_SIZE = constants.SYMBOL_SDF_SIZE;
+ var SYMBOL_SIZE = constants.SYMBOL_SIZE;
+ var SYMBOL_STROKE = constants.SYMBOL_STROKE;
+ var SYMBOL_SDF = {};
+ var SYMBOL_SVG_CIRCLE = Drawing.symbolFuncs[0](SYMBOL_SIZE * 0.05);
+ function getSymbolSdf(d, trace) {
+ var symbol = d.mx;
+ if (symbol === "circle") return null;
+ var symbolPath, symbolSdf;
+ var symbolNumber = Drawing.symbolNumber(symbol);
+ var symbolFunc = Drawing.symbolFuncs[symbolNumber % 100];
+ var symbolNoDot = !!Drawing.symbolNoDot[symbolNumber % 100];
+ var symbolNoFill = !!Drawing.symbolNoFill[symbolNumber % 100];
+ var isDot = helpers.isDotSymbol(symbol);
+ if (d.ma) symbol += "_" + d.ma;
+ if (SYMBOL_SDF[symbol]) return SYMBOL_SDF[symbol];
+ var angle = Drawing.getMarkerAngle(d, trace);
+ if (isDot && !symbolNoDot) {
+ symbolPath = symbolFunc(SYMBOL_SIZE * 1.1, angle) + SYMBOL_SVG_CIRCLE;
+ } else {
+ symbolPath = symbolFunc(SYMBOL_SIZE, angle);
+ }
+ symbolSdf = svgSdf(symbolPath, {
+ w: SYMBOL_SDF_SIZE,
+ h: SYMBOL_SDF_SIZE,
+ viewBox: [-SYMBOL_SIZE, -SYMBOL_SIZE, SYMBOL_SIZE, SYMBOL_SIZE],
+ stroke: symbolNoFill ? SYMBOL_STROKE : -SYMBOL_STROKE
+ });
+ SYMBOL_SDF[symbol] = symbolSdf;
+ return symbolSdf || null;
+ }
+ function convertLinePositions(gd, trace, positions) {
+ var len = positions.length;
+ var count = len / 2;
+ var linePositions;
+ var i;
+ if (subTypes.hasLines(trace) && count) {
+ if (trace.line.shape === "hv") {
+ linePositions = [];
+ for (i = 0; i < count - 1; i++) {
+ if (isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1])) {
+ linePositions.push(NaN, NaN, NaN, NaN);
+ } else {
+ linePositions.push(positions[i * 2], positions[i * 2 + 1]);
+ if (!isNaN(positions[i * 2 + 2]) && !isNaN(positions[i * 2 + 3])) {
+ linePositions.push(positions[i * 2 + 2], positions[i * 2 + 1]);
+ } else {
+ linePositions.push(NaN, NaN);
+ }
+ }
+ }
+ linePositions.push(positions[len - 2], positions[len - 1]);
+ } else if (trace.line.shape === "hvh") {
+ linePositions = [];
+ for (i = 0; i < count - 1; i++) {
+ if (isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1]) || isNaN(positions[i * 2 + 2]) || isNaN(positions[i * 2 + 3])) {
+ if (!isNaN(positions[i * 2]) && !isNaN(positions[i * 2 + 1])) {
+ linePositions.push(positions[i * 2], positions[i * 2 + 1]);
+ } else {
+ linePositions.push(NaN, NaN);
+ }
+ linePositions.push(NaN, NaN);
+ } else {
+ var midPtX = (positions[i * 2] + positions[i * 2 + 2]) / 2;
+ linePositions.push(
+ positions[i * 2],
+ positions[i * 2 + 1],
+ midPtX,
+ positions[i * 2 + 1],
+ midPtX,
+ positions[i * 2 + 3]
+ );
+ }
+ }
+ linePositions.push(positions[len - 2], positions[len - 1]);
+ } else if (trace.line.shape === "vhv") {
+ linePositions = [];
+ for (i = 0; i < count - 1; i++) {
+ if (isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1]) || isNaN(positions[i * 2 + 2]) || isNaN(positions[i * 2 + 3])) {
+ if (!isNaN(positions[i * 2]) && !isNaN(positions[i * 2 + 1])) {
+ linePositions.push(positions[i * 2], positions[i * 2 + 1]);
+ } else {
+ linePositions.push(NaN, NaN);
+ }
+ linePositions.push(NaN, NaN);
+ } else {
+ var midPtY = (positions[i * 2 + 1] + positions[i * 2 + 3]) / 2;
+ linePositions.push(
+ positions[i * 2],
+ positions[i * 2 + 1],
+ positions[i * 2],
+ midPtY,
+ positions[i * 2 + 2],
+ midPtY
+ );
+ }
+ }
+ linePositions.push(positions[len - 2], positions[len - 1]);
+ } else if (trace.line.shape === "vh") {
+ linePositions = [];
+ for (i = 0; i < count - 1; i++) {
+ if (isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1])) {
+ linePositions.push(NaN, NaN, NaN, NaN);
+ } else {
+ linePositions.push(positions[i * 2], positions[i * 2 + 1]);
+ if (!isNaN(positions[i * 2 + 2]) && !isNaN(positions[i * 2 + 3])) {
+ linePositions.push(positions[i * 2], positions[i * 2 + 3]);
+ } else {
+ linePositions.push(NaN, NaN);
+ }
+ }
+ }
+ linePositions.push(positions[len - 2], positions[len - 1]);
+ } else {
+ linePositions = positions;
+ }
+ }
+ var hasNaN = false;
+ for (i = 0; i < linePositions.length; i++) {
+ if (isNaN(linePositions[i])) {
+ hasNaN = true;
+ break;
+ }
+ }
+ var join = hasNaN || linePositions.length > constants.TOO_MANY_POINTS ? "rect" : subTypes.hasMarkers(trace) ? "rect" : "round";
+ if (hasNaN && trace.connectgaps) {
+ var lastX = linePositions[0];
+ var lastY = linePositions[1];
+ for (i = 0; i < linePositions.length; i += 2) {
+ if (isNaN(linePositions[i]) || isNaN(linePositions[i + 1])) {
+ linePositions[i] = lastX;
+ linePositions[i + 1] = lastY;
+ } else {
+ lastX = linePositions[i];
+ lastY = linePositions[i + 1];
+ }
+ }
+ }
+ return {
+ join,
+ positions: linePositions
+ };
+ }
+ function convertErrorBarPositions(gd, trace, positions, x, y) {
+ var makeComputeError = Registry.getComponentMethod("errorbars", "makeComputeError");
+ var xa = AxisIDs.getFromId(gd, trace.xaxis, "x");
+ var ya = AxisIDs.getFromId(gd, trace.yaxis, "y");
+ var count = positions.length / 2;
+ var out = {};
+ function convertOneAxis(coords, ax) {
+ var axLetter = ax._id.charAt(0);
+ var opts = trace["error_" + axLetter];
+ if (opts && opts.visible && (ax.type === "linear" || ax.type === "log")) {
+ var computeError = makeComputeError(opts);
+ var pOffset = { x: 0, y: 1 }[axLetter];
+ var eOffset = { x: [0, 1, 2, 3], y: [2, 3, 0, 1] }[axLetter];
+ var errors = new Float64Array(4 * count);
+ var minShoe = Infinity;
+ var maxHat = -Infinity;
+ for (var i = 0, j = 0; i < count; i++, j += 4) {
+ var dc = coords[i];
+ if (isNumeric(dc)) {
+ var dl = positions[i * 2 + pOffset];
+ var vals = computeError(dc, i);
+ var lv = vals[0];
+ var hv = vals[1];
+ if (isNumeric(lv) && isNumeric(hv)) {
+ var shoe = dc - lv;
+ var hat = dc + hv;
+ errors[j + eOffset[0]] = dl - ax.c2l(shoe);
+ errors[j + eOffset[1]] = ax.c2l(hat) - dl;
+ errors[j + eOffset[2]] = 0;
+ errors[j + eOffset[3]] = 0;
+ minShoe = Math.min(minShoe, dc - lv);
+ maxHat = Math.max(maxHat, dc + hv);
+ }
+ }
+ }
+ out[axLetter] = {
+ positions,
+ errors,
+ _bnds: [minShoe, maxHat]
+ };
+ }
+ }
+ convertOneAxis(x, xa);
+ convertOneAxis(y, ya);
+ return out;
+ }
+ function convertTextPosition(gd, trace, textOpts, markerOpts) {
+ var count = trace._length;
+ var out = {};
+ var i;
+ if (subTypes.hasMarkers(trace)) {
+ var fontOpts = textOpts.font;
+ var align = textOpts.align;
+ var baseline = textOpts.baseline;
+ out.offset = new Array(count);
+ for (i = 0; i < count; i++) {
+ var ms = markerOpts.sizes ? markerOpts.sizes[i] : markerOpts.size;
+ var fs = isArrayOrTypedArray(fontOpts) ? fontOpts[i].size : fontOpts.size;
+ var a = isArrayOrTypedArray(align) ? align.length > 1 ? align[i] : align[0] : align;
+ var b = isArrayOrTypedArray(baseline) ? baseline.length > 1 ? baseline[i] : baseline[0] : baseline;
+ var hSign = TEXTOFFSETSIGN[a];
+ var vSign = TEXTOFFSETSIGN[b];
+ var xPad = ms ? ms / 0.8 + 1 : 0;
+ var yPad = -vSign * xPad - vSign * 0.5;
+ out.offset[i] = [hSign * xPad / fs, yPad / fs];
+ }
+ }
+ return out;
+ }
+ module.exports = {
+ style: convertStyle,
+ markerStyle: convertMarkerStyle,
+ markerSelection: convertMarkerSelection,
+ linePositions: convertLinePositions,
+ errorBarPositions: convertErrorBarPositions,
+ textPosition: convertTextPosition
+ };
+ }
+ });
+
+ // src/traces/scattergl/scene_update.js
+ var require_scene_update = __commonJS({
+ "src/traces/scattergl/scene_update.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ module.exports = function sceneUpdate(gd, subplot) {
+ var scene = subplot._scene;
+ var resetOpts = {
+ // number of traces in subplot, since scene:subplot -> 1:1
+ count: 0,
+ // whether scene requires init hook in plot call (dirty plot call)
+ dirty: true,
+ // last used options
+ lineOptions: [],
+ fillOptions: [],
+ markerOptions: [],
+ markerSelectedOptions: [],
+ markerUnselectedOptions: [],
+ errorXOptions: [],
+ errorYOptions: [],
+ textOptions: [],
+ textSelectedOptions: [],
+ textUnselectedOptions: [],
+ // selection batches
+ selectBatch: [],
+ unselectBatch: []
+ };
+ var initOpts = {
+ fill2d: false,
+ scatter2d: false,
+ error2d: false,
+ line2d: false,
+ glText: false,
+ select2d: false
+ };
+ if (!subplot._scene) {
+ scene = subplot._scene = {};
+ scene.init = function init() {
+ Lib.extendFlat(scene, initOpts, resetOpts);
+ };
+ scene.init();
+ scene.update = function update(opt) {
+ var opts = Lib.repeat(opt, scene.count);
+ if (scene.fill2d) scene.fill2d.update(opts);
+ if (scene.scatter2d) scene.scatter2d.update(opts);
+ if (scene.line2d) scene.line2d.update(opts);
+ if (scene.error2d) scene.error2d.update(opts.concat(opts));
+ if (scene.select2d) scene.select2d.update(opts);
+ if (scene.glText) {
+ for (var i = 0; i < scene.count; i++) {
+ scene.glText[i].update(opt);
+ }
+ }
+ };
+ scene.draw = function draw() {
+ var count = scene.count;
+ var fill2d = scene.fill2d;
+ var error2d = scene.error2d;
+ var line2d = scene.line2d;
+ var scatter2d = scene.scatter2d;
+ var glText = scene.glText;
+ var select2d = scene.select2d;
+ var selectBatch = scene.selectBatch;
+ var unselectBatch = scene.unselectBatch;
+ for (var i = 0; i < count; i++) {
+ if (fill2d && scene.fillOrder[i]) {
+ fill2d.draw(scene.fillOrder[i]);
+ }
+ if (line2d && scene.lineOptions[i]) {
+ line2d.draw(i);
+ }
+ if (error2d) {
+ if (scene.errorXOptions[i]) error2d.draw(i);
+ if (scene.errorYOptions[i]) error2d.draw(i + count);
+ }
+ if (scatter2d && scene.markerOptions[i]) {
+ if (unselectBatch[i].length) {
+ var arg = Lib.repeat([], scene.count);
+ arg[i] = unselectBatch[i];
+ scatter2d.draw(arg);
+ } else if (!selectBatch[i].length) {
+ scatter2d.draw(i);
+ }
+ }
+ if (glText[i] && scene.textOptions[i]) {
+ glText[i].render();
+ }
+ }
+ if (select2d) {
+ select2d.draw(selectBatch);
+ }
+ scene.dirty = false;
+ };
+ scene.destroy = function destroy() {
+ if (scene.fill2d && scene.fill2d.destroy) scene.fill2d.destroy();
+ if (scene.scatter2d && scene.scatter2d.destroy) scene.scatter2d.destroy();
+ if (scene.error2d && scene.error2d.destroy) scene.error2d.destroy();
+ if (scene.line2d && scene.line2d.destroy) scene.line2d.destroy();
+ if (scene.select2d && scene.select2d.destroy) scene.select2d.destroy();
+ if (scene.glText) {
+ scene.glText.forEach(function(text) {
+ if (text.destroy) text.destroy();
+ });
+ }
+ scene.lineOptions = null;
+ scene.fillOptions = null;
+ scene.markerOptions = null;
+ scene.markerSelectedOptions = null;
+ scene.markerUnselectedOptions = null;
+ scene.errorXOptions = null;
+ scene.errorYOptions = null;
+ scene.textOptions = null;
+ scene.textSelectedOptions = null;
+ scene.textUnselectedOptions = null;
+ scene.selectBatch = null;
+ scene.unselectBatch = null;
+ subplot._scene = null;
+ };
+ }
+ if (!scene.dirty) {
+ Lib.extendFlat(scene, resetOpts);
+ }
+ return scene;
+ };
+ }
+ });
+
+ // src/traces/scattergl/calc.js
+ var require_calc29 = __commonJS({
+ "src/traces/scattergl/calc.js"(exports, module) {
+ "use strict";
+ var cluster = require_point_cluster();
+ var Lib = require_lib();
+ var AxisIDs = require_axis_ids();
+ var findExtremes = require_autorange().findExtremes;
+ var alignPeriod = require_align_period();
+ var scatterCalc = require_calc3();
+ var calcMarkerSize = scatterCalc.calcMarkerSize;
+ var calcAxisExpansion = scatterCalc.calcAxisExpansion;
+ var setFirstScatter = scatterCalc.setFirstScatter;
+ var calcColorscale = require_colorscale_calc();
+ var convert = require_convert10();
+ var sceneUpdate = require_scene_update();
+ var BADNUM = require_numerical().BADNUM;
+ var TOO_MANY_POINTS = require_constants23().TOO_MANY_POINTS;
+ module.exports = function calc(gd, trace) {
+ var fullLayout = gd._fullLayout;
+ var xa = trace._xA = AxisIDs.getFromId(gd, trace.xaxis, "x");
+ var ya = trace._yA = AxisIDs.getFromId(gd, trace.yaxis, "y");
+ var subplot = fullLayout._plots[trace.xaxis + trace.yaxis];
+ var len = trace._length;
+ var hasTooManyPoints = len >= TOO_MANY_POINTS;
+ var len2 = len * 2;
+ var stash = {};
+ var i;
+ var origX = xa.makeCalcdata(trace, "x");
+ var origY = ya.makeCalcdata(trace, "y");
+ var xObj = alignPeriod(trace, xa, "x", origX);
+ var yObj = alignPeriod(trace, ya, "y", origY);
+ var x = xObj.vals;
+ var y = yObj.vals;
+ trace._x = x;
+ trace._y = y;
+ if (trace.xperiodalignment) {
+ trace._origX = origX;
+ trace._xStarts = xObj.starts;
+ trace._xEnds = xObj.ends;
+ }
+ if (trace.yperiodalignment) {
+ trace._origY = origY;
+ trace._yStarts = yObj.starts;
+ trace._yEnds = yObj.ends;
+ }
+ var positions = new Array(len2);
+ var _ids = new Array(len);
+ for (i = 0; i < len; i++) {
+ positions[i * 2] = x[i] === BADNUM ? NaN : x[i];
+ positions[i * 2 + 1] = y[i] === BADNUM ? NaN : y[i];
+ _ids[i] = i;
+ }
+ if (xa.type === "log") {
+ for (i = 0; i < len2; i += 2) {
+ positions[i] = xa.c2l(positions[i]);
+ }
+ }
+ if (ya.type === "log") {
+ for (i = 1; i < len2; i += 2) {
+ positions[i] = ya.c2l(positions[i]);
+ }
+ }
+ if (hasTooManyPoints && (xa.type !== "log" && ya.type !== "log")) {
+ stash.tree = cluster(positions);
+ } else {
+ stash.ids = _ids;
+ }
+ calcColorscale(gd, trace);
+ var opts = sceneOptions(gd, subplot, trace, positions, x, y);
+ var scene = sceneUpdate(gd, subplot);
+ setFirstScatter(fullLayout, trace);
+ var ppad;
+ if (!hasTooManyPoints) {
+ ppad = calcMarkerSize(trace, len);
+ } else if (opts.marker) {
+ ppad = opts.marker.sizeAvg || Math.max(opts.marker.size, 3);
+ }
+ calcAxisExpansion(gd, trace, xa, ya, x, y, ppad);
+ if (opts.errorX) expandForErrorBars(trace, xa, opts.errorX);
+ if (opts.errorY) expandForErrorBars(trace, ya, opts.errorY);
+ if (opts.fill && !scene.fill2d) scene.fill2d = true;
+ if (opts.marker && !scene.scatter2d) scene.scatter2d = true;
+ if (opts.line && !scene.line2d) scene.line2d = true;
+ if ((opts.errorX || opts.errorY) && !scene.error2d) scene.error2d = true;
+ if (opts.text && !scene.glText) scene.glText = true;
+ if (opts.marker) opts.marker.snap = len;
+ scene.lineOptions.push(opts.line);
+ scene.errorXOptions.push(opts.errorX);
+ scene.errorYOptions.push(opts.errorY);
+ scene.fillOptions.push(opts.fill);
+ scene.markerOptions.push(opts.marker);
+ scene.markerSelectedOptions.push(opts.markerSel);
+ scene.markerUnselectedOptions.push(opts.markerUnsel);
+ scene.textOptions.push(opts.text);
+ scene.textSelectedOptions.push(opts.textSel);
+ scene.textUnselectedOptions.push(opts.textUnsel);
+ scene.selectBatch.push([]);
+ scene.unselectBatch.push([]);
+ stash._scene = scene;
+ stash.index = scene.count;
+ stash.x = x;
+ stash.y = y;
+ stash.positions = positions;
+ scene.count++;
+ return [{ x: false, y: false, t: stash, trace }];
+ };
+ function expandForErrorBars(trace, ax, opts) {
+ var extremes = trace._extremes[ax._id];
+ var errExt = findExtremes(ax, opts._bnds, { padded: true });
+ extremes.min = extremes.min.concat(errExt.min);
+ extremes.max = extremes.max.concat(errExt.max);
+ }
+ function sceneOptions(gd, subplot, trace, positions, x, y) {
+ var opts = convert.style(gd, trace);
+ if (opts.marker) {
+ opts.marker.positions = positions;
+ }
+ if (opts.line && positions.length > 1) {
+ Lib.extendFlat(
+ opts.line,
+ convert.linePositions(gd, trace, positions)
+ );
+ }
+ if (opts.errorX || opts.errorY) {
+ var errors = convert.errorBarPositions(gd, trace, positions, x, y);
+ if (opts.errorX) {
+ Lib.extendFlat(opts.errorX, errors.x);
+ }
+ if (opts.errorY) {
+ Lib.extendFlat(opts.errorY, errors.y);
+ }
+ }
+ if (opts.text) {
+ Lib.extendFlat(
+ opts.text,
+ { positions },
+ convert.textPosition(gd, trace, opts.text, opts.marker)
+ );
+ Lib.extendFlat(
+ opts.textSel,
+ { positions },
+ convert.textPosition(gd, trace, opts.text, opts.markerSel)
+ );
+ Lib.extendFlat(
+ opts.textUnsel,
+ { positions },
+ convert.textPosition(gd, trace, opts.text, opts.markerUnsel)
+ );
+ }
+ return opts;
+ }
+ }
+ });
+
+ // src/traces/scattergl/edit_style.js
+ var require_edit_style = __commonJS({
+ "src/traces/scattergl/edit_style.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var Color2 = require_color();
+ var DESELECTDIM = require_interactions().DESELECTDIM;
+ function styleTextSelection(cd) {
+ var cd0 = cd[0];
+ var trace = cd0.trace;
+ var stash = cd0.t;
+ var scene = stash._scene;
+ var index = stash.index;
+ var els = scene.selectBatch[index];
+ var unels = scene.unselectBatch[index];
+ var baseOpts = scene.textOptions[index];
+ var selOpts = scene.textSelectedOptions[index] || {};
+ var unselOpts = scene.textUnselectedOptions[index] || {};
+ var opts = Lib.extendFlat({}, baseOpts);
+ var i, j;
+ if (els.length || unels.length) {
+ var stc = selOpts.color;
+ var utc = unselOpts.color;
+ var base = baseOpts.color;
+ var hasArrayBase = Lib.isArrayOrTypedArray(base);
+ opts.color = new Array(trace._length);
+ for (i = 0; i < els.length; i++) {
+ j = els[i];
+ opts.color[j] = stc || (hasArrayBase ? base[j] : base);
+ }
+ for (i = 0; i < unels.length; i++) {
+ j = unels[i];
+ var basej = hasArrayBase ? base[j] : base;
+ opts.color[j] = utc ? utc : stc ? basej : Color2.addOpacity(basej, DESELECTDIM);
+ }
+ }
+ scene.glText[index].update(opts);
+ }
+ module.exports = {
+ styleTextSelection
+ };
+ }
+ });
+
+ // src/traces/scattergl/select.js
+ var require_select7 = __commonJS({
+ "src/traces/scattergl/select.js"(exports, module) {
+ "use strict";
+ var subTypes = require_subtypes();
+ var styleTextSelection = require_edit_style().styleTextSelection;
+ module.exports = function select(searchInfo, selectionTester) {
+ var cd = searchInfo.cd;
+ var xa = searchInfo.xaxis;
+ var ya = searchInfo.yaxis;
+ var selection = [];
+ var trace = cd[0].trace;
+ var stash = cd[0].t;
+ var len = trace._length;
+ var x = stash.x;
+ var y = stash.y;
+ var scene = stash._scene;
+ var index = stash.index;
+ if (!scene) return selection;
+ var hasText = subTypes.hasText(trace);
+ var hasMarkers = subTypes.hasMarkers(trace);
+ var hasOnlyLines = !hasMarkers && !hasText;
+ if (trace.visible !== true || hasOnlyLines) return selection;
+ var els = [];
+ var unels = [];
+ if (selectionTester !== false && !selectionTester.degenerate) {
+ for (var i = 0; i < len; i++) {
+ if (selectionTester.contains([stash.xpx[i], stash.ypx[i]], false, i, searchInfo)) {
+ els.push(i);
+ selection.push({
+ pointNumber: i,
+ x: xa.c2d(x[i]),
+ y: ya.c2d(y[i])
+ });
+ } else {
+ unels.push(i);
+ }
+ }
+ }
+ if (hasMarkers) {
+ var scatter2d = scene.scatter2d;
+ if (!els.length && !unels.length) {
+ var baseOpts = new Array(scene.count);
+ baseOpts[index] = scene.markerOptions[index];
+ scatter2d.update.apply(scatter2d, baseOpts);
+ } else if (!scene.selectBatch[index].length && !scene.unselectBatch[index].length) {
+ var unselOpts = new Array(scene.count);
+ unselOpts[index] = scene.markerUnselectedOptions[index];
+ scatter2d.update.apply(scatter2d, unselOpts);
+ }
+ }
+ scene.selectBatch[index] = els;
+ scene.unselectBatch[index] = unels;
+ if (hasText) {
+ styleTextSelection(cd);
+ }
+ return selection;
+ };
+ }
+ });
+
+ // src/traces/scattergl/base_index.js
+ var require_base_index = __commonJS({
+ "src/traces/scattergl/base_index.js"(exports, module) {
+ "use strict";
+ var hover = require_hover16();
+ module.exports = {
+ moduleType: "trace",
+ name: "scattergl",
+ basePlotModule: require_cartesian(),
+ categories: ["gl", "regl", "cartesian", "symbols", "errorBarsOK", "showLegend", "scatter-like"],
+ attributes: require_attributes50(),
+ supplyDefaults: require_defaults46(),
+ crossTraceDefaults: require_cross_trace_defaults2(),
+ colorbar: require_marker_colorbar(),
+ formatLabels: require_format_labels4(),
+ calc: require_calc29(),
+ hoverPoints: hover.hoverPoints,
+ selectPoints: require_select7(),
+ meta: {}
+ };
+ }
+ });
+
+ // node_modules/color-id/index.js
+ var require_color_id = __commonJS({
+ "node_modules/color-id/index.js"(exports, module) {
+ "use strict";
+ var clamp = require_clamp();
+ module.exports = toNumber;
+ module.exports.to = toNumber;
+ module.exports.from = fromNumber;
+ function toNumber(rgba3, normalized) {
+ if (normalized == null) normalized = true;
+ var r = rgba3[0], g = rgba3[1], b = rgba3[2], a = rgba3[3];
+ if (a == null) a = normalized ? 1 : 255;
+ if (normalized) {
+ r *= 255;
+ g *= 255;
+ b *= 255;
+ a *= 255;
+ }
+ r = clamp(r, 0, 255) & 255;
+ g = clamp(g, 0, 255) & 255;
+ b = clamp(b, 0, 255) & 255;
+ a = clamp(a, 0, 255) & 255;
+ var n = r * 16777216 + (g << 16) + (b << 8) + a;
+ return n;
+ }
+ function fromNumber(n, normalized) {
+ n = +n;
+ var r = n >>> 24;
+ var g = (n & 16711680) >>> 16;
+ var b = (n & 65280) >>> 8;
+ var a = n & 255;
+ if (normalized === false) return [r, g, b, a];
+ return [r / 255, g / 255, b / 255, a / 255];
+ }
+ }
+ });
+
+ // node_modules/object-assign/index.js
+ var require_object_assign = __commonJS({
+ "node_modules/object-assign/index.js"(exports, module) {
+ "use strict";
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
+ var hasOwnProperty2 = Object.prototype.hasOwnProperty;
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
+ function toObject(val) {
+ if (val === null || val === void 0) {
+ throw new TypeError("Object.assign cannot be called with null or undefined");
+ }
+ return Object(val);
+ }
+ function shouldUseNative() {
+ try {
+ if (!Object.assign) {
+ return false;
+ }
+ var test1 = new String("abc");
+ test1[5] = "de";
+ if (Object.getOwnPropertyNames(test1)[0] === "5") {
+ return false;
+ }
+ 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;
+ }
+ var test3 = {};
+ "abcdefghijklmnopqrst".split("").forEach(function(letter) {
+ test3[letter] = letter;
+ });
+ if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
+ return false;
+ }
+ return true;
+ } catch (err) {
+ return false;
+ }
+ }
+ module.exports = 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 (hasOwnProperty2.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;
+ };
+ }
+ });
+
+ // node_modules/glslify/browser.js
+ var require_browser3 = __commonJS({
+ "node_modules/glslify/browser.js"(exports, module) {
+ module.exports = function(strings) {
+ if (typeof strings === "string") strings = [strings];
+ var exprs = [].slice.call(arguments, 1);
+ var parts = [];
+ for (var i = 0; i < strings.length - 1; i++) {
+ parts.push(strings[i], exprs[i] || "");
+ }
+ parts.push(strings[i]);
+ return parts.join("");
+ };
+ }
+ });
+
+ // node_modules/update-diff/index.js
+ var require_update_diff = __commonJS({
+ "node_modules/update-diff/index.js"(exports, module) {
+ "use strict";
+ module.exports = function updateDiff(obj, diff, mappers) {
+ if (!Array.isArray(mappers)) mappers = [].slice.call(arguments, 2);
+ for (var i = 0, l = mappers.length; i < l; i++) {
+ var dict = mappers[i];
+ for (var prop in dict) {
+ if (diff[prop] !== void 0 && !Array.isArray(diff[prop]) && obj[prop] === diff[prop]) continue;
+ if (prop in diff) {
+ var result;
+ if (dict[prop] === true) result = diff[prop];
+ else if (dict[prop] === false) continue;
+ else if (typeof dict[prop] === "function") {
+ result = dict[prop](diff[prop], obj, diff);
+ if (result === void 0) continue;
+ }
+ obj[prop] = result;
+ }
+ }
+ }
+ return obj;
+ };
+ }
+ });
+
+ // node_modules/is-iexplorer/index.js
+ var require_is_iexplorer = __commonJS({
+ "node_modules/is-iexplorer/index.js"(exports, module) {
+ "use strict";
+ module.exports = typeof navigator !== "undefined" && (/MSIE/.test(navigator.userAgent) || /Trident\//.test(navigator.appVersion));
+ }
+ });
+
+ // node_modules/to-float32/index.js
+ var require_to_float32 = __commonJS({
+ "node_modules/to-float32/index.js"(exports, module) {
+ "use strict";
+ module.exports = float32;
+ module.exports.float32 = module.exports.float = float32;
+ module.exports.fract32 = module.exports.fract = fract32;
+ var narr = new Float32Array(1);
+ function fract32(arr, fract) {
+ if (arr.length) {
+ if (arr instanceof Float32Array) return new Float32Array(arr.length);
+ if (!(fract instanceof Float32Array)) fract = float32(arr);
+ for (var i = 0, l = fract.length; i < l; i++) {
+ fract[i] = arr[i] - fract[i];
+ }
+ return fract;
+ }
+ return float32(arr - float32(arr));
+ }
+ function float32(arr) {
+ if (arr.length) {
+ if (arr instanceof Float32Array) return arr;
+ return new Float32Array(arr);
+ }
+ narr[0] = arr;
+ return narr[0];
+ }
+ }
+ });
+
+ // node_modules/regl-scatter2d/bundle.js
+ var require_bundle = __commonJS({
+ "node_modules/regl-scatter2d/bundle.js"(exports, module) {
+ "use strict";
+ function _iterableToArrayLimit(arr, i) {
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
+ if (null != _i) {
+ var _s, _e, _x, _r, _arr = [], _n = true, _d = false;
+ try {
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
+ if (Object(_i) !== _i) return;
+ _n = false;
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = true) ;
+ } catch (err) {
+ _d = true, _e = err;
+ } finally {
+ try {
+ if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
+ } finally {
+ if (_d) throw _e;
+ }
+ }
+ return _arr;
+ }
+ }
+ function _slicedToArray(arr, i) {
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
+ }
+ function _toConsumableArray(arr) {
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
+ }
+ function _arrayWithoutHoles(arr) {
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
+ }
+ function _arrayWithHoles(arr) {
+ if (Array.isArray(arr)) return arr;
+ }
+ function _iterableToArray(iter) {
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
+ }
+ function _unsupportedIterableToArray(o, minLen) {
+ if (!o) return;
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
+ var n = Object.prototype.toString.call(o).slice(8, -1);
+ if (n === "Object" && o.constructor) n = o.constructor.name;
+ if (n === "Map" || n === "Set") return Array.from(o);
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
+ }
+ function _arrayLikeToArray(arr, len) {
+ if (len == null || len > arr.length) len = arr.length;
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
+ return arr2;
+ }
+ function _nonIterableSpread() {
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+ }
+ function _nonIterableRest() {
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+ }
+ var rgba3 = require_color_normalize();
+ var getBounds = require_array_bounds();
+ var colorId = require_color_id();
+ var cluster = require_point_cluster();
+ var extend2 = require_object_assign();
+ var glslify = require_browser3();
+ var pick = require_pick_by_alias();
+ var updateDiff = require_update_diff();
+ var flatten = require_flatten_vertex_data();
+ var ie = require_is_iexplorer();
+ var f32 = require_to_float32();
+ var parseRect = require_parse_rect();
+ var scatter = Scatter;
+ function Scatter(regl, options) {
+ var _this = this;
+ if (!(this instanceof Scatter)) return new Scatter(regl, options);
+ if (typeof regl === "function") {
+ if (!options) options = {};
+ options.regl = regl;
+ } else {
+ options = regl;
+ regl = null;
+ }
+ if (options && options.length) options.positions = options;
+ regl = options.regl;
+ var gl2 = regl._gl, paletteTexture, palette = [], paletteIds = {}, groups = [], markerTextures = [null], markerCache = [null];
+ var maxColors = 255, maxSize = 100;
+ this.tooManyColors = ie;
+ paletteTexture = regl.texture({
+ data: new Uint8Array(maxColors * 4),
+ width: maxColors,
+ height: 1,
+ type: "uint8",
+ format: "rgba",
+ wrapS: "clamp",
+ wrapT: "clamp",
+ mag: "nearest",
+ min: "nearest"
+ });
+ extend2(this, {
+ regl,
+ gl: gl2,
+ groups,
+ markerCache,
+ markerTextures,
+ palette,
+ paletteIds,
+ paletteTexture,
+ maxColors,
+ maxSize,
+ canvas: gl2.canvas
+ });
+ this.update(options);
+ var shaderOptions = {
+ uniforms: {
+ constPointSize: !!options.constPointSize,
+ opacity: regl.prop("opacity"),
+ paletteSize: function paletteSize(ctx, prop) {
+ return [_this.tooManyColors ? 0 : maxColors, paletteTexture.height];
+ },
+ pixelRatio: regl.context("pixelRatio"),
+ scale: regl.prop("scale"),
+ scaleFract: regl.prop("scaleFract"),
+ translate: regl.prop("translate"),
+ translateFract: regl.prop("translateFract"),
+ markerTexture: regl.prop("markerTexture"),
+ paletteTexture
+ },
+ attributes: {
+ // FIXME: optimize these parts
+ x: function x(ctx, prop) {
+ return prop.xAttr || {
+ buffer: prop.positionBuffer,
+ stride: 8,
+ offset: 0
+ };
+ },
+ y: function y(ctx, prop) {
+ return prop.yAttr || {
+ buffer: prop.positionBuffer,
+ stride: 8,
+ offset: 4
+ };
+ },
+ xFract: function xFract(ctx, prop) {
+ return prop.xAttr ? {
+ constant: [0, 0]
+ } : {
+ buffer: prop.positionFractBuffer,
+ stride: 8,
+ offset: 0
+ };
+ },
+ yFract: function yFract(ctx, prop) {
+ return prop.yAttr ? {
+ constant: [0, 0]
+ } : {
+ buffer: prop.positionFractBuffer,
+ stride: 8,
+ offset: 4
+ };
+ },
+ size: function size(ctx, prop) {
+ return prop.size.length ? {
+ buffer: prop.sizeBuffer,
+ stride: 2,
+ offset: 0
+ } : {
+ constant: [Math.round(prop.size * 255 / _this.maxSize)]
+ };
+ },
+ borderSize: function borderSize(ctx, prop) {
+ return prop.borderSize.length ? {
+ buffer: prop.sizeBuffer,
+ stride: 2,
+ offset: 1
+ } : {
+ constant: [Math.round(prop.borderSize * 255 / _this.maxSize)]
+ };
+ },
+ colorId: function colorId2(ctx, prop) {
+ return prop.color.length ? {
+ buffer: prop.colorBuffer,
+ stride: _this.tooManyColors ? 8 : 4,
+ offset: 0
+ } : {
+ constant: _this.tooManyColors ? palette.slice(prop.color * 4, prop.color * 4 + 4) : [prop.color]
+ };
+ },
+ borderColorId: function borderColorId(ctx, prop) {
+ return prop.borderColor.length ? {
+ buffer: prop.colorBuffer,
+ stride: _this.tooManyColors ? 8 : 4,
+ offset: _this.tooManyColors ? 4 : 2
+ } : {
+ constant: _this.tooManyColors ? palette.slice(prop.borderColor * 4, prop.borderColor * 4 + 4) : [prop.borderColor]
+ };
+ },
+ isActive: function isActive(ctx, prop) {
+ return prop.activation === true ? {
+ constant: [1]
+ } : prop.activation ? prop.activation : {
+ constant: [0]
+ };
+ }
+ },
+ blend: {
+ enable: true,
+ color: [0, 0, 0, 1],
+ // photoshop blending
+ func: {
+ srcRGB: "src alpha",
+ dstRGB: "one minus src alpha",
+ srcAlpha: "one minus dst alpha",
+ dstAlpha: "one"
+ }
+ },
+ scissor: {
+ enable: true,
+ box: regl.prop("viewport")
+ },
+ viewport: regl.prop("viewport"),
+ stencil: {
+ enable: false
+ },
+ depth: {
+ enable: false
+ },
+ elements: regl.prop("elements"),
+ count: regl.prop("count"),
+ offset: regl.prop("offset"),
+ primitive: "points"
+ };
+ var markerOptions = extend2({}, shaderOptions);
+ markerOptions.frag = glslify(["precision highp float;\n#define GLSLIFY 1\n\nuniform float opacity;\nuniform sampler2D markerTexture;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragWidth, fragBorderColorLevel, fragColorLevel;\n\nfloat smoothStep(float x, float y) {\n return 1.0 / (1.0 + exp(50.0*(x - y)));\n}\n\nvoid main() {\n float dist = texture2D(markerTexture, gl_PointCoord).r, delta = fragWidth;\n\n // max-distance alpha\n if (dist < 0.003) discard;\n\n // null-border case\n if (fragBorderColorLevel == fragColorLevel || fragBorderColor.a == 0.) {\n float colorAmt = smoothstep(.5 - delta, .5 + delta, dist);\n gl_FragColor = vec4(fragColor.rgb, colorAmt * fragColor.a * opacity);\n }\n else {\n float borderColorAmt = smoothstep(fragBorderColorLevel - delta, fragBorderColorLevel + delta, dist);\n float colorAmt = smoothstep(fragColorLevel - delta, fragColorLevel + delta, dist);\n\n vec4 color = fragBorderColor;\n color.a *= borderColorAmt;\n color = mix(color, fragColor, colorAmt);\n color.a *= opacity;\n\n gl_FragColor = color;\n }\n\n}\n"]);
+ markerOptions.vert = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\n// `invariant` effectively turns off optimizations for the position.\n// We need this because -fast-math on M1 Macs is re-ordering\n// floating point operations in a way that causes floating point\n// precision limits to put points in the wrong locations.\ninvariant gl_Position;\n\nuniform bool constPointSize;\nuniform float pixelRatio;\nuniform vec2 scale, scaleFract, translate, translateFract, paletteSize;\nuniform sampler2D paletteTexture;\n\nconst float maxSize = 100.;\nconst float borderLevel = .5;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragPointSize, fragBorderRadius, fragWidth, fragBorderColorLevel, fragColorLevel;\n\nfloat pointSizeScale = (constPointSize) ? 2. : pixelRatio;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(paletteTexture,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = 2. * size * pointSizeScale;\n fragPointSize = size * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0., 1.);\n\n fragColor = color;\n fragBorderColor = borderColor;\n fragWidth = 1. / gl_PointSize;\n\n fragBorderColorLevel = clamp(borderLevel - borderLevel * borderSize / size, 0., 1.);\n fragColorLevel = clamp(borderLevel + (1. - borderLevel) * borderSize / size, 0., 1.);\n}\n"]);
+ this.drawMarker = regl(markerOptions);
+ var circleOptions = extend2({}, shaderOptions);
+ circleOptions.frag = glslify(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nuniform float opacity;\n\nfloat smoothStep(float edge0, float edge1, float x) {\n float t;\n t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n return t * t * (3.0 - 2.0 * t);\n}\n\nvoid main() {\n float radius, alpha = 1.0, delta = fragWidth;\n\n radius = length(2.0 * gl_PointCoord.xy - 1.0);\n\n if (radius > 1.0 + delta) {\n discard;\n }\n\n alpha -= smoothstep(1.0 - delta, 1.0 + delta, radius);\n\n float borderRadius = fragBorderRadius;\n float ratio = smoothstep(borderRadius - delta, borderRadius + delta, radius);\n vec4 color = mix(fragColor, fragBorderColor, ratio);\n color.a *= alpha * opacity;\n gl_FragColor = color;\n}\n"]);
+ circleOptions.vert = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\n// `invariant` effectively turns off optimizations for the position.\n// We need this because -fast-math on M1 Macs is re-ordering\n// floating point operations in a way that causes floating point\n// precision limits to put points in the wrong locations.\ninvariant gl_Position;\n\nuniform bool constPointSize;\nuniform float pixelRatio;\nuniform vec2 paletteSize, scale, scaleFract, translate, translateFract;\nuniform sampler2D paletteTexture;\n\nconst float maxSize = 100.;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragBorderRadius, fragWidth;\n\nfloat pointSizeScale = (constPointSize) ? 2. : pixelRatio;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(paletteTexture,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = (size + borderSize) * pointSizeScale;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0., 1.);\n\n fragBorderRadius = 1. - 2. * borderSize / (size + borderSize);\n fragColor = color;\n fragBorderColor = borderColor.a == 0. || borderSize == 0. ? vec4(color.rgb, 0.) : borderColor;\n fragWidth = 1. / gl_PointSize;\n}\n"]);
+ if (ie) {
+ circleOptions.frag = circleOptions.frag.replace("smoothstep", "smoothStep");
+ markerOptions.frag = markerOptions.frag.replace("smoothstep", "smoothStep");
+ }
+ this.drawCircle = regl(circleOptions);
+ }
+ Scatter.defaults = {
+ color: "black",
+ borderColor: "transparent",
+ borderSize: 0,
+ size: 12,
+ opacity: 1,
+ marker: void 0,
+ viewport: null,
+ range: null,
+ pixelSize: null,
+ count: 0,
+ offset: 0,
+ bounds: null,
+ positions: [],
+ snap: 1e4
+ };
+ Scatter.prototype.render = function() {
+ if (arguments.length) {
+ this.update.apply(this, arguments);
+ }
+ this.draw();
+ return this;
+ };
+ Scatter.prototype.draw = function() {
+ var _this2 = this;
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
+ var groups = this.groups;
+ if (args.length === 1 && Array.isArray(args[0]) && (args[0][0] === null || Array.isArray(args[0][0]))) {
+ args = args[0];
+ }
+ this.regl._refresh();
+ if (args.length) {
+ for (var i = 0; i < args.length; i++) {
+ this.drawItem(i, args[i]);
+ }
+ } else {
+ groups.forEach(function(group, i2) {
+ _this2.drawItem(i2);
+ });
+ }
+ return this;
+ };
+ Scatter.prototype.drawItem = function(id, els) {
+ var groups = this.groups;
+ var group = groups[id];
+ if (typeof els === "number") {
+ id = els;
+ group = groups[els];
+ els = null;
+ }
+ if (!(group && group.count && group.opacity)) return;
+ if (group.activation[0]) {
+ this.drawCircle(this.getMarkerDrawOptions(0, group, els));
+ }
+ var batch = [];
+ for (var i = 1; i < group.activation.length; i++) {
+ if (!group.activation[i] || group.activation[i] !== true && !group.activation[i].data.length) continue;
+ batch.push.apply(batch, _toConsumableArray(this.getMarkerDrawOptions(i, group, els)));
+ }
+ if (batch.length) {
+ this.drawMarker(batch);
+ }
+ };
+ Scatter.prototype.getMarkerDrawOptions = function(markerId, group, elements) {
+ var range = group.range, tree = group.tree, viewport = group.viewport, activation = group.activation, selectionBuffer = group.selectionBuffer, count = group.count;
+ var regl = this.regl;
+ if (!tree) {
+ if (elements) {
+ return [extend2({}, group, {
+ markerTexture: this.markerTextures[markerId],
+ activation: activation[markerId],
+ count: elements.length,
+ elements,
+ offset: 0
+ })];
+ }
+ return [extend2({}, group, {
+ markerTexture: this.markerTextures[markerId],
+ activation: activation[markerId],
+ offset: 0
+ })];
+ }
+ var batch = [];
+ var lod = tree.range(range, {
+ lod: true,
+ px: [(range[2] - range[0]) / viewport.width, (range[3] - range[1]) / viewport.height]
+ });
+ if (elements) {
+ var markerActivation = activation[markerId];
+ var mask = markerActivation.data;
+ var data = new Uint8Array(count);
+ for (var i = 0; i < elements.length; i++) {
+ var id = elements[i];
+ data[id] = mask ? mask[id] : 1;
+ }
+ selectionBuffer.subdata(data);
+ }
+ for (var l = lod.length; l--; ) {
+ var _lod$l = _slicedToArray(lod[l], 2), from = _lod$l[0], to = _lod$l[1];
+ batch.push(extend2({}, group, {
+ markerTexture: this.markerTextures[markerId],
+ activation: elements ? selectionBuffer : activation[markerId],
+ offset: from,
+ count: to - from
+ }));
+ }
+ return batch;
+ };
+ Scatter.prototype.update = function() {
+ var _this3 = this;
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
+ args[_key2] = arguments[_key2];
+ }
+ if (!args.length) return;
+ if (args.length === 1 && Array.isArray(args[0])) args = args[0];
+ var groups = this.groups, gl2 = this.gl, regl = this.regl, maxSize = this.maxSize, maxColors = this.maxColors, palette = this.palette;
+ this.groups = groups = args.map(function(options, i) {
+ var group = groups[i];
+ if (options === void 0) return group;
+ if (options === null) options = {
+ positions: null
+ };
+ else if (typeof options === "function") options = {
+ ondraw: options
+ };
+ else if (typeof options[0] === "number") options = {
+ positions: options
+ };
+ options = pick(options, {
+ positions: "positions data points",
+ snap: "snap cluster lod tree",
+ size: "sizes size radius",
+ borderSize: "borderSizes borderSize border-size bordersize borderWidth borderWidths border-width borderwidth stroke-width strokeWidth strokewidth outline",
+ color: "colors color fill fill-color fillColor",
+ borderColor: "borderColors borderColor stroke stroke-color strokeColor",
+ marker: "markers marker shape",
+ range: "range dataBox databox",
+ viewport: "viewport viewPort viewBox viewbox",
+ opacity: "opacity alpha transparency",
+ bounds: "bound bounds boundaries limits",
+ tooManyColors: "tooManyColors palette paletteMode optimizePalette enablePalette"
+ });
+ if (options.positions === null) options.positions = [];
+ if (options.tooManyColors != null) _this3.tooManyColors = options.tooManyColors;
+ if (!group) {
+ groups[i] = group = {
+ id: i,
+ scale: null,
+ translate: null,
+ scaleFract: null,
+ translateFract: null,
+ // buffers for active markers
+ activation: [],
+ // buffer for filtered markers
+ selectionBuffer: regl.buffer({
+ data: new Uint8Array(0),
+ usage: "stream",
+ type: "uint8"
+ }),
+ // buffers with data: it is faster to switch them per-pass
+ // than provide one congregate buffer
+ sizeBuffer: regl.buffer({
+ data: new Uint8Array(0),
+ usage: "dynamic",
+ type: "uint8"
+ }),
+ colorBuffer: regl.buffer({
+ data: new Uint8Array(0),
+ usage: "dynamic",
+ type: "uint8"
+ }),
+ positionBuffer: regl.buffer({
+ data: new Uint8Array(0),
+ usage: "dynamic",
+ type: "float"
+ }),
+ positionFractBuffer: regl.buffer({
+ data: new Uint8Array(0),
+ usage: "dynamic",
+ type: "float"
+ })
+ };
+ options = extend2({}, Scatter.defaults, options);
+ }
+ if (options.positions && !("marker" in options)) {
+ options.marker = group.marker;
+ delete group.marker;
+ }
+ if (options.marker && !("positions" in options)) {
+ options.positions = group.positions;
+ delete group.positions;
+ }
+ var hasSize = 0, hasColor = 0;
+ updateDiff(group, options, [{
+ snap: true,
+ size: function size2(s, group2) {
+ if (s == null) s = Scatter.defaults.size;
+ hasSize += s && s.length ? 1 : 0;
+ return s;
+ },
+ borderSize: function borderSize2(s, group2) {
+ if (s == null) s = Scatter.defaults.borderSize;
+ hasSize += s && s.length ? 1 : 0;
+ return s;
+ },
+ opacity: parseFloat,
+ // add colors to palette, save references
+ color: function color3(c, group2) {
+ if (c == null) c = Scatter.defaults.color;
+ c = _this3.updateColor(c);
+ hasColor++;
+ return c;
+ },
+ borderColor: function borderColor2(c, group2) {
+ if (c == null) c = Scatter.defaults.borderColor;
+ c = _this3.updateColor(c);
+ hasColor++;
+ return c;
+ },
+ bounds: function bounds(_bounds, group2, options2) {
+ if (!("range" in options2)) options2.range = null;
+ return _bounds;
+ },
+ positions: function positions(_positions, group2, options2) {
+ var snap = group2.snap;
+ var positionBuffer = group2.positionBuffer, positionFractBuffer = group2.positionFractBuffer, selectionBuffer = group2.selectionBuffer;
+ if (_positions.x || _positions.y) {
+ if (_positions.x.length) {
+ group2.xAttr = {
+ buffer: regl.buffer(_positions.x),
+ offset: 0,
+ stride: 4,
+ count: _positions.x.length
+ };
+ } else {
+ group2.xAttr = {
+ buffer: _positions.x.buffer,
+ offset: _positions.x.offset * 4 || 0,
+ stride: (_positions.x.stride || 1) * 4,
+ count: _positions.x.count
+ };
+ }
+ if (_positions.y.length) {
+ group2.yAttr = {
+ buffer: regl.buffer(_positions.y),
+ offset: 0,
+ stride: 4,
+ count: _positions.y.length
+ };
+ } else {
+ group2.yAttr = {
+ buffer: _positions.y.buffer,
+ offset: _positions.y.offset * 4 || 0,
+ stride: (_positions.y.stride || 1) * 4,
+ count: _positions.y.count
+ };
+ }
+ group2.count = Math.max(group2.xAttr.count, group2.yAttr.count);
+ return _positions;
+ }
+ _positions = flatten(_positions, "float64");
+ var count2 = group2.count = Math.floor(_positions.length / 2);
+ var bounds = group2.bounds = count2 ? getBounds(_positions, 2) : null;
+ if (!options2.range && !group2.range) {
+ delete group2.range;
+ options2.range = bounds;
+ }
+ if (!options2.marker && !group2.marker) {
+ delete group2.marker;
+ options2.marker = null;
+ }
+ if (snap && (snap === true || count2 > snap)) {
+ group2.tree = cluster(_positions, {
+ bounds
+ });
+ } else if (snap && snap.length) {
+ group2.tree = snap;
+ }
+ if (group2.tree) {
+ var opts = {
+ primitive: "points",
+ usage: "static",
+ data: group2.tree,
+ type: "uint32"
+ };
+ if (group2.elements) group2.elements(opts);
+ else group2.elements = regl.elements(opts);
+ }
+ var float_data = f32.float32(_positions);
+ positionBuffer({
+ data: float_data,
+ usage: "dynamic"
+ });
+ var frac_data = f32.fract32(_positions, float_data);
+ positionFractBuffer({
+ data: frac_data,
+ usage: "dynamic"
+ });
+ selectionBuffer({
+ data: new Uint8Array(count2),
+ type: "uint8",
+ usage: "stream"
+ });
+ return _positions;
+ }
+ }, {
+ // create marker ids corresponding to known marker textures
+ marker: function marker(markers, group2, options2) {
+ var activation = group2.activation;
+ activation.forEach(function(buffer) {
+ return buffer && buffer.destroy && buffer.destroy();
+ });
+ activation.length = 0;
+ if (!markers || typeof markers[0] === "number") {
+ var id = _this3.addMarker(markers);
+ activation[id] = true;
+ } else {
+ var markerMasks = [];
+ for (var _i = 0, l = Math.min(markers.length, group2.count); _i < l; _i++) {
+ var _id = _this3.addMarker(markers[_i]);
+ if (!markerMasks[_id]) markerMasks[_id] = new Uint8Array(group2.count);
+ markerMasks[_id][_i] = 1;
+ }
+ for (var _id2 = 0; _id2 < markerMasks.length; _id2++) {
+ if (!markerMasks[_id2]) continue;
+ var opts = {
+ data: markerMasks[_id2],
+ type: "uint8",
+ usage: "static"
+ };
+ if (!activation[_id2]) {
+ activation[_id2] = regl.buffer(opts);
+ } else {
+ activation[_id2](opts);
+ }
+ activation[_id2].data = markerMasks[_id2];
+ }
+ }
+ return markers;
+ },
+ range: function range(_range, group2, options2) {
+ var bounds = group2.bounds;
+ if (!bounds) return;
+ if (!_range) _range = bounds;
+ group2.scale = [1 / (_range[2] - _range[0]), 1 / (_range[3] - _range[1])];
+ group2.translate = [-_range[0], -_range[1]];
+ group2.scaleFract = f32.fract(group2.scale);
+ group2.translateFract = f32.fract(group2.translate);
+ return _range;
+ },
+ viewport: function viewport(vp) {
+ var rect = parseRect(vp || [gl2.drawingBufferWidth, gl2.drawingBufferHeight]);
+ return rect;
+ }
+ }]);
+ if (hasSize) {
+ var _group = group, count = _group.count, size = _group.size, borderSize = _group.borderSize, sizeBuffer = _group.sizeBuffer;
+ var sizes = new Uint8Array(count * 2);
+ if (size.length || borderSize.length) {
+ for (var _i2 = 0; _i2 < count; _i2++) {
+ sizes[_i2 * 2] = Math.round((size[_i2] == null ? size : size[_i2]) * 255 / maxSize);
+ sizes[_i2 * 2 + 1] = Math.round((borderSize[_i2] == null ? borderSize : borderSize[_i2]) * 255 / maxSize);
+ }
+ }
+ sizeBuffer({
+ data: sizes,
+ usage: "dynamic"
+ });
+ }
+ if (hasColor) {
+ var _group2 = group, _count = _group2.count, color2 = _group2.color, borderColor = _group2.borderColor, colorBuffer = _group2.colorBuffer;
+ var colors;
+ if (_this3.tooManyColors) {
+ if (color2.length || borderColor.length) {
+ colors = new Uint8Array(_count * 8);
+ for (var _i3 = 0; _i3 < _count; _i3++) {
+ var _colorId = color2[_i3];
+ colors[_i3 * 8] = palette[_colorId * 4];
+ colors[_i3 * 8 + 1] = palette[_colorId * 4 + 1];
+ colors[_i3 * 8 + 2] = palette[_colorId * 4 + 2];
+ colors[_i3 * 8 + 3] = palette[_colorId * 4 + 3];
+ var borderColorId = borderColor[_i3];
+ colors[_i3 * 8 + 4] = palette[borderColorId * 4];
+ colors[_i3 * 8 + 5] = palette[borderColorId * 4 + 1];
+ colors[_i3 * 8 + 6] = palette[borderColorId * 4 + 2];
+ colors[_i3 * 8 + 7] = palette[borderColorId * 4 + 3];
+ }
+ }
+ } else {
+ if (color2.length || borderColor.length) {
+ colors = new Uint8Array(_count * 4 + 2);
+ for (var _i4 = 0; _i4 < _count; _i4++) {
+ if (color2[_i4] != null) {
+ colors[_i4 * 4] = color2[_i4] % maxColors;
+ colors[_i4 * 4 + 1] = Math.floor(color2[_i4] / maxColors);
+ }
+ if (borderColor[_i4] != null) {
+ colors[_i4 * 4 + 2] = borderColor[_i4] % maxColors;
+ colors[_i4 * 4 + 3] = Math.floor(borderColor[_i4] / maxColors);
+ }
+ }
+ }
+ }
+ colorBuffer({
+ data: colors || new Uint8Array(0),
+ type: "uint8",
+ usage: "dynamic"
+ });
+ }
+ return group;
+ });
+ };
+ Scatter.prototype.addMarker = function(sdf) {
+ var markerTextures = this.markerTextures, regl = this.regl, markerCache = this.markerCache;
+ var pos = sdf == null ? 0 : markerCache.indexOf(sdf);
+ if (pos >= 0) return pos;
+ var distArr;
+ if (sdf instanceof Uint8Array || sdf instanceof Uint8ClampedArray) {
+ distArr = sdf;
+ } else {
+ distArr = new Uint8Array(sdf.length);
+ for (var i = 0, l = sdf.length; i < l; i++) {
+ distArr[i] = sdf[i] * 255;
+ }
+ }
+ var radius = Math.floor(Math.sqrt(distArr.length));
+ pos = markerTextures.length;
+ markerCache.push(sdf);
+ markerTextures.push(regl.texture({
+ channels: 1,
+ data: distArr,
+ radius,
+ mag: "linear",
+ min: "linear"
+ }));
+ return pos;
+ };
+ Scatter.prototype.updateColor = function(colors) {
+ var paletteIds = this.paletteIds, palette = this.palette, maxColors = this.maxColors;
+ if (!Array.isArray(colors)) {
+ colors = [colors];
+ }
+ var idx = [];
+ if (typeof colors[0] === "number") {
+ var grouped = [];
+ if (Array.isArray(colors)) {
+ for (var i = 0; i < colors.length; i += 4) {
+ grouped.push(colors.slice(i, i + 4));
+ }
+ } else {
+ for (var _i5 = 0; _i5 < colors.length; _i5 += 4) {
+ grouped.push(colors.subarray(_i5, _i5 + 4));
+ }
+ }
+ colors = grouped;
+ }
+ for (var _i6 = 0; _i6 < colors.length; _i6++) {
+ var color2 = colors[_i6];
+ color2 = rgba3(color2, "uint8");
+ var id = colorId(color2, false);
+ if (paletteIds[id] == null) {
+ var pos = palette.length;
+ paletteIds[id] = Math.floor(pos / 4);
+ palette[pos] = color2[0];
+ palette[pos + 1] = color2[1];
+ palette[pos + 2] = color2[2];
+ palette[pos + 3] = color2[3];
+ }
+ idx[_i6] = paletteIds[id];
+ }
+ if (!this.tooManyColors && palette.length > maxColors * 4) this.tooManyColors = true;
+ this.updatePalette(palette);
+ return idx.length === 1 ? idx[0] : idx;
+ };
+ Scatter.prototype.updatePalette = function(palette) {
+ if (this.tooManyColors) return;
+ var maxColors = this.maxColors, paletteTexture = this.paletteTexture;
+ var requiredHeight = Math.ceil(palette.length * 0.25 / maxColors);
+ if (requiredHeight > 1) {
+ palette = palette.slice();
+ for (var i = palette.length * 0.25 % maxColors; i < requiredHeight * maxColors; i++) {
+ palette.push(0, 0, 0, 0);
+ }
+ }
+ if (paletteTexture.height < requiredHeight) {
+ paletteTexture.resize(maxColors, requiredHeight);
+ }
+ paletteTexture.subimage({
+ width: Math.min(palette.length * 0.25, maxColors),
+ height: requiredHeight,
+ data: palette
+ }, 0, 0);
+ };
+ Scatter.prototype.destroy = function() {
+ this.groups.forEach(function(group) {
+ group.sizeBuffer.destroy();
+ group.positionBuffer.destroy();
+ group.positionFractBuffer.destroy();
+ group.colorBuffer.destroy();
+ group.activation.forEach(function(b) {
+ return b && b.destroy && b.destroy();
+ });
+ group.selectionBuffer.destroy();
+ if (group.elements) group.elements.destroy();
+ });
+ this.groups.length = 0;
+ this.paletteTexture.destroy();
+ this.markerTextures.forEach(function(txt) {
+ return txt && txt.destroy && txt.destroy();
+ });
+ return this;
+ };
+ var extend$1 = require_object_assign();
+ var reglScatter2d = function reglScatter2d2(regl, options) {
+ var scatter$1 = new scatter(regl, options);
+ var render = scatter$1.render.bind(scatter$1);
+ extend$1(render, {
+ render,
+ update: scatter$1.update.bind(scatter$1),
+ draw: scatter$1.draw.bind(scatter$1),
+ destroy: scatter$1.destroy.bind(scatter$1),
+ regl: scatter$1.regl,
+ gl: scatter$1.gl,
+ canvas: scatter$1.gl.canvas,
+ groups: scatter$1.groups,
+ markers: scatter$1.markerCache,
+ palette: scatter$1.palette
+ });
+ return render;
+ };
+ module.exports = reglScatter2d;
+ }
+ });
+
+ // node_modules/earcut/src/earcut.js
+ var require_earcut = __commonJS({
+ "node_modules/earcut/src/earcut.js"(exports, module) {
+ "use strict";
+ module.exports = earcut;
+ module.exports.default = 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 || outerNode.next === outerNode.prev) return triangles;
+ var minX, minY, maxX, maxY, x, y, invSize;
+ if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
+ 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;
+ }
+ invSize = Math.max(maxX - minX, maxY - minY);
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
+ }
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
+ return 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);
+ }
+ if (last && equals(last, last.next)) {
+ removeNode(last);
+ last = last.next;
+ }
+ return last;
+ }
+ function filterPoints(start, end) {
+ if (!start) return start;
+ if (!end) end = start;
+ var p = start, again;
+ do {
+ again = false;
+ if (!p.steiner && (equals(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;
+ }
+ function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
+ if (!ear) return;
+ if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
+ var stop = ear, prev, next;
+ while (ear.prev !== ear.next) {
+ prev = ear.prev;
+ next = ear.next;
+ if (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;
+ continue;
+ }
+ ear = next;
+ if (ear === stop) {
+ if (!pass) {
+ earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
+ } else if (pass === 1) {
+ ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
+ earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
+ } else if (pass === 2) {
+ splitEarcut(ear, triangles, dim, minX, minY, invSize);
+ }
+ break;
+ }
+ }
+ }
+ function isEar(ear) {
+ var a = ear.prev, b = ear, c = ear.next;
+ if (area(a, b, c) >= 0) return false;
+ var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
+ var 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;
+ var p = c.next;
+ while (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 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;
+ var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
+ var 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;
+ var minZ = zOrder(x0, y0, minX, minY, invSize), maxZ = zOrder(x1, y1, minX, minY, invSize);
+ var p = ear.prevZ, n = ear.nextZ;
+ while (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 false;
+ p = p.prevZ;
+ 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 false;
+ n = n.nextZ;
+ }
+ while (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 false;
+ p = p.prevZ;
+ }
+ while (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 false;
+ n = n.nextZ;
+ }
+ return true;
+ }
+ function cureLocalIntersections(start, triangles, dim) {
+ var p = start;
+ do {
+ var a = p.prev, b = p.next.next;
+ if (!equals(a, b) && intersects(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 {
+ var b = a.next.next;
+ while (b !== a.prev) {
+ if (a.i !== b.i && isValidDiagonal(a, b)) {
+ var c = splitPolygon(a, b);
+ a = filterPoints(a, a.next);
+ c = filterPoints(c, c.next);
+ earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
+ earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
+ return;
+ }
+ b = b.next;
+ }
+ a = a.next;
+ } while (a !== start);
+ }
+ 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);
+ for (i = 0; i < queue.length; i++) {
+ outerNode = eliminateHole(queue[i], outerNode);
+ }
+ return outerNode;
+ }
+ function compareX(a, b) {
+ return a.x - b.x;
+ }
+ function eliminateHole(hole, outerNode) {
+ var bridge = findHoleBridge(hole, outerNode);
+ if (!bridge) {
+ return outerNode;
+ }
+ var bridgeReverse = splitPolygon(bridge, hole);
+ filterPoints(bridgeReverse, bridgeReverse.next);
+ return filterPoints(bridge, bridge.next);
+ }
+ function findHoleBridge(hole, outerNode) {
+ var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m;
+ 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;
+ if (x === hx) return m;
+ }
+ }
+ p = p.next;
+ } while (p !== outerNode);
+ if (!m) return null;
+ var stop = m, mx = m.x, my = m.y, tanMin = Infinity, tan;
+ p = m;
+ do {
+ 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);
+ if (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;
+ }
+ function sectorContainsSector(m, p) {
+ return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
+ }
+ function indexCurve(start, minX, minY, invSize) {
+ var p = start;
+ do {
+ if (p.z === 0) 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);
+ }
+ 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;
+ }
+ function zOrder(x, y, minX, minY, invSize) {
+ x = (x - minX) * invSize | 0;
+ y = (y - minY) * invSize | 0;
+ x = (x | x << 8) & 16711935;
+ x = (x | x << 4) & 252645135;
+ x = (x | x << 2) & 858993459;
+ x = (x | x << 1) & 1431655765;
+ y = (y | y << 8) & 16711935;
+ y = (y | y << 4) & 252645135;
+ y = (y | y << 2) & 858993459;
+ y = (y | y << 1) & 1431655765;
+ return x | y << 1;
+ }
+ function getLeftmost(start) {
+ var p = start, leftmost = start;
+ do {
+ if (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 && !intersectsPolygon(a, b) && // dones't intersect other edges
+ (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
+ (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
+ 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(p1, q1, p2, q2) {
+ var o1 = sign(area(p1, q1, p2));
+ var o2 = sign(area(p1, q1, q2));
+ var o3 = sign(area(p2, q2, p1));
+ var o4 = sign(area(p2, q2, q1));
+ if (o1 !== o2 && o3 !== o4) return true;
+ if (o1 === 0 && onSegment(p1, p2, q1)) return true;
+ if (o2 === 0 && onSegment(p1, q2, q1)) return true;
+ if (o3 === 0 && onSegment(p2, p1, q2)) return true;
+ if (o4 === 0 && onSegment(p2, q1, q2)) return true;
+ return false;
+ }
+ 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 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(p, p.next, a, b)) return true;
+ p = p.next;
+ } while (p !== a);
+ return false;
+ }
+ 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 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;
+ }
+ 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;
+ 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;
+ }
+ function insertNode(i, x, y, last) {
+ var p = new Node(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(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 = false;
+ }
+ 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;
+ }
+ 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;
+ };
+ }
+ });
+
+ // node_modules/array-normalize/index.js
+ var require_array_normalize = __commonJS({
+ "node_modules/array-normalize/index.js"(exports, module) {
+ "use strict";
+ var getBounds = require_array_bounds();
+ module.exports = normalize;
+ function normalize(arr, dim, bounds) {
+ if (!arr || arr.length == null) throw Error("Argument should be an array");
+ if (dim == null) dim = 1;
+ if (bounds == null) bounds = getBounds(arr, dim);
+ for (var offset = 0; offset < dim; offset++) {
+ var max = bounds[dim + offset], min = bounds[offset], i = offset, l = arr.length;
+ if (max === Infinity && min === -Infinity) {
+ for (i = offset; i < l; i += dim) {
+ arr[i] = arr[i] === max ? 1 : arr[i] === min ? 0 : 0.5;
+ }
+ } else if (max === Infinity) {
+ for (i = offset; i < l; i += dim) {
+ arr[i] = arr[i] === max ? 1 : 0;
+ }
+ } else if (min === -Infinity) {
+ for (i = offset; i < l; i += dim) {
+ arr[i] = arr[i] === min ? 0 : 1;
+ }
+ } else {
+ var range = max - min;
+ for (i = offset; i < l; i += dim) {
+ if (!isNaN(arr[i])) {
+ arr[i] = range === 0 ? 0.5 : (arr[i] - min) / range;
+ }
+ }
+ }
+ }
+ return arr;
+ }
+ }
+ });
+
+ // node_modules/es6-weak-map/is-implemented.js
+ var require_is_implemented = __commonJS({
+ "node_modules/es6-weak-map/is-implemented.js"(exports, module) {
+ "use strict";
+ module.exports = function() {
+ var weakMap, obj;
+ if (typeof WeakMap !== "function") return false;
+ try {
+ weakMap = new WeakMap([[obj = {}, "one"], [{}, "two"], [{}, "three"]]);
+ } catch (e) {
+ return false;
+ }
+ if (String(weakMap) !== "[object WeakMap]") return false;
+ if (typeof weakMap.set !== "function") return false;
+ if (weakMap.set({}, 1) !== weakMap) return false;
+ if (typeof weakMap.delete !== "function") return false;
+ if (typeof weakMap.has !== "function") return false;
+ if (weakMap.get(obj) !== "one") return false;
+ return true;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/function/noop.js
+ var require_noop2 = __commonJS({
+ "node_modules/es5-ext/function/noop.js"(exports, module) {
+ "use strict";
+ module.exports = function() {
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/is-value.js
+ var require_is_value = __commonJS({
+ "node_modules/es5-ext/object/is-value.js"(exports, module) {
+ "use strict";
+ var _undefined = require_noop2()();
+ module.exports = function(val) {
+ return val !== _undefined && val !== null;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/set-prototype-of/is-implemented.js
+ var require_is_implemented2 = __commonJS({
+ "node_modules/es5-ext/object/set-prototype-of/is-implemented.js"(exports, module) {
+ "use strict";
+ var create = Object.create;
+ var getPrototypeOf = Object.getPrototypeOf;
+ var plainObject = {};
+ module.exports = function() {
+ var setPrototypeOf = Object.setPrototypeOf, customCreate = arguments[0] || create;
+ if (typeof setPrototypeOf !== "function") return false;
+ return getPrototypeOf(setPrototypeOf(customCreate(null), plainObject)) === plainObject;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/is-object.js
+ var require_is_object = __commonJS({
+ "node_modules/es5-ext/object/is-object.js"(exports, module) {
+ "use strict";
+ var isValue = require_is_value();
+ var map = { function: true, object: true };
+ module.exports = function(value) {
+ return isValue(value) && map[typeof value] || false;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/valid-value.js
+ var require_valid_value = __commonJS({
+ "node_modules/es5-ext/object/valid-value.js"(exports, module) {
+ "use strict";
+ var isValue = require_is_value();
+ module.exports = function(value) {
+ if (!isValue(value)) throw new TypeError("Cannot use null or undefined");
+ return value;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/create.js
+ var require_create2 = __commonJS({
+ "node_modules/es5-ext/object/create.js"(exports, module) {
+ "use strict";
+ var create = Object.create;
+ var shim;
+ if (!require_is_implemented2()()) {
+ shim = require_shim3();
+ }
+ module.exports = function() {
+ var nullObject, polyProps, desc;
+ if (!shim) return create;
+ if (shim.level !== 1) return create;
+ nullObject = {};
+ polyProps = {};
+ desc = { configurable: false, enumerable: false, writable: true, value: void 0 };
+ Object.getOwnPropertyNames(Object.prototype).forEach(function(name2) {
+ if (name2 === "__proto__") {
+ polyProps[name2] = {
+ configurable: true,
+ enumerable: false,
+ writable: true,
+ value: void 0
+ };
+ return;
+ }
+ polyProps[name2] = desc;
+ });
+ Object.defineProperties(nullObject, polyProps);
+ Object.defineProperty(shim, "nullPolyfill", {
+ configurable: false,
+ enumerable: false,
+ writable: false,
+ value: nullObject
+ });
+ return function(prototype, props) {
+ return create(prototype === null ? nullObject : prototype, props);
+ };
+ }();
+ }
+ });
+
+ // node_modules/es5-ext/object/set-prototype-of/shim.js
+ var require_shim3 = __commonJS({
+ "node_modules/es5-ext/object/set-prototype-of/shim.js"(exports, module) {
+ "use strict";
+ var isObject = require_is_object();
+ var value = require_valid_value();
+ var objIsPrototypeOf = Object.prototype.isPrototypeOf;
+ var defineProperty = Object.defineProperty;
+ var nullDesc = { configurable: true, enumerable: false, writable: true, value: void 0 };
+ var validate;
+ validate = function(obj, prototype) {
+ value(obj);
+ if (prototype === null || isObject(prototype)) return obj;
+ throw new TypeError("Prototype must be null or an object");
+ };
+ module.exports = function(status) {
+ var fn, set;
+ if (!status) return null;
+ if (status.level === 2) {
+ if (status.set) {
+ set = status.set;
+ fn = function(obj, prototype) {
+ set.call(validate(obj, prototype), prototype);
+ return obj;
+ };
+ } else {
+ fn = function(obj, prototype) {
+ validate(obj, prototype).__proto__ = prototype;
+ return obj;
+ };
+ }
+ } else {
+ fn = function self2(obj, prototype) {
+ var isNullBase;
+ validate(obj, prototype);
+ isNullBase = objIsPrototypeOf.call(self2.nullPolyfill, obj);
+ if (isNullBase) delete self2.nullPolyfill.__proto__;
+ if (prototype === null) prototype = self2.nullPolyfill;
+ obj.__proto__ = prototype;
+ if (isNullBase) defineProperty(self2.nullPolyfill, "__proto__", nullDesc);
+ return obj;
+ };
+ }
+ return Object.defineProperty(fn, "level", {
+ configurable: false,
+ enumerable: false,
+ writable: false,
+ value: status.level
+ });
+ }(
+ function() {
+ var tmpObj1 = /* @__PURE__ */ Object.create(null), tmpObj2 = {}, set, desc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
+ if (desc) {
+ try {
+ set = desc.set;
+ set.call(tmpObj1, tmpObj2);
+ } catch (ignore) {
+ }
+ if (Object.getPrototypeOf(tmpObj1) === tmpObj2) return { set, level: 2 };
+ }
+ tmpObj1.__proto__ = tmpObj2;
+ if (Object.getPrototypeOf(tmpObj1) === tmpObj2) return { level: 2 };
+ tmpObj1 = {};
+ tmpObj1.__proto__ = tmpObj2;
+ if (Object.getPrototypeOf(tmpObj1) === tmpObj2) return { level: 1 };
+ return false;
+ }()
+ );
+ require_create2();
+ }
+ });
+
+ // node_modules/es5-ext/object/set-prototype-of/index.js
+ var require_set_prototype_of = __commonJS({
+ "node_modules/es5-ext/object/set-prototype-of/index.js"(exports, module) {
+ "use strict";
+ module.exports = require_is_implemented2()() ? Object.setPrototypeOf : require_shim3();
+ }
+ });
+
+ // node_modules/es5-ext/object/valid-object.js
+ var require_valid_object = __commonJS({
+ "node_modules/es5-ext/object/valid-object.js"(exports, module) {
+ "use strict";
+ var isObject = require_is_object();
+ module.exports = function(value) {
+ if (!isObject(value)) throw new TypeError(value + " is not an Object");
+ return value;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/string/random-uniq.js
+ var require_random_uniq = __commonJS({
+ "node_modules/es5-ext/string/random-uniq.js"(exports, module) {
+ "use strict";
+ var generated = /* @__PURE__ */ Object.create(null);
+ var random = Math.random;
+ module.exports = function() {
+ var str;
+ do {
+ str = random().toString(36).slice(2);
+ } while (generated[str]);
+ return str;
+ };
+ }
+ });
+
+ // node_modules/type/value/is.js
+ var require_is = __commonJS({
+ "node_modules/type/value/is.js"(exports, module) {
+ "use strict";
+ var _undefined = void 0;
+ module.exports = function(value) {
+ return value !== _undefined && value !== null;
+ };
+ }
+ });
+
+ // node_modules/type/object/is.js
+ var require_is2 = __commonJS({
+ "node_modules/type/object/is.js"(exports, module) {
+ "use strict";
+ var isValue = require_is();
+ var possibleTypes = {
+ "object": true,
+ "function": true,
+ "undefined": true
+ /* document.all */
+ };
+ module.exports = function(value) {
+ if (!isValue(value)) return false;
+ return hasOwnProperty.call(possibleTypes, typeof value);
+ };
+ }
+ });
+
+ // node_modules/type/prototype/is.js
+ var require_is3 = __commonJS({
+ "node_modules/type/prototype/is.js"(exports, module) {
+ "use strict";
+ var isObject = require_is2();
+ module.exports = function(value) {
+ if (!isObject(value)) return false;
+ try {
+ if (!value.constructor) return false;
+ return value.constructor.prototype === value;
+ } catch (error) {
+ return false;
+ }
+ };
+ }
+ });
+
+ // node_modules/type/function/is.js
+ var require_is4 = __commonJS({
+ "node_modules/type/function/is.js"(exports, module) {
+ "use strict";
+ var isPrototype = require_is3();
+ module.exports = function(value) {
+ if (typeof value !== "function") return false;
+ if (!hasOwnProperty.call(value, "length")) return false;
+ try {
+ if (typeof value.length !== "number") return false;
+ if (typeof value.call !== "function") return false;
+ if (typeof value.apply !== "function") return false;
+ } catch (error) {
+ return false;
+ }
+ return !isPrototype(value);
+ };
+ }
+ });
+
+ // node_modules/type/plain-function/is.js
+ var require_is5 = __commonJS({
+ "node_modules/type/plain-function/is.js"(exports, module) {
+ "use strict";
+ var isFunction = require_is4();
+ var classRe = /^\s*class[\s{/}]/;
+ var functionToString = Function.prototype.toString;
+ module.exports = function(value) {
+ if (!isFunction(value)) return false;
+ if (classRe.test(functionToString.call(value))) return false;
+ return true;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/assign/is-implemented.js
+ var require_is_implemented3 = __commonJS({
+ "node_modules/es5-ext/object/assign/is-implemented.js"(exports, module) {
+ "use strict";
+ module.exports = function() {
+ var assign = Object.assign, obj;
+ if (typeof assign !== "function") return false;
+ obj = { foo: "raz" };
+ assign(obj, { bar: "dwa" }, { trzy: "trzy" });
+ return obj.foo + obj.bar + obj.trzy === "razdwatrzy";
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/keys/is-implemented.js
+ var require_is_implemented4 = __commonJS({
+ "node_modules/es5-ext/object/keys/is-implemented.js"(exports, module) {
+ "use strict";
+ module.exports = function() {
+ try {
+ Object.keys("primitive");
+ return true;
+ } catch (e) {
+ return false;
+ }
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/keys/shim.js
+ var require_shim4 = __commonJS({
+ "node_modules/es5-ext/object/keys/shim.js"(exports, module) {
+ "use strict";
+ var isValue = require_is_value();
+ var keys = Object.keys;
+ module.exports = function(object) {
+ return keys(isValue(object) ? Object(object) : object);
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/keys/index.js
+ var require_keys = __commonJS({
+ "node_modules/es5-ext/object/keys/index.js"(exports, module) {
+ "use strict";
+ module.exports = require_is_implemented4()() ? Object.keys : require_shim4();
+ }
+ });
+
+ // node_modules/es5-ext/object/assign/shim.js
+ var require_shim5 = __commonJS({
+ "node_modules/es5-ext/object/assign/shim.js"(exports, module) {
+ "use strict";
+ var keys = require_keys();
+ var value = require_valid_value();
+ var max = Math.max;
+ module.exports = function(dest, src) {
+ var error, i, length = max(arguments.length, 2), assign;
+ dest = Object(value(dest));
+ assign = function(key) {
+ try {
+ dest[key] = src[key];
+ } catch (e) {
+ if (!error) error = e;
+ }
+ };
+ for (i = 1; i < length; ++i) {
+ src = arguments[i];
+ keys(src).forEach(assign);
+ }
+ if (error !== void 0) throw error;
+ return dest;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/assign/index.js
+ var require_assign = __commonJS({
+ "node_modules/es5-ext/object/assign/index.js"(exports, module) {
+ "use strict";
+ module.exports = require_is_implemented3()() ? Object.assign : require_shim5();
+ }
+ });
+
+ // node_modules/es5-ext/object/normalize-options.js
+ var require_normalize_options = __commonJS({
+ "node_modules/es5-ext/object/normalize-options.js"(exports, module) {
+ "use strict";
+ var isValue = require_is_value();
+ var forEach = Array.prototype.forEach;
+ var create = Object.create;
+ var process2 = function(src, obj) {
+ var key;
+ for (key in src) obj[key] = src[key];
+ };
+ module.exports = function(opts1) {
+ var result = create(null);
+ forEach.call(arguments, function(options) {
+ if (!isValue(options)) return;
+ process2(Object(options), result);
+ });
+ return result;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/string/#/contains/is-implemented.js
+ var require_is_implemented5 = __commonJS({
+ "node_modules/es5-ext/string/#/contains/is-implemented.js"(exports, module) {
+ "use strict";
+ var str = "razdwatrzy";
+ module.exports = function() {
+ if (typeof str.contains !== "function") return false;
+ return str.contains("dwa") === true && str.contains("foo") === false;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/string/#/contains/shim.js
+ var require_shim6 = __commonJS({
+ "node_modules/es5-ext/string/#/contains/shim.js"(exports, module) {
+ "use strict";
+ var indexOf = String.prototype.indexOf;
+ module.exports = function(searchString) {
+ return indexOf.call(this, searchString, arguments[1]) > -1;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/string/#/contains/index.js
+ var require_contains = __commonJS({
+ "node_modules/es5-ext/string/#/contains/index.js"(exports, module) {
+ "use strict";
+ module.exports = require_is_implemented5()() ? String.prototype.contains : require_shim6();
+ }
+ });
+
+ // node_modules/d/index.js
+ var require_d = __commonJS({
+ "node_modules/d/index.js"(exports, module) {
+ "use strict";
+ var isValue = require_is();
+ var isPlainFunction = require_is5();
+ var assign = require_assign();
+ var normalizeOpts = require_normalize_options();
+ var contains = require_contains();
+ var d = module.exports = function(dscr, value) {
+ var c, e, w, options, desc;
+ if (arguments.length < 2 || typeof dscr !== "string") {
+ options = value;
+ value = dscr;
+ dscr = null;
+ } else {
+ options = arguments[2];
+ }
+ if (isValue(dscr)) {
+ c = contains.call(dscr, "c");
+ e = contains.call(dscr, "e");
+ w = contains.call(dscr, "w");
+ } else {
+ c = w = true;
+ e = false;
+ }
+ desc = { value, configurable: c, enumerable: e, writable: w };
+ return !options ? desc : assign(normalizeOpts(options), desc);
+ };
+ d.gs = function(dscr, get, set) {
+ var c, e, options, desc;
+ if (typeof dscr !== "string") {
+ options = set;
+ set = get;
+ get = dscr;
+ dscr = null;
+ } else {
+ options = arguments[3];
+ }
+ if (!isValue(get)) {
+ get = void 0;
+ } else if (!isPlainFunction(get)) {
+ options = get;
+ get = set = void 0;
+ } else if (!isValue(set)) {
+ set = void 0;
+ } else if (!isPlainFunction(set)) {
+ options = set;
+ set = void 0;
+ }
+ if (isValue(dscr)) {
+ c = contains.call(dscr, "c");
+ e = contains.call(dscr, "e");
+ } else {
+ c = true;
+ e = false;
+ }
+ desc = { get, set, configurable: c, enumerable: e };
+ return !options ? desc : assign(normalizeOpts(options), desc);
+ };
+ }
+ });
+
+ // node_modules/es5-ext/function/is-arguments.js
+ var require_is_arguments2 = __commonJS({
+ "node_modules/es5-ext/function/is-arguments.js"(exports, module) {
+ "use strict";
+ var objToString = Object.prototype.toString;
+ var id = objToString.call(/* @__PURE__ */ function() {
+ return arguments;
+ }());
+ module.exports = function(value) {
+ return objToString.call(value) === id;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/string/is-string.js
+ var require_is_string = __commonJS({
+ "node_modules/es5-ext/string/is-string.js"(exports, module) {
+ "use strict";
+ var objToString = Object.prototype.toString;
+ var id = objToString.call("");
+ module.exports = function(value) {
+ return typeof value === "string" || value && typeof value === "object" && (value instanceof String || objToString.call(value) === id) || false;
+ };
+ }
+ });
+
+ // node_modules/ext/global-this/is-implemented.js
+ var require_is_implemented6 = __commonJS({
+ "node_modules/ext/global-this/is-implemented.js"(exports, module) {
+ "use strict";
+ module.exports = function() {
+ if (typeof globalThis !== "object") return false;
+ if (!globalThis) return false;
+ return globalThis.Array === Array;
+ };
+ }
+ });
+
+ // node_modules/ext/global-this/implementation.js
+ var require_implementation6 = __commonJS({
+ "node_modules/ext/global-this/implementation.js"(exports, module) {
+ var naiveFallback = function() {
+ if (typeof self === "object" && self) return self;
+ if (typeof window === "object" && window) return window;
+ throw new Error("Unable to resolve global `this`");
+ };
+ module.exports = function() {
+ if (this) return this;
+ try {
+ Object.defineProperty(Object.prototype, "__global__", {
+ get: function() {
+ return this;
+ },
+ configurable: true
+ });
+ } catch (error) {
+ return naiveFallback();
+ }
+ try {
+ if (!__global__) return naiveFallback();
+ return __global__;
+ } finally {
+ delete Object.prototype.__global__;
+ }
+ }();
+ }
+ });
+
+ // node_modules/ext/global-this/index.js
+ var require_global_this = __commonJS({
+ "node_modules/ext/global-this/index.js"(exports, module) {
+ "use strict";
+ module.exports = require_is_implemented6()() ? globalThis : require_implementation6();
+ }
+ });
+
+ // node_modules/es6-symbol/is-implemented.js
+ var require_is_implemented7 = __commonJS({
+ "node_modules/es6-symbol/is-implemented.js"(exports, module) {
+ "use strict";
+ var global2 = require_global_this();
+ var validTypes = { object: true, symbol: true };
+ module.exports = function() {
+ var Symbol2 = global2.Symbol;
+ var symbol;
+ if (typeof Symbol2 !== "function") return false;
+ symbol = Symbol2("test symbol");
+ try {
+ String(symbol);
+ } catch (e) {
+ return false;
+ }
+ if (!validTypes[typeof Symbol2.iterator]) return false;
+ if (!validTypes[typeof Symbol2.toPrimitive]) return false;
+ if (!validTypes[typeof Symbol2.toStringTag]) return false;
+ return true;
+ };
+ }
+ });
+
+ // node_modules/es6-symbol/is-symbol.js
+ var require_is_symbol = __commonJS({
+ "node_modules/es6-symbol/is-symbol.js"(exports, module) {
+ "use strict";
+ module.exports = function(value) {
+ if (!value) return false;
+ if (typeof value === "symbol") return true;
+ if (!value.constructor) return false;
+ if (value.constructor.name !== "Symbol") return false;
+ return value[value.constructor.toStringTag] === "Symbol";
+ };
+ }
+ });
+
+ // node_modules/es6-symbol/validate-symbol.js
+ var require_validate_symbol = __commonJS({
+ "node_modules/es6-symbol/validate-symbol.js"(exports, module) {
+ "use strict";
+ var isSymbol = require_is_symbol();
+ module.exports = function(value) {
+ if (!isSymbol(value)) throw new TypeError(value + " is not a symbol");
+ return value;
+ };
+ }
+ });
+
+ // node_modules/es6-symbol/lib/private/generate-name.js
+ var require_generate_name = __commonJS({
+ "node_modules/es6-symbol/lib/private/generate-name.js"(exports, module) {
+ "use strict";
+ var d = require_d();
+ var create = Object.create;
+ var defineProperty = Object.defineProperty;
+ var objPrototype = Object.prototype;
+ var created = create(null);
+ module.exports = function(desc) {
+ var postfix = 0, name2, ie11BugWorkaround;
+ while (created[desc + (postfix || "")]) ++postfix;
+ desc += postfix || "";
+ created[desc] = true;
+ name2 = "@@" + desc;
+ defineProperty(
+ objPrototype,
+ name2,
+ d.gs(null, function(value) {
+ if (ie11BugWorkaround) return;
+ ie11BugWorkaround = true;
+ defineProperty(this, name2, d(value));
+ ie11BugWorkaround = false;
+ })
+ );
+ return name2;
+ };
+ }
+ });
+
+ // node_modules/es6-symbol/lib/private/setup/standard-symbols.js
+ var require_standard_symbols = __commonJS({
+ "node_modules/es6-symbol/lib/private/setup/standard-symbols.js"(exports, module) {
+ "use strict";
+ var d = require_d();
+ var NativeSymbol = require_global_this().Symbol;
+ module.exports = function(SymbolPolyfill) {
+ return Object.defineProperties(SymbolPolyfill, {
+ // To ensure proper interoperability with other native functions (e.g. Array.from)
+ // fallback to eventual native implementation of given symbol
+ hasInstance: d(
+ "",
+ NativeSymbol && NativeSymbol.hasInstance || SymbolPolyfill("hasInstance")
+ ),
+ isConcatSpreadable: d(
+ "",
+ NativeSymbol && NativeSymbol.isConcatSpreadable || SymbolPolyfill("isConcatSpreadable")
+ ),
+ iterator: d("", NativeSymbol && NativeSymbol.iterator || SymbolPolyfill("iterator")),
+ match: d("", NativeSymbol && NativeSymbol.match || SymbolPolyfill("match")),
+ replace: d("", NativeSymbol && NativeSymbol.replace || SymbolPolyfill("replace")),
+ search: d("", NativeSymbol && NativeSymbol.search || SymbolPolyfill("search")),
+ species: d("", NativeSymbol && NativeSymbol.species || SymbolPolyfill("species")),
+ split: d("", NativeSymbol && NativeSymbol.split || SymbolPolyfill("split")),
+ toPrimitive: d(
+ "",
+ NativeSymbol && NativeSymbol.toPrimitive || SymbolPolyfill("toPrimitive")
+ ),
+ toStringTag: d(
+ "",
+ NativeSymbol && NativeSymbol.toStringTag || SymbolPolyfill("toStringTag")
+ ),
+ unscopables: d(
+ "",
+ NativeSymbol && NativeSymbol.unscopables || SymbolPolyfill("unscopables")
+ )
+ });
+ };
+ }
+ });
+
+ // node_modules/es6-symbol/lib/private/setup/symbol-registry.js
+ var require_symbol_registry = __commonJS({
+ "node_modules/es6-symbol/lib/private/setup/symbol-registry.js"(exports, module) {
+ "use strict";
+ var d = require_d();
+ var validateSymbol = require_validate_symbol();
+ var registry = /* @__PURE__ */ Object.create(null);
+ module.exports = function(SymbolPolyfill) {
+ return Object.defineProperties(SymbolPolyfill, {
+ for: d(function(key) {
+ if (registry[key]) return registry[key];
+ return registry[key] = SymbolPolyfill(String(key));
+ }),
+ keyFor: d(function(symbol) {
+ var key;
+ validateSymbol(symbol);
+ for (key in registry) {
+ if (registry[key] === symbol) return key;
+ }
+ return void 0;
+ })
+ });
+ };
+ }
+ });
+
+ // node_modules/es6-symbol/polyfill.js
+ var require_polyfill4 = __commonJS({
+ "node_modules/es6-symbol/polyfill.js"(exports, module) {
+ "use strict";
+ var d = require_d();
+ var validateSymbol = require_validate_symbol();
+ var NativeSymbol = require_global_this().Symbol;
+ var generateName = require_generate_name();
+ var setupStandardSymbols = require_standard_symbols();
+ var setupSymbolRegistry = require_symbol_registry();
+ var create = Object.create;
+ var defineProperties = Object.defineProperties;
+ var defineProperty = Object.defineProperty;
+ var SymbolPolyfill;
+ var HiddenSymbol;
+ var isNativeSafe;
+ if (typeof NativeSymbol === "function") {
+ try {
+ String(NativeSymbol());
+ isNativeSafe = true;
+ } catch (ignore) {
+ }
+ } else {
+ NativeSymbol = null;
+ }
+ HiddenSymbol = function Symbol2(description) {
+ if (this instanceof HiddenSymbol) throw new TypeError("Symbol is not a constructor");
+ return SymbolPolyfill(description);
+ };
+ module.exports = SymbolPolyfill = function Symbol2(description) {
+ var symbol;
+ if (this instanceof Symbol2) throw new TypeError("Symbol is not a constructor");
+ if (isNativeSafe) return NativeSymbol(description);
+ symbol = create(HiddenSymbol.prototype);
+ description = description === void 0 ? "" : String(description);
+ return defineProperties(symbol, {
+ __description__: d("", description),
+ __name__: d("", generateName(description))
+ });
+ };
+ setupStandardSymbols(SymbolPolyfill);
+ setupSymbolRegistry(SymbolPolyfill);
+ defineProperties(HiddenSymbol.prototype, {
+ constructor: d(SymbolPolyfill),
+ toString: d("", function() {
+ return this.__name__;
+ })
+ });
+ defineProperties(SymbolPolyfill.prototype, {
+ toString: d(function() {
+ return "Symbol (" + validateSymbol(this).__description__ + ")";
+ }),
+ valueOf: d(function() {
+ return validateSymbol(this);
+ })
+ });
+ defineProperty(
+ SymbolPolyfill.prototype,
+ SymbolPolyfill.toPrimitive,
+ d("", function() {
+ var symbol = validateSymbol(this);
+ if (typeof symbol === "symbol") return symbol;
+ return symbol.toString();
+ })
+ );
+ defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toStringTag, d("c", "Symbol"));
+ defineProperty(
+ HiddenSymbol.prototype,
+ SymbolPolyfill.toStringTag,
+ d("c", SymbolPolyfill.prototype[SymbolPolyfill.toStringTag])
+ );
+ defineProperty(
+ HiddenSymbol.prototype,
+ SymbolPolyfill.toPrimitive,
+ d("c", SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive])
+ );
+ }
+ });
+
+ // node_modules/es6-symbol/index.js
+ var require_es6_symbol = __commonJS({
+ "node_modules/es6-symbol/index.js"(exports, module) {
+ "use strict";
+ module.exports = require_is_implemented7()() ? require_global_this().Symbol : require_polyfill4();
+ }
+ });
+
+ // node_modules/es5-ext/array/#/clear.js
+ var require_clear = __commonJS({
+ "node_modules/es5-ext/array/#/clear.js"(exports, module) {
+ "use strict";
+ var value = require_valid_value();
+ module.exports = function() {
+ value(this).length = 0;
+ return this;
+ };
+ }
+ });
+
+ // node_modules/es5-ext/object/valid-callable.js
+ var require_valid_callable = __commonJS({
+ "node_modules/es5-ext/object/valid-callable.js"(exports, module) {
+ "use strict";
+ module.exports = function(fn) {
+ if (typeof fn !== "function") throw new TypeError(fn + " is not a function");
+ return fn;
+ };
+ }
+ });
+
+ // node_modules/type/string/coerce.js
+ var require_coerce2 = __commonJS({
+ "node_modules/type/string/coerce.js"(exports, module) {
+ "use strict";
+ var isValue = require_is();
+ var isObject = require_is2();
+ var objectToString = Object.prototype.toString;
+ module.exports = function(value) {
+ if (!isValue(value)) return null;
+ if (isObject(value)) {
+ var valueToString = value.toString;
+ if (typeof valueToString !== "function") return null;
+ if (valueToString === objectToString) return null;
+ }
+ try {
+ return "" + value;
+ } catch (error) {
+ return null;
+ }
+ };
+ }
+ });
+
+ // node_modules/type/lib/safe-to-string.js
+ var require_safe_to_string = __commonJS({
+ "node_modules/type/lib/safe-to-string.js"(exports, module) {
+ "use strict";
+ module.exports = function(value) {
+ try {
+ return value.toString();
+ } catch (error) {
+ try {
+ return String(value);
+ } catch (error2) {
+ return null;
+ }
+ }
+ };
+ }
+ });
+
+ // node_modules/type/lib/to-short-string.js
+ var require_to_short_string = __commonJS({
+ "node_modules/type/lib/to-short-string.js"(exports, module) {
+ "use strict";
+ var safeToString = require_safe_to_string();
+ var reNewLine = /[\n\r\u2028\u2029]/g;
+ module.exports = function(value) {
+ var string = safeToString(value);
+ if (string === null) return "
");
+ var mouseX = d3.mouse(gd)[0];
+ Fx.loneHover({
+ trace,
+ x: hoverCenterX - rootBBox.left + graphDivBBox.left,
+ y: hoverCenterY - rootBBox.top + graphDivBBox.top,
+ text: hovertext,
+ color: d.model.color,
+ borderColor: "black",
+ fontFamily: 'Monaco, "Courier New", monospace',
+ fontSize: 10,
+ fontColor: textColor,
+ idealAlign: mouseX < hoverCenterX ? "right" : "left",
+ hovertemplate: (trace.line || {}).hovertemplate,
+ hovertemplateLabels: labels,
+ eventData: [{
+ data: trace._input,
+ fullData: trace,
+ count,
+ probability: prob
+ }]
+ }, {
+ container: fullLayout._hoverlayer.node(),
+ outerContainer: fullLayout._paper.node(),
+ gd
+ });
+ }
+ }
+ }
+ }
+ function mouseoutPath(d) {
+ if (!d.parcatsViewModel.dragDimension) {
+ stylePathsNoHover(d3.select(this));
+ Fx.loneUnhover(d.parcatsViewModel.graphDiv._fullLayout._hoverlayer.node());
+ d.parcatsViewModel.pathSelection.sort(compareRawColor);
+ if (d.parcatsViewModel.hoverinfoItems.indexOf("skip") === -1) {
+ var points = buildPointsArrayForPath(d);
+ var constraints = buildConstraintsForPath(d);
+ d.parcatsViewModel.graphDiv.emit("plotly_unhover", {
+ points,
+ event: d3.event,
+ constraints
+ });
+ }
+ }
+ }
+ function buildPointsArrayForPath(d) {
+ var points = [];
+ var curveNumber = getTraceIndex(d.parcatsViewModel);
+ for (var i = 0; i < d.model.valueInds.length; i++) {
+ var pointNumber = d.model.valueInds[i];
+ points.push({
+ curveNumber,
+ pointNumber
+ });
+ }
+ return points;
+ }
+ function buildConstraintsForPath(d) {
+ var constraints = {};
+ var dimensions = d.parcatsViewModel.model.dimensions;
+ for (var i = 0; i < dimensions.length; i++) {
+ var dimension = dimensions[i];
+ var category = dimension.categories[d.model.categoryInds[i]];
+ constraints[dimension.containerInd] = category.categoryValue;
+ }
+ if (d.model.rawColor !== void 0) {
+ constraints.color = d.model.rawColor;
+ }
+ return constraints;
+ }
+ function clickPath(d) {
+ if (d.parcatsViewModel.hoverinfoItems.indexOf("skip") === -1) {
+ var points = buildPointsArrayForPath(d);
+ var constraints = buildConstraintsForPath(d);
+ d.parcatsViewModel.graphDiv.emit("plotly_click", {
+ points,
+ event: d3.event,
+ constraints
+ });
+ }
+ }
+ function stylePathsNoHover(pathSelection) {
+ pathSelection.attr("fill", function(d) {
+ return d.model.color;
+ }).attr("fill-opacity", 0.6).attr("stroke", "lightgray").attr("stroke-width", 0.2).attr("stroke-opacity", 1);
+ }
+ function stylePathsHover(pathSelection) {
+ pathSelection.attr("fill-opacity", 0.8).attr("stroke", function(d) {
+ return tinycolor.mostReadable(d.model.color, ["black", "white"]);
+ }).attr("stroke-width", 0.3);
+ }
+ function styleCategoryHover(categorySelection) {
+ categorySelection.select("rect.catrect").attr("stroke", "black").attr("stroke-width", 2.5);
+ }
+ function styleCategoriesNoHover(categorySelection) {
+ categorySelection.select("rect.catrect").attr("stroke", "black").attr("stroke-width", 1).attr("stroke-opacity", 1);
+ }
+ function styleBandsHover(bandsSelection) {
+ bandsSelection.attr("stroke", "black").attr("stroke-width", 1.5);
+ }
+ function styleBandsNoHover(bandsSelection) {
+ bandsSelection.attr("stroke", "black").attr("stroke-width", 0.2).attr("stroke-opacity", 1).attr("fill-opacity", 1);
+ }
+ function selectPathsThroughCategoryBandColor(catBandViewModel) {
+ var allPaths = catBandViewModel.parcatsViewModel.pathSelection;
+ var dimInd = catBandViewModel.categoryViewModel.model.dimensionInd;
+ var catInd = catBandViewModel.categoryViewModel.model.categoryInd;
+ return allPaths.filter(
+ /** @param {PathViewModel} pathViewModel */
+ function(pathViewModel) {
+ return pathViewModel.model.categoryInds[dimInd] === catInd && pathViewModel.model.color === catBandViewModel.color;
+ }
+ );
+ }
+ function styleForCategoryHovermode(bandElement) {
+ var bandSel = d3.select(bandElement.parentNode).selectAll("rect.bandrect");
+ bandSel.each(function(bvm) {
+ var paths = selectPathsThroughCategoryBandColor(bvm);
+ stylePathsHover(paths);
+ paths.each(function() {
+ Lib.raiseToTop(this);
+ });
+ });
+ styleCategoryHover(d3.select(bandElement.parentNode));
+ }
+ function styleForColorHovermode(bandElement) {
+ var bandViewModel = d3.select(bandElement).datum();
+ var catPaths = selectPathsThroughCategoryBandColor(bandViewModel);
+ stylePathsHover(catPaths);
+ catPaths.each(function() {
+ Lib.raiseToTop(this);
+ });
+ d3.select(bandElement.parentNode).selectAll("rect.bandrect").filter(function(b) {
+ return b.color === bandViewModel.color;
+ }).each(function() {
+ Lib.raiseToTop(this);
+ styleBandsHover(d3.select(this));
+ });
+ }
+ function emitPointsEventCategoryHovermode(bandElement, eventName, event) {
+ var bandViewModel = d3.select(bandElement).datum();
+ var categoryModel = bandViewModel.categoryViewModel.model;
+ var gd = bandViewModel.parcatsViewModel.graphDiv;
+ var bandSel = d3.select(bandElement.parentNode).selectAll("rect.bandrect");
+ var points = [];
+ bandSel.each(function(bvm) {
+ var paths = selectPathsThroughCategoryBandColor(bvm);
+ paths.each(function(pathViewModel) {
+ Array.prototype.push.apply(points, buildPointsArrayForPath(pathViewModel));
+ });
+ });
+ var constraints = {};
+ constraints[categoryModel.dimensionInd] = categoryModel.categoryValue;
+ gd.emit(eventName, {
+ points,
+ event,
+ constraints
+ });
+ }
+ function emitPointsEventColorHovermode(bandElement, eventName, event) {
+ var bandViewModel = d3.select(bandElement).datum();
+ var categoryModel = bandViewModel.categoryViewModel.model;
+ var gd = bandViewModel.parcatsViewModel.graphDiv;
+ var paths = selectPathsThroughCategoryBandColor(bandViewModel);
+ var points = [];
+ paths.each(function(pathViewModel) {
+ Array.prototype.push.apply(points, buildPointsArrayForPath(pathViewModel));
+ });
+ var constraints = {};
+ constraints[categoryModel.dimensionInd] = categoryModel.categoryValue;
+ if (bandViewModel.rawColor !== void 0) {
+ constraints.color = bandViewModel.rawColor;
+ }
+ gd.emit(eventName, {
+ points,
+ event,
+ constraints
+ });
+ }
+ function createHoverLabelForCategoryHovermode(gd, rootBBox, bandElement) {
+ gd._fullLayout._calcInverseTransform(gd);
+ var scaleX = gd._fullLayout._invScaleX;
+ var scaleY = gd._fullLayout._invScaleY;
+ var rectSelection = d3.select(bandElement.parentNode).select("rect.catrect");
+ var rectBoundingBox = rectSelection.node().getBoundingClientRect();
+ var catViewModel = rectSelection.datum();
+ var parcatsViewModel = catViewModel.parcatsViewModel;
+ var dimensionModel = parcatsViewModel.model.dimensions[catViewModel.model.dimensionInd];
+ var trace = parcatsViewModel.trace;
+ var hoverCenterY = rectBoundingBox.top + rectBoundingBox.height / 2;
+ var hoverCenterX, hoverLabelIdealAlign;
+ if (parcatsViewModel.dimensions.length > 1 && dimensionModel.displayInd === parcatsViewModel.dimensions.length - 1) {
+ hoverCenterX = rectBoundingBox.left;
+ hoverLabelIdealAlign = "left";
+ } else {
+ hoverCenterX = rectBoundingBox.left + rectBoundingBox.width;
+ hoverLabelIdealAlign = "right";
+ }
+ var count = catViewModel.model.count;
+ var catLabel = catViewModel.model.categoryLabel;
+ var prob = count / catViewModel.parcatsViewModel.model.count;
+ var labels = {
+ countLabel: count,
+ categoryLabel: catLabel,
+ probabilityLabel: prob.toFixed(3)
+ };
+ var hoverinfoParts = [];
+ if (catViewModel.parcatsViewModel.hoverinfoItems.indexOf("count") !== -1) {
+ hoverinfoParts.push(["Count:", labels.countLabel].join(" "));
+ }
+ if (catViewModel.parcatsViewModel.hoverinfoItems.indexOf("probability") !== -1) {
+ hoverinfoParts.push(["P(" + labels.categoryLabel + "):", labels.probabilityLabel].join(" "));
+ }
+ var hovertext = hoverinfoParts.join("
");
+ return {
+ trace,
+ x: scaleX * (hoverCenterX - rootBBox.left),
+ y: scaleY * (hoverCenterY - rootBBox.top),
+ text: hovertext,
+ color: "lightgray",
+ borderColor: "black",
+ fontFamily: 'Monaco, "Courier New", monospace',
+ fontSize: 12,
+ fontColor: "black",
+ idealAlign: hoverLabelIdealAlign,
+ hovertemplate: trace.hovertemplate,
+ hovertemplateLabels: labels,
+ eventData: [{
+ data: trace._input,
+ fullData: trace,
+ count,
+ category: catLabel,
+ probability: prob
+ }]
+ };
+ }
+ function createHoverLabelForDimensionHovermode(gd, rootBBox, bandElement) {
+ var allHoverlabels = [];
+ d3.select(bandElement.parentNode.parentNode).selectAll("g.category").select("rect.catrect").each(function() {
+ var bandNode = this;
+ allHoverlabels.push(createHoverLabelForCategoryHovermode(gd, rootBBox, bandNode));
+ });
+ return allHoverlabels;
+ }
+ function createHoverLabelForColorHovermode(gd, rootBBox, bandElement) {
+ gd._fullLayout._calcInverseTransform(gd);
+ var scaleX = gd._fullLayout._invScaleX;
+ var scaleY = gd._fullLayout._invScaleY;
+ var bandBoundingBox = bandElement.getBoundingClientRect();
+ var bandViewModel = d3.select(bandElement).datum();
+ var catViewModel = bandViewModel.categoryViewModel;
+ var parcatsViewModel = catViewModel.parcatsViewModel;
+ var dimensionModel = parcatsViewModel.model.dimensions[catViewModel.model.dimensionInd];
+ var trace = parcatsViewModel.trace;
+ var hoverCenterY = bandBoundingBox.y + bandBoundingBox.height / 2;
+ var hoverCenterX, hoverLabelIdealAlign;
+ if (parcatsViewModel.dimensions.length > 1 && dimensionModel.displayInd === parcatsViewModel.dimensions.length - 1) {
+ hoverCenterX = bandBoundingBox.left;
+ hoverLabelIdealAlign = "left";
+ } else {
+ hoverCenterX = bandBoundingBox.left + bandBoundingBox.width;
+ hoverLabelIdealAlign = "right";
+ }
+ var catLabel = catViewModel.model.categoryLabel;
+ var totalCount = bandViewModel.parcatsViewModel.model.count;
+ var bandColorCount = 0;
+ bandViewModel.categoryViewModel.bands.forEach(function(b) {
+ if (b.color === bandViewModel.color) {
+ bandColorCount += b.count;
+ }
+ });
+ var catCount = catViewModel.model.count;
+ var colorCount = 0;
+ parcatsViewModel.pathSelection.each(
+ /** @param {PathViewModel} pathViewModel */
+ function(pathViewModel) {
+ if (pathViewModel.model.color === bandViewModel.color) {
+ colorCount += pathViewModel.model.count;
+ }
+ }
+ );
+ var pColorAndCat = bandColorCount / totalCount;
+ var pCatGivenColor = bandColorCount / colorCount;
+ var pColorGivenCat = bandColorCount / catCount;
+ var labels = {
+ countLabel: bandColorCount,
+ categoryLabel: catLabel,
+ probabilityLabel: pColorAndCat.toFixed(3)
+ };
+ var hoverinfoParts = [];
+ if (catViewModel.parcatsViewModel.hoverinfoItems.indexOf("count") !== -1) {
+ hoverinfoParts.push(["Count:", labels.countLabel].join(" "));
+ }
+ if (catViewModel.parcatsViewModel.hoverinfoItems.indexOf("probability") !== -1) {
+ hoverinfoParts.push("P(color \u2229 " + catLabel + "): " + labels.probabilityLabel);
+ hoverinfoParts.push("P(" + catLabel + " | color): " + pCatGivenColor.toFixed(3));
+ hoverinfoParts.push("P(color | " + catLabel + "): " + pColorGivenCat.toFixed(3));
+ }
+ var hovertext = hoverinfoParts.join("
");
+ var textColor = tinycolor.mostReadable(bandViewModel.color, ["black", "white"]);
+ return {
+ trace,
+ x: scaleX * (hoverCenterX - rootBBox.left),
+ y: scaleY * (hoverCenterY - rootBBox.top),
+ // name: 'NAME',
+ text: hovertext,
+ color: bandViewModel.color,
+ borderColor: "black",
+ fontFamily: 'Monaco, "Courier New", monospace',
+ fontColor: textColor,
+ fontSize: 10,
+ idealAlign: hoverLabelIdealAlign,
+ hovertemplate: trace.hovertemplate,
+ hovertemplateLabels: labels,
+ eventData: [{
+ data: trace._input,
+ fullData: trace,
+ category: catLabel,
+ count: totalCount,
+ probability: pColorAndCat,
+ categorycount: catCount,
+ colorcount: colorCount,
+ bandcolorcount: bandColorCount
+ }]
+ };
+ }
+ function mouseoverCategoryBand(bandViewModel) {
+ if (!bandViewModel.parcatsViewModel.dragDimension) {
+ if (bandViewModel.parcatsViewModel.hoverinfoItems.indexOf("skip") === -1) {
+ var mouseY = d3.mouse(this)[1];
+ if (mouseY < -1) {
+ return;
+ }
+ var gd = bandViewModel.parcatsViewModel.graphDiv;
+ var fullLayout = gd._fullLayout;
+ var rootBBox = fullLayout._paperdiv.node().getBoundingClientRect();
+ var hoveron = bandViewModel.parcatsViewModel.hoveron;
+ var bandElement = this;
+ if (hoveron === "color") {
+ styleForColorHovermode(bandElement);
+ emitPointsEventColorHovermode(bandElement, "plotly_hover", d3.event);
+ } else {
+ styleForCategoryHovermode(bandElement);
+ emitPointsEventCategoryHovermode(bandElement, "plotly_hover", d3.event);
+ }
+ if (bandViewModel.parcatsViewModel.hoverinfoItems.indexOf("none") === -1) {
+ var hoverItems;
+ if (hoveron === "category") {
+ hoverItems = createHoverLabelForCategoryHovermode(gd, rootBBox, bandElement);
+ } else if (hoveron === "color") {
+ hoverItems = createHoverLabelForColorHovermode(gd, rootBBox, bandElement);
+ } else if (hoveron === "dimension") {
+ hoverItems = createHoverLabelForDimensionHovermode(gd, rootBBox, bandElement);
+ }
+ if (hoverItems) {
+ Fx.loneHover(hoverItems, {
+ container: fullLayout._hoverlayer.node(),
+ outerContainer: fullLayout._paper.node(),
+ gd
+ });
+ }
+ }
+ }
+ }
+ }
+ function mouseoutCategory(bandViewModel) {
+ var parcatsViewModel = bandViewModel.parcatsViewModel;
+ if (!parcatsViewModel.dragDimension) {
+ stylePathsNoHover(parcatsViewModel.pathSelection);
+ styleCategoriesNoHover(parcatsViewModel.dimensionSelection.selectAll("g.category"));
+ styleBandsNoHover(parcatsViewModel.dimensionSelection.selectAll("g.category").selectAll("rect.bandrect"));
+ Fx.loneUnhover(parcatsViewModel.graphDiv._fullLayout._hoverlayer.node());
+ parcatsViewModel.pathSelection.sort(compareRawColor);
+ if (parcatsViewModel.hoverinfoItems.indexOf("skip") === -1) {
+ var hoveron = bandViewModel.parcatsViewModel.hoveron;
+ var bandElement = this;
+ if (hoveron === "color") {
+ emitPointsEventColorHovermode(bandElement, "plotly_unhover", d3.event);
+ } else {
+ emitPointsEventCategoryHovermode(bandElement, "plotly_unhover", d3.event);
+ }
+ }
+ }
+ }
+ function dragDimensionStart(d) {
+ if (d.parcatsViewModel.arrangement === "fixed") {
+ return;
+ }
+ d.dragDimensionDisplayInd = d.model.displayInd;
+ d.initialDragDimensionDisplayInds = d.parcatsViewModel.model.dimensions.map(function(d2) {
+ return d2.displayInd;
+ });
+ d.dragHasMoved = false;
+ d.dragCategoryDisplayInd = null;
+ d3.select(this).selectAll("g.category").select("rect.catrect").each(
+ /** @param {CategoryViewModel} catViewModel */
+ function(catViewModel) {
+ var catMouseX = d3.mouse(this)[0];
+ var catMouseY = d3.mouse(this)[1];
+ if (-2 <= catMouseX && catMouseX <= catViewModel.width + 2 && -2 <= catMouseY && catMouseY <= catViewModel.height + 2) {
+ d.dragCategoryDisplayInd = catViewModel.model.displayInd;
+ d.initialDragCategoryDisplayInds = d.model.categories.map(function(c) {
+ return c.displayInd;
+ });
+ catViewModel.model.dragY = catViewModel.y;
+ Lib.raiseToTop(this.parentNode);
+ d3.select(this.parentNode).selectAll("rect.bandrect").each(function(bandViewModel) {
+ if (bandViewModel.y < catMouseY && catMouseY <= bandViewModel.y + bandViewModel.height) {
+ d.potentialClickBand = this;
+ }
+ });
+ }
+ }
+ );
+ d.parcatsViewModel.dragDimension = d;
+ Fx.loneUnhover(d.parcatsViewModel.graphDiv._fullLayout._hoverlayer.node());
+ }
+ function dragDimension(d) {
+ if (d.parcatsViewModel.arrangement === "fixed") {
+ return;
+ }
+ d.dragHasMoved = true;
+ if (d.dragDimensionDisplayInd === null) {
+ return;
+ }
+ var dragDimInd = d.dragDimensionDisplayInd;
+ var prevDimInd = dragDimInd - 1;
+ var nextDimInd = dragDimInd + 1;
+ var dragDimension2 = d.parcatsViewModel.dimensions[dragDimInd];
+ if (d.dragCategoryDisplayInd !== null) {
+ var dragCategory = dragDimension2.categories[d.dragCategoryDisplayInd];
+ dragCategory.model.dragY += d3.event.dy;
+ var categoryY = dragCategory.model.dragY;
+ var catDisplayInd = dragCategory.model.displayInd;
+ var dimCategoryViews = dragDimension2.categories;
+ var catAbove = dimCategoryViews[catDisplayInd - 1];
+ var catBelow = dimCategoryViews[catDisplayInd + 1];
+ if (catAbove !== void 0) {
+ if (categoryY < catAbove.y + catAbove.height / 2) {
+ dragCategory.model.displayInd = catAbove.model.displayInd;
+ catAbove.model.displayInd = catDisplayInd;
+ }
+ }
+ if (catBelow !== void 0) {
+ if (categoryY + dragCategory.height > catBelow.y + catBelow.height / 2) {
+ dragCategory.model.displayInd = catBelow.model.displayInd;
+ catBelow.model.displayInd = catDisplayInd;
+ }
+ }
+ d.dragCategoryDisplayInd = dragCategory.model.displayInd;
+ }
+ if (d.dragCategoryDisplayInd === null || d.parcatsViewModel.arrangement === "freeform") {
+ dragDimension2.model.dragX = d3.event.x;
+ var prevDimension = d.parcatsViewModel.dimensions[prevDimInd];
+ var nextDimension = d.parcatsViewModel.dimensions[nextDimInd];
+ if (prevDimension !== void 0) {
+ if (dragDimension2.model.dragX < prevDimension.x + prevDimension.width) {
+ dragDimension2.model.displayInd = prevDimension.model.displayInd;
+ prevDimension.model.displayInd = dragDimInd;
+ }
+ }
+ if (nextDimension !== void 0) {
+ if (dragDimension2.model.dragX + dragDimension2.width > nextDimension.x) {
+ dragDimension2.model.displayInd = nextDimension.model.displayInd;
+ nextDimension.model.displayInd = d.dragDimensionDisplayInd;
+ }
+ }
+ d.dragDimensionDisplayInd = dragDimension2.model.displayInd;
+ }
+ updateDimensionViewModels(d.parcatsViewModel);
+ updatePathViewModels(d.parcatsViewModel);
+ updateSvgCategories(d.parcatsViewModel);
+ updateSvgPaths(d.parcatsViewModel);
+ }
+ function dragDimensionEnd(d) {
+ if (d.parcatsViewModel.arrangement === "fixed") {
+ return;
+ }
+ if (d.dragDimensionDisplayInd === null) {
+ return;
+ }
+ d3.select(this).selectAll("text").attr("font-weight", "normal");
+ var restyleData = {};
+ var traceInd = getTraceIndex(d.parcatsViewModel);
+ var finalDragDimensionDisplayInds = d.parcatsViewModel.model.dimensions.map(function(d2) {
+ return d2.displayInd;
+ });
+ var anyDimsReordered = d.initialDragDimensionDisplayInds.some(function(initDimDisplay, dimInd) {
+ return initDimDisplay !== finalDragDimensionDisplayInds[dimInd];
+ });
+ if (anyDimsReordered) {
+ finalDragDimensionDisplayInds.forEach(function(finalDimDisplay, dimInd) {
+ var containerInd = d.parcatsViewModel.model.dimensions[dimInd].containerInd;
+ restyleData["dimensions[" + containerInd + "].displayindex"] = finalDimDisplay;
+ });
+ }
+ var anyCatsReordered = false;
+ if (d.dragCategoryDisplayInd !== null) {
+ var finalDragCategoryDisplayInds = d.model.categories.map(function(c) {
+ return c.displayInd;
+ });
+ anyCatsReordered = d.initialDragCategoryDisplayInds.some(function(initCatDisplay, catInd) {
+ return initCatDisplay !== finalDragCategoryDisplayInds[catInd];
+ });
+ if (anyCatsReordered) {
+ var sortedCategoryModels = d.model.categories.slice().sort(
+ function(a, b) {
+ return a.displayInd - b.displayInd;
+ }
+ );
+ var newCategoryArray = sortedCategoryModels.map(function(v) {
+ return v.categoryValue;
+ });
+ var newCategoryLabels = sortedCategoryModels.map(function(v) {
+ return v.categoryLabel;
+ });
+ restyleData["dimensions[" + d.model.containerInd + "].categoryarray"] = [newCategoryArray];
+ restyleData["dimensions[" + d.model.containerInd + "].ticktext"] = [newCategoryLabels];
+ restyleData["dimensions[" + d.model.containerInd + "].categoryorder"] = "array";
+ }
+ }
+ if (d.parcatsViewModel.hoverinfoItems.indexOf("skip") === -1) {
+ if (!d.dragHasMoved && d.potentialClickBand) {
+ if (d.parcatsViewModel.hoveron === "color") {
+ emitPointsEventColorHovermode(d.potentialClickBand, "plotly_click", d3.event.sourceEvent);
+ } else {
+ emitPointsEventCategoryHovermode(d.potentialClickBand, "plotly_click", d3.event.sourceEvent);
+ }
+ }
+ }
+ d.model.dragX = null;
+ if (d.dragCategoryDisplayInd !== null) {
+ var dragCategory = d.parcatsViewModel.dimensions[d.dragDimensionDisplayInd].categories[d.dragCategoryDisplayInd];
+ dragCategory.model.dragY = null;
+ d.dragCategoryDisplayInd = null;
+ }
+ d.dragDimensionDisplayInd = null;
+ d.parcatsViewModel.dragDimension = null;
+ d.dragHasMoved = null;
+ d.potentialClickBand = null;
+ updateDimensionViewModels(d.parcatsViewModel);
+ updatePathViewModels(d.parcatsViewModel);
+ var transition = d3.transition().duration(300).ease("cubic-in-out");
+ transition.each(function() {
+ updateSvgCategories(d.parcatsViewModel, true);
+ updateSvgPaths(d.parcatsViewModel, true);
+ }).each("end", function() {
+ if (anyDimsReordered || anyCatsReordered) {
+ Plotly.restyle(d.parcatsViewModel.graphDiv, restyleData, [traceInd]);
+ }
+ });
+ }
+ function getTraceIndex(parcatsViewModel) {
+ var traceInd;
+ var allTraces = parcatsViewModel.graphDiv._fullData;
+ for (var i = 0; i < allTraces.length; i++) {
+ if (parcatsViewModel.key === allTraces[i].uid) {
+ traceInd = i;
+ break;
+ }
+ }
+ return traceInd;
+ }
+ function updateSvgPaths(parcatsViewModel, hasTransition) {
+ if (hasTransition === void 0) {
+ hasTransition = false;
+ }
+ function transition(selection) {
+ return hasTransition ? selection.transition() : selection;
+ }
+ parcatsViewModel.pathSelection.data(function(d) {
+ return d.paths;
+ }, key);
+ transition(parcatsViewModel.pathSelection).attr("d", function(d) {
+ return d.svgD;
+ });
+ }
+ function updateSvgCategories(parcatsViewModel, hasTransition) {
+ if (hasTransition === void 0) {
+ hasTransition = false;
+ }
+ function transition(selection) {
+ return hasTransition ? selection.transition() : selection;
+ }
+ parcatsViewModel.dimensionSelection.data(function(d) {
+ return d.dimensions;
+ }, key);
+ var categorySelection = parcatsViewModel.dimensionSelection.selectAll("g.category").data(function(d) {
+ return d.categories;
+ }, key);
+ transition(parcatsViewModel.dimensionSelection).attr("transform", function(d) {
+ return strTranslate(d.x, 0);
+ });
+ transition(categorySelection).attr("transform", function(d) {
+ return strTranslate(0, d.y);
+ });
+ var dimLabelSelection = categorySelection.select(".dimlabel");
+ dimLabelSelection.text(function(d, i) {
+ if (i === 0) {
+ return d.parcatsViewModel.model.dimensions[d.model.dimensionInd].dimensionLabel;
+ } else {
+ return null;
+ }
+ });
+ var catLabelSelection = categorySelection.select(".catlabel");
+ catLabelSelection.attr(
+ "text-anchor",
+ function(d) {
+ if (catInRightDim(d)) {
+ return "start";
+ } else {
+ return "end";
+ }
+ }
+ ).attr(
+ "x",
+ function(d) {
+ if (catInRightDim(d)) {
+ return d.width + 5;
+ } else {
+ return -5;
+ }
+ }
+ ).each(function(d) {
+ var newX;
+ var newAnchor;
+ if (catInRightDim(d)) {
+ newX = d.width + 5;
+ newAnchor = "start";
+ } else {
+ newX = -5;
+ newAnchor = "end";
+ }
+ d3.select(this).selectAll("tspan").attr("x", newX).attr("text-anchor", newAnchor);
+ });
+ var bandSelection = categorySelection.selectAll("rect.bandrect").data(
+ /** @param {CategoryViewModel} catViewModel*/
+ function(catViewModel) {
+ return catViewModel.bands;
+ },
+ key
+ );
+ var bandsSelectionEnter = bandSelection.enter().append("rect").attr("class", "bandrect").attr("cursor", "move").attr("stroke-opacity", 0).attr("fill", function(d) {
+ return d.color;
+ }).attr("fill-opacity", 0);
+ bandSelection.attr("fill", function(d) {
+ return d.color;
+ }).attr("width", function(d) {
+ return d.width;
+ }).attr("height", function(d) {
+ return d.height;
+ }).attr("y", function(d) {
+ return d.y;
+ });
+ styleBandsNoHover(bandsSelectionEnter);
+ bandSelection.each(function() {
+ Lib.raiseToTop(this);
+ });
+ bandSelection.exit().remove();
+ }
+ function createParcatsViewModel(graphDiv, layout, wrappedParcatsModel) {
+ var parcatsModel = wrappedParcatsModel[0];
+ var margin = layout.margin || { l: 80, r: 80, t: 100, b: 80 };
+ var trace = parcatsModel.trace;
+ var domain = trace.domain;
+ var figureWidth = layout.width;
+ var figureHeight = layout.height;
+ var traceWidth = Math.floor(figureWidth * (domain.x[1] - domain.x[0]));
+ var traceHeight = Math.floor(figureHeight * (domain.y[1] - domain.y[0]));
+ var traceX = domain.x[0] * figureWidth + margin.l;
+ var traceY = layout.height - domain.y[1] * layout.height + margin.t;
+ var pathShape = trace.line.shape;
+ var hoverinfoItems;
+ if (trace.hoverinfo === "all") {
+ hoverinfoItems = ["count", "probability"];
+ } else {
+ hoverinfoItems = (trace.hoverinfo || "").split("+");
+ }
+ var parcatsViewModel = {
+ trace,
+ key: trace.uid,
+ model: parcatsModel,
+ x: traceX,
+ y: traceY,
+ width: traceWidth,
+ height: traceHeight,
+ hoveron: trace.hoveron,
+ hoverinfoItems,
+ arrangement: trace.arrangement,
+ bundlecolors: trace.bundlecolors,
+ sortpaths: trace.sortpaths,
+ labelfont: trace.labelfont,
+ categorylabelfont: trace.tickfont,
+ pathShape,
+ dragDimension: null,
+ margin,
+ paths: [],
+ dimensions: [],
+ graphDiv,
+ traceSelection: null,
+ pathSelection: null,
+ dimensionSelection: null
+ };
+ if (parcatsModel.dimensions) {
+ updateDimensionViewModels(parcatsViewModel);
+ updatePathViewModels(parcatsViewModel);
+ }
+ return parcatsViewModel;
+ }
+ function buildSvgPath(leftXPositions, pathYs, dimWidths, pathHeight, curvature) {
+ var xRefPoints1 = [];
+ var xRefPoints2 = [];
+ var refInterpolator;
+ var d;
+ for (d = 0; d < dimWidths.length - 1; d++) {
+ refInterpolator = interpolateNumber(dimWidths[d] + leftXPositions[d], leftXPositions[d + 1]);
+ xRefPoints1.push(refInterpolator(curvature));
+ xRefPoints2.push(refInterpolator(1 - curvature));
+ }
+ var svgD = "M " + leftXPositions[0] + "," + pathYs[0];
+ svgD += "l" + dimWidths[0] + ",0 ";
+ for (d = 1; d < dimWidths.length; d++) {
+ svgD += "C" + xRefPoints1[d - 1] + "," + pathYs[d - 1] + " " + xRefPoints2[d - 1] + "," + pathYs[d] + " " + leftXPositions[d] + "," + pathYs[d];
+ svgD += "l" + dimWidths[d] + ",0 ";
+ }
+ svgD += "l0," + pathHeight + " ";
+ svgD += "l -" + dimWidths[dimWidths.length - 1] + ",0 ";
+ for (d = dimWidths.length - 2; d >= 0; d--) {
+ svgD += "C" + xRefPoints2[d] + "," + (pathYs[d + 1] + pathHeight) + " " + xRefPoints1[d] + "," + (pathYs[d] + pathHeight) + " " + (leftXPositions[d] + dimWidths[d]) + "," + (pathYs[d] + pathHeight);
+ svgD += "l-" + dimWidths[d] + ",0 ";
+ }
+ svgD += "Z";
+ return svgD;
+ }
+ function updatePathViewModels(parcatsViewModel) {
+ var dimensionViewModels = parcatsViewModel.dimensions;
+ var parcatsModel = parcatsViewModel.model;
+ var nextYPositions = dimensionViewModels.map(
+ function(d2) {
+ return d2.categories.map(
+ function(c) {
+ return c.y;
+ }
+ );
+ }
+ );
+ var catToDisplayIndPerDim = parcatsViewModel.model.dimensions.map(
+ function(d2) {
+ return d2.categories.map(function(c) {
+ return c.displayInd;
+ });
+ }
+ );
+ var dimToDisplayInd = parcatsViewModel.model.dimensions.map(function(d2) {
+ return d2.displayInd;
+ });
+ var displayToDimInd = parcatsViewModel.dimensions.map(function(d2) {
+ return d2.model.dimensionInd;
+ });
+ var leftXPositions = dimensionViewModels.map(
+ function(d2) {
+ return d2.x;
+ }
+ );
+ var dimWidths = dimensionViewModels.map(function(d2) {
+ return d2.width;
+ });
+ var pathModels = [];
+ for (var p in parcatsModel.paths) {
+ if (parcatsModel.paths.hasOwnProperty(p)) {
+ pathModels.push(parcatsModel.paths[p]);
+ }
+ }
+ function pathDisplayCategoryInds(pathModel2) {
+ var dimensionInds = pathModel2.categoryInds.map(function(catInd2, dimInd) {
+ return catToDisplayIndPerDim[dimInd][catInd2];
+ });
+ var displayInds = displayToDimInd.map(function(dimInd) {
+ return dimensionInds[dimInd];
+ });
+ return displayInds;
+ }
+ pathModels.sort(function(v1, v2) {
+ var sortArray1 = pathDisplayCategoryInds(v1);
+ var sortArray2 = pathDisplayCategoryInds(v2);
+ if (parcatsViewModel.sortpaths === "backward") {
+ sortArray1.reverse();
+ sortArray2.reverse();
+ }
+ sortArray1.push(v1.valueInds[0]);
+ sortArray2.push(v2.valueInds[0]);
+ if (parcatsViewModel.bundlecolors) {
+ sortArray1.unshift(v1.rawColor);
+ sortArray2.unshift(v2.rawColor);
+ }
+ if (sortArray1 < sortArray2) {
+ return -1;
+ }
+ if (sortArray1 > sortArray2) {
+ return 1;
+ }
+ return 0;
+ });
+ var pathViewModels = new Array(pathModels.length);
+ var totalCount = dimensionViewModels[0].model.count;
+ var totalHeight = dimensionViewModels[0].categories.map(function(c) {
+ return c.height;
+ }).reduce(function(v1, v2) {
+ return v1 + v2;
+ });
+ for (var pathNumber = 0; pathNumber < pathModels.length; pathNumber++) {
+ var pathModel = pathModels[pathNumber];
+ var pathHeight;
+ if (totalCount > 0) {
+ pathHeight = totalHeight * (pathModel.count / totalCount);
+ } else {
+ pathHeight = 0;
+ }
+ var pathYs = new Array(nextYPositions.length);
+ for (var d = 0; d < pathModel.categoryInds.length; d++) {
+ var catInd = pathModel.categoryInds[d];
+ var catDisplayInd = catToDisplayIndPerDim[d][catInd];
+ var dimDisplayInd = dimToDisplayInd[d];
+ pathYs[dimDisplayInd] = nextYPositions[dimDisplayInd][catDisplayInd];
+ nextYPositions[dimDisplayInd][catDisplayInd] += pathHeight;
+ var catViewModle = parcatsViewModel.dimensions[dimDisplayInd].categories[catDisplayInd];
+ var numBands = catViewModle.bands.length;
+ var lastCatBand = catViewModle.bands[numBands - 1];
+ if (lastCatBand === void 0 || pathModel.rawColor !== lastCatBand.rawColor) {
+ var bandY = lastCatBand === void 0 ? 0 : lastCatBand.y + lastCatBand.height;
+ catViewModle.bands.push({
+ key: bandY,
+ color: pathModel.color,
+ rawColor: pathModel.rawColor,
+ height: pathHeight,
+ width: catViewModle.width,
+ count: pathModel.count,
+ y: bandY,
+ categoryViewModel: catViewModle,
+ parcatsViewModel
+ });
+ } else {
+ var currentBand = catViewModle.bands[numBands - 1];
+ currentBand.height += pathHeight;
+ currentBand.count += pathModel.count;
+ }
+ }
+ var svgD;
+ if (parcatsViewModel.pathShape === "hspline") {
+ svgD = buildSvgPath(leftXPositions, pathYs, dimWidths, pathHeight, 0.5);
+ } else {
+ svgD = buildSvgPath(leftXPositions, pathYs, dimWidths, pathHeight, 0);
+ }
+ pathViewModels[pathNumber] = {
+ key: pathModel.valueInds[0],
+ model: pathModel,
+ height: pathHeight,
+ leftXs: leftXPositions,
+ topYs: pathYs,
+ dimWidths,
+ svgD,
+ parcatsViewModel
+ };
+ }
+ parcatsViewModel.paths = pathViewModels;
+ }
+ function updateDimensionViewModels(parcatsViewModel) {
+ var dimensionsIndInfo = parcatsViewModel.model.dimensions.map(function(d) {
+ return { displayInd: d.displayInd, dimensionInd: d.dimensionInd };
+ });
+ dimensionsIndInfo.sort(function(a, b) {
+ return a.displayInd - b.displayInd;
+ });
+ var dimensions = [];
+ for (var displayInd in dimensionsIndInfo) {
+ var dimensionInd = dimensionsIndInfo[displayInd].dimensionInd;
+ var dimModel = parcatsViewModel.model.dimensions[dimensionInd];
+ dimensions.push(createDimensionViewModel(parcatsViewModel, dimModel));
+ }
+ parcatsViewModel.dimensions = dimensions;
+ }
+ function createDimensionViewModel(parcatsViewModel, dimensionModel) {
+ var categoryLabelPad = 40;
+ var dimWidth = 16;
+ var numDimensions = parcatsViewModel.model.dimensions.length;
+ var displayInd = dimensionModel.displayInd;
+ var dimDx;
+ var dimX0;
+ var dimX;
+ if (numDimensions > 1) {
+ dimDx = (parcatsViewModel.width - 2 * categoryLabelPad - dimWidth) / (numDimensions - 1);
+ } else {
+ dimDx = 0;
+ }
+ dimX0 = categoryLabelPad;
+ dimX = dimX0 + dimDx * displayInd;
+ var categories = [];
+ var maxCats = parcatsViewModel.model.maxCats;
+ var numCats = dimensionModel.categories.length;
+ var catSpacing = 8;
+ var totalCount = dimensionModel.count;
+ var totalHeight = parcatsViewModel.height - catSpacing * (maxCats - 1);
+ var nextCatHeight;
+ var nextCatModel;
+ var nextCat;
+ var catInd;
+ var catDisplayInd;
+ var nextCatY = (maxCats - numCats) * catSpacing / 2;
+ var categoryIndInfo = dimensionModel.categories.map(function(c) {
+ return { displayInd: c.displayInd, categoryInd: c.categoryInd };
+ });
+ categoryIndInfo.sort(function(a, b) {
+ return a.displayInd - b.displayInd;
+ });
+ for (catDisplayInd = 0; catDisplayInd < numCats; catDisplayInd++) {
+ catInd = categoryIndInfo[catDisplayInd].categoryInd;
+ nextCatModel = dimensionModel.categories[catInd];
+ if (totalCount > 0) {
+ nextCatHeight = nextCatModel.count / totalCount * totalHeight;
+ } else {
+ nextCatHeight = 0;
+ }
+ nextCat = {
+ key: nextCatModel.valueInds[0],
+ model: nextCatModel,
+ width: dimWidth,
+ height: nextCatHeight,
+ y: nextCatModel.dragY !== null ? nextCatModel.dragY : nextCatY,
+ bands: [],
+ parcatsViewModel
+ };
+ nextCatY = nextCatY + nextCatHeight + catSpacing;
+ categories.push(nextCat);
+ }
+ return {
+ key: dimensionModel.dimensionInd,
+ x: dimensionModel.dragX !== null ? dimensionModel.dragX : dimX,
+ y: 0,
+ width: dimWidth,
+ model: dimensionModel,
+ categories,
+ parcatsViewModel,
+ dragCategoryDisplayInd: null,
+ dragDimensionDisplayInd: null,
+ initialDragDimensionDisplayInds: null,
+ initialDragCategoryDisplayInds: null,
+ dragHasMoved: null,
+ potentialClickBand: null
+ };
+ }
+ }
+ });
+
+ // src/traces/parcats/plot.js
+ var require_plot22 = __commonJS({
+ "src/traces/parcats/plot.js"(exports, module) {
+ "use strict";
+ var parcats = require_parcats();
+ module.exports = function plot(graphDiv, parcatsModels, transitionOpts, makeOnCompleteCallback) {
+ var fullLayout = graphDiv._fullLayout;
+ var svg = fullLayout._paper;
+ var size = fullLayout._size;
+ parcats(
+ graphDiv,
+ svg,
+ parcatsModels,
+ {
+ width: size.w,
+ height: size.h,
+ margin: {
+ t: size.t,
+ r: size.r,
+ b: size.b,
+ l: size.l
+ }
+ },
+ transitionOpts,
+ makeOnCompleteCallback
+ );
+ };
+ }
+ });
+
+ // src/traces/parcats/base_plot.js
+ var require_base_plot8 = __commonJS({
+ "src/traces/parcats/base_plot.js"(exports) {
+ "use strict";
+ var getModuleCalcData = require_get_data().getModuleCalcData;
+ var parcatsPlot = require_plot22();
+ var PARCATS = "parcats";
+ exports.name = PARCATS;
+ exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
+ var cdModuleAndOthers = getModuleCalcData(gd.calcdata, PARCATS);
+ if (cdModuleAndOthers.length) {
+ var calcData = cdModuleAndOthers[0];
+ parcatsPlot(gd, calcData, transitionOpts, makeOnCompleteCallback);
+ }
+ };
+ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
+ var hadTable = oldFullLayout._has && oldFullLayout._has("parcats");
+ var hasTable = newFullLayout._has && newFullLayout._has("parcats");
+ if (hadTable && !hasTable) {
+ oldFullLayout._paperdiv.selectAll(".parcats").remove();
+ }
+ };
+ }
+ });
+
+ // src/traces/parcats/index.js
+ var require_parcats2 = __commonJS({
+ "src/traces/parcats/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes53(),
+ supplyDefaults: require_defaults49(),
+ calc: require_calc32(),
+ plot: require_plot22(),
+ colorbar: {
+ container: "line",
+ min: "cmin",
+ max: "cmax"
+ },
+ moduleType: "trace",
+ name: "parcats",
+ basePlotModule: require_base_plot8(),
+ categories: ["noOpacity"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/parcats.js
+ var require_parcats3 = __commonJS({
+ "lib/parcats.js"(exports, module) {
+ "use strict";
+ module.exports = require_parcats2();
+ }
+ });
+
+ // src/plots/mapbox/constants.js
+ var require_constants25 = __commonJS({
+ "src/plots/mapbox/constants.js"(exports, module) {
+ "use strict";
+ var sortObjectKeys = require_sort_object_keys();
+ var requiredVersion = "1.13.4";
+ var OSM = '\xA9 OpenStreetMap contributors';
+ var carto = [
+ '\xA9 Carto',
+ OSM
+ ].join(" ");
+ var stamenTerrainOrToner = [
+ 'Map tiles by Stamen Design',
+ 'under CC BY 3.0',
+ "|",
+ 'Data by OpenStreetMap contributors',
+ 'under ODbL'
+ ].join(" ");
+ var stamenWaterColor = [
+ 'Map tiles by Stamen Design',
+ 'under CC BY 3.0',
+ "|",
+ 'Data by OpenStreetMap contributors',
+ 'under CC BY SA'
+ ].join(" ");
+ var stylesNonMapbox = {
+ "open-street-map": {
+ id: "osm",
+ version: 8,
+ sources: {
+ "plotly-osm-tiles": {
+ type: "raster",
+ attribution: OSM,
+ tiles: [
+ "https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",
+ "https://b.tile.openstreetmap.org/{z}/{x}/{y}.png"
+ ],
+ tileSize: 256
+ }
+ },
+ layers: [{
+ id: "plotly-osm-tiles",
+ type: "raster",
+ source: "plotly-osm-tiles",
+ minzoom: 0,
+ maxzoom: 22
+ }],
+ glyphs: "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
+ },
+ "white-bg": {
+ id: "white-bg",
+ version: 8,
+ sources: {},
+ layers: [{
+ id: "white-bg",
+ type: "background",
+ paint: { "background-color": "#FFFFFF" },
+ minzoom: 0,
+ maxzoom: 22
+ }],
+ glyphs: "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
+ },
+ "carto-positron": {
+ id: "carto-positron",
+ version: 8,
+ sources: {
+ "plotly-carto-positron": {
+ type: "raster",
+ attribution: carto,
+ tiles: ["https://cartodb-basemaps-c.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png"],
+ tileSize: 256
+ }
+ },
+ layers: [{
+ id: "plotly-carto-positron",
+ type: "raster",
+ source: "plotly-carto-positron",
+ minzoom: 0,
+ maxzoom: 22
+ }],
+ glyphs: "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
+ },
+ "carto-darkmatter": {
+ id: "carto-darkmatter",
+ version: 8,
+ sources: {
+ "plotly-carto-darkmatter": {
+ type: "raster",
+ attribution: carto,
+ tiles: ["https://cartodb-basemaps-c.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png"],
+ tileSize: 256
+ }
+ },
+ layers: [{
+ id: "plotly-carto-darkmatter",
+ type: "raster",
+ source: "plotly-carto-darkmatter",
+ minzoom: 0,
+ maxzoom: 22
+ }],
+ glyphs: "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
+ },
+ "stamen-terrain": {
+ id: "stamen-terrain",
+ version: 8,
+ sources: {
+ "plotly-stamen-terrain": {
+ type: "raster",
+ attribution: stamenTerrainOrToner,
+ tiles: ["https://tiles.stadiamaps.com/tiles/stamen_terrain/{z}/{x}/{y}.png?api_key="],
+ tileSize: 256
+ }
+ },
+ layers: [{
+ id: "plotly-stamen-terrain",
+ type: "raster",
+ source: "plotly-stamen-terrain",
+ minzoom: 0,
+ maxzoom: 22
+ }],
+ glyphs: "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
+ },
+ "stamen-toner": {
+ id: "stamen-toner",
+ version: 8,
+ sources: {
+ "plotly-stamen-toner": {
+ type: "raster",
+ attribution: stamenTerrainOrToner,
+ tiles: ["https://tiles.stadiamaps.com/tiles/stamen_toner/{z}/{x}/{y}.png?api_key="],
+ tileSize: 256
+ }
+ },
+ layers: [{
+ id: "plotly-stamen-toner",
+ type: "raster",
+ source: "plotly-stamen-toner",
+ minzoom: 0,
+ maxzoom: 22
+ }],
+ glyphs: "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
+ },
+ "stamen-watercolor": {
+ id: "stamen-watercolor",
+ version: 8,
+ sources: {
+ "plotly-stamen-watercolor": {
+ type: "raster",
+ attribution: stamenWaterColor,
+ tiles: ["https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg?api_key="],
+ tileSize: 256
+ }
+ },
+ layers: [{
+ id: "plotly-stamen-watercolor",
+ type: "raster",
+ source: "plotly-stamen-watercolor",
+ minzoom: 0,
+ maxzoom: 22
+ }],
+ glyphs: "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
+ }
+ };
+ var styleValuesNonMapbox = sortObjectKeys(stylesNonMapbox);
+ module.exports = {
+ requiredVersion,
+ styleUrlPrefix: "mapbox://styles/mapbox/",
+ styleUrlSuffix: "v9",
+ styleValuesMapbox: ["basic", "streets", "outdoors", "light", "dark", "satellite", "satellite-streets"],
+ styleValueDflt: "basic",
+ stylesNonMapbox,
+ styleValuesNonMapbox,
+ traceLayerPrefix: "plotly-trace-layer-",
+ layoutLayerPrefix: "plotly-layout-layer-",
+ wrongVersionErrorMsg: [
+ "Your custom plotly.js bundle is not using the correct mapbox-gl version",
+ "Please install @plotly/mapbox-gl@" + requiredVersion + "."
+ ].join("\n"),
+ noAccessTokenErrorMsg: [
+ "Missing Mapbox access token.",
+ "Mapbox trace type require a Mapbox access token to be registered.",
+ "For example:",
+ " Plotly.newPlot(gd, data, layout, { mapboxAccessToken: 'my-access-token' });",
+ "More info here: https://www.mapbox.com/help/define-access-token/"
+ ].join("\n"),
+ missingStyleErrorMsg: [
+ "No valid mapbox style found, please set `mapbox.style` to one of:",
+ styleValuesNonMapbox.join(", "),
+ "or register a Mapbox access token to use a Mapbox-served style."
+ ].join("\n"),
+ multipleTokensErrorMsg: [
+ "Set multiple mapbox access token across different mapbox subplot,",
+ "using first token found as mapbox-gl does not allow multipleaccess tokens on the same page."
+ ].join("\n"),
+ mapOnErrorMsg: "Mapbox error.",
+ // Mapbox logo for static export
+ mapboxLogo: {
+ path0: "m 10.5,1.24 c -5.11,0 -9.25,4.15 -9.25,9.25 0,5.1 4.15,9.25 9.25,9.25 5.1,0 9.25,-4.15 9.25,-9.25 0,-5.11 -4.14,-9.25 -9.25,-9.25 z m 4.39,11.53 c -1.93,1.93 -4.78,2.31 -6.7,2.31 -0.7,0 -1.41,-0.05 -2.1,-0.16 0,0 -1.02,-5.64 2.14,-8.81 0.83,-0.83 1.95,-1.28 3.13,-1.28 1.27,0 2.49,0.51 3.39,1.42 1.84,1.84 1.89,4.75 0.14,6.52 z",
+ path1: "M 10.5,-0.01 C 4.7,-0.01 0,4.7 0,10.49 c 0,5.79 4.7,10.5 10.5,10.5 5.8,0 10.5,-4.7 10.5,-10.5 C 20.99,4.7 16.3,-0.01 10.5,-0.01 Z m 0,19.75 c -5.11,0 -9.25,-4.15 -9.25,-9.25 0,-5.1 4.14,-9.26 9.25,-9.26 5.11,0 9.25,4.15 9.25,9.25 0,5.13 -4.14,9.26 -9.25,9.26 z",
+ path2: "M 14.74,6.25 C 12.9,4.41 9.98,4.35 8.23,6.1 5.07,9.27 6.09,14.91 6.09,14.91 c 0,0 5.64,1.02 8.81,-2.14 C 16.64,11 16.59,8.09 14.74,6.25 Z m -2.27,4.09 -0.91,1.87 -0.9,-1.87 -1.86,-0.91 1.86,-0.9 0.9,-1.87 0.91,1.87 1.86,0.9 z",
+ polygon: "11.56,12.21 10.66,10.34 8.8,9.43 10.66,8.53 11.56,6.66 12.47,8.53 14.33,9.43 12.47,10.34"
+ },
+ // a subset of node_modules/mapbox-gl/dist/mapbox-gl.css
+ styleRules: {
+ map: "overflow:hidden;position:relative;",
+ "missing-css": "display:none;",
+ canary: "background-color:salmon;",
+ // Reusing CSS directives from: https://api.tiles.mapbox.com/mapbox-gl-js/v1.1.1/mapbox-gl.css
+ "ctrl-bottom-left": "position: absolute; pointer-events: none; z-index: 2; bottom: 0; left: 0;",
+ "ctrl-bottom-right": "position: absolute; pointer-events: none; z-index: 2; right: 0; bottom: 0;",
+ ctrl: "clear: both; pointer-events: auto; transform: translate(0, 0);",
+ // Compact ctrl
+ "ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner": "display: none;",
+ "ctrl-attrib.mapboxgl-compact:hover .mapboxgl-ctrl-attrib-inner": "display: block; margin-top:2px",
+ "ctrl-attrib.mapboxgl-compact:hover": "padding: 2px 24px 2px 4px; visibility: visible; margin-top: 6px;",
+ "ctrl-attrib.mapboxgl-compact::after": `content: ""; cursor: pointer; position: absolute; background-image: url('data:image/svg+xml;charset=utf-8,%3Csvg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"%3E %3Cpath fill="%23333333" fill-rule="evenodd" d="M4,10a6,6 0 1,0 12,0a6,6 0 1,0 -12,0 M9,7a1,1 0 1,0 2,0a1,1 0 1,0 -2,0 M9,10a1,1 0 1,1 2,0l0,3a1,1 0 1,1 -2,0"/%3E %3C/svg%3E'); background-color: rgba(255, 255, 255, 0.5); width: 24px; height: 24px; box-sizing: border-box; border-radius: 12px;`,
+ "ctrl-attrib.mapboxgl-compact": "min-height: 20px; padding: 0; margin: 10px; position: relative; background-color: #fff; border-radius: 3px 12px 12px 3px;",
+ "ctrl-bottom-right > .mapboxgl-ctrl-attrib.mapboxgl-compact::after": "bottom: 0; right: 0",
+ "ctrl-bottom-left > .mapboxgl-ctrl-attrib.mapboxgl-compact::after": "bottom: 0; left: 0",
+ "ctrl-bottom-left .mapboxgl-ctrl": "margin: 0 0 10px 10px; float: left;",
+ "ctrl-bottom-right .mapboxgl-ctrl": "margin: 0 10px 10px 0; float: right;",
+ "ctrl-attrib": "color: rgba(0, 0, 0, 0.75); text-decoration: none; font-size: 12px",
+ "ctrl-attrib a": "color: rgba(0, 0, 0, 0.75); text-decoration: none; font-size: 12px",
+ "ctrl-attrib a:hover": "color: inherit; text-decoration: underline;",
+ "ctrl-attrib .mapbox-improve-map": "font-weight: bold; margin-left: 2px;",
+ "attrib-empty": "display: none;",
+ // Compact Mapbox logo without text
+ "ctrl-logo": `display:block; width: 21px; height: 21px; background-image: url('data:image/svg+xml;charset=utf-8,%3C?xml version="1.0" encoding="utf-8"?%3E %3Csvg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 21 21" style="enable-background:new 0 0 21 21;" xml:space="preserve"%3E%3Cg transform="translate(0,0.01)"%3E%3Cpath d="m 10.5,1.24 c -5.11,0 -9.25,4.15 -9.25,9.25 0,5.1 4.15,9.25 9.25,9.25 5.1,0 9.25,-4.15 9.25,-9.25 0,-5.11 -4.14,-9.25 -9.25,-9.25 z m 4.39,11.53 c -1.93,1.93 -4.78,2.31 -6.7,2.31 -0.7,0 -1.41,-0.05 -2.1,-0.16 0,0 -1.02,-5.64 2.14,-8.81 0.83,-0.83 1.95,-1.28 3.13,-1.28 1.27,0 2.49,0.51 3.39,1.42 1.84,1.84 1.89,4.75 0.14,6.52 z" style="opacity:0.9;fill:%23ffffff;enable-background:new" class="st0"/%3E%3Cpath d="M 10.5,-0.01 C 4.7,-0.01 0,4.7 0,10.49 c 0,5.79 4.7,10.5 10.5,10.5 5.8,0 10.5,-4.7 10.5,-10.5 C 20.99,4.7 16.3,-0.01 10.5,-0.01 Z m 0,19.75 c -5.11,0 -9.25,-4.15 -9.25,-9.25 0,-5.1 4.14,-9.26 9.25,-9.26 5.11,0 9.25,4.15 9.25,9.25 0,5.13 -4.14,9.26 -9.25,9.26 z" style="opacity:0.35;enable-background:new" class="st1"/%3E%3Cpath d="M 14.74,6.25 C 12.9,4.41 9.98,4.35 8.23,6.1 5.07,9.27 6.09,14.91 6.09,14.91 c 0,0 5.64,1.02 8.81,-2.14 C 16.64,11 16.59,8.09 14.74,6.25 Z m -2.27,4.09 -0.91,1.87 -0.9,-1.87 -1.86,-0.91 1.86,-0.9 0.9,-1.87 0.91,1.87 1.86,0.9 z" style="opacity:0.35;enable-background:new" class="st1"/%3E%3Cpolygon points="11.56,12.21 10.66,10.34 8.8,9.43 10.66,8.53 11.56,6.66 12.47,8.53 14.33,9.43 12.47,10.34 " style="opacity:0.9;fill:%23ffffff;enable-background:new" class="st0"/%3E%3C/g%3E%3C/svg%3E')`
+ // Mapbox logo WITH text below (commented out for now)
+ // 'ctrl-logo': 'width: 85px; height: 21px; margin: 0 0 -3px -3px; display: block; background-repeat: no-repeat; cursor: pointer; background-image: url(\'data:image/svg+xml;charset=utf-8,%3C?xml version="1.0" encoding="utf-8"?%3E%3Csvg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 84.49 21" style="enable-background:new 0 0 84.49 21;" xml:space="preserve"%3E%3Cg%3E %3Cpath class="st0" style="opacity:0.9; fill: %23FFFFFF; enable-background: new;" d="M83.25,14.26c0,0.12-0.09,0.21-0.21,0.21h-1.61c-0.13,0-0.24-0.06-0.3-0.17l-1.44-2.39l-1.44,2.39 c-0.06,0.11-0.18,0.17-0.3,0.17h-1.61c-0.04,0-0.08-0.01-0.12-0.03c-0.09-0.06-0.13-0.19-0.06-0.28l0,0l2.43-3.68L76.2,6.84 c-0.02-0.03-0.03-0.07-0.03-0.12c0-0.12,0.09-0.21,0.21-0.21h1.61c0.13,0,0.24,0.06,0.3,0.17l1.41,2.36l1.4-2.35 c0.06-0.11,0.18-0.17,0.3-0.17H83c0.04,0,0.08,0.01,0.12,0.03c0.09,0.06,0.13,0.19,0.06,0.28l0,0l-2.37,3.63l2.43,3.67 C83.24,14.18,83.25,14.22,83.25,14.26z"/%3E %3Cpath class="st0" style="opacity:0.9; fill: %23FFFFFF; enable-background: new;" d="M66.24,9.59c-0.39-1.88-1.96-3.28-3.84-3.28c-1.03,0-2.03,0.42-2.73,1.18V3.51c0-0.13-0.1-0.23-0.23-0.23h-1.4 c-0.13,0-0.23,0.11-0.23,0.23v10.72c0,0.13,0.1,0.23,0.23,0.23h1.4c0.13,0,0.23-0.11,0.23-0.23V13.5c0.71,0.75,1.7,1.18,2.73,1.18 c1.88,0,3.45-1.41,3.84-3.29C66.37,10.79,66.37,10.18,66.24,9.59L66.24,9.59z M62.08,13c-1.32,0-2.39-1.11-2.41-2.48v-0.06 c0.02-1.38,1.09-2.48,2.41-2.48s2.42,1.12,2.42,2.51S63.41,13,62.08,13z"/%3E %3Cpath class="st0" style="opacity:0.9; fill: %23FFFFFF; enable-background: new;" d="M71.67,6.32c-1.98-0.01-3.72,1.35-4.16,3.29c-0.13,0.59-0.13,1.19,0,1.77c0.44,1.94,2.17,3.32,4.17,3.3 c2.35,0,4.26-1.87,4.26-4.19S74.04,6.32,71.67,6.32z M71.65,13.01c-1.33,0-2.42-1.12-2.42-2.51s1.08-2.52,2.42-2.52 c1.33,0,2.42,1.12,2.42,2.51S72.99,13,71.65,13.01L71.65,13.01z"/%3E %3Cpath class="st1" style="opacity:0.35; enable-background:new;" d="M62.08,7.98c-1.32,0-2.39,1.11-2.41,2.48v0.06C59.68,11.9,60.75,13,62.08,13s2.42-1.12,2.42-2.51 S63.41,7.98,62.08,7.98z M62.08,11.76c-0.63,0-1.14-0.56-1.17-1.25v-0.04c0.01-0.69,0.54-1.25,1.17-1.25 c0.63,0,1.17,0.57,1.17,1.27C63.24,11.2,62.73,11.76,62.08,11.76z"/%3E %3Cpath class="st1" style="opacity:0.35; enable-background:new;" d="M71.65,7.98c-1.33,0-2.42,1.12-2.42,2.51S70.32,13,71.65,13s2.42-1.12,2.42-2.51S72.99,7.98,71.65,7.98z M71.65,11.76c-0.64,0-1.17-0.57-1.17-1.27c0-0.7,0.53-1.26,1.17-1.26s1.17,0.57,1.17,1.27C72.82,11.21,72.29,11.76,71.65,11.76z"/%3E %3Cpath class="st0" style="opacity:0.9; fill: %23FFFFFF; enable-background: new;" d="M45.74,6.53h-1.4c-0.13,0-0.23,0.11-0.23,0.23v0.73c-0.71-0.75-1.7-1.18-2.73-1.18 c-2.17,0-3.94,1.87-3.94,4.19s1.77,4.19,3.94,4.19c1.04,0,2.03-0.43,2.73-1.19v0.73c0,0.13,0.1,0.23,0.23,0.23h1.4 c0.13,0,0.23-0.11,0.23-0.23V6.74c0-0.12-0.09-0.22-0.22-0.22C45.75,6.53,45.75,6.53,45.74,6.53z M44.12,10.53 C44.11,11.9,43.03,13,41.71,13s-2.42-1.12-2.42-2.51s1.08-2.52,2.4-2.52c1.33,0,2.39,1.11,2.41,2.48L44.12,10.53z"/%3E %3Cpath class="st1" style="opacity:0.35; enable-background:new;" d="M41.71,7.98c-1.33,0-2.42,1.12-2.42,2.51S40.37,13,41.71,13s2.39-1.11,2.41-2.48v-0.06 C44.1,9.09,43.03,7.98,41.71,7.98z M40.55,10.49c0-0.7,0.52-1.27,1.17-1.27c0.64,0,1.14,0.56,1.17,1.25v0.04 c-0.01,0.68-0.53,1.24-1.17,1.24C41.08,11.75,40.55,11.19,40.55,10.49z"/%3E %3Cpath class="st0" style="opacity:0.9; fill: %23FFFFFF; enable-background: new;" d="M52.41,6.32c-1.03,0-2.03,0.42-2.73,1.18V6.75c0-0.13-0.1-0.23-0.23-0.23h-1.4c-0.13,0-0.23,0.11-0.23,0.23 v10.72c0,0.13,0.1,0.23,0.23,0.23h1.4c0.13,0,0.23-0.1,0.23-0.23V13.5c0.71,0.75,1.7,1.18,2.74,1.18c2.17,0,3.94-1.87,3.94-4.19 S54.58,6.32,52.41,6.32z M52.08,13.01c-1.32,0-2.39-1.11-2.42-2.48v-0.07c0.02-1.38,1.09-2.49,2.4-2.49c1.32,0,2.41,1.12,2.41,2.51 S53.4,13,52.08,13.01L52.08,13.01z"/%3E %3Cpath class="st1" style="opacity:0.35; enable-background:new;" d="M52.08,7.98c-1.32,0-2.39,1.11-2.42,2.48v0.06c0.03,1.38,1.1,2.48,2.42,2.48s2.41-1.12,2.41-2.51 S53.4,7.98,52.08,7.98z M52.08,11.76c-0.63,0-1.14-0.56-1.17-1.25v-0.04c0.01-0.69,0.54-1.25,1.17-1.25c0.63,0,1.17,0.58,1.17,1.27 S52.72,11.76,52.08,11.76z"/%3E %3Cpath class="st0" style="opacity:0.9; fill: %23FFFFFF; enable-background: new;" d="M36.08,14.24c0,0.13-0.1,0.23-0.23,0.23h-1.41c-0.13,0-0.23-0.11-0.23-0.23V9.68c0-0.98-0.74-1.71-1.62-1.71 c-0.8,0-1.46,0.7-1.59,1.62l0.01,4.66c0,0.13-0.11,0.23-0.23,0.23h-1.41c-0.13,0-0.23-0.11-0.23-0.23V9.68 c0-0.98-0.74-1.71-1.62-1.71c-0.85,0-1.54,0.79-1.6,1.8v4.48c0,0.13-0.1,0.23-0.23,0.23h-1.4c-0.13,0-0.23-0.11-0.23-0.23V6.74 c0.01-0.13,0.1-0.22,0.23-0.22h1.4c0.13,0,0.22,0.11,0.23,0.22V7.4c0.5-0.68,1.3-1.09,2.16-1.1h0.03c1.09,0,2.09,0.6,2.6,1.55 c0.45-0.95,1.4-1.55,2.44-1.56c1.62,0,2.93,1.25,2.9,2.78L36.08,14.24z"/%3E %3Cpath class="st1" style="opacity:0.35; enable-background:new;" d="M84.34,13.59l-0.07-0.13l-1.96-2.99l1.94-2.95c0.44-0.67,0.26-1.56-0.41-2.02c-0.02,0-0.03,0-0.04-0.01 c-0.23-0.15-0.5-0.22-0.78-0.22h-1.61c-0.56,0-1.08,0.29-1.37,0.78L79.72,6.6l-0.34-0.56C79.09,5.56,78.57,5.27,78,5.27h-1.6 c-0.6,0-1.13,0.37-1.35,0.92c-2.19-1.66-5.28-1.47-7.26,0.45c-0.35,0.34-0.65,0.72-0.89,1.14c-0.9-1.62-2.58-2.72-4.5-2.72 c-0.5,0-1.01,0.07-1.48,0.23V3.51c0-0.82-0.66-1.48-1.47-1.48h-1.4c-0.81,0-1.47,0.66-1.47,1.47v3.75 c-0.95-1.36-2.5-2.18-4.17-2.19c-0.74,0-1.46,0.16-2.12,0.47c-0.24-0.17-0.54-0.26-0.84-0.26h-1.4c-0.45,0-0.87,0.21-1.15,0.56 c-0.02-0.03-0.04-0.05-0.07-0.08c-0.28-0.3-0.68-0.47-1.09-0.47h-1.39c-0.3,0-0.6,0.09-0.84,0.26c-0.67-0.3-1.39-0.46-2.12-0.46 c-1.83,0-3.43,1-4.37,2.5c-0.2-0.46-0.48-0.89-0.83-1.25c-0.8-0.81-1.89-1.25-3.02-1.25h-0.01c-0.89,0.01-1.75,0.33-2.46,0.88 c-0.74-0.57-1.64-0.88-2.57-0.88H28.1c-0.29,0-0.58,0.03-0.86,0.11c-0.28,0.06-0.56,0.16-0.82,0.28c-0.21-0.12-0.45-0.18-0.7-0.18 h-1.4c-0.82,0-1.47,0.66-1.47,1.47v7.5c0,0.82,0.66,1.47,1.47,1.47h1.4c0.82,0,1.48-0.66,1.48-1.48l0,0V9.79 c0.03-0.36,0.23-0.59,0.36-0.59c0.18,0,0.38,0.18,0.38,0.47v4.57c0,0.82,0.66,1.47,1.47,1.47h1.41c0.82,0,1.47-0.66,1.47-1.47 l-0.01-4.57c0.06-0.32,0.25-0.47,0.35-0.47c0.18,0,0.38,0.18,0.38,0.47v4.57c0,0.82,0.66,1.47,1.47,1.47h1.41 c0.82,0,1.47-0.66,1.47-1.47v-0.38c0.96,1.29,2.46,2.06,4.06,2.06c0.74,0,1.46-0.16,2.12-0.47c0.24,0.17,0.54,0.26,0.84,0.26h1.39 c0.3,0,0.6-0.09,0.84-0.26v2.01c0,0.82,0.66,1.47,1.47,1.47h1.4c0.82,0,1.47-0.66,1.47-1.47v-1.77c0.48,0.15,0.99,0.23,1.49,0.22 c1.7,0,3.22-0.87,4.17-2.2v0.52c0,0.82,0.66,1.47,1.47,1.47h1.4c0.3,0,0.6-0.09,0.84-0.26c0.66,0.31,1.39,0.47,2.12,0.47 c1.92,0,3.6-1.1,4.49-2.73c1.54,2.65,4.95,3.53,7.58,1.98c0.18-0.11,0.36-0.22,0.53-0.36c0.22,0.55,0.76,0.91,1.35,0.9H78 c0.56,0,1.08-0.29,1.37-0.78l0.37-0.61l0.37,0.61c0.29,0.48,0.81,0.78,1.38,0.78h1.6c0.81,0,1.46-0.66,1.45-1.46 C84.49,14.02,84.44,13.8,84.34,13.59L84.34,13.59z M35.86,14.47h-1.41c-0.13,0-0.23-0.11-0.23-0.23V9.68 c0-0.98-0.74-1.71-1.62-1.71c-0.8,0-1.46,0.7-1.59,1.62l0.01,4.66c0,0.13-0.1,0.23-0.23,0.23h-1.41c-0.13,0-0.23-0.11-0.23-0.23 V9.68c0-0.98-0.74-1.71-1.62-1.71c-0.85,0-1.54,0.79-1.6,1.8v4.48c0,0.13-0.1,0.23-0.23,0.23h-1.4c-0.13,0-0.23-0.11-0.23-0.23 V6.74c0.01-0.13,0.11-0.22,0.23-0.22h1.4c0.13,0,0.22,0.11,0.23,0.22V7.4c0.5-0.68,1.3-1.09,2.16-1.1h0.03 c1.09,0,2.09,0.6,2.6,1.55c0.45-0.95,1.4-1.55,2.44-1.56c1.62,0,2.93,1.25,2.9,2.78l0.01,5.16C36.09,14.36,35.98,14.46,35.86,14.47 L35.86,14.47z M45.97,14.24c0,0.13-0.1,0.23-0.23,0.23h-1.4c-0.13,0-0.23-0.11-0.23-0.23V13.5c-0.7,0.76-1.69,1.18-2.72,1.18 c-2.17,0-3.94-1.87-3.94-4.19s1.77-4.19,3.94-4.19c1.03,0,2.02,0.43,2.73,1.18V6.74c0-0.13,0.1-0.23,0.23-0.23h1.4 c0.12-0.01,0.22,0.08,0.23,0.21c0,0.01,0,0.01,0,0.02v7.51h-0.01V14.24z M52.41,14.67c-1.03,0-2.02-0.43-2.73-1.18v3.97 c0,0.13-0.1,0.23-0.23,0.23h-1.4c-0.13,0-0.23-0.1-0.23-0.23V6.75c0-0.13,0.1-0.22,0.23-0.22h1.4c0.13,0,0.23,0.11,0.23,0.23v0.73 c0.71-0.76,1.7-1.18,2.73-1.18c2.17,0,3.94,1.86,3.94,4.18S54.58,14.67,52.41,14.67z M66.24,11.39c-0.39,1.87-1.96,3.29-3.84,3.29 c-1.03,0-2.02-0.43-2.73-1.18v0.73c0,0.13-0.1,0.23-0.23,0.23h-1.4c-0.13,0-0.23-0.11-0.23-0.23V3.51c0-0.13,0.1-0.23,0.23-0.23 h1.4c0.13,0,0.23,0.11,0.23,0.23v3.97c0.71-0.75,1.7-1.18,2.73-1.17c1.88,0,3.45,1.4,3.84,3.28C66.37,10.19,66.37,10.8,66.24,11.39 L66.24,11.39L66.24,11.39z M71.67,14.68c-2,0.01-3.73-1.35-4.17-3.3c-0.13-0.59-0.13-1.19,0-1.77c0.44-1.94,2.17-3.31,4.17-3.3 c2.36,0,4.26,1.87,4.26,4.19S74.03,14.68,71.67,14.68L71.67,14.68z M83.04,14.47h-1.61c-0.13,0-0.24-0.06-0.3-0.17l-1.44-2.39 l-1.44,2.39c-0.06,0.11-0.18,0.17-0.3,0.17h-1.61c-0.04,0-0.08-0.01-0.12-0.03c-0.09-0.06-0.13-0.19-0.06-0.28l0,0l2.43-3.68 L76.2,6.84c-0.02-0.03-0.03-0.07-0.03-0.12c0-0.12,0.09-0.21,0.21-0.21h1.61c0.13,0,0.24,0.06,0.3,0.17l1.41,2.36l1.41-2.36 c0.06-0.11,0.18-0.17,0.3-0.17h1.61c0.04,0,0.08,0.01,0.12,0.03c0.09,0.06,0.13,0.19,0.06,0.28l0,0l-2.38,3.64l2.43,3.67 c0.02,0.03,0.03,0.07,0.03,0.12C83.25,14.38,83.16,14.47,83.04,14.47L83.04,14.47L83.04,14.47z"/%3E %3Cpath class="st0" style="opacity:0.9; fill: %23FFFFFF; enable-background: new;" d="M10.5,1.24c-5.11,0-9.25,4.15-9.25,9.25s4.15,9.25,9.25,9.25s9.25-4.15,9.25-9.25 C19.75,5.38,15.61,1.24,10.5,1.24z M14.89,12.77c-1.93,1.93-4.78,2.31-6.7,2.31c-0.7,0-1.41-0.05-2.1-0.16c0,0-1.02-5.64,2.14-8.81 c0.83-0.83,1.95-1.28,3.13-1.28c1.27,0,2.49,0.51,3.39,1.42C16.59,8.09,16.64,11,14.89,12.77z"/%3E %3Cpath class="st1" style="opacity:0.35; enable-background:new;" d="M10.5-0.01C4.7-0.01,0,4.7,0,10.49s4.7,10.5,10.5,10.5S21,16.29,21,10.49C20.99,4.7,16.3-0.01,10.5-0.01z M10.5,19.74c-5.11,0-9.25-4.15-9.25-9.25s4.14-9.26,9.25-9.26s9.25,4.15,9.25,9.25C19.75,15.61,15.61,19.74,10.5,19.74z"/%3E %3Cpath class="st1" style="opacity:0.35; enable-background:new;" d="M14.74,6.25C12.9,4.41,9.98,4.35,8.23,6.1c-3.16,3.17-2.14,8.81-2.14,8.81s5.64,1.02,8.81-2.14 C16.64,11,16.59,8.09,14.74,6.25z M12.47,10.34l-0.91,1.87l-0.9-1.87L8.8,9.43l1.86-0.9l0.9-1.87l0.91,1.87l1.86,0.9L12.47,10.34z"/%3E %3Cpolygon class="st0" style="opacity:0.9; fill: %23FFFFFF; enable-background: new;" points="14.33,9.43 12.47,10.34 11.56,12.21 10.66,10.34 8.8,9.43 10.66,8.53 11.56,6.66 12.47,8.53 "/%3E%3C/g%3E%3C/svg%3E\');'
+ }
+ };
+ }
+ });
+
+ // src/plots/mapbox/layout_attributes.js
+ var require_layout_attributes19 = __commonJS({
+ "src/plots/mapbox/layout_attributes.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var defaultLine = require_color().defaultLine;
+ var domainAttrs = require_domain().attributes;
+ var fontAttrs = require_font_attributes();
+ var textposition = require_attributes12().textposition;
+ var overrideAll = require_edit_types().overrideAll;
+ var templatedArray = require_plot_template().templatedArray;
+ var constants = require_constants25();
+ var fontAttr = fontAttrs({
+ noFontVariant: true,
+ noFontShadow: true,
+ noFontLineposition: true,
+ noFontTextcase: true
+ });
+ fontAttr.family.dflt = "Open Sans Regular, Arial Unicode MS Regular";
+ var attrs = module.exports = overrideAll({
+ _arrayAttrRegexps: [Lib.counterRegex("mapbox", ".layers", true)],
+ domain: domainAttrs({ name: "mapbox" }),
+ accesstoken: {
+ valType: "string",
+ noBlank: true,
+ strict: true
+ },
+ style: {
+ valType: "any",
+ values: constants.styleValuesMapbox.concat(constants.styleValuesNonMapbox),
+ dflt: constants.styleValueDflt
+ },
+ center: {
+ lon: {
+ valType: "number",
+ dflt: 0
+ },
+ lat: {
+ valType: "number",
+ dflt: 0
+ }
+ },
+ zoom: {
+ valType: "number",
+ dflt: 1
+ },
+ bearing: {
+ valType: "number",
+ dflt: 0
+ },
+ pitch: {
+ valType: "number",
+ dflt: 0
+ },
+ bounds: {
+ west: {
+ valType: "number"
+ },
+ east: {
+ valType: "number"
+ },
+ south: {
+ valType: "number"
+ },
+ north: {
+ valType: "number"
+ }
+ },
+ layers: templatedArray("layer", {
+ visible: {
+ valType: "boolean",
+ dflt: true
+ },
+ sourcetype: {
+ valType: "enumerated",
+ values: ["geojson", "vector", "raster", "image"],
+ dflt: "geojson"
+ },
+ source: {
+ valType: "any"
+ },
+ sourcelayer: {
+ valType: "string",
+ dflt: ""
+ },
+ sourceattribution: {
+ valType: "string"
+ },
+ type: {
+ valType: "enumerated",
+ values: ["circle", "line", "fill", "symbol", "raster"],
+ dflt: "circle"
+ },
+ coordinates: {
+ valType: "any"
+ },
+ // attributes shared between all types
+ below: {
+ valType: "string"
+ },
+ color: {
+ valType: "color",
+ dflt: defaultLine
+ },
+ opacity: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1
+ },
+ minzoom: {
+ valType: "number",
+ min: 0,
+ max: 24,
+ dflt: 0
+ },
+ maxzoom: {
+ valType: "number",
+ min: 0,
+ max: 24,
+ dflt: 24
+ },
+ // type-specific style attributes
+ circle: {
+ radius: {
+ valType: "number",
+ dflt: 15
+ }
+ },
+ line: {
+ width: {
+ valType: "number",
+ dflt: 2
+ },
+ dash: {
+ valType: "data_array"
+ }
+ },
+ fill: {
+ outlinecolor: {
+ valType: "color",
+ dflt: defaultLine
+ }
+ },
+ symbol: {
+ icon: {
+ valType: "string",
+ dflt: "marker"
+ },
+ iconsize: {
+ valType: "number",
+ dflt: 10
+ },
+ text: {
+ valType: "string",
+ dflt: ""
+ },
+ placement: {
+ valType: "enumerated",
+ values: ["point", "line", "line-center"],
+ dflt: "point"
+ },
+ textfont: fontAttr,
+ textposition: Lib.extendFlat({}, textposition, { arrayOk: false })
+ }
+ })
+ }, "plot", "from-root");
+ attrs.uirevision = {
+ valType: "any",
+ editType: "none"
+ };
+ }
+ });
+
+ // src/traces/scattermapbox/attributes.js
+ var require_attributes54 = __commonJS({
+ "src/traces/scattermapbox/attributes.js"(exports, module) {
+ "use strict";
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var texttemplateAttrs = require_template_attributes().texttemplateAttrs;
+ var makeFillcolorAttr = require_fillcolor_attribute();
+ var scatterGeoAttrs = require_attributes48();
+ var scatterAttrs = require_attributes12();
+ var mapboxAttrs = require_layout_attributes19();
+ var baseAttrs = require_attributes2();
+ var colorScaleAttrs = require_attributes8();
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var mapboxLayoutAtributes = require_layout_attributes19();
+ var lineAttrs = scatterGeoAttrs.line;
+ var markerAttrs = scatterGeoAttrs.marker;
+ module.exports = overrideAll({
+ lon: scatterGeoAttrs.lon,
+ lat: scatterGeoAttrs.lat,
+ cluster: {
+ enabled: {
+ valType: "boolean"
+ },
+ maxzoom: extendFlat({}, mapboxLayoutAtributes.layers.maxzoom, {}),
+ step: {
+ valType: "number",
+ arrayOk: true,
+ dflt: -1,
+ min: -1
+ },
+ size: {
+ valType: "number",
+ arrayOk: true,
+ dflt: 20,
+ min: 0
+ },
+ color: {
+ valType: "color",
+ arrayOk: true
+ },
+ opacity: extendFlat({}, markerAttrs.opacity, {
+ dflt: 1
+ })
+ },
+ // locations
+ // locationmode
+ mode: extendFlat({}, scatterAttrs.mode, {
+ dflt: "markers"
+ }),
+ text: extendFlat({}, scatterAttrs.text, {}),
+ texttemplate: texttemplateAttrs({ editType: "plot" }, {
+ keys: ["lat", "lon", "text"]
+ }),
+ hovertext: extendFlat({}, scatterAttrs.hovertext, {}),
+ line: {
+ color: lineAttrs.color,
+ width: lineAttrs.width
+ // TODO
+ // dash: dash
+ },
+ connectgaps: scatterAttrs.connectgaps,
+ marker: extendFlat(
+ {
+ symbol: {
+ valType: "string",
+ dflt: "circle",
+ arrayOk: true
+ },
+ angle: {
+ valType: "number",
+ dflt: "auto",
+ arrayOk: true
+ },
+ allowoverlap: {
+ valType: "boolean",
+ dflt: false
+ },
+ opacity: markerAttrs.opacity,
+ size: markerAttrs.size,
+ sizeref: markerAttrs.sizeref,
+ sizemin: markerAttrs.sizemin,
+ sizemode: markerAttrs.sizemode
+ },
+ colorScaleAttrs("marker")
+ // line
+ ),
+ fill: scatterGeoAttrs.fill,
+ fillcolor: makeFillcolorAttr(),
+ textfont: mapboxAttrs.layers.symbol.textfont,
+ textposition: mapboxAttrs.layers.symbol.textposition,
+ below: {
+ valType: "string"
+ },
+ selected: {
+ marker: scatterAttrs.selected.marker
+ },
+ unselected: {
+ marker: scatterAttrs.unselected.marker
+ },
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ flags: ["lon", "lat", "text", "name"]
+ }),
+ hovertemplate: hovertemplateAttrs()
+ }, "calc", "nested");
+ }
+ });
+
+ // src/traces/scattermapbox/constants.js
+ var require_constants26 = __commonJS({
+ "src/traces/scattermapbox/constants.js"(exports, module) {
+ "use strict";
+ var supportedFonts = [
+ "Metropolis Black Italic",
+ "Metropolis Black",
+ "Metropolis Bold Italic",
+ "Metropolis Bold",
+ "Metropolis Extra Bold Italic",
+ "Metropolis Extra Bold",
+ "Metropolis Extra Light Italic",
+ "Metropolis Extra Light",
+ "Metropolis Light Italic",
+ "Metropolis Light",
+ "Metropolis Medium Italic",
+ "Metropolis Medium",
+ "Metropolis Regular Italic",
+ "Metropolis Regular",
+ "Metropolis Semi Bold Italic",
+ "Metropolis Semi Bold",
+ "Metropolis Thin Italic",
+ "Metropolis Thin",
+ "Open Sans Bold Italic",
+ "Open Sans Bold",
+ "Open Sans Extrabold Italic",
+ "Open Sans Extrabold",
+ "Open Sans Italic",
+ "Open Sans Light Italic",
+ "Open Sans Light",
+ "Open Sans Regular",
+ "Open Sans Semibold Italic",
+ "Open Sans Semibold",
+ "Klokantech Noto Sans Bold",
+ "Klokantech Noto Sans CJK Bold",
+ "Klokantech Noto Sans CJK Regular",
+ "Klokantech Noto Sans Italic",
+ "Klokantech Noto Sans Regular"
+ ];
+ module.exports = {
+ isSupportedFont: function(a) {
+ return supportedFonts.indexOf(a) !== -1;
+ }
+ };
+ }
+ });
+
+ // src/traces/scattermapbox/defaults.js
+ var require_defaults50 = __commonJS({
+ "src/traces/scattermapbox/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var subTypes = require_subtypes();
+ var handleMarkerDefaults = require_marker_defaults();
+ var handleLineDefaults = require_line_defaults();
+ var handleTextDefaults = require_text_defaults();
+ var handleFillColorDefaults = require_fillcolor_defaults();
+ var attributes = require_attributes54();
+ var isSupportedFont = require_constants26().isSupportedFont;
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ function coerce2(attr, dflt) {
+ return Lib.coerce2(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var len = handleLonLatDefaults(traceIn, traceOut, coerce);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("text");
+ coerce("texttemplate");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ coerce("mode");
+ coerce("below");
+ if (subTypes.hasMarkers(traceOut)) {
+ handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, { noLine: true, noAngle: true });
+ coerce("marker.allowoverlap");
+ coerce("marker.angle");
+ var marker = traceOut.marker;
+ if (marker.symbol !== "circle") {
+ if (Lib.isArrayOrTypedArray(marker.size)) marker.size = marker.size[0];
+ if (Lib.isArrayOrTypedArray(marker.color)) marker.color = marker.color[0];
+ }
+ }
+ if (subTypes.hasLines(traceOut)) {
+ handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce, { noDash: true });
+ coerce("connectgaps");
+ }
+ var clusterMaxzoom = coerce2("cluster.maxzoom");
+ var clusterStep = coerce2("cluster.step");
+ var clusterColor = coerce2("cluster.color", traceOut.marker && traceOut.marker.color || defaultColor);
+ var clusterSize = coerce2("cluster.size");
+ var clusterOpacity = coerce2("cluster.opacity");
+ var clusterEnabledDflt = clusterMaxzoom !== false || clusterStep !== false || clusterColor !== false || clusterSize !== false || clusterOpacity !== false;
+ var clusterEnabled = coerce("cluster.enabled", clusterEnabledDflt);
+ if (clusterEnabled || subTypes.hasText(traceOut)) {
+ var layoutFontFamily = layout.font.family;
+ handleTextDefaults(
+ traceIn,
+ traceOut,
+ layout,
+ coerce,
+ {
+ noSelect: true,
+ noFontVariant: true,
+ noFontShadow: true,
+ noFontLineposition: true,
+ noFontTextcase: true,
+ font: {
+ family: isSupportedFont(layoutFontFamily) ? layoutFontFamily : "Open Sans Regular",
+ weight: layout.font.weight,
+ style: layout.font.style,
+ size: layout.font.size,
+ color: layout.font.color
+ }
+ }
+ );
+ }
+ coerce("fill");
+ if (traceOut.fill !== "none") {
+ handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
+ }
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ function handleLonLatDefaults(traceIn, traceOut, coerce) {
+ var lon = coerce("lon") || [];
+ var lat = coerce("lat") || [];
+ var len = Math.min(lon.length, lat.length);
+ traceOut._length = len;
+ return len;
+ }
+ }
+ });
+
+ // src/traces/scattermapbox/format_labels.js
+ var require_format_labels5 = __commonJS({
+ "src/traces/scattermapbox/format_labels.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ module.exports = function formatLabels(cdi, trace, fullLayout) {
+ var labels = {};
+ var subplot = fullLayout[trace.subplot]._subplot;
+ var ax = subplot.mockAxis;
+ var lonlat = cdi.lonlat;
+ labels.lonLabel = Axes.tickText(ax, ax.c2l(lonlat[0]), true).text;
+ labels.latLabel = Axes.tickText(ax, ax.c2l(lonlat[1]), true).text;
+ return labels;
+ };
+ }
+ });
+
+ // src/plots/mapbox/convert_text_opts.js
+ var require_convert_text_opts = __commonJS({
+ "src/plots/mapbox/convert_text_opts.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ module.exports = function convertTextOpts(textposition, iconSize) {
+ var parts = textposition.split(" ");
+ var vPos = parts[0];
+ var hPos = parts[1];
+ var factor = Lib.isArrayOrTypedArray(iconSize) ? Lib.mean(iconSize) : iconSize;
+ var xInc = 0.5 + factor / 100;
+ var yInc = 1.5 + factor / 100;
+ var anchorVals = ["", ""];
+ var offset = [0, 0];
+ switch (vPos) {
+ case "top":
+ anchorVals[0] = "top";
+ offset[1] = -yInc;
+ break;
+ case "bottom":
+ anchorVals[0] = "bottom";
+ offset[1] = yInc;
+ break;
+ }
+ switch (hPos) {
+ case "left":
+ anchorVals[1] = "right";
+ offset[0] = -xInc;
+ break;
+ case "right":
+ anchorVals[1] = "left";
+ offset[0] = xInc;
+ break;
+ }
+ var anchor;
+ if (anchorVals[0] && anchorVals[1]) anchor = anchorVals.join("-");
+ else if (anchorVals[0]) anchor = anchorVals[0];
+ else if (anchorVals[1]) anchor = anchorVals[1];
+ else anchor = "center";
+ return { anchor, offset };
+ };
+ }
+ });
+
+ // src/traces/scattermapbox/convert.js
+ var require_convert11 = __commonJS({
+ "src/traces/scattermapbox/convert.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var Lib = require_lib();
+ var BADNUM = require_numerical().BADNUM;
+ var geoJsonUtils = require_geojson_utils();
+ var Colorscale = require_colorscale();
+ var Drawing = require_drawing();
+ var makeBubbleSizeFn = require_make_bubble_size_func();
+ var subTypes = require_subtypes();
+ var isSupportedFont = require_constants26().isSupportedFont;
+ var convertTextOpts = require_convert_text_opts();
+ var appendArrayPointValue = require_helpers2().appendArrayPointValue;
+ var NEWLINES = require_svg_text_utils().NEWLINES;
+ var BR_TAG_ALL = require_svg_text_utils().BR_TAG_ALL;
+ module.exports = function convert(gd, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var isVisible = trace.visible === true && trace._length !== 0;
+ var hasFill = trace.fill !== "none";
+ var hasLines = subTypes.hasLines(trace);
+ var hasMarkers = subTypes.hasMarkers(trace);
+ var hasText = subTypes.hasText(trace);
+ var hasCircles = hasMarkers && trace.marker.symbol === "circle";
+ var hasSymbols = hasMarkers && trace.marker.symbol !== "circle";
+ var hasCluster = trace.cluster && trace.cluster.enabled;
+ var fill = initContainer("fill");
+ var line = initContainer("line");
+ var circle = initContainer("circle");
+ var symbol = initContainer("symbol");
+ var opts = {
+ fill,
+ line,
+ circle,
+ symbol
+ };
+ if (!isVisible) return opts;
+ var lineCoords;
+ if (hasFill || hasLines) {
+ lineCoords = geoJsonUtils.calcTraceToLineCoords(calcTrace);
+ }
+ if (hasFill) {
+ fill.geojson = geoJsonUtils.makePolygon(lineCoords);
+ fill.layout.visibility = "visible";
+ Lib.extendFlat(fill.paint, {
+ "fill-color": trace.fillcolor
+ });
+ }
+ if (hasLines) {
+ line.geojson = geoJsonUtils.makeLine(lineCoords);
+ line.layout.visibility = "visible";
+ Lib.extendFlat(line.paint, {
+ "line-width": trace.line.width,
+ "line-color": trace.line.color,
+ "line-opacity": trace.opacity
+ });
+ }
+ if (hasCircles) {
+ var circleOpts = makeCircleOpts(calcTrace);
+ circle.geojson = circleOpts.geojson;
+ circle.layout.visibility = "visible";
+ if (hasCluster) {
+ circle.filter = ["!", ["has", "point_count"]];
+ opts.cluster = {
+ type: "circle",
+ filter: ["has", "point_count"],
+ layout: { visibility: "visible" },
+ paint: {
+ "circle-color": arrayifyAttribute(trace.cluster.color, trace.cluster.step),
+ "circle-radius": arrayifyAttribute(trace.cluster.size, trace.cluster.step),
+ "circle-opacity": arrayifyAttribute(trace.cluster.opacity, trace.cluster.step)
+ }
+ };
+ opts.clusterCount = {
+ type: "symbol",
+ filter: ["has", "point_count"],
+ paint: {},
+ layout: {
+ "text-field": "{point_count_abbreviated}",
+ "text-font": getTextFont(trace),
+ "text-size": 12
+ }
+ };
+ }
+ Lib.extendFlat(circle.paint, {
+ "circle-color": circleOpts.mcc,
+ "circle-radius": circleOpts.mrc,
+ "circle-opacity": circleOpts.mo
+ });
+ }
+ if (hasCircles && hasCluster) {
+ circle.filter = ["!", ["has", "point_count"]];
+ }
+ if (hasSymbols || hasText) {
+ symbol.geojson = makeSymbolGeoJSON(calcTrace, gd);
+ Lib.extendFlat(symbol.layout, {
+ visibility: "visible",
+ "icon-image": "{symbol}-15",
+ "text-field": "{text}"
+ });
+ if (hasSymbols) {
+ Lib.extendFlat(symbol.layout, {
+ "icon-size": trace.marker.size / 10
+ });
+ if ("angle" in trace.marker && trace.marker.angle !== "auto") {
+ Lib.extendFlat(symbol.layout, {
+ // unfortunately cant use {angle} do to this issue:
+ // https://github.com/mapbox/mapbox-gl-js/issues/873
+ "icon-rotate": {
+ type: "identity",
+ property: "angle"
+ },
+ "icon-rotation-alignment": "map"
+ });
+ }
+ symbol.layout["icon-allow-overlap"] = trace.marker.allowoverlap;
+ Lib.extendFlat(symbol.paint, {
+ "icon-opacity": trace.opacity * trace.marker.opacity,
+ // TODO does not work ??
+ "icon-color": trace.marker.color
+ });
+ }
+ if (hasText) {
+ var iconSize = (trace.marker || {}).size;
+ var textOpts = convertTextOpts(trace.textposition, iconSize);
+ Lib.extendFlat(symbol.layout, {
+ "text-size": trace.textfont.size,
+ "text-anchor": textOpts.anchor,
+ "text-offset": textOpts.offset,
+ "text-font": getTextFont(trace)
+ });
+ Lib.extendFlat(symbol.paint, {
+ "text-color": trace.textfont.color,
+ "text-opacity": trace.opacity
+ });
+ }
+ }
+ return opts;
+ };
+ function initContainer(type) {
+ return {
+ type,
+ geojson: geoJsonUtils.makeBlank(),
+ layout: { visibility: "none" },
+ filter: null,
+ paint: {}
+ };
+ }
+ function makeCircleOpts(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var marker = trace.marker;
+ var selectedpoints = trace.selectedpoints;
+ var arrayColor = Lib.isArrayOrTypedArray(marker.color);
+ var arraySize = Lib.isArrayOrTypedArray(marker.size);
+ var arrayOpacity = Lib.isArrayOrTypedArray(marker.opacity);
+ var i;
+ function addTraceOpacity(o) {
+ return trace.opacity * o;
+ }
+ function size2radius(s) {
+ return s / 2;
+ }
+ var colorFn;
+ if (arrayColor) {
+ if (Colorscale.hasColorscale(trace, "marker")) {
+ colorFn = Colorscale.makeColorScaleFuncFromTrace(marker);
+ } else {
+ colorFn = Lib.identity;
+ }
+ }
+ var sizeFn;
+ if (arraySize) {
+ sizeFn = makeBubbleSizeFn(trace);
+ }
+ var opacityFn;
+ if (arrayOpacity) {
+ opacityFn = function(mo) {
+ var mo2 = isNumeric(mo) ? +Lib.constrain(mo, 0, 1) : 0;
+ return addTraceOpacity(mo2);
+ };
+ }
+ var features = [];
+ for (i = 0; i < calcTrace.length; i++) {
+ var calcPt = calcTrace[i];
+ var lonlat = calcPt.lonlat;
+ if (isBADNUM(lonlat)) continue;
+ var props = {};
+ if (colorFn) props.mcc = calcPt.mcc = colorFn(calcPt.mc);
+ if (sizeFn) props.mrc = calcPt.mrc = sizeFn(calcPt.ms);
+ if (opacityFn) props.mo = opacityFn(calcPt.mo);
+ if (selectedpoints) props.selected = calcPt.selected || 0;
+ features.push({
+ type: "Feature",
+ id: i + 1,
+ geometry: { type: "Point", coordinates: lonlat },
+ properties: props
+ });
+ }
+ var fns;
+ if (selectedpoints) {
+ fns = Drawing.makeSelectedPointStyleFns(trace);
+ for (i = 0; i < features.length; i++) {
+ var d = features[i].properties;
+ if (fns.selectedOpacityFn) {
+ d.mo = addTraceOpacity(fns.selectedOpacityFn(d));
+ }
+ if (fns.selectedColorFn) {
+ d.mcc = fns.selectedColorFn(d);
+ }
+ if (fns.selectedSizeFn) {
+ d.mrc = fns.selectedSizeFn(d);
+ }
+ }
+ }
+ return {
+ geojson: { type: "FeatureCollection", features },
+ mcc: arrayColor || fns && fns.selectedColorFn ? { type: "identity", property: "mcc" } : marker.color,
+ mrc: arraySize || fns && fns.selectedSizeFn ? { type: "identity", property: "mrc" } : size2radius(marker.size),
+ mo: arrayOpacity || fns && fns.selectedOpacityFn ? { type: "identity", property: "mo" } : addTraceOpacity(marker.opacity)
+ };
+ }
+ function makeSymbolGeoJSON(calcTrace, gd) {
+ var fullLayout = gd._fullLayout;
+ var trace = calcTrace[0].trace;
+ var marker = trace.marker || {};
+ var symbol = marker.symbol;
+ var angle = marker.angle;
+ var fillSymbol = symbol !== "circle" ? getFillFunc(symbol) : blankFillFunc;
+ var fillAngle = angle !== "auto" ? getFillFunc(angle, true) : blankFillFunc;
+ var fillText = subTypes.hasText(trace) ? getFillFunc(trace.text) : blankFillFunc;
+ var features = [];
+ for (var i = 0; i < calcTrace.length; i++) {
+ var calcPt = calcTrace[i];
+ if (isBADNUM(calcPt.lonlat)) continue;
+ var texttemplate = trace.texttemplate;
+ var text;
+ if (texttemplate) {
+ var tt = Array.isArray(texttemplate) ? texttemplate[i] || "" : texttemplate;
+ var labels = trace._module.formatLabels(calcPt, trace, fullLayout);
+ var pointValues = {};
+ appendArrayPointValue(pointValues, trace, calcPt.i);
+ var meta = trace._meta || {};
+ text = Lib.texttemplateString(tt, labels, fullLayout._d3locale, pointValues, calcPt, meta);
+ } else {
+ text = fillText(i);
+ }
+ if (text) {
+ text = text.replace(NEWLINES, "").replace(BR_TAG_ALL, "\n");
+ }
+ features.push({
+ type: "Feature",
+ geometry: {
+ type: "Point",
+ coordinates: calcPt.lonlat
+ },
+ properties: {
+ symbol: fillSymbol(i),
+ angle: fillAngle(i),
+ text
+ }
+ });
+ }
+ return {
+ type: "FeatureCollection",
+ features
+ };
+ }
+ function getFillFunc(attr, numeric) {
+ if (Lib.isArrayOrTypedArray(attr)) {
+ if (numeric) {
+ return function(i) {
+ return isNumeric(attr[i]) ? +attr[i] : 0;
+ };
+ }
+ return function(i) {
+ return attr[i];
+ };
+ } else if (attr) {
+ return function() {
+ return attr;
+ };
+ } else {
+ return blankFillFunc;
+ }
+ }
+ function blankFillFunc() {
+ return "";
+ }
+ function isBADNUM(lonlat) {
+ return lonlat[0] === BADNUM;
+ }
+ function arrayifyAttribute(values, step) {
+ var newAttribute;
+ if (Lib.isArrayOrTypedArray(values) && Lib.isArrayOrTypedArray(step)) {
+ newAttribute = ["step", ["get", "point_count"], values[0]];
+ for (var idx = 1; idx < values.length; idx++) {
+ newAttribute.push(step[idx - 1], values[idx]);
+ }
+ } else {
+ newAttribute = values;
+ }
+ return newAttribute;
+ }
+ function getTextFont(trace) {
+ var font = trace.textfont;
+ var family = font.family;
+ var style = font.style;
+ var weight = font.weight;
+ var parts = family.split(" ");
+ var isItalic = parts[parts.length - 1] === "Italic";
+ if (isItalic) parts.pop();
+ isItalic = isItalic || style === "italic";
+ var str = parts.join(" ");
+ if (weight === "bold" && parts.indexOf("Bold") === -1) {
+ str += " Bold";
+ } else if (weight <= 1e3) {
+ if (parts[0] === "Metropolis") {
+ str = "Metropolis";
+ if (weight > 850) str += " Black";
+ else if (weight > 750) str += " Extra Bold";
+ else if (weight > 650) str += " Bold";
+ else if (weight > 550) str += " Semi Bold";
+ else if (weight > 450) str += " Medium";
+ else if (weight > 350) str += " Regular";
+ else if (weight > 250) str += " Light";
+ else if (weight > 150) str += " Extra Light";
+ else str += " Thin";
+ } else if (parts.slice(0, 2).join(" ") === "Open Sans") {
+ str = "Open Sans";
+ if (weight > 750) str += " Extrabold";
+ else if (weight > 650) str += " Bold";
+ else if (weight > 550) str += " Semibold";
+ else if (weight > 350) str += " Regular";
+ else str += " Light";
+ } else if (parts.slice(0, 3).join(" ") === "Klokantech Noto Sans") {
+ str = "Klokantech Noto Sans";
+ if (parts[3] === "CJK") str += " CJK";
+ str += weight > 500 ? " Bold" : " Regular";
+ }
+ }
+ if (isItalic) str += " Italic";
+ if (str === "Open Sans Regular Italic") str = "Open Sans Italic";
+ else if (str === "Open Sans Regular Bold") str = "Open Sans Bold";
+ else if (str === "Open Sans Regular Bold Italic") str = "Open Sans Bold Italic";
+ else if (str === "Klokantech Noto Sans Regular Italic") str = "Klokantech Noto Sans Italic";
+ if (!isSupportedFont(str)) {
+ str = family;
+ }
+ var textFont = str.split(", ");
+ return textFont;
+ }
+ }
+ });
+
+ // src/traces/scattermapbox/plot.js
+ var require_plot23 = __commonJS({
+ "src/traces/scattermapbox/plot.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var convert = require_convert11();
+ var LAYER_PREFIX = require_constants25().traceLayerPrefix;
+ var ORDER = {
+ cluster: ["cluster", "clusterCount", "circle"],
+ nonCluster: ["fill", "line", "circle", "symbol"]
+ };
+ function ScatterMapbox(subplot, uid, clusterEnabled, isHidden) {
+ this.type = "scattermapbox";
+ this.subplot = subplot;
+ this.uid = uid;
+ this.clusterEnabled = clusterEnabled;
+ this.isHidden = isHidden;
+ this.sourceIds = {
+ fill: "source-" + uid + "-fill",
+ line: "source-" + uid + "-line",
+ circle: "source-" + uid + "-circle",
+ symbol: "source-" + uid + "-symbol",
+ cluster: "source-" + uid + "-circle",
+ clusterCount: "source-" + uid + "-circle"
+ };
+ this.layerIds = {
+ fill: LAYER_PREFIX + uid + "-fill",
+ line: LAYER_PREFIX + uid + "-line",
+ circle: LAYER_PREFIX + uid + "-circle",
+ symbol: LAYER_PREFIX + uid + "-symbol",
+ cluster: LAYER_PREFIX + uid + "-cluster",
+ clusterCount: LAYER_PREFIX + uid + "-cluster-count"
+ };
+ this.below = null;
+ }
+ var proto = ScatterMapbox.prototype;
+ proto.addSource = function(k, opts, cluster) {
+ var sourceOpts = {
+ type: "geojson",
+ data: opts.geojson
+ };
+ if (cluster && cluster.enabled) {
+ Lib.extendFlat(sourceOpts, {
+ cluster: true,
+ clusterMaxZoom: cluster.maxzoom
+ });
+ }
+ var isSourceExists = this.subplot.map.getSource(this.sourceIds[k]);
+ if (isSourceExists) {
+ isSourceExists.setData(opts.geojson);
+ } else {
+ this.subplot.map.addSource(this.sourceIds[k], sourceOpts);
+ }
+ };
+ proto.setSourceData = function(k, opts) {
+ this.subplot.map.getSource(this.sourceIds[k]).setData(opts.geojson);
+ };
+ proto.addLayer = function(k, opts, below) {
+ var source = {
+ type: opts.type,
+ id: this.layerIds[k],
+ source: this.sourceIds[k],
+ layout: opts.layout,
+ paint: opts.paint
+ };
+ if (opts.filter) {
+ source.filter = opts.filter;
+ }
+ var currentLayerId = this.layerIds[k];
+ var layerExist;
+ var layers = this.subplot.getMapLayers();
+ for (var i = 0; i < layers.length; i++) {
+ if (layers[i].id === currentLayerId) {
+ layerExist = true;
+ break;
+ }
+ }
+ if (layerExist) {
+ this.subplot.setOptions(currentLayerId, "setLayoutProperty", source.layout);
+ if (source.layout.visibility === "visible") {
+ this.subplot.setOptions(currentLayerId, "setPaintProperty", source.paint);
+ }
+ } else {
+ this.subplot.addLayer(source, below);
+ }
+ };
+ proto.update = function update(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var subplot = this.subplot;
+ var map = subplot.map;
+ var optsAll = convert(subplot.gd, calcTrace);
+ var below = subplot.belowLookup["trace-" + this.uid];
+ var hasCluster = !!(trace.cluster && trace.cluster.enabled);
+ var hadCluster = !!this.clusterEnabled;
+ var lThis = this;
+ function addCluster(noSource) {
+ if (!noSource) lThis.addSource("circle", optsAll.circle, trace.cluster);
+ var order = ORDER.cluster;
+ for (var i = 0; i < order.length; i++) {
+ var k = order[i];
+ var opts = optsAll[k];
+ lThis.addLayer(k, opts, below);
+ }
+ }
+ function removeCluster(noSource) {
+ var order = ORDER.cluster;
+ for (var i = order.length - 1; i >= 0; i--) {
+ var k = order[i];
+ map.removeLayer(lThis.layerIds[k]);
+ }
+ if (!noSource) map.removeSource(lThis.sourceIds.circle);
+ }
+ function addNonCluster(noSource) {
+ var order = ORDER.nonCluster;
+ for (var i = 0; i < order.length; i++) {
+ var k = order[i];
+ var opts = optsAll[k];
+ if (!noSource) lThis.addSource(k, opts);
+ lThis.addLayer(k, opts, below);
+ }
+ }
+ function removeNonCluster(noSource) {
+ var order = ORDER.nonCluster;
+ for (var i = order.length - 1; i >= 0; i--) {
+ var k = order[i];
+ map.removeLayer(lThis.layerIds[k]);
+ if (!noSource) map.removeSource(lThis.sourceIds[k]);
+ }
+ }
+ function remove(noSource) {
+ if (hadCluster) removeCluster(noSource);
+ else removeNonCluster(noSource);
+ }
+ function add(noSource) {
+ if (hasCluster) addCluster(noSource);
+ else addNonCluster(noSource);
+ }
+ function repaint() {
+ var order = hasCluster ? ORDER.cluster : ORDER.nonCluster;
+ for (var i = 0; i < order.length; i++) {
+ var k = order[i];
+ var opts = optsAll[k];
+ if (!opts) continue;
+ subplot.setOptions(lThis.layerIds[k], "setLayoutProperty", opts.layout);
+ if (opts.layout.visibility === "visible") {
+ if (k !== "cluster") {
+ lThis.setSourceData(k, opts);
+ }
+ subplot.setOptions(lThis.layerIds[k], "setPaintProperty", opts.paint);
+ }
+ }
+ }
+ var wasHidden = this.isHidden;
+ var isHidden = trace.visible !== true;
+ if (isHidden) {
+ if (!wasHidden) remove();
+ } else if (wasHidden) {
+ if (!isHidden) add();
+ } else if (hadCluster !== hasCluster) {
+ remove();
+ add();
+ } else if (this.below !== below) {
+ remove(true);
+ add(true);
+ repaint();
+ } else {
+ repaint();
+ }
+ this.clusterEnabled = hasCluster;
+ this.isHidden = isHidden;
+ this.below = below;
+ calcTrace[0].trace._glTrace = this;
+ };
+ proto.dispose = function dispose() {
+ var map = this.subplot.map;
+ var order = this.clusterEnabled ? ORDER.cluster : ORDER.nonCluster;
+ for (var i = order.length - 1; i >= 0; i--) {
+ var k = order[i];
+ map.removeLayer(this.layerIds[k]);
+ map.removeSource(this.sourceIds[k]);
+ }
+ };
+ module.exports = function createScatterMapbox(subplot, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var hasCluster = trace.cluster && trace.cluster.enabled;
+ var isHidden = trace.visible !== true;
+ var scatterMapbox = new ScatterMapbox(
+ subplot,
+ trace.uid,
+ hasCluster,
+ isHidden
+ );
+ var optsAll = convert(subplot.gd, calcTrace);
+ var below = scatterMapbox.below = subplot.belowLookup["trace-" + trace.uid];
+ var i, k, opts;
+ if (hasCluster) {
+ scatterMapbox.addSource("circle", optsAll.circle, trace.cluster);
+ for (i = 0; i < ORDER.cluster.length; i++) {
+ k = ORDER.cluster[i];
+ opts = optsAll[k];
+ scatterMapbox.addLayer(k, opts, below);
+ }
+ } else {
+ for (i = 0; i < ORDER.nonCluster.length; i++) {
+ k = ORDER.nonCluster[i];
+ opts = optsAll[k];
+ scatterMapbox.addSource(k, opts, trace.cluster);
+ scatterMapbox.addLayer(k, opts, below);
+ }
+ }
+ calcTrace[0].trace._glTrace = scatterMapbox;
+ return scatterMapbox;
+ };
+ }
+ });
+
+ // src/traces/scattermapbox/hover.js
+ var require_hover18 = __commonJS({
+ "src/traces/scattermapbox/hover.js"(exports, module) {
+ "use strict";
+ var Fx = require_fx();
+ var Lib = require_lib();
+ var getTraceColor = require_get_trace_color();
+ var fillText = Lib.fillText;
+ var BADNUM = require_numerical().BADNUM;
+ var LAYER_PREFIX = require_constants25().traceLayerPrefix;
+ function hoverPoints(pointData, xval, yval) {
+ var cd = pointData.cd;
+ var trace = cd[0].trace;
+ var xa = pointData.xa;
+ var ya = pointData.ya;
+ var subplot = pointData.subplot;
+ var clusteredPointsIds = [];
+ var layer = LAYER_PREFIX + trace.uid + "-circle";
+ var hasCluster = trace.cluster && trace.cluster.enabled;
+ if (hasCluster) {
+ var elems = subplot.map.queryRenderedFeatures(null, { layers: [layer] });
+ clusteredPointsIds = elems.map(function(elem) {
+ return elem.id;
+ });
+ }
+ var winding = xval >= 0 ? Math.floor((xval + 180) / 360) : Math.ceil((xval - 180) / 360);
+ var lonShift = winding * 360;
+ var xval2 = xval - lonShift;
+ function distFn(d) {
+ var lonlat2 = d.lonlat;
+ if (lonlat2[0] === BADNUM) return Infinity;
+ if (hasCluster && clusteredPointsIds.indexOf(d.i + 1) === -1) return Infinity;
+ var lon = Lib.modHalf(lonlat2[0], 360);
+ var lat = lonlat2[1];
+ var pt = subplot.project([lon, lat]);
+ var dx = pt.x - xa.c2p([xval2, lat]);
+ var dy = pt.y - ya.c2p([lon, yval]);
+ var rad2 = Math.max(3, d.mrc || 0);
+ return Math.max(Math.sqrt(dx * dx + dy * dy) - rad2, 1 - 3 / rad2);
+ }
+ Fx.getClosest(cd, distFn, pointData);
+ if (pointData.index === false) return;
+ var di = cd[pointData.index];
+ var lonlat = di.lonlat;
+ var lonlatShifted = [Lib.modHalf(lonlat[0], 360) + lonShift, lonlat[1]];
+ var xc = xa.c2p(lonlatShifted);
+ var yc = ya.c2p(lonlatShifted);
+ var rad = di.mrc || 1;
+ pointData.x0 = xc - rad;
+ pointData.x1 = xc + rad;
+ pointData.y0 = yc - rad;
+ pointData.y1 = yc + rad;
+ var fullLayout = {};
+ fullLayout[trace.subplot] = { _subplot: subplot };
+ var labels = trace._module.formatLabels(di, trace, fullLayout);
+ pointData.lonLabel = labels.lonLabel;
+ pointData.latLabel = labels.latLabel;
+ pointData.color = getTraceColor(trace, di);
+ pointData.extraText = getExtraText(trace, di, cd[0].t.labels);
+ pointData.hovertemplate = trace.hovertemplate;
+ return [pointData];
+ }
+ function getExtraText(trace, di, labels) {
+ if (trace.hovertemplate) return;
+ var hoverinfo = di.hi || trace.hoverinfo;
+ var parts = hoverinfo.split("+");
+ var isAll = parts.indexOf("all") !== -1;
+ var hasLon = parts.indexOf("lon") !== -1;
+ var hasLat = parts.indexOf("lat") !== -1;
+ var lonlat = di.lonlat;
+ var text = [];
+ function format(v) {
+ return v + "\xB0";
+ }
+ if (isAll || hasLon && hasLat) {
+ text.push("(" + format(lonlat[1]) + ", " + format(lonlat[0]) + ")");
+ } else if (hasLon) {
+ text.push(labels.lon + format(lonlat[0]));
+ } else if (hasLat) {
+ text.push(labels.lat + format(lonlat[1]));
+ }
+ if (isAll || parts.indexOf("text") !== -1) {
+ fillText(di, trace, text);
+ }
+ return text.join("
");
+ }
+ module.exports = {
+ hoverPoints,
+ getExtraText
+ };
+ }
+ });
+
+ // src/traces/scattermapbox/event_data.js
+ var require_event_data11 = __commonJS({
+ "src/traces/scattermapbox/event_data.js"(exports, module) {
+ "use strict";
+ module.exports = function eventData(out, pt) {
+ out.lon = pt.lon;
+ out.lat = pt.lat;
+ return out;
+ };
+ }
+ });
+
+ // src/traces/scattermapbox/select.js
+ var require_select9 = __commonJS({
+ "src/traces/scattermapbox/select.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var subtypes = require_subtypes();
+ var BADNUM = require_numerical().BADNUM;
+ module.exports = function selectPoints(searchInfo, selectionTester) {
+ var cd = searchInfo.cd;
+ var xa = searchInfo.xaxis;
+ var ya = searchInfo.yaxis;
+ var selection = [];
+ var trace = cd[0].trace;
+ var i;
+ if (!subtypes.hasMarkers(trace)) return [];
+ if (selectionTester === false) {
+ for (i = 0; i < cd.length; i++) {
+ cd[i].selected = 0;
+ }
+ } else {
+ for (i = 0; i < cd.length; i++) {
+ var di = cd[i];
+ var lonlat = di.lonlat;
+ if (lonlat[0] !== BADNUM) {
+ var lonlat2 = [Lib.modHalf(lonlat[0], 360), lonlat[1]];
+ var xy = [xa.c2p(lonlat2), ya.c2p(lonlat2)];
+ if (selectionTester.contains(xy, null, i, searchInfo)) {
+ selection.push({
+ pointNumber: i,
+ lon: lonlat[0],
+ lat: lonlat[1]
+ });
+ di.selected = 1;
+ } else {
+ di.selected = 0;
+ }
+ }
+ }
+ }
+ return selection;
+ };
+ }
+ });
+
+ // node_modules/@plotly/mapbox-gl/dist/mapbox-gl-unminified.js
+ var require_mapbox_gl_unminified = __commonJS({
+ "node_modules/@plotly/mapbox-gl/dist/mapbox-gl-unminified.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && false ? define(factory) : (global2 = global2 || self, global2.mapboxgl = factory());
+ })(exports, function() {
+ "use strict";
+ var shared, worker, mapboxgl;
+ function define2(_, chunk) {
+ if (!shared) {
+ shared = chunk;
+ } else if (!worker) {
+ worker = chunk;
+ } else {
+ var workerBundleString = "var sharedChunk = {}; (" + shared + ")(sharedChunk); (" + worker + ")(sharedChunk);";
+ var sharedChunk = {};
+ shared(sharedChunk);
+ mapboxgl = chunk(sharedChunk);
+ if (typeof window !== "undefined") {
+ mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: "text/javascript" }));
+ }
+ }
+ }
+ define2(["exports"], function(exports2) {
+ "use strict";
+ function createCommonjsModule(fn, module2) {
+ return module2 = { exports: {} }, fn(module2, module2.exports), module2.exports;
+ }
+ var version = "1.13.4";
+ var unitbezier = UnitBezier;
+ function UnitBezier(p1x, p1y, p2x, p2y) {
+ this.cx = 3 * p1x;
+ this.bx = 3 * (p2x - p1x) - this.cx;
+ this.ax = 1 - this.cx - this.bx;
+ this.cy = 3 * p1y;
+ this.by = 3 * (p2y - p1y) - this.cy;
+ this.ay = 1 - this.cy - this.by;
+ this.p1x = p1x;
+ this.p1y = p2y;
+ this.p2x = p2x;
+ this.p2y = p2y;
+ }
+ UnitBezier.prototype.sampleCurveX = function(t) {
+ return ((this.ax * t + this.bx) * t + this.cx) * t;
+ };
+ UnitBezier.prototype.sampleCurveY = function(t) {
+ return ((this.ay * t + this.by) * t + this.cy) * t;
+ };
+ UnitBezier.prototype.sampleCurveDerivativeX = function(t) {
+ return (3 * this.ax * t + 2 * this.bx) * t + this.cx;
+ };
+ UnitBezier.prototype.solveCurveX = function(x, epsilon) {
+ if (typeof epsilon === "undefined") {
+ epsilon = 1e-6;
+ }
+ var t03, t13, t23, x2, i;
+ for (t23 = x, i = 0; i < 8; i++) {
+ x2 = this.sampleCurveX(t23) - x;
+ if (Math.abs(x2) < epsilon) {
+ return t23;
+ }
+ var d2 = this.sampleCurveDerivativeX(t23);
+ if (Math.abs(d2) < 1e-6) {
+ break;
+ }
+ t23 = t23 - x2 / d2;
+ }
+ t03 = 0;
+ t13 = 1;
+ t23 = x;
+ if (t23 < t03) {
+ return t03;
+ }
+ if (t23 > t13) {
+ return t13;
+ }
+ while (t03 < t13) {
+ x2 = this.sampleCurveX(t23);
+ if (Math.abs(x2 - x) < epsilon) {
+ return t23;
+ }
+ if (x > x2) {
+ t03 = t23;
+ } else {
+ t13 = t23;
+ }
+ t23 = (t13 - t03) * 0.5 + t03;
+ }
+ return t23;
+ };
+ UnitBezier.prototype.solve = function(x, epsilon) {
+ return this.sampleCurveY(this.solveCurveX(x, epsilon));
+ };
+ var pointGeometry = 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);
+ },
+ 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 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;
+ }
+ };
+ Point.convert = function(a) {
+ if (a instanceof Point) {
+ return a;
+ }
+ if (Array.isArray(a)) {
+ return new Point(a[0], a[1]);
+ }
+ return a;
+ };
+ var window$1 = typeof self !== "undefined" ? self : {};
+ function deepEqual(a, b) {
+ if (Array.isArray(a)) {
+ if (!Array.isArray(b) || a.length !== b.length) {
+ return false;
+ }
+ for (var i = 0; i < a.length; i++) {
+ if (!deepEqual(a[i], b[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ if (typeof a === "object" && a !== null && b !== null) {
+ if (!(typeof b === "object")) {
+ return false;
+ }
+ var keys = Object.keys(a);
+ if (keys.length !== Object.keys(b).length) {
+ return false;
+ }
+ for (var key in a) {
+ if (!deepEqual(a[key], b[key])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return a === b;
+ }
+ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
+ function easeCubicInOut(t) {
+ if (t <= 0) {
+ return 0;
+ }
+ if (t >= 1) {
+ return 1;
+ }
+ var t23 = t * t, t33 = t23 * t;
+ return 4 * (t < 0.5 ? t33 : 3 * (t - t23) + t33 - 0.75);
+ }
+ function bezier(p1x, p1y, p2x, p2y) {
+ var bezier2 = new unitbezier(p1x, p1y, p2x, p2y);
+ return function(t) {
+ return bezier2.solve(t);
+ };
+ }
+ var ease = bezier(0.25, 0.1, 0.25, 1);
+ function clamp(n, min, max) {
+ return Math.min(max, Math.max(min, n));
+ }
+ function wrap(n, min, max) {
+ var d = max - min;
+ var w = ((n - min) % d + d) % d + min;
+ return w === min ? max : w;
+ }
+ function asyncAll(array2, fn, callback) {
+ if (!array2.length) {
+ return callback(null, []);
+ }
+ var remaining = array2.length;
+ var results = new Array(array2.length);
+ var error2 = null;
+ array2.forEach(function(item, i) {
+ fn(item, function(err, result) {
+ if (err) {
+ error2 = err;
+ }
+ results[i] = result;
+ if (--remaining === 0) {
+ callback(error2, results);
+ }
+ });
+ });
+ }
+ function values(obj) {
+ var result = [];
+ for (var k in obj) {
+ result.push(obj[k]);
+ }
+ return result;
+ }
+ function keysDifference(obj, other) {
+ var difference = [];
+ for (var i in obj) {
+ if (!(i in other)) {
+ difference.push(i);
+ }
+ }
+ return difference;
+ }
+ function extend2(dest) {
+ var sources2 = [], len = arguments.length - 1;
+ while (len-- > 0)
+ sources2[len] = arguments[len + 1];
+ for (var i = 0, list = sources2; i < list.length; i += 1) {
+ var src = list[i];
+ for (var k in src) {
+ dest[k] = src[k];
+ }
+ }
+ return dest;
+ }
+ function pick(src, properties2) {
+ var result = {};
+ for (var i = 0; i < properties2.length; i++) {
+ var k = properties2[i];
+ if (k in src) {
+ result[k] = src[k];
+ }
+ }
+ return result;
+ }
+ var id = 1;
+ function uniqueId() {
+ return id++;
+ }
+ function uuid() {
+ function b(a) {
+ return a ? (a ^ Math.random() * 16 >> a / 4).toString(16) : ([1e7] + -[1e3] + -4e3 + -8e3 + -1e11).replace(/[018]/g, b);
+ }
+ return b();
+ }
+ function nextPowerOfTwo(value) {
+ if (value <= 1) {
+ return 1;
+ }
+ return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
+ }
+ function validateUuid(str) {
+ return str ? /^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(str) : false;
+ }
+ function bindAll(fns, context) {
+ fns.forEach(function(fn) {
+ if (!context[fn]) {
+ return;
+ }
+ context[fn] = context[fn].bind(context);
+ });
+ }
+ function endsWith(string, suffix) {
+ return string.indexOf(suffix, string.length - suffix.length) !== -1;
+ }
+ function mapObject(input, iterator, context) {
+ var output = {};
+ for (var key in input) {
+ output[key] = iterator.call(context || this, input[key], key, input);
+ }
+ return output;
+ }
+ function filterObject(input, iterator, context) {
+ var output = {};
+ for (var key in input) {
+ if (iterator.call(context || this, input[key], key, input)) {
+ output[key] = input[key];
+ }
+ }
+ return output;
+ }
+ function clone(input) {
+ if (Array.isArray(input)) {
+ return input.map(clone);
+ } else if (typeof input === "object" && input) {
+ return mapObject(input, clone);
+ } else {
+ return input;
+ }
+ }
+ function arraysIntersect(a, b) {
+ for (var l = 0; l < a.length; l++) {
+ if (b.indexOf(a[l]) >= 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+ var warnOnceHistory = {};
+ function warnOnce(message) {
+ if (!warnOnceHistory[message]) {
+ if (typeof console !== "undefined") {
+ console.warn(message);
+ }
+ warnOnceHistory[message] = true;
+ }
+ }
+ function isCounterClockwise(a, b, c) {
+ return (c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x);
+ }
+ function calculateSignedArea(ring) {
+ var sum = 0;
+ for (var i = 0, len = ring.length, j = len - 1, p1 = void 0, p2 = void 0; i < len; j = i++) {
+ p1 = ring[i];
+ p2 = ring[j];
+ sum += (p2.x - p1.x) * (p1.y + p2.y);
+ }
+ return sum;
+ }
+ function sphericalToCartesian(ref) {
+ var r = ref[0];
+ var azimuthal = ref[1];
+ var polar = ref[2];
+ azimuthal += 90;
+ azimuthal *= Math.PI / 180;
+ polar *= Math.PI / 180;
+ return {
+ x: r * Math.cos(azimuthal) * Math.sin(polar),
+ y: r * Math.sin(azimuthal) * Math.sin(polar),
+ z: r * Math.cos(polar)
+ };
+ }
+ function isWorker() {
+ return typeof WorkerGlobalScope !== "undefined" && typeof self !== "undefined" && self instanceof WorkerGlobalScope;
+ }
+ function parseCacheControl(cacheControl) {
+ var re = /(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g;
+ var header = {};
+ cacheControl.replace(re, function($0, $1, $2, $3) {
+ var value = $2 || $3;
+ header[$1] = value ? value.toLowerCase() : true;
+ return "";
+ });
+ if (header["max-age"]) {
+ var maxAge = parseInt(header["max-age"], 10);
+ if (isNaN(maxAge)) {
+ delete header["max-age"];
+ } else {
+ header["max-age"] = maxAge;
+ }
+ }
+ return header;
+ }
+ var _isSafari = null;
+ function isSafari(scope) {
+ if (_isSafari == null) {
+ var userAgent = scope.navigator ? scope.navigator.userAgent : null;
+ _isSafari = !!scope.safari || !!(userAgent && (/\b(iPad|iPhone|iPod)\b/.test(userAgent) || !!userAgent.match("Safari") && !userAgent.match("Chrome")));
+ }
+ return _isSafari;
+ }
+ function storageAvailable(type) {
+ try {
+ var storage = window$1[type];
+ storage.setItem("_mapbox_test_", 1);
+ storage.removeItem("_mapbox_test_");
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+ function b64EncodeUnicode(str) {
+ return window$1.btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
+ return String.fromCharCode(Number("0x" + p1));
+ }));
+ }
+ function b64DecodeUnicode(str) {
+ return decodeURIComponent(window$1.atob(str).split("").map(function(c) {
+ return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
+ }).join(""));
+ }
+ var now = window$1.performance && window$1.performance.now ? window$1.performance.now.bind(window$1.performance) : Date.now.bind(Date);
+ var raf = window$1.requestAnimationFrame || window$1.mozRequestAnimationFrame || window$1.webkitRequestAnimationFrame || window$1.msRequestAnimationFrame;
+ var cancel = window$1.cancelAnimationFrame || window$1.mozCancelAnimationFrame || window$1.webkitCancelAnimationFrame || window$1.msCancelAnimationFrame;
+ var linkEl;
+ var reducedMotionQuery;
+ var exported = {
+ now,
+ frame: function frame(fn) {
+ var frame2 = raf(fn);
+ return {
+ cancel: function() {
+ return cancel(frame2);
+ }
+ };
+ },
+ getImageData: function getImageData(img, padding) {
+ if (padding === void 0)
+ padding = 0;
+ var canvas = window$1.document.createElement("canvas");
+ var context = canvas.getContext("2d");
+ if (!context) {
+ throw new Error("failed to create canvas 2d context");
+ }
+ canvas.width = img.width;
+ canvas.height = img.height;
+ context.drawImage(img, 0, 0, img.width, img.height);
+ return context.getImageData(-padding, -padding, img.width + 2 * padding, img.height + 2 * padding);
+ },
+ resolveURL: function resolveURL(path) {
+ if (!linkEl) {
+ linkEl = window$1.document.createElement("a");
+ }
+ linkEl.href = path;
+ return linkEl.href;
+ },
+ hardwareConcurrency: window$1.navigator && window$1.navigator.hardwareConcurrency || 4,
+ get devicePixelRatio() {
+ return window$1.devicePixelRatio;
+ },
+ get prefersReducedMotion() {
+ if (!window$1.matchMedia) {
+ return false;
+ }
+ if (reducedMotionQuery == null) {
+ reducedMotionQuery = window$1.matchMedia("(prefers-reduced-motion: reduce)");
+ }
+ return reducedMotionQuery.matches;
+ }
+ };
+ var config = {
+ API_URL: "https://api.mapbox.com",
+ get EVENTS_URL() {
+ if (!this.API_URL) {
+ return null;
+ }
+ if (this.API_URL.indexOf("https://api.mapbox.cn") === 0) {
+ return "https://events.mapbox.cn/events/v2";
+ } else if (this.API_URL.indexOf("https://api.mapbox.com") === 0) {
+ return "https://events.mapbox.com/events/v2";
+ } else {
+ return null;
+ }
+ },
+ FEEDBACK_URL: "https://apps.mapbox.com/feedback",
+ REQUIRE_ACCESS_TOKEN: true,
+ ACCESS_TOKEN: null,
+ MAX_PARALLEL_IMAGE_REQUESTS: 16
+ };
+ var exported$1 = {
+ supported: false,
+ testSupport
+ };
+ var glForTesting;
+ var webpCheckComplete = false;
+ var webpImgTest;
+ var webpImgTestOnloadComplete = false;
+ if (window$1.document) {
+ webpImgTest = window$1.document.createElement("img");
+ webpImgTest.onload = function() {
+ if (glForTesting) {
+ testWebpTextureUpload(glForTesting);
+ }
+ glForTesting = null;
+ webpImgTestOnloadComplete = true;
+ };
+ webpImgTest.onerror = function() {
+ webpCheckComplete = true;
+ glForTesting = null;
+ };
+ webpImgTest.src = "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=";
+ }
+ function testSupport(gl2) {
+ if (webpCheckComplete || !webpImgTest) {
+ return;
+ }
+ if (webpImgTestOnloadComplete) {
+ testWebpTextureUpload(gl2);
+ } else {
+ glForTesting = gl2;
+ }
+ }
+ function testWebpTextureUpload(gl2) {
+ var texture = gl2.createTexture();
+ gl2.bindTexture(gl2.TEXTURE_2D, texture);
+ try {
+ gl2.texImage2D(gl2.TEXTURE_2D, 0, gl2.RGBA, gl2.RGBA, gl2.UNSIGNED_BYTE, webpImgTest);
+ if (gl2.isContextLost()) {
+ return;
+ }
+ exported$1.supported = true;
+ } catch (e) {
+ }
+ gl2.deleteTexture(texture);
+ webpCheckComplete = true;
+ }
+ var SKU_ID = "01";
+ function createSkuToken() {
+ var TOKEN_VERSION = "1";
+ var base62chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ var sessionRandomizer = "";
+ for (var i = 0; i < 10; i++) {
+ sessionRandomizer += base62chars[Math.floor(Math.random() * 62)];
+ }
+ var expiration = 12 * 60 * 60 * 1e3;
+ var token = [
+ TOKEN_VERSION,
+ SKU_ID,
+ sessionRandomizer
+ ].join("");
+ var tokenExpiresAt = Date.now() + expiration;
+ return {
+ token,
+ tokenExpiresAt
+ };
+ }
+ var RequestManager = function RequestManager2(transformRequestFn, customAccessToken) {
+ this._transformRequestFn = transformRequestFn;
+ this._customAccessToken = customAccessToken;
+ this._createSkuToken();
+ };
+ RequestManager.prototype._createSkuToken = function _createSkuToken() {
+ var skuToken = createSkuToken();
+ this._skuToken = skuToken.token;
+ this._skuTokenExpiresAt = skuToken.tokenExpiresAt;
+ };
+ RequestManager.prototype._isSkuTokenExpired = function _isSkuTokenExpired() {
+ return Date.now() > this._skuTokenExpiresAt;
+ };
+ RequestManager.prototype.transformRequest = function transformRequest(url, type) {
+ if (this._transformRequestFn) {
+ return this._transformRequestFn(url, type) || { url };
+ }
+ return { url };
+ };
+ RequestManager.prototype.normalizeStyleURL = function normalizeStyleURL(url, accessToken) {
+ if (!isMapboxURL(url)) {
+ return url;
+ }
+ var urlObject = parseUrl(url);
+ urlObject.path = "/styles/v1" + urlObject.path;
+ return this._makeAPIURL(urlObject, this._customAccessToken || accessToken);
+ };
+ RequestManager.prototype.normalizeGlyphsURL = function normalizeGlyphsURL(url, accessToken) {
+ if (!isMapboxURL(url)) {
+ return url;
+ }
+ var urlObject = parseUrl(url);
+ urlObject.path = "/fonts/v1" + urlObject.path;
+ return this._makeAPIURL(urlObject, this._customAccessToken || accessToken);
+ };
+ RequestManager.prototype.normalizeSourceURL = function normalizeSourceURL(url, accessToken) {
+ if (!isMapboxURL(url)) {
+ return url;
+ }
+ var urlObject = parseUrl(url);
+ urlObject.path = "/v4/" + urlObject.authority + ".json";
+ urlObject.params.push("secure");
+ return this._makeAPIURL(urlObject, this._customAccessToken || accessToken);
+ };
+ RequestManager.prototype.normalizeSpriteURL = function normalizeSpriteURL(url, format, extension, accessToken) {
+ var urlObject = parseUrl(url);
+ if (!isMapboxURL(url)) {
+ urlObject.path += "" + format + extension;
+ return formatUrl(urlObject);
+ }
+ urlObject.path = "/styles/v1" + urlObject.path + "/sprite" + format + extension;
+ return this._makeAPIURL(urlObject, this._customAccessToken || accessToken);
+ };
+ RequestManager.prototype.normalizeTileURL = function normalizeTileURL(tileURL, tileSize) {
+ if (this._isSkuTokenExpired()) {
+ this._createSkuToken();
+ }
+ if (tileURL && !isMapboxURL(tileURL)) {
+ return tileURL;
+ }
+ var urlObject = parseUrl(tileURL);
+ var imageExtensionRe = /(\.(png|jpg)\d*)(?=$)/;
+ var tileURLAPIPrefixRe = /^.+\/v4\//;
+ var suffix = exported.devicePixelRatio >= 2 || tileSize === 512 ? "@2x" : "";
+ var extension = exported$1.supported ? ".webp" : "$1";
+ urlObject.path = urlObject.path.replace(imageExtensionRe, "" + suffix + extension);
+ urlObject.path = urlObject.path.replace(tileURLAPIPrefixRe, "/");
+ urlObject.path = "/v4" + urlObject.path;
+ var accessToken = this._customAccessToken || getAccessToken(urlObject.params) || config.ACCESS_TOKEN;
+ if (config.REQUIRE_ACCESS_TOKEN && accessToken && this._skuToken) {
+ urlObject.params.push("sku=" + this._skuToken);
+ }
+ return this._makeAPIURL(urlObject, accessToken);
+ };
+ RequestManager.prototype.canonicalizeTileURL = function canonicalizeTileURL(url, removeAccessToken) {
+ var version2 = "/v4/";
+ var extensionRe = /\.[\w]+$/;
+ var urlObject = parseUrl(url);
+ if (!urlObject.path.match(/(^\/v4\/)/) || !urlObject.path.match(extensionRe)) {
+ return url;
+ }
+ var result = "mapbox://tiles/";
+ result += urlObject.path.replace(version2, "");
+ var params = urlObject.params;
+ if (removeAccessToken) {
+ params = params.filter(function(p) {
+ return !p.match(/^access_token=/);
+ });
+ }
+ if (params.length) {
+ result += "?" + params.join("&");
+ }
+ return result;
+ };
+ RequestManager.prototype.canonicalizeTileset = function canonicalizeTileset(tileJSON, sourceURL) {
+ var removeAccessToken = sourceURL ? isMapboxURL(sourceURL) : false;
+ var canonical = [];
+ for (var i = 0, list = tileJSON.tiles || []; i < list.length; i += 1) {
+ var url = list[i];
+ if (isMapboxHTTPURL(url)) {
+ canonical.push(this.canonicalizeTileURL(url, removeAccessToken));
+ } else {
+ canonical.push(url);
+ }
+ }
+ return canonical;
+ };
+ RequestManager.prototype._makeAPIURL = function _makeAPIURL(urlObject, accessToken) {
+ var help = "See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes";
+ var apiUrlObject = parseUrl(config.API_URL);
+ urlObject.protocol = apiUrlObject.protocol;
+ urlObject.authority = apiUrlObject.authority;
+ if (urlObject.protocol === "http") {
+ var i = urlObject.params.indexOf("secure");
+ if (i >= 0) {
+ urlObject.params.splice(i, 1);
+ }
+ }
+ if (apiUrlObject.path !== "/") {
+ urlObject.path = "" + apiUrlObject.path + urlObject.path;
+ }
+ if (!config.REQUIRE_ACCESS_TOKEN) {
+ return formatUrl(urlObject);
+ }
+ accessToken = accessToken || config.ACCESS_TOKEN;
+ if (!accessToken) {
+ throw new Error("An API access token is required to use Mapbox GL. " + help);
+ }
+ if (accessToken[0] === "s") {
+ throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). " + help);
+ }
+ urlObject.params = urlObject.params.filter(function(d) {
+ return d.indexOf("access_token") === -1;
+ });
+ urlObject.params.push("access_token=" + accessToken);
+ return formatUrl(urlObject);
+ };
+ function isMapboxURL(url) {
+ return url.indexOf("mapbox:") === 0;
+ }
+ var mapboxHTTPURLRe = /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;
+ function isMapboxHTTPURL(url) {
+ return mapboxHTTPURLRe.test(url);
+ }
+ function hasCacheDefeatingSku(url) {
+ return url.indexOf("sku=") > 0 && isMapboxHTTPURL(url);
+ }
+ function getAccessToken(params) {
+ for (var i = 0, list = params; i < list.length; i += 1) {
+ var param = list[i];
+ var match = param.match(/^access_token=(.*)$/);
+ if (match) {
+ return match[1];
+ }
+ }
+ return null;
+ }
+ var urlRe = /^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;
+ function parseUrl(url) {
+ var parts = url.match(urlRe);
+ if (!parts) {
+ throw new Error("Unable to parse URL object");
+ }
+ return {
+ protocol: parts[1],
+ authority: parts[2],
+ path: parts[3] || "/",
+ params: parts[4] ? parts[4].split("&") : []
+ };
+ }
+ function formatUrl(obj) {
+ var params = obj.params.length ? "?" + obj.params.join("&") : "";
+ return obj.protocol + "://" + obj.authority + obj.path + params;
+ }
+ var telemEventKey = "mapbox.eventData";
+ function parseAccessToken(accessToken) {
+ if (!accessToken) {
+ return null;
+ }
+ var parts = accessToken.split(".");
+ if (!parts || parts.length !== 3) {
+ return null;
+ }
+ try {
+ var jsonData = JSON.parse(b64DecodeUnicode(parts[1]));
+ return jsonData;
+ } catch (e) {
+ return null;
+ }
+ }
+ var TelemetryEvent = function TelemetryEvent2(type) {
+ this.type = type;
+ this.anonId = null;
+ this.eventData = {};
+ this.queue = [];
+ this.pendingRequest = null;
+ };
+ TelemetryEvent.prototype.getStorageKey = function getStorageKey(domain) {
+ var tokenData = parseAccessToken(config.ACCESS_TOKEN);
+ var u = "";
+ if (tokenData && tokenData["u"]) {
+ u = b64EncodeUnicode(tokenData["u"]);
+ } else {
+ u = config.ACCESS_TOKEN || "";
+ }
+ return domain ? telemEventKey + "." + domain + ":" + u : telemEventKey + ":" + u;
+ };
+ TelemetryEvent.prototype.fetchEventData = function fetchEventData() {
+ var isLocalStorageAvailable = storageAvailable("localStorage");
+ var storageKey = this.getStorageKey();
+ var uuidKey = this.getStorageKey("uuid");
+ if (isLocalStorageAvailable) {
+ try {
+ var data = window$1.localStorage.getItem(storageKey);
+ if (data) {
+ this.eventData = JSON.parse(data);
+ }
+ var uuid2 = window$1.localStorage.getItem(uuidKey);
+ if (uuid2) {
+ this.anonId = uuid2;
+ }
+ } catch (e) {
+ warnOnce("Unable to read from LocalStorage");
+ }
+ }
+ };
+ TelemetryEvent.prototype.saveEventData = function saveEventData() {
+ var isLocalStorageAvailable = storageAvailable("localStorage");
+ var storageKey = this.getStorageKey();
+ var uuidKey = this.getStorageKey("uuid");
+ if (isLocalStorageAvailable) {
+ try {
+ window$1.localStorage.setItem(uuidKey, this.anonId);
+ if (Object.keys(this.eventData).length >= 1) {
+ window$1.localStorage.setItem(storageKey, JSON.stringify(this.eventData));
+ }
+ } catch (e) {
+ warnOnce("Unable to write to LocalStorage");
+ }
+ }
+ };
+ TelemetryEvent.prototype.processRequests = function processRequests(_) {
+ };
+ TelemetryEvent.prototype.postEvent = function postEvent(timestamp, additionalPayload, callback, customAccessToken) {
+ var this$1 = this;
+ if (!config.EVENTS_URL) {
+ return;
+ }
+ var eventsUrlObject = parseUrl(config.EVENTS_URL);
+ eventsUrlObject.params.push("access_token=" + (customAccessToken || config.ACCESS_TOKEN || ""));
+ var payload = {
+ event: this.type,
+ created: new Date(timestamp).toISOString(),
+ sdkIdentifier: "mapbox-gl-js",
+ sdkVersion: version,
+ skuId: SKU_ID,
+ userId: this.anonId
+ };
+ var finalPayload = additionalPayload ? extend2(payload, additionalPayload) : payload;
+ var request = {
+ url: formatUrl(eventsUrlObject),
+ headers: { "Content-Type": "text/plain" },
+ body: JSON.stringify([finalPayload])
+ };
+ this.pendingRequest = postData(request, function(error2) {
+ this$1.pendingRequest = null;
+ callback(error2);
+ this$1.saveEventData();
+ this$1.processRequests(customAccessToken);
+ });
+ };
+ TelemetryEvent.prototype.queueRequest = function queueRequest(event, customAccessToken) {
+ this.queue.push(event);
+ this.processRequests(customAccessToken);
+ };
+ var MapLoadEvent = function(TelemetryEvent2) {
+ function MapLoadEvent2() {
+ TelemetryEvent2.call(this, "map.load");
+ this.success = {};
+ this.skuToken = "";
+ }
+ if (TelemetryEvent2)
+ MapLoadEvent2.__proto__ = TelemetryEvent2;
+ MapLoadEvent2.prototype = Object.create(TelemetryEvent2 && TelemetryEvent2.prototype);
+ MapLoadEvent2.prototype.constructor = MapLoadEvent2;
+ MapLoadEvent2.prototype.postMapLoadEvent = function postMapLoadEvent2(tileUrls, mapId, skuToken, customAccessToken) {
+ this.skuToken = skuToken;
+ if (config.EVENTS_URL && customAccessToken || config.ACCESS_TOKEN && Array.isArray(tileUrls) && tileUrls.some(function(url) {
+ return isMapboxURL(url) || isMapboxHTTPURL(url);
+ })) {
+ this.queueRequest({
+ id: mapId,
+ timestamp: Date.now()
+ }, customAccessToken);
+ }
+ };
+ MapLoadEvent2.prototype.processRequests = function processRequests(customAccessToken) {
+ var this$1 = this;
+ if (this.pendingRequest || this.queue.length === 0) {
+ return;
+ }
+ var ref = this.queue.shift();
+ var id2 = ref.id;
+ var timestamp = ref.timestamp;
+ if (id2 && this.success[id2]) {
+ return;
+ }
+ if (!this.anonId) {
+ this.fetchEventData();
+ }
+ if (!validateUuid(this.anonId)) {
+ this.anonId = uuid();
+ }
+ this.postEvent(timestamp, { skuToken: this.skuToken }, function(err) {
+ if (!err) {
+ if (id2) {
+ this$1.success[id2] = true;
+ }
+ }
+ }, customAccessToken);
+ };
+ return MapLoadEvent2;
+ }(TelemetryEvent);
+ var TurnstileEvent = function(TelemetryEvent2) {
+ function TurnstileEvent2(customAccessToken) {
+ TelemetryEvent2.call(this, "appUserTurnstile");
+ this._customAccessToken = customAccessToken;
+ }
+ if (TelemetryEvent2)
+ TurnstileEvent2.__proto__ = TelemetryEvent2;
+ TurnstileEvent2.prototype = Object.create(TelemetryEvent2 && TelemetryEvent2.prototype);
+ TurnstileEvent2.prototype.constructor = TurnstileEvent2;
+ TurnstileEvent2.prototype.postTurnstileEvent = function postTurnstileEvent2(tileUrls, customAccessToken) {
+ if (config.EVENTS_URL && config.ACCESS_TOKEN && Array.isArray(tileUrls) && tileUrls.some(function(url) {
+ return isMapboxURL(url) || isMapboxHTTPURL(url);
+ })) {
+ this.queueRequest(Date.now(), customAccessToken);
+ }
+ };
+ TurnstileEvent2.prototype.processRequests = function processRequests(customAccessToken) {
+ var this$1 = this;
+ if (this.pendingRequest || this.queue.length === 0) {
+ return;
+ }
+ if (!this.anonId || !this.eventData.lastSuccess || !this.eventData.tokenU) {
+ this.fetchEventData();
+ }
+ var tokenData = parseAccessToken(config.ACCESS_TOKEN);
+ var tokenU = tokenData ? tokenData["u"] : config.ACCESS_TOKEN;
+ var dueForEvent = tokenU !== this.eventData.tokenU;
+ if (!validateUuid(this.anonId)) {
+ this.anonId = uuid();
+ dueForEvent = true;
+ }
+ var nextUpdate = this.queue.shift();
+ if (this.eventData.lastSuccess) {
+ var lastUpdate = new Date(this.eventData.lastSuccess);
+ var nextDate = new Date(nextUpdate);
+ var daysElapsed = (nextUpdate - this.eventData.lastSuccess) / (24 * 60 * 60 * 1e3);
+ dueForEvent = dueForEvent || daysElapsed >= 1 || daysElapsed < -1 || lastUpdate.getDate() !== nextDate.getDate();
+ } else {
+ dueForEvent = true;
+ }
+ if (!dueForEvent) {
+ return this.processRequests();
+ }
+ this.postEvent(nextUpdate, { "enabled.telemetry": false }, function(err) {
+ if (!err) {
+ this$1.eventData.lastSuccess = nextUpdate;
+ this$1.eventData.tokenU = tokenU;
+ }
+ }, customAccessToken);
+ };
+ return TurnstileEvent2;
+ }(TelemetryEvent);
+ var turnstileEvent_ = new TurnstileEvent();
+ var postTurnstileEvent = turnstileEvent_.postTurnstileEvent.bind(turnstileEvent_);
+ var mapLoadEvent_ = new MapLoadEvent();
+ var postMapLoadEvent = mapLoadEvent_.postMapLoadEvent.bind(mapLoadEvent_);
+ var CACHE_NAME = "mapbox-tiles";
+ var cacheLimit = 500;
+ var cacheCheckThreshold = 50;
+ var MIN_TIME_UNTIL_EXPIRY = 1e3 * 60 * 7;
+ var sharedCache;
+ function cacheOpen() {
+ if (window$1.caches && !sharedCache) {
+ sharedCache = window$1.caches.open(CACHE_NAME);
+ }
+ }
+ var responseConstructorSupportsReadableStream;
+ function prepareBody(response, callback) {
+ if (responseConstructorSupportsReadableStream === void 0) {
+ try {
+ new Response(new ReadableStream());
+ responseConstructorSupportsReadableStream = true;
+ } catch (e) {
+ responseConstructorSupportsReadableStream = false;
+ }
+ }
+ if (responseConstructorSupportsReadableStream) {
+ callback(response.body);
+ } else {
+ response.blob().then(callback);
+ }
+ }
+ function cachePut(request, response, requestTime) {
+ cacheOpen();
+ if (!sharedCache) {
+ return;
+ }
+ var options = {
+ status: response.status,
+ statusText: response.statusText,
+ headers: new window$1.Headers()
+ };
+ response.headers.forEach(function(v, k) {
+ return options.headers.set(k, v);
+ });
+ var cacheControl = parseCacheControl(response.headers.get("Cache-Control") || "");
+ if (cacheControl["no-store"]) {
+ return;
+ }
+ if (cacheControl["max-age"]) {
+ options.headers.set("Expires", new Date(requestTime + cacheControl["max-age"] * 1e3).toUTCString());
+ }
+ var timeUntilExpiry = new Date(options.headers.get("Expires")).getTime() - requestTime;
+ if (timeUntilExpiry < MIN_TIME_UNTIL_EXPIRY) {
+ return;
+ }
+ prepareBody(response, function(body) {
+ var clonedResponse = new window$1.Response(body, options);
+ cacheOpen();
+ if (!sharedCache) {
+ return;
+ }
+ sharedCache.then(function(cache) {
+ return cache.put(stripQueryParameters(request.url), clonedResponse);
+ }).catch(function(e) {
+ return warnOnce(e.message);
+ });
+ });
+ }
+ function stripQueryParameters(url) {
+ var start = url.indexOf("?");
+ return start < 0 ? url : url.slice(0, start);
+ }
+ function cacheGet(request, callback) {
+ cacheOpen();
+ if (!sharedCache) {
+ return callback(null);
+ }
+ var strippedURL = stripQueryParameters(request.url);
+ sharedCache.then(function(cache) {
+ cache.match(strippedURL).then(function(response) {
+ var fresh = isFresh(response);
+ cache.delete(strippedURL);
+ if (fresh) {
+ cache.put(strippedURL, response.clone());
+ }
+ callback(null, response, fresh);
+ }).catch(callback);
+ }).catch(callback);
+ }
+ function isFresh(response) {
+ if (!response) {
+ return false;
+ }
+ var expires = new Date(response.headers.get("Expires") || 0);
+ var cacheControl = parseCacheControl(response.headers.get("Cache-Control") || "");
+ return expires > Date.now() && !cacheControl["no-cache"];
+ }
+ var globalEntryCounter = Infinity;
+ function cacheEntryPossiblyAdded(dispatcher) {
+ globalEntryCounter++;
+ if (globalEntryCounter > cacheCheckThreshold) {
+ dispatcher.getActor().send("enforceCacheSizeLimit", cacheLimit);
+ globalEntryCounter = 0;
+ }
+ }
+ function enforceCacheSizeLimit(limit) {
+ cacheOpen();
+ if (!sharedCache) {
+ return;
+ }
+ sharedCache.then(function(cache) {
+ cache.keys().then(function(keys) {
+ for (var i = 0; i < keys.length - limit; i++) {
+ cache.delete(keys[i]);
+ }
+ });
+ });
+ }
+ function clearTileCache(callback) {
+ var promise = window$1.caches.delete(CACHE_NAME);
+ if (callback) {
+ promise.catch(callback).then(function() {
+ return callback();
+ });
+ }
+ }
+ function setCacheLimits(limit, checkThreshold) {
+ cacheLimit = limit;
+ cacheCheckThreshold = checkThreshold;
+ }
+ var supportsOffscreenCanvas;
+ function offscreenCanvasSupported() {
+ if (supportsOffscreenCanvas == null) {
+ supportsOffscreenCanvas = window$1.OffscreenCanvas && new window$1.OffscreenCanvas(1, 1).getContext("2d") && typeof window$1.createImageBitmap === "function";
+ }
+ return supportsOffscreenCanvas;
+ }
+ var ResourceType = {
+ Unknown: "Unknown",
+ Style: "Style",
+ Source: "Source",
+ Tile: "Tile",
+ Glyphs: "Glyphs",
+ SpriteImage: "SpriteImage",
+ SpriteJSON: "SpriteJSON",
+ Image: "Image"
+ };
+ if (typeof Object.freeze == "function") {
+ Object.freeze(ResourceType);
+ }
+ var AJAXError = function(Error2) {
+ function AJAXError2(message, status2, url) {
+ if (status2 === 401 && isMapboxHTTPURL(url)) {
+ message += ": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes";
+ }
+ Error2.call(this, message);
+ this.status = status2;
+ this.url = url;
+ this.name = this.constructor.name;
+ this.message = message;
+ }
+ if (Error2)
+ AJAXError2.__proto__ = Error2;
+ AJAXError2.prototype = Object.create(Error2 && Error2.prototype);
+ AJAXError2.prototype.constructor = AJAXError2;
+ AJAXError2.prototype.toString = function toString2() {
+ return this.name + ": " + this.message + " (" + this.status + "): " + this.url;
+ };
+ return AJAXError2;
+ }(Error);
+ var getReferrer = isWorker() ? function() {
+ return self.worker && self.worker.referrer;
+ } : function() {
+ return (window$1.location.protocol === "blob:" ? window$1.parent : window$1).location.href;
+ };
+ var isFileURL = function(url) {
+ return /^file:/.test(url) || /^file:/.test(getReferrer()) && !/^\w+:/.test(url);
+ };
+ function makeFetchRequest(requestParameters, callback) {
+ var controller = new window$1.AbortController();
+ var request = new window$1.Request(requestParameters.url, {
+ method: requestParameters.method || "GET",
+ body: requestParameters.body,
+ credentials: requestParameters.credentials,
+ headers: requestParameters.headers,
+ referrer: getReferrer(),
+ signal: controller.signal
+ });
+ var complete = false;
+ var aborted = false;
+ var cacheIgnoringSearch = hasCacheDefeatingSku(request.url);
+ if (requestParameters.type === "json") {
+ request.headers.set("Accept", "application/json");
+ }
+ var validateOrFetch = function(err, cachedResponse, responseIsFresh) {
+ if (aborted) {
+ return;
+ }
+ if (err) {
+ if (err.message !== "SecurityError") {
+ warnOnce(err);
+ }
+ }
+ if (cachedResponse && responseIsFresh) {
+ return finishRequest(cachedResponse);
+ }
+ var requestTime = Date.now();
+ window$1.fetch(request).then(function(response) {
+ if (response.ok) {
+ var cacheableResponse = cacheIgnoringSearch ? response.clone() : null;
+ return finishRequest(response, cacheableResponse, requestTime);
+ } else {
+ return callback(new AJAXError(response.statusText, response.status, requestParameters.url));
+ }
+ }).catch(function(error2) {
+ if (error2.code === 20) {
+ return;
+ }
+ callback(new Error(error2.message));
+ });
+ };
+ var finishRequest = function(response, cacheableResponse, requestTime) {
+ (requestParameters.type === "arrayBuffer" ? response.arrayBuffer() : requestParameters.type === "json" ? response.json() : response.text()).then(function(result) {
+ if (aborted) {
+ return;
+ }
+ if (cacheableResponse && requestTime) {
+ cachePut(request, cacheableResponse, requestTime);
+ }
+ complete = true;
+ callback(null, result, response.headers.get("Cache-Control"), response.headers.get("Expires"));
+ }).catch(function(err) {
+ if (!aborted) {
+ callback(new Error(err.message));
+ }
+ });
+ };
+ if (cacheIgnoringSearch) {
+ cacheGet(request, validateOrFetch);
+ } else {
+ validateOrFetch(null, null);
+ }
+ return {
+ cancel: function() {
+ aborted = true;
+ if (!complete) {
+ controller.abort();
+ }
+ }
+ };
+ }
+ function makeXMLHttpRequest(requestParameters, callback) {
+ var xhr = new window$1.XMLHttpRequest();
+ xhr.open(requestParameters.method || "GET", requestParameters.url, true);
+ if (requestParameters.type === "arrayBuffer") {
+ xhr.responseType = "arraybuffer";
+ }
+ for (var k in requestParameters.headers) {
+ xhr.setRequestHeader(k, requestParameters.headers[k]);
+ }
+ if (requestParameters.type === "json") {
+ xhr.responseType = "text";
+ xhr.setRequestHeader("Accept", "application/json");
+ }
+ xhr.withCredentials = requestParameters.credentials === "include";
+ xhr.onerror = function() {
+ callback(new Error(xhr.statusText));
+ };
+ xhr.onload = function() {
+ if ((xhr.status >= 200 && xhr.status < 300 || xhr.status === 0) && xhr.response !== null) {
+ var data = xhr.response;
+ if (requestParameters.type === "json") {
+ try {
+ data = JSON.parse(xhr.response);
+ } catch (err) {
+ return callback(err);
+ }
+ }
+ callback(null, data, xhr.getResponseHeader("Cache-Control"), xhr.getResponseHeader("Expires"));
+ } else {
+ callback(new AJAXError(xhr.statusText, xhr.status, requestParameters.url));
+ }
+ };
+ xhr.send(requestParameters.body);
+ return {
+ cancel: function() {
+ return xhr.abort();
+ }
+ };
+ }
+ var makeRequest = function(requestParameters, callback) {
+ if (!isFileURL(requestParameters.url)) {
+ if (window$1.fetch && window$1.Request && window$1.AbortController && window$1.Request.prototype.hasOwnProperty("signal")) {
+ return makeFetchRequest(requestParameters, callback);
+ }
+ if (isWorker() && self.worker && self.worker.actor) {
+ var queueOnMainThread = true;
+ return self.worker.actor.send("getResource", requestParameters, callback, void 0, queueOnMainThread);
+ }
+ }
+ return makeXMLHttpRequest(requestParameters, callback);
+ };
+ var getJSON = function(requestParameters, callback) {
+ return makeRequest(extend2(requestParameters, { type: "json" }), callback);
+ };
+ var getArrayBuffer = function(requestParameters, callback) {
+ return makeRequest(extend2(requestParameters, { type: "arrayBuffer" }), callback);
+ };
+ var postData = function(requestParameters, callback) {
+ return makeRequest(extend2(requestParameters, { method: "POST" }), callback);
+ };
+ function sameOrigin(url) {
+ var a = window$1.document.createElement("a");
+ a.href = url;
+ return a.protocol === window$1.document.location.protocol && a.host === window$1.document.location.host;
+ }
+ var transparentPngUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";
+ function arrayBufferToImage(data, callback, cacheControl, expires) {
+ var img = new window$1.Image();
+ var URL2 = window$1.URL;
+ img.onload = function() {
+ callback(null, img);
+ URL2.revokeObjectURL(img.src);
+ img.onload = null;
+ window$1.requestAnimationFrame(function() {
+ img.src = transparentPngUrl;
+ });
+ };
+ img.onerror = function() {
+ return callback(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));
+ };
+ var blob = new window$1.Blob([new Uint8Array(data)], { type: "image/png" });
+ img.cacheControl = cacheControl;
+ img.expires = expires;
+ img.src = data.byteLength ? URL2.createObjectURL(blob) : transparentPngUrl;
+ }
+ function arrayBufferToImageBitmap(data, callback) {
+ var blob = new window$1.Blob([new Uint8Array(data)], { type: "image/png" });
+ window$1.createImageBitmap(blob).then(function(imgBitmap) {
+ callback(null, imgBitmap);
+ }).catch(function(e) {
+ callback(new Error("Could not load image because of " + e.message + ". Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));
+ });
+ }
+ var imageQueue, numImageRequests;
+ var resetImageRequestQueue = function() {
+ imageQueue = [];
+ numImageRequests = 0;
+ };
+ resetImageRequestQueue();
+ var getImage = function(requestParameters, callback) {
+ if (exported$1.supported) {
+ if (!requestParameters.headers) {
+ requestParameters.headers = {};
+ }
+ requestParameters.headers.accept = "image/webp,*/*";
+ }
+ if (numImageRequests >= config.MAX_PARALLEL_IMAGE_REQUESTS) {
+ var queued = {
+ requestParameters,
+ callback,
+ cancelled: false,
+ cancel: function cancel2() {
+ this.cancelled = true;
+ }
+ };
+ imageQueue.push(queued);
+ return queued;
+ }
+ numImageRequests++;
+ var advanced = false;
+ var advanceImageRequestQueue = function() {
+ if (advanced) {
+ return;
+ }
+ advanced = true;
+ numImageRequests--;
+ while (imageQueue.length && numImageRequests < config.MAX_PARALLEL_IMAGE_REQUESTS) {
+ var request2 = imageQueue.shift();
+ var requestParameters2 = request2.requestParameters;
+ var callback2 = request2.callback;
+ var cancelled = request2.cancelled;
+ if (!cancelled) {
+ request2.cancel = getImage(requestParameters2, callback2).cancel;
+ }
+ }
+ };
+ var request = getArrayBuffer(requestParameters, function(err, data, cacheControl, expires) {
+ advanceImageRequestQueue();
+ if (err) {
+ callback(err);
+ } else if (data) {
+ if (offscreenCanvasSupported()) {
+ arrayBufferToImageBitmap(data, callback);
+ } else {
+ arrayBufferToImage(data, callback, cacheControl, expires);
+ }
+ }
+ });
+ return {
+ cancel: function() {
+ request.cancel();
+ advanceImageRequestQueue();
+ }
+ };
+ };
+ var getVideo = function(urls, callback) {
+ var video = window$1.document.createElement("video");
+ video.muted = true;
+ video.onloadstart = function() {
+ callback(null, video);
+ };
+ for (var i = 0; i < urls.length; i++) {
+ var s = window$1.document.createElement("source");
+ if (!sameOrigin(urls[i])) {
+ video.crossOrigin = "Anonymous";
+ }
+ s.src = urls[i];
+ video.appendChild(s);
+ }
+ return {
+ cancel: function() {
+ }
+ };
+ };
+ function _addEventListener(type, listener, listenerList) {
+ var listenerExists = listenerList[type] && listenerList[type].indexOf(listener) !== -1;
+ if (!listenerExists) {
+ listenerList[type] = listenerList[type] || [];
+ listenerList[type].push(listener);
+ }
+ }
+ function _removeEventListener(type, listener, listenerList) {
+ if (listenerList && listenerList[type]) {
+ var index = listenerList[type].indexOf(listener);
+ if (index !== -1) {
+ listenerList[type].splice(index, 1);
+ }
+ }
+ }
+ var Event = function Event2(type, data) {
+ if (data === void 0)
+ data = {};
+ extend2(this, data);
+ this.type = type;
+ };
+ var ErrorEvent = function(Event2) {
+ function ErrorEvent2(error2, data) {
+ if (data === void 0)
+ data = {};
+ Event2.call(this, "error", extend2({ error: error2 }, data));
+ }
+ if (Event2)
+ ErrorEvent2.__proto__ = Event2;
+ ErrorEvent2.prototype = Object.create(Event2 && Event2.prototype);
+ ErrorEvent2.prototype.constructor = ErrorEvent2;
+ return ErrorEvent2;
+ }(Event);
+ var Evented = function Evented2() {
+ };
+ Evented.prototype.on = function on(type, listener) {
+ this._listeners = this._listeners || {};
+ _addEventListener(type, listener, this._listeners);
+ return this;
+ };
+ Evented.prototype.off = function off(type, listener) {
+ _removeEventListener(type, listener, this._listeners);
+ _removeEventListener(type, listener, this._oneTimeListeners);
+ return this;
+ };
+ Evented.prototype.once = function once(type, listener) {
+ this._oneTimeListeners = this._oneTimeListeners || {};
+ _addEventListener(type, listener, this._oneTimeListeners);
+ return this;
+ };
+ Evented.prototype.fire = function fire(event, properties2) {
+ if (typeof event === "string") {
+ event = new Event(event, properties2 || {});
+ }
+ var type = event.type;
+ if (this.listens(type)) {
+ event.target = this;
+ var listeners = this._listeners && this._listeners[type] ? this._listeners[type].slice() : [];
+ for (var i = 0, list = listeners; i < list.length; i += 1) {
+ var listener = list[i];
+ listener.call(this, event);
+ }
+ var oneTimeListeners = this._oneTimeListeners && this._oneTimeListeners[type] ? this._oneTimeListeners[type].slice() : [];
+ for (var i$1 = 0, list$1 = oneTimeListeners; i$1 < list$1.length; i$1 += 1) {
+ var listener$1 = list$1[i$1];
+ _removeEventListener(type, listener$1, this._oneTimeListeners);
+ listener$1.call(this, event);
+ }
+ var parent = this._eventedParent;
+ if (parent) {
+ extend2(event, typeof this._eventedParentData === "function" ? this._eventedParentData() : this._eventedParentData);
+ parent.fire(event);
+ }
+ } else if (event instanceof ErrorEvent) {
+ console.error(event.error);
+ }
+ return this;
+ };
+ Evented.prototype.listens = function listens(type) {
+ return this._listeners && this._listeners[type] && this._listeners[type].length > 0 || this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0 || this._eventedParent && this._eventedParent.listens(type);
+ };
+ Evented.prototype.setEventedParent = function setEventedParent(parent, data) {
+ this._eventedParent = parent;
+ this._eventedParentData = data;
+ return this;
+ };
+ var $version = 8;
+ var $root = {
+ version: {
+ required: true,
+ type: "enum",
+ values: [
+ 8
+ ]
+ },
+ name: {
+ type: "string"
+ },
+ metadata: {
+ type: "*"
+ },
+ center: {
+ type: "array",
+ value: "number"
+ },
+ zoom: {
+ type: "number"
+ },
+ bearing: {
+ type: "number",
+ "default": 0,
+ period: 360,
+ units: "degrees"
+ },
+ pitch: {
+ type: "number",
+ "default": 0,
+ units: "degrees"
+ },
+ light: {
+ type: "light"
+ },
+ sources: {
+ required: true,
+ type: "sources"
+ },
+ sprite: {
+ type: "string"
+ },
+ glyphs: {
+ type: "string"
+ },
+ transition: {
+ type: "transition"
+ },
+ layers: {
+ required: true,
+ type: "array",
+ value: "layer"
+ }
+ };
+ var sources = {
+ "*": {
+ type: "source"
+ }
+ };
+ var source = [
+ "source_vector",
+ "source_raster",
+ "source_raster_dem",
+ "source_geojson",
+ "source_video",
+ "source_image"
+ ];
+ var source_vector = {
+ type: {
+ required: true,
+ type: "enum",
+ values: {
+ vector: {}
+ }
+ },
+ url: {
+ type: "string"
+ },
+ tiles: {
+ type: "array",
+ value: "string"
+ },
+ bounds: {
+ type: "array",
+ value: "number",
+ length: 4,
+ "default": [
+ -180,
+ -85.051129,
+ 180,
+ 85.051129
+ ]
+ },
+ scheme: {
+ type: "enum",
+ values: {
+ xyz: {},
+ tms: {}
+ },
+ "default": "xyz"
+ },
+ minzoom: {
+ type: "number",
+ "default": 0
+ },
+ maxzoom: {
+ type: "number",
+ "default": 22
+ },
+ attribution: {
+ type: "string"
+ },
+ promoteId: {
+ type: "promoteId"
+ },
+ volatile: {
+ type: "boolean",
+ "default": false
+ },
+ "*": {
+ type: "*"
+ }
+ };
+ var source_raster = {
+ type: {
+ required: true,
+ type: "enum",
+ values: {
+ raster: {}
+ }
+ },
+ url: {
+ type: "string"
+ },
+ tiles: {
+ type: "array",
+ value: "string"
+ },
+ bounds: {
+ type: "array",
+ value: "number",
+ length: 4,
+ "default": [
+ -180,
+ -85.051129,
+ 180,
+ 85.051129
+ ]
+ },
+ minzoom: {
+ type: "number",
+ "default": 0
+ },
+ maxzoom: {
+ type: "number",
+ "default": 22
+ },
+ tileSize: {
+ type: "number",
+ "default": 512,
+ units: "pixels"
+ },
+ scheme: {
+ type: "enum",
+ values: {
+ xyz: {},
+ tms: {}
+ },
+ "default": "xyz"
+ },
+ attribution: {
+ type: "string"
+ },
+ volatile: {
+ type: "boolean",
+ "default": false
+ },
+ "*": {
+ type: "*"
+ }
+ };
+ var source_raster_dem = {
+ type: {
+ required: true,
+ type: "enum",
+ values: {
+ "raster-dem": {}
+ }
+ },
+ url: {
+ type: "string"
+ },
+ tiles: {
+ type: "array",
+ value: "string"
+ },
+ bounds: {
+ type: "array",
+ value: "number",
+ length: 4,
+ "default": [
+ -180,
+ -85.051129,
+ 180,
+ 85.051129
+ ]
+ },
+ minzoom: {
+ type: "number",
+ "default": 0
+ },
+ maxzoom: {
+ type: "number",
+ "default": 22
+ },
+ tileSize: {
+ type: "number",
+ "default": 512,
+ units: "pixels"
+ },
+ attribution: {
+ type: "string"
+ },
+ encoding: {
+ type: "enum",
+ values: {
+ terrarium: {},
+ mapbox: {}
+ },
+ "default": "mapbox"
+ },
+ volatile: {
+ type: "boolean",
+ "default": false
+ },
+ "*": {
+ type: "*"
+ }
+ };
+ var source_geojson = {
+ type: {
+ required: true,
+ type: "enum",
+ values: {
+ geojson: {}
+ }
+ },
+ data: {
+ type: "*"
+ },
+ maxzoom: {
+ type: "number",
+ "default": 18
+ },
+ attribution: {
+ type: "string"
+ },
+ buffer: {
+ type: "number",
+ "default": 128,
+ maximum: 512,
+ minimum: 0
+ },
+ filter: {
+ type: "*"
+ },
+ tolerance: {
+ type: "number",
+ "default": 0.375
+ },
+ cluster: {
+ type: "boolean",
+ "default": false
+ },
+ clusterRadius: {
+ type: "number",
+ "default": 50,
+ minimum: 0
+ },
+ clusterMaxZoom: {
+ type: "number"
+ },
+ clusterMinPoints: {
+ type: "number"
+ },
+ clusterProperties: {
+ type: "*"
+ },
+ lineMetrics: {
+ type: "boolean",
+ "default": false
+ },
+ generateId: {
+ type: "boolean",
+ "default": false
+ },
+ promoteId: {
+ type: "promoteId"
+ }
+ };
+ var source_video = {
+ type: {
+ required: true,
+ type: "enum",
+ values: {
+ video: {}
+ }
+ },
+ urls: {
+ required: true,
+ type: "array",
+ value: "string"
+ },
+ coordinates: {
+ required: true,
+ type: "array",
+ length: 4,
+ value: {
+ type: "array",
+ length: 2,
+ value: "number"
+ }
+ }
+ };
+ var source_image = {
+ type: {
+ required: true,
+ type: "enum",
+ values: {
+ image: {}
+ }
+ },
+ url: {
+ required: true,
+ type: "string"
+ },
+ coordinates: {
+ required: true,
+ type: "array",
+ length: 4,
+ value: {
+ type: "array",
+ length: 2,
+ value: "number"
+ }
+ }
+ };
+ var layer = {
+ id: {
+ type: "string",
+ required: true
+ },
+ type: {
+ type: "enum",
+ values: {
+ fill: {},
+ line: {},
+ symbol: {},
+ circle: {},
+ heatmap: {},
+ "fill-extrusion": {},
+ raster: {},
+ hillshade: {},
+ background: {}
+ },
+ required: true
+ },
+ metadata: {
+ type: "*"
+ },
+ source: {
+ type: "string"
+ },
+ "source-layer": {
+ type: "string"
+ },
+ minzoom: {
+ type: "number",
+ minimum: 0,
+ maximum: 24
+ },
+ maxzoom: {
+ type: "number",
+ minimum: 0,
+ maximum: 24
+ },
+ filter: {
+ type: "filter"
+ },
+ layout: {
+ type: "layout"
+ },
+ paint: {
+ type: "paint"
+ }
+ };
+ var layout = [
+ "layout_fill",
+ "layout_line",
+ "layout_circle",
+ "layout_heatmap",
+ "layout_fill-extrusion",
+ "layout_symbol",
+ "layout_raster",
+ "layout_hillshade",
+ "layout_background"
+ ];
+ var layout_background = {
+ visibility: {
+ type: "enum",
+ values: {
+ visible: {},
+ none: {}
+ },
+ "default": "visible",
+ "property-type": "constant"
+ }
+ };
+ var layout_fill = {
+ "fill-sort-key": {
+ type: "number",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ visibility: {
+ type: "enum",
+ values: {
+ visible: {},
+ none: {}
+ },
+ "default": "visible",
+ "property-type": "constant"
+ }
+ };
+ var layout_circle = {
+ "circle-sort-key": {
+ type: "number",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ visibility: {
+ type: "enum",
+ values: {
+ visible: {},
+ none: {}
+ },
+ "default": "visible",
+ "property-type": "constant"
+ }
+ };
+ var layout_heatmap = {
+ visibility: {
+ type: "enum",
+ values: {
+ visible: {},
+ none: {}
+ },
+ "default": "visible",
+ "property-type": "constant"
+ }
+ };
+ var layout_line = {
+ "line-cap": {
+ type: "enum",
+ values: {
+ butt: {},
+ round: {},
+ square: {}
+ },
+ "default": "butt",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "line-join": {
+ type: "enum",
+ values: {
+ bevel: {},
+ round: {},
+ miter: {}
+ },
+ "default": "miter",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "line-miter-limit": {
+ type: "number",
+ "default": 2,
+ requires: [
+ {
+ "line-join": "miter"
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "line-round-limit": {
+ type: "number",
+ "default": 1.05,
+ requires: [
+ {
+ "line-join": "round"
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "line-sort-key": {
+ type: "number",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ visibility: {
+ type: "enum",
+ values: {
+ visible: {},
+ none: {}
+ },
+ "default": "visible",
+ "property-type": "constant"
+ }
+ };
+ var layout_symbol = {
+ "symbol-placement": {
+ type: "enum",
+ values: {
+ point: {},
+ line: {},
+ "line-center": {}
+ },
+ "default": "point",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "symbol-spacing": {
+ type: "number",
+ "default": 250,
+ minimum: 1,
+ units: "pixels",
+ requires: [
+ {
+ "symbol-placement": "line"
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "symbol-avoid-edges": {
+ type: "boolean",
+ "default": false,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "symbol-sort-key": {
+ type: "number",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "symbol-z-order": {
+ type: "enum",
+ values: {
+ auto: {},
+ "viewport-y": {},
+ source: {}
+ },
+ "default": "auto",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-allow-overlap": {
+ type: "boolean",
+ "default": false,
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-ignore-placement": {
+ type: "boolean",
+ "default": false,
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-optional": {
+ type: "boolean",
+ "default": false,
+ requires: [
+ "icon-image",
+ "text-field"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-rotation-alignment": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {},
+ auto: {}
+ },
+ "default": "auto",
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-size": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ units: "factor of the original icon size",
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-text-fit": {
+ type: "enum",
+ values: {
+ none: {},
+ width: {},
+ height: {},
+ both: {}
+ },
+ "default": "none",
+ requires: [
+ "icon-image",
+ "text-field"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-text-fit-padding": {
+ type: "array",
+ value: "number",
+ length: 4,
+ "default": [
+ 0,
+ 0,
+ 0,
+ 0
+ ],
+ units: "pixels",
+ requires: [
+ "icon-image",
+ "text-field",
+ {
+ "icon-text-fit": [
+ "both",
+ "width",
+ "height"
+ ]
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-image": {
+ type: "resolvedImage",
+ tokens: true,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-rotate": {
+ type: "number",
+ "default": 0,
+ period: 360,
+ units: "degrees",
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-padding": {
+ type: "number",
+ "default": 2,
+ minimum: 0,
+ units: "pixels",
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-keep-upright": {
+ type: "boolean",
+ "default": false,
+ requires: [
+ "icon-image",
+ {
+ "icon-rotation-alignment": "map"
+ },
+ {
+ "symbol-placement": [
+ "line",
+ "line-center"
+ ]
+ }
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-offset": {
+ type: "array",
+ value: "number",
+ length: 2,
+ "default": [
+ 0,
+ 0
+ ],
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-anchor": {
+ type: "enum",
+ values: {
+ center: {},
+ left: {},
+ right: {},
+ top: {},
+ bottom: {},
+ "top-left": {},
+ "top-right": {},
+ "bottom-left": {},
+ "bottom-right": {}
+ },
+ "default": "center",
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-pitch-alignment": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {},
+ auto: {}
+ },
+ "default": "auto",
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-pitch-alignment": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {},
+ auto: {}
+ },
+ "default": "auto",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-rotation-alignment": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {},
+ auto: {}
+ },
+ "default": "auto",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-field": {
+ type: "formatted",
+ "default": "",
+ tokens: true,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-font": {
+ type: "array",
+ value: "string",
+ "default": [
+ "Open Sans Regular",
+ "Arial Unicode MS Regular"
+ ],
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-size": {
+ type: "number",
+ "default": 16,
+ minimum: 0,
+ units: "pixels",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-max-width": {
+ type: "number",
+ "default": 10,
+ minimum: 0,
+ units: "ems",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-line-height": {
+ type: "number",
+ "default": 1.2,
+ units: "ems",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-letter-spacing": {
+ type: "number",
+ "default": 0,
+ units: "ems",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-justify": {
+ type: "enum",
+ values: {
+ auto: {},
+ left: {},
+ center: {},
+ right: {}
+ },
+ "default": "center",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-radial-offset": {
+ type: "number",
+ units: "ems",
+ "default": 0,
+ requires: [
+ "text-field"
+ ],
+ "property-type": "data-driven",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ }
+ },
+ "text-variable-anchor": {
+ type: "array",
+ value: "enum",
+ values: {
+ center: {},
+ left: {},
+ right: {},
+ top: {},
+ bottom: {},
+ "top-left": {},
+ "top-right": {},
+ "bottom-left": {},
+ "bottom-right": {}
+ },
+ requires: [
+ "text-field",
+ {
+ "symbol-placement": [
+ "point"
+ ]
+ }
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-anchor": {
+ type: "enum",
+ values: {
+ center: {},
+ left: {},
+ right: {},
+ top: {},
+ bottom: {},
+ "top-left": {},
+ "top-right": {},
+ "bottom-left": {},
+ "bottom-right": {}
+ },
+ "default": "center",
+ requires: [
+ "text-field",
+ {
+ "!": "text-variable-anchor"
+ }
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-max-angle": {
+ type: "number",
+ "default": 45,
+ units: "degrees",
+ requires: [
+ "text-field",
+ {
+ "symbol-placement": [
+ "line",
+ "line-center"
+ ]
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-writing-mode": {
+ type: "array",
+ value: "enum",
+ values: {
+ horizontal: {},
+ vertical: {}
+ },
+ requires: [
+ "text-field",
+ {
+ "symbol-placement": [
+ "point"
+ ]
+ }
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-rotate": {
+ type: "number",
+ "default": 0,
+ period: 360,
+ units: "degrees",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-padding": {
+ type: "number",
+ "default": 2,
+ minimum: 0,
+ units: "pixels",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-keep-upright": {
+ type: "boolean",
+ "default": true,
+ requires: [
+ "text-field",
+ {
+ "text-rotation-alignment": "map"
+ },
+ {
+ "symbol-placement": [
+ "line",
+ "line-center"
+ ]
+ }
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-transform": {
+ type: "enum",
+ values: {
+ none: {},
+ uppercase: {},
+ lowercase: {}
+ },
+ "default": "none",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-offset": {
+ type: "array",
+ value: "number",
+ units: "ems",
+ length: 2,
+ "default": [
+ 0,
+ 0
+ ],
+ requires: [
+ "text-field",
+ {
+ "!": "text-radial-offset"
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-allow-overlap": {
+ type: "boolean",
+ "default": false,
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-ignore-placement": {
+ type: "boolean",
+ "default": false,
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-optional": {
+ type: "boolean",
+ "default": false,
+ requires: [
+ "text-field",
+ "icon-image"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ visibility: {
+ type: "enum",
+ values: {
+ visible: {},
+ none: {}
+ },
+ "default": "visible",
+ "property-type": "constant"
+ }
+ };
+ var layout_raster = {
+ visibility: {
+ type: "enum",
+ values: {
+ visible: {},
+ none: {}
+ },
+ "default": "visible",
+ "property-type": "constant"
+ }
+ };
+ var layout_hillshade = {
+ visibility: {
+ type: "enum",
+ values: {
+ visible: {},
+ none: {}
+ },
+ "default": "visible",
+ "property-type": "constant"
+ }
+ };
+ var filter = {
+ type: "array",
+ value: "*"
+ };
+ var filter_operator = {
+ type: "enum",
+ values: {
+ "==": {},
+ "!=": {},
+ ">": {},
+ ">=": {},
+ "<": {},
+ "<=": {},
+ "in": {},
+ "!in": {},
+ all: {},
+ any: {},
+ none: {},
+ has: {},
+ "!has": {},
+ within: {}
+ }
+ };
+ var geometry_type = {
+ type: "enum",
+ values: {
+ Point: {},
+ LineString: {},
+ Polygon: {}
+ }
+ };
+ var function_stop = {
+ type: "array",
+ minimum: 0,
+ maximum: 24,
+ value: [
+ "number",
+ "color"
+ ],
+ length: 2
+ };
+ var expression = {
+ type: "array",
+ value: "*",
+ minimum: 1
+ };
+ var light = {
+ anchor: {
+ type: "enum",
+ "default": "viewport",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "property-type": "data-constant",
+ transition: false,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ }
+ },
+ position: {
+ type: "array",
+ "default": [
+ 1.15,
+ 210,
+ 30
+ ],
+ length: 3,
+ value: "number",
+ "property-type": "data-constant",
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ }
+ },
+ color: {
+ type: "color",
+ "property-type": "data-constant",
+ "default": "#ffffff",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ transition: true
+ },
+ intensity: {
+ type: "number",
+ "property-type": "data-constant",
+ "default": 0.5,
+ minimum: 0,
+ maximum: 1,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ transition: true
+ }
+ };
+ var paint = [
+ "paint_fill",
+ "paint_line",
+ "paint_circle",
+ "paint_heatmap",
+ "paint_fill-extrusion",
+ "paint_symbol",
+ "paint_raster",
+ "paint_hillshade",
+ "paint_background"
+ ];
+ var paint_fill = {
+ "fill-antialias": {
+ type: "boolean",
+ "default": true,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "fill-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "fill-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ requires: [
+ {
+ "!": "fill-pattern"
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "fill-outline-color": {
+ type: "color",
+ transition: true,
+ requires: [
+ {
+ "!": "fill-pattern"
+ },
+ {
+ "fill-antialias": true
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "fill-translate": {
+ type: "array",
+ value: "number",
+ length: 2,
+ "default": [
+ 0,
+ 0
+ ],
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "fill-translate-anchor": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "default": "map",
+ requires: [
+ "fill-translate"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "fill-pattern": {
+ type: "resolvedImage",
+ transition: true,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "cross-faded-data-driven"
+ }
+ };
+ var paint_line = {
+ "line-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "line-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ requires: [
+ {
+ "!": "line-pattern"
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "line-translate": {
+ type: "array",
+ value: "number",
+ length: 2,
+ "default": [
+ 0,
+ 0
+ ],
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "line-translate-anchor": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "default": "map",
+ requires: [
+ "line-translate"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "line-width": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "line-gap-width": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "line-offset": {
+ type: "number",
+ "default": 0,
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "line-blur": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "line-dasharray": {
+ type: "array",
+ value: "number",
+ minimum: 0,
+ transition: true,
+ units: "line widths",
+ requires: [
+ {
+ "!": "line-pattern"
+ }
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "cross-faded"
+ },
+ "line-pattern": {
+ type: "resolvedImage",
+ transition: true,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "cross-faded-data-driven"
+ },
+ "line-gradient": {
+ type: "color",
+ transition: false,
+ requires: [
+ {
+ "!": "line-dasharray"
+ },
+ {
+ "!": "line-pattern"
+ },
+ {
+ source: "geojson",
+ has: {
+ lineMetrics: true
+ }
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "line-progress"
+ ]
+ },
+ "property-type": "color-ramp"
+ }
+ };
+ var paint_circle = {
+ "circle-radius": {
+ type: "number",
+ "default": 5,
+ minimum: 0,
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "circle-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "circle-blur": {
+ type: "number",
+ "default": 0,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "circle-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "circle-translate": {
+ type: "array",
+ value: "number",
+ length: 2,
+ "default": [
+ 0,
+ 0
+ ],
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "circle-translate-anchor": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "default": "map",
+ requires: [
+ "circle-translate"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "circle-pitch-scale": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "default": "map",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "circle-pitch-alignment": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "default": "viewport",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "circle-stroke-width": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "circle-stroke-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "circle-stroke-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ }
+ };
+ var paint_heatmap = {
+ "heatmap-radius": {
+ type: "number",
+ "default": 30,
+ minimum: 1,
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "heatmap-weight": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ transition: false,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "heatmap-intensity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "heatmap-color": {
+ type: "color",
+ "default": [
+ "interpolate",
+ [
+ "linear"
+ ],
+ [
+ "heatmap-density"
+ ],
+ 0,
+ "rgba(0, 0, 255, 0)",
+ 0.1,
+ "royalblue",
+ 0.3,
+ "cyan",
+ 0.5,
+ "lime",
+ 0.7,
+ "yellow",
+ 1,
+ "red"
+ ],
+ transition: false,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "heatmap-density"
+ ]
+ },
+ "property-type": "color-ramp"
+ },
+ "heatmap-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ }
+ };
+ var paint_symbol = {
+ "icon-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-halo-color": {
+ type: "color",
+ "default": "rgba(0, 0, 0, 0)",
+ transition: true,
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-halo-width": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ transition: true,
+ units: "pixels",
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-halo-blur": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ transition: true,
+ units: "pixels",
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "icon-translate": {
+ type: "array",
+ value: "number",
+ length: 2,
+ "default": [
+ 0,
+ 0
+ ],
+ transition: true,
+ units: "pixels",
+ requires: [
+ "icon-image"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "icon-translate-anchor": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "default": "map",
+ requires: [
+ "icon-image",
+ "icon-translate"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ overridable: true,
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-halo-color": {
+ type: "color",
+ "default": "rgba(0, 0, 0, 0)",
+ transition: true,
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-halo-width": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ transition: true,
+ units: "pixels",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-halo-blur": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ transition: true,
+ units: "pixels",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "text-translate": {
+ type: "array",
+ value: "number",
+ length: 2,
+ "default": [
+ 0,
+ 0
+ ],
+ transition: true,
+ units: "pixels",
+ requires: [
+ "text-field"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "text-translate-anchor": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "default": "map",
+ requires: [
+ "text-field",
+ "text-translate"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ }
+ };
+ var paint_raster = {
+ "raster-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "raster-hue-rotate": {
+ type: "number",
+ "default": 0,
+ period: 360,
+ transition: true,
+ units: "degrees",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "raster-brightness-min": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "raster-brightness-max": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "raster-saturation": {
+ type: "number",
+ "default": 0,
+ minimum: -1,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "raster-contrast": {
+ type: "number",
+ "default": 0,
+ minimum: -1,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "raster-resampling": {
+ type: "enum",
+ values: {
+ linear: {},
+ nearest: {}
+ },
+ "default": "linear",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "raster-fade-duration": {
+ type: "number",
+ "default": 300,
+ minimum: 0,
+ transition: false,
+ units: "milliseconds",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ }
+ };
+ var paint_hillshade = {
+ "hillshade-illumination-direction": {
+ type: "number",
+ "default": 335,
+ minimum: 0,
+ maximum: 359,
+ transition: false,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "hillshade-illumination-anchor": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "default": "viewport",
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "hillshade-exaggeration": {
+ type: "number",
+ "default": 0.5,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "hillshade-shadow-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "hillshade-highlight-color": {
+ type: "color",
+ "default": "#FFFFFF",
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "hillshade-accent-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ }
+ };
+ var paint_background = {
+ "background-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ requires: [
+ {
+ "!": "background-pattern"
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "background-pattern": {
+ type: "resolvedImage",
+ transition: true,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "cross-faded"
+ },
+ "background-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ }
+ };
+ var transition = {
+ duration: {
+ type: "number",
+ "default": 300,
+ minimum: 0,
+ units: "milliseconds"
+ },
+ delay: {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ units: "milliseconds"
+ }
+ };
+ var promoteId = {
+ "*": {
+ type: "string"
+ }
+ };
+ var spec = {
+ $version,
+ $root,
+ sources,
+ source,
+ source_vector,
+ source_raster,
+ source_raster_dem,
+ source_geojson,
+ source_video,
+ source_image,
+ layer,
+ layout,
+ layout_background,
+ layout_fill,
+ layout_circle,
+ layout_heatmap,
+ "layout_fill-extrusion": {
+ visibility: {
+ type: "enum",
+ values: {
+ visible: {},
+ none: {}
+ },
+ "default": "visible",
+ "property-type": "constant"
+ }
+ },
+ layout_line,
+ layout_symbol,
+ layout_raster,
+ layout_hillshade,
+ filter,
+ filter_operator,
+ geometry_type,
+ "function": {
+ expression: {
+ type: "expression"
+ },
+ stops: {
+ type: "array",
+ value: "function_stop"
+ },
+ base: {
+ type: "number",
+ "default": 1,
+ minimum: 0
+ },
+ property: {
+ type: "string",
+ "default": "$zoom"
+ },
+ type: {
+ type: "enum",
+ values: {
+ identity: {},
+ exponential: {},
+ interval: {},
+ categorical: {}
+ },
+ "default": "exponential"
+ },
+ colorSpace: {
+ type: "enum",
+ values: {
+ rgb: {},
+ lab: {},
+ hcl: {}
+ },
+ "default": "rgb"
+ },
+ "default": {
+ type: "*",
+ required: false
+ }
+ },
+ function_stop,
+ expression,
+ light,
+ paint,
+ paint_fill,
+ "paint_fill-extrusion": {
+ "fill-extrusion-opacity": {
+ type: "number",
+ "default": 1,
+ minimum: 0,
+ maximum: 1,
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "fill-extrusion-color": {
+ type: "color",
+ "default": "#000000",
+ transition: true,
+ requires: [
+ {
+ "!": "fill-extrusion-pattern"
+ }
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "fill-extrusion-translate": {
+ type: "array",
+ value: "number",
+ length: 2,
+ "default": [
+ 0,
+ 0
+ ],
+ transition: true,
+ units: "pixels",
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "fill-extrusion-translate-anchor": {
+ type: "enum",
+ values: {
+ map: {},
+ viewport: {}
+ },
+ "default": "map",
+ requires: [
+ "fill-extrusion-translate"
+ ],
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ },
+ "fill-extrusion-pattern": {
+ type: "resolvedImage",
+ transition: true,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom",
+ "feature"
+ ]
+ },
+ "property-type": "cross-faded-data-driven"
+ },
+ "fill-extrusion-height": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ units: "meters",
+ transition: true,
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "fill-extrusion-base": {
+ type: "number",
+ "default": 0,
+ minimum: 0,
+ units: "meters",
+ transition: true,
+ requires: [
+ "fill-extrusion-height"
+ ],
+ expression: {
+ interpolated: true,
+ parameters: [
+ "zoom",
+ "feature",
+ "feature-state"
+ ]
+ },
+ "property-type": "data-driven"
+ },
+ "fill-extrusion-vertical-gradient": {
+ type: "boolean",
+ "default": true,
+ transition: false,
+ expression: {
+ interpolated: false,
+ parameters: [
+ "zoom"
+ ]
+ },
+ "property-type": "data-constant"
+ }
+ },
+ paint_line,
+ paint_circle,
+ paint_heatmap,
+ paint_symbol,
+ paint_raster,
+ paint_hillshade,
+ paint_background,
+ transition,
+ "property-type": {
+ "data-driven": {
+ type: "property-type"
+ },
+ "cross-faded": {
+ type: "property-type"
+ },
+ "cross-faded-data-driven": {
+ type: "property-type"
+ },
+ "color-ramp": {
+ type: "property-type"
+ },
+ "data-constant": {
+ type: "property-type"
+ },
+ constant: {
+ type: "property-type"
+ }
+ },
+ promoteId
+ };
+ var ValidationError = function ValidationError2(key, value, message, identifier) {
+ this.message = (key ? key + ": " : "") + message;
+ if (identifier) {
+ this.identifier = identifier;
+ }
+ if (value !== null && value !== void 0 && value.__line__) {
+ this.line = value.__line__;
+ }
+ };
+ function validateConstants(options) {
+ var key = options.key;
+ var constants = options.value;
+ if (constants) {
+ return [new ValidationError(key, constants, "constants have been deprecated as of v8")];
+ } else {
+ return [];
+ }
+ }
+ function extend$1(output) {
+ var inputs = [], len = arguments.length - 1;
+ while (len-- > 0)
+ inputs[len] = arguments[len + 1];
+ for (var i = 0, list = inputs; i < list.length; i += 1) {
+ var input = list[i];
+ for (var k in input) {
+ output[k] = input[k];
+ }
+ }
+ return output;
+ }
+ function unbundle(value) {
+ if (value instanceof Number || value instanceof String || value instanceof Boolean) {
+ return value.valueOf();
+ } else {
+ return value;
+ }
+ }
+ function deepUnbundle(value) {
+ if (Array.isArray(value)) {
+ return value.map(deepUnbundle);
+ } else if (value instanceof Object && !(value instanceof Number || value instanceof String || value instanceof Boolean)) {
+ var unbundledValue = {};
+ for (var key in value) {
+ unbundledValue[key] = deepUnbundle(value[key]);
+ }
+ return unbundledValue;
+ }
+ return unbundle(value);
+ }
+ var ParsingError = function(Error2) {
+ function ParsingError2(key, message) {
+ Error2.call(this, message);
+ this.message = message;
+ this.key = key;
+ }
+ if (Error2)
+ ParsingError2.__proto__ = Error2;
+ ParsingError2.prototype = Object.create(Error2 && Error2.prototype);
+ ParsingError2.prototype.constructor = ParsingError2;
+ return ParsingError2;
+ }(Error);
+ var Scope = function Scope2(parent, bindings) {
+ if (bindings === void 0)
+ bindings = [];
+ this.parent = parent;
+ this.bindings = {};
+ for (var i = 0, list = bindings; i < list.length; i += 1) {
+ var ref = list[i];
+ var name3 = ref[0];
+ var expression2 = ref[1];
+ this.bindings[name3] = expression2;
+ }
+ };
+ Scope.prototype.concat = function concat(bindings) {
+ return new Scope(this, bindings);
+ };
+ Scope.prototype.get = function get2(name3) {
+ if (this.bindings[name3]) {
+ return this.bindings[name3];
+ }
+ if (this.parent) {
+ return this.parent.get(name3);
+ }
+ throw new Error(name3 + " not found in scope.");
+ };
+ Scope.prototype.has = function has2(name3) {
+ if (this.bindings[name3]) {
+ return true;
+ }
+ return this.parent ? this.parent.has(name3) : false;
+ };
+ var NullType = { kind: "null" };
+ var NumberType = { kind: "number" };
+ var StringType = { kind: "string" };
+ var BooleanType = { kind: "boolean" };
+ var ColorType = { kind: "color" };
+ var ObjectType = { kind: "object" };
+ var ValueType = { kind: "value" };
+ var ErrorType = { kind: "error" };
+ var CollatorType = { kind: "collator" };
+ var FormattedType = { kind: "formatted" };
+ var ResolvedImageType = { kind: "resolvedImage" };
+ function array(itemType, N) {
+ return {
+ kind: "array",
+ itemType,
+ N
+ };
+ }
+ function toString(type) {
+ if (type.kind === "array") {
+ var itemType = toString(type.itemType);
+ return typeof type.N === "number" ? "array<" + itemType + ", " + type.N + ">" : type.itemType.kind === "value" ? "array" : "array<" + itemType + ">";
+ } else {
+ return type.kind;
+ }
+ }
+ var valueMemberTypes = [
+ NullType,
+ NumberType,
+ StringType,
+ BooleanType,
+ ColorType,
+ FormattedType,
+ ObjectType,
+ array(ValueType),
+ ResolvedImageType
+ ];
+ function checkSubtype(expected, t) {
+ if (t.kind === "error") {
+ return null;
+ } else if (expected.kind === "array") {
+ if (t.kind === "array" && (t.N === 0 && t.itemType.kind === "value" || !checkSubtype(expected.itemType, t.itemType)) && (typeof expected.N !== "number" || expected.N === t.N)) {
+ return null;
+ }
+ } else if (expected.kind === t.kind) {
+ return null;
+ } else if (expected.kind === "value") {
+ for (var i = 0, list = valueMemberTypes; i < list.length; i += 1) {
+ var memberType = list[i];
+ if (!checkSubtype(memberType, t)) {
+ return null;
+ }
+ }
+ }
+ return "Expected " + toString(expected) + " but found " + toString(t) + " instead.";
+ }
+ function isValidType(provided, allowedTypes) {
+ return allowedTypes.some(function(t) {
+ return t.kind === provided.kind;
+ });
+ }
+ function isValidNativeType(provided, allowedTypes) {
+ return allowedTypes.some(function(t) {
+ if (t === "null") {
+ return provided === null;
+ } else if (t === "array") {
+ return Array.isArray(provided);
+ } else if (t === "object") {
+ return provided && !Array.isArray(provided) && typeof provided === "object";
+ } else {
+ return t === typeof provided;
+ }
+ });
+ }
+ var csscolorparser = createCommonjsModule(function(module2, exports3) {
+ var kCSSColorTable = {
+ "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 clamp_css_byte(i) {
+ i = Math.round(i);
+ return i < 0 ? 0 : i > 255 ? 255 : i;
+ }
+ function clamp_css_float(f) {
+ return f < 0 ? 0 : f > 1 ? 1 : f;
+ }
+ function parse_css_int(str) {
+ if (str[str.length - 1] === "%") {
+ return clamp_css_byte(parseFloat(str) / 100 * 255);
+ }
+ return clamp_css_byte(parseInt(str));
+ }
+ function parse_css_float(str) {
+ if (str[str.length - 1] === "%") {
+ return clamp_css_float(parseFloat(str) / 100);
+ }
+ return clamp_css_float(parseFloat(str));
+ }
+ function css_hue_to_rgb(m1, m2, h) {
+ if (h < 0) {
+ h += 1;
+ } else if (h > 1) {
+ h -= 1;
+ }
+ if (h * 6 < 1) {
+ return m1 + (m2 - m1) * h * 6;
+ }
+ if (h * 2 < 1) {
+ return m2;
+ }
+ if (h * 3 < 2) {
+ return m1 + (m2 - m1) * (2 / 3 - h) * 6;
+ }
+ return m1;
+ }
+ function parseCSSColor(css_str) {
+ var str = css_str.replace(/ /g, "").toLowerCase();
+ if (str in kCSSColorTable) {
+ return kCSSColorTable[str].slice();
+ }
+ if (str[0] === "#") {
+ if (str.length === 4) {
+ var iv = parseInt(str.substr(1), 16);
+ if (!(iv >= 0 && iv <= 4095)) {
+ return null;
+ }
+ return [
+ (iv & 3840) >> 4 | (iv & 3840) >> 8,
+ iv & 240 | (iv & 240) >> 4,
+ iv & 15 | (iv & 15) << 4,
+ 1
+ ];
+ } else if (str.length === 7) {
+ var iv = parseInt(str.substr(1), 16);
+ if (!(iv >= 0 && iv <= 16777215)) {
+ return null;
+ }
+ return [
+ (iv & 16711680) >> 16,
+ (iv & 65280) >> 8,
+ iv & 255,
+ 1
+ ];
+ }
+ return null;
+ }
+ var op = str.indexOf("("), ep = str.indexOf(")");
+ if (op !== -1 && ep + 1 === str.length) {
+ var fname = str.substr(0, op);
+ var params = str.substr(op + 1, ep - (op + 1)).split(",");
+ var alpha = 1;
+ switch (fname) {
+ case "rgba":
+ if (params.length !== 4) {
+ return null;
+ }
+ alpha = parse_css_float(params.pop());
+ case "rgb":
+ if (params.length !== 3) {
+ return null;
+ }
+ return [
+ parse_css_int(params[0]),
+ parse_css_int(params[1]),
+ parse_css_int(params[2]),
+ alpha
+ ];
+ case "hsla":
+ if (params.length !== 4) {
+ return null;
+ }
+ alpha = parse_css_float(params.pop());
+ case "hsl":
+ if (params.length !== 3) {
+ return null;
+ }
+ var h = (parseFloat(params[0]) % 360 + 360) % 360 / 360;
+ var s = parse_css_float(params[1]);
+ var l = parse_css_float(params[2]);
+ var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
+ var m1 = l * 2 - m2;
+ return [
+ clamp_css_byte(css_hue_to_rgb(m1, m2, h + 1 / 3) * 255),
+ clamp_css_byte(css_hue_to_rgb(m1, m2, h) * 255),
+ clamp_css_byte(css_hue_to_rgb(m1, m2, h - 1 / 3) * 255),
+ alpha
+ ];
+ default:
+ return null;
+ }
+ }
+ return null;
+ }
+ try {
+ exports3.parseCSSColor = parseCSSColor;
+ } catch (e) {
+ }
+ });
+ var csscolorparser_1 = csscolorparser.parseCSSColor;
+ var Color2 = function Color3(r, g, b, a) {
+ if (a === void 0)
+ a = 1;
+ this.r = r;
+ this.g = g;
+ this.b = b;
+ this.a = a;
+ };
+ Color2.parse = function parse2(input) {
+ if (!input) {
+ return void 0;
+ }
+ if (input instanceof Color2) {
+ return input;
+ }
+ if (typeof input !== "string") {
+ return void 0;
+ }
+ var rgba4 = csscolorparser_1(input);
+ if (!rgba4) {
+ return void 0;
+ }
+ return new Color2(rgba4[0] / 255 * rgba4[3], rgba4[1] / 255 * rgba4[3], rgba4[2] / 255 * rgba4[3], rgba4[3]);
+ };
+ Color2.prototype.toString = function toString2() {
+ var ref = this.toArray();
+ var r = ref[0];
+ var g = ref[1];
+ var b = ref[2];
+ var a = ref[3];
+ return "rgba(" + Math.round(r) + "," + Math.round(g) + "," + Math.round(b) + "," + a + ")";
+ };
+ Color2.prototype.toArray = function toArray() {
+ var ref = this;
+ var r = ref.r;
+ var g = ref.g;
+ var b = ref.b;
+ var a = ref.a;
+ return a === 0 ? [
+ 0,
+ 0,
+ 0,
+ 0
+ ] : [
+ r * 255 / a,
+ g * 255 / a,
+ b * 255 / a,
+ a
+ ];
+ };
+ Color2.black = new Color2(0, 0, 0, 1);
+ Color2.white = new Color2(1, 1, 1, 1);
+ Color2.transparent = new Color2(0, 0, 0, 0);
+ Color2.red = new Color2(1, 0, 0, 1);
+ var Collator = function Collator2(caseSensitive, diacriticSensitive, locale) {
+ if (caseSensitive) {
+ this.sensitivity = diacriticSensitive ? "variant" : "case";
+ } else {
+ this.sensitivity = diacriticSensitive ? "accent" : "base";
+ }
+ this.locale = locale;
+ this.collator = new Intl.Collator(this.locale ? this.locale : [], {
+ sensitivity: this.sensitivity,
+ usage: "search"
+ });
+ };
+ Collator.prototype.compare = function compare2(lhs, rhs) {
+ return this.collator.compare(lhs, rhs);
+ };
+ Collator.prototype.resolvedLocale = function resolvedLocale() {
+ return new Intl.Collator(this.locale ? this.locale : []).resolvedOptions().locale;
+ };
+ var FormattedSection = function FormattedSection2(text, image, scale2, fontStack, textColor) {
+ this.text = text;
+ this.image = image;
+ this.scale = scale2;
+ this.fontStack = fontStack;
+ this.textColor = textColor;
+ };
+ var Formatted = function Formatted2(sections) {
+ this.sections = sections;
+ };
+ Formatted.fromString = function fromString(unformatted) {
+ return new Formatted([new FormattedSection(unformatted, null, null, null, null)]);
+ };
+ Formatted.prototype.isEmpty = function isEmpty2() {
+ if (this.sections.length === 0) {
+ return true;
+ }
+ return !this.sections.some(function(section) {
+ return section.text.length !== 0 || section.image && section.image.name.length !== 0;
+ });
+ };
+ Formatted.factory = function factory(text) {
+ if (text instanceof Formatted) {
+ return text;
+ } else {
+ return Formatted.fromString(text);
+ }
+ };
+ Formatted.prototype.toString = function toString2() {
+ if (this.sections.length === 0) {
+ return "";
+ }
+ return this.sections.map(function(section) {
+ return section.text;
+ }).join("");
+ };
+ Formatted.prototype.serialize = function serialize2() {
+ var serialized = ["format"];
+ for (var i = 0, list = this.sections; i < list.length; i += 1) {
+ var section = list[i];
+ if (section.image) {
+ serialized.push([
+ "image",
+ section.image.name
+ ]);
+ continue;
+ }
+ serialized.push(section.text);
+ var options = {};
+ if (section.fontStack) {
+ options["text-font"] = [
+ "literal",
+ section.fontStack.split(",")
+ ];
+ }
+ if (section.scale) {
+ options["font-scale"] = section.scale;
+ }
+ if (section.textColor) {
+ options["text-color"] = ["rgba"].concat(section.textColor.toArray());
+ }
+ serialized.push(options);
+ }
+ return serialized;
+ };
+ var ResolvedImage = function ResolvedImage2(options) {
+ this.name = options.name;
+ this.available = options.available;
+ };
+ ResolvedImage.prototype.toString = function toString2() {
+ return this.name;
+ };
+ ResolvedImage.fromString = function fromString(name3) {
+ if (!name3) {
+ return null;
+ }
+ return new ResolvedImage({
+ name: name3,
+ available: false
+ });
+ };
+ ResolvedImage.prototype.serialize = function serialize2() {
+ return [
+ "image",
+ this.name
+ ];
+ };
+ function validateRGBA(r, g, b, a) {
+ if (!(typeof r === "number" && r >= 0 && r <= 255 && typeof g === "number" && g >= 0 && g <= 255 && typeof b === "number" && b >= 0 && b <= 255)) {
+ var value = typeof a === "number" ? [
+ r,
+ g,
+ b,
+ a
+ ] : [
+ r,
+ g,
+ b
+ ];
+ return "Invalid rgba value [" + value.join(", ") + "]: 'r', 'g', and 'b' must be between 0 and 255.";
+ }
+ if (!(typeof a === "undefined" || typeof a === "number" && a >= 0 && a <= 1)) {
+ return "Invalid rgba value [" + [
+ r,
+ g,
+ b,
+ a
+ ].join(", ") + "]: 'a' must be between 0 and 1.";
+ }
+ return null;
+ }
+ function isValue(mixed) {
+ if (mixed === null) {
+ return true;
+ } else if (typeof mixed === "string") {
+ return true;
+ } else if (typeof mixed === "boolean") {
+ return true;
+ } else if (typeof mixed === "number") {
+ return true;
+ } else if (mixed instanceof Color2) {
+ return true;
+ } else if (mixed instanceof Collator) {
+ return true;
+ } else if (mixed instanceof Formatted) {
+ return true;
+ } else if (mixed instanceof ResolvedImage) {
+ return true;
+ } else if (Array.isArray(mixed)) {
+ for (var i = 0, list = mixed; i < list.length; i += 1) {
+ var item = list[i];
+ if (!isValue(item)) {
+ return false;
+ }
+ }
+ return true;
+ } else if (typeof mixed === "object") {
+ for (var key in mixed) {
+ if (!isValue(mixed[key])) {
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+ function typeOf(value) {
+ if (value === null) {
+ return NullType;
+ } else if (typeof value === "string") {
+ return StringType;
+ } else if (typeof value === "boolean") {
+ return BooleanType;
+ } else if (typeof value === "number") {
+ return NumberType;
+ } else if (value instanceof Color2) {
+ return ColorType;
+ } else if (value instanceof Collator) {
+ return CollatorType;
+ } else if (value instanceof Formatted) {
+ return FormattedType;
+ } else if (value instanceof ResolvedImage) {
+ return ResolvedImageType;
+ } else if (Array.isArray(value)) {
+ var length = value.length;
+ var itemType;
+ for (var i = 0, list = value; i < list.length; i += 1) {
+ var item = list[i];
+ var t = typeOf(item);
+ if (!itemType) {
+ itemType = t;
+ } else if (itemType === t) {
+ continue;
+ } else {
+ itemType = ValueType;
+ break;
+ }
+ }
+ return array(itemType || ValueType, length);
+ } else {
+ return ObjectType;
+ }
+ }
+ function toString$1(value) {
+ var type = typeof value;
+ if (value === null) {
+ return "";
+ } else if (type === "string" || type === "number" || type === "boolean") {
+ return String(value);
+ } else if (value instanceof Color2 || value instanceof Formatted || value instanceof ResolvedImage) {
+ return value.toString();
+ } else {
+ return JSON.stringify(value);
+ }
+ }
+ var Literal = function Literal2(type, value) {
+ this.type = type;
+ this.value = value;
+ };
+ Literal.parse = function parse2(args, context) {
+ if (args.length !== 2) {
+ return context.error("'literal' expression requires exactly one argument, but found " + (args.length - 1) + " instead.");
+ }
+ if (!isValue(args[1])) {
+ return context.error("invalid value");
+ }
+ var value = args[1];
+ var type = typeOf(value);
+ var expected = context.expectedType;
+ if (type.kind === "array" && type.N === 0 && expected && expected.kind === "array" && (typeof expected.N !== "number" || expected.N === 0)) {
+ type = expected;
+ }
+ return new Literal(type, value);
+ };
+ Literal.prototype.evaluate = function evaluate() {
+ return this.value;
+ };
+ Literal.prototype.eachChild = function eachChild() {
+ };
+ Literal.prototype.outputDefined = function outputDefined() {
+ return true;
+ };
+ Literal.prototype.serialize = function serialize2() {
+ if (this.type.kind === "array" || this.type.kind === "object") {
+ return [
+ "literal",
+ this.value
+ ];
+ } else if (this.value instanceof Color2) {
+ return ["rgba"].concat(this.value.toArray());
+ } else if (this.value instanceof Formatted) {
+ return this.value.serialize();
+ } else {
+ return this.value;
+ }
+ };
+ var RuntimeError = function RuntimeError2(message) {
+ this.name = "ExpressionEvaluationError";
+ this.message = message;
+ };
+ RuntimeError.prototype.toJSON = function toJSON() {
+ return this.message;
+ };
+ var types = {
+ string: StringType,
+ number: NumberType,
+ boolean: BooleanType,
+ object: ObjectType
+ };
+ var Assertion = function Assertion2(type, args) {
+ this.type = type;
+ this.args = args;
+ };
+ Assertion.parse = function parse2(args, context) {
+ if (args.length < 2) {
+ return context.error("Expected at least one argument.");
+ }
+ var i = 1;
+ var type;
+ var name3 = args[0];
+ if (name3 === "array") {
+ var itemType;
+ if (args.length > 2) {
+ var type$1 = args[1];
+ if (typeof type$1 !== "string" || !(type$1 in types) || type$1 === "object") {
+ return context.error('The item type argument of "array" must be one of string, number, boolean', 1);
+ }
+ itemType = types[type$1];
+ i++;
+ } else {
+ itemType = ValueType;
+ }
+ var N;
+ if (args.length > 3) {
+ if (args[2] !== null && (typeof args[2] !== "number" || args[2] < 0 || args[2] !== Math.floor(args[2]))) {
+ return context.error('The length argument to "array" must be a positive integer literal', 2);
+ }
+ N = args[2];
+ i++;
+ }
+ type = array(itemType, N);
+ } else {
+ type = types[name3];
+ }
+ var parsed = [];
+ for (; i < args.length; i++) {
+ var input = context.parse(args[i], i, ValueType);
+ if (!input) {
+ return null;
+ }
+ parsed.push(input);
+ }
+ return new Assertion(type, parsed);
+ };
+ Assertion.prototype.evaluate = function evaluate(ctx) {
+ for (var i = 0; i < this.args.length; i++) {
+ var value = this.args[i].evaluate(ctx);
+ var error2 = checkSubtype(this.type, typeOf(value));
+ if (!error2) {
+ return value;
+ } else if (i === this.args.length - 1) {
+ throw new RuntimeError("Expected value to be of type " + toString(this.type) + ", but found " + toString(typeOf(value)) + " instead.");
+ }
+ }
+ return null;
+ };
+ Assertion.prototype.eachChild = function eachChild(fn) {
+ this.args.forEach(fn);
+ };
+ Assertion.prototype.outputDefined = function outputDefined() {
+ return this.args.every(function(arg) {
+ return arg.outputDefined();
+ });
+ };
+ Assertion.prototype.serialize = function serialize2() {
+ var type = this.type;
+ var serialized = [type.kind];
+ if (type.kind === "array") {
+ var itemType = type.itemType;
+ if (itemType.kind === "string" || itemType.kind === "number" || itemType.kind === "boolean") {
+ serialized.push(itemType.kind);
+ var N = type.N;
+ if (typeof N === "number" || this.args.length > 1) {
+ serialized.push(N);
+ }
+ }
+ }
+ return serialized.concat(this.args.map(function(arg) {
+ return arg.serialize();
+ }));
+ };
+ var FormatExpression = function FormatExpression2(sections) {
+ this.type = FormattedType;
+ this.sections = sections;
+ };
+ FormatExpression.parse = function parse2(args, context) {
+ if (args.length < 2) {
+ return context.error("Expected at least one argument.");
+ }
+ var firstArg = args[1];
+ if (!Array.isArray(firstArg) && typeof firstArg === "object") {
+ return context.error("First argument must be an image or text section.");
+ }
+ var sections = [];
+ var nextTokenMayBeObject = false;
+ for (var i = 1; i <= args.length - 1; ++i) {
+ var arg = args[i];
+ if (nextTokenMayBeObject && typeof arg === "object" && !Array.isArray(arg)) {
+ nextTokenMayBeObject = false;
+ var scale2 = null;
+ if (arg["font-scale"]) {
+ scale2 = context.parse(arg["font-scale"], 1, NumberType);
+ if (!scale2) {
+ return null;
+ }
+ }
+ var font = null;
+ if (arg["text-font"]) {
+ font = context.parse(arg["text-font"], 1, array(StringType));
+ if (!font) {
+ return null;
+ }
+ }
+ var textColor = null;
+ if (arg["text-color"]) {
+ textColor = context.parse(arg["text-color"], 1, ColorType);
+ if (!textColor) {
+ return null;
+ }
+ }
+ var lastExpression = sections[sections.length - 1];
+ lastExpression.scale = scale2;
+ lastExpression.font = font;
+ lastExpression.textColor = textColor;
+ } else {
+ var content = context.parse(args[i], 1, ValueType);
+ if (!content) {
+ return null;
+ }
+ var kind = content.type.kind;
+ if (kind !== "string" && kind !== "value" && kind !== "null" && kind !== "resolvedImage") {
+ return context.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");
+ }
+ nextTokenMayBeObject = true;
+ sections.push({
+ content,
+ scale: null,
+ font: null,
+ textColor: null
+ });
+ }
+ }
+ return new FormatExpression(sections);
+ };
+ FormatExpression.prototype.evaluate = function evaluate(ctx) {
+ var evaluateSection = function(section) {
+ var evaluatedContent = section.content.evaluate(ctx);
+ if (typeOf(evaluatedContent) === ResolvedImageType) {
+ return new FormattedSection("", evaluatedContent, null, null, null);
+ }
+ return new FormattedSection(toString$1(evaluatedContent), null, section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(",") : null, section.textColor ? section.textColor.evaluate(ctx) : null);
+ };
+ return new Formatted(this.sections.map(evaluateSection));
+ };
+ FormatExpression.prototype.eachChild = function eachChild(fn) {
+ for (var i = 0, list = this.sections; i < list.length; i += 1) {
+ var section = list[i];
+ fn(section.content);
+ if (section.scale) {
+ fn(section.scale);
+ }
+ if (section.font) {
+ fn(section.font);
+ }
+ if (section.textColor) {
+ fn(section.textColor);
+ }
+ }
+ };
+ FormatExpression.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ FormatExpression.prototype.serialize = function serialize2() {
+ var serialized = ["format"];
+ for (var i = 0, list = this.sections; i < list.length; i += 1) {
+ var section = list[i];
+ serialized.push(section.content.serialize());
+ var options = {};
+ if (section.scale) {
+ options["font-scale"] = section.scale.serialize();
+ }
+ if (section.font) {
+ options["text-font"] = section.font.serialize();
+ }
+ if (section.textColor) {
+ options["text-color"] = section.textColor.serialize();
+ }
+ serialized.push(options);
+ }
+ return serialized;
+ };
+ var ImageExpression = function ImageExpression2(input) {
+ this.type = ResolvedImageType;
+ this.input = input;
+ };
+ ImageExpression.parse = function parse2(args, context) {
+ if (args.length !== 2) {
+ return context.error("Expected two arguments.");
+ }
+ var name3 = context.parse(args[1], 1, StringType);
+ if (!name3) {
+ return context.error("No image name provided.");
+ }
+ return new ImageExpression(name3);
+ };
+ ImageExpression.prototype.evaluate = function evaluate(ctx) {
+ var evaluatedImageName = this.input.evaluate(ctx);
+ var value = ResolvedImage.fromString(evaluatedImageName);
+ if (value && ctx.availableImages) {
+ value.available = ctx.availableImages.indexOf(evaluatedImageName) > -1;
+ }
+ return value;
+ };
+ ImageExpression.prototype.eachChild = function eachChild(fn) {
+ fn(this.input);
+ };
+ ImageExpression.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ ImageExpression.prototype.serialize = function serialize2() {
+ return [
+ "image",
+ this.input.serialize()
+ ];
+ };
+ var types$1 = {
+ "to-boolean": BooleanType,
+ "to-color": ColorType,
+ "to-number": NumberType,
+ "to-string": StringType
+ };
+ var Coercion = function Coercion2(type, args) {
+ this.type = type;
+ this.args = args;
+ };
+ Coercion.parse = function parse2(args, context) {
+ if (args.length < 2) {
+ return context.error("Expected at least one argument.");
+ }
+ var name3 = args[0];
+ if ((name3 === "to-boolean" || name3 === "to-string") && args.length !== 2) {
+ return context.error("Expected one argument.");
+ }
+ var type = types$1[name3];
+ var parsed = [];
+ for (var i = 1; i < args.length; i++) {
+ var input = context.parse(args[i], i, ValueType);
+ if (!input) {
+ return null;
+ }
+ parsed.push(input);
+ }
+ return new Coercion(type, parsed);
+ };
+ Coercion.prototype.evaluate = function evaluate(ctx) {
+ if (this.type.kind === "boolean") {
+ return Boolean(this.args[0].evaluate(ctx));
+ } else if (this.type.kind === "color") {
+ var input;
+ var error2;
+ for (var i = 0, list = this.args; i < list.length; i += 1) {
+ var arg = list[i];
+ input = arg.evaluate(ctx);
+ error2 = null;
+ if (input instanceof Color2) {
+ return input;
+ } else if (typeof input === "string") {
+ var c = ctx.parseColor(input);
+ if (c) {
+ return c;
+ }
+ } else if (Array.isArray(input)) {
+ if (input.length < 3 || input.length > 4) {
+ error2 = "Invalid rbga value " + JSON.stringify(input) + ": expected an array containing either three or four numeric values.";
+ } else {
+ error2 = validateRGBA(input[0], input[1], input[2], input[3]);
+ }
+ if (!error2) {
+ return new Color2(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);
+ }
+ }
+ }
+ throw new RuntimeError(error2 || "Could not parse color from value '" + (typeof input === "string" ? input : String(JSON.stringify(input))) + "'");
+ } else if (this.type.kind === "number") {
+ var value = null;
+ for (var i$1 = 0, list$1 = this.args; i$1 < list$1.length; i$1 += 1) {
+ var arg$1 = list$1[i$1];
+ value = arg$1.evaluate(ctx);
+ if (value === null) {
+ return 0;
+ }
+ var num = Number(value);
+ if (isNaN(num)) {
+ continue;
+ }
+ return num;
+ }
+ throw new RuntimeError("Could not convert " + JSON.stringify(value) + " to number.");
+ } else if (this.type.kind === "formatted") {
+ return Formatted.fromString(toString$1(this.args[0].evaluate(ctx)));
+ } else if (this.type.kind === "resolvedImage") {
+ return ResolvedImage.fromString(toString$1(this.args[0].evaluate(ctx)));
+ } else {
+ return toString$1(this.args[0].evaluate(ctx));
+ }
+ };
+ Coercion.prototype.eachChild = function eachChild(fn) {
+ this.args.forEach(fn);
+ };
+ Coercion.prototype.outputDefined = function outputDefined() {
+ return this.args.every(function(arg) {
+ return arg.outputDefined();
+ });
+ };
+ Coercion.prototype.serialize = function serialize2() {
+ if (this.type.kind === "formatted") {
+ return new FormatExpression([{
+ content: this.args[0],
+ scale: null,
+ font: null,
+ textColor: null
+ }]).serialize();
+ }
+ if (this.type.kind === "resolvedImage") {
+ return new ImageExpression(this.args[0]).serialize();
+ }
+ var serialized = ["to-" + this.type.kind];
+ this.eachChild(function(child) {
+ serialized.push(child.serialize());
+ });
+ return serialized;
+ };
+ var geometryTypes = [
+ "Unknown",
+ "Point",
+ "LineString",
+ "Polygon"
+ ];
+ var EvaluationContext = function EvaluationContext2() {
+ this.globals = null;
+ this.feature = null;
+ this.featureState = null;
+ this.formattedSection = null;
+ this._parseColorCache = {};
+ this.availableImages = null;
+ this.canonical = null;
+ };
+ EvaluationContext.prototype.id = function id2() {
+ return this.feature && "id" in this.feature ? this.feature.id : null;
+ };
+ EvaluationContext.prototype.geometryType = function geometryType() {
+ return this.feature ? typeof this.feature.type === "number" ? geometryTypes[this.feature.type] : this.feature.type : null;
+ };
+ EvaluationContext.prototype.geometry = function geometry() {
+ return this.feature && "geometry" in this.feature ? this.feature.geometry : null;
+ };
+ EvaluationContext.prototype.canonicalID = function canonicalID() {
+ return this.canonical;
+ };
+ EvaluationContext.prototype.properties = function properties2() {
+ return this.feature && this.feature.properties || {};
+ };
+ EvaluationContext.prototype.parseColor = function parseColor(input) {
+ var cached = this._parseColorCache[input];
+ if (!cached) {
+ cached = this._parseColorCache[input] = Color2.parse(input);
+ }
+ return cached;
+ };
+ var CompoundExpression = function CompoundExpression2(name3, type, evaluate, args) {
+ this.name = name3;
+ this.type = type;
+ this._evaluate = evaluate;
+ this.args = args;
+ };
+ CompoundExpression.prototype.evaluate = function evaluate(ctx) {
+ return this._evaluate(ctx, this.args);
+ };
+ CompoundExpression.prototype.eachChild = function eachChild(fn) {
+ this.args.forEach(fn);
+ };
+ CompoundExpression.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ CompoundExpression.prototype.serialize = function serialize2() {
+ return [this.name].concat(this.args.map(function(arg) {
+ return arg.serialize();
+ }));
+ };
+ CompoundExpression.parse = function parse2(args, context) {
+ var ref$1;
+ var op = args[0];
+ var definition = CompoundExpression.definitions[op];
+ if (!definition) {
+ return context.error('Unknown expression "' + op + '". If you wanted a literal array, use ["literal", [...]].', 0);
+ }
+ var type = Array.isArray(definition) ? definition[0] : definition.type;
+ var availableOverloads = Array.isArray(definition) ? [[
+ definition[1],
+ definition[2]
+ ]] : definition.overloads;
+ var overloads = availableOverloads.filter(function(ref2) {
+ var signature = ref2[0];
+ return !Array.isArray(signature) || signature.length === args.length - 1;
+ });
+ var signatureContext = null;
+ for (var i$3 = 0, list = overloads; i$3 < list.length; i$3 += 1) {
+ var ref = list[i$3];
+ var params = ref[0];
+ var evaluate = ref[1];
+ signatureContext = new ParsingContext(context.registry, context.path, null, context.scope);
+ var parsedArgs = [];
+ var argParseFailed = false;
+ for (var i = 1; i < args.length; i++) {
+ var arg = args[i];
+ var expectedType = Array.isArray(params) ? params[i - 1] : params.type;
+ var parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);
+ if (!parsed) {
+ argParseFailed = true;
+ break;
+ }
+ parsedArgs.push(parsed);
+ }
+ if (argParseFailed) {
+ continue;
+ }
+ if (Array.isArray(params)) {
+ if (params.length !== parsedArgs.length) {
+ signatureContext.error("Expected " + params.length + " arguments, but found " + parsedArgs.length + " instead.");
+ continue;
+ }
+ }
+ for (var i$1 = 0; i$1 < parsedArgs.length; i$1++) {
+ var expected = Array.isArray(params) ? params[i$1] : params.type;
+ var arg$1 = parsedArgs[i$1];
+ signatureContext.concat(i$1 + 1).checkSubtype(expected, arg$1.type);
+ }
+ if (signatureContext.errors.length === 0) {
+ return new CompoundExpression(op, type, evaluate, parsedArgs);
+ }
+ }
+ if (overloads.length === 1) {
+ (ref$1 = context.errors).push.apply(ref$1, signatureContext.errors);
+ } else {
+ var expected$1 = overloads.length ? overloads : availableOverloads;
+ var signatures = expected$1.map(function(ref2) {
+ var params2 = ref2[0];
+ return stringifySignature(params2);
+ }).join(" | ");
+ var actualTypes = [];
+ for (var i$2 = 1; i$2 < args.length; i$2++) {
+ var parsed$1 = context.parse(args[i$2], 1 + actualTypes.length);
+ if (!parsed$1) {
+ return null;
+ }
+ actualTypes.push(toString(parsed$1.type));
+ }
+ context.error("Expected arguments of type " + signatures + ", but found (" + actualTypes.join(", ") + ") instead.");
+ }
+ return null;
+ };
+ CompoundExpression.register = function register2(registry2, definitions) {
+ CompoundExpression.definitions = definitions;
+ for (var name3 in definitions) {
+ registry2[name3] = CompoundExpression;
+ }
+ };
+ function stringifySignature(signature) {
+ if (Array.isArray(signature)) {
+ return "(" + signature.map(toString).join(", ") + ")";
+ } else {
+ return "(" + toString(signature.type) + "...)";
+ }
+ }
+ var CollatorExpression = function CollatorExpression2(caseSensitive, diacriticSensitive, locale) {
+ this.type = CollatorType;
+ this.locale = locale;
+ this.caseSensitive = caseSensitive;
+ this.diacriticSensitive = diacriticSensitive;
+ };
+ CollatorExpression.parse = function parse2(args, context) {
+ if (args.length !== 2) {
+ return context.error("Expected one argument.");
+ }
+ var options = args[1];
+ if (typeof options !== "object" || Array.isArray(options)) {
+ return context.error("Collator options argument must be an object.");
+ }
+ var caseSensitive = context.parse(options["case-sensitive"] === void 0 ? false : options["case-sensitive"], 1, BooleanType);
+ if (!caseSensitive) {
+ return null;
+ }
+ var diacriticSensitive = context.parse(options["diacritic-sensitive"] === void 0 ? false : options["diacritic-sensitive"], 1, BooleanType);
+ if (!diacriticSensitive) {
+ return null;
+ }
+ var locale = null;
+ if (options["locale"]) {
+ locale = context.parse(options["locale"], 1, StringType);
+ if (!locale) {
+ return null;
+ }
+ }
+ return new CollatorExpression(caseSensitive, diacriticSensitive, locale);
+ };
+ CollatorExpression.prototype.evaluate = function evaluate(ctx) {
+ return new Collator(this.caseSensitive.evaluate(ctx), this.diacriticSensitive.evaluate(ctx), this.locale ? this.locale.evaluate(ctx) : null);
+ };
+ CollatorExpression.prototype.eachChild = function eachChild(fn) {
+ fn(this.caseSensitive);
+ fn(this.diacriticSensitive);
+ if (this.locale) {
+ fn(this.locale);
+ }
+ };
+ CollatorExpression.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ CollatorExpression.prototype.serialize = function serialize2() {
+ var options = {};
+ options["case-sensitive"] = this.caseSensitive.serialize();
+ options["diacritic-sensitive"] = this.diacriticSensitive.serialize();
+ if (this.locale) {
+ options["locale"] = this.locale.serialize();
+ }
+ return [
+ "collator",
+ options
+ ];
+ };
+ var EXTENT = 8192;
+ function updateBBox(bbox, coord) {
+ bbox[0] = Math.min(bbox[0], coord[0]);
+ bbox[1] = Math.min(bbox[1], coord[1]);
+ bbox[2] = Math.max(bbox[2], coord[0]);
+ bbox[3] = Math.max(bbox[3], coord[1]);
+ }
+ function mercatorXfromLng(lng) {
+ return (180 + lng) / 360;
+ }
+ function mercatorYfromLat(lat) {
+ return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360;
+ }
+ function boxWithinBox(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;
+ }
+ function getTileCoordinates(p, canonical) {
+ var x = mercatorXfromLng(p[0]);
+ var y = mercatorYfromLat(p[1]);
+ var tilesAtZoom = Math.pow(2, canonical.z);
+ return [
+ Math.round(x * tilesAtZoom * EXTENT),
+ Math.round(y * tilesAtZoom * EXTENT)
+ ];
+ }
+ function onBoundary(p, p1, p2) {
+ var x1 = p[0] - p1[0];
+ var y1 = p[1] - p1[1];
+ var x2 = p[0] - p2[0];
+ var y2 = p[1] - p2[1];
+ return x1 * y2 - x2 * y1 === 0 && x1 * x2 <= 0 && y1 * y2 <= 0;
+ }
+ function rayIntersect(p, p1, p2) {
+ return p1[1] > p[1] !== p2[1] > p[1] && p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0];
+ }
+ function pointWithinPolygon(point, rings) {
+ var inside = false;
+ for (var i = 0, len = rings.length; i < len; i++) {
+ var ring = rings[i];
+ for (var j = 0, len2 = ring.length; j < len2 - 1; j++) {
+ if (onBoundary(point, ring[j], ring[j + 1])) {
+ return false;
+ }
+ if (rayIntersect(point, ring[j], ring[j + 1])) {
+ inside = !inside;
+ }
+ }
+ }
+ return inside;
+ }
+ function pointWithinPolygons(point, polygons) {
+ for (var i = 0; i < polygons.length; i++) {
+ if (pointWithinPolygon(point, polygons[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function perp(v1, v2) {
+ return v1[0] * v2[1] - v1[1] * v2[0];
+ }
+ function twoSided(p1, p2, q1, q2) {
+ var x1 = p1[0] - q1[0];
+ var y1 = p1[1] - q1[1];
+ var x2 = p2[0] - q1[0];
+ var y2 = p2[1] - q1[1];
+ var x3 = q2[0] - q1[0];
+ var y3 = q2[1] - q1[1];
+ var det1 = x1 * y3 - x3 * y1;
+ var det2 = x2 * y3 - x3 * y2;
+ if (det1 > 0 && det2 < 0 || det1 < 0 && det2 > 0) {
+ return true;
+ }
+ return false;
+ }
+ function lineIntersectLine(a, b, c, d) {
+ var vectorP = [
+ b[0] - a[0],
+ b[1] - a[1]
+ ];
+ var vectorQ = [
+ d[0] - c[0],
+ d[1] - c[1]
+ ];
+ if (perp(vectorQ, vectorP) === 0) {
+ return false;
+ }
+ if (twoSided(a, b, c, d) && twoSided(c, d, a, b)) {
+ return true;
+ }
+ return false;
+ }
+ function lineIntersectPolygon(p1, p2, polygon) {
+ for (var i = 0, list = polygon; i < list.length; i += 1) {
+ var ring = list[i];
+ for (var j = 0; j < ring.length - 1; ++j) {
+ if (lineIntersectLine(p1, p2, ring[j], ring[j + 1])) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ function lineStringWithinPolygon(line, polygon) {
+ for (var i = 0; i < line.length; ++i) {
+ if (!pointWithinPolygon(line[i], polygon)) {
+ return false;
+ }
+ }
+ for (var i$1 = 0; i$1 < line.length - 1; ++i$1) {
+ if (lineIntersectPolygon(line[i$1], line[i$1 + 1], polygon)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ function lineStringWithinPolygons(line, polygons) {
+ for (var i = 0; i < polygons.length; i++) {
+ if (lineStringWithinPolygon(line, polygons[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function getTilePolygon(coordinates, bbox, canonical) {
+ var polygon = [];
+ for (var i = 0; i < coordinates.length; i++) {
+ var ring = [];
+ for (var j = 0; j < coordinates[i].length; j++) {
+ var coord = getTileCoordinates(coordinates[i][j], canonical);
+ updateBBox(bbox, coord);
+ ring.push(coord);
+ }
+ polygon.push(ring);
+ }
+ return polygon;
+ }
+ function getTilePolygons(coordinates, bbox, canonical) {
+ var polygons = [];
+ for (var i = 0; i < coordinates.length; i++) {
+ var polygon = getTilePolygon(coordinates[i], bbox, canonical);
+ polygons.push(polygon);
+ }
+ return polygons;
+ }
+ function updatePoint(p, bbox, polyBBox, worldSize) {
+ if (p[0] < polyBBox[0] || p[0] > polyBBox[2]) {
+ var halfWorldSize = worldSize * 0.5;
+ var shift = p[0] - polyBBox[0] > halfWorldSize ? -worldSize : polyBBox[0] - p[0] > halfWorldSize ? worldSize : 0;
+ if (shift === 0) {
+ shift = p[0] - polyBBox[2] > halfWorldSize ? -worldSize : polyBBox[2] - p[0] > halfWorldSize ? worldSize : 0;
+ }
+ p[0] += shift;
+ }
+ updateBBox(bbox, p);
+ }
+ function resetBBox(bbox) {
+ bbox[0] = bbox[1] = Infinity;
+ bbox[2] = bbox[3] = -Infinity;
+ }
+ function getTilePoints(geometry, pointBBox, polyBBox, canonical) {
+ var worldSize = Math.pow(2, canonical.z) * EXTENT;
+ var shifts = [
+ canonical.x * EXTENT,
+ canonical.y * EXTENT
+ ];
+ var tilePoints = [];
+ for (var i$1 = 0, list$1 = geometry; i$1 < list$1.length; i$1 += 1) {
+ var points = list$1[i$1];
+ for (var i = 0, list = points; i < list.length; i += 1) {
+ var point = list[i];
+ var p = [
+ point.x + shifts[0],
+ point.y + shifts[1]
+ ];
+ updatePoint(p, pointBBox, polyBBox, worldSize);
+ tilePoints.push(p);
+ }
+ }
+ return tilePoints;
+ }
+ function getTileLines(geometry, lineBBox, polyBBox, canonical) {
+ var worldSize = Math.pow(2, canonical.z) * EXTENT;
+ var shifts = [
+ canonical.x * EXTENT,
+ canonical.y * EXTENT
+ ];
+ var tileLines = [];
+ for (var i$1 = 0, list$1 = geometry; i$1 < list$1.length; i$1 += 1) {
+ var line = list$1[i$1];
+ var tileLine = [];
+ for (var i = 0, list = line; i < list.length; i += 1) {
+ var point = list[i];
+ var p = [
+ point.x + shifts[0],
+ point.y + shifts[1]
+ ];
+ updateBBox(lineBBox, p);
+ tileLine.push(p);
+ }
+ tileLines.push(tileLine);
+ }
+ if (lineBBox[2] - lineBBox[0] <= worldSize / 2) {
+ resetBBox(lineBBox);
+ for (var i$3 = 0, list$3 = tileLines; i$3 < list$3.length; i$3 += 1) {
+ var line$1 = list$3[i$3];
+ for (var i$2 = 0, list$2 = line$1; i$2 < list$2.length; i$2 += 1) {
+ var p$1 = list$2[i$2];
+ updatePoint(p$1, lineBBox, polyBBox, worldSize);
+ }
+ }
+ }
+ return tileLines;
+ }
+ function pointsWithinPolygons(ctx, polygonGeometry) {
+ var pointBBox = [
+ Infinity,
+ Infinity,
+ -Infinity,
+ -Infinity
+ ];
+ var polyBBox = [
+ Infinity,
+ Infinity,
+ -Infinity,
+ -Infinity
+ ];
+ var canonical = ctx.canonicalID();
+ if (polygonGeometry.type === "Polygon") {
+ var tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);
+ var tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);
+ if (!boxWithinBox(pointBBox, polyBBox)) {
+ return false;
+ }
+ for (var i = 0, list = tilePoints; i < list.length; i += 1) {
+ var point = list[i];
+ if (!pointWithinPolygon(point, tilePolygon)) {
+ return false;
+ }
+ }
+ }
+ if (polygonGeometry.type === "MultiPolygon") {
+ var tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);
+ var tilePoints$1 = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);
+ if (!boxWithinBox(pointBBox, polyBBox)) {
+ return false;
+ }
+ for (var i$1 = 0, list$1 = tilePoints$1; i$1 < list$1.length; i$1 += 1) {
+ var point$1 = list$1[i$1];
+ if (!pointWithinPolygons(point$1, tilePolygons)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ function linesWithinPolygons(ctx, polygonGeometry) {
+ var lineBBox = [
+ Infinity,
+ Infinity,
+ -Infinity,
+ -Infinity
+ ];
+ var polyBBox = [
+ Infinity,
+ Infinity,
+ -Infinity,
+ -Infinity
+ ];
+ var canonical = ctx.canonicalID();
+ if (polygonGeometry.type === "Polygon") {
+ var tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);
+ var tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);
+ if (!boxWithinBox(lineBBox, polyBBox)) {
+ return false;
+ }
+ for (var i = 0, list = tileLines; i < list.length; i += 1) {
+ var line = list[i];
+ if (!lineStringWithinPolygon(line, tilePolygon)) {
+ return false;
+ }
+ }
+ }
+ if (polygonGeometry.type === "MultiPolygon") {
+ var tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);
+ var tileLines$1 = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);
+ if (!boxWithinBox(lineBBox, polyBBox)) {
+ return false;
+ }
+ for (var i$1 = 0, list$1 = tileLines$1; i$1 < list$1.length; i$1 += 1) {
+ var line$1 = list$1[i$1];
+ if (!lineStringWithinPolygons(line$1, tilePolygons)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ var Within = function Within2(geojson, geometries) {
+ this.type = BooleanType;
+ this.geojson = geojson;
+ this.geometries = geometries;
+ };
+ Within.parse = function parse2(args, context) {
+ if (args.length !== 2) {
+ return context.error("'within' expression requires exactly one argument, but found " + (args.length - 1) + " instead.");
+ }
+ if (isValue(args[1])) {
+ var geojson = args[1];
+ if (geojson.type === "FeatureCollection") {
+ for (var i = 0; i < geojson.features.length; ++i) {
+ var type = geojson.features[i].geometry.type;
+ if (type === "Polygon" || type === "MultiPolygon") {
+ return new Within(geojson, geojson.features[i].geometry);
+ }
+ }
+ } else if (geojson.type === "Feature") {
+ var type$1 = geojson.geometry.type;
+ if (type$1 === "Polygon" || type$1 === "MultiPolygon") {
+ return new Within(geojson, geojson.geometry);
+ }
+ } else if (geojson.type === "Polygon" || geojson.type === "MultiPolygon") {
+ return new Within(geojson, geojson);
+ }
+ }
+ return context.error("'within' expression requires valid geojson object that contains polygon geometry type.");
+ };
+ Within.prototype.evaluate = function evaluate(ctx) {
+ if (ctx.geometry() != null && ctx.canonicalID() != null) {
+ if (ctx.geometryType() === "Point") {
+ return pointsWithinPolygons(ctx, this.geometries);
+ } else if (ctx.geometryType() === "LineString") {
+ return linesWithinPolygons(ctx, this.geometries);
+ }
+ }
+ return false;
+ };
+ Within.prototype.eachChild = function eachChild() {
+ };
+ Within.prototype.outputDefined = function outputDefined() {
+ return true;
+ };
+ Within.prototype.serialize = function serialize2() {
+ return [
+ "within",
+ this.geojson
+ ];
+ };
+ function isFeatureConstant(e) {
+ if (e instanceof CompoundExpression) {
+ if (e.name === "get" && e.args.length === 1) {
+ return false;
+ } else if (e.name === "feature-state") {
+ return false;
+ } else if (e.name === "has" && e.args.length === 1) {
+ return false;
+ } else if (e.name === "properties" || e.name === "geometry-type" || e.name === "id") {
+ return false;
+ } else if (/^filter-/.test(e.name)) {
+ return false;
+ }
+ }
+ if (e instanceof Within) {
+ return false;
+ }
+ var result = true;
+ e.eachChild(function(arg) {
+ if (result && !isFeatureConstant(arg)) {
+ result = false;
+ }
+ });
+ return result;
+ }
+ function isStateConstant(e) {
+ if (e instanceof CompoundExpression) {
+ if (e.name === "feature-state") {
+ return false;
+ }
+ }
+ var result = true;
+ e.eachChild(function(arg) {
+ if (result && !isStateConstant(arg)) {
+ result = false;
+ }
+ });
+ return result;
+ }
+ function isGlobalPropertyConstant(e, properties2) {
+ if (e instanceof CompoundExpression && properties2.indexOf(e.name) >= 0) {
+ return false;
+ }
+ var result = true;
+ e.eachChild(function(arg) {
+ if (result && !isGlobalPropertyConstant(arg, properties2)) {
+ result = false;
+ }
+ });
+ return result;
+ }
+ var Var = function Var2(name3, boundExpression) {
+ this.type = boundExpression.type;
+ this.name = name3;
+ this.boundExpression = boundExpression;
+ };
+ Var.parse = function parse2(args, context) {
+ if (args.length !== 2 || typeof args[1] !== "string") {
+ return context.error("'var' expression requires exactly one string literal argument.");
+ }
+ var name3 = args[1];
+ if (!context.scope.has(name3)) {
+ return context.error('Unknown variable "' + name3 + '". Make sure "' + name3 + '" has been bound in an enclosing "let" expression before using it.', 1);
+ }
+ return new Var(name3, context.scope.get(name3));
+ };
+ Var.prototype.evaluate = function evaluate(ctx) {
+ return this.boundExpression.evaluate(ctx);
+ };
+ Var.prototype.eachChild = function eachChild() {
+ };
+ Var.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ Var.prototype.serialize = function serialize2() {
+ return [
+ "var",
+ this.name
+ ];
+ };
+ var ParsingContext = function ParsingContext2(registry2, path, expectedType, scope, errors) {
+ if (path === void 0)
+ path = [];
+ if (scope === void 0)
+ scope = new Scope();
+ if (errors === void 0)
+ errors = [];
+ this.registry = registry2;
+ this.path = path;
+ this.key = path.map(function(part) {
+ return "[" + part + "]";
+ }).join("");
+ this.scope = scope;
+ this.errors = errors;
+ this.expectedType = expectedType;
+ };
+ ParsingContext.prototype.parse = function parse2(expr, index, expectedType, bindings, options) {
+ if (options === void 0)
+ options = {};
+ if (index) {
+ return this.concat(index, expectedType, bindings)._parse(expr, options);
+ }
+ return this._parse(expr, options);
+ };
+ ParsingContext.prototype._parse = function _parse(expr, options) {
+ if (expr === null || typeof expr === "string" || typeof expr === "boolean" || typeof expr === "number") {
+ expr = [
+ "literal",
+ expr
+ ];
+ }
+ function annotate(parsed2, type, typeAnnotation) {
+ if (typeAnnotation === "assert") {
+ return new Assertion(type, [parsed2]);
+ } else if (typeAnnotation === "coerce") {
+ return new Coercion(type, [parsed2]);
+ } else {
+ return parsed2;
+ }
+ }
+ if (Array.isArray(expr)) {
+ if (expr.length === 0) {
+ return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');
+ }
+ var op = expr[0];
+ if (typeof op !== "string") {
+ this.error("Expression name must be a string, but found " + typeof op + ' instead. If you wanted a literal array, use ["literal", [...]].', 0);
+ return null;
+ }
+ var Expr = this.registry[op];
+ if (Expr) {
+ var parsed = Expr.parse(expr, this);
+ if (!parsed) {
+ return null;
+ }
+ if (this.expectedType) {
+ var expected = this.expectedType;
+ var actual = parsed.type;
+ if ((expected.kind === "string" || expected.kind === "number" || expected.kind === "boolean" || expected.kind === "object" || expected.kind === "array") && actual.kind === "value") {
+ parsed = annotate(parsed, expected, options.typeAnnotation || "assert");
+ } else if ((expected.kind === "color" || expected.kind === "formatted" || expected.kind === "resolvedImage") && (actual.kind === "value" || actual.kind === "string")) {
+ parsed = annotate(parsed, expected, options.typeAnnotation || "coerce");
+ } else if (this.checkSubtype(expected, actual)) {
+ return null;
+ }
+ }
+ if (!(parsed instanceof Literal) && parsed.type.kind !== "resolvedImage" && isConstant(parsed)) {
+ var ec = new EvaluationContext();
+ try {
+ parsed = new Literal(parsed.type, parsed.evaluate(ec));
+ } catch (e) {
+ this.error(e.message);
+ return null;
+ }
+ }
+ return parsed;
+ }
+ return this.error('Unknown expression "' + op + '". If you wanted a literal array, use ["literal", [...]].', 0);
+ } else if (typeof expr === "undefined") {
+ return this.error("'undefined' value invalid. Use null instead.");
+ } else if (typeof expr === "object") {
+ return this.error('Bare objects invalid. Use ["literal", {...}] instead.');
+ } else {
+ return this.error("Expected an array, but found " + typeof expr + " instead.");
+ }
+ };
+ ParsingContext.prototype.concat = function concat(index, expectedType, bindings) {
+ var path = typeof index === "number" ? this.path.concat(index) : this.path;
+ var scope = bindings ? this.scope.concat(bindings) : this.scope;
+ return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors);
+ };
+ ParsingContext.prototype.error = function error2(error$1) {
+ var keys = [], len = arguments.length - 1;
+ while (len-- > 0)
+ keys[len] = arguments[len + 1];
+ var key = "" + this.key + keys.map(function(k) {
+ return "[" + k + "]";
+ }).join("");
+ this.errors.push(new ParsingError(key, error$1));
+ };
+ ParsingContext.prototype.checkSubtype = function checkSubtype$1(expected, t) {
+ var error2 = checkSubtype(expected, t);
+ if (error2) {
+ this.error(error2);
+ }
+ return error2;
+ };
+ function isConstant(expression2) {
+ if (expression2 instanceof Var) {
+ return isConstant(expression2.boundExpression);
+ } else if (expression2 instanceof CompoundExpression && expression2.name === "error") {
+ return false;
+ } else if (expression2 instanceof CollatorExpression) {
+ return false;
+ } else if (expression2 instanceof Within) {
+ return false;
+ }
+ var isTypeAnnotation = expression2 instanceof Coercion || expression2 instanceof Assertion;
+ var childrenConstant = true;
+ expression2.eachChild(function(child) {
+ if (isTypeAnnotation) {
+ childrenConstant = childrenConstant && isConstant(child);
+ } else {
+ childrenConstant = childrenConstant && child instanceof Literal;
+ }
+ });
+ if (!childrenConstant) {
+ return false;
+ }
+ return isFeatureConstant(expression2) && isGlobalPropertyConstant(expression2, [
+ "zoom",
+ "heatmap-density",
+ "line-progress",
+ "accumulated",
+ "is-supported-script"
+ ]);
+ }
+ function findStopLessThanOrEqualTo(stops, input) {
+ var lastIndex = stops.length - 1;
+ var lowerIndex = 0;
+ var upperIndex = lastIndex;
+ var currentIndex = 0;
+ var currentValue, nextValue;
+ while (lowerIndex <= upperIndex) {
+ currentIndex = Math.floor((lowerIndex + upperIndex) / 2);
+ currentValue = stops[currentIndex];
+ nextValue = stops[currentIndex + 1];
+ if (currentValue <= input) {
+ if (currentIndex === lastIndex || input < nextValue) {
+ return currentIndex;
+ }
+ lowerIndex = currentIndex + 1;
+ } else if (currentValue > input) {
+ upperIndex = currentIndex - 1;
+ } else {
+ throw new RuntimeError("Input is not a number.");
+ }
+ }
+ return 0;
+ }
+ var Step = function Step2(type, input, stops) {
+ this.type = type;
+ this.input = input;
+ this.labels = [];
+ this.outputs = [];
+ for (var i = 0, list = stops; i < list.length; i += 1) {
+ var ref = list[i];
+ var label = ref[0];
+ var expression2 = ref[1];
+ this.labels.push(label);
+ this.outputs.push(expression2);
+ }
+ };
+ Step.parse = function parse2(args, context) {
+ if (args.length - 1 < 4) {
+ return context.error("Expected at least 4 arguments, but found only " + (args.length - 1) + ".");
+ }
+ if ((args.length - 1) % 2 !== 0) {
+ return context.error("Expected an even number of arguments.");
+ }
+ var input = context.parse(args[1], 1, NumberType);
+ if (!input) {
+ return null;
+ }
+ var stops = [];
+ var outputType = null;
+ if (context.expectedType && context.expectedType.kind !== "value") {
+ outputType = context.expectedType;
+ }
+ for (var i = 1; i < args.length; i += 2) {
+ var label = i === 1 ? -Infinity : args[i];
+ var value = args[i + 1];
+ var labelKey = i;
+ var valueKey = i + 1;
+ if (typeof label !== "number") {
+ return context.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);
+ }
+ if (stops.length && stops[stops.length - 1][0] >= label) {
+ return context.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.', labelKey);
+ }
+ var parsed = context.parse(value, valueKey, outputType);
+ if (!parsed) {
+ return null;
+ }
+ outputType = outputType || parsed.type;
+ stops.push([
+ label,
+ parsed
+ ]);
+ }
+ return new Step(outputType, input, stops);
+ };
+ Step.prototype.evaluate = function evaluate(ctx) {
+ var labels = this.labels;
+ var outputs = this.outputs;
+ if (labels.length === 1) {
+ return outputs[0].evaluate(ctx);
+ }
+ var value = this.input.evaluate(ctx);
+ if (value <= labels[0]) {
+ return outputs[0].evaluate(ctx);
+ }
+ var stopCount = labels.length;
+ if (value >= labels[stopCount - 1]) {
+ return outputs[stopCount - 1].evaluate(ctx);
+ }
+ var index = findStopLessThanOrEqualTo(labels, value);
+ return outputs[index].evaluate(ctx);
+ };
+ Step.prototype.eachChild = function eachChild(fn) {
+ fn(this.input);
+ for (var i = 0, list = this.outputs; i < list.length; i += 1) {
+ var expression2 = list[i];
+ fn(expression2);
+ }
+ };
+ Step.prototype.outputDefined = function outputDefined() {
+ return this.outputs.every(function(out) {
+ return out.outputDefined();
+ });
+ };
+ Step.prototype.serialize = function serialize2() {
+ var serialized = [
+ "step",
+ this.input.serialize()
+ ];
+ for (var i = 0; i < this.labels.length; i++) {
+ if (i > 0) {
+ serialized.push(this.labels[i]);
+ }
+ serialized.push(this.outputs[i].serialize());
+ }
+ return serialized;
+ };
+ function number(a, b, t) {
+ return a * (1 - t) + b * t;
+ }
+ function color2(from, to, t) {
+ return new Color2(number(from.r, to.r, t), number(from.g, to.g, t), number(from.b, to.b, t), number(from.a, to.a, t));
+ }
+ function array$1(from, to, t) {
+ return from.map(function(d, i) {
+ return number(d, to[i], t);
+ });
+ }
+ var interpolate = /* @__PURE__ */ Object.freeze({
+ __proto__: null,
+ number,
+ color: color2,
+ array: array$1
+ });
+ var Xn2 = 0.95047, Yn2 = 1, Zn2 = 1.08883, t02 = 4 / 29, t12 = 6 / 29, t22 = 3 * t12 * t12, t32 = t12 * t12 * t12, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;
+ function xyz2lab2(t) {
+ return t > t32 ? Math.pow(t, 1 / 3) : t / t22 + t02;
+ }
+ function lab2xyz2(t) {
+ return t > t12 ? t * t * t : t22 * (t - t02);
+ }
+ function xyz2rgb(x) {
+ return 255 * (x <= 31308e-7 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
+ }
+ function rgb2xyz(x) {
+ x /= 255;
+ return x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
+ }
+ function rgbToLab(rgbColor) {
+ var b = rgb2xyz(rgbColor.r), a = rgb2xyz(rgbColor.g), l = rgb2xyz(rgbColor.b), x = xyz2lab2((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn2), y = xyz2lab2((0.2126729 * b + 0.7151522 * a + 0.072175 * l) / Yn2), z = xyz2lab2((0.0193339 * b + 0.119192 * a + 0.9503041 * l) / Zn2);
+ return {
+ l: 116 * y - 16,
+ a: 500 * (x - y),
+ b: 200 * (y - z),
+ alpha: rgbColor.a
+ };
+ }
+ function labToRgb(labColor) {
+ var y = (labColor.l + 16) / 116, x = isNaN(labColor.a) ? y : y + labColor.a / 500, z = isNaN(labColor.b) ? y : y - labColor.b / 200;
+ y = Yn2 * lab2xyz2(y);
+ x = Xn2 * lab2xyz2(x);
+ z = Zn2 * lab2xyz2(z);
+ return new Color2(xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z), xyz2rgb(-0.969266 * x + 1.8760108 * y + 0.041556 * z), xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z), labColor.alpha);
+ }
+ function interpolateLab(from, to, t) {
+ return {
+ l: number(from.l, to.l, t),
+ a: number(from.a, to.a, t),
+ b: number(from.b, to.b, t),
+ alpha: number(from.alpha, to.alpha, t)
+ };
+ }
+ function rgbToHcl(rgbColor) {
+ var ref = rgbToLab(rgbColor);
+ var l = ref.l;
+ var a = ref.a;
+ var b = ref.b;
+ var h = Math.atan2(b, a) * rad2deg;
+ return {
+ h: h < 0 ? h + 360 : h,
+ c: Math.sqrt(a * a + b * b),
+ l,
+ alpha: rgbColor.a
+ };
+ }
+ function hclToRgb(hclColor) {
+ var h = hclColor.h * deg2rad, c = hclColor.c, l = hclColor.l;
+ return labToRgb({
+ l,
+ a: Math.cos(h) * c,
+ b: Math.sin(h) * c,
+ alpha: hclColor.alpha
+ });
+ }
+ function interpolateHue(a, b, t) {
+ var d = b - a;
+ return a + t * (d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d);
+ }
+ function interpolateHcl(from, to, t) {
+ return {
+ h: interpolateHue(from.h, to.h, t),
+ c: number(from.c, to.c, t),
+ l: number(from.l, to.l, t),
+ alpha: number(from.alpha, to.alpha, t)
+ };
+ }
+ var lab3 = {
+ forward: rgbToLab,
+ reverse: labToRgb,
+ interpolate: interpolateLab
+ };
+ var hcl3 = {
+ forward: rgbToHcl,
+ reverse: hclToRgb,
+ interpolate: interpolateHcl
+ };
+ var colorSpaces = /* @__PURE__ */ Object.freeze({
+ __proto__: null,
+ lab: lab3,
+ hcl: hcl3
+ });
+ var Interpolate = function Interpolate2(type, operator, interpolation, input, stops) {
+ this.type = type;
+ this.operator = operator;
+ this.interpolation = interpolation;
+ this.input = input;
+ this.labels = [];
+ this.outputs = [];
+ for (var i = 0, list = stops; i < list.length; i += 1) {
+ var ref = list[i];
+ var label = ref[0];
+ var expression2 = ref[1];
+ this.labels.push(label);
+ this.outputs.push(expression2);
+ }
+ };
+ Interpolate.interpolationFactor = function interpolationFactor2(interpolation, input, lower, upper) {
+ var t = 0;
+ if (interpolation.name === "exponential") {
+ t = exponentialInterpolation(input, interpolation.base, lower, upper);
+ } else if (interpolation.name === "linear") {
+ t = exponentialInterpolation(input, 1, lower, upper);
+ } else if (interpolation.name === "cubic-bezier") {
+ var c = interpolation.controlPoints;
+ var ub = new unitbezier(c[0], c[1], c[2], c[3]);
+ t = ub.solve(exponentialInterpolation(input, 1, lower, upper));
+ }
+ return t;
+ };
+ Interpolate.parse = function parse2(args, context) {
+ var operator = args[0];
+ var interpolation = args[1];
+ var input = args[2];
+ var rest = args.slice(3);
+ if (!Array.isArray(interpolation) || interpolation.length === 0) {
+ return context.error("Expected an interpolation type expression.", 1);
+ }
+ if (interpolation[0] === "linear") {
+ interpolation = { name: "linear" };
+ } else if (interpolation[0] === "exponential") {
+ var base = interpolation[1];
+ if (typeof base !== "number") {
+ return context.error("Exponential interpolation requires a numeric base.", 1, 1);
+ }
+ interpolation = {
+ name: "exponential",
+ base
+ };
+ } else if (interpolation[0] === "cubic-bezier") {
+ var controlPoints = interpolation.slice(1);
+ if (controlPoints.length !== 4 || controlPoints.some(function(t) {
+ return typeof t !== "number" || t < 0 || t > 1;
+ })) {
+ return context.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.", 1);
+ }
+ interpolation = {
+ name: "cubic-bezier",
+ controlPoints
+ };
+ } else {
+ return context.error("Unknown interpolation type " + String(interpolation[0]), 1, 0);
+ }
+ if (args.length - 1 < 4) {
+ return context.error("Expected at least 4 arguments, but found only " + (args.length - 1) + ".");
+ }
+ if ((args.length - 1) % 2 !== 0) {
+ return context.error("Expected an even number of arguments.");
+ }
+ input = context.parse(input, 2, NumberType);
+ if (!input) {
+ return null;
+ }
+ var stops = [];
+ var outputType = null;
+ if (operator === "interpolate-hcl" || operator === "interpolate-lab") {
+ outputType = ColorType;
+ } else if (context.expectedType && context.expectedType.kind !== "value") {
+ outputType = context.expectedType;
+ }
+ for (var i = 0; i < rest.length; i += 2) {
+ var label = rest[i];
+ var value = rest[i + 1];
+ var labelKey = i + 3;
+ var valueKey = i + 4;
+ if (typeof label !== "number") {
+ return context.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);
+ }
+ if (stops.length && stops[stops.length - 1][0] >= label) {
+ return context.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.', labelKey);
+ }
+ var parsed = context.parse(value, valueKey, outputType);
+ if (!parsed) {
+ return null;
+ }
+ outputType = outputType || parsed.type;
+ stops.push([
+ label,
+ parsed
+ ]);
+ }
+ if (outputType.kind !== "number" && outputType.kind !== "color" && !(outputType.kind === "array" && outputType.itemType.kind === "number" && typeof outputType.N === "number")) {
+ return context.error("Type " + toString(outputType) + " is not interpolatable.");
+ }
+ return new Interpolate(outputType, operator, interpolation, input, stops);
+ };
+ Interpolate.prototype.evaluate = function evaluate(ctx) {
+ var labels = this.labels;
+ var outputs = this.outputs;
+ if (labels.length === 1) {
+ return outputs[0].evaluate(ctx);
+ }
+ var value = this.input.evaluate(ctx);
+ if (value <= labels[0]) {
+ return outputs[0].evaluate(ctx);
+ }
+ var stopCount = labels.length;
+ if (value >= labels[stopCount - 1]) {
+ return outputs[stopCount - 1].evaluate(ctx);
+ }
+ var index = findStopLessThanOrEqualTo(labels, value);
+ var lower = labels[index];
+ var upper = labels[index + 1];
+ var t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);
+ var outputLower = outputs[index].evaluate(ctx);
+ var outputUpper = outputs[index + 1].evaluate(ctx);
+ if (this.operator === "interpolate") {
+ return interpolate[this.type.kind.toLowerCase()](outputLower, outputUpper, t);
+ } else if (this.operator === "interpolate-hcl") {
+ return hcl3.reverse(hcl3.interpolate(hcl3.forward(outputLower), hcl3.forward(outputUpper), t));
+ } else {
+ return lab3.reverse(lab3.interpolate(lab3.forward(outputLower), lab3.forward(outputUpper), t));
+ }
+ };
+ Interpolate.prototype.eachChild = function eachChild(fn) {
+ fn(this.input);
+ for (var i = 0, list = this.outputs; i < list.length; i += 1) {
+ var expression2 = list[i];
+ fn(expression2);
+ }
+ };
+ Interpolate.prototype.outputDefined = function outputDefined() {
+ return this.outputs.every(function(out) {
+ return out.outputDefined();
+ });
+ };
+ Interpolate.prototype.serialize = function serialize2() {
+ var interpolation;
+ if (this.interpolation.name === "linear") {
+ interpolation = ["linear"];
+ } else if (this.interpolation.name === "exponential") {
+ if (this.interpolation.base === 1) {
+ interpolation = ["linear"];
+ } else {
+ interpolation = [
+ "exponential",
+ this.interpolation.base
+ ];
+ }
+ } else {
+ interpolation = ["cubic-bezier"].concat(this.interpolation.controlPoints);
+ }
+ var serialized = [
+ this.operator,
+ interpolation,
+ this.input.serialize()
+ ];
+ for (var i = 0; i < this.labels.length; i++) {
+ serialized.push(this.labels[i], this.outputs[i].serialize());
+ }
+ return serialized;
+ };
+ function exponentialInterpolation(input, base, lowerValue, upperValue) {
+ var difference = upperValue - lowerValue;
+ var progress = input - lowerValue;
+ if (difference === 0) {
+ return 0;
+ } else if (base === 1) {
+ return progress / difference;
+ } else {
+ return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
+ }
+ }
+ var Coalesce = function Coalesce2(type, args) {
+ this.type = type;
+ this.args = args;
+ };
+ Coalesce.parse = function parse2(args, context) {
+ if (args.length < 2) {
+ return context.error("Expectected at least one argument.");
+ }
+ var outputType = null;
+ var expectedType = context.expectedType;
+ if (expectedType && expectedType.kind !== "value") {
+ outputType = expectedType;
+ }
+ var parsedArgs = [];
+ for (var i = 0, list = args.slice(1); i < list.length; i += 1) {
+ var arg = list[i];
+ var parsed = context.parse(arg, 1 + parsedArgs.length, outputType, void 0, { typeAnnotation: "omit" });
+ if (!parsed) {
+ return null;
+ }
+ outputType = outputType || parsed.type;
+ parsedArgs.push(parsed);
+ }
+ var needsAnnotation = expectedType && parsedArgs.some(function(arg2) {
+ return checkSubtype(expectedType, arg2.type);
+ });
+ return needsAnnotation ? new Coalesce(ValueType, parsedArgs) : new Coalesce(outputType, parsedArgs);
+ };
+ Coalesce.prototype.evaluate = function evaluate(ctx) {
+ var result = null;
+ var argCount = 0;
+ var requestedImageName;
+ for (var i = 0, list = this.args; i < list.length; i += 1) {
+ var arg = list[i];
+ argCount++;
+ result = arg.evaluate(ctx);
+ if (result && result instanceof ResolvedImage && !result.available) {
+ if (!requestedImageName) {
+ requestedImageName = result.name;
+ }
+ result = null;
+ if (argCount === this.args.length) {
+ result = requestedImageName;
+ }
+ }
+ if (result !== null) {
+ break;
+ }
+ }
+ return result;
+ };
+ Coalesce.prototype.eachChild = function eachChild(fn) {
+ this.args.forEach(fn);
+ };
+ Coalesce.prototype.outputDefined = function outputDefined() {
+ return this.args.every(function(arg) {
+ return arg.outputDefined();
+ });
+ };
+ Coalesce.prototype.serialize = function serialize2() {
+ var serialized = ["coalesce"];
+ this.eachChild(function(child) {
+ serialized.push(child.serialize());
+ });
+ return serialized;
+ };
+ var Let = function Let2(bindings, result) {
+ this.type = result.type;
+ this.bindings = [].concat(bindings);
+ this.result = result;
+ };
+ Let.prototype.evaluate = function evaluate(ctx) {
+ return this.result.evaluate(ctx);
+ };
+ Let.prototype.eachChild = function eachChild(fn) {
+ for (var i = 0, list = this.bindings; i < list.length; i += 1) {
+ var binding = list[i];
+ fn(binding[1]);
+ }
+ fn(this.result);
+ };
+ Let.parse = function parse2(args, context) {
+ if (args.length < 4) {
+ return context.error("Expected at least 3 arguments, but found " + (args.length - 1) + " instead.");
+ }
+ var bindings = [];
+ for (var i = 1; i < args.length - 1; i += 2) {
+ var name3 = args[i];
+ if (typeof name3 !== "string") {
+ return context.error("Expected string, but found " + typeof name3 + " instead.", i);
+ }
+ if (/[^a-zA-Z0-9_]/.test(name3)) {
+ return context.error("Variable names must contain only alphanumeric characters or '_'.", i);
+ }
+ var value = context.parse(args[i + 1], i + 1);
+ if (!value) {
+ return null;
+ }
+ bindings.push([
+ name3,
+ value
+ ]);
+ }
+ var result = context.parse(args[args.length - 1], args.length - 1, context.expectedType, bindings);
+ if (!result) {
+ return null;
+ }
+ return new Let(bindings, result);
+ };
+ Let.prototype.outputDefined = function outputDefined() {
+ return this.result.outputDefined();
+ };
+ Let.prototype.serialize = function serialize2() {
+ var serialized = ["let"];
+ for (var i = 0, list = this.bindings; i < list.length; i += 1) {
+ var ref = list[i];
+ var name3 = ref[0];
+ var expr = ref[1];
+ serialized.push(name3, expr.serialize());
+ }
+ serialized.push(this.result.serialize());
+ return serialized;
+ };
+ var At = function At2(type, index, input) {
+ this.type = type;
+ this.index = index;
+ this.input = input;
+ };
+ At.parse = function parse2(args, context) {
+ if (args.length !== 3) {
+ return context.error("Expected 2 arguments, but found " + (args.length - 1) + " instead.");
+ }
+ var index = context.parse(args[1], 1, NumberType);
+ var input = context.parse(args[2], 2, array(context.expectedType || ValueType));
+ if (!index || !input) {
+ return null;
+ }
+ var t = input.type;
+ return new At(t.itemType, index, input);
+ };
+ At.prototype.evaluate = function evaluate(ctx) {
+ var index = this.index.evaluate(ctx);
+ var array2 = this.input.evaluate(ctx);
+ if (index < 0) {
+ throw new RuntimeError("Array index out of bounds: " + index + " < 0.");
+ }
+ if (index >= array2.length) {
+ throw new RuntimeError("Array index out of bounds: " + index + " > " + (array2.length - 1) + ".");
+ }
+ if (index !== Math.floor(index)) {
+ throw new RuntimeError("Array index must be an integer, but found " + index + " instead.");
+ }
+ return array2[index];
+ };
+ At.prototype.eachChild = function eachChild(fn) {
+ fn(this.index);
+ fn(this.input);
+ };
+ At.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ At.prototype.serialize = function serialize2() {
+ return [
+ "at",
+ this.index.serialize(),
+ this.input.serialize()
+ ];
+ };
+ var In = function In2(needle, haystack) {
+ this.type = BooleanType;
+ this.needle = needle;
+ this.haystack = haystack;
+ };
+ In.parse = function parse2(args, context) {
+ if (args.length !== 3) {
+ return context.error("Expected 2 arguments, but found " + (args.length - 1) + " instead.");
+ }
+ var needle = context.parse(args[1], 1, ValueType);
+ var haystack = context.parse(args[2], 2, ValueType);
+ if (!needle || !haystack) {
+ return null;
+ }
+ if (!isValidType(needle.type, [
+ BooleanType,
+ StringType,
+ NumberType,
+ NullType,
+ ValueType
+ ])) {
+ return context.error("Expected first argument to be of type boolean, string, number or null, but found " + toString(needle.type) + " instead");
+ }
+ return new In(needle, haystack);
+ };
+ In.prototype.evaluate = function evaluate(ctx) {
+ var needle = this.needle.evaluate(ctx);
+ var haystack = this.haystack.evaluate(ctx);
+ if (!haystack) {
+ return false;
+ }
+ if (!isValidNativeType(needle, [
+ "boolean",
+ "string",
+ "number",
+ "null"
+ ])) {
+ throw new RuntimeError("Expected first argument to be of type boolean, string, number or null, but found " + toString(typeOf(needle)) + " instead.");
+ }
+ if (!isValidNativeType(haystack, [
+ "string",
+ "array"
+ ])) {
+ throw new RuntimeError("Expected second argument to be of type array or string, but found " + toString(typeOf(haystack)) + " instead.");
+ }
+ return haystack.indexOf(needle) >= 0;
+ };
+ In.prototype.eachChild = function eachChild(fn) {
+ fn(this.needle);
+ fn(this.haystack);
+ };
+ In.prototype.outputDefined = function outputDefined() {
+ return true;
+ };
+ In.prototype.serialize = function serialize2() {
+ return [
+ "in",
+ this.needle.serialize(),
+ this.haystack.serialize()
+ ];
+ };
+ var IndexOf = function IndexOf2(needle, haystack, fromIndex) {
+ this.type = NumberType;
+ this.needle = needle;
+ this.haystack = haystack;
+ this.fromIndex = fromIndex;
+ };
+ IndexOf.parse = function parse2(args, context) {
+ if (args.length <= 2 || args.length >= 5) {
+ return context.error("Expected 3 or 4 arguments, but found " + (args.length - 1) + " instead.");
+ }
+ var needle = context.parse(args[1], 1, ValueType);
+ var haystack = context.parse(args[2], 2, ValueType);
+ if (!needle || !haystack) {
+ return null;
+ }
+ if (!isValidType(needle.type, [
+ BooleanType,
+ StringType,
+ NumberType,
+ NullType,
+ ValueType
+ ])) {
+ return context.error("Expected first argument to be of type boolean, string, number or null, but found " + toString(needle.type) + " instead");
+ }
+ if (args.length === 4) {
+ var fromIndex = context.parse(args[3], 3, NumberType);
+ if (!fromIndex) {
+ return null;
+ }
+ return new IndexOf(needle, haystack, fromIndex);
+ } else {
+ return new IndexOf(needle, haystack);
+ }
+ };
+ IndexOf.prototype.evaluate = function evaluate(ctx) {
+ var needle = this.needle.evaluate(ctx);
+ var haystack = this.haystack.evaluate(ctx);
+ if (!isValidNativeType(needle, [
+ "boolean",
+ "string",
+ "number",
+ "null"
+ ])) {
+ throw new RuntimeError("Expected first argument to be of type boolean, string, number or null, but found " + toString(typeOf(needle)) + " instead.");
+ }
+ if (!isValidNativeType(haystack, [
+ "string",
+ "array"
+ ])) {
+ throw new RuntimeError("Expected second argument to be of type array or string, but found " + toString(typeOf(haystack)) + " instead.");
+ }
+ if (this.fromIndex) {
+ var fromIndex = this.fromIndex.evaluate(ctx);
+ return haystack.indexOf(needle, fromIndex);
+ }
+ return haystack.indexOf(needle);
+ };
+ IndexOf.prototype.eachChild = function eachChild(fn) {
+ fn(this.needle);
+ fn(this.haystack);
+ if (this.fromIndex) {
+ fn(this.fromIndex);
+ }
+ };
+ IndexOf.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ IndexOf.prototype.serialize = function serialize2() {
+ if (this.fromIndex != null && this.fromIndex !== void 0) {
+ var fromIndex = this.fromIndex.serialize();
+ return [
+ "index-of",
+ this.needle.serialize(),
+ this.haystack.serialize(),
+ fromIndex
+ ];
+ }
+ return [
+ "index-of",
+ this.needle.serialize(),
+ this.haystack.serialize()
+ ];
+ };
+ var Match = function Match2(inputType, outputType, input, cases, outputs, otherwise) {
+ this.inputType = inputType;
+ this.type = outputType;
+ this.input = input;
+ this.cases = cases;
+ this.outputs = outputs;
+ this.otherwise = otherwise;
+ };
+ Match.parse = function parse2(args, context) {
+ if (args.length < 5) {
+ return context.error("Expected at least 4 arguments, but found only " + (args.length - 1) + ".");
+ }
+ if (args.length % 2 !== 1) {
+ return context.error("Expected an even number of arguments.");
+ }
+ var inputType;
+ var outputType;
+ if (context.expectedType && context.expectedType.kind !== "value") {
+ outputType = context.expectedType;
+ }
+ var cases = {};
+ var outputs = [];
+ for (var i = 2; i < args.length - 1; i += 2) {
+ var labels = args[i];
+ var value = args[i + 1];
+ if (!Array.isArray(labels)) {
+ labels = [labels];
+ }
+ var labelContext = context.concat(i);
+ if (labels.length === 0) {
+ return labelContext.error("Expected at least one branch label.");
+ }
+ for (var i$1 = 0, list = labels; i$1 < list.length; i$1 += 1) {
+ var label = list[i$1];
+ if (typeof label !== "number" && typeof label !== "string") {
+ return labelContext.error("Branch labels must be numbers or strings.");
+ } else if (typeof label === "number" && Math.abs(label) > Number.MAX_SAFE_INTEGER) {
+ return labelContext.error("Branch labels must be integers no larger than " + Number.MAX_SAFE_INTEGER + ".");
+ } else if (typeof label === "number" && Math.floor(label) !== label) {
+ return labelContext.error("Numeric branch labels must be integer values.");
+ } else if (!inputType) {
+ inputType = typeOf(label);
+ } else if (labelContext.checkSubtype(inputType, typeOf(label))) {
+ return null;
+ }
+ if (typeof cases[String(label)] !== "undefined") {
+ return labelContext.error("Branch labels must be unique.");
+ }
+ cases[String(label)] = outputs.length;
+ }
+ var result = context.parse(value, i, outputType);
+ if (!result) {
+ return null;
+ }
+ outputType = outputType || result.type;
+ outputs.push(result);
+ }
+ var input = context.parse(args[1], 1, ValueType);
+ if (!input) {
+ return null;
+ }
+ var otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);
+ if (!otherwise) {
+ return null;
+ }
+ if (input.type.kind !== "value" && context.concat(1).checkSubtype(inputType, input.type)) {
+ return null;
+ }
+ return new Match(inputType, outputType, input, cases, outputs, otherwise);
+ };
+ Match.prototype.evaluate = function evaluate(ctx) {
+ var input = this.input.evaluate(ctx);
+ var output = typeOf(input) === this.inputType && this.outputs[this.cases[input]] || this.otherwise;
+ return output.evaluate(ctx);
+ };
+ Match.prototype.eachChild = function eachChild(fn) {
+ fn(this.input);
+ this.outputs.forEach(fn);
+ fn(this.otherwise);
+ };
+ Match.prototype.outputDefined = function outputDefined() {
+ return this.outputs.every(function(out) {
+ return out.outputDefined();
+ }) && this.otherwise.outputDefined();
+ };
+ Match.prototype.serialize = function serialize2() {
+ var this$1 = this;
+ var serialized = [
+ "match",
+ this.input.serialize()
+ ];
+ var sortedLabels = Object.keys(this.cases).sort();
+ var groupedByOutput = [];
+ var outputLookup = {};
+ for (var i = 0, list = sortedLabels; i < list.length; i += 1) {
+ var label = list[i];
+ var outputIndex = outputLookup[this.cases[label]];
+ if (outputIndex === void 0) {
+ outputLookup[this.cases[label]] = groupedByOutput.length;
+ groupedByOutput.push([
+ this.cases[label],
+ [label]
+ ]);
+ } else {
+ groupedByOutput[outputIndex][1].push(label);
+ }
+ }
+ var coerceLabel = function(label2) {
+ return this$1.inputType.kind === "number" ? Number(label2) : label2;
+ };
+ for (var i$1 = 0, list$1 = groupedByOutput; i$1 < list$1.length; i$1 += 1) {
+ var ref = list$1[i$1];
+ var outputIndex = ref[0];
+ var labels = ref[1];
+ if (labels.length === 1) {
+ serialized.push(coerceLabel(labels[0]));
+ } else {
+ serialized.push(labels.map(coerceLabel));
+ }
+ serialized.push(this.outputs[outputIndex$1].serialize());
+ }
+ serialized.push(this.otherwise.serialize());
+ return serialized;
+ };
+ var Case = function Case2(type, branches, otherwise) {
+ this.type = type;
+ this.branches = branches;
+ this.otherwise = otherwise;
+ };
+ Case.parse = function parse2(args, context) {
+ if (args.length < 4) {
+ return context.error("Expected at least 3 arguments, but found only " + (args.length - 1) + ".");
+ }
+ if (args.length % 2 !== 0) {
+ return context.error("Expected an odd number of arguments.");
+ }
+ var outputType;
+ if (context.expectedType && context.expectedType.kind !== "value") {
+ outputType = context.expectedType;
+ }
+ var branches = [];
+ for (var i = 1; i < args.length - 1; i += 2) {
+ var test = context.parse(args[i], i, BooleanType);
+ if (!test) {
+ return null;
+ }
+ var result = context.parse(args[i + 1], i + 1, outputType);
+ if (!result) {
+ return null;
+ }
+ branches.push([
+ test,
+ result
+ ]);
+ outputType = outputType || result.type;
+ }
+ var otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);
+ if (!otherwise) {
+ return null;
+ }
+ return new Case(outputType, branches, otherwise);
+ };
+ Case.prototype.evaluate = function evaluate(ctx) {
+ for (var i = 0, list = this.branches; i < list.length; i += 1) {
+ var ref = list[i];
+ var test = ref[0];
+ var expression2 = ref[1];
+ if (test.evaluate(ctx)) {
+ return expression2.evaluate(ctx);
+ }
+ }
+ return this.otherwise.evaluate(ctx);
+ };
+ Case.prototype.eachChild = function eachChild(fn) {
+ for (var i = 0, list = this.branches; i < list.length; i += 1) {
+ var ref = list[i];
+ var test = ref[0];
+ var expression2 = ref[1];
+ fn(test);
+ fn(expression2);
+ }
+ fn(this.otherwise);
+ };
+ Case.prototype.outputDefined = function outputDefined() {
+ return this.branches.every(function(ref) {
+ var _ = ref[0];
+ var out = ref[1];
+ return out.outputDefined();
+ }) && this.otherwise.outputDefined();
+ };
+ Case.prototype.serialize = function serialize2() {
+ var serialized = ["case"];
+ this.eachChild(function(child) {
+ serialized.push(child.serialize());
+ });
+ return serialized;
+ };
+ var Slice = function Slice2(type, input, beginIndex, endIndex) {
+ this.type = type;
+ this.input = input;
+ this.beginIndex = beginIndex;
+ this.endIndex = endIndex;
+ };
+ Slice.parse = function parse2(args, context) {
+ if (args.length <= 2 || args.length >= 5) {
+ return context.error("Expected 3 or 4 arguments, but found " + (args.length - 1) + " instead.");
+ }
+ var input = context.parse(args[1], 1, ValueType);
+ var beginIndex = context.parse(args[2], 2, NumberType);
+ if (!input || !beginIndex) {
+ return null;
+ }
+ if (!isValidType(input.type, [
+ array(ValueType),
+ StringType,
+ ValueType
+ ])) {
+ return context.error("Expected first argument to be of type array or string, but found " + toString(input.type) + " instead");
+ }
+ if (args.length === 4) {
+ var endIndex = context.parse(args[3], 3, NumberType);
+ if (!endIndex) {
+ return null;
+ }
+ return new Slice(input.type, input, beginIndex, endIndex);
+ } else {
+ return new Slice(input.type, input, beginIndex);
+ }
+ };
+ Slice.prototype.evaluate = function evaluate(ctx) {
+ var input = this.input.evaluate(ctx);
+ var beginIndex = this.beginIndex.evaluate(ctx);
+ if (!isValidNativeType(input, [
+ "string",
+ "array"
+ ])) {
+ throw new RuntimeError("Expected first argument to be of type array or string, but found " + toString(typeOf(input)) + " instead.");
+ }
+ if (this.endIndex) {
+ var endIndex = this.endIndex.evaluate(ctx);
+ return input.slice(beginIndex, endIndex);
+ }
+ return input.slice(beginIndex);
+ };
+ Slice.prototype.eachChild = function eachChild(fn) {
+ fn(this.input);
+ fn(this.beginIndex);
+ if (this.endIndex) {
+ fn(this.endIndex);
+ }
+ };
+ Slice.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ Slice.prototype.serialize = function serialize2() {
+ if (this.endIndex != null && this.endIndex !== void 0) {
+ var endIndex = this.endIndex.serialize();
+ return [
+ "slice",
+ this.input.serialize(),
+ this.beginIndex.serialize(),
+ endIndex
+ ];
+ }
+ return [
+ "slice",
+ this.input.serialize(),
+ this.beginIndex.serialize()
+ ];
+ };
+ function isComparableType(op, type) {
+ if (op === "==" || op === "!=") {
+ return type.kind === "boolean" || type.kind === "string" || type.kind === "number" || type.kind === "null" || type.kind === "value";
+ } else {
+ return type.kind === "string" || type.kind === "number" || type.kind === "value";
+ }
+ }
+ function eq(ctx, a, b) {
+ return a === b;
+ }
+ function neq(ctx, a, b) {
+ return a !== b;
+ }
+ function lt(ctx, a, b) {
+ return a < b;
+ }
+ function gt(ctx, a, b) {
+ return a > b;
+ }
+ function lteq(ctx, a, b) {
+ return a <= b;
+ }
+ function gteq(ctx, a, b) {
+ return a >= b;
+ }
+ function eqCollate(ctx, a, b, c) {
+ return c.compare(a, b) === 0;
+ }
+ function neqCollate(ctx, a, b, c) {
+ return !eqCollate(ctx, a, b, c);
+ }
+ function ltCollate(ctx, a, b, c) {
+ return c.compare(a, b) < 0;
+ }
+ function gtCollate(ctx, a, b, c) {
+ return c.compare(a, b) > 0;
+ }
+ function lteqCollate(ctx, a, b, c) {
+ return c.compare(a, b) <= 0;
+ }
+ function gteqCollate(ctx, a, b, c) {
+ return c.compare(a, b) >= 0;
+ }
+ function makeComparison(op, compareBasic, compareWithCollator) {
+ var isOrderComparison = op !== "==" && op !== "!=";
+ return function() {
+ function Comparison(lhs, rhs, collator) {
+ this.type = BooleanType;
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.collator = collator;
+ this.hasUntypedArgument = lhs.type.kind === "value" || rhs.type.kind === "value";
+ }
+ Comparison.parse = function parse2(args, context) {
+ if (args.length !== 3 && args.length !== 4) {
+ return context.error("Expected two or three arguments.");
+ }
+ var op2 = args[0];
+ var lhs = context.parse(args[1], 1, ValueType);
+ if (!lhs) {
+ return null;
+ }
+ if (!isComparableType(op2, lhs.type)) {
+ return context.concat(1).error('"' + op2 + `" comparisons are not supported for type '` + toString(lhs.type) + "'.");
+ }
+ var rhs = context.parse(args[2], 2, ValueType);
+ if (!rhs) {
+ return null;
+ }
+ if (!isComparableType(op2, rhs.type)) {
+ return context.concat(2).error('"' + op2 + `" comparisons are not supported for type '` + toString(rhs.type) + "'.");
+ }
+ if (lhs.type.kind !== rhs.type.kind && lhs.type.kind !== "value" && rhs.type.kind !== "value") {
+ return context.error("Cannot compare types '" + toString(lhs.type) + "' and '" + toString(rhs.type) + "'.");
+ }
+ if (isOrderComparison) {
+ if (lhs.type.kind === "value" && rhs.type.kind !== "value") {
+ lhs = new Assertion(rhs.type, [lhs]);
+ } else if (lhs.type.kind !== "value" && rhs.type.kind === "value") {
+ rhs = new Assertion(lhs.type, [rhs]);
+ }
+ }
+ var collator = null;
+ if (args.length === 4) {
+ if (lhs.type.kind !== "string" && rhs.type.kind !== "string" && lhs.type.kind !== "value" && rhs.type.kind !== "value") {
+ return context.error("Cannot use collator to compare non-string types.");
+ }
+ collator = context.parse(args[3], 3, CollatorType);
+ if (!collator) {
+ return null;
+ }
+ }
+ return new Comparison(lhs, rhs, collator);
+ };
+ Comparison.prototype.evaluate = function evaluate(ctx) {
+ var lhs = this.lhs.evaluate(ctx);
+ var rhs = this.rhs.evaluate(ctx);
+ if (isOrderComparison && this.hasUntypedArgument) {
+ var lt2 = typeOf(lhs);
+ var rt = typeOf(rhs);
+ if (lt2.kind !== rt.kind || !(lt2.kind === "string" || lt2.kind === "number")) {
+ throw new RuntimeError('Expected arguments for "' + op + '" to be (string, string) or (number, number), but found (' + lt2.kind + ", " + rt.kind + ") instead.");
+ }
+ }
+ if (this.collator && !isOrderComparison && this.hasUntypedArgument) {
+ var lt$1 = typeOf(lhs);
+ var rt$1 = typeOf(rhs);
+ if (lt$1.kind !== "string" || rt$1.kind !== "string") {
+ return compareBasic(ctx, lhs, rhs);
+ }
+ }
+ return this.collator ? compareWithCollator(ctx, lhs, rhs, this.collator.evaluate(ctx)) : compareBasic(ctx, lhs, rhs);
+ };
+ Comparison.prototype.eachChild = function eachChild(fn) {
+ fn(this.lhs);
+ fn(this.rhs);
+ if (this.collator) {
+ fn(this.collator);
+ }
+ };
+ Comparison.prototype.outputDefined = function outputDefined() {
+ return true;
+ };
+ Comparison.prototype.serialize = function serialize2() {
+ var serialized = [op];
+ this.eachChild(function(child) {
+ serialized.push(child.serialize());
+ });
+ return serialized;
+ };
+ return Comparison;
+ }();
+ }
+ var Equals = makeComparison("==", eq, eqCollate);
+ var NotEquals = makeComparison("!=", neq, neqCollate);
+ var LessThan = makeComparison("<", lt, ltCollate);
+ var GreaterThan = makeComparison(">", gt, gtCollate);
+ var LessThanOrEqual = makeComparison("<=", lteq, lteqCollate);
+ var GreaterThanOrEqual = makeComparison(">=", gteq, gteqCollate);
+ var NumberFormat = function NumberFormat2(number2, locale, currency, minFractionDigits, maxFractionDigits) {
+ this.type = StringType;
+ this.number = number2;
+ this.locale = locale;
+ this.currency = currency;
+ this.minFractionDigits = minFractionDigits;
+ this.maxFractionDigits = maxFractionDigits;
+ };
+ NumberFormat.parse = function parse2(args, context) {
+ if (args.length !== 3) {
+ return context.error("Expected two arguments.");
+ }
+ var number2 = context.parse(args[1], 1, NumberType);
+ if (!number2) {
+ return null;
+ }
+ var options = args[2];
+ if (typeof options !== "object" || Array.isArray(options)) {
+ return context.error("NumberFormat options argument must be an object.");
+ }
+ var locale = null;
+ if (options["locale"]) {
+ locale = context.parse(options["locale"], 1, StringType);
+ if (!locale) {
+ return null;
+ }
+ }
+ var currency = null;
+ if (options["currency"]) {
+ currency = context.parse(options["currency"], 1, StringType);
+ if (!currency) {
+ return null;
+ }
+ }
+ var minFractionDigits = null;
+ if (options["min-fraction-digits"]) {
+ minFractionDigits = context.parse(options["min-fraction-digits"], 1, NumberType);
+ if (!minFractionDigits) {
+ return null;
+ }
+ }
+ var maxFractionDigits = null;
+ if (options["max-fraction-digits"]) {
+ maxFractionDigits = context.parse(options["max-fraction-digits"], 1, NumberType);
+ if (!maxFractionDigits) {
+ return null;
+ }
+ }
+ return new NumberFormat(number2, locale, currency, minFractionDigits, maxFractionDigits);
+ };
+ NumberFormat.prototype.evaluate = function evaluate(ctx) {
+ return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], {
+ style: this.currency ? "currency" : "decimal",
+ currency: this.currency ? this.currency.evaluate(ctx) : void 0,
+ minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : void 0,
+ maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : void 0
+ }).format(this.number.evaluate(ctx));
+ };
+ NumberFormat.prototype.eachChild = function eachChild(fn) {
+ fn(this.number);
+ if (this.locale) {
+ fn(this.locale);
+ }
+ if (this.currency) {
+ fn(this.currency);
+ }
+ if (this.minFractionDigits) {
+ fn(this.minFractionDigits);
+ }
+ if (this.maxFractionDigits) {
+ fn(this.maxFractionDigits);
+ }
+ };
+ NumberFormat.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ NumberFormat.prototype.serialize = function serialize2() {
+ var options = {};
+ if (this.locale) {
+ options["locale"] = this.locale.serialize();
+ }
+ if (this.currency) {
+ options["currency"] = this.currency.serialize();
+ }
+ if (this.minFractionDigits) {
+ options["min-fraction-digits"] = this.minFractionDigits.serialize();
+ }
+ if (this.maxFractionDigits) {
+ options["max-fraction-digits"] = this.maxFractionDigits.serialize();
+ }
+ return [
+ "number-format",
+ this.number.serialize(),
+ options
+ ];
+ };
+ var Length = function Length2(input) {
+ this.type = NumberType;
+ this.input = input;
+ };
+ Length.parse = function parse2(args, context) {
+ if (args.length !== 2) {
+ return context.error("Expected 1 argument, but found " + (args.length - 1) + " instead.");
+ }
+ var input = context.parse(args[1], 1);
+ if (!input) {
+ return null;
+ }
+ if (input.type.kind !== "array" && input.type.kind !== "string" && input.type.kind !== "value") {
+ return context.error("Expected argument of type string or array, but found " + toString(input.type) + " instead.");
+ }
+ return new Length(input);
+ };
+ Length.prototype.evaluate = function evaluate(ctx) {
+ var input = this.input.evaluate(ctx);
+ if (typeof input === "string") {
+ return input.length;
+ } else if (Array.isArray(input)) {
+ return input.length;
+ } else {
+ throw new RuntimeError("Expected value to be of type string or array, but found " + toString(typeOf(input)) + " instead.");
+ }
+ };
+ Length.prototype.eachChild = function eachChild(fn) {
+ fn(this.input);
+ };
+ Length.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ Length.prototype.serialize = function serialize2() {
+ var serialized = ["length"];
+ this.eachChild(function(child) {
+ serialized.push(child.serialize());
+ });
+ return serialized;
+ };
+ var expressions = {
+ "==": Equals,
+ "!=": NotEquals,
+ ">": GreaterThan,
+ "<": LessThan,
+ ">=": GreaterThanOrEqual,
+ "<=": LessThanOrEqual,
+ "array": Assertion,
+ "at": At,
+ "boolean": Assertion,
+ "case": Case,
+ "coalesce": Coalesce,
+ "collator": CollatorExpression,
+ "format": FormatExpression,
+ "image": ImageExpression,
+ "in": In,
+ "index-of": IndexOf,
+ "interpolate": Interpolate,
+ "interpolate-hcl": Interpolate,
+ "interpolate-lab": Interpolate,
+ "length": Length,
+ "let": Let,
+ "literal": Literal,
+ "match": Match,
+ "number": Assertion,
+ "number-format": NumberFormat,
+ "object": Assertion,
+ "slice": Slice,
+ "step": Step,
+ "string": Assertion,
+ "to-boolean": Coercion,
+ "to-color": Coercion,
+ "to-number": Coercion,
+ "to-string": Coercion,
+ "var": Var,
+ "within": Within
+ };
+ function rgba3(ctx, ref) {
+ var r = ref[0];
+ var g = ref[1];
+ var b = ref[2];
+ var a = ref[3];
+ r = r.evaluate(ctx);
+ g = g.evaluate(ctx);
+ b = b.evaluate(ctx);
+ var alpha = a ? a.evaluate(ctx) : 1;
+ var error2 = validateRGBA(r, g, b, alpha);
+ if (error2) {
+ throw new RuntimeError(error2);
+ }
+ return new Color2(r / 255 * alpha, g / 255 * alpha, b / 255 * alpha, alpha);
+ }
+ function has(key, obj) {
+ return key in obj;
+ }
+ function get(key, obj) {
+ var v = obj[key];
+ return typeof v === "undefined" ? null : v;
+ }
+ function binarySearch(v, a, i, j) {
+ while (i <= j) {
+ var m = i + j >> 1;
+ if (a[m] === v) {
+ return true;
+ }
+ if (a[m] > v) {
+ j = m - 1;
+ } else {
+ i = m + 1;
+ }
+ }
+ return false;
+ }
+ function varargs(type) {
+ return { type };
+ }
+ CompoundExpression.register(expressions, {
+ "error": [
+ ErrorType,
+ [StringType],
+ function(ctx, ref) {
+ var v = ref[0];
+ throw new RuntimeError(v.evaluate(ctx));
+ }
+ ],
+ "typeof": [
+ StringType,
+ [ValueType],
+ function(ctx, ref) {
+ var v = ref[0];
+ return toString(typeOf(v.evaluate(ctx)));
+ }
+ ],
+ "to-rgba": [
+ array(NumberType, 4),
+ [ColorType],
+ function(ctx, ref) {
+ var v = ref[0];
+ return v.evaluate(ctx).toArray();
+ }
+ ],
+ "rgb": [
+ ColorType,
+ [
+ NumberType,
+ NumberType,
+ NumberType
+ ],
+ rgba3
+ ],
+ "rgba": [
+ ColorType,
+ [
+ NumberType,
+ NumberType,
+ NumberType,
+ NumberType
+ ],
+ rgba3
+ ],
+ "has": {
+ type: BooleanType,
+ overloads: [
+ [
+ [StringType],
+ function(ctx, ref) {
+ var key = ref[0];
+ return has(key.evaluate(ctx), ctx.properties());
+ }
+ ],
+ [
+ [
+ StringType,
+ ObjectType
+ ],
+ function(ctx, ref) {
+ var key = ref[0];
+ var obj = ref[1];
+ return has(key.evaluate(ctx), obj.evaluate(ctx));
+ }
+ ]
+ ]
+ },
+ "get": {
+ type: ValueType,
+ overloads: [
+ [
+ [StringType],
+ function(ctx, ref) {
+ var key = ref[0];
+ return get(key.evaluate(ctx), ctx.properties());
+ }
+ ],
+ [
+ [
+ StringType,
+ ObjectType
+ ],
+ function(ctx, ref) {
+ var key = ref[0];
+ var obj = ref[1];
+ return get(key.evaluate(ctx), obj.evaluate(ctx));
+ }
+ ]
+ ]
+ },
+ "feature-state": [
+ ValueType,
+ [StringType],
+ function(ctx, ref) {
+ var key = ref[0];
+ return get(key.evaluate(ctx), ctx.featureState || {});
+ }
+ ],
+ "properties": [
+ ObjectType,
+ [],
+ function(ctx) {
+ return ctx.properties();
+ }
+ ],
+ "geometry-type": [
+ StringType,
+ [],
+ function(ctx) {
+ return ctx.geometryType();
+ }
+ ],
+ "id": [
+ ValueType,
+ [],
+ function(ctx) {
+ return ctx.id();
+ }
+ ],
+ "zoom": [
+ NumberType,
+ [],
+ function(ctx) {
+ return ctx.globals.zoom;
+ }
+ ],
+ "heatmap-density": [
+ NumberType,
+ [],
+ function(ctx) {
+ return ctx.globals.heatmapDensity || 0;
+ }
+ ],
+ "line-progress": [
+ NumberType,
+ [],
+ function(ctx) {
+ return ctx.globals.lineProgress || 0;
+ }
+ ],
+ "accumulated": [
+ ValueType,
+ [],
+ function(ctx) {
+ return ctx.globals.accumulated === void 0 ? null : ctx.globals.accumulated;
+ }
+ ],
+ "+": [
+ NumberType,
+ varargs(NumberType),
+ function(ctx, args) {
+ var result = 0;
+ for (var i = 0, list = args; i < list.length; i += 1) {
+ var arg = list[i];
+ result += arg.evaluate(ctx);
+ }
+ return result;
+ }
+ ],
+ "*": [
+ NumberType,
+ varargs(NumberType),
+ function(ctx, args) {
+ var result = 1;
+ for (var i = 0, list = args; i < list.length; i += 1) {
+ var arg = list[i];
+ result *= arg.evaluate(ctx);
+ }
+ return result;
+ }
+ ],
+ "-": {
+ type: NumberType,
+ overloads: [
+ [
+ [
+ NumberType,
+ NumberType
+ ],
+ function(ctx, ref) {
+ var a = ref[0];
+ var b = ref[1];
+ return a.evaluate(ctx) - b.evaluate(ctx);
+ }
+ ],
+ [
+ [NumberType],
+ function(ctx, ref) {
+ var a = ref[0];
+ return -a.evaluate(ctx);
+ }
+ ]
+ ]
+ },
+ "/": [
+ NumberType,
+ [
+ NumberType,
+ NumberType
+ ],
+ function(ctx, ref) {
+ var a = ref[0];
+ var b = ref[1];
+ return a.evaluate(ctx) / b.evaluate(ctx);
+ }
+ ],
+ "%": [
+ NumberType,
+ [
+ NumberType,
+ NumberType
+ ],
+ function(ctx, ref) {
+ var a = ref[0];
+ var b = ref[1];
+ return a.evaluate(ctx) % b.evaluate(ctx);
+ }
+ ],
+ "ln2": [
+ NumberType,
+ [],
+ function() {
+ return Math.LN2;
+ }
+ ],
+ "pi": [
+ NumberType,
+ [],
+ function() {
+ return Math.PI;
+ }
+ ],
+ "e": [
+ NumberType,
+ [],
+ function() {
+ return Math.E;
+ }
+ ],
+ "^": [
+ NumberType,
+ [
+ NumberType,
+ NumberType
+ ],
+ function(ctx, ref) {
+ var b = ref[0];
+ var e = ref[1];
+ return Math.pow(b.evaluate(ctx), e.evaluate(ctx));
+ }
+ ],
+ "sqrt": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var x = ref[0];
+ return Math.sqrt(x.evaluate(ctx));
+ }
+ ],
+ "log10": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.log(n.evaluate(ctx)) / Math.LN10;
+ }
+ ],
+ "ln": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.log(n.evaluate(ctx));
+ }
+ ],
+ "log2": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.log(n.evaluate(ctx)) / Math.LN2;
+ }
+ ],
+ "sin": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.sin(n.evaluate(ctx));
+ }
+ ],
+ "cos": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.cos(n.evaluate(ctx));
+ }
+ ],
+ "tan": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.tan(n.evaluate(ctx));
+ }
+ ],
+ "asin": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.asin(n.evaluate(ctx));
+ }
+ ],
+ "acos": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.acos(n.evaluate(ctx));
+ }
+ ],
+ "atan": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.atan(n.evaluate(ctx));
+ }
+ ],
+ "min": [
+ NumberType,
+ varargs(NumberType),
+ function(ctx, args) {
+ return Math.min.apply(Math, args.map(function(arg) {
+ return arg.evaluate(ctx);
+ }));
+ }
+ ],
+ "max": [
+ NumberType,
+ varargs(NumberType),
+ function(ctx, args) {
+ return Math.max.apply(Math, args.map(function(arg) {
+ return arg.evaluate(ctx);
+ }));
+ }
+ ],
+ "abs": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.abs(n.evaluate(ctx));
+ }
+ ],
+ "round": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ var v = n.evaluate(ctx);
+ return v < 0 ? -Math.round(-v) : Math.round(v);
+ }
+ ],
+ "floor": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.floor(n.evaluate(ctx));
+ }
+ ],
+ "ceil": [
+ NumberType,
+ [NumberType],
+ function(ctx, ref) {
+ var n = ref[0];
+ return Math.ceil(n.evaluate(ctx));
+ }
+ ],
+ "filter-==": [
+ BooleanType,
+ [
+ StringType,
+ ValueType
+ ],
+ function(ctx, ref) {
+ var k = ref[0];
+ var v = ref[1];
+ return ctx.properties()[k.value] === v.value;
+ }
+ ],
+ "filter-id-==": [
+ BooleanType,
+ [ValueType],
+ function(ctx, ref) {
+ var v = ref[0];
+ return ctx.id() === v.value;
+ }
+ ],
+ "filter-type-==": [
+ BooleanType,
+ [StringType],
+ function(ctx, ref) {
+ var v = ref[0];
+ return ctx.geometryType() === v.value;
+ }
+ ],
+ "filter-<": [
+ BooleanType,
+ [
+ StringType,
+ ValueType
+ ],
+ function(ctx, ref) {
+ var k = ref[0];
+ var v = ref[1];
+ var a = ctx.properties()[k.value];
+ var b = v.value;
+ return typeof a === typeof b && a < b;
+ }
+ ],
+ "filter-id-<": [
+ BooleanType,
+ [ValueType],
+ function(ctx, ref) {
+ var v = ref[0];
+ var a = ctx.id();
+ var b = v.value;
+ return typeof a === typeof b && a < b;
+ }
+ ],
+ "filter->": [
+ BooleanType,
+ [
+ StringType,
+ ValueType
+ ],
+ function(ctx, ref) {
+ var k = ref[0];
+ var v = ref[1];
+ var a = ctx.properties()[k.value];
+ var b = v.value;
+ return typeof a === typeof b && a > b;
+ }
+ ],
+ "filter-id->": [
+ BooleanType,
+ [ValueType],
+ function(ctx, ref) {
+ var v = ref[0];
+ var a = ctx.id();
+ var b = v.value;
+ return typeof a === typeof b && a > b;
+ }
+ ],
+ "filter-<=": [
+ BooleanType,
+ [
+ StringType,
+ ValueType
+ ],
+ function(ctx, ref) {
+ var k = ref[0];
+ var v = ref[1];
+ var a = ctx.properties()[k.value];
+ var b = v.value;
+ return typeof a === typeof b && a <= b;
+ }
+ ],
+ "filter-id-<=": [
+ BooleanType,
+ [ValueType],
+ function(ctx, ref) {
+ var v = ref[0];
+ var a = ctx.id();
+ var b = v.value;
+ return typeof a === typeof b && a <= b;
+ }
+ ],
+ "filter->=": [
+ BooleanType,
+ [
+ StringType,
+ ValueType
+ ],
+ function(ctx, ref) {
+ var k = ref[0];
+ var v = ref[1];
+ var a = ctx.properties()[k.value];
+ var b = v.value;
+ return typeof a === typeof b && a >= b;
+ }
+ ],
+ "filter-id->=": [
+ BooleanType,
+ [ValueType],
+ function(ctx, ref) {
+ var v = ref[0];
+ var a = ctx.id();
+ var b = v.value;
+ return typeof a === typeof b && a >= b;
+ }
+ ],
+ "filter-has": [
+ BooleanType,
+ [ValueType],
+ function(ctx, ref) {
+ var k = ref[0];
+ return k.value in ctx.properties();
+ }
+ ],
+ "filter-has-id": [
+ BooleanType,
+ [],
+ function(ctx) {
+ return ctx.id() !== null && ctx.id() !== void 0;
+ }
+ ],
+ "filter-type-in": [
+ BooleanType,
+ [array(StringType)],
+ function(ctx, ref) {
+ var v = ref[0];
+ return v.value.indexOf(ctx.geometryType()) >= 0;
+ }
+ ],
+ "filter-id-in": [
+ BooleanType,
+ [array(ValueType)],
+ function(ctx, ref) {
+ var v = ref[0];
+ return v.value.indexOf(ctx.id()) >= 0;
+ }
+ ],
+ "filter-in-small": [
+ BooleanType,
+ [
+ StringType,
+ array(ValueType)
+ ],
+ function(ctx, ref) {
+ var k = ref[0];
+ var v = ref[1];
+ return v.value.indexOf(ctx.properties()[k.value]) >= 0;
+ }
+ ],
+ "filter-in-large": [
+ BooleanType,
+ [
+ StringType,
+ array(ValueType)
+ ],
+ function(ctx, ref) {
+ var k = ref[0];
+ var v = ref[1];
+ return binarySearch(ctx.properties()[k.value], v.value, 0, v.value.length - 1);
+ }
+ ],
+ "all": {
+ type: BooleanType,
+ overloads: [
+ [
+ [
+ BooleanType,
+ BooleanType
+ ],
+ function(ctx, ref) {
+ var a = ref[0];
+ var b = ref[1];
+ return a.evaluate(ctx) && b.evaluate(ctx);
+ }
+ ],
+ [
+ varargs(BooleanType),
+ function(ctx, args) {
+ for (var i = 0, list = args; i < list.length; i += 1) {
+ var arg = list[i];
+ if (!arg.evaluate(ctx)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ ]
+ ]
+ },
+ "any": {
+ type: BooleanType,
+ overloads: [
+ [
+ [
+ BooleanType,
+ BooleanType
+ ],
+ function(ctx, ref) {
+ var a = ref[0];
+ var b = ref[1];
+ return a.evaluate(ctx) || b.evaluate(ctx);
+ }
+ ],
+ [
+ varargs(BooleanType),
+ function(ctx, args) {
+ for (var i = 0, list = args; i < list.length; i += 1) {
+ var arg = list[i];
+ if (arg.evaluate(ctx)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ ]
+ ]
+ },
+ "!": [
+ BooleanType,
+ [BooleanType],
+ function(ctx, ref) {
+ var b = ref[0];
+ return !b.evaluate(ctx);
+ }
+ ],
+ "is-supported-script": [
+ BooleanType,
+ [StringType],
+ function(ctx, ref) {
+ var s = ref[0];
+ var isSupportedScript = ctx.globals && ctx.globals.isSupportedScript;
+ if (isSupportedScript) {
+ return isSupportedScript(s.evaluate(ctx));
+ }
+ return true;
+ }
+ ],
+ "upcase": [
+ StringType,
+ [StringType],
+ function(ctx, ref) {
+ var s = ref[0];
+ return s.evaluate(ctx).toUpperCase();
+ }
+ ],
+ "downcase": [
+ StringType,
+ [StringType],
+ function(ctx, ref) {
+ var s = ref[0];
+ return s.evaluate(ctx).toLowerCase();
+ }
+ ],
+ "concat": [
+ StringType,
+ varargs(ValueType),
+ function(ctx, args) {
+ return args.map(function(arg) {
+ return toString$1(arg.evaluate(ctx));
+ }).join("");
+ }
+ ],
+ "resolved-locale": [
+ StringType,
+ [CollatorType],
+ function(ctx, ref) {
+ var collator = ref[0];
+ return collator.evaluate(ctx).resolvedLocale();
+ }
+ ]
+ });
+ function success(value) {
+ return {
+ result: "success",
+ value
+ };
+ }
+ function error(value) {
+ return {
+ result: "error",
+ value
+ };
+ }
+ function supportsPropertyExpression(spec2) {
+ return spec2["property-type"] === "data-driven" || spec2["property-type"] === "cross-faded-data-driven";
+ }
+ function supportsZoomExpression(spec2) {
+ return !!spec2.expression && spec2.expression.parameters.indexOf("zoom") > -1;
+ }
+ function supportsInterpolation(spec2) {
+ return !!spec2.expression && spec2.expression.interpolated;
+ }
+ function getType(val) {
+ if (val instanceof Number) {
+ return "number";
+ } else if (val instanceof String) {
+ return "string";
+ } else if (val instanceof Boolean) {
+ return "boolean";
+ } else if (Array.isArray(val)) {
+ return "array";
+ } else if (val === null) {
+ return "null";
+ } else {
+ return typeof val;
+ }
+ }
+ function isFunction(value) {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+ }
+ function identityFunction(x) {
+ return x;
+ }
+ function createFunction(parameters, propertySpec) {
+ var isColor = propertySpec.type === "color";
+ var zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === "object";
+ var featureDependent = zoomAndFeatureDependent || parameters.property !== void 0;
+ var zoomDependent = zoomAndFeatureDependent || !featureDependent;
+ var type = parameters.type || (supportsInterpolation(propertySpec) ? "exponential" : "interval");
+ if (isColor) {
+ parameters = extend$1({}, parameters);
+ if (parameters.stops) {
+ parameters.stops = parameters.stops.map(function(stop2) {
+ return [
+ stop2[0],
+ Color2.parse(stop2[1])
+ ];
+ });
+ }
+ if (parameters.default) {
+ parameters.default = Color2.parse(parameters.default);
+ } else {
+ parameters.default = Color2.parse(propertySpec.default);
+ }
+ }
+ if (parameters.colorSpace && parameters.colorSpace !== "rgb" && !colorSpaces[parameters.colorSpace]) {
+ throw new Error("Unknown color space: " + parameters.colorSpace);
+ }
+ var innerFun;
+ var hashedStops;
+ var categoricalKeyType;
+ if (type === "exponential") {
+ innerFun = evaluateExponentialFunction;
+ } else if (type === "interval") {
+ innerFun = evaluateIntervalFunction;
+ } else if (type === "categorical") {
+ innerFun = evaluateCategoricalFunction;
+ hashedStops = /* @__PURE__ */ Object.create(null);
+ for (var i = 0, list = parameters.stops; i < list.length; i += 1) {
+ var stop = list[i];
+ hashedStops[stop[0]] = stop[1];
+ }
+ categoricalKeyType = typeof parameters.stops[0][0];
+ } else if (type === "identity") {
+ innerFun = evaluateIdentityFunction;
+ } else {
+ throw new Error('Unknown function type "' + type + '"');
+ }
+ if (zoomAndFeatureDependent) {
+ var featureFunctions = {};
+ var zoomStops = [];
+ for (var s = 0; s < parameters.stops.length; s++) {
+ var stop$1 = parameters.stops[s];
+ var zoom = stop$1[0].zoom;
+ if (featureFunctions[zoom] === void 0) {
+ featureFunctions[zoom] = {
+ zoom,
+ type: parameters.type,
+ property: parameters.property,
+ default: parameters.default,
+ stops: []
+ };
+ zoomStops.push(zoom);
+ }
+ featureFunctions[zoom].stops.push([
+ stop$1[0].value,
+ stop$1[1]
+ ]);
+ }
+ var featureFunctionStops = [];
+ for (var i$1 = 0, list$1 = zoomStops; i$1 < list$1.length; i$1 += 1) {
+ var z = list$1[i$1];
+ featureFunctionStops.push([
+ featureFunctions[z].zoom,
+ createFunction(featureFunctions[z], propertySpec)
+ ]);
+ }
+ var interpolationType = { name: "linear" };
+ return {
+ kind: "composite",
+ interpolationType,
+ interpolationFactor: Interpolate.interpolationFactor.bind(void 0, interpolationType),
+ zoomStops: featureFunctionStops.map(function(s2) {
+ return s2[0];
+ }),
+ evaluate: function evaluate(ref, properties2) {
+ var zoom2 = ref.zoom;
+ return evaluateExponentialFunction({
+ stops: featureFunctionStops,
+ base: parameters.base
+ }, propertySpec, zoom2).evaluate(zoom2, properties2);
+ }
+ };
+ } else if (zoomDependent) {
+ var interpolationType$1 = type === "exponential" ? {
+ name: "exponential",
+ base: parameters.base !== void 0 ? parameters.base : 1
+ } : null;
+ return {
+ kind: "camera",
+ interpolationType: interpolationType$1,
+ interpolationFactor: Interpolate.interpolationFactor.bind(void 0, interpolationType$1),
+ zoomStops: parameters.stops.map(function(s2) {
+ return s2[0];
+ }),
+ evaluate: function(ref) {
+ var zoom2 = ref.zoom;
+ return innerFun(parameters, propertySpec, zoom2, hashedStops, categoricalKeyType);
+ }
+ };
+ } else {
+ return {
+ kind: "source",
+ evaluate: function evaluate(_, feature) {
+ var value = feature && feature.properties ? feature.properties[parameters.property] : void 0;
+ if (value === void 0) {
+ return coalesce(parameters.default, propertySpec.default);
+ }
+ return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);
+ }
+ };
+ }
+ }
+ function coalesce(a, b, c) {
+ if (a !== void 0) {
+ return a;
+ }
+ if (b !== void 0) {
+ return b;
+ }
+ if (c !== void 0) {
+ return c;
+ }
+ }
+ function evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {
+ var evaluated = typeof input === keyType ? hashedStops[input] : void 0;
+ return coalesce(evaluated, parameters.default, propertySpec.default);
+ }
+ function evaluateIntervalFunction(parameters, propertySpec, input) {
+ if (getType(input) !== "number") {
+ return coalesce(parameters.default, propertySpec.default);
+ }
+ var n = parameters.stops.length;
+ if (n === 1) {
+ return parameters.stops[0][1];
+ }
+ if (input <= parameters.stops[0][0]) {
+ return parameters.stops[0][1];
+ }
+ if (input >= parameters.stops[n - 1][0]) {
+ return parameters.stops[n - 1][1];
+ }
+ var index = findStopLessThanOrEqualTo(parameters.stops.map(function(stop) {
+ return stop[0];
+ }), input);
+ return parameters.stops[index][1];
+ }
+ function evaluateExponentialFunction(parameters, propertySpec, input) {
+ var base = parameters.base !== void 0 ? parameters.base : 1;
+ if (getType(input) !== "number") {
+ return coalesce(parameters.default, propertySpec.default);
+ }
+ var n = parameters.stops.length;
+ if (n === 1) {
+ return parameters.stops[0][1];
+ }
+ if (input <= parameters.stops[0][0]) {
+ return parameters.stops[0][1];
+ }
+ if (input >= parameters.stops[n - 1][0]) {
+ return parameters.stops[n - 1][1];
+ }
+ var index = findStopLessThanOrEqualTo(parameters.stops.map(function(stop) {
+ return stop[0];
+ }), input);
+ var t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]);
+ var outputLower = parameters.stops[index][1];
+ var outputUpper = parameters.stops[index + 1][1];
+ var interp = interpolate[propertySpec.type] || identityFunction;
+ if (parameters.colorSpace && parameters.colorSpace !== "rgb") {
+ var colorspace = colorSpaces[parameters.colorSpace];
+ interp = function(a, b) {
+ return colorspace.reverse(colorspace.interpolate(colorspace.forward(a), colorspace.forward(b), t));
+ };
+ }
+ if (typeof outputLower.evaluate === "function") {
+ return {
+ evaluate: function evaluate() {
+ var args = [], len = arguments.length;
+ while (len--)
+ args[len] = arguments[len];
+ var evaluatedLower = outputLower.evaluate.apply(void 0, args);
+ var evaluatedUpper = outputUpper.evaluate.apply(void 0, args);
+ if (evaluatedLower === void 0 || evaluatedUpper === void 0) {
+ return void 0;
+ }
+ return interp(evaluatedLower, evaluatedUpper, t);
+ }
+ };
+ }
+ return interp(outputLower, outputUpper, t);
+ }
+ function evaluateIdentityFunction(parameters, propertySpec, input) {
+ if (propertySpec.type === "color") {
+ input = Color2.parse(input);
+ } else if (propertySpec.type === "formatted") {
+ input = Formatted.fromString(input.toString());
+ } else if (propertySpec.type === "resolvedImage") {
+ input = ResolvedImage.fromString(input.toString());
+ } else if (getType(input) !== propertySpec.type && (propertySpec.type !== "enum" || !propertySpec.values[input])) {
+ input = void 0;
+ }
+ return coalesce(input, parameters.default, propertySpec.default);
+ }
+ function interpolationFactor(input, base, lowerValue, upperValue) {
+ var difference = upperValue - lowerValue;
+ var progress = input - lowerValue;
+ if (difference === 0) {
+ return 0;
+ } else if (base === 1) {
+ return progress / difference;
+ } else {
+ return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
+ }
+ }
+ var StyleExpression = function StyleExpression2(expression2, propertySpec) {
+ this.expression = expression2;
+ this._warningHistory = {};
+ this._evaluator = new EvaluationContext();
+ this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
+ this._enumValues = propertySpec && propertySpec.type === "enum" ? propertySpec.values : null;
+ };
+ StyleExpression.prototype.evaluateWithoutErrorHandling = function evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {
+ this._evaluator.globals = globals;
+ this._evaluator.feature = feature;
+ this._evaluator.featureState = featureState;
+ this._evaluator.canonical = canonical;
+ this._evaluator.availableImages = availableImages || null;
+ this._evaluator.formattedSection = formattedSection;
+ return this.expression.evaluate(this._evaluator);
+ };
+ StyleExpression.prototype.evaluate = function evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {
+ this._evaluator.globals = globals;
+ this._evaluator.feature = feature || null;
+ this._evaluator.featureState = featureState || null;
+ this._evaluator.canonical = canonical;
+ this._evaluator.availableImages = availableImages || null;
+ this._evaluator.formattedSection = formattedSection || null;
+ try {
+ var val = this.expression.evaluate(this._evaluator);
+ if (val === null || val === void 0 || typeof val === "number" && val !== val) {
+ return this._defaultValue;
+ }
+ if (this._enumValues && !(val in this._enumValues)) {
+ throw new RuntimeError("Expected value to be one of " + Object.keys(this._enumValues).map(function(v) {
+ return JSON.stringify(v);
+ }).join(", ") + ", but found " + JSON.stringify(val) + " instead.");
+ }
+ return val;
+ } catch (e) {
+ if (!this._warningHistory[e.message]) {
+ this._warningHistory[e.message] = true;
+ if (typeof console !== "undefined") {
+ console.warn(e.message);
+ }
+ }
+ return this._defaultValue;
+ }
+ };
+ function isExpression(expression2) {
+ return Array.isArray(expression2) && expression2.length > 0 && typeof expression2[0] === "string" && expression2[0] in expressions;
+ }
+ function createExpression(expression2, propertySpec) {
+ var parser = new ParsingContext(expressions, [], propertySpec ? getExpectedType(propertySpec) : void 0);
+ var parsed = parser.parse(expression2, void 0, void 0, void 0, propertySpec && propertySpec.type === "string" ? { typeAnnotation: "coerce" } : void 0);
+ if (!parsed) {
+ return error(parser.errors);
+ }
+ return success(new StyleExpression(parsed, propertySpec));
+ }
+ var ZoomConstantExpression = function ZoomConstantExpression2(kind, expression2) {
+ this.kind = kind;
+ this._styleExpression = expression2;
+ this.isStateDependent = kind !== "constant" && !isStateConstant(expression2.expression);
+ };
+ ZoomConstantExpression.prototype.evaluateWithoutErrorHandling = function evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {
+ return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
+ };
+ ZoomConstantExpression.prototype.evaluate = function evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {
+ return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
+ };
+ var ZoomDependentExpression = function ZoomDependentExpression2(kind, expression2, zoomStops, interpolationType) {
+ this.kind = kind;
+ this.zoomStops = zoomStops;
+ this._styleExpression = expression2;
+ this.isStateDependent = kind !== "camera" && !isStateConstant(expression2.expression);
+ this.interpolationType = interpolationType;
+ };
+ ZoomDependentExpression.prototype.evaluateWithoutErrorHandling = function evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {
+ return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
+ };
+ ZoomDependentExpression.prototype.evaluate = function evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {
+ return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
+ };
+ ZoomDependentExpression.prototype.interpolationFactor = function interpolationFactor2(input, lower, upper) {
+ if (this.interpolationType) {
+ return Interpolate.interpolationFactor(this.interpolationType, input, lower, upper);
+ } else {
+ return 0;
+ }
+ };
+ function createPropertyExpression(expression2, propertySpec) {
+ expression2 = createExpression(expression2, propertySpec);
+ if (expression2.result === "error") {
+ return expression2;
+ }
+ var parsed = expression2.value.expression;
+ var isFeatureConstant$1 = isFeatureConstant(parsed);
+ if (!isFeatureConstant$1 && !supportsPropertyExpression(propertySpec)) {
+ return error([new ParsingError("", "data expressions not supported")]);
+ }
+ var isZoomConstant = isGlobalPropertyConstant(parsed, ["zoom"]);
+ if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {
+ return error([new ParsingError("", "zoom expressions not supported")]);
+ }
+ var zoomCurve = findZoomCurve(parsed);
+ if (!zoomCurve && !isZoomConstant) {
+ return error([new ParsingError("", '"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);
+ } else if (zoomCurve instanceof ParsingError) {
+ return error([zoomCurve]);
+ } else if (zoomCurve instanceof Interpolate && !supportsInterpolation(propertySpec)) {
+ return error([new ParsingError("", '"interpolate" expressions cannot be used with this property')]);
+ }
+ if (!zoomCurve) {
+ return success(isFeatureConstant$1 ? new ZoomConstantExpression("constant", expression2.value) : new ZoomConstantExpression("source", expression2.value));
+ }
+ var interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : void 0;
+ return success(isFeatureConstant$1 ? new ZoomDependentExpression("camera", expression2.value, zoomCurve.labels, interpolationType) : new ZoomDependentExpression("composite", expression2.value, zoomCurve.labels, interpolationType));
+ }
+ var StylePropertyFunction = function StylePropertyFunction2(parameters, specification) {
+ this._parameters = parameters;
+ this._specification = specification;
+ extend$1(this, createFunction(this._parameters, this._specification));
+ };
+ StylePropertyFunction.deserialize = function deserialize2(serialized) {
+ return new StylePropertyFunction(serialized._parameters, serialized._specification);
+ };
+ StylePropertyFunction.serialize = function serialize2(input) {
+ return {
+ _parameters: input._parameters,
+ _specification: input._specification
+ };
+ };
+ function normalizePropertyExpression(value, specification) {
+ if (isFunction(value)) {
+ return new StylePropertyFunction(value, specification);
+ } else if (isExpression(value)) {
+ var expression2 = createPropertyExpression(value, specification);
+ if (expression2.result === "error") {
+ throw new Error(expression2.value.map(function(err) {
+ return err.key + ": " + err.message;
+ }).join(", "));
+ }
+ return expression2.value;
+ } else {
+ var constant = value;
+ if (typeof value === "string" && specification.type === "color") {
+ constant = Color2.parse(value);
+ }
+ return {
+ kind: "constant",
+ evaluate: function() {
+ return constant;
+ }
+ };
+ }
+ }
+ function findZoomCurve(expression2) {
+ var result = null;
+ if (expression2 instanceof Let) {
+ result = findZoomCurve(expression2.result);
+ } else if (expression2 instanceof Coalesce) {
+ for (var i = 0, list = expression2.args; i < list.length; i += 1) {
+ var arg = list[i];
+ result = findZoomCurve(arg);
+ if (result) {
+ break;
+ }
+ }
+ } else if ((expression2 instanceof Step || expression2 instanceof Interpolate) && expression2.input instanceof CompoundExpression && expression2.input.name === "zoom") {
+ result = expression2;
+ }
+ if (result instanceof ParsingError) {
+ return result;
+ }
+ expression2.eachChild(function(child) {
+ var childResult = findZoomCurve(child);
+ if (childResult instanceof ParsingError) {
+ result = childResult;
+ } else if (!result && childResult) {
+ result = new ParsingError("", '"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.');
+ } else if (result && childResult && result !== childResult) {
+ result = new ParsingError("", 'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.');
+ }
+ });
+ return result;
+ }
+ function getExpectedType(spec2) {
+ var types2 = {
+ color: ColorType,
+ string: StringType,
+ number: NumberType,
+ enum: StringType,
+ boolean: BooleanType,
+ formatted: FormattedType,
+ resolvedImage: ResolvedImageType
+ };
+ if (spec2.type === "array") {
+ return array(types2[spec2.value] || ValueType, spec2.length);
+ }
+ return types2[spec2.type];
+ }
+ function getDefaultValue(spec2) {
+ if (spec2.type === "color" && isFunction(spec2.default)) {
+ return new Color2(0, 0, 0, 0);
+ } else if (spec2.type === "color") {
+ return Color2.parse(spec2.default) || null;
+ } else if (spec2.default === void 0) {
+ return null;
+ } else {
+ return spec2.default;
+ }
+ }
+ function validateObject(options) {
+ var key = options.key;
+ var object = options.value;
+ var elementSpecs = options.valueSpec || {};
+ var elementValidators = options.objectElementValidators || {};
+ var style = options.style;
+ var styleSpec = options.styleSpec;
+ var errors = [];
+ var type = getType(object);
+ if (type !== "object") {
+ return [new ValidationError(key, object, "object expected, " + type + " found")];
+ }
+ for (var objectKey in object) {
+ var elementSpecKey = objectKey.split(".")[0];
+ var elementSpec = elementSpecs[elementSpecKey] || elementSpecs["*"];
+ var validateElement = void 0;
+ if (elementValidators[elementSpecKey]) {
+ validateElement = elementValidators[elementSpecKey];
+ } else if (elementSpecs[elementSpecKey]) {
+ validateElement = validate;
+ } else if (elementValidators["*"]) {
+ validateElement = elementValidators["*"];
+ } else if (elementSpecs["*"]) {
+ validateElement = validate;
+ } else {
+ errors.push(new ValidationError(key, object[objectKey], 'unknown property "' + objectKey + '"'));
+ continue;
+ }
+ errors = errors.concat(validateElement({
+ key: (key ? key + "." : key) + objectKey,
+ value: object[objectKey],
+ valueSpec: elementSpec,
+ style,
+ styleSpec,
+ object,
+ objectKey
+ }, object));
+ }
+ for (var elementSpecKey$1 in elementSpecs) {
+ if (elementValidators[elementSpecKey$1]) {
+ continue;
+ }
+ if (elementSpecs[elementSpecKey$1].required && elementSpecs[elementSpecKey$1]["default"] === void 0 && object[elementSpecKey$1] === void 0) {
+ errors.push(new ValidationError(key, object, 'missing required property "' + elementSpecKey$1 + '"'));
+ }
+ }
+ return errors;
+ }
+ function validateArray(options) {
+ var array2 = options.value;
+ var arraySpec = options.valueSpec;
+ var style = options.style;
+ var styleSpec = options.styleSpec;
+ var key = options.key;
+ var validateArrayElement = options.arrayElementValidator || validate;
+ if (getType(array2) !== "array") {
+ return [new ValidationError(key, array2, "array expected, " + getType(array2) + " found")];
+ }
+ if (arraySpec.length && array2.length !== arraySpec.length) {
+ return [new ValidationError(key, array2, "array length " + arraySpec.length + " expected, length " + array2.length + " found")];
+ }
+ if (arraySpec["min-length"] && array2.length < arraySpec["min-length"]) {
+ return [new ValidationError(key, array2, "array length at least " + arraySpec["min-length"] + " expected, length " + array2.length + " found")];
+ }
+ var arrayElementSpec = {
+ "type": arraySpec.value,
+ "values": arraySpec.values
+ };
+ if (styleSpec.$version < 7) {
+ arrayElementSpec.function = arraySpec.function;
+ }
+ if (getType(arraySpec.value) === "object") {
+ arrayElementSpec = arraySpec.value;
+ }
+ var errors = [];
+ for (var i = 0; i < array2.length; i++) {
+ errors = errors.concat(validateArrayElement({
+ array: array2,
+ arrayIndex: i,
+ value: array2[i],
+ valueSpec: arrayElementSpec,
+ style,
+ styleSpec,
+ key: key + "[" + i + "]"
+ }));
+ }
+ return errors;
+ }
+ function validateNumber(options) {
+ var key = options.key;
+ var value = options.value;
+ var valueSpec = options.valueSpec;
+ var type = getType(value);
+ if (type === "number" && value !== value) {
+ type = "NaN";
+ }
+ if (type !== "number") {
+ return [new ValidationError(key, value, "number expected, " + type + " found")];
+ }
+ if ("minimum" in valueSpec && value < valueSpec.minimum) {
+ return [new ValidationError(key, value, value + " is less than the minimum value " + valueSpec.minimum)];
+ }
+ if ("maximum" in valueSpec && value > valueSpec.maximum) {
+ return [new ValidationError(key, value, value + " is greater than the maximum value " + valueSpec.maximum)];
+ }
+ return [];
+ }
+ function validateFunction(options) {
+ var functionValueSpec = options.valueSpec;
+ var functionType = unbundle(options.value.type);
+ var stopKeyType;
+ var stopDomainValues = {};
+ var previousStopDomainValue;
+ var previousStopDomainZoom;
+ var isZoomFunction = functionType !== "categorical" && options.value.property === void 0;
+ var isPropertyFunction = !isZoomFunction;
+ var isZoomAndPropertyFunction = getType(options.value.stops) === "array" && getType(options.value.stops[0]) === "array" && getType(options.value.stops[0][0]) === "object";
+ var errors = validateObject({
+ key: options.key,
+ value: options.value,
+ valueSpec: options.styleSpec.function,
+ style: options.style,
+ styleSpec: options.styleSpec,
+ objectElementValidators: {
+ stops: validateFunctionStops,
+ default: validateFunctionDefault
+ }
+ });
+ if (functionType === "identity" && isZoomFunction) {
+ errors.push(new ValidationError(options.key, options.value, 'missing required property "property"'));
+ }
+ if (functionType !== "identity" && !options.value.stops) {
+ errors.push(new ValidationError(options.key, options.value, 'missing required property "stops"'));
+ }
+ if (functionType === "exponential" && options.valueSpec.expression && !supportsInterpolation(options.valueSpec)) {
+ errors.push(new ValidationError(options.key, options.value, "exponential functions not supported"));
+ }
+ if (options.styleSpec.$version >= 8) {
+ if (isPropertyFunction && !supportsPropertyExpression(options.valueSpec)) {
+ errors.push(new ValidationError(options.key, options.value, "property functions not supported"));
+ } else if (isZoomFunction && !supportsZoomExpression(options.valueSpec)) {
+ errors.push(new ValidationError(options.key, options.value, "zoom functions not supported"));
+ }
+ }
+ if ((functionType === "categorical" || isZoomAndPropertyFunction) && options.value.property === void 0) {
+ errors.push(new ValidationError(options.key, options.value, '"property" property is required'));
+ }
+ return errors;
+ function validateFunctionStops(options2) {
+ if (functionType === "identity") {
+ return [new ValidationError(options2.key, options2.value, 'identity function may not have a "stops" property')];
+ }
+ var errors2 = [];
+ var value = options2.value;
+ errors2 = errors2.concat(validateArray({
+ key: options2.key,
+ value,
+ valueSpec: options2.valueSpec,
+ style: options2.style,
+ styleSpec: options2.styleSpec,
+ arrayElementValidator: validateFunctionStop
+ }));
+ if (getType(value) === "array" && value.length === 0) {
+ errors2.push(new ValidationError(options2.key, value, "array must have at least one stop"));
+ }
+ return errors2;
+ }
+ function validateFunctionStop(options2) {
+ var errors2 = [];
+ var value = options2.value;
+ var key = options2.key;
+ if (getType(value) !== "array") {
+ return [new ValidationError(key, value, "array expected, " + getType(value) + " found")];
+ }
+ if (value.length !== 2) {
+ return [new ValidationError(key, value, "array length 2 expected, length " + value.length + " found")];
+ }
+ if (isZoomAndPropertyFunction) {
+ if (getType(value[0]) !== "object") {
+ return [new ValidationError(key, value, "object expected, " + getType(value[0]) + " found")];
+ }
+ if (value[0].zoom === void 0) {
+ return [new ValidationError(key, value, "object stop key must have zoom")];
+ }
+ if (value[0].value === void 0) {
+ return [new ValidationError(key, value, "object stop key must have value")];
+ }
+ if (previousStopDomainZoom && previousStopDomainZoom > unbundle(value[0].zoom)) {
+ return [new ValidationError(key, value[0].zoom, "stop zoom values must appear in ascending order")];
+ }
+ if (unbundle(value[0].zoom) !== previousStopDomainZoom) {
+ previousStopDomainZoom = unbundle(value[0].zoom);
+ previousStopDomainValue = void 0;
+ stopDomainValues = {};
+ }
+ errors2 = errors2.concat(validateObject({
+ key: key + "[0]",
+ value: value[0],
+ valueSpec: { zoom: {} },
+ style: options2.style,
+ styleSpec: options2.styleSpec,
+ objectElementValidators: {
+ zoom: validateNumber,
+ value: validateStopDomainValue
+ }
+ }));
+ } else {
+ errors2 = errors2.concat(validateStopDomainValue({
+ key: key + "[0]",
+ value: value[0],
+ valueSpec: {},
+ style: options2.style,
+ styleSpec: options2.styleSpec
+ }, value));
+ }
+ if (isExpression(deepUnbundle(value[1]))) {
+ return errors2.concat([new ValidationError(key + "[1]", value[1], "expressions are not allowed in function stops.")]);
+ }
+ return errors2.concat(validate({
+ key: key + "[1]",
+ value: value[1],
+ valueSpec: functionValueSpec,
+ style: options2.style,
+ styleSpec: options2.styleSpec
+ }));
+ }
+ function validateStopDomainValue(options2, stop) {
+ var type = getType(options2.value);
+ var value = unbundle(options2.value);
+ var reportValue = options2.value !== null ? options2.value : stop;
+ if (!stopKeyType) {
+ stopKeyType = type;
+ } else if (type !== stopKeyType) {
+ return [new ValidationError(options2.key, reportValue, type + " stop domain type must match previous stop domain type " + stopKeyType)];
+ }
+ if (type !== "number" && type !== "string" && type !== "boolean") {
+ return [new ValidationError(options2.key, reportValue, "stop domain value must be a number, string, or boolean")];
+ }
+ if (type !== "number" && functionType !== "categorical") {
+ var message = "number expected, " + type + " found";
+ if (supportsPropertyExpression(functionValueSpec) && functionType === void 0) {
+ message += '\nIf you intended to use a categorical function, specify `"type": "categorical"`.';
+ }
+ return [new ValidationError(options2.key, reportValue, message)];
+ }
+ if (functionType === "categorical" && type === "number" && (!isFinite(value) || Math.floor(value) !== value)) {
+ return [new ValidationError(options2.key, reportValue, "integer expected, found " + value)];
+ }
+ if (functionType !== "categorical" && type === "number" && previousStopDomainValue !== void 0 && value < previousStopDomainValue) {
+ return [new ValidationError(options2.key, reportValue, "stop domain values must appear in ascending order")];
+ } else {
+ previousStopDomainValue = value;
+ }
+ if (functionType === "categorical" && value in stopDomainValues) {
+ return [new ValidationError(options2.key, reportValue, "stop domain values must be unique")];
+ } else {
+ stopDomainValues[value] = true;
+ }
+ return [];
+ }
+ function validateFunctionDefault(options2) {
+ return validate({
+ key: options2.key,
+ value: options2.value,
+ valueSpec: functionValueSpec,
+ style: options2.style,
+ styleSpec: options2.styleSpec
+ });
+ }
+ }
+ function validateExpression(options) {
+ var expression2 = (options.expressionContext === "property" ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);
+ if (expression2.result === "error") {
+ return expression2.value.map(function(error2) {
+ return new ValidationError("" + options.key + error2.key, options.value, error2.message);
+ });
+ }
+ var expressionObj = expression2.value.expression || expression2.value._styleExpression.expression;
+ if (options.expressionContext === "property" && options.propertyKey === "text-font" && !expressionObj.outputDefined()) {
+ return [new ValidationError(options.key, options.value, 'Invalid data expression for "' + options.propertyKey + '". Output values must be contained as literals within the expression.')];
+ }
+ if (options.expressionContext === "property" && options.propertyType === "layout" && !isStateConstant(expressionObj)) {
+ return [new ValidationError(options.key, options.value, '"feature-state" data expressions are not supported with layout properties.')];
+ }
+ if (options.expressionContext === "filter" && !isStateConstant(expressionObj)) {
+ return [new ValidationError(options.key, options.value, '"feature-state" data expressions are not supported with filters.')];
+ }
+ if (options.expressionContext && options.expressionContext.indexOf("cluster") === 0) {
+ if (!isGlobalPropertyConstant(expressionObj, [
+ "zoom",
+ "feature-state"
+ ])) {
+ return [new ValidationError(options.key, options.value, '"zoom" and "feature-state" expressions are not supported with cluster properties.')];
+ }
+ if (options.expressionContext === "cluster-initial" && !isFeatureConstant(expressionObj)) {
+ return [new ValidationError(options.key, options.value, "Feature data expressions are not supported with initial expression part of cluster properties.")];
+ }
+ }
+ return [];
+ }
+ function validateBoolean(options) {
+ var value = options.value;
+ var key = options.key;
+ var type = getType(value);
+ if (type !== "boolean") {
+ return [new ValidationError(key, value, "boolean expected, " + type + " found")];
+ }
+ return [];
+ }
+ function validateColor(options) {
+ var key = options.key;
+ var value = options.value;
+ var type = getType(value);
+ if (type !== "string") {
+ return [new ValidationError(key, value, "color expected, " + type + " found")];
+ }
+ if (csscolorparser_1(value) === null) {
+ return [new ValidationError(key, value, 'color expected, "' + value + '" found')];
+ }
+ return [];
+ }
+ function validateEnum(options) {
+ var key = options.key;
+ var value = options.value;
+ var valueSpec = options.valueSpec;
+ var errors = [];
+ if (Array.isArray(valueSpec.values)) {
+ if (valueSpec.values.indexOf(unbundle(value)) === -1) {
+ errors.push(new ValidationError(key, value, "expected one of [" + valueSpec.values.join(", ") + "], " + JSON.stringify(value) + " found"));
+ }
+ } else {
+ if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {
+ errors.push(new ValidationError(key, value, "expected one of [" + Object.keys(valueSpec.values).join(", ") + "], " + JSON.stringify(value) + " found"));
+ }
+ }
+ return errors;
+ }
+ function isExpressionFilter(filter2) {
+ if (filter2 === true || filter2 === false) {
+ return true;
+ }
+ if (!Array.isArray(filter2) || filter2.length === 0) {
+ return false;
+ }
+ switch (filter2[0]) {
+ case "has":
+ return filter2.length >= 2 && filter2[1] !== "$id" && filter2[1] !== "$type";
+ case "in":
+ return filter2.length >= 3 && (typeof filter2[1] !== "string" || Array.isArray(filter2[2]));
+ case "!in":
+ case "!has":
+ case "none":
+ return false;
+ case "==":
+ case "!=":
+ case ">":
+ case ">=":
+ case "<":
+ case "<=":
+ return filter2.length !== 3 || (Array.isArray(filter2[1]) || Array.isArray(filter2[2]));
+ case "any":
+ case "all":
+ for (var i = 0, list = filter2.slice(1); i < list.length; i += 1) {
+ var f = list[i];
+ if (!isExpressionFilter(f) && typeof f !== "boolean") {
+ return false;
+ }
+ }
+ return true;
+ default:
+ return true;
+ }
+ }
+ var filterSpec = {
+ "type": "boolean",
+ "default": false,
+ "transition": false,
+ "property-type": "data-driven",
+ "expression": {
+ "interpolated": false,
+ "parameters": [
+ "zoom",
+ "feature"
+ ]
+ }
+ };
+ function createFilter(filter2) {
+ if (filter2 === null || filter2 === void 0) {
+ return {
+ filter: function() {
+ return true;
+ },
+ needGeometry: false
+ };
+ }
+ if (!isExpressionFilter(filter2)) {
+ filter2 = convertFilter(filter2);
+ }
+ var compiled = createExpression(filter2, filterSpec);
+ if (compiled.result === "error") {
+ throw new Error(compiled.value.map(function(err) {
+ return err.key + ": " + err.message;
+ }).join(", "));
+ } else {
+ var needGeometry = geometryNeeded(filter2);
+ return {
+ filter: function(globalProperties, feature, canonical) {
+ return compiled.value.evaluate(globalProperties, feature, {}, canonical);
+ },
+ needGeometry
+ };
+ }
+ }
+ function compare(a, b) {
+ return a < b ? -1 : a > b ? 1 : 0;
+ }
+ function geometryNeeded(filter2) {
+ if (!Array.isArray(filter2)) {
+ return false;
+ }
+ if (filter2[0] === "within") {
+ return true;
+ }
+ for (var index = 1; index < filter2.length; index++) {
+ if (geometryNeeded(filter2[index])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function convertFilter(filter2) {
+ if (!filter2) {
+ return true;
+ }
+ var op = filter2[0];
+ if (filter2.length <= 1) {
+ return op !== "any";
+ }
+ var converted = op === "==" ? convertComparisonOp(filter2[1], filter2[2], "==") : op === "!=" ? convertNegation(convertComparisonOp(filter2[1], filter2[2], "==")) : op === "<" || op === ">" || op === "<=" || op === ">=" ? convertComparisonOp(filter2[1], filter2[2], op) : op === "any" ? convertDisjunctionOp(filter2.slice(1)) : op === "all" ? ["all"].concat(filter2.slice(1).map(convertFilter)) : op === "none" ? ["all"].concat(filter2.slice(1).map(convertFilter).map(convertNegation)) : op === "in" ? convertInOp(filter2[1], filter2.slice(2)) : op === "!in" ? convertNegation(convertInOp(filter2[1], filter2.slice(2))) : op === "has" ? convertHasOp(filter2[1]) : op === "!has" ? convertNegation(convertHasOp(filter2[1])) : op === "within" ? filter2 : true;
+ return converted;
+ }
+ function convertComparisonOp(property, value, op) {
+ switch (property) {
+ case "$type":
+ return [
+ "filter-type-" + op,
+ value
+ ];
+ case "$id":
+ return [
+ "filter-id-" + op,
+ value
+ ];
+ default:
+ return [
+ "filter-" + op,
+ property,
+ value
+ ];
+ }
+ }
+ function convertDisjunctionOp(filters) {
+ return ["any"].concat(filters.map(convertFilter));
+ }
+ function convertInOp(property, values2) {
+ if (values2.length === 0) {
+ return false;
+ }
+ switch (property) {
+ case "$type":
+ return [
+ "filter-type-in",
+ [
+ "literal",
+ values2
+ ]
+ ];
+ case "$id":
+ return [
+ "filter-id-in",
+ [
+ "literal",
+ values2
+ ]
+ ];
+ default:
+ if (values2.length > 200 && !values2.some(function(v) {
+ return typeof v !== typeof values2[0];
+ })) {
+ return [
+ "filter-in-large",
+ property,
+ [
+ "literal",
+ values2.sort(compare)
+ ]
+ ];
+ } else {
+ return [
+ "filter-in-small",
+ property,
+ [
+ "literal",
+ values2
+ ]
+ ];
+ }
+ }
+ }
+ function convertHasOp(property) {
+ switch (property) {
+ case "$type":
+ return true;
+ case "$id":
+ return ["filter-has-id"];
+ default:
+ return [
+ "filter-has",
+ property
+ ];
+ }
+ }
+ function convertNegation(filter2) {
+ return [
+ "!",
+ filter2
+ ];
+ }
+ function validateFilter(options) {
+ if (isExpressionFilter(deepUnbundle(options.value))) {
+ return validateExpression(extend$1({}, options, {
+ expressionContext: "filter",
+ valueSpec: { value: "boolean" }
+ }));
+ } else {
+ return validateNonExpressionFilter(options);
+ }
+ }
+ function validateNonExpressionFilter(options) {
+ var value = options.value;
+ var key = options.key;
+ if (getType(value) !== "array") {
+ return [new ValidationError(key, value, "array expected, " + getType(value) + " found")];
+ }
+ var styleSpec = options.styleSpec;
+ var type;
+ var errors = [];
+ if (value.length < 1) {
+ return [new ValidationError(key, value, "filter array must have at least 1 element")];
+ }
+ errors = errors.concat(validateEnum({
+ key: key + "[0]",
+ value: value[0],
+ valueSpec: styleSpec.filter_operator,
+ style: options.style,
+ styleSpec: options.styleSpec
+ }));
+ switch (unbundle(value[0])) {
+ case "<":
+ case "<=":
+ case ">":
+ case ">=":
+ if (value.length >= 2 && unbundle(value[1]) === "$type") {
+ errors.push(new ValidationError(key, value, '"$type" cannot be use with operator "' + value[0] + '"'));
+ }
+ case "==":
+ case "!=":
+ if (value.length !== 3) {
+ errors.push(new ValidationError(key, value, 'filter array for operator "' + value[0] + '" must have 3 elements'));
+ }
+ case "in":
+ case "!in":
+ if (value.length >= 2) {
+ type = getType(value[1]);
+ if (type !== "string") {
+ errors.push(new ValidationError(key + "[1]", value[1], "string expected, " + type + " found"));
+ }
+ }
+ for (var i = 2; i < value.length; i++) {
+ type = getType(value[i]);
+ if (unbundle(value[1]) === "$type") {
+ errors = errors.concat(validateEnum({
+ key: key + "[" + i + "]",
+ value: value[i],
+ valueSpec: styleSpec.geometry_type,
+ style: options.style,
+ styleSpec: options.styleSpec
+ }));
+ } else if (type !== "string" && type !== "number" && type !== "boolean") {
+ errors.push(new ValidationError(key + "[" + i + "]", value[i], "string, number, or boolean expected, " + type + " found"));
+ }
+ }
+ break;
+ case "any":
+ case "all":
+ case "none":
+ for (var i$1 = 1; i$1 < value.length; i$1++) {
+ errors = errors.concat(validateNonExpressionFilter({
+ key: key + "[" + i$1 + "]",
+ value: value[i$1],
+ style: options.style,
+ styleSpec: options.styleSpec
+ }));
+ }
+ break;
+ case "has":
+ case "!has":
+ type = getType(value[1]);
+ if (value.length !== 2) {
+ errors.push(new ValidationError(key, value, 'filter array for "' + value[0] + '" operator must have 2 elements'));
+ } else if (type !== "string") {
+ errors.push(new ValidationError(key + "[1]", value[1], "string expected, " + type + " found"));
+ }
+ break;
+ case "within":
+ type = getType(value[1]);
+ if (value.length !== 2) {
+ errors.push(new ValidationError(key, value, 'filter array for "' + value[0] + '" operator must have 2 elements'));
+ } else if (type !== "object") {
+ errors.push(new ValidationError(key + "[1]", value[1], "object expected, " + type + " found"));
+ }
+ break;
+ }
+ return errors;
+ }
+ function validateProperty(options, propertyType) {
+ var key = options.key;
+ var style = options.style;
+ var styleSpec = options.styleSpec;
+ var value = options.value;
+ var propertyKey = options.objectKey;
+ var layerSpec = styleSpec[propertyType + "_" + options.layerType];
+ if (!layerSpec) {
+ return [];
+ }
+ var transitionMatch = propertyKey.match(/^(.*)-transition$/);
+ if (propertyType === "paint" && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {
+ return validate({
+ key,
+ value,
+ valueSpec: styleSpec.transition,
+ style,
+ styleSpec
+ });
+ }
+ var valueSpec = options.valueSpec || layerSpec[propertyKey];
+ if (!valueSpec) {
+ return [new ValidationError(key, value, 'unknown property "' + propertyKey + '"')];
+ }
+ var tokenMatch;
+ if (getType(value) === "string" && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {
+ return [new ValidationError(key, value, '"' + propertyKey + '" does not support interpolation syntax\nUse an identity property function instead: `{ "type": "identity", "property": ' + JSON.stringify(tokenMatch[1]) + " }`.")];
+ }
+ var errors = [];
+ if (options.layerType === "symbol") {
+ if (propertyKey === "text-field" && style && !style.glyphs) {
+ errors.push(new ValidationError(key, value, 'use of "text-field" requires a style "glyphs" property'));
+ }
+ if (propertyKey === "text-font" && isFunction(deepUnbundle(value)) && unbundle(value.type) === "identity") {
+ errors.push(new ValidationError(key, value, '"text-font" does not support identity functions'));
+ }
+ }
+ return errors.concat(validate({
+ key: options.key,
+ value,
+ valueSpec,
+ style,
+ styleSpec,
+ expressionContext: "property",
+ propertyType,
+ propertyKey
+ }));
+ }
+ function validatePaintProperty(options) {
+ return validateProperty(options, "paint");
+ }
+ function validateLayoutProperty(options) {
+ return validateProperty(options, "layout");
+ }
+ function validateLayer(options) {
+ var errors = [];
+ var layer2 = options.value;
+ var key = options.key;
+ var style = options.style;
+ var styleSpec = options.styleSpec;
+ if (!layer2.type && !layer2.ref) {
+ errors.push(new ValidationError(key, layer2, 'either "type" or "ref" is required'));
+ }
+ var type = unbundle(layer2.type);
+ var ref = unbundle(layer2.ref);
+ if (layer2.id) {
+ var layerId = unbundle(layer2.id);
+ for (var i = 0; i < options.arrayIndex; i++) {
+ var otherLayer = style.layers[i];
+ if (unbundle(otherLayer.id) === layerId) {
+ errors.push(new ValidationError(key, layer2.id, 'duplicate layer id "' + layer2.id + '", previously used at line ' + otherLayer.id.__line__));
+ }
+ }
+ }
+ if ("ref" in layer2) {
+ [
+ "type",
+ "source",
+ "source-layer",
+ "filter",
+ "layout"
+ ].forEach(function(p) {
+ if (p in layer2) {
+ errors.push(new ValidationError(key, layer2[p], '"' + p + '" is prohibited for ref layers'));
+ }
+ });
+ var parent;
+ style.layers.forEach(function(layer3) {
+ if (unbundle(layer3.id) === ref) {
+ parent = layer3;
+ }
+ });
+ if (!parent) {
+ errors.push(new ValidationError(key, layer2.ref, 'ref layer "' + ref + '" not found'));
+ } else if (parent.ref) {
+ errors.push(new ValidationError(key, layer2.ref, "ref cannot reference another ref layer"));
+ } else {
+ type = unbundle(parent.type);
+ }
+ } else if (type !== "background") {
+ if (!layer2.source) {
+ errors.push(new ValidationError(key, layer2, 'missing required property "source"'));
+ } else {
+ var source2 = style.sources && style.sources[layer2.source];
+ var sourceType = source2 && unbundle(source2.type);
+ if (!source2) {
+ errors.push(new ValidationError(key, layer2.source, 'source "' + layer2.source + '" not found'));
+ } else if (sourceType === "vector" && type === "raster") {
+ errors.push(new ValidationError(key, layer2.source, 'layer "' + layer2.id + '" requires a raster source'));
+ } else if (sourceType === "raster" && type !== "raster") {
+ errors.push(new ValidationError(key, layer2.source, 'layer "' + layer2.id + '" requires a vector source'));
+ } else if (sourceType === "vector" && !layer2["source-layer"]) {
+ errors.push(new ValidationError(key, layer2, 'layer "' + layer2.id + '" must specify a "source-layer"'));
+ } else if (sourceType === "raster-dem" && type !== "hillshade") {
+ errors.push(new ValidationError(key, layer2.source, "raster-dem source can only be used with layer type 'hillshade'."));
+ } else if (type === "line" && layer2.paint && layer2.paint["line-gradient"] && (sourceType !== "geojson" || !source2.lineMetrics)) {
+ errors.push(new ValidationError(key, layer2, 'layer "' + layer2.id + '" specifies a line-gradient, which requires a GeoJSON source with `lineMetrics` enabled.'));
+ }
+ }
+ }
+ errors = errors.concat(validateObject({
+ key,
+ value: layer2,
+ valueSpec: styleSpec.layer,
+ style: options.style,
+ styleSpec: options.styleSpec,
+ objectElementValidators: {
+ "*": function _() {
+ return [];
+ },
+ type: function type2() {
+ return validate({
+ key: key + ".type",
+ value: layer2.type,
+ valueSpec: styleSpec.layer.type,
+ style: options.style,
+ styleSpec: options.styleSpec,
+ object: layer2,
+ objectKey: "type"
+ });
+ },
+ filter: validateFilter,
+ layout: function layout2(options2) {
+ return validateObject({
+ layer: layer2,
+ key: options2.key,
+ value: options2.value,
+ style: options2.style,
+ styleSpec: options2.styleSpec,
+ objectElementValidators: {
+ "*": function _(options3) {
+ return validateLayoutProperty(extend$1({ layerType: type }, options3));
+ }
+ }
+ });
+ },
+ paint: function paint2(options2) {
+ return validateObject({
+ layer: layer2,
+ key: options2.key,
+ value: options2.value,
+ style: options2.style,
+ styleSpec: options2.styleSpec,
+ objectElementValidators: {
+ "*": function _(options3) {
+ return validatePaintProperty(extend$1({ layerType: type }, options3));
+ }
+ }
+ });
+ }
+ }
+ }));
+ return errors;
+ }
+ function validateString(options) {
+ var value = options.value;
+ var key = options.key;
+ var type = getType(value);
+ if (type !== "string") {
+ return [new ValidationError(key, value, "string expected, " + type + " found")];
+ }
+ return [];
+ }
+ var objectElementValidators = { promoteId: validatePromoteId };
+ function validateSource(options) {
+ var value = options.value;
+ var key = options.key;
+ var styleSpec = options.styleSpec;
+ var style = options.style;
+ if (!value.type) {
+ return [new ValidationError(key, value, '"type" is required')];
+ }
+ var type = unbundle(value.type);
+ var errors;
+ switch (type) {
+ case "vector":
+ case "raster":
+ case "raster-dem":
+ errors = validateObject({
+ key,
+ value,
+ valueSpec: styleSpec["source_" + type.replace("-", "_")],
+ style: options.style,
+ styleSpec,
+ objectElementValidators
+ });
+ return errors;
+ case "geojson":
+ errors = validateObject({
+ key,
+ value,
+ valueSpec: styleSpec.source_geojson,
+ style,
+ styleSpec,
+ objectElementValidators
+ });
+ if (value.cluster) {
+ for (var prop in value.clusterProperties) {
+ var ref = value.clusterProperties[prop];
+ var operator = ref[0];
+ var mapExpr = ref[1];
+ var reduceExpr = typeof operator === "string" ? [
+ operator,
+ ["accumulated"],
+ [
+ "get",
+ prop
+ ]
+ ] : operator;
+ errors.push.apply(errors, validateExpression({
+ key: key + "." + prop + ".map",
+ value: mapExpr,
+ expressionContext: "cluster-map"
+ }));
+ errors.push.apply(errors, validateExpression({
+ key: key + "." + prop + ".reduce",
+ value: reduceExpr,
+ expressionContext: "cluster-reduce"
+ }));
+ }
+ }
+ return errors;
+ case "video":
+ return validateObject({
+ key,
+ value,
+ valueSpec: styleSpec.source_video,
+ style,
+ styleSpec
+ });
+ case "image":
+ return validateObject({
+ key,
+ value,
+ valueSpec: styleSpec.source_image,
+ style,
+ styleSpec
+ });
+ case "canvas":
+ return [new ValidationError(key, null, "Please use runtime APIs to add canvas sources, rather than including them in stylesheets.", "source.canvas")];
+ default:
+ return validateEnum({
+ key: key + ".type",
+ value: value.type,
+ valueSpec: {
+ values: [
+ "vector",
+ "raster",
+ "raster-dem",
+ "geojson",
+ "video",
+ "image"
+ ]
+ },
+ style,
+ styleSpec
+ });
+ }
+ }
+ function validatePromoteId(ref) {
+ var key = ref.key;
+ var value = ref.value;
+ if (getType(value) === "string") {
+ return validateString({
+ key,
+ value
+ });
+ } else {
+ var errors = [];
+ for (var prop in value) {
+ errors.push.apply(errors, validateString({
+ key: key + "." + prop,
+ value: value[prop]
+ }));
+ }
+ return errors;
+ }
+ }
+ function validateLight(options) {
+ var light2 = options.value;
+ var styleSpec = options.styleSpec;
+ var lightSpec = styleSpec.light;
+ var style = options.style;
+ var errors = [];
+ var rootType = getType(light2);
+ if (light2 === void 0) {
+ return errors;
+ } else if (rootType !== "object") {
+ errors = errors.concat([new ValidationError("light", light2, "object expected, " + rootType + " found")]);
+ return errors;
+ }
+ for (var key in light2) {
+ var transitionMatch = key.match(/^(.*)-transition$/);
+ if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) {
+ errors = errors.concat(validate({
+ key,
+ value: light2[key],
+ valueSpec: styleSpec.transition,
+ style,
+ styleSpec
+ }));
+ } else if (lightSpec[key]) {
+ errors = errors.concat(validate({
+ key,
+ value: light2[key],
+ valueSpec: lightSpec[key],
+ style,
+ styleSpec
+ }));
+ } else {
+ errors = errors.concat([new ValidationError(key, light2[key], 'unknown property "' + key + '"')]);
+ }
+ }
+ return errors;
+ }
+ function validateFormatted(options) {
+ if (validateString(options).length === 0) {
+ return [];
+ }
+ return validateExpression(options);
+ }
+ function validateImage(options) {
+ if (validateString(options).length === 0) {
+ return [];
+ }
+ return validateExpression(options);
+ }
+ var VALIDATORS = {
+ "*": function _() {
+ return [];
+ },
+ "array": validateArray,
+ "boolean": validateBoolean,
+ "number": validateNumber,
+ "color": validateColor,
+ "constants": validateConstants,
+ "enum": validateEnum,
+ "filter": validateFilter,
+ "function": validateFunction,
+ "layer": validateLayer,
+ "object": validateObject,
+ "source": validateSource,
+ "light": validateLight,
+ "string": validateString,
+ "formatted": validateFormatted,
+ "resolvedImage": validateImage
+ };
+ function validate(options) {
+ var value = options.value;
+ var valueSpec = options.valueSpec;
+ var styleSpec = options.styleSpec;
+ if (valueSpec.expression && isFunction(unbundle(value))) {
+ return validateFunction(options);
+ } else if (valueSpec.expression && isExpression(deepUnbundle(value))) {
+ return validateExpression(options);
+ } else if (valueSpec.type && VALIDATORS[valueSpec.type]) {
+ return VALIDATORS[valueSpec.type](options);
+ } else {
+ var valid = validateObject(extend$1({}, options, { valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec }));
+ return valid;
+ }
+ }
+ function validateGlyphsURL(options) {
+ var value = options.value;
+ var key = options.key;
+ var errors = validateString(options);
+ if (errors.length) {
+ return errors;
+ }
+ if (value.indexOf("{fontstack}") === -1) {
+ errors.push(new ValidationError(key, value, '"glyphs" url must include a "{fontstack}" token'));
+ }
+ if (value.indexOf("{range}") === -1) {
+ errors.push(new ValidationError(key, value, '"glyphs" url must include a "{range}" token'));
+ }
+ return errors;
+ }
+ function validateStyleMin(style, styleSpec) {
+ if (styleSpec === void 0)
+ styleSpec = spec;
+ var errors = [];
+ errors = errors.concat(validate({
+ key: "",
+ value: style,
+ valueSpec: styleSpec.$root,
+ styleSpec,
+ style,
+ objectElementValidators: {
+ glyphs: validateGlyphsURL,
+ "*": function _() {
+ return [];
+ }
+ }
+ }));
+ if (style.constants) {
+ errors = errors.concat(validateConstants({
+ key: "constants",
+ value: style.constants,
+ style,
+ styleSpec
+ }));
+ }
+ return sortErrors(errors);
+ }
+ validateStyleMin.source = wrapCleanErrors(validateSource);
+ validateStyleMin.light = wrapCleanErrors(validateLight);
+ validateStyleMin.layer = wrapCleanErrors(validateLayer);
+ validateStyleMin.filter = wrapCleanErrors(validateFilter);
+ validateStyleMin.paintProperty = wrapCleanErrors(validatePaintProperty);
+ validateStyleMin.layoutProperty = wrapCleanErrors(validateLayoutProperty);
+ function sortErrors(errors) {
+ return [].concat(errors).sort(function(a, b) {
+ return a.line - b.line;
+ });
+ }
+ function wrapCleanErrors(inner) {
+ return function() {
+ var args = [], len = arguments.length;
+ while (len--)
+ args[len] = arguments[len];
+ return sortErrors(inner.apply(this, args));
+ };
+ }
+ var validateStyle = validateStyleMin;
+ var validateLight$1 = validateStyle.light;
+ var validatePaintProperty$1 = validateStyle.paintProperty;
+ var validateLayoutProperty$1 = validateStyle.layoutProperty;
+ function emitValidationErrors(emitter, errors) {
+ var hasErrors = false;
+ if (errors && errors.length) {
+ for (var i = 0, list = errors; i < list.length; i += 1) {
+ var error2 = list[i];
+ emitter.fire(new ErrorEvent(new Error(error2.message)));
+ hasErrors = true;
+ }
+ }
+ return hasErrors;
+ }
+ var gridIndex = GridIndex;
+ var NUM_PARAMS = 3;
+ function GridIndex(extent, n, padding) {
+ var cells = this.cells = [];
+ if (extent instanceof ArrayBuffer) {
+ this.arrayBuffer = extent;
+ var array2 = new Int32Array(this.arrayBuffer);
+ extent = array2[0];
+ n = array2[1];
+ padding = array2[2];
+ this.d = n + 2 * padding;
+ for (var k = 0; k < this.d * this.d; k++) {
+ var start = array2[NUM_PARAMS + k];
+ var end = array2[NUM_PARAMS + k + 1];
+ cells.push(start === end ? null : array2.subarray(start, end));
+ }
+ var keysOffset = array2[NUM_PARAMS + cells.length];
+ var bboxesOffset = array2[NUM_PARAMS + cells.length + 1];
+ this.keys = array2.subarray(keysOffset, bboxesOffset);
+ this.bboxes = array2.subarray(bboxesOffset);
+ this.insert = this._insertReadonly;
+ } else {
+ this.d = n + 2 * padding;
+ for (var i = 0; i < this.d * this.d; i++) {
+ cells.push([]);
+ }
+ this.keys = [];
+ this.bboxes = [];
+ }
+ this.n = n;
+ this.extent = extent;
+ this.padding = padding;
+ this.scale = n / extent;
+ this.uid = 0;
+ var p = padding / n * extent;
+ this.min = -p;
+ this.max = extent + p;
+ }
+ GridIndex.prototype.insert = function(key, x1, y1, x2, y2) {
+ this._forEachCell(x1, y1, x2, y2, this._insertCell, this.uid++);
+ this.keys.push(key);
+ this.bboxes.push(x1);
+ this.bboxes.push(y1);
+ this.bboxes.push(x2);
+ this.bboxes.push(y2);
+ };
+ GridIndex.prototype._insertReadonly = function() {
+ throw "Cannot insert into a GridIndex created from an ArrayBuffer.";
+ };
+ GridIndex.prototype._insertCell = function(x1, y1, x2, y2, cellIndex, uid) {
+ this.cells[cellIndex].push(uid);
+ };
+ GridIndex.prototype.query = function(x1, y1, x2, y2, intersectionTest) {
+ var min = this.min;
+ var max = this.max;
+ if (x1 <= min && y1 <= min && max <= x2 && max <= y2 && !intersectionTest) {
+ return Array.prototype.slice.call(this.keys);
+ } else {
+ var result = [];
+ var seenUids = {};
+ this._forEachCell(x1, y1, x2, y2, this._queryCell, result, seenUids, intersectionTest);
+ return result;
+ }
+ };
+ GridIndex.prototype._queryCell = function(x1, y1, x2, y2, cellIndex, result, seenUids, intersectionTest) {
+ var cell = this.cells[cellIndex];
+ if (cell !== null) {
+ var keys = this.keys;
+ var bboxes = this.bboxes;
+ for (var u = 0; u < cell.length; u++) {
+ var uid = cell[u];
+ if (seenUids[uid] === void 0) {
+ var offset = uid * 4;
+ if (intersectionTest ? intersectionTest(bboxes[offset + 0], bboxes[offset + 1], bboxes[offset + 2], bboxes[offset + 3]) : x1 <= bboxes[offset + 2] && y1 <= bboxes[offset + 3] && x2 >= bboxes[offset + 0] && y2 >= bboxes[offset + 1]) {
+ seenUids[uid] = true;
+ result.push(keys[uid]);
+ } else {
+ seenUids[uid] = false;
+ }
+ }
+ }
+ }
+ };
+ GridIndex.prototype._forEachCell = function(x1, y1, x2, y2, fn, arg1, arg2, intersectionTest) {
+ var cx1 = this._convertToCellCoord(x1);
+ var cy1 = this._convertToCellCoord(y1);
+ var cx2 = this._convertToCellCoord(x2);
+ var cy2 = this._convertToCellCoord(y2);
+ for (var x = cx1; x <= cx2; x++) {
+ for (var y = cy1; y <= cy2; y++) {
+ var cellIndex = this.d * y + x;
+ if (intersectionTest && !intersectionTest(this._convertFromCellCoord(x), this._convertFromCellCoord(y), this._convertFromCellCoord(x + 1), this._convertFromCellCoord(y + 1))) {
+ continue;
+ }
+ if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, intersectionTest)) {
+ return;
+ }
+ }
+ }
+ };
+ GridIndex.prototype._convertFromCellCoord = function(x) {
+ return (x - this.padding) / this.scale;
+ };
+ GridIndex.prototype._convertToCellCoord = function(x) {
+ return Math.max(0, Math.min(this.d - 1, Math.floor(x * this.scale) + this.padding));
+ };
+ GridIndex.prototype.toArrayBuffer = function() {
+ if (this.arrayBuffer) {
+ return this.arrayBuffer;
+ }
+ var cells = this.cells;
+ var metadataLength = NUM_PARAMS + this.cells.length + 1 + 1;
+ var totalCellLength = 0;
+ for (var i = 0; i < this.cells.length; i++) {
+ totalCellLength += this.cells[i].length;
+ }
+ var array2 = new Int32Array(metadataLength + totalCellLength + this.keys.length + this.bboxes.length);
+ array2[0] = this.extent;
+ array2[1] = this.n;
+ array2[2] = this.padding;
+ var offset = metadataLength;
+ for (var k = 0; k < cells.length; k++) {
+ var cell = cells[k];
+ array2[NUM_PARAMS + k] = offset;
+ array2.set(cell, offset);
+ offset += cell.length;
+ }
+ array2[NUM_PARAMS + cells.length] = offset;
+ array2.set(this.keys, offset);
+ offset += this.keys.length;
+ array2[NUM_PARAMS + cells.length + 1] = offset;
+ array2.set(this.bboxes, offset);
+ offset += this.bboxes.length;
+ return array2.buffer;
+ };
+ var ImageData2 = window$1.ImageData;
+ var ImageBitmap2 = window$1.ImageBitmap;
+ var registry = {};
+ function register(name3, klass, options) {
+ if (options === void 0)
+ options = {};
+ Object.defineProperty(klass, "_classRegistryKey", {
+ value: name3,
+ writeable: false
+ });
+ registry[name3] = {
+ klass,
+ omit: options.omit || [],
+ shallow: options.shallow || []
+ };
+ }
+ register("Object", Object);
+ gridIndex.serialize = function serialize2(grid, transferables) {
+ var buffer = grid.toArrayBuffer();
+ if (transferables) {
+ transferables.push(buffer);
+ }
+ return { buffer };
+ };
+ gridIndex.deserialize = function deserialize2(serialized) {
+ return new gridIndex(serialized.buffer);
+ };
+ register("Grid", gridIndex);
+ register("Color", Color2);
+ register("Error", Error);
+ register("ResolvedImage", ResolvedImage);
+ register("StylePropertyFunction", StylePropertyFunction);
+ register("StyleExpression", StyleExpression, { omit: ["_evaluator"] });
+ register("ZoomDependentExpression", ZoomDependentExpression);
+ register("ZoomConstantExpression", ZoomConstantExpression);
+ register("CompoundExpression", CompoundExpression, { omit: ["_evaluate"] });
+ for (var name2 in expressions) {
+ if (expressions[name2]._classRegistryKey) {
+ continue;
+ }
+ register("Expression_" + name2, expressions[name2]);
+ }
+ function isArrayBuffer(val) {
+ return val && typeof ArrayBuffer !== "undefined" && (val instanceof ArrayBuffer || val.constructor && val.constructor.name === "ArrayBuffer");
+ }
+ function isImageBitmap(val) {
+ return ImageBitmap2 && val instanceof ImageBitmap2;
+ }
+ function serialize(input, transferables) {
+ if (input === null || input === void 0 || typeof input === "boolean" || typeof input === "number" || typeof input === "string" || input instanceof Boolean || input instanceof Number || input instanceof String || input instanceof Date || input instanceof RegExp) {
+ return input;
+ }
+ if (isArrayBuffer(input) || isImageBitmap(input)) {
+ if (transferables) {
+ transferables.push(input);
+ }
+ return input;
+ }
+ if (ArrayBuffer.isView(input)) {
+ var view = input;
+ if (transferables) {
+ transferables.push(view.buffer);
+ }
+ return view;
+ }
+ if (input instanceof ImageData2) {
+ if (transferables) {
+ transferables.push(input.data.buffer);
+ }
+ return input;
+ }
+ if (Array.isArray(input)) {
+ var serialized = [];
+ for (var i = 0, list = input; i < list.length; i += 1) {
+ var item = list[i];
+ serialized.push(serialize(item, transferables));
+ }
+ return serialized;
+ }
+ if (typeof input === "object") {
+ var klass = input.constructor;
+ var name3 = klass._classRegistryKey;
+ if (!name3) {
+ throw new Error("can't serialize object of unregistered class");
+ }
+ var properties2 = klass.serialize ? klass.serialize(input, transferables) : {};
+ if (!klass.serialize) {
+ for (var key in input) {
+ if (!input.hasOwnProperty(key)) {
+ continue;
+ }
+ if (registry[name3].omit.indexOf(key) >= 0) {
+ continue;
+ }
+ var property = input[key];
+ properties2[key] = registry[name3].shallow.indexOf(key) >= 0 ? property : serialize(property, transferables);
+ }
+ if (input instanceof Error) {
+ properties2.message = input.message;
+ }
+ }
+ if (properties2.$name) {
+ throw new Error("$name property is reserved for worker serialization logic.");
+ }
+ if (name3 !== "Object") {
+ properties2.$name = name3;
+ }
+ return properties2;
+ }
+ throw new Error("can't serialize object of type " + typeof input);
+ }
+ function deserialize(input) {
+ if (input === null || input === void 0 || typeof input === "boolean" || typeof input === "number" || typeof input === "string" || input instanceof Boolean || input instanceof Number || input instanceof String || input instanceof Date || input instanceof RegExp || isArrayBuffer(input) || isImageBitmap(input) || ArrayBuffer.isView(input) || input instanceof ImageData2) {
+ return input;
+ }
+ if (Array.isArray(input)) {
+ return input.map(deserialize);
+ }
+ if (typeof input === "object") {
+ var name3 = input.$name || "Object";
+ var ref = registry[name3];
+ var klass = ref.klass;
+ if (!klass) {
+ throw new Error("can't deserialize unregistered class " + name3);
+ }
+ if (klass.deserialize) {
+ return klass.deserialize(input);
+ }
+ var result = Object.create(klass.prototype);
+ for (var i = 0, list = Object.keys(input); i < list.length; i += 1) {
+ var key = list[i];
+ if (key === "$name") {
+ continue;
+ }
+ var value = input[key];
+ result[key] = registry[name3].shallow.indexOf(key) >= 0 ? value : deserialize(value);
+ }
+ return result;
+ }
+ throw new Error("can't deserialize object of type " + typeof input);
+ }
+ var ZoomHistory = function ZoomHistory2() {
+ this.first = true;
+ };
+ ZoomHistory.prototype.update = function update(z, now2) {
+ var floorZ = Math.floor(z);
+ if (this.first) {
+ this.first = false;
+ this.lastIntegerZoom = floorZ;
+ this.lastIntegerZoomTime = 0;
+ this.lastZoom = z;
+ this.lastFloorZoom = floorZ;
+ return true;
+ }
+ if (this.lastFloorZoom > floorZ) {
+ this.lastIntegerZoom = floorZ + 1;
+ this.lastIntegerZoomTime = now2;
+ } else if (this.lastFloorZoom < floorZ) {
+ this.lastIntegerZoom = floorZ;
+ this.lastIntegerZoomTime = now2;
+ }
+ if (z !== this.lastZoom) {
+ this.lastZoom = z;
+ this.lastFloorZoom = floorZ;
+ return true;
+ }
+ return false;
+ };
+ var unicodeBlockLookup = {
+ "Latin-1 Supplement": function(char) {
+ return char >= 128 && char <= 255;
+ },
+ "Arabic": function(char) {
+ return char >= 1536 && char <= 1791;
+ },
+ "Arabic Supplement": function(char) {
+ return char >= 1872 && char <= 1919;
+ },
+ "Arabic Extended-A": function(char) {
+ return char >= 2208 && char <= 2303;
+ },
+ "Hangul Jamo": function(char) {
+ return char >= 4352 && char <= 4607;
+ },
+ "Unified Canadian Aboriginal Syllabics": function(char) {
+ return char >= 5120 && char <= 5759;
+ },
+ "Khmer": function(char) {
+ return char >= 6016 && char <= 6143;
+ },
+ "Unified Canadian Aboriginal Syllabics Extended": function(char) {
+ return char >= 6320 && char <= 6399;
+ },
+ "General Punctuation": function(char) {
+ return char >= 8192 && char <= 8303;
+ },
+ "Letterlike Symbols": function(char) {
+ return char >= 8448 && char <= 8527;
+ },
+ "Number Forms": function(char) {
+ return char >= 8528 && char <= 8591;
+ },
+ "Miscellaneous Technical": function(char) {
+ return char >= 8960 && char <= 9215;
+ },
+ "Control Pictures": function(char) {
+ return char >= 9216 && char <= 9279;
+ },
+ "Optical Character Recognition": function(char) {
+ return char >= 9280 && char <= 9311;
+ },
+ "Enclosed Alphanumerics": function(char) {
+ return char >= 9312 && char <= 9471;
+ },
+ "Geometric Shapes": function(char) {
+ return char >= 9632 && char <= 9727;
+ },
+ "Miscellaneous Symbols": function(char) {
+ return char >= 9728 && char <= 9983;
+ },
+ "Miscellaneous Symbols and Arrows": function(char) {
+ return char >= 11008 && char <= 11263;
+ },
+ "CJK Radicals Supplement": function(char) {
+ return char >= 11904 && char <= 12031;
+ },
+ "Kangxi Radicals": function(char) {
+ return char >= 12032 && char <= 12255;
+ },
+ "Ideographic Description Characters": function(char) {
+ return char >= 12272 && char <= 12287;
+ },
+ "CJK Symbols and Punctuation": function(char) {
+ return char >= 12288 && char <= 12351;
+ },
+ "Hiragana": function(char) {
+ return char >= 12352 && char <= 12447;
+ },
+ "Katakana": function(char) {
+ return char >= 12448 && char <= 12543;
+ },
+ "Bopomofo": function(char) {
+ return char >= 12544 && char <= 12591;
+ },
+ "Hangul Compatibility Jamo": function(char) {
+ return char >= 12592 && char <= 12687;
+ },
+ "Kanbun": function(char) {
+ return char >= 12688 && char <= 12703;
+ },
+ "Bopomofo Extended": function(char) {
+ return char >= 12704 && char <= 12735;
+ },
+ "CJK Strokes": function(char) {
+ return char >= 12736 && char <= 12783;
+ },
+ "Katakana Phonetic Extensions": function(char) {
+ return char >= 12784 && char <= 12799;
+ },
+ "Enclosed CJK Letters and Months": function(char) {
+ return char >= 12800 && char <= 13055;
+ },
+ "CJK Compatibility": function(char) {
+ return char >= 13056 && char <= 13311;
+ },
+ "CJK Unified Ideographs Extension A": function(char) {
+ return char >= 13312 && char <= 19903;
+ },
+ "Yijing Hexagram Symbols": function(char) {
+ return char >= 19904 && char <= 19967;
+ },
+ "CJK Unified Ideographs": function(char) {
+ return char >= 19968 && char <= 40959;
+ },
+ "Yi Syllables": function(char) {
+ return char >= 40960 && char <= 42127;
+ },
+ "Yi Radicals": function(char) {
+ return char >= 42128 && char <= 42191;
+ },
+ "Hangul Jamo Extended-A": function(char) {
+ return char >= 43360 && char <= 43391;
+ },
+ "Hangul Syllables": function(char) {
+ return char >= 44032 && char <= 55215;
+ },
+ "Hangul Jamo Extended-B": function(char) {
+ return char >= 55216 && char <= 55295;
+ },
+ "Private Use Area": function(char) {
+ return char >= 57344 && char <= 63743;
+ },
+ "CJK Compatibility Ideographs": function(char) {
+ return char >= 63744 && char <= 64255;
+ },
+ "Arabic Presentation Forms-A": function(char) {
+ return char >= 64336 && char <= 65023;
+ },
+ "Vertical Forms": function(char) {
+ return char >= 65040 && char <= 65055;
+ },
+ "CJK Compatibility Forms": function(char) {
+ return char >= 65072 && char <= 65103;
+ },
+ "Small Form Variants": function(char) {
+ return char >= 65104 && char <= 65135;
+ },
+ "Arabic Presentation Forms-B": function(char) {
+ return char >= 65136 && char <= 65279;
+ },
+ "Halfwidth and Fullwidth Forms": function(char) {
+ return char >= 65280 && char <= 65519;
+ }
+ };
+ function allowsVerticalWritingMode(chars) {
+ for (var i = 0, list = chars; i < list.length; i += 1) {
+ var char = list[i];
+ if (charHasUprightVerticalOrientation(char.charCodeAt(0))) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function allowsLetterSpacing(chars) {
+ for (var i = 0, list = chars; i < list.length; i += 1) {
+ var char = list[i];
+ if (!charAllowsLetterSpacing(char.charCodeAt(0))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ function charAllowsLetterSpacing(char) {
+ if (unicodeBlockLookup["Arabic"](char)) {
+ return false;
+ }
+ if (unicodeBlockLookup["Arabic Supplement"](char)) {
+ return false;
+ }
+ if (unicodeBlockLookup["Arabic Extended-A"](char)) {
+ return false;
+ }
+ if (unicodeBlockLookup["Arabic Presentation Forms-A"](char)) {
+ return false;
+ }
+ if (unicodeBlockLookup["Arabic Presentation Forms-B"](char)) {
+ return false;
+ }
+ return true;
+ }
+ function charAllowsIdeographicBreaking(char) {
+ if (char < 11904) {
+ return false;
+ }
+ if (unicodeBlockLookup["Bopomofo Extended"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Bopomofo"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Compatibility Forms"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Compatibility Ideographs"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Compatibility"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Radicals Supplement"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Strokes"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Symbols and Punctuation"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Unified Ideographs Extension A"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Unified Ideographs"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Enclosed CJK Letters and Months"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Halfwidth and Fullwidth Forms"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Hiragana"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Ideographic Description Characters"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Kangxi Radicals"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Katakana Phonetic Extensions"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Katakana"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Vertical Forms"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Yi Radicals"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Yi Syllables"](char)) {
+ return true;
+ }
+ return false;
+ }
+ function charHasUprightVerticalOrientation(char) {
+ if (char === 746 || char === 747) {
+ return true;
+ }
+ if (char < 4352) {
+ return false;
+ }
+ if (unicodeBlockLookup["Bopomofo Extended"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Bopomofo"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Compatibility Forms"](char)) {
+ if (!(char >= 65097 && char <= 65103)) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["CJK Compatibility Ideographs"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Compatibility"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Radicals Supplement"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Strokes"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Symbols and Punctuation"](char)) {
+ if (!(char >= 12296 && char <= 12305) && !(char >= 12308 && char <= 12319) && char !== 12336) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["CJK Unified Ideographs Extension A"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Unified Ideographs"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Enclosed CJK Letters and Months"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Hangul Compatibility Jamo"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Hangul Jamo Extended-A"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Hangul Jamo Extended-B"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Hangul Jamo"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Hangul Syllables"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Hiragana"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Ideographic Description Characters"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Kanbun"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Kangxi Radicals"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Katakana Phonetic Extensions"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Katakana"](char)) {
+ if (char !== 12540) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["Halfwidth and Fullwidth Forms"](char)) {
+ if (char !== 65288 && char !== 65289 && char !== 65293 && !(char >= 65306 && char <= 65310) && char !== 65339 && char !== 65341 && char !== 65343 && !(char >= 65371 && char <= 65503) && char !== 65507 && !(char >= 65512 && char <= 65519)) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["Small Form Variants"](char)) {
+ if (!(char >= 65112 && char <= 65118) && !(char >= 65123 && char <= 65126)) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["Unified Canadian Aboriginal Syllabics"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Unified Canadian Aboriginal Syllabics Extended"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Vertical Forms"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Yijing Hexagram Symbols"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Yi Syllables"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Yi Radicals"](char)) {
+ return true;
+ }
+ return false;
+ }
+ function charHasNeutralVerticalOrientation(char) {
+ if (unicodeBlockLookup["Latin-1 Supplement"](char)) {
+ if (char === 167 || char === 169 || char === 174 || char === 177 || char === 188 || char === 189 || char === 190 || char === 215 || char === 247) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["General Punctuation"](char)) {
+ if (char === 8214 || char === 8224 || char === 8225 || char === 8240 || char === 8241 || char === 8251 || char === 8252 || char === 8258 || char === 8263 || char === 8264 || char === 8265 || char === 8273) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["Letterlike Symbols"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Number Forms"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Miscellaneous Technical"](char)) {
+ if (char >= 8960 && char <= 8967 || char >= 8972 && char <= 8991 || char >= 8996 && char <= 9e3 || char === 9003 || char >= 9085 && char <= 9114 || char >= 9150 && char <= 9165 || char === 9167 || char >= 9169 && char <= 9179 || char >= 9186 && char <= 9215) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["Control Pictures"](char) && char !== 9251) {
+ return true;
+ }
+ if (unicodeBlockLookup["Optical Character Recognition"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Enclosed Alphanumerics"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Geometric Shapes"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Miscellaneous Symbols"](char)) {
+ if (!(char >= 9754 && char <= 9759)) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["Miscellaneous Symbols and Arrows"](char)) {
+ if (char >= 11026 && char <= 11055 || char >= 11088 && char <= 11097 || char >= 11192 && char <= 11243) {
+ return true;
+ }
+ }
+ if (unicodeBlockLookup["CJK Symbols and Punctuation"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Katakana"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Private Use Area"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["CJK Compatibility Forms"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Small Form Variants"](char)) {
+ return true;
+ }
+ if (unicodeBlockLookup["Halfwidth and Fullwidth Forms"](char)) {
+ return true;
+ }
+ if (char === 8734 || char === 8756 || char === 8757 || char >= 9984 && char <= 10087 || char >= 10102 && char <= 10131 || char === 65532 || char === 65533) {
+ return true;
+ }
+ return false;
+ }
+ function charHasRotatedVerticalOrientation(char) {
+ return !(charHasUprightVerticalOrientation(char) || charHasNeutralVerticalOrientation(char));
+ }
+ function charInComplexShapingScript(char) {
+ return unicodeBlockLookup["Arabic"](char) || unicodeBlockLookup["Arabic Supplement"](char) || unicodeBlockLookup["Arabic Extended-A"](char) || unicodeBlockLookup["Arabic Presentation Forms-A"](char) || unicodeBlockLookup["Arabic Presentation Forms-B"](char);
+ }
+ function charInRTLScript(char) {
+ return char >= 1424 && char <= 2303 || unicodeBlockLookup["Arabic Presentation Forms-A"](char) || unicodeBlockLookup["Arabic Presentation Forms-B"](char);
+ }
+ function charInSupportedScript(char, canRenderRTL) {
+ if (!canRenderRTL && charInRTLScript(char)) {
+ return false;
+ }
+ if (char >= 2304 && char <= 3583 || char >= 3840 && char <= 4255 || unicodeBlockLookup["Khmer"](char)) {
+ return false;
+ }
+ return true;
+ }
+ function stringContainsRTLText(chars) {
+ for (var i = 0, list = chars; i < list.length; i += 1) {
+ var char = list[i];
+ if (charInRTLScript(char.charCodeAt(0))) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function isStringInSupportedScript(chars, canRenderRTL) {
+ for (var i = 0, list = chars; i < list.length; i += 1) {
+ var char = list[i];
+ if (!charInSupportedScript(char.charCodeAt(0), canRenderRTL)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ var status = {
+ unavailable: "unavailable",
+ deferred: "deferred",
+ loading: "loading",
+ loaded: "loaded",
+ error: "error"
+ };
+ var _completionCallback = null;
+ var pluginStatus = status.unavailable;
+ var pluginURL = null;
+ var triggerPluginCompletionEvent = function(error2) {
+ if (error2 && typeof error2 === "string" && error2.indexOf("NetworkError") > -1) {
+ pluginStatus = status.error;
+ }
+ if (_completionCallback) {
+ _completionCallback(error2);
+ }
+ };
+ function sendPluginStateToWorker() {
+ evented.fire(new Event("pluginStateChange", {
+ pluginStatus,
+ pluginURL
+ }));
+ }
+ var evented = new Evented();
+ var getRTLTextPluginStatus = function() {
+ return pluginStatus;
+ };
+ var registerForPluginStateChange = function(callback) {
+ callback({
+ pluginStatus,
+ pluginURL
+ });
+ evented.on("pluginStateChange", callback);
+ return callback;
+ };
+ var setRTLTextPlugin = function(url, callback, deferred) {
+ if (deferred === void 0)
+ deferred = false;
+ if (pluginStatus === status.deferred || pluginStatus === status.loading || pluginStatus === status.loaded) {
+ throw new Error("setRTLTextPlugin cannot be called multiple times.");
+ }
+ pluginURL = exported.resolveURL(url);
+ pluginStatus = status.deferred;
+ _completionCallback = callback;
+ sendPluginStateToWorker();
+ if (!deferred) {
+ downloadRTLTextPlugin();
+ }
+ };
+ var downloadRTLTextPlugin = function() {
+ if (pluginStatus !== status.deferred || !pluginURL) {
+ throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");
+ }
+ pluginStatus = status.loading;
+ sendPluginStateToWorker();
+ if (pluginURL) {
+ getArrayBuffer({ url: pluginURL }, function(error2) {
+ if (error2) {
+ triggerPluginCompletionEvent(error2);
+ } else {
+ pluginStatus = status.loaded;
+ sendPluginStateToWorker();
+ }
+ });
+ }
+ };
+ var plugin = {
+ applyArabicShaping: null,
+ processBidirectionalText: null,
+ processStyledBidirectionalText: null,
+ isLoaded: function isLoaded() {
+ return pluginStatus === status.loaded || plugin.applyArabicShaping != null;
+ },
+ isLoading: function isLoading() {
+ return pluginStatus === status.loading;
+ },
+ setState: function setState(state) {
+ pluginStatus = state.pluginStatus;
+ pluginURL = state.pluginURL;
+ },
+ isParsed: function isParsed() {
+ return plugin.applyArabicShaping != null && plugin.processBidirectionalText != null && plugin.processStyledBidirectionalText != null;
+ },
+ getPluginURL: function getPluginURL() {
+ return pluginURL;
+ }
+ };
+ var lazyLoadRTLTextPlugin = function() {
+ if (!plugin.isLoading() && !plugin.isLoaded() && getRTLTextPluginStatus() === "deferred") {
+ downloadRTLTextPlugin();
+ }
+ };
+ var EvaluationParameters = function EvaluationParameters2(zoom, options) {
+ this.zoom = zoom;
+ if (options) {
+ this.now = options.now;
+ this.fadeDuration = options.fadeDuration;
+ this.zoomHistory = options.zoomHistory;
+ this.transition = options.transition;
+ } else {
+ this.now = 0;
+ this.fadeDuration = 0;
+ this.zoomHistory = new ZoomHistory();
+ this.transition = {};
+ }
+ };
+ EvaluationParameters.prototype.isSupportedScript = function isSupportedScript(str) {
+ return isStringInSupportedScript(str, plugin.isLoaded());
+ };
+ EvaluationParameters.prototype.crossFadingFactor = function crossFadingFactor() {
+ if (this.fadeDuration === 0) {
+ return 1;
+ } else {
+ return Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1);
+ }
+ };
+ EvaluationParameters.prototype.getCrossfadeParameters = function getCrossfadeParameters() {
+ var z = this.zoom;
+ var fraction = z - Math.floor(z);
+ var t = this.crossFadingFactor();
+ return z > this.zoomHistory.lastIntegerZoom ? {
+ fromScale: 2,
+ toScale: 1,
+ t: fraction + (1 - fraction) * t
+ } : {
+ fromScale: 0.5,
+ toScale: 1,
+ t: 1 - (1 - t) * fraction
+ };
+ };
+ var PropertyValue = function PropertyValue2(property, value) {
+ this.property = property;
+ this.value = value;
+ this.expression = normalizePropertyExpression(value === void 0 ? property.specification.default : value, property.specification);
+ };
+ PropertyValue.prototype.isDataDriven = function isDataDriven() {
+ return this.expression.kind === "source" || this.expression.kind === "composite";
+ };
+ PropertyValue.prototype.possiblyEvaluate = function possiblyEvaluate(parameters, canonical, availableImages) {
+ return this.property.possiblyEvaluate(this, parameters, canonical, availableImages);
+ };
+ var TransitionablePropertyValue = function TransitionablePropertyValue2(property) {
+ this.property = property;
+ this.value = new PropertyValue(property, void 0);
+ };
+ TransitionablePropertyValue.prototype.transitioned = function transitioned(parameters, prior) {
+ return new TransitioningPropertyValue(this.property, this.value, prior, extend2({}, parameters.transition, this.transition), parameters.now);
+ };
+ TransitionablePropertyValue.prototype.untransitioned = function untransitioned() {
+ return new TransitioningPropertyValue(this.property, this.value, null, {}, 0);
+ };
+ var Transitionable = function Transitionable2(properties2) {
+ this._properties = properties2;
+ this._values = Object.create(properties2.defaultTransitionablePropertyValues);
+ };
+ Transitionable.prototype.getValue = function getValue(name3) {
+ return clone(this._values[name3].value.value);
+ };
+ Transitionable.prototype.setValue = function setValue(name3, value) {
+ if (!this._values.hasOwnProperty(name3)) {
+ this._values[name3] = new TransitionablePropertyValue(this._values[name3].property);
+ }
+ this._values[name3].value = new PropertyValue(this._values[name3].property, value === null ? void 0 : clone(value));
+ };
+ Transitionable.prototype.getTransition = function getTransition(name3) {
+ return clone(this._values[name3].transition);
+ };
+ Transitionable.prototype.setTransition = function setTransition(name3, value) {
+ if (!this._values.hasOwnProperty(name3)) {
+ this._values[name3] = new TransitionablePropertyValue(this._values[name3].property);
+ }
+ this._values[name3].transition = clone(value) || void 0;
+ };
+ Transitionable.prototype.serialize = function serialize2() {
+ var result = {};
+ for (var i = 0, list = Object.keys(this._values); i < list.length; i += 1) {
+ var property = list[i];
+ var value = this.getValue(property);
+ if (value !== void 0) {
+ result[property] = value;
+ }
+ var transition2 = this.getTransition(property);
+ if (transition2 !== void 0) {
+ result[property + "-transition"] = transition2;
+ }
+ }
+ return result;
+ };
+ Transitionable.prototype.transitioned = function transitioned(parameters, prior) {
+ var result = new Transitioning(this._properties);
+ for (var i = 0, list = Object.keys(this._values); i < list.length; i += 1) {
+ var property = list[i];
+ result._values[property] = this._values[property].transitioned(parameters, prior._values[property]);
+ }
+ return result;
+ };
+ Transitionable.prototype.untransitioned = function untransitioned() {
+ var result = new Transitioning(this._properties);
+ for (var i = 0, list = Object.keys(this._values); i < list.length; i += 1) {
+ var property = list[i];
+ result._values[property] = this._values[property].untransitioned();
+ }
+ return result;
+ };
+ var TransitioningPropertyValue = function TransitioningPropertyValue2(property, value, prior, transition2, now2) {
+ this.property = property;
+ this.value = value;
+ this.begin = now2 + transition2.delay || 0;
+ this.end = this.begin + transition2.duration || 0;
+ if (property.specification.transition && (transition2.delay || transition2.duration)) {
+ this.prior = prior;
+ }
+ };
+ TransitioningPropertyValue.prototype.possiblyEvaluate = function possiblyEvaluate(parameters, canonical, availableImages) {
+ var now2 = parameters.now || 0;
+ var finalValue = this.value.possiblyEvaluate(parameters, canonical, availableImages);
+ var prior = this.prior;
+ if (!prior) {
+ return finalValue;
+ } else if (now2 > this.end) {
+ this.prior = null;
+ return finalValue;
+ } else if (this.value.isDataDriven()) {
+ this.prior = null;
+ return finalValue;
+ } else if (now2 < this.begin) {
+ return prior.possiblyEvaluate(parameters, canonical, availableImages);
+ } else {
+ var t = (now2 - this.begin) / (this.end - this.begin);
+ return this.property.interpolate(prior.possiblyEvaluate(parameters, canonical, availableImages), finalValue, easeCubicInOut(t));
+ }
+ };
+ var Transitioning = function Transitioning2(properties2) {
+ this._properties = properties2;
+ this._values = Object.create(properties2.defaultTransitioningPropertyValues);
+ };
+ Transitioning.prototype.possiblyEvaluate = function possiblyEvaluate(parameters, canonical, availableImages) {
+ var result = new PossiblyEvaluated(this._properties);
+ for (var i = 0, list = Object.keys(this._values); i < list.length; i += 1) {
+ var property = list[i];
+ result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);
+ }
+ return result;
+ };
+ Transitioning.prototype.hasTransition = function hasTransition() {
+ for (var i = 0, list = Object.keys(this._values); i < list.length; i += 1) {
+ var property = list[i];
+ if (this._values[property].prior) {
+ return true;
+ }
+ }
+ return false;
+ };
+ var Layout = function Layout2(properties2) {
+ this._properties = properties2;
+ this._values = Object.create(properties2.defaultPropertyValues);
+ };
+ Layout.prototype.getValue = function getValue(name3) {
+ return clone(this._values[name3].value);
+ };
+ Layout.prototype.setValue = function setValue(name3, value) {
+ this._values[name3] = new PropertyValue(this._values[name3].property, value === null ? void 0 : clone(value));
+ };
+ Layout.prototype.serialize = function serialize2() {
+ var result = {};
+ for (var i = 0, list = Object.keys(this._values); i < list.length; i += 1) {
+ var property = list[i];
+ var value = this.getValue(property);
+ if (value !== void 0) {
+ result[property] = value;
+ }
+ }
+ return result;
+ };
+ Layout.prototype.possiblyEvaluate = function possiblyEvaluate(parameters, canonical, availableImages) {
+ var result = new PossiblyEvaluated(this._properties);
+ for (var i = 0, list = Object.keys(this._values); i < list.length; i += 1) {
+ var property = list[i];
+ result._values[property] = this._values[property].possiblyEvaluate(parameters, canonical, availableImages);
+ }
+ return result;
+ };
+ var PossiblyEvaluatedPropertyValue = function PossiblyEvaluatedPropertyValue2(property, value, parameters) {
+ this.property = property;
+ this.value = value;
+ this.parameters = parameters;
+ };
+ PossiblyEvaluatedPropertyValue.prototype.isConstant = function isConstant2() {
+ return this.value.kind === "constant";
+ };
+ PossiblyEvaluatedPropertyValue.prototype.constantOr = function constantOr(value) {
+ if (this.value.kind === "constant") {
+ return this.value.value;
+ } else {
+ return value;
+ }
+ };
+ PossiblyEvaluatedPropertyValue.prototype.evaluate = function evaluate(feature, featureState, canonical, availableImages) {
+ return this.property.evaluate(this.value, this.parameters, feature, featureState, canonical, availableImages);
+ };
+ var PossiblyEvaluated = function PossiblyEvaluated2(properties2) {
+ this._properties = properties2;
+ this._values = Object.create(properties2.defaultPossiblyEvaluatedValues);
+ };
+ PossiblyEvaluated.prototype.get = function get2(name3) {
+ return this._values[name3];
+ };
+ var DataConstantProperty = function DataConstantProperty2(specification) {
+ this.specification = specification;
+ };
+ DataConstantProperty.prototype.possiblyEvaluate = function possiblyEvaluate(value, parameters) {
+ return value.expression.evaluate(parameters);
+ };
+ DataConstantProperty.prototype.interpolate = function interpolate$1(a, b, t) {
+ var interp = interpolate[this.specification.type];
+ if (interp) {
+ return interp(a, b, t);
+ } else {
+ return a;
+ }
+ };
+ var DataDrivenProperty = function DataDrivenProperty2(specification, overrides) {
+ this.specification = specification;
+ this.overrides = overrides;
+ };
+ DataDrivenProperty.prototype.possiblyEvaluate = function possiblyEvaluate(value, parameters, canonical, availableImages) {
+ if (value.expression.kind === "constant" || value.expression.kind === "camera") {
+ return new PossiblyEvaluatedPropertyValue(this, {
+ kind: "constant",
+ value: value.expression.evaluate(parameters, null, {}, canonical, availableImages)
+ }, parameters);
+ } else {
+ return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);
+ }
+ };
+ DataDrivenProperty.prototype.interpolate = function interpolate$2(a, b, t) {
+ if (a.value.kind !== "constant" || b.value.kind !== "constant") {
+ return a;
+ }
+ if (a.value.value === void 0 || b.value.value === void 0) {
+ return new PossiblyEvaluatedPropertyValue(this, {
+ kind: "constant",
+ value: void 0
+ }, a.parameters);
+ }
+ var interp = interpolate[this.specification.type];
+ if (interp) {
+ return new PossiblyEvaluatedPropertyValue(this, {
+ kind: "constant",
+ value: interp(a.value.value, b.value.value, t)
+ }, a.parameters);
+ } else {
+ return a;
+ }
+ };
+ DataDrivenProperty.prototype.evaluate = function evaluate(value, parameters, feature, featureState, canonical, availableImages) {
+ if (value.kind === "constant") {
+ return value.value;
+ } else {
+ return value.evaluate(parameters, feature, featureState, canonical, availableImages);
+ }
+ };
+ var CrossFadedDataDrivenProperty = function(DataDrivenProperty2) {
+ function CrossFadedDataDrivenProperty2() {
+ DataDrivenProperty2.apply(this, arguments);
+ }
+ if (DataDrivenProperty2)
+ CrossFadedDataDrivenProperty2.__proto__ = DataDrivenProperty2;
+ CrossFadedDataDrivenProperty2.prototype = Object.create(DataDrivenProperty2 && DataDrivenProperty2.prototype);
+ CrossFadedDataDrivenProperty2.prototype.constructor = CrossFadedDataDrivenProperty2;
+ CrossFadedDataDrivenProperty2.prototype.possiblyEvaluate = function possiblyEvaluate(value, parameters, canonical, availableImages) {
+ if (value.value === void 0) {
+ return new PossiblyEvaluatedPropertyValue(this, {
+ kind: "constant",
+ value: void 0
+ }, parameters);
+ } else if (value.expression.kind === "constant") {
+ var evaluatedValue = value.expression.evaluate(parameters, null, {}, canonical, availableImages);
+ var isImageExpression = value.property.specification.type === "resolvedImage";
+ var constantValue = isImageExpression && typeof evaluatedValue !== "string" ? evaluatedValue.name : evaluatedValue;
+ var constant = this._calculate(constantValue, constantValue, constantValue, parameters);
+ return new PossiblyEvaluatedPropertyValue(this, {
+ kind: "constant",
+ value: constant
+ }, parameters);
+ } else if (value.expression.kind === "camera") {
+ var cameraVal = this._calculate(value.expression.evaluate({ zoom: parameters.zoom - 1 }), value.expression.evaluate({ zoom: parameters.zoom }), value.expression.evaluate({ zoom: parameters.zoom + 1 }), parameters);
+ return new PossiblyEvaluatedPropertyValue(this, {
+ kind: "constant",
+ value: cameraVal
+ }, parameters);
+ } else {
+ return new PossiblyEvaluatedPropertyValue(this, value.expression, parameters);
+ }
+ };
+ CrossFadedDataDrivenProperty2.prototype.evaluate = function evaluate(value, globals, feature, featureState, canonical, availableImages) {
+ if (value.kind === "source") {
+ var constant = value.evaluate(globals, feature, featureState, canonical, availableImages);
+ return this._calculate(constant, constant, constant, globals);
+ } else if (value.kind === "composite") {
+ return this._calculate(value.evaluate({ zoom: Math.floor(globals.zoom) - 1 }, feature, featureState), value.evaluate({ zoom: Math.floor(globals.zoom) }, feature, featureState), value.evaluate({ zoom: Math.floor(globals.zoom) + 1 }, feature, featureState), globals);
+ } else {
+ return value.value;
+ }
+ };
+ CrossFadedDataDrivenProperty2.prototype._calculate = function _calculate(min, mid, max, parameters) {
+ var z = parameters.zoom;
+ return z > parameters.zoomHistory.lastIntegerZoom ? {
+ from: min,
+ to: mid
+ } : {
+ from: max,
+ to: mid
+ };
+ };
+ CrossFadedDataDrivenProperty2.prototype.interpolate = function interpolate2(a) {
+ return a;
+ };
+ return CrossFadedDataDrivenProperty2;
+ }(DataDrivenProperty);
+ var CrossFadedProperty = function CrossFadedProperty2(specification) {
+ this.specification = specification;
+ };
+ CrossFadedProperty.prototype.possiblyEvaluate = function possiblyEvaluate(value, parameters, canonical, availableImages) {
+ if (value.value === void 0) {
+ return void 0;
+ } else if (value.expression.kind === "constant") {
+ var constant = value.expression.evaluate(parameters, null, {}, canonical, availableImages);
+ return this._calculate(constant, constant, constant, parameters);
+ } else {
+ return this._calculate(value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom - 1), parameters)), value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom), parameters)), value.expression.evaluate(new EvaluationParameters(Math.floor(parameters.zoom + 1), parameters)), parameters);
+ }
+ };
+ CrossFadedProperty.prototype._calculate = function _calculate(min, mid, max, parameters) {
+ var z = parameters.zoom;
+ return z > parameters.zoomHistory.lastIntegerZoom ? {
+ from: min,
+ to: mid
+ } : {
+ from: max,
+ to: mid
+ };
+ };
+ CrossFadedProperty.prototype.interpolate = function interpolate2(a) {
+ return a;
+ };
+ var ColorRampProperty = function ColorRampProperty2(specification) {
+ this.specification = specification;
+ };
+ ColorRampProperty.prototype.possiblyEvaluate = function possiblyEvaluate(value, parameters, canonical, availableImages) {
+ return !!value.expression.evaluate(parameters, null, {}, canonical, availableImages);
+ };
+ ColorRampProperty.prototype.interpolate = function interpolate2() {
+ return false;
+ };
+ var Properties = function Properties2(properties2) {
+ this.properties = properties2;
+ this.defaultPropertyValues = {};
+ this.defaultTransitionablePropertyValues = {};
+ this.defaultTransitioningPropertyValues = {};
+ this.defaultPossiblyEvaluatedValues = {};
+ this.overridableProperties = [];
+ for (var property in properties2) {
+ var prop = properties2[property];
+ if (prop.specification.overridable) {
+ this.overridableProperties.push(property);
+ }
+ var defaultPropertyValue = this.defaultPropertyValues[property] = new PropertyValue(prop, void 0);
+ var defaultTransitionablePropertyValue = this.defaultTransitionablePropertyValues[property] = new TransitionablePropertyValue(prop);
+ this.defaultTransitioningPropertyValues[property] = defaultTransitionablePropertyValue.untransitioned();
+ this.defaultPossiblyEvaluatedValues[property] = defaultPropertyValue.possiblyEvaluate({});
+ }
+ };
+ register("DataDrivenProperty", DataDrivenProperty);
+ register("DataConstantProperty", DataConstantProperty);
+ register("CrossFadedDataDrivenProperty", CrossFadedDataDrivenProperty);
+ register("CrossFadedProperty", CrossFadedProperty);
+ register("ColorRampProperty", ColorRampProperty);
+ var TRANSITION_SUFFIX = "-transition";
+ var StyleLayer = function(Evented2) {
+ function StyleLayer2(layer2, properties2) {
+ Evented2.call(this);
+ this.id = layer2.id;
+ this.type = layer2.type;
+ this._featureFilter = {
+ filter: function() {
+ return true;
+ },
+ needGeometry: false
+ };
+ if (layer2.type === "custom") {
+ return;
+ }
+ layer2 = layer2;
+ this.metadata = layer2.metadata;
+ this.minzoom = layer2.minzoom;
+ this.maxzoom = layer2.maxzoom;
+ if (layer2.type !== "background") {
+ this.source = layer2.source;
+ this.sourceLayer = layer2["source-layer"];
+ this.filter = layer2.filter;
+ }
+ if (properties2.layout) {
+ this._unevaluatedLayout = new Layout(properties2.layout);
+ }
+ if (properties2.paint) {
+ this._transitionablePaint = new Transitionable(properties2.paint);
+ for (var property in layer2.paint) {
+ this.setPaintProperty(property, layer2.paint[property], { validate: false });
+ }
+ for (var property$1 in layer2.layout) {
+ this.setLayoutProperty(property$1, layer2.layout[property$1], { validate: false });
+ }
+ this._transitioningPaint = this._transitionablePaint.untransitioned();
+ this.paint = new PossiblyEvaluated(properties2.paint);
+ }
+ }
+ if (Evented2)
+ StyleLayer2.__proto__ = Evented2;
+ StyleLayer2.prototype = Object.create(Evented2 && Evented2.prototype);
+ StyleLayer2.prototype.constructor = StyleLayer2;
+ StyleLayer2.prototype.getCrossfadeParameters = function getCrossfadeParameters() {
+ return this._crossfadeParameters;
+ };
+ StyleLayer2.prototype.getLayoutProperty = function getLayoutProperty(name3) {
+ if (name3 === "visibility") {
+ return this.visibility;
+ }
+ return this._unevaluatedLayout.getValue(name3);
+ };
+ StyleLayer2.prototype.setLayoutProperty = function setLayoutProperty(name3, value, options) {
+ if (options === void 0)
+ options = {};
+ if (value !== null && value !== void 0) {
+ var key = "layers." + this.id + ".layout." + name3;
+ if (this._validate(validateLayoutProperty$1, key, name3, value, options)) {
+ return;
+ }
+ }
+ if (name3 === "visibility") {
+ this.visibility = value;
+ return;
+ }
+ this._unevaluatedLayout.setValue(name3, value);
+ };
+ StyleLayer2.prototype.getPaintProperty = function getPaintProperty(name3) {
+ if (endsWith(name3, TRANSITION_SUFFIX)) {
+ return this._transitionablePaint.getTransition(name3.slice(0, -TRANSITION_SUFFIX.length));
+ } else {
+ return this._transitionablePaint.getValue(name3);
+ }
+ };
+ StyleLayer2.prototype.setPaintProperty = function setPaintProperty(name3, value, options) {
+ if (options === void 0)
+ options = {};
+ if (value !== null && value !== void 0) {
+ var key = "layers." + this.id + ".paint." + name3;
+ if (this._validate(validatePaintProperty$1, key, name3, value, options)) {
+ return false;
+ }
+ }
+ if (endsWith(name3, TRANSITION_SUFFIX)) {
+ this._transitionablePaint.setTransition(name3.slice(0, -TRANSITION_SUFFIX.length), value || void 0);
+ return false;
+ } else {
+ var transitionable = this._transitionablePaint._values[name3];
+ var isCrossFadedProperty = transitionable.property.specification["property-type"] === "cross-faded-data-driven";
+ var wasDataDriven = transitionable.value.isDataDriven();
+ var oldValue = transitionable.value;
+ this._transitionablePaint.setValue(name3, value);
+ this._handleSpecialPaintPropertyUpdate(name3);
+ var newValue = this._transitionablePaint._values[name3].value;
+ var isDataDriven = newValue.isDataDriven();
+ return isDataDriven || wasDataDriven || isCrossFadedProperty || this._handleOverridablePaintPropertyUpdate(name3, oldValue, newValue);
+ }
+ };
+ StyleLayer2.prototype._handleSpecialPaintPropertyUpdate = function _handleSpecialPaintPropertyUpdate(_) {
+ };
+ StyleLayer2.prototype._handleOverridablePaintPropertyUpdate = function _handleOverridablePaintPropertyUpdate(name3, oldValue, newValue) {
+ return false;
+ };
+ StyleLayer2.prototype.isHidden = function isHidden(zoom) {
+ if (this.minzoom && zoom < this.minzoom) {
+ return true;
+ }
+ if (this.maxzoom && zoom >= this.maxzoom) {
+ return true;
+ }
+ return this.visibility === "none";
+ };
+ StyleLayer2.prototype.updateTransitions = function updateTransitions(parameters) {
+ this._transitioningPaint = this._transitionablePaint.transitioned(parameters, this._transitioningPaint);
+ };
+ StyleLayer2.prototype.hasTransition = function hasTransition() {
+ return this._transitioningPaint.hasTransition();
+ };
+ StyleLayer2.prototype.recalculate = function recalculate(parameters, availableImages) {
+ if (parameters.getCrossfadeParameters) {
+ this._crossfadeParameters = parameters.getCrossfadeParameters();
+ }
+ if (this._unevaluatedLayout) {
+ this.layout = this._unevaluatedLayout.possiblyEvaluate(parameters, void 0, availableImages);
+ }
+ this.paint = this._transitioningPaint.possiblyEvaluate(parameters, void 0, availableImages);
+ };
+ StyleLayer2.prototype.serialize = function serialize2() {
+ var output = {
+ "id": this.id,
+ "type": this.type,
+ "source": this.source,
+ "source-layer": this.sourceLayer,
+ "metadata": this.metadata,
+ "minzoom": this.minzoom,
+ "maxzoom": this.maxzoom,
+ "filter": this.filter,
+ "layout": this._unevaluatedLayout && this._unevaluatedLayout.serialize(),
+ "paint": this._transitionablePaint && this._transitionablePaint.serialize()
+ };
+ if (this.visibility) {
+ output.layout = output.layout || {};
+ output.layout.visibility = this.visibility;
+ }
+ return filterObject(output, function(value, key) {
+ return value !== void 0 && !(key === "layout" && !Object.keys(value).length) && !(key === "paint" && !Object.keys(value).length);
+ });
+ };
+ StyleLayer2.prototype._validate = function _validate(validate2, key, name3, value, options) {
+ if (options === void 0)
+ options = {};
+ if (options && options.validate === false) {
+ return false;
+ }
+ return emitValidationErrors(this, validate2.call(validateStyle, {
+ key,
+ layerType: this.type,
+ objectKey: name3,
+ value,
+ styleSpec: spec,
+ style: {
+ glyphs: true,
+ sprite: true
+ }
+ }));
+ };
+ StyleLayer2.prototype.is3D = function is3D() {
+ return false;
+ };
+ StyleLayer2.prototype.isTileClipped = function isTileClipped() {
+ return false;
+ };
+ StyleLayer2.prototype.hasOffscreenPass = function hasOffscreenPass() {
+ return false;
+ };
+ StyleLayer2.prototype.resize = function resize() {
+ };
+ StyleLayer2.prototype.isStateDependent = function isStateDependent() {
+ for (var property in this.paint._values) {
+ var value = this.paint.get(property);
+ if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {
+ continue;
+ }
+ if ((value.value.kind === "source" || value.value.kind === "composite") && value.value.isStateDependent) {
+ return true;
+ }
+ }
+ return false;
+ };
+ return StyleLayer2;
+ }(Evented);
+ var viewTypes = {
+ "Int8": Int8Array,
+ "Uint8": Uint8Array,
+ "Int16": Int16Array,
+ "Uint16": Uint16Array,
+ "Int32": Int32Array,
+ "Uint32": Uint32Array,
+ "Float32": Float32Array
+ };
+ var Struct = function Struct2(structArray, index) {
+ this._structArray = structArray;
+ this._pos1 = index * this.size;
+ this._pos2 = this._pos1 / 2;
+ this._pos4 = this._pos1 / 4;
+ this._pos8 = this._pos1 / 8;
+ };
+ var DEFAULT_CAPACITY = 128;
+ var RESIZE_MULTIPLIER = 5;
+ var StructArray = function StructArray2() {
+ this.isTransferred = false;
+ this.capacity = -1;
+ this.resize(0);
+ };
+ StructArray.serialize = function serialize2(array2, transferables) {
+ array2._trim();
+ if (transferables) {
+ array2.isTransferred = true;
+ transferables.push(array2.arrayBuffer);
+ }
+ return {
+ length: array2.length,
+ arrayBuffer: array2.arrayBuffer
+ };
+ };
+ StructArray.deserialize = function deserialize2(input) {
+ var structArray = Object.create(this.prototype);
+ structArray.arrayBuffer = input.arrayBuffer;
+ structArray.length = input.length;
+ structArray.capacity = input.arrayBuffer.byteLength / structArray.bytesPerElement;
+ structArray._refreshViews();
+ return structArray;
+ };
+ StructArray.prototype._trim = function _trim() {
+ if (this.length !== this.capacity) {
+ this.capacity = this.length;
+ this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement);
+ this._refreshViews();
+ }
+ };
+ StructArray.prototype.clear = function clear() {
+ this.length = 0;
+ };
+ StructArray.prototype.resize = function resize(n) {
+ this.reserve(n);
+ this.length = n;
+ };
+ StructArray.prototype.reserve = function reserve(n) {
+ if (n > this.capacity) {
+ this.capacity = Math.max(n, Math.floor(this.capacity * RESIZE_MULTIPLIER), DEFAULT_CAPACITY);
+ this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement);
+ var oldUint8Array = this.uint8;
+ this._refreshViews();
+ if (oldUint8Array) {
+ this.uint8.set(oldUint8Array);
+ }
+ }
+ };
+ StructArray.prototype._refreshViews = function _refreshViews() {
+ throw new Error("_refreshViews() must be implemented by each concrete StructArray layout");
+ };
+ function createLayout(members2, alignment) {
+ if (alignment === void 0)
+ alignment = 1;
+ var offset = 0;
+ var maxSize = 0;
+ var layoutMembers = members2.map(function(member) {
+ var typeSize = sizeOf(member.type);
+ var memberOffset = offset = align(offset, Math.max(alignment, typeSize));
+ var components = member.components || 1;
+ maxSize = Math.max(maxSize, typeSize);
+ offset += typeSize * components;
+ return {
+ name: member.name,
+ type: member.type,
+ components,
+ offset: memberOffset
+ };
+ });
+ var size = align(offset, Math.max(maxSize, alignment));
+ return {
+ members: layoutMembers,
+ size,
+ alignment
+ };
+ }
+ function sizeOf(type) {
+ return viewTypes[type].BYTES_PER_ELEMENT;
+ }
+ function align(offset, size) {
+ return Math.ceil(offset / size) * size;
+ }
+ var StructArrayLayout2i4 = function(StructArray2) {
+ function StructArrayLayout2i42() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout2i42.__proto__ = StructArray2;
+ StructArrayLayout2i42.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout2i42.prototype.constructor = StructArrayLayout2i42;
+ StructArrayLayout2i42.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ };
+ StructArrayLayout2i42.prototype.emplaceBack = function emplaceBack(v0, v1) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1);
+ };
+ StructArrayLayout2i42.prototype.emplace = function emplace(i, v0, v1) {
+ var o2 = i * 2;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ return i;
+ };
+ return StructArrayLayout2i42;
+ }(StructArray);
+ StructArrayLayout2i4.prototype.bytesPerElement = 4;
+ register("StructArrayLayout2i4", StructArrayLayout2i4);
+ var StructArrayLayout4i8 = function(StructArray2) {
+ function StructArrayLayout4i82() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout4i82.__proto__ = StructArray2;
+ StructArrayLayout4i82.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout4i82.prototype.constructor = StructArrayLayout4i82;
+ StructArrayLayout4i82.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ };
+ StructArrayLayout4i82.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3);
+ };
+ StructArrayLayout4i82.prototype.emplace = function emplace(i, v0, v1, v2, v3) {
+ var o2 = i * 4;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ this.int16[o2 + 2] = v2;
+ this.int16[o2 + 3] = v3;
+ return i;
+ };
+ return StructArrayLayout4i82;
+ }(StructArray);
+ StructArrayLayout4i8.prototype.bytesPerElement = 8;
+ register("StructArrayLayout4i8", StructArrayLayout4i8);
+ var StructArrayLayout2i4i12 = function(StructArray2) {
+ function StructArrayLayout2i4i122() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout2i4i122.__proto__ = StructArray2;
+ StructArrayLayout2i4i122.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout2i4i122.prototype.constructor = StructArrayLayout2i4i122;
+ StructArrayLayout2i4i122.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ };
+ StructArrayLayout2i4i122.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3, v4, v5) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3, v4, v5);
+ };
+ StructArrayLayout2i4i122.prototype.emplace = function emplace(i, v0, v1, v2, v3, v4, v5) {
+ var o2 = i * 6;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ this.int16[o2 + 2] = v2;
+ this.int16[o2 + 3] = v3;
+ this.int16[o2 + 4] = v4;
+ this.int16[o2 + 5] = v5;
+ return i;
+ };
+ return StructArrayLayout2i4i122;
+ }(StructArray);
+ StructArrayLayout2i4i12.prototype.bytesPerElement = 12;
+ register("StructArrayLayout2i4i12", StructArrayLayout2i4i12);
+ var StructArrayLayout2i4ub8 = function(StructArray2) {
+ function StructArrayLayout2i4ub82() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout2i4ub82.__proto__ = StructArray2;
+ StructArrayLayout2i4ub82.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout2i4ub82.prototype.constructor = StructArrayLayout2i4ub82;
+ StructArrayLayout2i4ub82.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ };
+ StructArrayLayout2i4ub82.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3, v4, v5) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3, v4, v5);
+ };
+ StructArrayLayout2i4ub82.prototype.emplace = function emplace(i, v0, v1, v2, v3, v4, v5) {
+ var o2 = i * 4;
+ var o1 = i * 8;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ this.uint8[o1 + 4] = v2;
+ this.uint8[o1 + 5] = v3;
+ this.uint8[o1 + 6] = v4;
+ this.uint8[o1 + 7] = v5;
+ return i;
+ };
+ return StructArrayLayout2i4ub82;
+ }(StructArray);
+ StructArrayLayout2i4ub8.prototype.bytesPerElement = 8;
+ register("StructArrayLayout2i4ub8", StructArrayLayout2i4ub8);
+ var StructArrayLayout2f8 = function(StructArray2) {
+ function StructArrayLayout2f82() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout2f82.__proto__ = StructArray2;
+ StructArrayLayout2f82.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout2f82.prototype.constructor = StructArrayLayout2f82;
+ StructArrayLayout2f82.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.float32 = new Float32Array(this.arrayBuffer);
+ };
+ StructArrayLayout2f82.prototype.emplaceBack = function emplaceBack(v0, v1) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1);
+ };
+ StructArrayLayout2f82.prototype.emplace = function emplace(i, v0, v1) {
+ var o4 = i * 2;
+ this.float32[o4 + 0] = v0;
+ this.float32[o4 + 1] = v1;
+ return i;
+ };
+ return StructArrayLayout2f82;
+ }(StructArray);
+ StructArrayLayout2f8.prototype.bytesPerElement = 8;
+ register("StructArrayLayout2f8", StructArrayLayout2f8);
+ var StructArrayLayout10ui20 = function(StructArray2) {
+ function StructArrayLayout10ui202() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout10ui202.__proto__ = StructArray2;
+ StructArrayLayout10ui202.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout10ui202.prototype.constructor = StructArrayLayout10ui202;
+ StructArrayLayout10ui202.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.uint16 = new Uint16Array(this.arrayBuffer);
+ };
+ StructArrayLayout10ui202.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
+ };
+ StructArrayLayout10ui202.prototype.emplace = function emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
+ var o2 = i * 10;
+ this.uint16[o2 + 0] = v0;
+ this.uint16[o2 + 1] = v1;
+ this.uint16[o2 + 2] = v2;
+ this.uint16[o2 + 3] = v3;
+ this.uint16[o2 + 4] = v4;
+ this.uint16[o2 + 5] = v5;
+ this.uint16[o2 + 6] = v6;
+ this.uint16[o2 + 7] = v7;
+ this.uint16[o2 + 8] = v8;
+ this.uint16[o2 + 9] = v9;
+ return i;
+ };
+ return StructArrayLayout10ui202;
+ }(StructArray);
+ StructArrayLayout10ui20.prototype.bytesPerElement = 20;
+ register("StructArrayLayout10ui20", StructArrayLayout10ui20);
+ var StructArrayLayout4i4ui4i24 = function(StructArray2) {
+ function StructArrayLayout4i4ui4i242() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout4i4ui4i242.__proto__ = StructArray2;
+ StructArrayLayout4i4ui4i242.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout4i4ui4i242.prototype.constructor = StructArrayLayout4i4ui4i242;
+ StructArrayLayout4i4ui4i242.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ this.uint16 = new Uint16Array(this.arrayBuffer);
+ };
+ StructArrayLayout4i4ui4i242.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);
+ };
+ StructArrayLayout4i4ui4i242.prototype.emplace = function emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) {
+ var o2 = i * 12;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ this.int16[o2 + 2] = v2;
+ this.int16[o2 + 3] = v3;
+ this.uint16[o2 + 4] = v4;
+ this.uint16[o2 + 5] = v5;
+ this.uint16[o2 + 6] = v6;
+ this.uint16[o2 + 7] = v7;
+ this.int16[o2 + 8] = v8;
+ this.int16[o2 + 9] = v9;
+ this.int16[o2 + 10] = v10;
+ this.int16[o2 + 11] = v11;
+ return i;
+ };
+ return StructArrayLayout4i4ui4i242;
+ }(StructArray);
+ StructArrayLayout4i4ui4i24.prototype.bytesPerElement = 24;
+ register("StructArrayLayout4i4ui4i24", StructArrayLayout4i4ui4i24);
+ var StructArrayLayout3f12 = function(StructArray2) {
+ function StructArrayLayout3f122() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout3f122.__proto__ = StructArray2;
+ StructArrayLayout3f122.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout3f122.prototype.constructor = StructArrayLayout3f122;
+ StructArrayLayout3f122.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.float32 = new Float32Array(this.arrayBuffer);
+ };
+ StructArrayLayout3f122.prototype.emplaceBack = function emplaceBack(v0, v1, v2) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2);
+ };
+ StructArrayLayout3f122.prototype.emplace = function emplace(i, v0, v1, v2) {
+ var o4 = i * 3;
+ this.float32[o4 + 0] = v0;
+ this.float32[o4 + 1] = v1;
+ this.float32[o4 + 2] = v2;
+ return i;
+ };
+ return StructArrayLayout3f122;
+ }(StructArray);
+ StructArrayLayout3f12.prototype.bytesPerElement = 12;
+ register("StructArrayLayout3f12", StructArrayLayout3f12);
+ var StructArrayLayout1ul4 = function(StructArray2) {
+ function StructArrayLayout1ul42() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout1ul42.__proto__ = StructArray2;
+ StructArrayLayout1ul42.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout1ul42.prototype.constructor = StructArrayLayout1ul42;
+ StructArrayLayout1ul42.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.uint32 = new Uint32Array(this.arrayBuffer);
+ };
+ StructArrayLayout1ul42.prototype.emplaceBack = function emplaceBack(v0) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0);
+ };
+ StructArrayLayout1ul42.prototype.emplace = function emplace(i, v0) {
+ var o4 = i * 1;
+ this.uint32[o4 + 0] = v0;
+ return i;
+ };
+ return StructArrayLayout1ul42;
+ }(StructArray);
+ StructArrayLayout1ul4.prototype.bytesPerElement = 4;
+ register("StructArrayLayout1ul4", StructArrayLayout1ul4);
+ var StructArrayLayout6i1ul2ui20 = function(StructArray2) {
+ function StructArrayLayout6i1ul2ui202() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout6i1ul2ui202.__proto__ = StructArray2;
+ StructArrayLayout6i1ul2ui202.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout6i1ul2ui202.prototype.constructor = StructArrayLayout6i1ul2ui202;
+ StructArrayLayout6i1ul2ui202.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ this.uint32 = new Uint32Array(this.arrayBuffer);
+ this.uint16 = new Uint16Array(this.arrayBuffer);
+ };
+ StructArrayLayout6i1ul2ui202.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8);
+ };
+ StructArrayLayout6i1ul2ui202.prototype.emplace = function emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8) {
+ var o2 = i * 10;
+ var o4 = i * 5;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ this.int16[o2 + 2] = v2;
+ this.int16[o2 + 3] = v3;
+ this.int16[o2 + 4] = v4;
+ this.int16[o2 + 5] = v5;
+ this.uint32[o4 + 3] = v6;
+ this.uint16[o2 + 8] = v7;
+ this.uint16[o2 + 9] = v8;
+ return i;
+ };
+ return StructArrayLayout6i1ul2ui202;
+ }(StructArray);
+ StructArrayLayout6i1ul2ui20.prototype.bytesPerElement = 20;
+ register("StructArrayLayout6i1ul2ui20", StructArrayLayout6i1ul2ui20);
+ var StructArrayLayout2i2i2i12 = function(StructArray2) {
+ function StructArrayLayout2i2i2i122() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout2i2i2i122.__proto__ = StructArray2;
+ StructArrayLayout2i2i2i122.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout2i2i2i122.prototype.constructor = StructArrayLayout2i2i2i122;
+ StructArrayLayout2i2i2i122.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ };
+ StructArrayLayout2i2i2i122.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3, v4, v5) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3, v4, v5);
+ };
+ StructArrayLayout2i2i2i122.prototype.emplace = function emplace(i, v0, v1, v2, v3, v4, v5) {
+ var o2 = i * 6;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ this.int16[o2 + 2] = v2;
+ this.int16[o2 + 3] = v3;
+ this.int16[o2 + 4] = v4;
+ this.int16[o2 + 5] = v5;
+ return i;
+ };
+ return StructArrayLayout2i2i2i122;
+ }(StructArray);
+ StructArrayLayout2i2i2i12.prototype.bytesPerElement = 12;
+ register("StructArrayLayout2i2i2i12", StructArrayLayout2i2i2i12);
+ var StructArrayLayout2f1f2i16 = function(StructArray2) {
+ function StructArrayLayout2f1f2i162() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout2f1f2i162.__proto__ = StructArray2;
+ StructArrayLayout2f1f2i162.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout2f1f2i162.prototype.constructor = StructArrayLayout2f1f2i162;
+ StructArrayLayout2f1f2i162.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.float32 = new Float32Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ };
+ StructArrayLayout2f1f2i162.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3, v4) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3, v4);
+ };
+ StructArrayLayout2f1f2i162.prototype.emplace = function emplace(i, v0, v1, v2, v3, v4) {
+ var o4 = i * 4;
+ var o2 = i * 8;
+ this.float32[o4 + 0] = v0;
+ this.float32[o4 + 1] = v1;
+ this.float32[o4 + 2] = v2;
+ this.int16[o2 + 6] = v3;
+ this.int16[o2 + 7] = v4;
+ return i;
+ };
+ return StructArrayLayout2f1f2i162;
+ }(StructArray);
+ StructArrayLayout2f1f2i16.prototype.bytesPerElement = 16;
+ register("StructArrayLayout2f1f2i16", StructArrayLayout2f1f2i16);
+ var StructArrayLayout2ub2f12 = function(StructArray2) {
+ function StructArrayLayout2ub2f122() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout2ub2f122.__proto__ = StructArray2;
+ StructArrayLayout2ub2f122.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout2ub2f122.prototype.constructor = StructArrayLayout2ub2f122;
+ StructArrayLayout2ub2f122.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.float32 = new Float32Array(this.arrayBuffer);
+ };
+ StructArrayLayout2ub2f122.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3);
+ };
+ StructArrayLayout2ub2f122.prototype.emplace = function emplace(i, v0, v1, v2, v3) {
+ var o1 = i * 12;
+ var o4 = i * 3;
+ this.uint8[o1 + 0] = v0;
+ this.uint8[o1 + 1] = v1;
+ this.float32[o4 + 1] = v2;
+ this.float32[o4 + 2] = v3;
+ return i;
+ };
+ return StructArrayLayout2ub2f122;
+ }(StructArray);
+ StructArrayLayout2ub2f12.prototype.bytesPerElement = 12;
+ register("StructArrayLayout2ub2f12", StructArrayLayout2ub2f12);
+ var StructArrayLayout3ui6 = function(StructArray2) {
+ function StructArrayLayout3ui62() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout3ui62.__proto__ = StructArray2;
+ StructArrayLayout3ui62.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout3ui62.prototype.constructor = StructArrayLayout3ui62;
+ StructArrayLayout3ui62.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.uint16 = new Uint16Array(this.arrayBuffer);
+ };
+ StructArrayLayout3ui62.prototype.emplaceBack = function emplaceBack(v0, v1, v2) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2);
+ };
+ StructArrayLayout3ui62.prototype.emplace = function emplace(i, v0, v1, v2) {
+ var o2 = i * 3;
+ this.uint16[o2 + 0] = v0;
+ this.uint16[o2 + 1] = v1;
+ this.uint16[o2 + 2] = v2;
+ return i;
+ };
+ return StructArrayLayout3ui62;
+ }(StructArray);
+ StructArrayLayout3ui6.prototype.bytesPerElement = 6;
+ register("StructArrayLayout3ui6", StructArrayLayout3ui6);
+ var StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 = function(StructArray2) {
+ function StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482.__proto__ = StructArray2;
+ StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482.prototype.constructor = StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482;
+ StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ this.uint16 = new Uint16Array(this.arrayBuffer);
+ this.uint32 = new Uint32Array(this.arrayBuffer);
+ this.float32 = new Float32Array(this.arrayBuffer);
+ };
+ StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16);
+ };
+ StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482.prototype.emplace = function emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) {
+ var o2 = i * 24;
+ var o4 = i * 12;
+ var o1 = i * 48;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ this.uint16[o2 + 2] = v2;
+ this.uint16[o2 + 3] = v3;
+ this.uint32[o4 + 2] = v4;
+ this.uint32[o4 + 3] = v5;
+ this.uint32[o4 + 4] = v6;
+ this.uint16[o2 + 10] = v7;
+ this.uint16[o2 + 11] = v8;
+ this.uint16[o2 + 12] = v9;
+ this.float32[o4 + 7] = v10;
+ this.float32[o4 + 8] = v11;
+ this.uint8[o1 + 36] = v12;
+ this.uint8[o1 + 37] = v13;
+ this.uint8[o1 + 38] = v14;
+ this.uint32[o4 + 10] = v15;
+ this.int16[o2 + 22] = v16;
+ return i;
+ };
+ return StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482;
+ }(StructArray);
+ StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48.prototype.bytesPerElement = 48;
+ register("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48", StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48);
+ var StructArrayLayout8i15ui1ul4f68 = function(StructArray2) {
+ function StructArrayLayout8i15ui1ul4f682() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout8i15ui1ul4f682.__proto__ = StructArray2;
+ StructArrayLayout8i15ui1ul4f682.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout8i15ui1ul4f682.prototype.constructor = StructArrayLayout8i15ui1ul4f682;
+ StructArrayLayout8i15ui1ul4f682.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ this.uint16 = new Uint16Array(this.arrayBuffer);
+ this.uint32 = new Uint32Array(this.arrayBuffer);
+ this.float32 = new Float32Array(this.arrayBuffer);
+ };
+ StructArrayLayout8i15ui1ul4f682.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);
+ };
+ StructArrayLayout8i15ui1ul4f682.prototype.emplace = function emplace(i, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) {
+ var o2 = i * 34;
+ var o4 = i * 17;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ this.int16[o2 + 2] = v2;
+ this.int16[o2 + 3] = v3;
+ this.int16[o2 + 4] = v4;
+ this.int16[o2 + 5] = v5;
+ this.int16[o2 + 6] = v6;
+ this.int16[o2 + 7] = v7;
+ this.uint16[o2 + 8] = v8;
+ this.uint16[o2 + 9] = v9;
+ this.uint16[o2 + 10] = v10;
+ this.uint16[o2 + 11] = v11;
+ this.uint16[o2 + 12] = v12;
+ this.uint16[o2 + 13] = v13;
+ this.uint16[o2 + 14] = v14;
+ this.uint16[o2 + 15] = v15;
+ this.uint16[o2 + 16] = v16;
+ this.uint16[o2 + 17] = v17;
+ this.uint16[o2 + 18] = v18;
+ this.uint16[o2 + 19] = v19;
+ this.uint16[o2 + 20] = v20;
+ this.uint16[o2 + 21] = v21;
+ this.uint16[o2 + 22] = v22;
+ this.uint32[o4 + 12] = v23;
+ this.float32[o4 + 13] = v24;
+ this.float32[o4 + 14] = v25;
+ this.float32[o4 + 15] = v26;
+ this.float32[o4 + 16] = v27;
+ return i;
+ };
+ return StructArrayLayout8i15ui1ul4f682;
+ }(StructArray);
+ StructArrayLayout8i15ui1ul4f68.prototype.bytesPerElement = 68;
+ register("StructArrayLayout8i15ui1ul4f68", StructArrayLayout8i15ui1ul4f68);
+ var StructArrayLayout1f4 = function(StructArray2) {
+ function StructArrayLayout1f42() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout1f42.__proto__ = StructArray2;
+ StructArrayLayout1f42.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout1f42.prototype.constructor = StructArrayLayout1f42;
+ StructArrayLayout1f42.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.float32 = new Float32Array(this.arrayBuffer);
+ };
+ StructArrayLayout1f42.prototype.emplaceBack = function emplaceBack(v0) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0);
+ };
+ StructArrayLayout1f42.prototype.emplace = function emplace(i, v0) {
+ var o4 = i * 1;
+ this.float32[o4 + 0] = v0;
+ return i;
+ };
+ return StructArrayLayout1f42;
+ }(StructArray);
+ StructArrayLayout1f4.prototype.bytesPerElement = 4;
+ register("StructArrayLayout1f4", StructArrayLayout1f4);
+ var StructArrayLayout3i6 = function(StructArray2) {
+ function StructArrayLayout3i62() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout3i62.__proto__ = StructArray2;
+ StructArrayLayout3i62.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout3i62.prototype.constructor = StructArrayLayout3i62;
+ StructArrayLayout3i62.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.int16 = new Int16Array(this.arrayBuffer);
+ };
+ StructArrayLayout3i62.prototype.emplaceBack = function emplaceBack(v0, v1, v2) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2);
+ };
+ StructArrayLayout3i62.prototype.emplace = function emplace(i, v0, v1, v2) {
+ var o2 = i * 3;
+ this.int16[o2 + 0] = v0;
+ this.int16[o2 + 1] = v1;
+ this.int16[o2 + 2] = v2;
+ return i;
+ };
+ return StructArrayLayout3i62;
+ }(StructArray);
+ StructArrayLayout3i6.prototype.bytesPerElement = 6;
+ register("StructArrayLayout3i6", StructArrayLayout3i6);
+ var StructArrayLayout1ul2ui8 = function(StructArray2) {
+ function StructArrayLayout1ul2ui82() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout1ul2ui82.__proto__ = StructArray2;
+ StructArrayLayout1ul2ui82.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout1ul2ui82.prototype.constructor = StructArrayLayout1ul2ui82;
+ StructArrayLayout1ul2ui82.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.uint32 = new Uint32Array(this.arrayBuffer);
+ this.uint16 = new Uint16Array(this.arrayBuffer);
+ };
+ StructArrayLayout1ul2ui82.prototype.emplaceBack = function emplaceBack(v0, v1, v2) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2);
+ };
+ StructArrayLayout1ul2ui82.prototype.emplace = function emplace(i, v0, v1, v2) {
+ var o4 = i * 2;
+ var o2 = i * 4;
+ this.uint32[o4 + 0] = v0;
+ this.uint16[o2 + 2] = v1;
+ this.uint16[o2 + 3] = v2;
+ return i;
+ };
+ return StructArrayLayout1ul2ui82;
+ }(StructArray);
+ StructArrayLayout1ul2ui8.prototype.bytesPerElement = 8;
+ register("StructArrayLayout1ul2ui8", StructArrayLayout1ul2ui8);
+ var StructArrayLayout2ui4 = function(StructArray2) {
+ function StructArrayLayout2ui42() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout2ui42.__proto__ = StructArray2;
+ StructArrayLayout2ui42.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout2ui42.prototype.constructor = StructArrayLayout2ui42;
+ StructArrayLayout2ui42.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.uint16 = new Uint16Array(this.arrayBuffer);
+ };
+ StructArrayLayout2ui42.prototype.emplaceBack = function emplaceBack(v0, v1) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1);
+ };
+ StructArrayLayout2ui42.prototype.emplace = function emplace(i, v0, v1) {
+ var o2 = i * 2;
+ this.uint16[o2 + 0] = v0;
+ this.uint16[o2 + 1] = v1;
+ return i;
+ };
+ return StructArrayLayout2ui42;
+ }(StructArray);
+ StructArrayLayout2ui4.prototype.bytesPerElement = 4;
+ register("StructArrayLayout2ui4", StructArrayLayout2ui4);
+ var StructArrayLayout1ui2 = function(StructArray2) {
+ function StructArrayLayout1ui22() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout1ui22.__proto__ = StructArray2;
+ StructArrayLayout1ui22.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout1ui22.prototype.constructor = StructArrayLayout1ui22;
+ StructArrayLayout1ui22.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.uint16 = new Uint16Array(this.arrayBuffer);
+ };
+ StructArrayLayout1ui22.prototype.emplaceBack = function emplaceBack(v0) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0);
+ };
+ StructArrayLayout1ui22.prototype.emplace = function emplace(i, v0) {
+ var o2 = i * 1;
+ this.uint16[o2 + 0] = v0;
+ return i;
+ };
+ return StructArrayLayout1ui22;
+ }(StructArray);
+ StructArrayLayout1ui2.prototype.bytesPerElement = 2;
+ register("StructArrayLayout1ui2", StructArrayLayout1ui2);
+ var StructArrayLayout4f16 = function(StructArray2) {
+ function StructArrayLayout4f162() {
+ StructArray2.apply(this, arguments);
+ }
+ if (StructArray2)
+ StructArrayLayout4f162.__proto__ = StructArray2;
+ StructArrayLayout4f162.prototype = Object.create(StructArray2 && StructArray2.prototype);
+ StructArrayLayout4f162.prototype.constructor = StructArrayLayout4f162;
+ StructArrayLayout4f162.prototype._refreshViews = function _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer);
+ this.float32 = new Float32Array(this.arrayBuffer);
+ };
+ StructArrayLayout4f162.prototype.emplaceBack = function emplaceBack(v0, v1, v2, v3) {
+ var i = this.length;
+ this.resize(i + 1);
+ return this.emplace(i, v0, v1, v2, v3);
+ };
+ StructArrayLayout4f162.prototype.emplace = function emplace(i, v0, v1, v2, v3) {
+ var o4 = i * 4;
+ this.float32[o4 + 0] = v0;
+ this.float32[o4 + 1] = v1;
+ this.float32[o4 + 2] = v2;
+ this.float32[o4 + 3] = v3;
+ return i;
+ };
+ return StructArrayLayout4f162;
+ }(StructArray);
+ StructArrayLayout4f16.prototype.bytesPerElement = 16;
+ register("StructArrayLayout4f16", StructArrayLayout4f16);
+ var CollisionBoxStruct = function(Struct2) {
+ function CollisionBoxStruct2() {
+ Struct2.apply(this, arguments);
+ }
+ if (Struct2)
+ CollisionBoxStruct2.__proto__ = Struct2;
+ CollisionBoxStruct2.prototype = Object.create(Struct2 && Struct2.prototype);
+ CollisionBoxStruct2.prototype.constructor = CollisionBoxStruct2;
+ var prototypeAccessors2 = {
+ anchorPointX: { configurable: true },
+ anchorPointY: { configurable: true },
+ x1: { configurable: true },
+ y1: { configurable: true },
+ x2: { configurable: true },
+ y2: { configurable: true },
+ featureIndex: { configurable: true },
+ sourceLayerIndex: { configurable: true },
+ bucketIndex: { configurable: true },
+ anchorPoint: { configurable: true }
+ };
+ prototypeAccessors2.anchorPointX.get = function() {
+ return this._structArray.int16[this._pos2 + 0];
+ };
+ prototypeAccessors2.anchorPointY.get = function() {
+ return this._structArray.int16[this._pos2 + 1];
+ };
+ prototypeAccessors2.x1.get = function() {
+ return this._structArray.int16[this._pos2 + 2];
+ };
+ prototypeAccessors2.y1.get = function() {
+ return this._structArray.int16[this._pos2 + 3];
+ };
+ prototypeAccessors2.x2.get = function() {
+ return this._structArray.int16[this._pos2 + 4];
+ };
+ prototypeAccessors2.y2.get = function() {
+ return this._structArray.int16[this._pos2 + 5];
+ };
+ prototypeAccessors2.featureIndex.get = function() {
+ return this._structArray.uint32[this._pos4 + 3];
+ };
+ prototypeAccessors2.sourceLayerIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 8];
+ };
+ prototypeAccessors2.bucketIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 9];
+ };
+ prototypeAccessors2.anchorPoint.get = function() {
+ return new pointGeometry(this.anchorPointX, this.anchorPointY);
+ };
+ Object.defineProperties(CollisionBoxStruct2.prototype, prototypeAccessors2);
+ return CollisionBoxStruct2;
+ }(Struct);
+ CollisionBoxStruct.prototype.size = 20;
+ var CollisionBoxArray = function(StructArrayLayout6i1ul2ui202) {
+ function CollisionBoxArray2() {
+ StructArrayLayout6i1ul2ui202.apply(this, arguments);
+ }
+ if (StructArrayLayout6i1ul2ui202)
+ CollisionBoxArray2.__proto__ = StructArrayLayout6i1ul2ui202;
+ CollisionBoxArray2.prototype = Object.create(StructArrayLayout6i1ul2ui202 && StructArrayLayout6i1ul2ui202.prototype);
+ CollisionBoxArray2.prototype.constructor = CollisionBoxArray2;
+ CollisionBoxArray2.prototype.get = function get2(index) {
+ return new CollisionBoxStruct(this, index);
+ };
+ return CollisionBoxArray2;
+ }(StructArrayLayout6i1ul2ui20);
+ register("CollisionBoxArray", CollisionBoxArray);
+ var PlacedSymbolStruct = function(Struct2) {
+ function PlacedSymbolStruct2() {
+ Struct2.apply(this, arguments);
+ }
+ if (Struct2)
+ PlacedSymbolStruct2.__proto__ = Struct2;
+ PlacedSymbolStruct2.prototype = Object.create(Struct2 && Struct2.prototype);
+ PlacedSymbolStruct2.prototype.constructor = PlacedSymbolStruct2;
+ var prototypeAccessors$12 = {
+ anchorX: { configurable: true },
+ anchorY: { configurable: true },
+ glyphStartIndex: { configurable: true },
+ numGlyphs: { configurable: true },
+ vertexStartIndex: { configurable: true },
+ lineStartIndex: { configurable: true },
+ lineLength: { configurable: true },
+ segment: { configurable: true },
+ lowerSize: { configurable: true },
+ upperSize: { configurable: true },
+ lineOffsetX: { configurable: true },
+ lineOffsetY: { configurable: true },
+ writingMode: { configurable: true },
+ placedOrientation: { configurable: true },
+ hidden: { configurable: true },
+ crossTileID: { configurable: true },
+ associatedIconIndex: { configurable: true }
+ };
+ prototypeAccessors$12.anchorX.get = function() {
+ return this._structArray.int16[this._pos2 + 0];
+ };
+ prototypeAccessors$12.anchorY.get = function() {
+ return this._structArray.int16[this._pos2 + 1];
+ };
+ prototypeAccessors$12.glyphStartIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 2];
+ };
+ prototypeAccessors$12.numGlyphs.get = function() {
+ return this._structArray.uint16[this._pos2 + 3];
+ };
+ prototypeAccessors$12.vertexStartIndex.get = function() {
+ return this._structArray.uint32[this._pos4 + 2];
+ };
+ prototypeAccessors$12.lineStartIndex.get = function() {
+ return this._structArray.uint32[this._pos4 + 3];
+ };
+ prototypeAccessors$12.lineLength.get = function() {
+ return this._structArray.uint32[this._pos4 + 4];
+ };
+ prototypeAccessors$12.segment.get = function() {
+ return this._structArray.uint16[this._pos2 + 10];
+ };
+ prototypeAccessors$12.lowerSize.get = function() {
+ return this._structArray.uint16[this._pos2 + 11];
+ };
+ prototypeAccessors$12.upperSize.get = function() {
+ return this._structArray.uint16[this._pos2 + 12];
+ };
+ prototypeAccessors$12.lineOffsetX.get = function() {
+ return this._structArray.float32[this._pos4 + 7];
+ };
+ prototypeAccessors$12.lineOffsetY.get = function() {
+ return this._structArray.float32[this._pos4 + 8];
+ };
+ prototypeAccessors$12.writingMode.get = function() {
+ return this._structArray.uint8[this._pos1 + 36];
+ };
+ prototypeAccessors$12.placedOrientation.get = function() {
+ return this._structArray.uint8[this._pos1 + 37];
+ };
+ prototypeAccessors$12.placedOrientation.set = function(x) {
+ this._structArray.uint8[this._pos1 + 37] = x;
+ };
+ prototypeAccessors$12.hidden.get = function() {
+ return this._structArray.uint8[this._pos1 + 38];
+ };
+ prototypeAccessors$12.hidden.set = function(x) {
+ this._structArray.uint8[this._pos1 + 38] = x;
+ };
+ prototypeAccessors$12.crossTileID.get = function() {
+ return this._structArray.uint32[this._pos4 + 10];
+ };
+ prototypeAccessors$12.crossTileID.set = function(x) {
+ this._structArray.uint32[this._pos4 + 10] = x;
+ };
+ prototypeAccessors$12.associatedIconIndex.get = function() {
+ return this._structArray.int16[this._pos2 + 22];
+ };
+ Object.defineProperties(PlacedSymbolStruct2.prototype, prototypeAccessors$12);
+ return PlacedSymbolStruct2;
+ }(Struct);
+ PlacedSymbolStruct.prototype.size = 48;
+ var PlacedSymbolArray = function(StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482) {
+ function PlacedSymbolArray2() {
+ StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482.apply(this, arguments);
+ }
+ if (StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482)
+ PlacedSymbolArray2.__proto__ = StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482;
+ PlacedSymbolArray2.prototype = Object.create(StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482 && StructArrayLayout2i2ui3ul3ui2f3ub1ul1i482.prototype);
+ PlacedSymbolArray2.prototype.constructor = PlacedSymbolArray2;
+ PlacedSymbolArray2.prototype.get = function get2(index) {
+ return new PlacedSymbolStruct(this, index);
+ };
+ return PlacedSymbolArray2;
+ }(StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48);
+ register("PlacedSymbolArray", PlacedSymbolArray);
+ var SymbolInstanceStruct = function(Struct2) {
+ function SymbolInstanceStruct2() {
+ Struct2.apply(this, arguments);
+ }
+ if (Struct2)
+ SymbolInstanceStruct2.__proto__ = Struct2;
+ SymbolInstanceStruct2.prototype = Object.create(Struct2 && Struct2.prototype);
+ SymbolInstanceStruct2.prototype.constructor = SymbolInstanceStruct2;
+ var prototypeAccessors$2 = {
+ anchorX: { configurable: true },
+ anchorY: { configurable: true },
+ rightJustifiedTextSymbolIndex: { configurable: true },
+ centerJustifiedTextSymbolIndex: { configurable: true },
+ leftJustifiedTextSymbolIndex: { configurable: true },
+ verticalPlacedTextSymbolIndex: { configurable: true },
+ placedIconSymbolIndex: { configurable: true },
+ verticalPlacedIconSymbolIndex: { configurable: true },
+ key: { configurable: true },
+ textBoxStartIndex: { configurable: true },
+ textBoxEndIndex: { configurable: true },
+ verticalTextBoxStartIndex: { configurable: true },
+ verticalTextBoxEndIndex: { configurable: true },
+ iconBoxStartIndex: { configurable: true },
+ iconBoxEndIndex: { configurable: true },
+ verticalIconBoxStartIndex: { configurable: true },
+ verticalIconBoxEndIndex: { configurable: true },
+ featureIndex: { configurable: true },
+ numHorizontalGlyphVertices: { configurable: true },
+ numVerticalGlyphVertices: { configurable: true },
+ numIconVertices: { configurable: true },
+ numVerticalIconVertices: { configurable: true },
+ useRuntimeCollisionCircles: { configurable: true },
+ crossTileID: { configurable: true },
+ textBoxScale: { configurable: true },
+ textOffset0: { configurable: true },
+ textOffset1: { configurable: true },
+ collisionCircleDiameter: { configurable: true }
+ };
+ prototypeAccessors$2.anchorX.get = function() {
+ return this._structArray.int16[this._pos2 + 0];
+ };
+ prototypeAccessors$2.anchorY.get = function() {
+ return this._structArray.int16[this._pos2 + 1];
+ };
+ prototypeAccessors$2.rightJustifiedTextSymbolIndex.get = function() {
+ return this._structArray.int16[this._pos2 + 2];
+ };
+ prototypeAccessors$2.centerJustifiedTextSymbolIndex.get = function() {
+ return this._structArray.int16[this._pos2 + 3];
+ };
+ prototypeAccessors$2.leftJustifiedTextSymbolIndex.get = function() {
+ return this._structArray.int16[this._pos2 + 4];
+ };
+ prototypeAccessors$2.verticalPlacedTextSymbolIndex.get = function() {
+ return this._structArray.int16[this._pos2 + 5];
+ };
+ prototypeAccessors$2.placedIconSymbolIndex.get = function() {
+ return this._structArray.int16[this._pos2 + 6];
+ };
+ prototypeAccessors$2.verticalPlacedIconSymbolIndex.get = function() {
+ return this._structArray.int16[this._pos2 + 7];
+ };
+ prototypeAccessors$2.key.get = function() {
+ return this._structArray.uint16[this._pos2 + 8];
+ };
+ prototypeAccessors$2.textBoxStartIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 9];
+ };
+ prototypeAccessors$2.textBoxEndIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 10];
+ };
+ prototypeAccessors$2.verticalTextBoxStartIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 11];
+ };
+ prototypeAccessors$2.verticalTextBoxEndIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 12];
+ };
+ prototypeAccessors$2.iconBoxStartIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 13];
+ };
+ prototypeAccessors$2.iconBoxEndIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 14];
+ };
+ prototypeAccessors$2.verticalIconBoxStartIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 15];
+ };
+ prototypeAccessors$2.verticalIconBoxEndIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 16];
+ };
+ prototypeAccessors$2.featureIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 17];
+ };
+ prototypeAccessors$2.numHorizontalGlyphVertices.get = function() {
+ return this._structArray.uint16[this._pos2 + 18];
+ };
+ prototypeAccessors$2.numVerticalGlyphVertices.get = function() {
+ return this._structArray.uint16[this._pos2 + 19];
+ };
+ prototypeAccessors$2.numIconVertices.get = function() {
+ return this._structArray.uint16[this._pos2 + 20];
+ };
+ prototypeAccessors$2.numVerticalIconVertices.get = function() {
+ return this._structArray.uint16[this._pos2 + 21];
+ };
+ prototypeAccessors$2.useRuntimeCollisionCircles.get = function() {
+ return this._structArray.uint16[this._pos2 + 22];
+ };
+ prototypeAccessors$2.crossTileID.get = function() {
+ return this._structArray.uint32[this._pos4 + 12];
+ };
+ prototypeAccessors$2.crossTileID.set = function(x) {
+ this._structArray.uint32[this._pos4 + 12] = x;
+ };
+ prototypeAccessors$2.textBoxScale.get = function() {
+ return this._structArray.float32[this._pos4 + 13];
+ };
+ prototypeAccessors$2.textOffset0.get = function() {
+ return this._structArray.float32[this._pos4 + 14];
+ };
+ prototypeAccessors$2.textOffset1.get = function() {
+ return this._structArray.float32[this._pos4 + 15];
+ };
+ prototypeAccessors$2.collisionCircleDiameter.get = function() {
+ return this._structArray.float32[this._pos4 + 16];
+ };
+ Object.defineProperties(SymbolInstanceStruct2.prototype, prototypeAccessors$2);
+ return SymbolInstanceStruct2;
+ }(Struct);
+ SymbolInstanceStruct.prototype.size = 68;
+ var SymbolInstanceArray = function(StructArrayLayout8i15ui1ul4f682) {
+ function SymbolInstanceArray2() {
+ StructArrayLayout8i15ui1ul4f682.apply(this, arguments);
+ }
+ if (StructArrayLayout8i15ui1ul4f682)
+ SymbolInstanceArray2.__proto__ = StructArrayLayout8i15ui1ul4f682;
+ SymbolInstanceArray2.prototype = Object.create(StructArrayLayout8i15ui1ul4f682 && StructArrayLayout8i15ui1ul4f682.prototype);
+ SymbolInstanceArray2.prototype.constructor = SymbolInstanceArray2;
+ SymbolInstanceArray2.prototype.get = function get2(index) {
+ return new SymbolInstanceStruct(this, index);
+ };
+ return SymbolInstanceArray2;
+ }(StructArrayLayout8i15ui1ul4f68);
+ register("SymbolInstanceArray", SymbolInstanceArray);
+ var GlyphOffsetArray = function(StructArrayLayout1f42) {
+ function GlyphOffsetArray2() {
+ StructArrayLayout1f42.apply(this, arguments);
+ }
+ if (StructArrayLayout1f42)
+ GlyphOffsetArray2.__proto__ = StructArrayLayout1f42;
+ GlyphOffsetArray2.prototype = Object.create(StructArrayLayout1f42 && StructArrayLayout1f42.prototype);
+ GlyphOffsetArray2.prototype.constructor = GlyphOffsetArray2;
+ GlyphOffsetArray2.prototype.getoffsetX = function getoffsetX(index) {
+ return this.float32[index * 1 + 0];
+ };
+ return GlyphOffsetArray2;
+ }(StructArrayLayout1f4);
+ register("GlyphOffsetArray", GlyphOffsetArray);
+ var SymbolLineVertexArray = function(StructArrayLayout3i62) {
+ function SymbolLineVertexArray2() {
+ StructArrayLayout3i62.apply(this, arguments);
+ }
+ if (StructArrayLayout3i62)
+ SymbolLineVertexArray2.__proto__ = StructArrayLayout3i62;
+ SymbolLineVertexArray2.prototype = Object.create(StructArrayLayout3i62 && StructArrayLayout3i62.prototype);
+ SymbolLineVertexArray2.prototype.constructor = SymbolLineVertexArray2;
+ SymbolLineVertexArray2.prototype.getx = function getx(index) {
+ return this.int16[index * 3 + 0];
+ };
+ SymbolLineVertexArray2.prototype.gety = function gety(index) {
+ return this.int16[index * 3 + 1];
+ };
+ SymbolLineVertexArray2.prototype.gettileUnitDistanceFromAnchor = function gettileUnitDistanceFromAnchor(index) {
+ return this.int16[index * 3 + 2];
+ };
+ return SymbolLineVertexArray2;
+ }(StructArrayLayout3i6);
+ register("SymbolLineVertexArray", SymbolLineVertexArray);
+ var FeatureIndexStruct = function(Struct2) {
+ function FeatureIndexStruct2() {
+ Struct2.apply(this, arguments);
+ }
+ if (Struct2)
+ FeatureIndexStruct2.__proto__ = Struct2;
+ FeatureIndexStruct2.prototype = Object.create(Struct2 && Struct2.prototype);
+ FeatureIndexStruct2.prototype.constructor = FeatureIndexStruct2;
+ var prototypeAccessors$3 = {
+ featureIndex: { configurable: true },
+ sourceLayerIndex: { configurable: true },
+ bucketIndex: { configurable: true }
+ };
+ prototypeAccessors$3.featureIndex.get = function() {
+ return this._structArray.uint32[this._pos4 + 0];
+ };
+ prototypeAccessors$3.sourceLayerIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 2];
+ };
+ prototypeAccessors$3.bucketIndex.get = function() {
+ return this._structArray.uint16[this._pos2 + 3];
+ };
+ Object.defineProperties(FeatureIndexStruct2.prototype, prototypeAccessors$3);
+ return FeatureIndexStruct2;
+ }(Struct);
+ FeatureIndexStruct.prototype.size = 8;
+ var FeatureIndexArray = function(StructArrayLayout1ul2ui82) {
+ function FeatureIndexArray2() {
+ StructArrayLayout1ul2ui82.apply(this, arguments);
+ }
+ if (StructArrayLayout1ul2ui82)
+ FeatureIndexArray2.__proto__ = StructArrayLayout1ul2ui82;
+ FeatureIndexArray2.prototype = Object.create(StructArrayLayout1ul2ui82 && StructArrayLayout1ul2ui82.prototype);
+ FeatureIndexArray2.prototype.constructor = FeatureIndexArray2;
+ FeatureIndexArray2.prototype.get = function get2(index) {
+ return new FeatureIndexStruct(this, index);
+ };
+ return FeatureIndexArray2;
+ }(StructArrayLayout1ul2ui8);
+ register("FeatureIndexArray", FeatureIndexArray);
+ var layout$1 = createLayout([{
+ name: "a_pos",
+ components: 2,
+ type: "Int16"
+ }], 4);
+ var members = layout$1.members;
+ var SegmentVector = function SegmentVector2(segments) {
+ if (segments === void 0)
+ segments = [];
+ this.segments = segments;
+ };
+ SegmentVector.prototype.prepareSegment = function prepareSegment(numVertices, layoutVertexArray, indexArray, sortKey) {
+ var segment = this.segments[this.segments.length - 1];
+ if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
+ warnOnce("Max vertices per segment is " + SegmentVector.MAX_VERTEX_ARRAY_LENGTH + ": bucket requested " + numVertices);
+ }
+ if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH || segment.sortKey !== sortKey) {
+ segment = {
+ vertexOffset: layoutVertexArray.length,
+ primitiveOffset: indexArray.length,
+ vertexLength: 0,
+ primitiveLength: 0
+ };
+ if (sortKey !== void 0) {
+ segment.sortKey = sortKey;
+ }
+ this.segments.push(segment);
+ }
+ return segment;
+ };
+ SegmentVector.prototype.get = function get2() {
+ return this.segments;
+ };
+ SegmentVector.prototype.destroy = function destroy() {
+ for (var i = 0, list = this.segments; i < list.length; i += 1) {
+ var segment = list[i];
+ for (var k in segment.vaos) {
+ segment.vaos[k].destroy();
+ }
+ }
+ };
+ SegmentVector.simpleSegment = function simpleSegment(vertexOffset, primitiveOffset, vertexLength, primitiveLength) {
+ return new SegmentVector([{
+ vertexOffset,
+ primitiveOffset,
+ vertexLength,
+ primitiveLength,
+ vaos: {},
+ sortKey: 0
+ }]);
+ };
+ SegmentVector.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1;
+ register("SegmentVector", SegmentVector);
+ function packUint8ToFloat(a, b) {
+ a = clamp(Math.floor(a), 0, 255);
+ b = clamp(Math.floor(b), 0, 255);
+ return 256 * a + b;
+ }
+ var patternAttributes = createLayout([
+ {
+ name: "a_pattern_from",
+ components: 4,
+ type: "Uint16"
+ },
+ {
+ name: "a_pattern_to",
+ components: 4,
+ type: "Uint16"
+ },
+ {
+ name: "a_pixel_ratio_from",
+ components: 1,
+ type: "Uint16"
+ },
+ {
+ name: "a_pixel_ratio_to",
+ components: 1,
+ type: "Uint16"
+ }
+ ]);
+ var murmurhash3_gc = createCommonjsModule(function(module2) {
+ function murmurhash3_32_gc(key, seed) {
+ var remainder, bytes, h1, h1b, c1, c2, k1, i;
+ remainder = key.length & 3;
+ bytes = key.length - remainder;
+ h1 = seed;
+ c1 = 3432918353;
+ c2 = 461845907;
+ i = 0;
+ while (i < bytes) {
+ k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(++i) & 255) << 8 | (key.charCodeAt(++i) & 255) << 16 | (key.charCodeAt(++i) & 255) << 24;
+ ++i;
+ k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
+ k1 = k1 << 15 | k1 >>> 17;
+ k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
+ h1 ^= k1;
+ h1 = h1 << 13 | h1 >>> 19;
+ h1b = (h1 & 65535) * 5 + (((h1 >>> 16) * 5 & 65535) << 16) & 4294967295;
+ h1 = (h1b & 65535) + 27492 + (((h1b >>> 16) + 58964 & 65535) << 16);
+ }
+ k1 = 0;
+ switch (remainder) {
+ case 3:
+ k1 ^= (key.charCodeAt(i + 2) & 255) << 16;
+ case 2:
+ k1 ^= (key.charCodeAt(i + 1) & 255) << 8;
+ case 1:
+ k1 ^= key.charCodeAt(i) & 255;
+ k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
+ k1 = k1 << 15 | k1 >>> 17;
+ k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
+ h1 ^= k1;
+ }
+ h1 ^= key.length;
+ h1 ^= h1 >>> 16;
+ h1 = (h1 & 65535) * 2246822507 + (((h1 >>> 16) * 2246822507 & 65535) << 16) & 4294967295;
+ h1 ^= h1 >>> 13;
+ h1 = (h1 & 65535) * 3266489909 + (((h1 >>> 16) * 3266489909 & 65535) << 16) & 4294967295;
+ h1 ^= h1 >>> 16;
+ return h1 >>> 0;
+ }
+ {
+ module2.exports = murmurhash3_32_gc;
+ }
+ });
+ var murmurhash2_gc = createCommonjsModule(function(module2) {
+ function murmurhash2_32_gc(str, seed) {
+ var l = str.length, h = seed ^ l, i = 0, k;
+ while (l >= 4) {
+ k = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
+ k = (k & 65535) * 1540483477 + (((k >>> 16) * 1540483477 & 65535) << 16);
+ k ^= k >>> 24;
+ k = (k & 65535) * 1540483477 + (((k >>> 16) * 1540483477 & 65535) << 16);
+ h = (h & 65535) * 1540483477 + (((h >>> 16) * 1540483477 & 65535) << 16) ^ k;
+ l -= 4;
+ ++i;
+ }
+ switch (l) {
+ case 3:
+ h ^= (str.charCodeAt(i + 2) & 255) << 16;
+ case 2:
+ h ^= (str.charCodeAt(i + 1) & 255) << 8;
+ case 1:
+ h ^= str.charCodeAt(i) & 255;
+ h = (h & 65535) * 1540483477 + (((h >>> 16) * 1540483477 & 65535) << 16);
+ }
+ h ^= h >>> 13;
+ h = (h & 65535) * 1540483477 + (((h >>> 16) * 1540483477 & 65535) << 16);
+ h ^= h >>> 15;
+ return h >>> 0;
+ }
+ {
+ module2.exports = murmurhash2_32_gc;
+ }
+ });
+ var murmurhashJs = murmurhash3_gc;
+ var murmur3_1 = murmurhash3_gc;
+ var murmur2_1 = murmurhash2_gc;
+ murmurhashJs.murmur3 = murmur3_1;
+ murmurhashJs.murmur2 = murmur2_1;
+ var FeaturePositionMap = function FeaturePositionMap2() {
+ this.ids = [];
+ this.positions = [];
+ this.indexed = false;
+ };
+ FeaturePositionMap.prototype.add = function add2(id2, index, start, end) {
+ this.ids.push(getNumericId(id2));
+ this.positions.push(index, start, end);
+ };
+ FeaturePositionMap.prototype.getPositions = function getPositions(id2) {
+ var intId = getNumericId(id2);
+ var i = 0;
+ var j = this.ids.length - 1;
+ while (i < j) {
+ var m = i + j >> 1;
+ if (this.ids[m] >= intId) {
+ j = m;
+ } else {
+ i = m + 1;
+ }
+ }
+ var positions = [];
+ while (this.ids[i] === intId) {
+ var index = this.positions[3 * i];
+ var start = this.positions[3 * i + 1];
+ var end = this.positions[3 * i + 2];
+ positions.push({
+ index,
+ start,
+ end
+ });
+ i++;
+ }
+ return positions;
+ };
+ FeaturePositionMap.serialize = function serialize2(map, transferables) {
+ var ids = new Float64Array(map.ids);
+ var positions = new Uint32Array(map.positions);
+ sort(ids, positions, 0, ids.length - 1);
+ if (transferables) {
+ transferables.push(ids.buffer, positions.buffer);
+ }
+ return {
+ ids,
+ positions
+ };
+ };
+ FeaturePositionMap.deserialize = function deserialize2(obj) {
+ var map = new FeaturePositionMap();
+ map.ids = obj.ids;
+ map.positions = obj.positions;
+ map.indexed = true;
+ return map;
+ };
+ var MAX_SAFE_INTEGER$1 = Math.pow(2, 53) - 1;
+ function getNumericId(value) {
+ var numValue = +value;
+ if (!isNaN(numValue) && numValue <= MAX_SAFE_INTEGER$1) {
+ return numValue;
+ }
+ return murmurhashJs(String(value));
+ }
+ function sort(ids, positions, left, right) {
+ while (left < right) {
+ var pivot = ids[left + right >> 1];
+ var i = left - 1;
+ var j = right + 1;
+ while (true) {
+ do {
+ i++;
+ } while (ids[i] < pivot);
+ do {
+ j--;
+ } while (ids[j] > pivot);
+ if (i >= j) {
+ break;
+ }
+ swap(ids, i, j);
+ swap(positions, 3 * i, 3 * j);
+ swap(positions, 3 * i + 1, 3 * j + 1);
+ swap(positions, 3 * i + 2, 3 * j + 2);
+ }
+ if (j - left < right - j) {
+ sort(ids, positions, left, j);
+ left = j + 1;
+ } else {
+ sort(ids, positions, j + 1, right);
+ right = j;
+ }
+ }
+ }
+ function swap(arr, i, j) {
+ var tmp = arr[i];
+ arr[i] = arr[j];
+ arr[j] = tmp;
+ }
+ register("FeaturePositionMap", FeaturePositionMap);
+ var Uniform = function Uniform2(context, location2) {
+ this.gl = context.gl;
+ this.location = location2;
+ };
+ var Uniform1i = function(Uniform2) {
+ function Uniform1i2(context, location2) {
+ Uniform2.call(this, context, location2);
+ this.current = 0;
+ }
+ if (Uniform2)
+ Uniform1i2.__proto__ = Uniform2;
+ Uniform1i2.prototype = Object.create(Uniform2 && Uniform2.prototype);
+ Uniform1i2.prototype.constructor = Uniform1i2;
+ Uniform1i2.prototype.set = function set(v) {
+ if (this.current !== v) {
+ this.current = v;
+ this.gl.uniform1i(this.location, v);
+ }
+ };
+ return Uniform1i2;
+ }(Uniform);
+ var Uniform1f = function(Uniform2) {
+ function Uniform1f2(context, location2) {
+ Uniform2.call(this, context, location2);
+ this.current = 0;
+ }
+ if (Uniform2)
+ Uniform1f2.__proto__ = Uniform2;
+ Uniform1f2.prototype = Object.create(Uniform2 && Uniform2.prototype);
+ Uniform1f2.prototype.constructor = Uniform1f2;
+ Uniform1f2.prototype.set = function set(v) {
+ if (this.current !== v) {
+ this.current = v;
+ this.gl.uniform1f(this.location, v);
+ }
+ };
+ return Uniform1f2;
+ }(Uniform);
+ var Uniform2f = function(Uniform2) {
+ function Uniform2f2(context, location2) {
+ Uniform2.call(this, context, location2);
+ this.current = [
+ 0,
+ 0
+ ];
+ }
+ if (Uniform2)
+ Uniform2f2.__proto__ = Uniform2;
+ Uniform2f2.prototype = Object.create(Uniform2 && Uniform2.prototype);
+ Uniform2f2.prototype.constructor = Uniform2f2;
+ Uniform2f2.prototype.set = function set(v) {
+ if (v[0] !== this.current[0] || v[1] !== this.current[1]) {
+ this.current = v;
+ this.gl.uniform2f(this.location, v[0], v[1]);
+ }
+ };
+ return Uniform2f2;
+ }(Uniform);
+ var Uniform3f = function(Uniform2) {
+ function Uniform3f2(context, location2) {
+ Uniform2.call(this, context, location2);
+ this.current = [
+ 0,
+ 0,
+ 0
+ ];
+ }
+ if (Uniform2)
+ Uniform3f2.__proto__ = Uniform2;
+ Uniform3f2.prototype = Object.create(Uniform2 && Uniform2.prototype);
+ Uniform3f2.prototype.constructor = Uniform3f2;
+ Uniform3f2.prototype.set = function set(v) {
+ if (v[0] !== this.current[0] || v[1] !== this.current[1] || v[2] !== this.current[2]) {
+ this.current = v;
+ this.gl.uniform3f(this.location, v[0], v[1], v[2]);
+ }
+ };
+ return Uniform3f2;
+ }(Uniform);
+ var Uniform4f = function(Uniform2) {
+ function Uniform4f2(context, location2) {
+ Uniform2.call(this, context, location2);
+ this.current = [
+ 0,
+ 0,
+ 0,
+ 0
+ ];
+ }
+ if (Uniform2)
+ Uniform4f2.__proto__ = Uniform2;
+ Uniform4f2.prototype = Object.create(Uniform2 && Uniform2.prototype);
+ Uniform4f2.prototype.constructor = Uniform4f2;
+ Uniform4f2.prototype.set = function set(v) {
+ if (v[0] !== this.current[0] || v[1] !== this.current[1] || v[2] !== this.current[2] || v[3] !== this.current[3]) {
+ this.current = v;
+ this.gl.uniform4f(this.location, v[0], v[1], v[2], v[3]);
+ }
+ };
+ return Uniform4f2;
+ }(Uniform);
+ var UniformColor = function(Uniform2) {
+ function UniformColor2(context, location2) {
+ Uniform2.call(this, context, location2);
+ this.current = Color2.transparent;
+ }
+ if (Uniform2)
+ UniformColor2.__proto__ = Uniform2;
+ UniformColor2.prototype = Object.create(Uniform2 && Uniform2.prototype);
+ UniformColor2.prototype.constructor = UniformColor2;
+ UniformColor2.prototype.set = function set(v) {
+ if (v.r !== this.current.r || v.g !== this.current.g || v.b !== this.current.b || v.a !== this.current.a) {
+ this.current = v;
+ this.gl.uniform4f(this.location, v.r, v.g, v.b, v.a);
+ }
+ };
+ return UniformColor2;
+ }(Uniform);
+ var emptyMat4 = new Float32Array(16);
+ var UniformMatrix4f = function(Uniform2) {
+ function UniformMatrix4f2(context, location2) {
+ Uniform2.call(this, context, location2);
+ this.current = emptyMat4;
+ }
+ if (Uniform2)
+ UniformMatrix4f2.__proto__ = Uniform2;
+ UniformMatrix4f2.prototype = Object.create(Uniform2 && Uniform2.prototype);
+ UniformMatrix4f2.prototype.constructor = UniformMatrix4f2;
+ UniformMatrix4f2.prototype.set = function set(v) {
+ if (v[12] !== this.current[12] || v[0] !== this.current[0]) {
+ this.current = v;
+ this.gl.uniformMatrix4fv(this.location, false, v);
+ return;
+ }
+ for (var i = 1; i < 16; i++) {
+ if (v[i] !== this.current[i]) {
+ this.current = v;
+ this.gl.uniformMatrix4fv(this.location, false, v);
+ break;
+ }
+ }
+ };
+ return UniformMatrix4f2;
+ }(Uniform);
+ function packColor(color3) {
+ return [
+ packUint8ToFloat(255 * color3.r, 255 * color3.g),
+ packUint8ToFloat(255 * color3.b, 255 * color3.a)
+ ];
+ }
+ var ConstantBinder = function ConstantBinder2(value, names2, type) {
+ this.value = value;
+ this.uniformNames = names2.map(function(name3) {
+ return "u_" + name3;
+ });
+ this.type = type;
+ };
+ ConstantBinder.prototype.setUniform = function setUniform(uniform, globals, currentValue) {
+ uniform.set(currentValue.constantOr(this.value));
+ };
+ ConstantBinder.prototype.getBinding = function getBinding(context, location2, _) {
+ return this.type === "color" ? new UniformColor(context, location2) : new Uniform1f(context, location2);
+ };
+ var CrossFadedConstantBinder = function CrossFadedConstantBinder2(value, names2) {
+ this.uniformNames = names2.map(function(name3) {
+ return "u_" + name3;
+ });
+ this.patternFrom = null;
+ this.patternTo = null;
+ this.pixelRatioFrom = 1;
+ this.pixelRatioTo = 1;
+ };
+ CrossFadedConstantBinder.prototype.setConstantPatternPositions = function setConstantPatternPositions(posTo, posFrom) {
+ this.pixelRatioFrom = posFrom.pixelRatio;
+ this.pixelRatioTo = posTo.pixelRatio;
+ this.patternFrom = posFrom.tlbr;
+ this.patternTo = posTo.tlbr;
+ };
+ CrossFadedConstantBinder.prototype.setUniform = function setUniform(uniform, globals, currentValue, uniformName) {
+ var pos = uniformName === "u_pattern_to" ? this.patternTo : uniformName === "u_pattern_from" ? this.patternFrom : uniformName === "u_pixel_ratio_to" ? this.pixelRatioTo : uniformName === "u_pixel_ratio_from" ? this.pixelRatioFrom : null;
+ if (pos) {
+ uniform.set(pos);
+ }
+ };
+ CrossFadedConstantBinder.prototype.getBinding = function getBinding(context, location2, name3) {
+ return name3.substr(0, 9) === "u_pattern" ? new Uniform4f(context, location2) : new Uniform1f(context, location2);
+ };
+ var SourceExpressionBinder = function SourceExpressionBinder2(expression2, names2, type, PaintVertexArray) {
+ this.expression = expression2;
+ this.type = type;
+ this.maxValue = 0;
+ this.paintVertexAttributes = names2.map(function(name3) {
+ return {
+ name: "a_" + name3,
+ type: "Float32",
+ components: type === "color" ? 2 : 1,
+ offset: 0
+ };
+ });
+ this.paintVertexArray = new PaintVertexArray();
+ };
+ SourceExpressionBinder.prototype.populatePaintArray = function populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection) {
+ var start = this.paintVertexArray.length;
+ var value = this.expression.evaluate(new EvaluationParameters(0), feature, {}, canonical, [], formattedSection);
+ this.paintVertexArray.resize(newLength);
+ this._setPaintValue(start, newLength, value);
+ };
+ SourceExpressionBinder.prototype.updatePaintArray = function updatePaintArray(start, end, feature, featureState) {
+ var value = this.expression.evaluate({ zoom: 0 }, feature, featureState);
+ this._setPaintValue(start, end, value);
+ };
+ SourceExpressionBinder.prototype._setPaintValue = function _setPaintValue(start, end, value) {
+ if (this.type === "color") {
+ var color3 = packColor(value);
+ for (var i = start; i < end; i++) {
+ this.paintVertexArray.emplace(i, color3[0], color3[1]);
+ }
+ } else {
+ for (var i$1 = start; i$1 < end; i$1++) {
+ this.paintVertexArray.emplace(i$1, value);
+ }
+ this.maxValue = Math.max(this.maxValue, Math.abs(value));
+ }
+ };
+ SourceExpressionBinder.prototype.upload = function upload(context) {
+ if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {
+ if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {
+ this.paintVertexBuffer.updateData(this.paintVertexArray);
+ } else {
+ this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);
+ }
+ }
+ };
+ SourceExpressionBinder.prototype.destroy = function destroy() {
+ if (this.paintVertexBuffer) {
+ this.paintVertexBuffer.destroy();
+ }
+ };
+ var CompositeExpressionBinder = function CompositeExpressionBinder2(expression2, names2, type, useIntegerZoom, zoom, PaintVertexArray) {
+ this.expression = expression2;
+ this.uniformNames = names2.map(function(name3) {
+ return "u_" + name3 + "_t";
+ });
+ this.type = type;
+ this.useIntegerZoom = useIntegerZoom;
+ this.zoom = zoom;
+ this.maxValue = 0;
+ this.paintVertexAttributes = names2.map(function(name3) {
+ return {
+ name: "a_" + name3,
+ type: "Float32",
+ components: type === "color" ? 4 : 2,
+ offset: 0
+ };
+ });
+ this.paintVertexArray = new PaintVertexArray();
+ };
+ CompositeExpressionBinder.prototype.populatePaintArray = function populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection) {
+ var min = this.expression.evaluate(new EvaluationParameters(this.zoom), feature, {}, canonical, [], formattedSection);
+ var max = this.expression.evaluate(new EvaluationParameters(this.zoom + 1), feature, {}, canonical, [], formattedSection);
+ var start = this.paintVertexArray.length;
+ this.paintVertexArray.resize(newLength);
+ this._setPaintValue(start, newLength, min, max);
+ };
+ CompositeExpressionBinder.prototype.updatePaintArray = function updatePaintArray(start, end, feature, featureState) {
+ var min = this.expression.evaluate({ zoom: this.zoom }, feature, featureState);
+ var max = this.expression.evaluate({ zoom: this.zoom + 1 }, feature, featureState);
+ this._setPaintValue(start, end, min, max);
+ };
+ CompositeExpressionBinder.prototype._setPaintValue = function _setPaintValue(start, end, min, max) {
+ if (this.type === "color") {
+ var minColor = packColor(min);
+ var maxColor = packColor(max);
+ for (var i = start; i < end; i++) {
+ this.paintVertexArray.emplace(i, minColor[0], minColor[1], maxColor[0], maxColor[1]);
+ }
+ } else {
+ for (var i$1 = start; i$1 < end; i$1++) {
+ this.paintVertexArray.emplace(i$1, min, max);
+ }
+ this.maxValue = Math.max(this.maxValue, Math.abs(min), Math.abs(max));
+ }
+ };
+ CompositeExpressionBinder.prototype.upload = function upload(context) {
+ if (this.paintVertexArray && this.paintVertexArray.arrayBuffer) {
+ if (this.paintVertexBuffer && this.paintVertexBuffer.buffer) {
+ this.paintVertexBuffer.updateData(this.paintVertexArray);
+ } else {
+ this.paintVertexBuffer = context.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent);
+ }
+ }
+ };
+ CompositeExpressionBinder.prototype.destroy = function destroy() {
+ if (this.paintVertexBuffer) {
+ this.paintVertexBuffer.destroy();
+ }
+ };
+ CompositeExpressionBinder.prototype.setUniform = function setUniform(uniform, globals) {
+ var currentZoom = this.useIntegerZoom ? Math.floor(globals.zoom) : globals.zoom;
+ var factor = clamp(this.expression.interpolationFactor(currentZoom, this.zoom, this.zoom + 1), 0, 1);
+ uniform.set(factor);
+ };
+ CompositeExpressionBinder.prototype.getBinding = function getBinding(context, location2, _) {
+ return new Uniform1f(context, location2);
+ };
+ var CrossFadedCompositeBinder = function CrossFadedCompositeBinder2(expression2, type, useIntegerZoom, zoom, PaintVertexArray, layerId) {
+ this.expression = expression2;
+ this.type = type;
+ this.useIntegerZoom = useIntegerZoom;
+ this.zoom = zoom;
+ this.layerId = layerId;
+ this.zoomInPaintVertexArray = new PaintVertexArray();
+ this.zoomOutPaintVertexArray = new PaintVertexArray();
+ };
+ CrossFadedCompositeBinder.prototype.populatePaintArray = function populatePaintArray(length, feature, imagePositions) {
+ var start = this.zoomInPaintVertexArray.length;
+ this.zoomInPaintVertexArray.resize(length);
+ this.zoomOutPaintVertexArray.resize(length);
+ this._setPaintValues(start, length, feature.patterns && feature.patterns[this.layerId], imagePositions);
+ };
+ CrossFadedCompositeBinder.prototype.updatePaintArray = function updatePaintArray(start, end, feature, featureState, imagePositions) {
+ this._setPaintValues(start, end, feature.patterns && feature.patterns[this.layerId], imagePositions);
+ };
+ CrossFadedCompositeBinder.prototype._setPaintValues = function _setPaintValues(start, end, patterns, positions) {
+ if (!positions || !patterns) {
+ return;
+ }
+ var min = patterns.min;
+ var mid = patterns.mid;
+ var max = patterns.max;
+ var imageMin = positions[min];
+ var imageMid = positions[mid];
+ var imageMax = positions[max];
+ if (!imageMin || !imageMid || !imageMax) {
+ return;
+ }
+ for (var i = start; i < end; i++) {
+ this.zoomInPaintVertexArray.emplace(i, imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1], imageMin.tl[0], imageMin.tl[1], imageMin.br[0], imageMin.br[1], imageMid.pixelRatio, imageMin.pixelRatio);
+ this.zoomOutPaintVertexArray.emplace(i, imageMid.tl[0], imageMid.tl[1], imageMid.br[0], imageMid.br[1], imageMax.tl[0], imageMax.tl[1], imageMax.br[0], imageMax.br[1], imageMid.pixelRatio, imageMax.pixelRatio);
+ }
+ };
+ CrossFadedCompositeBinder.prototype.upload = function upload(context) {
+ if (this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer) {
+ this.zoomInPaintVertexBuffer = context.createVertexBuffer(this.zoomInPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);
+ this.zoomOutPaintVertexBuffer = context.createVertexBuffer(this.zoomOutPaintVertexArray, patternAttributes.members, this.expression.isStateDependent);
+ }
+ };
+ CrossFadedCompositeBinder.prototype.destroy = function destroy() {
+ if (this.zoomOutPaintVertexBuffer) {
+ this.zoomOutPaintVertexBuffer.destroy();
+ }
+ if (this.zoomInPaintVertexBuffer) {
+ this.zoomInPaintVertexBuffer.destroy();
+ }
+ };
+ var ProgramConfiguration = function ProgramConfiguration2(layer2, zoom, filterProperties) {
+ this.binders = {};
+ this._buffers = [];
+ var keys = [];
+ for (var property in layer2.paint._values) {
+ if (!filterProperties(property)) {
+ continue;
+ }
+ var value = layer2.paint.get(property);
+ if (!(value instanceof PossiblyEvaluatedPropertyValue) || !supportsPropertyExpression(value.property.specification)) {
+ continue;
+ }
+ var names2 = paintAttributeNames(property, layer2.type);
+ var expression2 = value.value;
+ var type = value.property.specification.type;
+ var useIntegerZoom = value.property.useIntegerZoom;
+ var propType = value.property.specification["property-type"];
+ var isCrossFaded = propType === "cross-faded" || propType === "cross-faded-data-driven";
+ if (expression2.kind === "constant") {
+ this.binders[property] = isCrossFaded ? new CrossFadedConstantBinder(expression2.value, names2) : new ConstantBinder(expression2.value, names2, type);
+ keys.push("/u_" + property);
+ } else if (expression2.kind === "source" || isCrossFaded) {
+ var StructArrayLayout = layoutType(property, type, "source");
+ this.binders[property] = isCrossFaded ? new CrossFadedCompositeBinder(expression2, type, useIntegerZoom, zoom, StructArrayLayout, layer2.id) : new SourceExpressionBinder(expression2, names2, type, StructArrayLayout);
+ keys.push("/a_" + property);
+ } else {
+ var StructArrayLayout$1 = layoutType(property, type, "composite");
+ this.binders[property] = new CompositeExpressionBinder(expression2, names2, type, useIntegerZoom, zoom, StructArrayLayout$1);
+ keys.push("/z_" + property);
+ }
+ }
+ this.cacheKey = keys.sort().join("");
+ };
+ ProgramConfiguration.prototype.getMaxValue = function getMaxValue(property) {
+ var binder = this.binders[property];
+ return binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder ? binder.maxValue : 0;
+ };
+ ProgramConfiguration.prototype.populatePaintArrays = function populatePaintArrays(newLength, feature, imagePositions, canonical, formattedSection) {
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) {
+ binder.populatePaintArray(newLength, feature, imagePositions, canonical, formattedSection);
+ }
+ }
+ };
+ ProgramConfiguration.prototype.setConstantPatternPositions = function setConstantPatternPositions(posTo, posFrom) {
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if (binder instanceof CrossFadedConstantBinder) {
+ binder.setConstantPatternPositions(posTo, posFrom);
+ }
+ }
+ };
+ ProgramConfiguration.prototype.updatePaintArrays = function updatePaintArrays(featureStates, featureMap, vtLayer, layer2, imagePositions) {
+ var dirty = false;
+ for (var id2 in featureStates) {
+ var positions = featureMap.getPositions(id2);
+ for (var i = 0, list = positions; i < list.length; i += 1) {
+ var pos = list[i];
+ var feature = vtLayer.feature(pos.index);
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) && binder.expression.isStateDependent === true) {
+ var value = layer2.paint.get(property);
+ binder.expression = value.value;
+ binder.updatePaintArray(pos.start, pos.end, feature, featureStates[id2], imagePositions);
+ dirty = true;
+ }
+ }
+ }
+ }
+ return dirty;
+ };
+ ProgramConfiguration.prototype.defines = function defines() {
+ var result = [];
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) {
+ result.push.apply(result, binder.uniformNames.map(function(name3) {
+ return "#define HAS_UNIFORM_" + name3;
+ }));
+ }
+ }
+ return result;
+ };
+ ProgramConfiguration.prototype.getBinderAttributes = function getBinderAttributes() {
+ var result = [];
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) {
+ for (var i = 0; i < binder.paintVertexAttributes.length; i++) {
+ result.push(binder.paintVertexAttributes[i].name);
+ }
+ } else if (binder instanceof CrossFadedCompositeBinder) {
+ for (var i$1 = 0; i$1 < patternAttributes.members.length; i$1++) {
+ result.push(patternAttributes.members[i$1].name);
+ }
+ }
+ }
+ return result;
+ };
+ ProgramConfiguration.prototype.getBinderUniforms = function getBinderUniforms() {
+ var uniforms = [];
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {
+ for (var i = 0, list = binder.uniformNames; i < list.length; i += 1) {
+ var uniformName = list[i];
+ uniforms.push(uniformName);
+ }
+ }
+ }
+ return uniforms;
+ };
+ ProgramConfiguration.prototype.getPaintVertexBuffers = function getPaintVertexBuffers() {
+ return this._buffers;
+ };
+ ProgramConfiguration.prototype.getUniforms = function getUniforms(context, locations) {
+ var uniforms = [];
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder || binder instanceof CompositeExpressionBinder) {
+ for (var i = 0, list = binder.uniformNames; i < list.length; i += 1) {
+ var name3 = list[i];
+ if (locations[name3]) {
+ var binding = binder.getBinding(context, locations[name3], name3);
+ uniforms.push({
+ name: name3,
+ property,
+ binding
+ });
+ }
+ }
+ }
+ }
+ return uniforms;
+ };
+ ProgramConfiguration.prototype.setUniforms = function setUniforms(context, binderUniforms, properties2, globals) {
+ for (var i = 0, list = binderUniforms; i < list.length; i += 1) {
+ var ref = list[i];
+ var name3 = ref.name;
+ var property = ref.property;
+ var binding = ref.binding;
+ this.binders[property].setUniform(binding, globals, properties2.get(property), name3);
+ }
+ };
+ ProgramConfiguration.prototype.updatePaintBuffers = function updatePaintBuffers(crossfade) {
+ this._buffers = [];
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if (crossfade && binder instanceof CrossFadedCompositeBinder) {
+ var patternVertexBuffer = crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer;
+ if (patternVertexBuffer) {
+ this._buffers.push(patternVertexBuffer);
+ }
+ } else if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) && binder.paintVertexBuffer) {
+ this._buffers.push(binder.paintVertexBuffer);
+ }
+ }
+ };
+ ProgramConfiguration.prototype.upload = function upload(context) {
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) {
+ binder.upload(context);
+ }
+ }
+ this.updatePaintBuffers();
+ };
+ ProgramConfiguration.prototype.destroy = function destroy() {
+ for (var property in this.binders) {
+ var binder = this.binders[property];
+ if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder) {
+ binder.destroy();
+ }
+ }
+ };
+ var ProgramConfigurationSet = function ProgramConfigurationSet2(layers, zoom, filterProperties) {
+ if (filterProperties === void 0)
+ filterProperties = function() {
+ return true;
+ };
+ this.programConfigurations = {};
+ for (var i = 0, list = layers; i < list.length; i += 1) {
+ var layer2 = list[i];
+ this.programConfigurations[layer2.id] = new ProgramConfiguration(layer2, zoom, filterProperties);
+ }
+ this.needsUpload = false;
+ this._featureMap = new FeaturePositionMap();
+ this._bufferOffset = 0;
+ };
+ ProgramConfigurationSet.prototype.populatePaintArrays = function populatePaintArrays(length, feature, index, imagePositions, canonical, formattedSection) {
+ for (var key in this.programConfigurations) {
+ this.programConfigurations[key].populatePaintArrays(length, feature, imagePositions, canonical, formattedSection);
+ }
+ if (feature.id !== void 0) {
+ this._featureMap.add(feature.id, index, this._bufferOffset, length);
+ }
+ this._bufferOffset = length;
+ this.needsUpload = true;
+ };
+ ProgramConfigurationSet.prototype.updatePaintArrays = function updatePaintArrays(featureStates, vtLayer, layers, imagePositions) {
+ for (var i = 0, list = layers; i < list.length; i += 1) {
+ var layer2 = list[i];
+ this.needsUpload = this.programConfigurations[layer2.id].updatePaintArrays(featureStates, this._featureMap, vtLayer, layer2, imagePositions) || this.needsUpload;
+ }
+ };
+ ProgramConfigurationSet.prototype.get = function get2(layerId) {
+ return this.programConfigurations[layerId];
+ };
+ ProgramConfigurationSet.prototype.upload = function upload(context) {
+ if (!this.needsUpload) {
+ return;
+ }
+ for (var layerId in this.programConfigurations) {
+ this.programConfigurations[layerId].upload(context);
+ }
+ this.needsUpload = false;
+ };
+ ProgramConfigurationSet.prototype.destroy = function destroy() {
+ for (var layerId in this.programConfigurations) {
+ this.programConfigurations[layerId].destroy();
+ }
+ };
+ function paintAttributeNames(property, type) {
+ var attributeNameExceptions = {
+ "text-opacity": ["opacity"],
+ "icon-opacity": ["opacity"],
+ "text-color": ["fill_color"],
+ "icon-color": ["fill_color"],
+ "text-halo-color": ["halo_color"],
+ "icon-halo-color": ["halo_color"],
+ "text-halo-blur": ["halo_blur"],
+ "icon-halo-blur": ["halo_blur"],
+ "text-halo-width": ["halo_width"],
+ "icon-halo-width": ["halo_width"],
+ "line-gap-width": ["gapwidth"],
+ "line-pattern": [
+ "pattern_to",
+ "pattern_from",
+ "pixel_ratio_to",
+ "pixel_ratio_from"
+ ],
+ "fill-pattern": [
+ "pattern_to",
+ "pattern_from",
+ "pixel_ratio_to",
+ "pixel_ratio_from"
+ ],
+ "fill-extrusion-pattern": [
+ "pattern_to",
+ "pattern_from",
+ "pixel_ratio_to",
+ "pixel_ratio_from"
+ ]
+ };
+ return attributeNameExceptions[property] || [property.replace(type + "-", "").replace(/-/g, "_")];
+ }
+ function getLayoutException(property) {
+ var propertyExceptions = {
+ "line-pattern": {
+ "source": StructArrayLayout10ui20,
+ "composite": StructArrayLayout10ui20
+ },
+ "fill-pattern": {
+ "source": StructArrayLayout10ui20,
+ "composite": StructArrayLayout10ui20
+ },
+ "fill-extrusion-pattern": {
+ "source": StructArrayLayout10ui20,
+ "composite": StructArrayLayout10ui20
+ }
+ };
+ return propertyExceptions[property];
+ }
+ function layoutType(property, type, binderType) {
+ var defaultLayouts = {
+ "color": {
+ "source": StructArrayLayout2f8,
+ "composite": StructArrayLayout4f16
+ },
+ "number": {
+ "source": StructArrayLayout1f4,
+ "composite": StructArrayLayout2f8
+ }
+ };
+ var layoutException = getLayoutException(property);
+ return layoutException && layoutException[binderType] || defaultLayouts[type][binderType];
+ }
+ register("ConstantBinder", ConstantBinder);
+ register("CrossFadedConstantBinder", CrossFadedConstantBinder);
+ register("SourceExpressionBinder", SourceExpressionBinder);
+ register("CrossFadedCompositeBinder", CrossFadedCompositeBinder);
+ register("CompositeExpressionBinder", CompositeExpressionBinder);
+ register("ProgramConfiguration", ProgramConfiguration, { omit: ["_buffers"] });
+ register("ProgramConfigurationSet", ProgramConfigurationSet);
+ var EXTENT$1 = 8192;
+ var BITS = 15;
+ var MAX = Math.pow(2, BITS - 1) - 1;
+ var MIN = -MAX - 1;
+ function loadGeometry(feature) {
+ var scale2 = EXTENT$1 / feature.extent;
+ var geometry = feature.loadGeometry();
+ for (var r = 0; r < geometry.length; r++) {
+ var ring = geometry[r];
+ for (var p = 0; p < ring.length; p++) {
+ var point = ring[p];
+ var x = Math.round(point.x * scale2);
+ var y = Math.round(point.y * scale2);
+ point.x = clamp(x, MIN, MAX);
+ point.y = clamp(y, MIN, MAX);
+ if (x < point.x || x > point.x + 1 || y < point.y || y > point.y + 1) {
+ warnOnce("Geometry exceeds allowed extent, reduce your vector tile buffer size");
+ }
+ }
+ }
+ return geometry;
+ }
+ function toEvaluationFeature(feature, needGeometry) {
+ return {
+ type: feature.type,
+ id: feature.id,
+ properties: feature.properties,
+ geometry: needGeometry ? loadGeometry(feature) : []
+ };
+ }
+ function addCircleVertex(layoutVertexArray, x, y, extrudeX, extrudeY) {
+ layoutVertexArray.emplaceBack(x * 2 + (extrudeX + 1) / 2, y * 2 + (extrudeY + 1) / 2);
+ }
+ var CircleBucket = function CircleBucket2(options) {
+ this.zoom = options.zoom;
+ this.overscaling = options.overscaling;
+ this.layers = options.layers;
+ this.layerIds = this.layers.map(function(layer2) {
+ return layer2.id;
+ });
+ this.index = options.index;
+ this.hasPattern = false;
+ this.layoutVertexArray = new StructArrayLayout2i4();
+ this.indexArray = new StructArrayLayout3ui6();
+ this.segments = new SegmentVector();
+ this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);
+ this.stateDependentLayerIds = this.layers.filter(function(l) {
+ return l.isStateDependent();
+ }).map(function(l) {
+ return l.id;
+ });
+ };
+ CircleBucket.prototype.populate = function populate(features, options, canonical) {
+ var styleLayer = this.layers[0];
+ var bucketFeatures = [];
+ var circleSortKey = null;
+ if (styleLayer.type === "circle") {
+ circleSortKey = styleLayer.layout.get("circle-sort-key");
+ }
+ for (var i = 0, list = features; i < list.length; i += 1) {
+ var ref = list[i];
+ var feature = ref.feature;
+ var id2 = ref.id;
+ var index = ref.index;
+ var sourceLayerIndex = ref.sourceLayerIndex;
+ var needGeometry = this.layers[0]._featureFilter.needGeometry;
+ var evaluationFeature = toEvaluationFeature(feature, needGeometry);
+ if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) {
+ continue;
+ }
+ var sortKey = circleSortKey ? circleSortKey.evaluate(evaluationFeature, {}, canonical) : void 0;
+ var bucketFeature = {
+ id: id2,
+ properties: feature.properties,
+ type: feature.type,
+ sourceLayerIndex,
+ index,
+ geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),
+ patterns: {},
+ sortKey
+ };
+ bucketFeatures.push(bucketFeature);
+ }
+ if (circleSortKey) {
+ bucketFeatures.sort(function(a, b) {
+ return a.sortKey - b.sortKey;
+ });
+ }
+ for (var i$1 = 0, list$1 = bucketFeatures; i$1 < list$1.length; i$1 += 1) {
+ var bucketFeature$1 = list$1[i$1];
+ var ref$1 = bucketFeature$1;
+ var geometry = ref$1.geometry;
+ var index$1 = ref$1.index;
+ var sourceLayerIndex$1 = ref$1.sourceLayerIndex;
+ var feature$1 = features[index$1].feature;
+ this.addFeature(bucketFeature$1, geometry, index$1, canonical);
+ options.featureIndex.insert(feature$1, geometry, index$1, sourceLayerIndex$1, this.index);
+ }
+ };
+ CircleBucket.prototype.update = function update(states, vtLayer, imagePositions) {
+ if (!this.stateDependentLayers.length) {
+ return;
+ }
+ this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);
+ };
+ CircleBucket.prototype.isEmpty = function isEmpty2() {
+ return this.layoutVertexArray.length === 0;
+ };
+ CircleBucket.prototype.uploadPending = function uploadPending() {
+ return !this.uploaded || this.programConfigurations.needsUpload;
+ };
+ CircleBucket.prototype.upload = function upload(context) {
+ if (!this.uploaded) {
+ this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, members);
+ this.indexBuffer = context.createIndexBuffer(this.indexArray);
+ }
+ this.programConfigurations.upload(context);
+ this.uploaded = true;
+ };
+ CircleBucket.prototype.destroy = function destroy() {
+ if (!this.layoutVertexBuffer) {
+ return;
+ }
+ this.layoutVertexBuffer.destroy();
+ this.indexBuffer.destroy();
+ this.programConfigurations.destroy();
+ this.segments.destroy();
+ };
+ CircleBucket.prototype.addFeature = function addFeature2(feature, geometry, index, canonical) {
+ for (var i$1 = 0, list$1 = geometry; i$1 < list$1.length; i$1 += 1) {
+ var ring = list$1[i$1];
+ for (var i = 0, list = ring; i < list.length; i += 1) {
+ var point = list[i];
+ var x = point.x;
+ var y = point.y;
+ if (x < 0 || x >= EXTENT$1 || y < 0 || y >= EXTENT$1) {
+ continue;
+ }
+ var segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, feature.sortKey);
+ var index$1 = segment.vertexLength;
+ addCircleVertex(this.layoutVertexArray, x, y, -1, -1);
+ addCircleVertex(this.layoutVertexArray, x, y, 1, -1);
+ addCircleVertex(this.layoutVertexArray, x, y, 1, 1);
+ addCircleVertex(this.layoutVertexArray, x, y, -1, 1);
+ this.indexArray.emplaceBack(index$1, index$1 + 1, index$1 + 2);
+ this.indexArray.emplaceBack(index$1, index$1 + 3, index$1 + 2);
+ segment.vertexLength += 4;
+ segment.primitiveLength += 2;
+ }
+ }
+ this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, {}, canonical);
+ };
+ register("CircleBucket", CircleBucket, { omit: ["layers"] });
+ function polygonIntersectsPolygon(polygonA, polygonB) {
+ for (var i = 0; i < polygonA.length; i++) {
+ if (polygonContainsPoint(polygonB, polygonA[i])) {
+ return true;
+ }
+ }
+ for (var i$1 = 0; i$1 < polygonB.length; i$1++) {
+ if (polygonContainsPoint(polygonA, polygonB[i$1])) {
+ return true;
+ }
+ }
+ if (lineIntersectsLine(polygonA, polygonB)) {
+ return true;
+ }
+ return false;
+ }
+ function polygonIntersectsBufferedPoint(polygon, point, radius) {
+ if (polygonContainsPoint(polygon, point)) {
+ return true;
+ }
+ if (pointIntersectsBufferedLine(point, polygon, radius)) {
+ return true;
+ }
+ return false;
+ }
+ function polygonIntersectsMultiPolygon(polygon, multiPolygon) {
+ if (polygon.length === 1) {
+ return multiPolygonContainsPoint(multiPolygon, polygon[0]);
+ }
+ for (var m = 0; m < multiPolygon.length; m++) {
+ var ring = multiPolygon[m];
+ for (var n = 0; n < ring.length; n++) {
+ if (polygonContainsPoint(polygon, ring[n])) {
+ return true;
+ }
+ }
+ }
+ for (var i = 0; i < polygon.length; i++) {
+ if (multiPolygonContainsPoint(multiPolygon, polygon[i])) {
+ return true;
+ }
+ }
+ for (var k = 0; k < multiPolygon.length; k++) {
+ if (lineIntersectsLine(polygon, multiPolygon[k])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function polygonIntersectsBufferedMultiLine(polygon, multiLine, radius) {
+ for (var i = 0; i < multiLine.length; i++) {
+ var line = multiLine[i];
+ if (polygon.length >= 3) {
+ for (var k = 0; k < line.length; k++) {
+ if (polygonContainsPoint(polygon, line[k])) {
+ return true;
+ }
+ }
+ }
+ if (lineIntersectsBufferedLine(polygon, line, radius)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function lineIntersectsBufferedLine(lineA, lineB, radius) {
+ if (lineA.length > 1) {
+ if (lineIntersectsLine(lineA, lineB)) {
+ return true;
+ }
+ for (var j = 0; j < lineB.length; j++) {
+ if (pointIntersectsBufferedLine(lineB[j], lineA, radius)) {
+ return true;
+ }
+ }
+ }
+ for (var k = 0; k < lineA.length; k++) {
+ if (pointIntersectsBufferedLine(lineA[k], lineB, radius)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function lineIntersectsLine(lineA, lineB) {
+ if (lineA.length === 0 || lineB.length === 0) {
+ return false;
+ }
+ for (var i = 0; i < lineA.length - 1; i++) {
+ var a0 = lineA[i];
+ var a1 = lineA[i + 1];
+ for (var j = 0; j < lineB.length - 1; j++) {
+ var b0 = lineB[j];
+ var b1 = lineB[j + 1];
+ if (lineSegmentIntersectsLineSegment(a0, a1, b0, b1)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ function lineSegmentIntersectsLineSegment(a0, a1, b0, b1) {
+ return isCounterClockwise(a0, b0, b1) !== isCounterClockwise(a1, b0, b1) && isCounterClockwise(a0, a1, b0) !== isCounterClockwise(a0, a1, b1);
+ }
+ function pointIntersectsBufferedLine(p, line, radius) {
+ var radiusSquared = radius * radius;
+ if (line.length === 1) {
+ return p.distSqr(line[0]) < radiusSquared;
+ }
+ for (var i = 1; i < line.length; i++) {
+ var v = line[i - 1], w = line[i];
+ if (distToSegmentSquared(p, v, w) < radiusSquared) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function distToSegmentSquared(p, v, w) {
+ var l2 = v.distSqr(w);
+ if (l2 === 0) {
+ return p.distSqr(v);
+ }
+ var t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
+ if (t < 0) {
+ return p.distSqr(v);
+ }
+ if (t > 1) {
+ return p.distSqr(w);
+ }
+ return p.distSqr(w.sub(v)._mult(t)._add(v));
+ }
+ function multiPolygonContainsPoint(rings, p) {
+ var c = false, ring, p1, p2;
+ for (var k = 0; k < rings.length; k++) {
+ ring = rings[k];
+ for (var i = 0, j = ring.length - 1; i < ring.length; j = i++) {
+ p1 = ring[i];
+ p2 = ring[j];
+ if (p1.y > p.y !== p2.y > p.y && p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x) {
+ c = !c;
+ }
+ }
+ }
+ return c;
+ }
+ function polygonContainsPoint(ring, p) {
+ var c = false;
+ for (var i = 0, j = ring.length - 1; i < ring.length; j = i++) {
+ var p1 = ring[i];
+ var p2 = ring[j];
+ if (p1.y > p.y !== p2.y > p.y && p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x) {
+ c = !c;
+ }
+ }
+ return c;
+ }
+ function polygonIntersectsBox(ring, boxX1, boxY1, boxX2, boxY2) {
+ for (var i$1 = 0, list = ring; i$1 < list.length; i$1 += 1) {
+ var p = list[i$1];
+ if (boxX1 <= p.x && boxY1 <= p.y && boxX2 >= p.x && boxY2 >= p.y) {
+ return true;
+ }
+ }
+ var corners = [
+ new pointGeometry(boxX1, boxY1),
+ new pointGeometry(boxX1, boxY2),
+ new pointGeometry(boxX2, boxY2),
+ new pointGeometry(boxX2, boxY1)
+ ];
+ if (ring.length > 2) {
+ for (var i$2 = 0, list$1 = corners; i$2 < list$1.length; i$2 += 1) {
+ var corner = list$1[i$2];
+ if (polygonContainsPoint(ring, corner)) {
+ return true;
+ }
+ }
+ }
+ for (var i = 0; i < ring.length - 1; i++) {
+ var p1 = ring[i];
+ var p2 = ring[i + 1];
+ if (edgeIntersectsBox(p1, p2, corners)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function edgeIntersectsBox(e1, e2, corners) {
+ var tl = corners[0];
+ var br = corners[2];
+ if (e1.x < tl.x && e2.x < tl.x || e1.x > br.x && e2.x > br.x || e1.y < tl.y && e2.y < tl.y || e1.y > br.y && e2.y > br.y) {
+ return false;
+ }
+ var dir = isCounterClockwise(e1, e2, corners[0]);
+ return dir !== isCounterClockwise(e1, e2, corners[1]) || dir !== isCounterClockwise(e1, e2, corners[2]) || dir !== isCounterClockwise(e1, e2, corners[3]);
+ }
+ function getMaximumPaintValue(property, layer2, bucket) {
+ var value = layer2.paint.get(property).value;
+ if (value.kind === "constant") {
+ return value.value;
+ } else {
+ return bucket.programConfigurations.get(layer2.id).getMaxValue(property);
+ }
+ }
+ function translateDistance(translate2) {
+ return Math.sqrt(translate2[0] * translate2[0] + translate2[1] * translate2[1]);
+ }
+ function translate(queryGeometry, translate2, translateAnchor, bearing, pixelsToTileUnits) {
+ if (!translate2[0] && !translate2[1]) {
+ return queryGeometry;
+ }
+ var pt = pointGeometry.convert(translate2)._mult(pixelsToTileUnits);
+ if (translateAnchor === "viewport") {
+ pt._rotate(-bearing);
+ }
+ var translated = [];
+ for (var i = 0; i < queryGeometry.length; i++) {
+ var point = queryGeometry[i];
+ translated.push(point.sub(pt));
+ }
+ return translated;
+ }
+ var layout$2 = new Properties({ "circle-sort-key": new DataDrivenProperty(spec["layout_circle"]["circle-sort-key"]) });
+ var paint$1 = new Properties({
+ "circle-radius": new DataDrivenProperty(spec["paint_circle"]["circle-radius"]),
+ "circle-color": new DataDrivenProperty(spec["paint_circle"]["circle-color"]),
+ "circle-blur": new DataDrivenProperty(spec["paint_circle"]["circle-blur"]),
+ "circle-opacity": new DataDrivenProperty(spec["paint_circle"]["circle-opacity"]),
+ "circle-translate": new DataConstantProperty(spec["paint_circle"]["circle-translate"]),
+ "circle-translate-anchor": new DataConstantProperty(spec["paint_circle"]["circle-translate-anchor"]),
+ "circle-pitch-scale": new DataConstantProperty(spec["paint_circle"]["circle-pitch-scale"]),
+ "circle-pitch-alignment": new DataConstantProperty(spec["paint_circle"]["circle-pitch-alignment"]),
+ "circle-stroke-width": new DataDrivenProperty(spec["paint_circle"]["circle-stroke-width"]),
+ "circle-stroke-color": new DataDrivenProperty(spec["paint_circle"]["circle-stroke-color"]),
+ "circle-stroke-opacity": new DataDrivenProperty(spec["paint_circle"]["circle-stroke-opacity"])
+ });
+ var properties = {
+ paint: paint$1,
+ layout: layout$2
+ };
+ var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
+ if (!Math.hypot) {
+ Math.hypot = function() {
+ var arguments$1 = arguments;
+ var y = 0, i = arguments.length;
+ while (i--) {
+ y += arguments$1[i] * arguments$1[i];
+ }
+ return Math.sqrt(y);
+ };
+ }
+ function create() {
+ var out = new ARRAY_TYPE(4);
+ if (ARRAY_TYPE != Float32Array) {
+ out[1] = 0;
+ out[2] = 0;
+ }
+ out[0] = 1;
+ out[3] = 1;
+ return out;
+ }
+ function rotate(out, a, rad) {
+ var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
+ var s = Math.sin(rad);
+ var c = Math.cos(rad);
+ out[0] = a0 * c + a2 * s;
+ out[1] = a1 * c + a3 * s;
+ out[2] = a0 * -s + a2 * c;
+ out[3] = a1 * -s + a3 * c;
+ return out;
+ }
+ function create$1() {
+ var out = new ARRAY_TYPE(9);
+ if (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;
+ return out;
+ }
+ function fromRotation(out, rad) {
+ var s = Math.sin(rad), c = Math.cos(rad);
+ 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;
+ return out;
+ }
+ function create$2() {
+ var out = new ARRAY_TYPE(16);
+ if (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;
+ return out;
+ }
+ function clone$1(a) {
+ var out = new ARRAY_TYPE(16);
+ 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 identity2(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 invert(out, a) {
+ var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
+ var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
+ var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
+ var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
+ var b00 = a00 * a11 - a01 * a10;
+ var b01 = a00 * a12 - a02 * a10;
+ var b02 = a00 * a13 - a03 * a10;
+ var b03 = a01 * a12 - a02 * a11;
+ var b04 = a01 * a13 - a03 * a11;
+ var b05 = a02 * a13 - a03 * a12;
+ var b06 = a20 * a31 - a21 * a30;
+ var b07 = a20 * a32 - a22 * a30;
+ var b08 = a20 * a33 - a23 * a30;
+ var b09 = a21 * a32 - a22 * a31;
+ var b10 = a21 * a33 - a23 * a31;
+ var b11 = a22 * a33 - a23 * a32;
+ var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+ if (!det) {
+ return null;
+ }
+ det = 1 / 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 multiply(out, a, b) {
+ var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
+ var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
+ var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
+ var 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 translate$1(out, a, v) {
+ var x = v[0], y = v[1], z = v[2];
+ var a00, a01, a02, a03;
+ var a10, a11, a12, a13;
+ var 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);
+ var c = Math.cos(rad);
+ var a10 = a[4];
+ var a11 = a[5];
+ var a12 = a[6];
+ var a13 = a[7];
+ var a20 = a[8];
+ var a21 = a[9];
+ var a22 = a[10];
+ var 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);
+ var c = Math.cos(rad);
+ var a00 = a[0];
+ var a01 = a[1];
+ var a02 = a[2];
+ var a03 = a[3];
+ var a10 = a[4];
+ var a11 = a[5];
+ var a12 = a[6];
+ var 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 perspective(out, fovy, aspect, near, far) {
+ var f = 1 / Math.tan(fovy / 2), nf;
+ 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;
+ if (far != null && far !== Infinity) {
+ nf = 1 / (near - far);
+ out[10] = (far + near) * nf;
+ out[14] = 2 * far * near * nf;
+ } else {
+ out[10] = -1;
+ out[14] = -2 * near;
+ }
+ return out;
+ }
+ function ortho(out, left, right, bottom, top, near, far) {
+ var lr = 1 / (left - right);
+ var bt = 1 / (bottom - top);
+ var nf = 1 / (near - far);
+ 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;
+ return out;
+ }
+ var mul = multiply;
+ function create$3() {
+ var out = new ARRAY_TYPE(3);
+ if (ARRAY_TYPE != Float32Array) {
+ out[0] = 0;
+ out[1] = 0;
+ out[2] = 0;
+ }
+ return out;
+ }
+ function clone$2(a) {
+ var out = new ARRAY_TYPE(3);
+ out[0] = a[0];
+ out[1] = a[1];
+ out[2] = a[2];
+ 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 scale$1(out, a, b) {
+ out[0] = a[0] * b;
+ out[1] = a[1] * b;
+ out[2] = a[2] * b;
+ return out;
+ }
+ function normalize(out, a) {
+ var x = a[0];
+ var y = a[1];
+ var 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 cross(out, a, b) {
+ var ax = a[0], ay = a[1], az = a[2];
+ var 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 transformMat3(out, a, m) {
+ var x = a[0], y = a[1], z = a[2];
+ 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];
+ return out;
+ }
+ var sub = subtract;
+ var forEach = function() {
+ var vec = create$3();
+ return function(a, stride, offset, count, fn, arg) {
+ var i, l;
+ if (!stride) {
+ stride = 3;
+ }
+ if (!offset) {
+ offset = 0;
+ }
+ if (count) {
+ l = Math.min(count * stride + offset, a.length);
+ } else {
+ l = a.length;
+ }
+ for (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;
+ };
+ }();
+ function create$4() {
+ var out = new ARRAY_TYPE(4);
+ if (ARRAY_TYPE != Float32Array) {
+ out[0] = 0;
+ out[1] = 0;
+ out[2] = 0;
+ out[3] = 0;
+ }
+ return out;
+ }
+ function scale$2(out, a, b) {
+ out[0] = a[0] * b;
+ out[1] = a[1] * b;
+ out[2] = a[2] * b;
+ out[3] = a[3] * b;
+ return out;
+ }
+ function dot$1(a, b) {
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
+ }
+ function transformMat4(out, a, m) {
+ var x = a[0], y = a[1], z = a[2], w = a[3];
+ 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;
+ return out;
+ }
+ var forEach$1 = function() {
+ var vec = create$4();
+ return function(a, stride, offset, count, fn, arg) {
+ var i, l;
+ if (!stride) {
+ stride = 4;
+ }
+ if (!offset) {
+ offset = 0;
+ }
+ if (count) {
+ l = Math.min(count * stride + offset, a.length);
+ } else {
+ l = a.length;
+ }
+ for (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;
+ };
+ }();
+ function create$5() {
+ var out = new ARRAY_TYPE(2);
+ if (ARRAY_TYPE != Float32Array) {
+ out[0] = 0;
+ out[1] = 0;
+ }
+ return out;
+ }
+ function squaredLength(a) {
+ var x = a[0], y = a[1];
+ return x * x + y * y;
+ }
+ var sqrLen = squaredLength;
+ var forEach$2 = function() {
+ var vec = create$5();
+ return function(a, stride, offset, count, fn, arg) {
+ var i, l;
+ if (!stride) {
+ stride = 2;
+ }
+ if (!offset) {
+ offset = 0;
+ }
+ if (count) {
+ l = Math.min(count * stride + offset, a.length);
+ } else {
+ l = a.length;
+ }
+ for (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;
+ };
+ }();
+ var CircleStyleLayer = function(StyleLayer2) {
+ function CircleStyleLayer2(layer2) {
+ StyleLayer2.call(this, layer2, properties);
+ }
+ if (StyleLayer2)
+ CircleStyleLayer2.__proto__ = StyleLayer2;
+ CircleStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ CircleStyleLayer2.prototype.constructor = CircleStyleLayer2;
+ CircleStyleLayer2.prototype.createBucket = function createBucket(parameters) {
+ return new CircleBucket(parameters);
+ };
+ CircleStyleLayer2.prototype.queryRadius = function queryRadius(bucket) {
+ var circleBucket = bucket;
+ return getMaximumPaintValue("circle-radius", this, circleBucket) + getMaximumPaintValue("circle-stroke-width", this, circleBucket) + translateDistance(this.paint.get("circle-translate"));
+ };
+ CircleStyleLayer2.prototype.queryIntersectsFeature = function queryIntersectsFeature(queryGeometry, feature, featureState, geometry, zoom, transform, pixelsToTileUnits, pixelPosMatrix) {
+ var translatedPolygon = translate(queryGeometry, this.paint.get("circle-translate"), this.paint.get("circle-translate-anchor"), transform.angle, pixelsToTileUnits);
+ var radius = this.paint.get("circle-radius").evaluate(feature, featureState);
+ var stroke = this.paint.get("circle-stroke-width").evaluate(feature, featureState);
+ var size = radius + stroke;
+ var alignWithMap = this.paint.get("circle-pitch-alignment") === "map";
+ var transformedPolygon = alignWithMap ? translatedPolygon : projectQueryGeometry(translatedPolygon, pixelPosMatrix);
+ var transformedSize = alignWithMap ? size * pixelsToTileUnits : size;
+ for (var i$1 = 0, list$1 = geometry; i$1 < list$1.length; i$1 += 1) {
+ var ring = list$1[i$1];
+ for (var i = 0, list = ring; i < list.length; i += 1) {
+ var point = list[i];
+ var transformedPoint = alignWithMap ? point : projectPoint(point, pixelPosMatrix);
+ var adjustedSize = transformedSize;
+ var projectedCenter = transformMat4([], [
+ point.x,
+ point.y,
+ 0,
+ 1
+ ], pixelPosMatrix);
+ if (this.paint.get("circle-pitch-scale") === "viewport" && this.paint.get("circle-pitch-alignment") === "map") {
+ adjustedSize *= projectedCenter[3] / transform.cameraToCenterDistance;
+ } else if (this.paint.get("circle-pitch-scale") === "map" && this.paint.get("circle-pitch-alignment") === "viewport") {
+ adjustedSize *= transform.cameraToCenterDistance / projectedCenter[3];
+ }
+ if (polygonIntersectsBufferedPoint(transformedPolygon, transformedPoint, adjustedSize)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+ return CircleStyleLayer2;
+ }(StyleLayer);
+ function projectPoint(p, pixelPosMatrix) {
+ var point = transformMat4([], [
+ p.x,
+ p.y,
+ 0,
+ 1
+ ], pixelPosMatrix);
+ return new pointGeometry(point[0] / point[3], point[1] / point[3]);
+ }
+ function projectQueryGeometry(queryGeometry, pixelPosMatrix) {
+ return queryGeometry.map(function(p) {
+ return projectPoint(p, pixelPosMatrix);
+ });
+ }
+ var HeatmapBucket = function(CircleBucket2) {
+ function HeatmapBucket2() {
+ CircleBucket2.apply(this, arguments);
+ }
+ if (CircleBucket2)
+ HeatmapBucket2.__proto__ = CircleBucket2;
+ HeatmapBucket2.prototype = Object.create(CircleBucket2 && CircleBucket2.prototype);
+ HeatmapBucket2.prototype.constructor = HeatmapBucket2;
+ return HeatmapBucket2;
+ }(CircleBucket);
+ register("HeatmapBucket", HeatmapBucket, { omit: ["layers"] });
+ function createImage(image, ref, channels, data) {
+ var width = ref.width;
+ var height = ref.height;
+ if (!data) {
+ data = new Uint8Array(width * height * channels);
+ } else if (data instanceof Uint8ClampedArray) {
+ data = new Uint8Array(data.buffer);
+ } else if (data.length !== width * height * channels) {
+ throw new RangeError("mismatched image size");
+ }
+ image.width = width;
+ image.height = height;
+ image.data = data;
+ return image;
+ }
+ function resizeImage(image, ref, channels) {
+ var width = ref.width;
+ var height = ref.height;
+ if (width === image.width && height === image.height) {
+ return;
+ }
+ var newImage = createImage({}, {
+ width,
+ height
+ }, channels);
+ copyImage(image, newImage, {
+ x: 0,
+ y: 0
+ }, {
+ x: 0,
+ y: 0
+ }, {
+ width: Math.min(image.width, width),
+ height: Math.min(image.height, height)
+ }, channels);
+ image.width = width;
+ image.height = height;
+ image.data = newImage.data;
+ }
+ function copyImage(srcImg, dstImg, srcPt, dstPt, size, channels) {
+ if (size.width === 0 || size.height === 0) {
+ return dstImg;
+ }
+ if (size.width > srcImg.width || size.height > srcImg.height || srcPt.x > srcImg.width - size.width || srcPt.y > srcImg.height - size.height) {
+ throw new RangeError("out of range source coordinates for image copy");
+ }
+ if (size.width > dstImg.width || size.height > dstImg.height || dstPt.x > dstImg.width - size.width || dstPt.y > dstImg.height - size.height) {
+ throw new RangeError("out of range destination coordinates for image copy");
+ }
+ var srcData = srcImg.data;
+ var dstData = dstImg.data;
+ for (var y = 0; y < size.height; y++) {
+ var srcOffset = ((srcPt.y + y) * srcImg.width + srcPt.x) * channels;
+ var dstOffset = ((dstPt.y + y) * dstImg.width + dstPt.x) * channels;
+ for (var i = 0; i < size.width * channels; i++) {
+ dstData[dstOffset + i] = srcData[srcOffset + i];
+ }
+ }
+ return dstImg;
+ }
+ var AlphaImage = function AlphaImage2(size, data) {
+ createImage(this, size, 1, data);
+ };
+ AlphaImage.prototype.resize = function resize(size) {
+ resizeImage(this, size, 1);
+ };
+ AlphaImage.prototype.clone = function clone2() {
+ return new AlphaImage({
+ width: this.width,
+ height: this.height
+ }, new Uint8Array(this.data));
+ };
+ AlphaImage.copy = function copy(srcImg, dstImg, srcPt, dstPt, size) {
+ copyImage(srcImg, dstImg, srcPt, dstPt, size, 1);
+ };
+ var RGBAImage = function RGBAImage2(size, data) {
+ createImage(this, size, 4, data);
+ };
+ RGBAImage.prototype.resize = function resize(size) {
+ resizeImage(this, size, 4);
+ };
+ RGBAImage.prototype.replace = function replace(data, copy) {
+ if (copy) {
+ this.data.set(data);
+ } else if (data instanceof Uint8ClampedArray) {
+ this.data = new Uint8Array(data.buffer);
+ } else {
+ this.data = data;
+ }
+ };
+ RGBAImage.prototype.clone = function clone2() {
+ return new RGBAImage({
+ width: this.width,
+ height: this.height
+ }, new Uint8Array(this.data));
+ };
+ RGBAImage.copy = function copy(srcImg, dstImg, srcPt, dstPt, size) {
+ copyImage(srcImg, dstImg, srcPt, dstPt, size, 4);
+ };
+ register("AlphaImage", AlphaImage);
+ register("RGBAImage", RGBAImage);
+ var paint$2 = new Properties({
+ "heatmap-radius": new DataDrivenProperty(spec["paint_heatmap"]["heatmap-radius"]),
+ "heatmap-weight": new DataDrivenProperty(spec["paint_heatmap"]["heatmap-weight"]),
+ "heatmap-intensity": new DataConstantProperty(spec["paint_heatmap"]["heatmap-intensity"]),
+ "heatmap-color": new ColorRampProperty(spec["paint_heatmap"]["heatmap-color"]),
+ "heatmap-opacity": new DataConstantProperty(spec["paint_heatmap"]["heatmap-opacity"])
+ });
+ var properties$1 = { paint: paint$2 };
+ function renderColorRamp(params) {
+ var evaluationGlobals = {};
+ var width = params.resolution || 256;
+ var height = params.clips ? params.clips.length : 1;
+ var image = params.image || new RGBAImage({
+ width,
+ height
+ });
+ var renderPixel = function(stride2, index, progress2) {
+ evaluationGlobals[params.evaluationKey] = progress2;
+ var pxColor = params.expression.evaluate(evaluationGlobals);
+ image.data[stride2 + index + 0] = Math.floor(pxColor.r * 255 / pxColor.a);
+ image.data[stride2 + index + 1] = Math.floor(pxColor.g * 255 / pxColor.a);
+ image.data[stride2 + index + 2] = Math.floor(pxColor.b * 255 / pxColor.a);
+ image.data[stride2 + index + 3] = Math.floor(pxColor.a * 255);
+ };
+ if (!params.clips) {
+ for (var i = 0, j = 0; i < width; i++, j += 4) {
+ var progress = i / (width - 1);
+ renderPixel(0, j, progress);
+ }
+ } else {
+ for (var clip = 0, stride = 0; clip < height; ++clip, stride += width * 4) {
+ for (var i$1 = 0, j$1 = 0; i$1 < width; i$1++, j$1 += 4) {
+ var progress$1 = i$1 / (width - 1);
+ var ref = params.clips[clip];
+ var start = ref.start;
+ var end = ref.end;
+ var evaluationProgress = start * (1 - progress$1) + end * progress$1;
+ renderPixel(stride, j$1, evaluationProgress);
+ }
+ }
+ }
+ return image;
+ }
+ var HeatmapStyleLayer = function(StyleLayer2) {
+ function HeatmapStyleLayer2(layer2) {
+ StyleLayer2.call(this, layer2, properties$1);
+ this._updateColorRamp();
+ }
+ if (StyleLayer2)
+ HeatmapStyleLayer2.__proto__ = StyleLayer2;
+ HeatmapStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ HeatmapStyleLayer2.prototype.constructor = HeatmapStyleLayer2;
+ HeatmapStyleLayer2.prototype.createBucket = function createBucket(options) {
+ return new HeatmapBucket(options);
+ };
+ HeatmapStyleLayer2.prototype._handleSpecialPaintPropertyUpdate = function _handleSpecialPaintPropertyUpdate(name3) {
+ if (name3 === "heatmap-color") {
+ this._updateColorRamp();
+ }
+ };
+ HeatmapStyleLayer2.prototype._updateColorRamp = function _updateColorRamp() {
+ var expression2 = this._transitionablePaint._values["heatmap-color"].value.expression;
+ this.colorRamp = renderColorRamp({
+ expression: expression2,
+ evaluationKey: "heatmapDensity",
+ image: this.colorRamp
+ });
+ this.colorRampTexture = null;
+ };
+ HeatmapStyleLayer2.prototype.resize = function resize() {
+ if (this.heatmapFbo) {
+ this.heatmapFbo.destroy();
+ this.heatmapFbo = null;
+ }
+ };
+ HeatmapStyleLayer2.prototype.queryRadius = function queryRadius() {
+ return 0;
+ };
+ HeatmapStyleLayer2.prototype.queryIntersectsFeature = function queryIntersectsFeature() {
+ return false;
+ };
+ HeatmapStyleLayer2.prototype.hasOffscreenPass = function hasOffscreenPass() {
+ return this.paint.get("heatmap-opacity") !== 0 && this.visibility !== "none";
+ };
+ return HeatmapStyleLayer2;
+ }(StyleLayer);
+ var paint$3 = new Properties({
+ "hillshade-illumination-direction": new DataConstantProperty(spec["paint_hillshade"]["hillshade-illumination-direction"]),
+ "hillshade-illumination-anchor": new DataConstantProperty(spec["paint_hillshade"]["hillshade-illumination-anchor"]),
+ "hillshade-exaggeration": new DataConstantProperty(spec["paint_hillshade"]["hillshade-exaggeration"]),
+ "hillshade-shadow-color": new DataConstantProperty(spec["paint_hillshade"]["hillshade-shadow-color"]),
+ "hillshade-highlight-color": new DataConstantProperty(spec["paint_hillshade"]["hillshade-highlight-color"]),
+ "hillshade-accent-color": new DataConstantProperty(spec["paint_hillshade"]["hillshade-accent-color"])
+ });
+ var properties$2 = { paint: paint$3 };
+ var HillshadeStyleLayer = function(StyleLayer2) {
+ function HillshadeStyleLayer2(layer2) {
+ StyleLayer2.call(this, layer2, properties$2);
+ }
+ if (StyleLayer2)
+ HillshadeStyleLayer2.__proto__ = StyleLayer2;
+ HillshadeStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ HillshadeStyleLayer2.prototype.constructor = HillshadeStyleLayer2;
+ HillshadeStyleLayer2.prototype.hasOffscreenPass = function hasOffscreenPass() {
+ return this.paint.get("hillshade-exaggeration") !== 0 && this.visibility !== "none";
+ };
+ return HillshadeStyleLayer2;
+ }(StyleLayer);
+ var layout$3 = createLayout([{
+ name: "a_pos",
+ components: 2,
+ type: "Int16"
+ }], 4);
+ var members$1 = layout$3.members;
+ var earcut_1 = earcut;
+ var default_1 = 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 || outerNode.next === outerNode.prev) {
+ return triangles;
+ }
+ var minX, minY, maxX, maxY, x, y, invSize;
+ if (hasHoles) {
+ outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
+ }
+ 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;
+ }
+ }
+ invSize = Math.max(maxX - minX, maxY - minY);
+ invSize = invSize !== 0 ? 1 / invSize : 0;
+ }
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
+ return 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);
+ }
+ }
+ if (last && equals(last, last.next)) {
+ removeNode(last);
+ last = last.next;
+ }
+ return last;
+ }
+ function filterPoints(start, end) {
+ if (!start) {
+ return start;
+ }
+ if (!end) {
+ end = start;
+ }
+ var p = start, again;
+ do {
+ again = false;
+ if (!p.steiner && (equals(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;
+ }
+ function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
+ if (!ear) {
+ return;
+ }
+ if (!pass && invSize) {
+ indexCurve(ear, minX, minY, invSize);
+ }
+ var stop = ear, prev, next;
+ while (ear.prev !== ear.next) {
+ prev = ear.prev;
+ next = ear.next;
+ if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
+ triangles.push(prev.i / dim);
+ triangles.push(ear.i / dim);
+ triangles.push(next.i / dim);
+ removeNode(ear);
+ ear = next.next;
+ stop = next.next;
+ continue;
+ }
+ ear = next;
+ if (ear === stop) {
+ if (!pass) {
+ earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
+ } else if (pass === 1) {
+ ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
+ earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
+ } else if (pass === 2) {
+ splitEarcut(ear, triangles, dim, minX, minY, invSize);
+ }
+ break;
+ }
+ }
+ }
+ function isEar(ear) {
+ var a = ear.prev, b = ear, c = ear.next;
+ if (area(a, b, c) >= 0) {
+ return false;
+ }
+ 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;
+ }
+ 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;
+ var minZ = zOrder(minTX, minTY, minX, minY, invSize), maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
+ var p = ear.prevZ, n = ear.nextZ;
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ function cureLocalIntersections(start, triangles, dim) {
+ var p = start;
+ do {
+ var a = p.prev, b = p.next.next;
+ if (!equals(a, b) && intersects(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);
+ 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 {
+ var b = a.next.next;
+ while (b !== a.prev) {
+ if (a.i !== b.i && isValidDiagonal(a, b)) {
+ var c = splitPolygon(a, b);
+ a = filterPoints(a, a.next);
+ c = filterPoints(c, c.next);
+ earcutLinked(a, triangles, dim, minX, minY, invSize);
+ earcutLinked(c, triangles, dim, minX, minY, invSize);
+ return;
+ }
+ b = b.next;
+ }
+ a = a.next;
+ } while (a !== start);
+ }
+ 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);
+ 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;
+ }
+ function eliminateHole(hole, outerNode) {
+ outerNode = findHoleBridge(hole, outerNode);
+ if (outerNode) {
+ var b = splitPolygon(outerNode, hole);
+ filterPoints(outerNode, outerNode.next);
+ filterPoints(b, b.next);
+ }
+ }
+ function findHoleBridge(hole, outerNode) {
+ var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m;
+ 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;
+ }
+ var stop = m, mx = m.x, my = m.y, tanMin = Infinity, tan;
+ p = m;
+ do {
+ 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);
+ if (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;
+ }
+ function sectorContainsSector(m, p) {
+ return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
+ }
+ 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);
+ }
+ 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;
+ }
+ function zOrder(x, y, minX, minY, invSize) {
+ x = 32767 * (x - minX) * invSize;
+ y = 32767 * (y - minY) * invSize;
+ x = (x | x << 8) & 16711935;
+ x = (x | x << 4) & 252645135;
+ x = (x | x << 2) & 858993459;
+ x = (x | x << 1) & 1431655765;
+ y = (y | y << 8) & 16711935;
+ y = (y | y << 4) & 252645135;
+ y = (y | y << 2) & 858993459;
+ y = (y | y << 1) & 1431655765;
+ return x | y << 1;
+ }
+ function getLeftmost(start) {
+ var p = start, leftmost = start;
+ do {
+ if (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) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
+ }
+ 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) && (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(p1, q1, p2, q2) {
+ var o1 = sign(area(p1, q1, p2));
+ var o2 = sign(area(p1, q1, q2));
+ var o3 = sign(area(p2, q2, p1));
+ var o4 = sign(area(p2, q2, q1));
+ if (o1 !== o2 && o3 !== o4) {
+ return true;
+ }
+ if (o1 === 0 && onSegment(p1, p2, q1)) {
+ return true;
+ }
+ if (o2 === 0 && onSegment(p1, q2, q1)) {
+ return true;
+ }
+ if (o3 === 0 && onSegment(p2, p1, q2)) {
+ return true;
+ }
+ if (o4 === 0 && onSegment(p2, q1, q2)) {
+ return true;
+ }
+ return false;
+ }
+ 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 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(p, p.next, a, b)) {
+ return true;
+ }
+ p = p.next;
+ } while (p !== a);
+ return false;
+ }
+ 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 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;
+ }
+ 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;
+ 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;
+ }
+ function insertNode(i, x, y, last) {
+ var p = new Node(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(i, x, y) {
+ this.i = i;
+ this.x = x;
+ this.y = y;
+ this.prev = null;
+ this.next = null;
+ this.z = null;
+ this.prevZ = null;
+ this.nextZ = null;
+ this.steiner = false;
+ }
+ 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;
+ }
+ 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;
+ function quickselect(arr, k, left, right, compare2) {
+ quickselectStep(arr, k, left || 0, right || arr.length - 1, compare2 || defaultCompare);
+ }
+ function quickselectStep(arr, k, left, right, compare2) {
+ 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, compare2);
+ }
+ var t = arr[k];
+ var i = left;
+ var j = right;
+ swap$1(arr, left, k);
+ if (compare2(arr[right], t) > 0) {
+ swap$1(arr, left, right);
+ }
+ while (i < j) {
+ swap$1(arr, i, j);
+ i++;
+ j--;
+ while (compare2(arr[i], t) < 0) {
+ i++;
+ }
+ while (compare2(arr[j], t) > 0) {
+ j--;
+ }
+ }
+ if (compare2(arr[left], t) === 0) {
+ swap$1(arr, left, j);
+ } else {
+ j++;
+ swap$1(arr, j, right);
+ }
+ if (j <= k) {
+ left = j + 1;
+ }
+ if (k <= j) {
+ right = j - 1;
+ }
+ }
+ }
+ function swap$1(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;
+ }
+ function classifyRings(rings, maxRings) {
+ var len = rings.length;
+ if (len <= 1) {
+ return [rings];
+ }
+ var polygons = [];
+ var polygon, ccw;
+ for (var i = 0; i < len; i++) {
+ var area2 = calculateSignedArea(rings[i]);
+ if (area2 === 0) {
+ continue;
+ }
+ rings[i].area = Math.abs(area2);
+ if (ccw === void 0) {
+ ccw = area2 < 0;
+ }
+ if (ccw === area2 < 0) {
+ if (polygon) {
+ polygons.push(polygon);
+ }
+ polygon = [rings[i]];
+ } else {
+ polygon.push(rings[i]);
+ }
+ }
+ if (polygon) {
+ polygons.push(polygon);
+ }
+ if (maxRings > 1) {
+ for (var j = 0; j < polygons.length; j++) {
+ if (polygons[j].length <= maxRings) {
+ continue;
+ }
+ quickselect(polygons[j], maxRings, 1, polygons[j].length - 1, compareAreas);
+ polygons[j] = polygons[j].slice(0, maxRings);
+ }
+ }
+ return polygons;
+ }
+ function compareAreas(a, b) {
+ return b.area - a.area;
+ }
+ function hasPattern(type, layers, options) {
+ var patterns = options.patternDependencies;
+ var hasPattern2 = false;
+ for (var i = 0, list = layers; i < list.length; i += 1) {
+ var layer2 = list[i];
+ var patternProperty = layer2.paint.get(type + "-pattern");
+ if (!patternProperty.isConstant()) {
+ hasPattern2 = true;
+ }
+ var constantPattern = patternProperty.constantOr(null);
+ if (constantPattern) {
+ hasPattern2 = true;
+ patterns[constantPattern.to] = true;
+ patterns[constantPattern.from] = true;
+ }
+ }
+ return hasPattern2;
+ }
+ function addPatternDependencies(type, layers, patternFeature, zoom, options) {
+ var patterns = options.patternDependencies;
+ for (var i = 0, list = layers; i < list.length; i += 1) {
+ var layer2 = list[i];
+ var patternProperty = layer2.paint.get(type + "-pattern");
+ var patternPropertyValue = patternProperty.value;
+ if (patternPropertyValue.kind !== "constant") {
+ var min = patternPropertyValue.evaluate({ zoom: zoom - 1 }, patternFeature, {}, options.availableImages);
+ var mid = patternPropertyValue.evaluate({ zoom }, patternFeature, {}, options.availableImages);
+ var max = patternPropertyValue.evaluate({ zoom: zoom + 1 }, patternFeature, {}, options.availableImages);
+ min = min && min.name ? min.name : min;
+ mid = mid && mid.name ? mid.name : mid;
+ max = max && max.name ? max.name : max;
+ patterns[min] = true;
+ patterns[mid] = true;
+ patterns[max] = true;
+ patternFeature.patterns[layer2.id] = {
+ min,
+ mid,
+ max
+ };
+ }
+ }
+ return patternFeature;
+ }
+ var EARCUT_MAX_RINGS = 500;
+ var FillBucket = function FillBucket2(options) {
+ this.zoom = options.zoom;
+ this.overscaling = options.overscaling;
+ this.layers = options.layers;
+ this.layerIds = this.layers.map(function(layer2) {
+ return layer2.id;
+ });
+ this.index = options.index;
+ this.hasPattern = false;
+ this.patternFeatures = [];
+ this.layoutVertexArray = new StructArrayLayout2i4();
+ this.indexArray = new StructArrayLayout3ui6();
+ this.indexArray2 = new StructArrayLayout2ui4();
+ this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);
+ this.segments = new SegmentVector();
+ this.segments2 = new SegmentVector();
+ this.stateDependentLayerIds = this.layers.filter(function(l) {
+ return l.isStateDependent();
+ }).map(function(l) {
+ return l.id;
+ });
+ };
+ FillBucket.prototype.populate = function populate(features, options, canonical) {
+ this.hasPattern = hasPattern("fill", this.layers, options);
+ var fillSortKey = this.layers[0].layout.get("fill-sort-key");
+ var bucketFeatures = [];
+ for (var i = 0, list = features; i < list.length; i += 1) {
+ var ref = list[i];
+ var feature = ref.feature;
+ var id2 = ref.id;
+ var index = ref.index;
+ var sourceLayerIndex = ref.sourceLayerIndex;
+ var needGeometry = this.layers[0]._featureFilter.needGeometry;
+ var evaluationFeature = toEvaluationFeature(feature, needGeometry);
+ if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) {
+ continue;
+ }
+ var sortKey = fillSortKey ? fillSortKey.evaluate(evaluationFeature, {}, canonical, options.availableImages) : void 0;
+ var bucketFeature = {
+ id: id2,
+ properties: feature.properties,
+ type: feature.type,
+ sourceLayerIndex,
+ index,
+ geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),
+ patterns: {},
+ sortKey
+ };
+ bucketFeatures.push(bucketFeature);
+ }
+ if (fillSortKey) {
+ bucketFeatures.sort(function(a, b) {
+ return a.sortKey - b.sortKey;
+ });
+ }
+ for (var i$1 = 0, list$1 = bucketFeatures; i$1 < list$1.length; i$1 += 1) {
+ var bucketFeature$1 = list$1[i$1];
+ var ref$1 = bucketFeature$1;
+ var geometry = ref$1.geometry;
+ var index$1 = ref$1.index;
+ var sourceLayerIndex$1 = ref$1.sourceLayerIndex;
+ if (this.hasPattern) {
+ var patternFeature = addPatternDependencies("fill", this.layers, bucketFeature$1, this.zoom, options);
+ this.patternFeatures.push(patternFeature);
+ } else {
+ this.addFeature(bucketFeature$1, geometry, index$1, canonical, {});
+ }
+ var feature$1 = features[index$1].feature;
+ options.featureIndex.insert(feature$1, geometry, index$1, sourceLayerIndex$1, this.index);
+ }
+ };
+ FillBucket.prototype.update = function update(states, vtLayer, imagePositions) {
+ if (!this.stateDependentLayers.length) {
+ return;
+ }
+ this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);
+ };
+ FillBucket.prototype.addFeatures = function addFeatures(options, canonical, imagePositions) {
+ for (var i = 0, list = this.patternFeatures; i < list.length; i += 1) {
+ var feature = list[i];
+ this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);
+ }
+ };
+ FillBucket.prototype.isEmpty = function isEmpty2() {
+ return this.layoutVertexArray.length === 0;
+ };
+ FillBucket.prototype.uploadPending = function uploadPending() {
+ return !this.uploaded || this.programConfigurations.needsUpload;
+ };
+ FillBucket.prototype.upload = function upload(context) {
+ if (!this.uploaded) {
+ this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, members$1);
+ this.indexBuffer = context.createIndexBuffer(this.indexArray);
+ this.indexBuffer2 = context.createIndexBuffer(this.indexArray2);
+ }
+ this.programConfigurations.upload(context);
+ this.uploaded = true;
+ };
+ FillBucket.prototype.destroy = function destroy() {
+ if (!this.layoutVertexBuffer) {
+ return;
+ }
+ this.layoutVertexBuffer.destroy();
+ this.indexBuffer.destroy();
+ this.indexBuffer2.destroy();
+ this.programConfigurations.destroy();
+ this.segments.destroy();
+ this.segments2.destroy();
+ };
+ FillBucket.prototype.addFeature = function addFeature2(feature, geometry, index, canonical, imagePositions) {
+ for (var i$4 = 0, list$2 = classifyRings(geometry, EARCUT_MAX_RINGS); i$4 < list$2.length; i$4 += 1) {
+ var polygon = list$2[i$4];
+ var numVertices = 0;
+ for (var i$2 = 0, list = polygon; i$2 < list.length; i$2 += 1) {
+ var ring = list[i$2];
+ numVertices += ring.length;
+ }
+ var triangleSegment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);
+ var triangleIndex = triangleSegment.vertexLength;
+ var flattened = [];
+ var holeIndices = [];
+ for (var i$3 = 0, list$1 = polygon; i$3 < list$1.length; i$3 += 1) {
+ var ring$1 = list$1[i$3];
+ if (ring$1.length === 0) {
+ continue;
+ }
+ if (ring$1 !== polygon[0]) {
+ holeIndices.push(flattened.length / 2);
+ }
+ var lineSegment = this.segments2.prepareSegment(ring$1.length, this.layoutVertexArray, this.indexArray2);
+ var lineIndex = lineSegment.vertexLength;
+ this.layoutVertexArray.emplaceBack(ring$1[0].x, ring$1[0].y);
+ this.indexArray2.emplaceBack(lineIndex + ring$1.length - 1, lineIndex);
+ flattened.push(ring$1[0].x);
+ flattened.push(ring$1[0].y);
+ for (var i = 1; i < ring$1.length; i++) {
+ this.layoutVertexArray.emplaceBack(ring$1[i].x, ring$1[i].y);
+ this.indexArray2.emplaceBack(lineIndex + i - 1, lineIndex + i);
+ flattened.push(ring$1[i].x);
+ flattened.push(ring$1[i].y);
+ }
+ lineSegment.vertexLength += ring$1.length;
+ lineSegment.primitiveLength += ring$1.length;
+ }
+ var indices = earcut_1(flattened, holeIndices);
+ for (var i$1 = 0; i$1 < indices.length; i$1 += 3) {
+ this.indexArray.emplaceBack(triangleIndex + indices[i$1], triangleIndex + indices[i$1 + 1], triangleIndex + indices[i$1 + 2]);
+ }
+ triangleSegment.vertexLength += numVertices;
+ triangleSegment.primitiveLength += indices.length / 3;
+ }
+ this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);
+ };
+ register("FillBucket", FillBucket, {
+ omit: [
+ "layers",
+ "patternFeatures"
+ ]
+ });
+ var layout$4 = new Properties({ "fill-sort-key": new DataDrivenProperty(spec["layout_fill"]["fill-sort-key"]) });
+ var paint$4 = new Properties({
+ "fill-antialias": new DataConstantProperty(spec["paint_fill"]["fill-antialias"]),
+ "fill-opacity": new DataDrivenProperty(spec["paint_fill"]["fill-opacity"]),
+ "fill-color": new DataDrivenProperty(spec["paint_fill"]["fill-color"]),
+ "fill-outline-color": new DataDrivenProperty(spec["paint_fill"]["fill-outline-color"]),
+ "fill-translate": new DataConstantProperty(spec["paint_fill"]["fill-translate"]),
+ "fill-translate-anchor": new DataConstantProperty(spec["paint_fill"]["fill-translate-anchor"]),
+ "fill-pattern": new CrossFadedDataDrivenProperty(spec["paint_fill"]["fill-pattern"])
+ });
+ var properties$3 = {
+ paint: paint$4,
+ layout: layout$4
+ };
+ var FillStyleLayer = function(StyleLayer2) {
+ function FillStyleLayer2(layer2) {
+ StyleLayer2.call(this, layer2, properties$3);
+ }
+ if (StyleLayer2)
+ FillStyleLayer2.__proto__ = StyleLayer2;
+ FillStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ FillStyleLayer2.prototype.constructor = FillStyleLayer2;
+ FillStyleLayer2.prototype.recalculate = function recalculate(parameters, availableImages) {
+ StyleLayer2.prototype.recalculate.call(this, parameters, availableImages);
+ var outlineColor = this.paint._values["fill-outline-color"];
+ if (outlineColor.value.kind === "constant" && outlineColor.value.value === void 0) {
+ this.paint._values["fill-outline-color"] = this.paint._values["fill-color"];
+ }
+ };
+ FillStyleLayer2.prototype.createBucket = function createBucket(parameters) {
+ return new FillBucket(parameters);
+ };
+ FillStyleLayer2.prototype.queryRadius = function queryRadius() {
+ return translateDistance(this.paint.get("fill-translate"));
+ };
+ FillStyleLayer2.prototype.queryIntersectsFeature = function queryIntersectsFeature(queryGeometry, feature, featureState, geometry, zoom, transform, pixelsToTileUnits) {
+ var translatedPolygon = translate(queryGeometry, this.paint.get("fill-translate"), this.paint.get("fill-translate-anchor"), transform.angle, pixelsToTileUnits);
+ return polygonIntersectsMultiPolygon(translatedPolygon, geometry);
+ };
+ FillStyleLayer2.prototype.isTileClipped = function isTileClipped() {
+ return true;
+ };
+ return FillStyleLayer2;
+ }(StyleLayer);
+ var layout$5 = createLayout([
+ {
+ name: "a_pos",
+ components: 2,
+ type: "Int16"
+ },
+ {
+ name: "a_normal_ed",
+ components: 4,
+ type: "Int16"
+ }
+ ], 4);
+ var members$2 = layout$5.members;
+ var vectortilefeature = VectorTileFeature;
+ function VectorTileFeature(pbf2, end, extent, keys, values2) {
+ this.properties = {};
+ this.extent = extent;
+ this.type = 0;
+ this._pbf = pbf2;
+ this._geometry = -1;
+ this._keys = keys;
+ this._values = values2;
+ pbf2.readFields(readFeature, this, end);
+ }
+ function readFeature(tag, feature, pbf2) {
+ if (tag == 1) {
+ feature.id = pbf2.readVarint();
+ } else if (tag == 2) {
+ readTag(pbf2, feature);
+ } else if (tag == 3) {
+ feature.type = pbf2.readVarint();
+ } else if (tag == 4) {
+ feature._geometry = pbf2.pos;
+ }
+ }
+ function readTag(pbf2, feature) {
+ var end = pbf2.readVarint() + pbf2.pos;
+ while (pbf2.pos < end) {
+ var key = feature._keys[pbf2.readVarint()], value = feature._values[pbf2.readVarint()];
+ feature.properties[key] = value;
+ }
+ }
+ VectorTileFeature.types = [
+ "Unknown",
+ "Point",
+ "LineString",
+ "Polygon"
+ ];
+ VectorTileFeature.prototype.loadGeometry = function() {
+ var pbf2 = this._pbf;
+ pbf2.pos = this._geometry;
+ var end = pbf2.readVarint() + pbf2.pos, cmd = 1, length = 0, x = 0, y = 0, lines = [], line;
+ while (pbf2.pos < end) {
+ if (length <= 0) {
+ var cmdLen = pbf2.readVarint();
+ cmd = cmdLen & 7;
+ length = cmdLen >> 3;
+ }
+ length--;
+ if (cmd === 1 || cmd === 2) {
+ x += pbf2.readSVarint();
+ y += pbf2.readSVarint();
+ if (cmd === 1) {
+ if (line) {
+ lines.push(line);
+ }
+ line = [];
+ }
+ line.push(new pointGeometry(x, y));
+ } else if (cmd === 7) {
+ if (line) {
+ line.push(line[0].clone());
+ }
+ } else {
+ throw new Error("unknown command " + cmd);
+ }
+ }
+ if (line) {
+ lines.push(line);
+ }
+ return lines;
+ };
+ VectorTileFeature.prototype.bbox = function() {
+ var pbf2 = this._pbf;
+ pbf2.pos = this._geometry;
+ var end = pbf2.readVarint() + pbf2.pos, cmd = 1, length = 0, x = 0, y = 0, x1 = Infinity, x2 = -Infinity, y1 = Infinity, y2 = -Infinity;
+ while (pbf2.pos < end) {
+ if (length <= 0) {
+ var cmdLen = pbf2.readVarint();
+ cmd = cmdLen & 7;
+ length = cmdLen >> 3;
+ }
+ length--;
+ if (cmd === 1 || cmd === 2) {
+ x += pbf2.readSVarint();
+ y += pbf2.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 j2 = 0; j2 < line.length; j2++) {
+ var p = line[j2], y2 = 180 - (p.y + y0) * 360 / size;
+ line[j2] = [
+ (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$1(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,
+ coordinates: coords
+ },
+ properties: this.properties
+ };
+ if ("id" in this) {
+ result.id = this.id;
+ }
+ return result;
+ };
+ function classifyRings$1(rings) {
+ var len = rings.length;
+ if (len <= 1) {
+ return [rings];
+ }
+ var polygons = [], polygon, ccw;
+ for (var i = 0; i < len; i++) {
+ var area2 = signedArea$1(rings[i]);
+ if (area2 === 0) {
+ continue;
+ }
+ if (ccw === void 0) {
+ ccw = area2 < 0;
+ }
+ if (ccw === area2 < 0) {
+ if (polygon) {
+ polygons.push(polygon);
+ }
+ polygon = [rings[i]];
+ } else {
+ polygon.push(rings[i]);
+ }
+ }
+ if (polygon) {
+ polygons.push(polygon);
+ }
+ return polygons;
+ }
+ function signedArea$1(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;
+ }
+ var vectortilelayer = VectorTileLayer;
+ function VectorTileLayer(pbf2, end) {
+ this.version = 1;
+ this.name = null;
+ this.extent = 4096;
+ this.length = 0;
+ this._pbf = pbf2;
+ this._keys = [];
+ this._values = [];
+ this._features = [];
+ pbf2.readFields(readLayer, this, end);
+ this.length = this._features.length;
+ }
+ function readLayer(tag, layer2, pbf2) {
+ if (tag === 15) {
+ layer2.version = pbf2.readVarint();
+ } else if (tag === 1) {
+ layer2.name = pbf2.readString();
+ } else if (tag === 5) {
+ layer2.extent = pbf2.readVarint();
+ } else if (tag === 2) {
+ layer2._features.push(pbf2.pos);
+ } else if (tag === 3) {
+ layer2._keys.push(pbf2.readString());
+ } else if (tag === 4) {
+ layer2._values.push(readValueMessage(pbf2));
+ }
+ }
+ function readValueMessage(pbf2) {
+ var value = null, end = pbf2.readVarint() + pbf2.pos;
+ while (pbf2.pos < end) {
+ var tag = pbf2.readVarint() >> 3;
+ value = tag === 1 ? pbf2.readString() : tag === 2 ? pbf2.readFloat() : tag === 3 ? pbf2.readDouble() : tag === 4 ? pbf2.readVarint64() : tag === 5 ? pbf2.readVarint() : tag === 6 ? pbf2.readSVarint() : tag === 7 ? pbf2.readBoolean() : null;
+ }
+ return value;
+ }
+ 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);
+ };
+ var vectortile = VectorTile;
+ function VectorTile(pbf2, end) {
+ this.layers = pbf2.readFields(readTile, {}, end);
+ }
+ function readTile(tag, layers, pbf2) {
+ if (tag === 3) {
+ var layer2 = new vectortilelayer(pbf2, pbf2.readVarint() + pbf2.pos);
+ if (layer2.length) {
+ layers[layer2.name] = layer2;
+ }
+ }
+ }
+ var VectorTile$1 = vectortile;
+ var VectorTileFeature$1 = vectortilefeature;
+ var VectorTileLayer$1 = vectortilelayer;
+ var vectorTile = {
+ VectorTile: VectorTile$1,
+ VectorTileFeature: VectorTileFeature$1,
+ VectorTileLayer: VectorTileLayer$1
+ };
+ var vectorTileFeatureTypes = vectorTile.VectorTileFeature.types;
+ var EARCUT_MAX_RINGS$1 = 500;
+ var FACTOR = Math.pow(2, 13);
+ function addVertex(vertexArray, x, y, nx, ny, nz, t, e) {
+ vertexArray.emplaceBack(x, y, Math.floor(nx * FACTOR) * 2 + t, ny * FACTOR * 2, nz * FACTOR * 2, Math.round(e));
+ }
+ var FillExtrusionBucket = function FillExtrusionBucket2(options) {
+ this.zoom = options.zoom;
+ this.overscaling = options.overscaling;
+ this.layers = options.layers;
+ this.layerIds = this.layers.map(function(layer2) {
+ return layer2.id;
+ });
+ this.index = options.index;
+ this.hasPattern = false;
+ this.layoutVertexArray = new StructArrayLayout2i4i12();
+ this.indexArray = new StructArrayLayout3ui6();
+ this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);
+ this.segments = new SegmentVector();
+ this.stateDependentLayerIds = this.layers.filter(function(l) {
+ return l.isStateDependent();
+ }).map(function(l) {
+ return l.id;
+ });
+ };
+ FillExtrusionBucket.prototype.populate = function populate(features, options, canonical) {
+ this.features = [];
+ this.hasPattern = hasPattern("fill-extrusion", this.layers, options);
+ for (var i = 0, list = features; i < list.length; i += 1) {
+ var ref = list[i];
+ var feature = ref.feature;
+ var id2 = ref.id;
+ var index = ref.index;
+ var sourceLayerIndex = ref.sourceLayerIndex;
+ var needGeometry = this.layers[0]._featureFilter.needGeometry;
+ var evaluationFeature = toEvaluationFeature(feature, needGeometry);
+ if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) {
+ continue;
+ }
+ var bucketFeature = {
+ id: id2,
+ sourceLayerIndex,
+ index,
+ geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),
+ properties: feature.properties,
+ type: feature.type,
+ patterns: {}
+ };
+ if (this.hasPattern) {
+ this.features.push(addPatternDependencies("fill-extrusion", this.layers, bucketFeature, this.zoom, options));
+ } else {
+ this.addFeature(bucketFeature, bucketFeature.geometry, index, canonical, {});
+ }
+ options.featureIndex.insert(feature, bucketFeature.geometry, index, sourceLayerIndex, this.index, true);
+ }
+ };
+ FillExtrusionBucket.prototype.addFeatures = function addFeatures(options, canonical, imagePositions) {
+ for (var i = 0, list = this.features; i < list.length; i += 1) {
+ var feature = list[i];
+ var geometry = feature.geometry;
+ this.addFeature(feature, geometry, feature.index, canonical, imagePositions);
+ }
+ };
+ FillExtrusionBucket.prototype.update = function update(states, vtLayer, imagePositions) {
+ if (!this.stateDependentLayers.length) {
+ return;
+ }
+ this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);
+ };
+ FillExtrusionBucket.prototype.isEmpty = function isEmpty2() {
+ return this.layoutVertexArray.length === 0;
+ };
+ FillExtrusionBucket.prototype.uploadPending = function uploadPending() {
+ return !this.uploaded || this.programConfigurations.needsUpload;
+ };
+ FillExtrusionBucket.prototype.upload = function upload(context) {
+ if (!this.uploaded) {
+ this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, members$2);
+ this.indexBuffer = context.createIndexBuffer(this.indexArray);
+ }
+ this.programConfigurations.upload(context);
+ this.uploaded = true;
+ };
+ FillExtrusionBucket.prototype.destroy = function destroy() {
+ if (!this.layoutVertexBuffer) {
+ return;
+ }
+ this.layoutVertexBuffer.destroy();
+ this.indexBuffer.destroy();
+ this.programConfigurations.destroy();
+ this.segments.destroy();
+ };
+ FillExtrusionBucket.prototype.addFeature = function addFeature2(feature, geometry, index, canonical, imagePositions) {
+ for (var i$4 = 0, list$3 = classifyRings(geometry, EARCUT_MAX_RINGS$1); i$4 < list$3.length; i$4 += 1) {
+ var polygon = list$3[i$4];
+ var numVertices = 0;
+ for (var i$1 = 0, list = polygon; i$1 < list.length; i$1 += 1) {
+ var ring = list[i$1];
+ numVertices += ring.length;
+ }
+ var segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);
+ for (var i$2 = 0, list$1 = polygon; i$2 < list$1.length; i$2 += 1) {
+ var ring$1 = list$1[i$2];
+ if (ring$1.length === 0) {
+ continue;
+ }
+ if (isEntirelyOutside(ring$1)) {
+ continue;
+ }
+ var edgeDistance = 0;
+ for (var p = 0; p < ring$1.length; p++) {
+ var p1 = ring$1[p];
+ if (p >= 1) {
+ var p2 = ring$1[p - 1];
+ if (!isBoundaryEdge(p1, p2)) {
+ if (segment.vertexLength + 4 > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
+ segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);
+ }
+ var perp2 = p1.sub(p2)._perp()._unit();
+ var dist = p2.dist(p1);
+ if (edgeDistance + dist > 32768) {
+ edgeDistance = 0;
+ }
+ addVertex(this.layoutVertexArray, p1.x, p1.y, perp2.x, perp2.y, 0, 0, edgeDistance);
+ addVertex(this.layoutVertexArray, p1.x, p1.y, perp2.x, perp2.y, 0, 1, edgeDistance);
+ edgeDistance += dist;
+ addVertex(this.layoutVertexArray, p2.x, p2.y, perp2.x, perp2.y, 0, 0, edgeDistance);
+ addVertex(this.layoutVertexArray, p2.x, p2.y, perp2.x, perp2.y, 0, 1, edgeDistance);
+ var bottomRight = segment.vertexLength;
+ this.indexArray.emplaceBack(bottomRight, bottomRight + 2, bottomRight + 1);
+ this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3);
+ segment.vertexLength += 4;
+ segment.primitiveLength += 2;
+ }
+ }
+ }
+ }
+ if (segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
+ segment = this.segments.prepareSegment(numVertices, this.layoutVertexArray, this.indexArray);
+ }
+ if (vectorTileFeatureTypes[feature.type] !== "Polygon") {
+ continue;
+ }
+ var flattened = [];
+ var holeIndices = [];
+ var triangleIndex = segment.vertexLength;
+ for (var i$3 = 0, list$2 = polygon; i$3 < list$2.length; i$3 += 1) {
+ var ring$2 = list$2[i$3];
+ if (ring$2.length === 0) {
+ continue;
+ }
+ if (ring$2 !== polygon[0]) {
+ holeIndices.push(flattened.length / 2);
+ }
+ for (var i = 0; i < ring$2.length; i++) {
+ var p$1 = ring$2[i];
+ addVertex(this.layoutVertexArray, p$1.x, p$1.y, 0, 0, 1, 1, 0);
+ flattened.push(p$1.x);
+ flattened.push(p$1.y);
+ }
+ }
+ var indices = earcut_1(flattened, holeIndices);
+ for (var j = 0; j < indices.length; j += 3) {
+ this.indexArray.emplaceBack(triangleIndex + indices[j], triangleIndex + indices[j + 2], triangleIndex + indices[j + 1]);
+ }
+ segment.primitiveLength += indices.length / 3;
+ segment.vertexLength += numVertices;
+ }
+ this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);
+ };
+ register("FillExtrusionBucket", FillExtrusionBucket, {
+ omit: [
+ "layers",
+ "features"
+ ]
+ });
+ function isBoundaryEdge(p1, p2) {
+ return p1.x === p2.x && (p1.x < 0 || p1.x > EXTENT$1) || p1.y === p2.y && (p1.y < 0 || p1.y > EXTENT$1);
+ }
+ function isEntirelyOutside(ring) {
+ return ring.every(function(p) {
+ return p.x < 0;
+ }) || ring.every(function(p) {
+ return p.x > EXTENT$1;
+ }) || ring.every(function(p) {
+ return p.y < 0;
+ }) || ring.every(function(p) {
+ return p.y > EXTENT$1;
+ });
+ }
+ var paint$5 = new Properties({
+ "fill-extrusion-opacity": new DataConstantProperty(spec["paint_fill-extrusion"]["fill-extrusion-opacity"]),
+ "fill-extrusion-color": new DataDrivenProperty(spec["paint_fill-extrusion"]["fill-extrusion-color"]),
+ "fill-extrusion-translate": new DataConstantProperty(spec["paint_fill-extrusion"]["fill-extrusion-translate"]),
+ "fill-extrusion-translate-anchor": new DataConstantProperty(spec["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),
+ "fill-extrusion-pattern": new CrossFadedDataDrivenProperty(spec["paint_fill-extrusion"]["fill-extrusion-pattern"]),
+ "fill-extrusion-height": new DataDrivenProperty(spec["paint_fill-extrusion"]["fill-extrusion-height"]),
+ "fill-extrusion-base": new DataDrivenProperty(spec["paint_fill-extrusion"]["fill-extrusion-base"]),
+ "fill-extrusion-vertical-gradient": new DataConstantProperty(spec["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])
+ });
+ var properties$4 = { paint: paint$5 };
+ var FillExtrusionStyleLayer = function(StyleLayer2) {
+ function FillExtrusionStyleLayer2(layer2) {
+ StyleLayer2.call(this, layer2, properties$4);
+ }
+ if (StyleLayer2)
+ FillExtrusionStyleLayer2.__proto__ = StyleLayer2;
+ FillExtrusionStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ FillExtrusionStyleLayer2.prototype.constructor = FillExtrusionStyleLayer2;
+ FillExtrusionStyleLayer2.prototype.createBucket = function createBucket(parameters) {
+ return new FillExtrusionBucket(parameters);
+ };
+ FillExtrusionStyleLayer2.prototype.queryRadius = function queryRadius() {
+ return translateDistance(this.paint.get("fill-extrusion-translate"));
+ };
+ FillExtrusionStyleLayer2.prototype.is3D = function is3D() {
+ return true;
+ };
+ FillExtrusionStyleLayer2.prototype.queryIntersectsFeature = function queryIntersectsFeature(queryGeometry, feature, featureState, geometry, zoom, transform, pixelsToTileUnits, pixelPosMatrix) {
+ var translatedPolygon = translate(queryGeometry, this.paint.get("fill-extrusion-translate"), this.paint.get("fill-extrusion-translate-anchor"), transform.angle, pixelsToTileUnits);
+ var height = this.paint.get("fill-extrusion-height").evaluate(feature, featureState);
+ var base = this.paint.get("fill-extrusion-base").evaluate(feature, featureState);
+ var projectedQueryGeometry = projectQueryGeometry$1(translatedPolygon, pixelPosMatrix, transform, 0);
+ var projected = projectExtrusion(geometry, base, height, pixelPosMatrix);
+ var projectedBase = projected[0];
+ var projectedTop = projected[1];
+ return checkIntersection(projectedBase, projectedTop, projectedQueryGeometry);
+ };
+ return FillExtrusionStyleLayer2;
+ }(StyleLayer);
+ function dot$2(a, b) {
+ return a.x * b.x + a.y * b.y;
+ }
+ function getIntersectionDistance(projectedQueryGeometry, projectedFace) {
+ if (projectedQueryGeometry.length === 1) {
+ var i = 0;
+ var a = projectedFace[i++];
+ var b;
+ while (!b || a.equals(b)) {
+ b = projectedFace[i++];
+ if (!b) {
+ return Infinity;
+ }
+ }
+ for (; i < projectedFace.length; i++) {
+ var c = projectedFace[i];
+ var p = projectedQueryGeometry[0];
+ var ab = b.sub(a);
+ var ac = c.sub(a);
+ var ap = p.sub(a);
+ var dotABAB = dot$2(ab, ab);
+ var dotABAC = dot$2(ab, ac);
+ var dotACAC = dot$2(ac, ac);
+ var dotAPAB = dot$2(ap, ab);
+ var dotAPAC = dot$2(ap, ac);
+ var denom = dotABAB * dotACAC - dotABAC * dotABAC;
+ var v = (dotACAC * dotAPAB - dotABAC * dotAPAC) / denom;
+ var w = (dotABAB * dotAPAC - dotABAC * dotAPAB) / denom;
+ var u = 1 - v - w;
+ var distance = a.z * u + b.z * v + c.z * w;
+ if (isFinite(distance)) {
+ return distance;
+ }
+ }
+ return Infinity;
+ } else {
+ var closestDistance = Infinity;
+ for (var i$1 = 0, list = projectedFace; i$1 < list.length; i$1 += 1) {
+ var p$1 = list[i$1];
+ closestDistance = Math.min(closestDistance, p$1.z);
+ }
+ return closestDistance;
+ }
+ }
+ function checkIntersection(projectedBase, projectedTop, projectedQueryGeometry) {
+ var closestDistance = Infinity;
+ if (polygonIntersectsMultiPolygon(projectedQueryGeometry, projectedTop)) {
+ closestDistance = getIntersectionDistance(projectedQueryGeometry, projectedTop[0]);
+ }
+ for (var r = 0; r < projectedTop.length; r++) {
+ var ringTop = projectedTop[r];
+ var ringBase = projectedBase[r];
+ for (var p = 0; p < ringTop.length - 1; p++) {
+ var topA = ringTop[p];
+ var topB = ringTop[p + 1];
+ var baseA = ringBase[p];
+ var baseB = ringBase[p + 1];
+ var face = [
+ topA,
+ topB,
+ baseB,
+ baseA,
+ topA
+ ];
+ if (polygonIntersectsPolygon(projectedQueryGeometry, face)) {
+ closestDistance = Math.min(closestDistance, getIntersectionDistance(projectedQueryGeometry, face));
+ }
+ }
+ }
+ return closestDistance === Infinity ? false : closestDistance;
+ }
+ function projectExtrusion(geometry, zBase, zTop, m) {
+ var projectedBase = [];
+ var projectedTop = [];
+ var baseXZ = m[8] * zBase;
+ var baseYZ = m[9] * zBase;
+ var baseZZ = m[10] * zBase;
+ var baseWZ = m[11] * zBase;
+ var topXZ = m[8] * zTop;
+ var topYZ = m[9] * zTop;
+ var topZZ = m[10] * zTop;
+ var topWZ = m[11] * zTop;
+ for (var i$1 = 0, list$1 = geometry; i$1 < list$1.length; i$1 += 1) {
+ var r = list$1[i$1];
+ var ringBase = [];
+ var ringTop = [];
+ for (var i = 0, list = r; i < list.length; i += 1) {
+ var p = list[i];
+ var x = p.x;
+ var y = p.y;
+ var sX = m[0] * x + m[4] * y + m[12];
+ var sY = m[1] * x + m[5] * y + m[13];
+ var sZ = m[2] * x + m[6] * y + m[14];
+ var sW = m[3] * x + m[7] * y + m[15];
+ var baseX = sX + baseXZ;
+ var baseY = sY + baseYZ;
+ var baseZ = sZ + baseZZ;
+ var baseW = sW + baseWZ;
+ var topX = sX + topXZ;
+ var topY = sY + topYZ;
+ var topZ = sZ + topZZ;
+ var topW = sW + topWZ;
+ var b = new pointGeometry(baseX / baseW, baseY / baseW);
+ b.z = baseZ / baseW;
+ ringBase.push(b);
+ var t = new pointGeometry(topX / topW, topY / topW);
+ t.z = topZ / topW;
+ ringTop.push(t);
+ }
+ projectedBase.push(ringBase);
+ projectedTop.push(ringTop);
+ }
+ return [
+ projectedBase,
+ projectedTop
+ ];
+ }
+ function projectQueryGeometry$1(queryGeometry, pixelPosMatrix, transform, z) {
+ var projectedQueryGeometry = [];
+ for (var i = 0, list = queryGeometry; i < list.length; i += 1) {
+ var p = list[i];
+ var v = [
+ p.x,
+ p.y,
+ z,
+ 1
+ ];
+ transformMat4(v, v, pixelPosMatrix);
+ projectedQueryGeometry.push(new pointGeometry(v[0] / v[3], v[1] / v[3]));
+ }
+ return projectedQueryGeometry;
+ }
+ var lineLayoutAttributes = createLayout([
+ {
+ name: "a_pos_normal",
+ components: 2,
+ type: "Int16"
+ },
+ {
+ name: "a_data",
+ components: 4,
+ type: "Uint8"
+ }
+ ], 4);
+ var members$3 = lineLayoutAttributes.members;
+ var lineLayoutAttributesExt = createLayout([
+ {
+ name: "a_uv_x",
+ components: 1,
+ type: "Float32"
+ },
+ {
+ name: "a_split_index",
+ components: 1,
+ type: "Float32"
+ }
+ ]);
+ var members$4 = lineLayoutAttributesExt.members;
+ var vectorTileFeatureTypes$1 = vectorTile.VectorTileFeature.types;
+ var EXTRUDE_SCALE = 63;
+ var COS_HALF_SHARP_CORNER = Math.cos(75 / 2 * (Math.PI / 180));
+ var SHARP_CORNER_OFFSET = 15;
+ var DEG_PER_TRIANGLE = 20;
+ var LINE_DISTANCE_BUFFER_BITS = 15;
+ var LINE_DISTANCE_SCALE = 1 / 2;
+ var MAX_LINE_DISTANCE = Math.pow(2, LINE_DISTANCE_BUFFER_BITS - 1) / LINE_DISTANCE_SCALE;
+ var LineBucket = function LineBucket2(options) {
+ var this$1 = this;
+ this.zoom = options.zoom;
+ this.overscaling = options.overscaling;
+ this.layers = options.layers;
+ this.layerIds = this.layers.map(function(layer2) {
+ return layer2.id;
+ });
+ this.index = options.index;
+ this.hasPattern = false;
+ this.patternFeatures = [];
+ this.lineClipsArray = [];
+ this.gradients = {};
+ this.layers.forEach(function(layer2) {
+ this$1.gradients[layer2.id] = {};
+ });
+ this.layoutVertexArray = new StructArrayLayout2i4ub8();
+ this.layoutVertexArray2 = new StructArrayLayout2f8();
+ this.indexArray = new StructArrayLayout3ui6();
+ this.programConfigurations = new ProgramConfigurationSet(options.layers, options.zoom);
+ this.segments = new SegmentVector();
+ this.maxLineLength = 0;
+ this.stateDependentLayerIds = this.layers.filter(function(l) {
+ return l.isStateDependent();
+ }).map(function(l) {
+ return l.id;
+ });
+ };
+ LineBucket.prototype.populate = function populate(features, options, canonical) {
+ this.hasPattern = hasPattern("line", this.layers, options);
+ var lineSortKey = this.layers[0].layout.get("line-sort-key");
+ var bucketFeatures = [];
+ for (var i = 0, list = features; i < list.length; i += 1) {
+ var ref = list[i];
+ var feature = ref.feature;
+ var id2 = ref.id;
+ var index = ref.index;
+ var sourceLayerIndex = ref.sourceLayerIndex;
+ var needGeometry = this.layers[0]._featureFilter.needGeometry;
+ var evaluationFeature = toEvaluationFeature(feature, needGeometry);
+ if (!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom), evaluationFeature, canonical)) {
+ continue;
+ }
+ var sortKey = lineSortKey ? lineSortKey.evaluate(evaluationFeature, {}, canonical) : void 0;
+ var bucketFeature = {
+ id: id2,
+ properties: feature.properties,
+ type: feature.type,
+ sourceLayerIndex,
+ index,
+ geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature),
+ patterns: {},
+ sortKey
+ };
+ bucketFeatures.push(bucketFeature);
+ }
+ if (lineSortKey) {
+ bucketFeatures.sort(function(a, b) {
+ return a.sortKey - b.sortKey;
+ });
+ }
+ for (var i$1 = 0, list$1 = bucketFeatures; i$1 < list$1.length; i$1 += 1) {
+ var bucketFeature$1 = list$1[i$1];
+ var ref$1 = bucketFeature$1;
+ var geometry = ref$1.geometry;
+ var index$1 = ref$1.index;
+ var sourceLayerIndex$1 = ref$1.sourceLayerIndex;
+ if (this.hasPattern) {
+ var patternBucketFeature = addPatternDependencies("line", this.layers, bucketFeature$1, this.zoom, options);
+ this.patternFeatures.push(patternBucketFeature);
+ } else {
+ this.addFeature(bucketFeature$1, geometry, index$1, canonical, {});
+ }
+ var feature$1 = features[index$1].feature;
+ options.featureIndex.insert(feature$1, geometry, index$1, sourceLayerIndex$1, this.index);
+ }
+ };
+ LineBucket.prototype.update = function update(states, vtLayer, imagePositions) {
+ if (!this.stateDependentLayers.length) {
+ return;
+ }
+ this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, imagePositions);
+ };
+ LineBucket.prototype.addFeatures = function addFeatures(options, canonical, imagePositions) {
+ for (var i = 0, list = this.patternFeatures; i < list.length; i += 1) {
+ var feature = list[i];
+ this.addFeature(feature, feature.geometry, feature.index, canonical, imagePositions);
+ }
+ };
+ LineBucket.prototype.isEmpty = function isEmpty2() {
+ return this.layoutVertexArray.length === 0;
+ };
+ LineBucket.prototype.uploadPending = function uploadPending() {
+ return !this.uploaded || this.programConfigurations.needsUpload;
+ };
+ LineBucket.prototype.upload = function upload(context) {
+ if (!this.uploaded) {
+ if (this.layoutVertexArray2.length !== 0) {
+ this.layoutVertexBuffer2 = context.createVertexBuffer(this.layoutVertexArray2, members$4);
+ }
+ this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, members$3);
+ this.indexBuffer = context.createIndexBuffer(this.indexArray);
+ }
+ this.programConfigurations.upload(context);
+ this.uploaded = true;
+ };
+ LineBucket.prototype.destroy = function destroy() {
+ if (!this.layoutVertexBuffer) {
+ return;
+ }
+ this.layoutVertexBuffer.destroy();
+ this.indexBuffer.destroy();
+ this.programConfigurations.destroy();
+ this.segments.destroy();
+ };
+ LineBucket.prototype.lineFeatureClips = function lineFeatureClips(feature) {
+ if (!!feature.properties && feature.properties.hasOwnProperty("mapbox_clip_start") && feature.properties.hasOwnProperty("mapbox_clip_end")) {
+ var start = +feature.properties["mapbox_clip_start"];
+ var end = +feature.properties["mapbox_clip_end"];
+ return {
+ start,
+ end
+ };
+ }
+ };
+ LineBucket.prototype.addFeature = function addFeature2(feature, geometry, index, canonical, imagePositions) {
+ var layout2 = this.layers[0].layout;
+ var join = layout2.get("line-join").evaluate(feature, {});
+ var cap = layout2.get("line-cap");
+ var miterLimit = layout2.get("line-miter-limit");
+ var roundLimit = layout2.get("line-round-limit");
+ this.lineClips = this.lineFeatureClips(feature);
+ for (var i = 0, list = geometry; i < list.length; i += 1) {
+ var line = list[i];
+ this.addLine(line, feature, join, cap, miterLimit, roundLimit);
+ }
+ this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, feature, index, imagePositions, canonical);
+ };
+ LineBucket.prototype.addLine = function addLine(vertices, feature, join, cap, miterLimit, roundLimit) {
+ this.distance = 0;
+ this.scaledDistance = 0;
+ this.totalDistance = 0;
+ if (this.lineClips) {
+ this.lineClipsArray.push(this.lineClips);
+ for (var i = 0; i < vertices.length - 1; i++) {
+ this.totalDistance += vertices[i].dist(vertices[i + 1]);
+ }
+ this.updateScaledDistance();
+ this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance);
+ }
+ var isPolygon = vectorTileFeatureTypes$1[feature.type] === "Polygon";
+ var len = vertices.length;
+ while (len >= 2 && vertices[len - 1].equals(vertices[len - 2])) {
+ len--;
+ }
+ var first = 0;
+ while (first < len - 1 && vertices[first].equals(vertices[first + 1])) {
+ first++;
+ }
+ if (len < (isPolygon ? 3 : 2)) {
+ return;
+ }
+ if (join === "bevel") {
+ miterLimit = 1.05;
+ }
+ var sharpCornerOffset = this.overscaling <= 16 ? SHARP_CORNER_OFFSET * EXTENT$1 / (512 * this.overscaling) : 0;
+ var segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray);
+ var currentVertex;
+ var prevVertex = void 0;
+ var nextVertex = void 0;
+ var prevNormal = void 0;
+ var nextNormal = void 0;
+ this.e1 = this.e2 = -1;
+ if (isPolygon) {
+ currentVertex = vertices[len - 2];
+ nextNormal = vertices[first].sub(currentVertex)._unit()._perp();
+ }
+ for (var i$1 = first; i$1 < len; i$1++) {
+ nextVertex = i$1 === len - 1 ? isPolygon ? vertices[first + 1] : void 0 : vertices[i$1 + 1];
+ if (nextVertex && vertices[i$1].equals(nextVertex)) {
+ continue;
+ }
+ if (nextNormal) {
+ prevNormal = nextNormal;
+ }
+ if (currentVertex) {
+ prevVertex = currentVertex;
+ }
+ currentVertex = vertices[i$1];
+ nextNormal = nextVertex ? nextVertex.sub(currentVertex)._unit()._perp() : prevNormal;
+ prevNormal = prevNormal || nextNormal;
+ var joinNormal = prevNormal.add(nextNormal);
+ if (joinNormal.x !== 0 || joinNormal.y !== 0) {
+ joinNormal._unit();
+ }
+ var cosAngle = prevNormal.x * nextNormal.x + prevNormal.y * nextNormal.y;
+ var cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y;
+ var miterLength = cosHalfAngle !== 0 ? 1 / cosHalfAngle : Infinity;
+ var approxAngle = 2 * Math.sqrt(2 - 2 * cosHalfAngle);
+ var isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex;
+ var lineTurnsLeft = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0;
+ if (isSharpCorner && i$1 > first) {
+ var prevSegmentLength = currentVertex.dist(prevVertex);
+ if (prevSegmentLength > 2 * sharpCornerOffset) {
+ var newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round());
+ this.updateDistance(prevVertex, newPrevVertex);
+ this.addCurrentVertex(newPrevVertex, prevNormal, 0, 0, segment);
+ prevVertex = newPrevVertex;
+ }
+ }
+ var middleVertex = prevVertex && nextVertex;
+ var currentJoin = middleVertex ? join : isPolygon ? "butt" : cap;
+ if (middleVertex && currentJoin === "round") {
+ if (miterLength < roundLimit) {
+ currentJoin = "miter";
+ } else if (miterLength <= 2) {
+ currentJoin = "fakeround";
+ }
+ }
+ if (currentJoin === "miter" && miterLength > miterLimit) {
+ currentJoin = "bevel";
+ }
+ if (currentJoin === "bevel") {
+ if (miterLength > 2) {
+ currentJoin = "flipbevel";
+ }
+ if (miterLength < miterLimit) {
+ currentJoin = "miter";
+ }
+ }
+ if (prevVertex) {
+ this.updateDistance(prevVertex, currentVertex);
+ }
+ if (currentJoin === "miter") {
+ joinNormal._mult(miterLength);
+ this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);
+ } else if (currentJoin === "flipbevel") {
+ if (miterLength > 100) {
+ joinNormal = nextNormal.mult(-1);
+ } else {
+ var bevelLength = miterLength * prevNormal.add(nextNormal).mag() / prevNormal.sub(nextNormal).mag();
+ joinNormal._perp()._mult(bevelLength * (lineTurnsLeft ? -1 : 1));
+ }
+ this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);
+ this.addCurrentVertex(currentVertex, joinNormal.mult(-1), 0, 0, segment);
+ } else if (currentJoin === "bevel" || currentJoin === "fakeround") {
+ var offset = -Math.sqrt(miterLength * miterLength - 1);
+ var offsetA = lineTurnsLeft ? offset : 0;
+ var offsetB = lineTurnsLeft ? 0 : offset;
+ if (prevVertex) {
+ this.addCurrentVertex(currentVertex, prevNormal, offsetA, offsetB, segment);
+ }
+ if (currentJoin === "fakeround") {
+ var n = Math.round(approxAngle * 180 / Math.PI / DEG_PER_TRIANGLE);
+ for (var m = 1; m < n; m++) {
+ var t = m / n;
+ if (t !== 0.5) {
+ var t23 = t - 0.5;
+ var A2 = 1.0904 + cosAngle * (-3.2452 + cosAngle * (3.55645 - cosAngle * 1.43519));
+ var B2 = 0.848013 + cosAngle * (-1.06021 + cosAngle * 0.215638);
+ t = t + t * t23 * (t - 1) * (A2 * t23 * t23 + B2);
+ }
+ var extrude = nextNormal.sub(prevNormal)._mult(t)._add(prevNormal)._unit()._mult(lineTurnsLeft ? -1 : 1);
+ this.addHalfVertex(currentVertex, extrude.x, extrude.y, false, lineTurnsLeft, 0, segment);
+ }
+ }
+ if (nextVertex) {
+ this.addCurrentVertex(currentVertex, nextNormal, -offsetA, -offsetB, segment);
+ }
+ } else if (currentJoin === "butt") {
+ this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment);
+ } else if (currentJoin === "square") {
+ var offset$1 = prevVertex ? 1 : -1;
+ this.addCurrentVertex(currentVertex, joinNormal, offset$1, offset$1, segment);
+ } else if (currentJoin === "round") {
+ if (prevVertex) {
+ this.addCurrentVertex(currentVertex, prevNormal, 0, 0, segment);
+ this.addCurrentVertex(currentVertex, prevNormal, 1, 1, segment, true);
+ }
+ if (nextVertex) {
+ this.addCurrentVertex(currentVertex, nextNormal, -1, -1, segment, true);
+ this.addCurrentVertex(currentVertex, nextNormal, 0, 0, segment);
+ }
+ }
+ if (isSharpCorner && i$1 < len - 1) {
+ var nextSegmentLength = currentVertex.dist(nextVertex);
+ if (nextSegmentLength > 2 * sharpCornerOffset) {
+ var newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round());
+ this.updateDistance(currentVertex, newCurrentVertex);
+ this.addCurrentVertex(newCurrentVertex, nextNormal, 0, 0, segment);
+ currentVertex = newCurrentVertex;
+ }
+ }
+ }
+ };
+ LineBucket.prototype.addCurrentVertex = function addCurrentVertex(p, normal, endLeft, endRight, segment, round) {
+ if (round === void 0)
+ round = false;
+ var leftX = normal.x + normal.y * endLeft;
+ var leftY = normal.y - normal.x * endLeft;
+ var rightX = -normal.x + normal.y * endRight;
+ var rightY = -normal.y - normal.x * endRight;
+ this.addHalfVertex(p, leftX, leftY, round, false, endLeft, segment);
+ this.addHalfVertex(p, rightX, rightY, round, true, -endRight, segment);
+ if (this.distance > MAX_LINE_DISTANCE / 2 && this.totalDistance === 0) {
+ this.distance = 0;
+ this.addCurrentVertex(p, normal, endLeft, endRight, segment, round);
+ }
+ };
+ LineBucket.prototype.addHalfVertex = function addHalfVertex(ref, extrudeX, extrudeY, round, up, dir, segment) {
+ var x = ref.x;
+ var y = ref.y;
+ var totalDistance = this.lineClips ? this.scaledDistance * (MAX_LINE_DISTANCE - 1) : this.scaledDistance;
+ var linesofarScaled = totalDistance * LINE_DISTANCE_SCALE;
+ this.layoutVertexArray.emplaceBack((x << 1) + (round ? 1 : 0), (y << 1) + (up ? 1 : 0), Math.round(EXTRUDE_SCALE * extrudeX) + 128, Math.round(EXTRUDE_SCALE * extrudeY) + 128, (dir === 0 ? 0 : dir < 0 ? -1 : 1) + 1 | (linesofarScaled & 63) << 2, linesofarScaled >> 6);
+ if (this.lineClips) {
+ var progressRealigned = this.scaledDistance - this.lineClips.start;
+ var endClipRealigned = this.lineClips.end - this.lineClips.start;
+ var uvX = progressRealigned / endClipRealigned;
+ this.layoutVertexArray2.emplaceBack(uvX, this.lineClipsArray.length);
+ }
+ var e = segment.vertexLength++;
+ if (this.e1 >= 0 && this.e2 >= 0) {
+ this.indexArray.emplaceBack(this.e1, this.e2, e);
+ segment.primitiveLength++;
+ }
+ if (up) {
+ this.e2 = e;
+ } else {
+ this.e1 = e;
+ }
+ };
+ LineBucket.prototype.updateScaledDistance = function updateScaledDistance() {
+ this.scaledDistance = this.lineClips ? this.lineClips.start + (this.lineClips.end - this.lineClips.start) * this.distance / this.totalDistance : this.distance;
+ };
+ LineBucket.prototype.updateDistance = function updateDistance(prev, next) {
+ this.distance += prev.dist(next);
+ this.updateScaledDistance();
+ };
+ register("LineBucket", LineBucket, {
+ omit: [
+ "layers",
+ "patternFeatures"
+ ]
+ });
+ var layout$6 = new Properties({
+ "line-cap": new DataConstantProperty(spec["layout_line"]["line-cap"]),
+ "line-join": new DataDrivenProperty(spec["layout_line"]["line-join"]),
+ "line-miter-limit": new DataConstantProperty(spec["layout_line"]["line-miter-limit"]),
+ "line-round-limit": new DataConstantProperty(spec["layout_line"]["line-round-limit"]),
+ "line-sort-key": new DataDrivenProperty(spec["layout_line"]["line-sort-key"])
+ });
+ var paint$6 = new Properties({
+ "line-opacity": new DataDrivenProperty(spec["paint_line"]["line-opacity"]),
+ "line-color": new DataDrivenProperty(spec["paint_line"]["line-color"]),
+ "line-translate": new DataConstantProperty(spec["paint_line"]["line-translate"]),
+ "line-translate-anchor": new DataConstantProperty(spec["paint_line"]["line-translate-anchor"]),
+ "line-width": new DataDrivenProperty(spec["paint_line"]["line-width"]),
+ "line-gap-width": new DataDrivenProperty(spec["paint_line"]["line-gap-width"]),
+ "line-offset": new DataDrivenProperty(spec["paint_line"]["line-offset"]),
+ "line-blur": new DataDrivenProperty(spec["paint_line"]["line-blur"]),
+ "line-dasharray": new CrossFadedProperty(spec["paint_line"]["line-dasharray"]),
+ "line-pattern": new CrossFadedDataDrivenProperty(spec["paint_line"]["line-pattern"]),
+ "line-gradient": new ColorRampProperty(spec["paint_line"]["line-gradient"])
+ });
+ var properties$5 = {
+ paint: paint$6,
+ layout: layout$6
+ };
+ var LineFloorwidthProperty = function(DataDrivenProperty2) {
+ function LineFloorwidthProperty2() {
+ DataDrivenProperty2.apply(this, arguments);
+ }
+ if (DataDrivenProperty2)
+ LineFloorwidthProperty2.__proto__ = DataDrivenProperty2;
+ LineFloorwidthProperty2.prototype = Object.create(DataDrivenProperty2 && DataDrivenProperty2.prototype);
+ LineFloorwidthProperty2.prototype.constructor = LineFloorwidthProperty2;
+ LineFloorwidthProperty2.prototype.possiblyEvaluate = function possiblyEvaluate(value, parameters) {
+ parameters = new EvaluationParameters(Math.floor(parameters.zoom), {
+ now: parameters.now,
+ fadeDuration: parameters.fadeDuration,
+ zoomHistory: parameters.zoomHistory,
+ transition: parameters.transition
+ });
+ return DataDrivenProperty2.prototype.possiblyEvaluate.call(this, value, parameters);
+ };
+ LineFloorwidthProperty2.prototype.evaluate = function evaluate(value, globals, feature, featureState) {
+ globals = extend2({}, globals, { zoom: Math.floor(globals.zoom) });
+ return DataDrivenProperty2.prototype.evaluate.call(this, value, globals, feature, featureState);
+ };
+ return LineFloorwidthProperty2;
+ }(DataDrivenProperty);
+ var lineFloorwidthProperty = new LineFloorwidthProperty(properties$5.paint.properties["line-width"].specification);
+ lineFloorwidthProperty.useIntegerZoom = true;
+ var LineStyleLayer = function(StyleLayer2) {
+ function LineStyleLayer2(layer2) {
+ StyleLayer2.call(this, layer2, properties$5);
+ this.gradientVersion = 0;
+ }
+ if (StyleLayer2)
+ LineStyleLayer2.__proto__ = StyleLayer2;
+ LineStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ LineStyleLayer2.prototype.constructor = LineStyleLayer2;
+ LineStyleLayer2.prototype._handleSpecialPaintPropertyUpdate = function _handleSpecialPaintPropertyUpdate(name3) {
+ if (name3 === "line-gradient") {
+ var expression2 = this._transitionablePaint._values["line-gradient"].value.expression;
+ this.stepInterpolant = expression2._styleExpression.expression instanceof Step;
+ this.gradientVersion = (this.gradientVersion + 1) % MAX_SAFE_INTEGER;
+ }
+ };
+ LineStyleLayer2.prototype.gradientExpression = function gradientExpression() {
+ return this._transitionablePaint._values["line-gradient"].value.expression;
+ };
+ LineStyleLayer2.prototype.recalculate = function recalculate(parameters, availableImages) {
+ StyleLayer2.prototype.recalculate.call(this, parameters, availableImages);
+ this.paint._values["line-floorwidth"] = lineFloorwidthProperty.possiblyEvaluate(this._transitioningPaint._values["line-width"].value, parameters);
+ };
+ LineStyleLayer2.prototype.createBucket = function createBucket(parameters) {
+ return new LineBucket(parameters);
+ };
+ LineStyleLayer2.prototype.queryRadius = function queryRadius(bucket) {
+ var lineBucket = bucket;
+ var width = getLineWidth(getMaximumPaintValue("line-width", this, lineBucket), getMaximumPaintValue("line-gap-width", this, lineBucket));
+ var offset = getMaximumPaintValue("line-offset", this, lineBucket);
+ return width / 2 + Math.abs(offset) + translateDistance(this.paint.get("line-translate"));
+ };
+ LineStyleLayer2.prototype.queryIntersectsFeature = function queryIntersectsFeature(queryGeometry, feature, featureState, geometry, zoom, transform, pixelsToTileUnits) {
+ var translatedPolygon = translate(queryGeometry, this.paint.get("line-translate"), this.paint.get("line-translate-anchor"), transform.angle, pixelsToTileUnits);
+ var halfWidth = pixelsToTileUnits / 2 * getLineWidth(this.paint.get("line-width").evaluate(feature, featureState), this.paint.get("line-gap-width").evaluate(feature, featureState));
+ var lineOffset = this.paint.get("line-offset").evaluate(feature, featureState);
+ if (lineOffset) {
+ geometry = offsetLine(geometry, lineOffset * pixelsToTileUnits);
+ }
+ return polygonIntersectsBufferedMultiLine(translatedPolygon, geometry, halfWidth);
+ };
+ LineStyleLayer2.prototype.isTileClipped = function isTileClipped() {
+ return true;
+ };
+ return LineStyleLayer2;
+ }(StyleLayer);
+ function getLineWidth(lineWidth, lineGapWidth) {
+ if (lineGapWidth > 0) {
+ return lineGapWidth + 2 * lineWidth;
+ } else {
+ return lineWidth;
+ }
+ }
+ function offsetLine(rings, offset) {
+ var newRings = [];
+ var zero2 = new pointGeometry(0, 0);
+ for (var k = 0; k < rings.length; k++) {
+ var ring = rings[k];
+ var newRing = [];
+ for (var i = 0; i < ring.length; i++) {
+ var a = ring[i - 1];
+ var b = ring[i];
+ var c = ring[i + 1];
+ var aToB = i === 0 ? zero2 : b.sub(a)._unit()._perp();
+ var bToC = i === ring.length - 1 ? zero2 : c.sub(b)._unit()._perp();
+ var extrude = aToB._add(bToC)._unit();
+ var cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y;
+ extrude._mult(1 / cosHalfAngle);
+ newRing.push(extrude._mult(offset)._add(b));
+ }
+ newRings.push(newRing);
+ }
+ return newRings;
+ }
+ var symbolLayoutAttributes = createLayout([
+ {
+ name: "a_pos_offset",
+ components: 4,
+ type: "Int16"
+ },
+ {
+ name: "a_data",
+ components: 4,
+ type: "Uint16"
+ },
+ {
+ name: "a_pixeloffset",
+ components: 4,
+ type: "Int16"
+ }
+ ], 4);
+ var dynamicLayoutAttributes = createLayout([{
+ name: "a_projected_pos",
+ components: 3,
+ type: "Float32"
+ }], 4);
+ var placementOpacityAttributes = createLayout([{
+ name: "a_fade_opacity",
+ components: 1,
+ type: "Uint32"
+ }], 4);
+ var collisionVertexAttributes = createLayout([
+ {
+ name: "a_placed",
+ components: 2,
+ type: "Uint8"
+ },
+ {
+ name: "a_shift",
+ components: 2,
+ type: "Float32"
+ }
+ ]);
+ var collisionBox = createLayout([
+ {
+ type: "Int16",
+ name: "anchorPointX"
+ },
+ {
+ type: "Int16",
+ name: "anchorPointY"
+ },
+ {
+ type: "Int16",
+ name: "x1"
+ },
+ {
+ type: "Int16",
+ name: "y1"
+ },
+ {
+ type: "Int16",
+ name: "x2"
+ },
+ {
+ type: "Int16",
+ name: "y2"
+ },
+ {
+ type: "Uint32",
+ name: "featureIndex"
+ },
+ {
+ type: "Uint16",
+ name: "sourceLayerIndex"
+ },
+ {
+ type: "Uint16",
+ name: "bucketIndex"
+ }
+ ]);
+ var collisionBoxLayout = createLayout([
+ {
+ name: "a_pos",
+ components: 2,
+ type: "Int16"
+ },
+ {
+ name: "a_anchor_pos",
+ components: 2,
+ type: "Int16"
+ },
+ {
+ name: "a_extrude",
+ components: 2,
+ type: "Int16"
+ }
+ ], 4);
+ var collisionCircleLayout = createLayout([
+ {
+ name: "a_pos",
+ components: 2,
+ type: "Float32"
+ },
+ {
+ name: "a_radius",
+ components: 1,
+ type: "Float32"
+ },
+ {
+ name: "a_flags",
+ components: 2,
+ type: "Int16"
+ }
+ ], 4);
+ var quadTriangle = createLayout([{
+ name: "triangle",
+ components: 3,
+ type: "Uint16"
+ }]);
+ var placement = createLayout([
+ {
+ type: "Int16",
+ name: "anchorX"
+ },
+ {
+ type: "Int16",
+ name: "anchorY"
+ },
+ {
+ type: "Uint16",
+ name: "glyphStartIndex"
+ },
+ {
+ type: "Uint16",
+ name: "numGlyphs"
+ },
+ {
+ type: "Uint32",
+ name: "vertexStartIndex"
+ },
+ {
+ type: "Uint32",
+ name: "lineStartIndex"
+ },
+ {
+ type: "Uint32",
+ name: "lineLength"
+ },
+ {
+ type: "Uint16",
+ name: "segment"
+ },
+ {
+ type: "Uint16",
+ name: "lowerSize"
+ },
+ {
+ type: "Uint16",
+ name: "upperSize"
+ },
+ {
+ type: "Float32",
+ name: "lineOffsetX"
+ },
+ {
+ type: "Float32",
+ name: "lineOffsetY"
+ },
+ {
+ type: "Uint8",
+ name: "writingMode"
+ },
+ {
+ type: "Uint8",
+ name: "placedOrientation"
+ },
+ {
+ type: "Uint8",
+ name: "hidden"
+ },
+ {
+ type: "Uint32",
+ name: "crossTileID"
+ },
+ {
+ type: "Int16",
+ name: "associatedIconIndex"
+ }
+ ]);
+ var symbolInstance = createLayout([
+ {
+ type: "Int16",
+ name: "anchorX"
+ },
+ {
+ type: "Int16",
+ name: "anchorY"
+ },
+ {
+ type: "Int16",
+ name: "rightJustifiedTextSymbolIndex"
+ },
+ {
+ type: "Int16",
+ name: "centerJustifiedTextSymbolIndex"
+ },
+ {
+ type: "Int16",
+ name: "leftJustifiedTextSymbolIndex"
+ },
+ {
+ type: "Int16",
+ name: "verticalPlacedTextSymbolIndex"
+ },
+ {
+ type: "Int16",
+ name: "placedIconSymbolIndex"
+ },
+ {
+ type: "Int16",
+ name: "verticalPlacedIconSymbolIndex"
+ },
+ {
+ type: "Uint16",
+ name: "key"
+ },
+ {
+ type: "Uint16",
+ name: "textBoxStartIndex"
+ },
+ {
+ type: "Uint16",
+ name: "textBoxEndIndex"
+ },
+ {
+ type: "Uint16",
+ name: "verticalTextBoxStartIndex"
+ },
+ {
+ type: "Uint16",
+ name: "verticalTextBoxEndIndex"
+ },
+ {
+ type: "Uint16",
+ name: "iconBoxStartIndex"
+ },
+ {
+ type: "Uint16",
+ name: "iconBoxEndIndex"
+ },
+ {
+ type: "Uint16",
+ name: "verticalIconBoxStartIndex"
+ },
+ {
+ type: "Uint16",
+ name: "verticalIconBoxEndIndex"
+ },
+ {
+ type: "Uint16",
+ name: "featureIndex"
+ },
+ {
+ type: "Uint16",
+ name: "numHorizontalGlyphVertices"
+ },
+ {
+ type: "Uint16",
+ name: "numVerticalGlyphVertices"
+ },
+ {
+ type: "Uint16",
+ name: "numIconVertices"
+ },
+ {
+ type: "Uint16",
+ name: "numVerticalIconVertices"
+ },
+ {
+ type: "Uint16",
+ name: "useRuntimeCollisionCircles"
+ },
+ {
+ type: "Uint32",
+ name: "crossTileID"
+ },
+ {
+ type: "Float32",
+ name: "textBoxScale"
+ },
+ {
+ type: "Float32",
+ components: 2,
+ name: "textOffset"
+ },
+ {
+ type: "Float32",
+ name: "collisionCircleDiameter"
+ }
+ ]);
+ var glyphOffset = createLayout([{
+ type: "Float32",
+ name: "offsetX"
+ }]);
+ var lineVertex = createLayout([
+ {
+ type: "Int16",
+ name: "x"
+ },
+ {
+ type: "Int16",
+ name: "y"
+ },
+ {
+ type: "Int16",
+ name: "tileUnitDistanceFromAnchor"
+ }
+ ]);
+ function transformText(text, layer2, feature) {
+ var transform = layer2.layout.get("text-transform").evaluate(feature, {});
+ if (transform === "uppercase") {
+ text = text.toLocaleUpperCase();
+ } else if (transform === "lowercase") {
+ text = text.toLocaleLowerCase();
+ }
+ if (plugin.applyArabicShaping) {
+ text = plugin.applyArabicShaping(text);
+ }
+ return text;
+ }
+ function transformText$1(text, layer2, feature) {
+ text.sections.forEach(function(section) {
+ section.text = transformText(section.text, layer2, feature);
+ });
+ return text;
+ }
+ function mergeLines(features) {
+ var leftIndex = {};
+ var rightIndex = {};
+ var mergedFeatures = [];
+ var mergedIndex = 0;
+ function add2(k2) {
+ mergedFeatures.push(features[k2]);
+ mergedIndex++;
+ }
+ function mergeFromRight(leftKey2, rightKey2, geom2) {
+ var i2 = rightIndex[leftKey2];
+ delete rightIndex[leftKey2];
+ rightIndex[rightKey2] = i2;
+ mergedFeatures[i2].geometry[0].pop();
+ mergedFeatures[i2].geometry[0] = mergedFeatures[i2].geometry[0].concat(geom2[0]);
+ return i2;
+ }
+ function mergeFromLeft(leftKey2, rightKey2, geom2) {
+ var i2 = leftIndex[rightKey2];
+ delete leftIndex[rightKey2];
+ leftIndex[leftKey2] = i2;
+ mergedFeatures[i2].geometry[0].shift();
+ mergedFeatures[i2].geometry[0] = geom2[0].concat(mergedFeatures[i2].geometry[0]);
+ return i2;
+ }
+ function getKey(text2, geom2, onRight) {
+ var point = onRight ? geom2[0][geom2[0].length - 1] : geom2[0][0];
+ return text2 + ":" + point.x + ":" + point.y;
+ }
+ for (var k = 0; k < features.length; k++) {
+ var feature = features[k];
+ var geom = feature.geometry;
+ var text = feature.text ? feature.text.toString() : null;
+ if (!text) {
+ add2(k);
+ continue;
+ }
+ var leftKey = getKey(text, geom), rightKey = getKey(text, geom, true);
+ if (leftKey in rightIndex && rightKey in leftIndex && rightIndex[leftKey] !== leftIndex[rightKey]) {
+ var j = mergeFromLeft(leftKey, rightKey, geom);
+ var i = mergeFromRight(leftKey, rightKey, mergedFeatures[j].geometry);
+ delete leftIndex[leftKey];
+ delete rightIndex[rightKey];
+ rightIndex[getKey(text, mergedFeatures[i].geometry, true)] = i;
+ mergedFeatures[j].geometry = null;
+ } else if (leftKey in rightIndex) {
+ mergeFromRight(leftKey, rightKey, geom);
+ } else if (rightKey in leftIndex) {
+ mergeFromLeft(leftKey, rightKey, geom);
+ } else {
+ add2(k);
+ leftIndex[leftKey] = mergedIndex - 1;
+ rightIndex[rightKey] = mergedIndex - 1;
+ }
+ }
+ return mergedFeatures.filter(function(f) {
+ return f.geometry;
+ });
+ }
+ var verticalizedCharacterMap = {
+ "!": "\uFE15",
+ "#": "\uFF03",
+ "$": "\uFF04",
+ "%": "\uFF05",
+ "&": "\uFF06",
+ "(": "\uFE35",
+ ")": "\uFE36",
+ "*": "\uFF0A",
+ "+": "\uFF0B",
+ ",": "\uFE10",
+ "-": "\uFE32",
+ ".": "\u30FB",
+ "/": "\uFF0F",
+ ":": "\uFE13",
+ ";": "\uFE14",
+ "<": "\uFE3F",
+ "=": "\uFF1D",
+ ">": "\uFE40",
+ "?": "\uFE16",
+ "@": "\uFF20",
+ "[": "\uFE47",
+ "\\": "\uFF3C",
+ "]": "\uFE48",
+ "^": "\uFF3E",
+ "_": "\uFE33",
+ "`": "\uFF40",
+ "{": "\uFE37",
+ "|": "\u2015",
+ "}": "\uFE38",
+ "~": "\uFF5E",
+ "\xA2": "\uFFE0",
+ "\xA3": "\uFFE1",
+ "\xA5": "\uFFE5",
+ "\xA6": "\uFFE4",
+ "\xAC": "\uFFE2",
+ "\xAF": "\uFFE3",
+ "\u2013": "\uFE32",
+ "\u2014": "\uFE31",
+ "\u2018": "\uFE43",
+ "\u2019": "\uFE44",
+ "\u201C": "\uFE41",
+ "\u201D": "\uFE42",
+ "\u2026": "\uFE19",
+ "\u2027": "\u30FB",
+ "\u20A9": "\uFFE6",
+ "\u3001": "\uFE11",
+ "\u3002": "\uFE12",
+ "\u3008": "\uFE3F",
+ "\u3009": "\uFE40",
+ "\u300A": "\uFE3D",
+ "\u300B": "\uFE3E",
+ "\u300C": "\uFE41",
+ "\u300D": "\uFE42",
+ "\u300E": "\uFE43",
+ "\u300F": "\uFE44",
+ "\u3010": "\uFE3B",
+ "\u3011": "\uFE3C",
+ "\u3014": "\uFE39",
+ "\u3015": "\uFE3A",
+ "\u3016": "\uFE17",
+ "\u3017": "\uFE18",
+ "\uFF01": "\uFE15",
+ "\uFF08": "\uFE35",
+ "\uFF09": "\uFE36",
+ "\uFF0C": "\uFE10",
+ "\uFF0D": "\uFE32",
+ "\uFF0E": "\u30FB",
+ "\uFF1A": "\uFE13",
+ "\uFF1B": "\uFE14",
+ "\uFF1C": "\uFE3F",
+ "\uFF1E": "\uFE40",
+ "\uFF1F": "\uFE16",
+ "\uFF3B": "\uFE47",
+ "\uFF3D": "\uFE48",
+ "\uFF3F": "\uFE33",
+ "\uFF5B": "\uFE37",
+ "\uFF5C": "\u2015",
+ "\uFF5D": "\uFE38",
+ "\uFF5F": "\uFE35",
+ "\uFF60": "\uFE36",
+ "\uFF61": "\uFE12",
+ "\uFF62": "\uFE41",
+ "\uFF63": "\uFE42"
+ };
+ function verticalizePunctuation(input) {
+ var output = "";
+ for (var i = 0; i < input.length; i++) {
+ var nextCharCode = input.charCodeAt(i + 1) || null;
+ var prevCharCode = input.charCodeAt(i - 1) || null;
+ var canReplacePunctuation = (!nextCharCode || !charHasRotatedVerticalOrientation(nextCharCode) || verticalizedCharacterMap[input[i + 1]]) && (!prevCharCode || !charHasRotatedVerticalOrientation(prevCharCode) || verticalizedCharacterMap[input[i - 1]]);
+ if (canReplacePunctuation && verticalizedCharacterMap[input[i]]) {
+ output += verticalizedCharacterMap[input[i]];
+ } else {
+ output += input[i];
+ }
+ }
+ return output;
+ }
+ var ONE_EM = 24;
+ var 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);
+ };
+ var 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 & 255, i += d, m /= 256, mLen -= 8) {
+ }
+ e = e << mLen | m;
+ eLen += mLen;
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
+ }
+ buffer[offset + i - d] |= s * 128;
+ };
+ var ieee754 = {
+ read,
+ write
+ };
+ var pbf = Pbf;
+ 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;
+ Pbf.Fixed64 = 1;
+ Pbf.Bytes = 2;
+ Pbf.Fixed32 = 5;
+ var SHIFT_LEFT_32 = (1 << 16) * (1 << 16), SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
+ var TEXT_DECODER_MIN_LENGTH = 12;
+ var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf8");
+ Pbf.prototype = {
+ destroy: function() {
+ this.buf = null;
+ },
+ 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 & 7;
+ 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;
+ },
+ 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 & 127;
+ if (b < 128) {
+ return val;
+ }
+ b = buf[this.pos++];
+ val |= (b & 127) << 7;
+ if (b < 128) {
+ return val;
+ }
+ b = buf[this.pos++];
+ val |= (b & 127) << 14;
+ if (b < 128) {
+ return val;
+ }
+ b = buf[this.pos++];
+ val |= (b & 127) << 21;
+ if (b < 128) {
+ return val;
+ }
+ b = buf[this.pos];
+ val |= (b & 15) << 28;
+ return readVarintRemainder(val, isSigned, this);
+ },
+ readVarint64: function() {
+ return this.readVarint(true);
+ },
+ readSVarint: function() {
+ var num = this.readVarint();
+ return num % 2 === 1 ? (num + 1) / -2 : num / 2;
+ },
+ 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) {
+ return readUtf8TextDecoder(this.buf, pos, end);
+ }
+ 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;
+ },
+ 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 & 7;
+ if (type === Pbf.Varint) {
+ while (this.buf[this.pos++] > 127) {
+ }
+ } 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);
+ }
+ },
+ 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 > 268435455 || val < 0) {
+ writeBigVarint(val, this);
+ return;
+ }
+ this.realloc(4);
+ this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
+ if (val <= 127) {
+ return;
+ }
+ this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
+ if (val <= 127) {
+ return;
+ }
+ this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
+ if (val <= 127) {
+ return;
+ }
+ this.buf[this.pos++] = val >>> 7 & 127;
+ },
+ 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++;
+ var startPos = this.pos;
+ this.pos = writeUtf8(this.buf, str, this.pos);
+ var len = this.pos - startPos;
+ if (len >= 128) {
+ makeRoomForExtraLength(startPos, len, this);
+ }
+ 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++;
+ var startPos = this.pos;
+ fn(obj, this);
+ var len = this.pos - startPos;
+ if (len >= 128) {
+ makeRoomForExtraLength(startPos, len, this);
+ }
+ 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 & 112) >> 4;
+ if (b < 128) {
+ return toNum(l, h, s);
+ }
+ b = buf[p.pos++];
+ h |= (b & 127) << 3;
+ if (b < 128) {
+ return toNum(l, h, s);
+ }
+ b = buf[p.pos++];
+ h |= (b & 127) << 10;
+ if (b < 128) {
+ return toNum(l, h, s);
+ }
+ b = buf[p.pos++];
+ h |= (b & 127) << 17;
+ if (b < 128) {
+ return toNum(l, h, s);
+ }
+ b = buf[p.pos++];
+ h |= (b & 127) << 24;
+ if (b < 128) {
+ return toNum(l, h, s);
+ }
+ b = buf[p.pos++];
+ h |= (b & 1) << 31;
+ if (b < 128) {
+ return toNum(l, h, s);
+ }
+ throw new Error("Expected varint not more than 10 bytes");
+ }
+ function readPackedEnd(pbf2) {
+ return pbf2.type === Pbf.Bytes ? pbf2.readVarint() + pbf2.pos : pbf2.pos + 1;
+ }
+ function toNum(low, high, isSigned) {
+ if (isSigned) {
+ return high * 4294967296 + (low >>> 0);
+ }
+ return (high >>> 0) * 4294967296 + (low >>> 0);
+ }
+ function writeBigVarint(val, pbf2) {
+ var low, high;
+ if (val >= 0) {
+ low = val % 4294967296 | 0;
+ high = val / 4294967296 | 0;
+ } else {
+ low = ~(-val % 4294967296);
+ high = ~(-val / 4294967296);
+ if (low ^ 4294967295) {
+ low = low + 1 | 0;
+ } else {
+ low = 0;
+ high = high + 1 | 0;
+ }
+ }
+ if (val >= 18446744073709552e3 || val < -18446744073709552e3) {
+ throw new Error("Given varint doesn't fit into 10 bytes");
+ }
+ pbf2.realloc(10);
+ writeBigVarintLow(low, high, pbf2);
+ writeBigVarintHigh(high, pbf2);
+ }
+ function writeBigVarintLow(low, high, pbf2) {
+ pbf2.buf[pbf2.pos++] = low & 127 | 128;
+ low >>>= 7;
+ pbf2.buf[pbf2.pos++] = low & 127 | 128;
+ low >>>= 7;
+ pbf2.buf[pbf2.pos++] = low & 127 | 128;
+ low >>>= 7;
+ pbf2.buf[pbf2.pos++] = low & 127 | 128;
+ low >>>= 7;
+ pbf2.buf[pbf2.pos] = low & 127;
+ }
+ function writeBigVarintHigh(high, pbf2) {
+ var lsb = (high & 7) << 4;
+ pbf2.buf[pbf2.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);
+ if (!high) {
+ return;
+ }
+ pbf2.buf[pbf2.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
+ if (!high) {
+ return;
+ }
+ pbf2.buf[pbf2.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
+ if (!high) {
+ return;
+ }
+ pbf2.buf[pbf2.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
+ if (!high) {
+ return;
+ }
+ pbf2.buf[pbf2.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
+ if (!high) {
+ return;
+ }
+ pbf2.buf[pbf2.pos++] = high & 127;
+ }
+ function makeRoomForExtraLength(startPos, len, pbf2) {
+ var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
+ pbf2.realloc(extraLen);
+ for (var i = pbf2.pos - 1; i >= startPos; i--) {
+ pbf2.buf[i + extraLen] = pbf2.buf[i];
+ }
+ }
+ function writePackedVarint(arr, pbf2) {
+ for (var i = 0; i < arr.length; i++) {
+ pbf2.writeVarint(arr[i]);
+ }
+ }
+ function writePackedSVarint(arr, pbf2) {
+ for (var i = 0; i < arr.length; i++) {
+ pbf2.writeSVarint(arr[i]);
+ }
+ }
+ function writePackedFloat(arr, pbf2) {
+ for (var i = 0; i < arr.length; i++) {
+ pbf2.writeFloat(arr[i]);
+ }
+ }
+ function writePackedDouble(arr, pbf2) {
+ for (var i = 0; i < arr.length; i++) {
+ pbf2.writeDouble(arr[i]);
+ }
+ }
+ function writePackedBoolean(arr, pbf2) {
+ for (var i = 0; i < arr.length; i++) {
+ pbf2.writeBoolean(arr[i]);
+ }
+ }
+ function writePackedFixed32(arr, pbf2) {
+ for (var i = 0; i < arr.length; i++) {
+ pbf2.writeFixed32(arr[i]);
+ }
+ }
+ function writePackedSFixed32(arr, pbf2) {
+ for (var i = 0; i < arr.length; i++) {
+ pbf2.writeSFixed32(arr[i]);
+ }
+ }
+ function writePackedFixed64(arr, pbf2) {
+ for (var i = 0; i < arr.length; i++) {
+ pbf2.writeFixed64(arr[i]);
+ }
+ }
+ function writePackedSFixed64(arr, pbf2) {
+ for (var i = 0; i < arr.length; i++) {
+ pbf2.writeSFixed64(arr[i]);
+ }
+ }
+ function readUInt32(buf, pos) {
+ return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + buf[pos + 3] * 16777216;
+ }
+ 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;
+ var bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
+ if (i + bytesPerSequence > end) {
+ break;
+ }
+ var b1, b2, b3;
+ if (bytesPerSequence === 1) {
+ if (b0 < 128) {
+ c = b0;
+ }
+ } else if (bytesPerSequence === 2) {
+ b1 = buf[i + 1];
+ if ((b1 & 192) === 128) {
+ c = (b0 & 31) << 6 | b1 & 63;
+ if (c <= 127) {
+ c = null;
+ }
+ }
+ } else if (bytesPerSequence === 3) {
+ b1 = buf[i + 1];
+ b2 = buf[i + 2];
+ if ((b1 & 192) === 128 && (b2 & 192) === 128) {
+ c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
+ if (c <= 2047 || c >= 55296 && c <= 57343) {
+ c = null;
+ }
+ }
+ } else if (bytesPerSequence === 4) {
+ b1 = buf[i + 1];
+ b2 = buf[i + 2];
+ b3 = buf[i + 3];
+ if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
+ c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
+ if (c <= 65535 || c >= 1114112) {
+ c = null;
+ }
+ }
+ }
+ if (c === null) {
+ c = 65533;
+ bytesPerSequence = 1;
+ } else if (c > 65535) {
+ c -= 65536;
+ str += String.fromCharCode(c >>> 10 & 1023 | 55296);
+ c = 56320 | c & 1023;
+ }
+ 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);
+ if (c > 55295 && c < 57344) {
+ if (lead) {
+ if (c < 56320) {
+ buf[pos++] = 239;
+ buf[pos++] = 191;
+ buf[pos++] = 189;
+ lead = c;
+ continue;
+ } else {
+ c = lead - 55296 << 10 | c - 56320 | 65536;
+ lead = null;
+ }
+ } else {
+ if (c > 56319 || i + 1 === str.length) {
+ buf[pos++] = 239;
+ buf[pos++] = 191;
+ buf[pos++] = 189;
+ } else {
+ lead = c;
+ }
+ continue;
+ }
+ } else if (lead) {
+ buf[pos++] = 239;
+ buf[pos++] = 191;
+ buf[pos++] = 189;
+ lead = null;
+ }
+ if (c < 128) {
+ buf[pos++] = c;
+ } else {
+ if (c < 2048) {
+ buf[pos++] = c >> 6 | 192;
+ } else {
+ if (c < 65536) {
+ buf[pos++] = c >> 12 | 224;
+ } else {
+ buf[pos++] = c >> 18 | 240;
+ buf[pos++] = c >> 12 & 63 | 128;
+ }
+ buf[pos++] = c >> 6 & 63 | 128;
+ }
+ buf[pos++] = c & 63 | 128;
+ }
+ }
+ return pos;
+ }
+ var border = 3;
+ function readFontstacks(tag, glyphs, pbf2) {
+ if (tag === 1) {
+ pbf2.readMessage(readFontstack, glyphs);
+ }
+ }
+ function readFontstack(tag, glyphs, pbf2) {
+ if (tag === 3) {
+ var ref = pbf2.readMessage(readGlyph, {});
+ var id2 = ref.id;
+ var bitmap = ref.bitmap;
+ var width = ref.width;
+ var height = ref.height;
+ var left = ref.left;
+ var top = ref.top;
+ var advance = ref.advance;
+ glyphs.push({
+ id: id2,
+ bitmap: new AlphaImage({
+ width: width + 2 * border,
+ height: height + 2 * border
+ }, bitmap),
+ metrics: {
+ width,
+ height,
+ left,
+ top,
+ advance
+ }
+ });
+ }
+ }
+ function readGlyph(tag, glyph, pbf2) {
+ if (tag === 1) {
+ glyph.id = pbf2.readVarint();
+ } else if (tag === 2) {
+ glyph.bitmap = pbf2.readBytes();
+ } else if (tag === 3) {
+ glyph.width = pbf2.readVarint();
+ } else if (tag === 4) {
+ glyph.height = pbf2.readVarint();
+ } else if (tag === 5) {
+ glyph.left = pbf2.readSVarint();
+ } else if (tag === 6) {
+ glyph.top = pbf2.readSVarint();
+ } else if (tag === 7) {
+ glyph.advance = pbf2.readVarint();
+ }
+ }
+ function parseGlyphPBF(data) {
+ return new pbf(data).readFields(readFontstacks, []);
+ }
+ var GLYPH_PBF_BORDER = border;
+ function potpack(boxes) {
+ var area2 = 0;
+ var maxWidth = 0;
+ for (var i$1 = 0, list = boxes; i$1 < list.length; i$1 += 1) {
+ var box = list[i$1];
+ area2 += box.w * box.h;
+ maxWidth = Math.max(maxWidth, box.w);
+ }
+ boxes.sort(function(a, b) {
+ return b.h - a.h;
+ });
+ var startWidth = Math.max(Math.ceil(Math.sqrt(area2 / 0.95)), maxWidth);
+ var spaces = [{ x: 0, y: 0, w: startWidth, h: Infinity }];
+ var width = 0;
+ var height = 0;
+ for (var i$2 = 0, list$1 = boxes; i$2 < list$1.length; i$2 += 1) {
+ var box$1 = list$1[i$2];
+ for (var i = spaces.length - 1; i >= 0; i--) {
+ var space = spaces[i];
+ if (box$1.w > space.w || box$1.h > space.h) {
+ continue;
+ }
+ box$1.x = space.x;
+ box$1.y = space.y;
+ height = Math.max(height, box$1.y + box$1.h);
+ width = Math.max(width, box$1.x + box$1.w);
+ if (box$1.w === space.w && box$1.h === space.h) {
+ var last = spaces.pop();
+ if (i < spaces.length) {
+ spaces[i] = last;
+ }
+ } else if (box$1.h === space.h) {
+ space.x += box$1.w;
+ space.w -= box$1.w;
+ } else if (box$1.w === space.w) {
+ space.y += box$1.h;
+ space.h -= box$1.h;
+ } else {
+ spaces.push({
+ x: space.x + box$1.w,
+ y: space.y,
+ w: space.w - box$1.w,
+ h: box$1.h
+ });
+ space.y += box$1.h;
+ space.h -= box$1.h;
+ }
+ break;
+ }
+ }
+ return {
+ w: width,
+ // container width
+ h: height,
+ // container height
+ fill: area2 / (width * height) || 0
+ // space utilization
+ };
+ }
+ var IMAGE_PADDING = 1;
+ var ImagePosition = function ImagePosition2(paddedRect, ref) {
+ var pixelRatio = ref.pixelRatio;
+ var version2 = ref.version;
+ var stretchX = ref.stretchX;
+ var stretchY = ref.stretchY;
+ var content = ref.content;
+ this.paddedRect = paddedRect;
+ this.pixelRatio = pixelRatio;
+ this.stretchX = stretchX;
+ this.stretchY = stretchY;
+ this.content = content;
+ this.version = version2;
+ };
+ var prototypeAccessors = {
+ tl: { configurable: true },
+ br: { configurable: true },
+ tlbr: { configurable: true },
+ displaySize: { configurable: true }
+ };
+ prototypeAccessors.tl.get = function() {
+ return [
+ this.paddedRect.x + IMAGE_PADDING,
+ this.paddedRect.y + IMAGE_PADDING
+ ];
+ };
+ prototypeAccessors.br.get = function() {
+ return [
+ this.paddedRect.x + this.paddedRect.w - IMAGE_PADDING,
+ this.paddedRect.y + this.paddedRect.h - IMAGE_PADDING
+ ];
+ };
+ prototypeAccessors.tlbr.get = function() {
+ return this.tl.concat(this.br);
+ };
+ prototypeAccessors.displaySize.get = function() {
+ return [
+ (this.paddedRect.w - IMAGE_PADDING * 2) / this.pixelRatio,
+ (this.paddedRect.h - IMAGE_PADDING * 2) / this.pixelRatio
+ ];
+ };
+ Object.defineProperties(ImagePosition.prototype, prototypeAccessors);
+ var ImageAtlas = function ImageAtlas2(icons, patterns) {
+ var iconPositions = {}, patternPositions = {};
+ this.haveRenderCallbacks = [];
+ var bins = [];
+ this.addImages(icons, iconPositions, bins);
+ this.addImages(patterns, patternPositions, bins);
+ var ref = potpack(bins);
+ var w = ref.w;
+ var h = ref.h;
+ var image = new RGBAImage({
+ width: w || 1,
+ height: h || 1
+ });
+ for (var id2 in icons) {
+ var src = icons[id2];
+ var bin = iconPositions[id2].paddedRect;
+ RGBAImage.copy(src.data, image, {
+ x: 0,
+ y: 0
+ }, {
+ x: bin.x + IMAGE_PADDING,
+ y: bin.y + IMAGE_PADDING
+ }, src.data);
+ }
+ for (var id$1 in patterns) {
+ var src$1 = patterns[id$1];
+ var bin$1 = patternPositions[id$1].paddedRect;
+ var x = bin$1.x + IMAGE_PADDING, y = bin$1.y + IMAGE_PADDING, w$1 = src$1.data.width, h$1 = src$1.data.height;
+ RGBAImage.copy(src$1.data, image, {
+ x: 0,
+ y: 0
+ }, {
+ x,
+ y
+ }, src$1.data);
+ RGBAImage.copy(src$1.data, image, {
+ x: 0,
+ y: h$1 - 1
+ }, {
+ x,
+ y: y - 1
+ }, {
+ width: w$1,
+ height: 1
+ });
+ RGBAImage.copy(src$1.data, image, {
+ x: 0,
+ y: 0
+ }, {
+ x,
+ y: y + h$1
+ }, {
+ width: w$1,
+ height: 1
+ });
+ RGBAImage.copy(src$1.data, image, {
+ x: w$1 - 1,
+ y: 0
+ }, {
+ x: x - 1,
+ y
+ }, {
+ width: 1,
+ height: h$1
+ });
+ RGBAImage.copy(src$1.data, image, {
+ x: 0,
+ y: 0
+ }, {
+ x: x + w$1,
+ y
+ }, {
+ width: 1,
+ height: h$1
+ });
+ }
+ this.image = image;
+ this.iconPositions = iconPositions;
+ this.patternPositions = patternPositions;
+ };
+ ImageAtlas.prototype.addImages = function addImages(images, positions, bins) {
+ for (var id2 in images) {
+ var src = images[id2];
+ var bin = {
+ x: 0,
+ y: 0,
+ w: src.data.width + 2 * IMAGE_PADDING,
+ h: src.data.height + 2 * IMAGE_PADDING
+ };
+ bins.push(bin);
+ positions[id2] = new ImagePosition(bin, src);
+ if (src.hasRenderCallback) {
+ this.haveRenderCallbacks.push(id2);
+ }
+ }
+ };
+ ImageAtlas.prototype.patchUpdatedImages = function patchUpdatedImages(imageManager, texture) {
+ imageManager.dispatchRenderCallbacks(this.haveRenderCallbacks);
+ for (var name3 in imageManager.updatedImages) {
+ this.patchUpdatedImage(this.iconPositions[name3], imageManager.getImage(name3), texture);
+ this.patchUpdatedImage(this.patternPositions[name3], imageManager.getImage(name3), texture);
+ }
+ };
+ ImageAtlas.prototype.patchUpdatedImage = function patchUpdatedImage(position, image, texture) {
+ if (!position || !image) {
+ return;
+ }
+ if (position.version === image.version) {
+ return;
+ }
+ position.version = image.version;
+ var ref = position.tl;
+ var x = ref[0];
+ var y = ref[1];
+ texture.update(image.data, void 0, {
+ x,
+ y
+ });
+ };
+ register("ImagePosition", ImagePosition);
+ register("ImageAtlas", ImageAtlas);
+ var WritingMode = {
+ horizontal: 1,
+ vertical: 2,
+ horizontalOnly: 3
+ };
+ var SHAPING_DEFAULT_OFFSET = -17;
+ function isEmpty(positionedLines) {
+ for (var i = 0, list = positionedLines; i < list.length; i += 1) {
+ var line = list[i];
+ if (line.positionedGlyphs.length !== 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+ var PUAbegin = 57344;
+ var PUAend = 63743;
+ var SectionOptions = function SectionOptions2() {
+ this.scale = 1;
+ this.fontStack = "";
+ this.imageName = null;
+ };
+ SectionOptions.forText = function forText(scale2, fontStack) {
+ var textOptions = new SectionOptions();
+ textOptions.scale = scale2 || 1;
+ textOptions.fontStack = fontStack;
+ return textOptions;
+ };
+ SectionOptions.forImage = function forImage(imageName) {
+ var imageOptions = new SectionOptions();
+ imageOptions.imageName = imageName;
+ return imageOptions;
+ };
+ var TaggedString = function TaggedString2() {
+ this.text = "";
+ this.sectionIndex = [];
+ this.sections = [];
+ this.imageSectionID = null;
+ };
+ TaggedString.fromFeature = function fromFeature(text, defaultFontStack) {
+ var result = new TaggedString();
+ for (var i = 0; i < text.sections.length; i++) {
+ var section = text.sections[i];
+ if (!section.image) {
+ result.addTextSection(section, defaultFontStack);
+ } else {
+ result.addImageSection(section);
+ }
+ }
+ return result;
+ };
+ TaggedString.prototype.length = function length() {
+ return this.text.length;
+ };
+ TaggedString.prototype.getSection = function getSection(index) {
+ return this.sections[this.sectionIndex[index]];
+ };
+ TaggedString.prototype.getSectionIndex = function getSectionIndex(index) {
+ return this.sectionIndex[index];
+ };
+ TaggedString.prototype.getCharCode = function getCharCode(index) {
+ return this.text.charCodeAt(index);
+ };
+ TaggedString.prototype.verticalizePunctuation = function verticalizePunctuation$1() {
+ this.text = verticalizePunctuation(this.text);
+ };
+ TaggedString.prototype.trim = function trim() {
+ var beginningWhitespace = 0;
+ for (var i = 0; i < this.text.length && whitespace[this.text.charCodeAt(i)]; i++) {
+ beginningWhitespace++;
+ }
+ var trailingWhitespace = this.text.length;
+ for (var i$1 = this.text.length - 1; i$1 >= 0 && i$1 >= beginningWhitespace && whitespace[this.text.charCodeAt(i$1)]; i$1--) {
+ trailingWhitespace--;
+ }
+ this.text = this.text.substring(beginningWhitespace, trailingWhitespace);
+ this.sectionIndex = this.sectionIndex.slice(beginningWhitespace, trailingWhitespace);
+ };
+ TaggedString.prototype.substring = function substring(start, end) {
+ var substring2 = new TaggedString();
+ substring2.text = this.text.substring(start, end);
+ substring2.sectionIndex = this.sectionIndex.slice(start, end);
+ substring2.sections = this.sections;
+ return substring2;
+ };
+ TaggedString.prototype.toString = function toString2() {
+ return this.text;
+ };
+ TaggedString.prototype.getMaxScale = function getMaxScale() {
+ var this$1 = this;
+ return this.sectionIndex.reduce(function(max, index) {
+ return Math.max(max, this$1.sections[index].scale);
+ }, 0);
+ };
+ TaggedString.prototype.addTextSection = function addTextSection(section, defaultFontStack) {
+ this.text += section.text;
+ this.sections.push(SectionOptions.forText(section.scale, section.fontStack || defaultFontStack));
+ var index = this.sections.length - 1;
+ for (var i = 0; i < section.text.length; ++i) {
+ this.sectionIndex.push(index);
+ }
+ };
+ TaggedString.prototype.addImageSection = function addImageSection(section) {
+ var imageName = section.image ? section.image.name : "";
+ if (imageName.length === 0) {
+ warnOnce("Can't add FormattedSection with an empty image.");
+ return;
+ }
+ var nextImageSectionCharCode = this.getNextImageSectionCharCode();
+ if (!nextImageSectionCharCode) {
+ warnOnce("Reached maximum number of images " + (PUAend - PUAbegin + 2));
+ return;
+ }
+ this.text += String.fromCharCode(nextImageSectionCharCode);
+ this.sections.push(SectionOptions.forImage(imageName));
+ this.sectionIndex.push(this.sections.length - 1);
+ };
+ TaggedString.prototype.getNextImageSectionCharCode = function getNextImageSectionCharCode() {
+ if (!this.imageSectionID) {
+ this.imageSectionID = PUAbegin;
+ return this.imageSectionID;
+ }
+ if (this.imageSectionID >= PUAend) {
+ return null;
+ }
+ return ++this.imageSectionID;
+ };
+ function breakLines(input, lineBreakPoints) {
+ var lines = [];
+ var text = input.text;
+ var start = 0;
+ for (var i = 0, list = lineBreakPoints; i < list.length; i += 1) {
+ var lineBreak = list[i];
+ lines.push(input.substring(start, lineBreak));
+ start = lineBreak;
+ }
+ if (start < text.length) {
+ lines.push(input.substring(start, text.length));
+ }
+ return lines;
+ }
+ function shapeText(text, glyphMap, glyphPositions, imagePositions, defaultFontStack, maxWidth, lineHeight, textAnchor, textJustify, spacing, translate2, writingMode, allowVerticalPlacement, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom) {
+ var logicalInput = TaggedString.fromFeature(text, defaultFontStack);
+ if (writingMode === WritingMode.vertical) {
+ logicalInput.verticalizePunctuation();
+ }
+ var lines;
+ var processBidirectionalText = plugin.processBidirectionalText;
+ var processStyledBidirectionalText = plugin.processStyledBidirectionalText;
+ if (processBidirectionalText && logicalInput.sections.length === 1) {
+ lines = [];
+ var untaggedLines = processBidirectionalText(logicalInput.toString(), determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));
+ for (var i$1 = 0, list = untaggedLines; i$1 < list.length; i$1 += 1) {
+ var line = list[i$1];
+ var taggedLine = new TaggedString();
+ taggedLine.text = line;
+ taggedLine.sections = logicalInput.sections;
+ for (var i = 0; i < line.length; i++) {
+ taggedLine.sectionIndex.push(0);
+ }
+ lines.push(taggedLine);
+ }
+ } else if (processStyledBidirectionalText) {
+ lines = [];
+ var processedLines = processStyledBidirectionalText(logicalInput.text, logicalInput.sectionIndex, determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));
+ for (var i$2 = 0, list$1 = processedLines; i$2 < list$1.length; i$2 += 1) {
+ var line$1 = list$1[i$2];
+ var taggedLine$1 = new TaggedString();
+ taggedLine$1.text = line$1[0];
+ taggedLine$1.sectionIndex = line$1[1];
+ taggedLine$1.sections = logicalInput.sections;
+ lines.push(taggedLine$1);
+ }
+ } else {
+ lines = breakLines(logicalInput, determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize));
+ }
+ var positionedLines = [];
+ var shaping = {
+ positionedLines,
+ text: logicalInput.toString(),
+ top: translate2[1],
+ bottom: translate2[1],
+ left: translate2[0],
+ right: translate2[0],
+ writingMode,
+ iconsInText: false,
+ verticalizable: false
+ };
+ shapeLines(shaping, glyphMap, glyphPositions, imagePositions, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, allowVerticalPlacement, layoutTextSizeThisZoom);
+ if (isEmpty(positionedLines)) {
+ return false;
+ }
+ return shaping;
+ }
+ var whitespace = {};
+ whitespace[9] = true;
+ whitespace[10] = true;
+ whitespace[11] = true;
+ whitespace[12] = true;
+ whitespace[13] = true;
+ whitespace[32] = true;
+ var breakable = {};
+ breakable[10] = true;
+ breakable[32] = true;
+ breakable[38] = true;
+ breakable[40] = true;
+ breakable[41] = true;
+ breakable[43] = true;
+ breakable[45] = true;
+ breakable[47] = true;
+ breakable[173] = true;
+ breakable[183] = true;
+ breakable[8203] = true;
+ breakable[8208] = true;
+ breakable[8211] = true;
+ breakable[8231] = true;
+ function getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing, layoutTextSize) {
+ if (!section.imageName) {
+ var positions = glyphMap[section.fontStack];
+ var glyph = positions && positions[codePoint];
+ if (!glyph) {
+ return 0;
+ }
+ return glyph.metrics.advance * section.scale + spacing;
+ } else {
+ var imagePosition = imagePositions[section.imageName];
+ if (!imagePosition) {
+ return 0;
+ }
+ return imagePosition.displaySize[0] * section.scale * ONE_EM / layoutTextSize + spacing;
+ }
+ }
+ function determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap, imagePositions, layoutTextSize) {
+ var totalWidth = 0;
+ for (var index = 0; index < logicalInput.length(); index++) {
+ var section = logicalInput.getSection(index);
+ totalWidth += getGlyphAdvance(logicalInput.getCharCode(index), section, glyphMap, imagePositions, spacing, layoutTextSize);
+ }
+ var lineCount = Math.max(1, Math.ceil(totalWidth / maxWidth));
+ return totalWidth / lineCount;
+ }
+ function calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) {
+ var raggedness = Math.pow(lineWidth - targetWidth, 2);
+ if (isLastBreak) {
+ if (lineWidth < targetWidth) {
+ return raggedness / 2;
+ } else {
+ return raggedness * 2;
+ }
+ }
+ return raggedness + Math.abs(penalty) * penalty;
+ }
+ function calculatePenalty(codePoint, nextCodePoint, penalizableIdeographicBreak) {
+ var penalty = 0;
+ if (codePoint === 10) {
+ penalty -= 1e4;
+ }
+ if (penalizableIdeographicBreak) {
+ penalty += 150;
+ }
+ if (codePoint === 40 || codePoint === 65288) {
+ penalty += 50;
+ }
+ if (nextCodePoint === 41 || nextCodePoint === 65289) {
+ penalty += 50;
+ }
+ return penalty;
+ }
+ function evaluateBreak(breakIndex, breakX, targetWidth, potentialBreaks, penalty, isLastBreak) {
+ var bestPriorBreak = null;
+ var bestBreakBadness = calculateBadness(breakX, targetWidth, penalty, isLastBreak);
+ for (var i = 0, list = potentialBreaks; i < list.length; i += 1) {
+ var potentialBreak = list[i];
+ var lineWidth = breakX - potentialBreak.x;
+ var breakBadness = calculateBadness(lineWidth, targetWidth, penalty, isLastBreak) + potentialBreak.badness;
+ if (breakBadness <= bestBreakBadness) {
+ bestPriorBreak = potentialBreak;
+ bestBreakBadness = breakBadness;
+ }
+ }
+ return {
+ index: breakIndex,
+ x: breakX,
+ priorBreak: bestPriorBreak,
+ badness: bestBreakBadness
+ };
+ }
+ function leastBadBreaks(lastLineBreak) {
+ if (!lastLineBreak) {
+ return [];
+ }
+ return leastBadBreaks(lastLineBreak.priorBreak).concat(lastLineBreak.index);
+ }
+ function determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap, imagePositions, symbolPlacement, layoutTextSize) {
+ if (symbolPlacement !== "point") {
+ return [];
+ }
+ if (!logicalInput) {
+ return [];
+ }
+ var potentialLineBreaks = [];
+ var targetWidth = determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap, imagePositions, layoutTextSize);
+ var hasServerSuggestedBreakpoints = logicalInput.text.indexOf("\u200B") >= 0;
+ var currentX = 0;
+ for (var i = 0; i < logicalInput.length(); i++) {
+ var section = logicalInput.getSection(i);
+ var codePoint = logicalInput.getCharCode(i);
+ if (!whitespace[codePoint]) {
+ currentX += getGlyphAdvance(codePoint, section, glyphMap, imagePositions, spacing, layoutTextSize);
+ }
+ if (i < logicalInput.length() - 1) {
+ var ideographicBreak = charAllowsIdeographicBreaking(codePoint);
+ if (breakable[codePoint] || ideographicBreak || section.imageName) {
+ potentialLineBreaks.push(evaluateBreak(i + 1, currentX, targetWidth, potentialLineBreaks, calculatePenalty(codePoint, logicalInput.getCharCode(i + 1), ideographicBreak && hasServerSuggestedBreakpoints), false));
+ }
+ }
+ }
+ return leastBadBreaks(evaluateBreak(logicalInput.length(), currentX, targetWidth, potentialLineBreaks, 0, true));
+ }
+ function getAnchorAlignment(anchor) {
+ var horizontalAlign = 0.5, verticalAlign = 0.5;
+ switch (anchor) {
+ case "right":
+ case "top-right":
+ case "bottom-right":
+ horizontalAlign = 1;
+ break;
+ case "left":
+ case "top-left":
+ case "bottom-left":
+ horizontalAlign = 0;
+ break;
+ }
+ switch (anchor) {
+ case "bottom":
+ case "bottom-right":
+ case "bottom-left":
+ verticalAlign = 1;
+ break;
+ case "top":
+ case "top-right":
+ case "top-left":
+ verticalAlign = 0;
+ break;
+ }
+ return {
+ horizontalAlign,
+ verticalAlign
+ };
+ }
+ function shapeLines(shaping, glyphMap, glyphPositions, imagePositions, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, allowVerticalPlacement, layoutTextSizeThisZoom) {
+ var x = 0;
+ var y = SHAPING_DEFAULT_OFFSET;
+ var maxLineLength = 0;
+ var maxLineHeight = 0;
+ var justify = textJustify === "right" ? 1 : textJustify === "left" ? 0 : 0.5;
+ var lineIndex = 0;
+ for (var i$1 = 0, list = lines; i$1 < list.length; i$1 += 1) {
+ var line = list[i$1];
+ line.trim();
+ var lineMaxScale = line.getMaxScale();
+ var maxLineOffset = (lineMaxScale - 1) * ONE_EM;
+ var positionedLine = {
+ positionedGlyphs: [],
+ lineOffset: 0
+ };
+ shaping.positionedLines[lineIndex] = positionedLine;
+ var positionedGlyphs = positionedLine.positionedGlyphs;
+ var lineOffset = 0;
+ if (!line.length()) {
+ y += lineHeight;
+ ++lineIndex;
+ continue;
+ }
+ for (var i = 0; i < line.length(); i++) {
+ var section = line.getSection(i);
+ var sectionIndex = line.getSectionIndex(i);
+ var codePoint = line.getCharCode(i);
+ var baselineOffset2 = 0;
+ var metrics = null;
+ var rect = null;
+ var imageName = null;
+ var verticalAdvance = ONE_EM;
+ var vertical = !(writingMode === WritingMode.horizontal || !allowVerticalPlacement && !charHasUprightVerticalOrientation(codePoint) || allowVerticalPlacement && (whitespace[codePoint] || charInComplexShapingScript(codePoint)));
+ if (!section.imageName) {
+ var positions = glyphPositions[section.fontStack];
+ var glyphPosition = positions && positions[codePoint];
+ if (glyphPosition && glyphPosition.rect) {
+ rect = glyphPosition.rect;
+ metrics = glyphPosition.metrics;
+ } else {
+ var glyphs = glyphMap[section.fontStack];
+ var glyph = glyphs && glyphs[codePoint];
+ if (!glyph) {
+ continue;
+ }
+ metrics = glyph.metrics;
+ }
+ baselineOffset2 = (lineMaxScale - section.scale) * ONE_EM;
+ } else {
+ var imagePosition = imagePositions[section.imageName];
+ if (!imagePosition) {
+ continue;
+ }
+ imageName = section.imageName;
+ shaping.iconsInText = shaping.iconsInText || true;
+ rect = imagePosition.paddedRect;
+ var size = imagePosition.displaySize;
+ section.scale = section.scale * ONE_EM / layoutTextSizeThisZoom;
+ metrics = {
+ width: size[0],
+ height: size[1],
+ left: IMAGE_PADDING,
+ top: -GLYPH_PBF_BORDER,
+ advance: vertical ? size[1] : size[0]
+ };
+ var imageOffset = ONE_EM - size[1] * section.scale;
+ baselineOffset2 = maxLineOffset + imageOffset;
+ verticalAdvance = metrics.advance;
+ var offset = vertical ? size[0] * section.scale - ONE_EM * lineMaxScale : size[1] * section.scale - ONE_EM * lineMaxScale;
+ if (offset > 0 && offset > lineOffset) {
+ lineOffset = offset;
+ }
+ }
+ if (!vertical) {
+ positionedGlyphs.push({
+ glyph: codePoint,
+ imageName,
+ x,
+ y: y + baselineOffset2,
+ vertical,
+ scale: section.scale,
+ fontStack: section.fontStack,
+ sectionIndex,
+ metrics,
+ rect
+ });
+ x += metrics.advance * section.scale + spacing;
+ } else {
+ shaping.verticalizable = true;
+ positionedGlyphs.push({
+ glyph: codePoint,
+ imageName,
+ x,
+ y: y + baselineOffset2,
+ vertical,
+ scale: section.scale,
+ fontStack: section.fontStack,
+ sectionIndex,
+ metrics,
+ rect
+ });
+ x += verticalAdvance * section.scale + spacing;
+ }
+ }
+ if (positionedGlyphs.length !== 0) {
+ var lineLength = x - spacing;
+ maxLineLength = Math.max(lineLength, maxLineLength);
+ justifyLine(positionedGlyphs, 0, positionedGlyphs.length - 1, justify, lineOffset);
+ }
+ x = 0;
+ var currentLineHeight = lineHeight * lineMaxScale + lineOffset;
+ positionedLine.lineOffset = Math.max(lineOffset, maxLineOffset);
+ y += currentLineHeight;
+ maxLineHeight = Math.max(currentLineHeight, maxLineHeight);
+ ++lineIndex;
+ }
+ var height = y - SHAPING_DEFAULT_OFFSET;
+ var ref = getAnchorAlignment(textAnchor);
+ var horizontalAlign = ref.horizontalAlign;
+ var verticalAlign = ref.verticalAlign;
+ align$1(shaping.positionedLines, justify, horizontalAlign, verticalAlign, maxLineLength, maxLineHeight, lineHeight, height, lines.length);
+ shaping.top += -verticalAlign * height;
+ shaping.bottom = shaping.top + height;
+ shaping.left += -horizontalAlign * maxLineLength;
+ shaping.right = shaping.left + maxLineLength;
+ }
+ function justifyLine(positionedGlyphs, start, end, justify, lineOffset) {
+ if (!justify && !lineOffset) {
+ return;
+ }
+ var lastPositionedGlyph = positionedGlyphs[end];
+ var lastAdvance = lastPositionedGlyph.metrics.advance * lastPositionedGlyph.scale;
+ var lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;
+ for (var j = start; j <= end; j++) {
+ positionedGlyphs[j].x -= lineIndent;
+ positionedGlyphs[j].y += lineOffset;
+ }
+ }
+ function align$1(positionedLines, justify, horizontalAlign, verticalAlign, maxLineLength, maxLineHeight, lineHeight, blockHeight, lineCount) {
+ var shiftX = (justify - horizontalAlign) * maxLineLength;
+ var shiftY = 0;
+ if (maxLineHeight !== lineHeight) {
+ shiftY = -blockHeight * verticalAlign - SHAPING_DEFAULT_OFFSET;
+ } else {
+ shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;
+ }
+ for (var i$1 = 0, list$1 = positionedLines; i$1 < list$1.length; i$1 += 1) {
+ var line = list$1[i$1];
+ for (var i = 0, list = line.positionedGlyphs; i < list.length; i += 1) {
+ var positionedGlyph = list[i];
+ positionedGlyph.x += shiftX;
+ positionedGlyph.y += shiftY;
+ }
+ }
+ }
+ function shapeIcon(image, iconOffset, iconAnchor) {
+ var ref = getAnchorAlignment(iconAnchor);
+ var horizontalAlign = ref.horizontalAlign;
+ var verticalAlign = ref.verticalAlign;
+ var dx = iconOffset[0];
+ var dy = iconOffset[1];
+ var x1 = dx - image.displaySize[0] * horizontalAlign;
+ var x2 = x1 + image.displaySize[0];
+ var y1 = dy - image.displaySize[1] * verticalAlign;
+ var y2 = y1 + image.displaySize[1];
+ return {
+ image,
+ top: y1,
+ bottom: y2,
+ left: x1,
+ right: x2
+ };
+ }
+ function fitIconToText(shapedIcon, shapedText, textFit, padding, iconOffset, fontScale) {
+ var image = shapedIcon.image;
+ var collisionPadding;
+ if (image.content) {
+ var content = image.content;
+ var pixelRatio = image.pixelRatio || 1;
+ collisionPadding = [
+ content[0] / pixelRatio,
+ content[1] / pixelRatio,
+ image.displaySize[0] - content[2] / pixelRatio,
+ image.displaySize[1] - content[3] / pixelRatio
+ ];
+ }
+ var textLeft = shapedText.left * fontScale;
+ var textRight = shapedText.right * fontScale;
+ var top, right, bottom, left;
+ if (textFit === "width" || textFit === "both") {
+ left = iconOffset[0] + textLeft - padding[3];
+ right = iconOffset[0] + textRight + padding[1];
+ } else {
+ left = iconOffset[0] + (textLeft + textRight - image.displaySize[0]) / 2;
+ right = left + image.displaySize[0];
+ }
+ var textTop = shapedText.top * fontScale;
+ var textBottom = shapedText.bottom * fontScale;
+ if (textFit === "height" || textFit === "both") {
+ top = iconOffset[1] + textTop - padding[0];
+ bottom = iconOffset[1] + textBottom + padding[2];
+ } else {
+ top = iconOffset[1] + (textTop + textBottom - image.displaySize[1]) / 2;
+ bottom = top + image.displaySize[1];
+ }
+ return {
+ image,
+ top,
+ right,
+ bottom,
+ left,
+ collisionPadding
+ };
+ }
+ var Anchor = function(Point2) {
+ function Anchor2(x, y, angle, segment) {
+ Point2.call(this, x, y);
+ this.angle = angle;
+ if (segment !== void 0) {
+ this.segment = segment;
+ }
+ }
+ if (Point2)
+ Anchor2.__proto__ = Point2;
+ Anchor2.prototype = Object.create(Point2 && Point2.prototype);
+ Anchor2.prototype.constructor = Anchor2;
+ Anchor2.prototype.clone = function clone2() {
+ return new Anchor2(this.x, this.y, this.angle, this.segment);
+ };
+ return Anchor2;
+ }(pointGeometry);
+ register("Anchor", Anchor);
+ var SIZE_PACK_FACTOR = 128;
+ function getSizeData(tileZoom, value) {
+ var expression2 = value.expression;
+ if (expression2.kind === "constant") {
+ var layoutSize = expression2.evaluate(new EvaluationParameters(tileZoom + 1));
+ return {
+ kind: "constant",
+ layoutSize
+ };
+ } else if (expression2.kind === "source") {
+ return { kind: "source" };
+ } else {
+ var zoomStops = expression2.zoomStops;
+ var interpolationType = expression2.interpolationType;
+ var lower = 0;
+ while (lower < zoomStops.length && zoomStops[lower] <= tileZoom) {
+ lower++;
+ }
+ lower = Math.max(0, lower - 1);
+ var upper = lower;
+ while (upper < zoomStops.length && zoomStops[upper] < tileZoom + 1) {
+ upper++;
+ }
+ upper = Math.min(zoomStops.length - 1, upper);
+ var minZoom = zoomStops[lower];
+ var maxZoom = zoomStops[upper];
+ if (expression2.kind === "composite") {
+ return {
+ kind: "composite",
+ minZoom,
+ maxZoom,
+ interpolationType
+ };
+ }
+ var minSize = expression2.evaluate(new EvaluationParameters(minZoom));
+ var maxSize = expression2.evaluate(new EvaluationParameters(maxZoom));
+ return {
+ kind: "camera",
+ minZoom,
+ maxZoom,
+ minSize,
+ maxSize,
+ interpolationType
+ };
+ }
+ }
+ function evaluateSizeForFeature(sizeData, ref, ref$1) {
+ var uSize = ref.uSize;
+ var uSizeT = ref.uSizeT;
+ var lowerSize = ref$1.lowerSize;
+ var upperSize = ref$1.upperSize;
+ if (sizeData.kind === "source") {
+ return lowerSize / SIZE_PACK_FACTOR;
+ } else if (sizeData.kind === "composite") {
+ return number(lowerSize / SIZE_PACK_FACTOR, upperSize / SIZE_PACK_FACTOR, uSizeT);
+ }
+ return uSize;
+ }
+ function evaluateSizeForZoom(sizeData, zoom) {
+ var uSizeT = 0;
+ var uSize = 0;
+ if (sizeData.kind === "constant") {
+ uSize = sizeData.layoutSize;
+ } else if (sizeData.kind !== "source") {
+ var interpolationType = sizeData.interpolationType;
+ var minZoom = sizeData.minZoom;
+ var maxZoom = sizeData.maxZoom;
+ var t = !interpolationType ? 0 : clamp(Interpolate.interpolationFactor(interpolationType, zoom, minZoom, maxZoom), 0, 1);
+ if (sizeData.kind === "camera") {
+ uSize = number(sizeData.minSize, sizeData.maxSize, t);
+ } else {
+ uSizeT = t;
+ }
+ }
+ return {
+ uSizeT,
+ uSize
+ };
+ }
+ var symbolSize = /* @__PURE__ */ Object.freeze({
+ __proto__: null,
+ getSizeData,
+ evaluateSizeForFeature,
+ evaluateSizeForZoom,
+ SIZE_PACK_FACTOR
+ });
+ function checkMaxAngle(line, anchor, labelLength, windowSize, maxAngle) {
+ if (anchor.segment === void 0) {
+ return true;
+ }
+ var p = anchor;
+ var index = anchor.segment + 1;
+ var anchorDistance = 0;
+ while (anchorDistance > -labelLength / 2) {
+ index--;
+ if (index < 0) {
+ return false;
+ }
+ anchorDistance -= line[index].dist(p);
+ p = line[index];
+ }
+ anchorDistance += line[index].dist(line[index + 1]);
+ index++;
+ var recentCorners = [];
+ var recentAngleDelta = 0;
+ while (anchorDistance < labelLength / 2) {
+ var prev = line[index - 1];
+ var current = line[index];
+ var next = line[index + 1];
+ if (!next) {
+ return false;
+ }
+ var angleDelta = prev.angleTo(current) - current.angleTo(next);
+ angleDelta = Math.abs((angleDelta + 3 * Math.PI) % (Math.PI * 2) - Math.PI);
+ recentCorners.push({
+ distance: anchorDistance,
+ angleDelta
+ });
+ recentAngleDelta += angleDelta;
+ while (anchorDistance - recentCorners[0].distance > windowSize) {
+ recentAngleDelta -= recentCorners.shift().angleDelta;
+ }
+ if (recentAngleDelta > maxAngle) {
+ return false;
+ }
+ index++;
+ anchorDistance += current.dist(next);
+ }
+ return true;
+ }
+ function getLineLength(line) {
+ var lineLength = 0;
+ for (var k = 0; k < line.length - 1; k++) {
+ lineLength += line[k].dist(line[k + 1]);
+ }
+ return lineLength;
+ }
+ function getAngleWindowSize(shapedText, glyphSize, boxScale) {
+ return shapedText ? 3 / 5 * glyphSize * boxScale : 0;
+ }
+ function getShapedLabelLength(shapedText, shapedIcon) {
+ return Math.max(shapedText ? shapedText.right - shapedText.left : 0, shapedIcon ? shapedIcon.right - shapedIcon.left : 0);
+ }
+ function getCenterAnchor(line, maxAngle, shapedText, shapedIcon, glyphSize, boxScale) {
+ var angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);
+ var labelLength = getShapedLabelLength(shapedText, shapedIcon) * boxScale;
+ var prevDistance = 0;
+ var centerDistance = getLineLength(line) / 2;
+ for (var i = 0; i < line.length - 1; i++) {
+ var a = line[i], b = line[i + 1];
+ var segmentDistance = a.dist(b);
+ if (prevDistance + segmentDistance > centerDistance) {
+ var t = (centerDistance - prevDistance) / segmentDistance, x = number(a.x, b.x, t), y = number(a.y, b.y, t);
+ var anchor = new Anchor(x, y, b.angleTo(a), i);
+ anchor._round();
+ if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {
+ return anchor;
+ } else {
+ return;
+ }
+ }
+ prevDistance += segmentDistance;
+ }
+ }
+ function getAnchors(line, spacing, maxAngle, shapedText, shapedIcon, glyphSize, boxScale, overscaling, tileExtent) {
+ var angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);
+ var shapedLabelLength = getShapedLabelLength(shapedText, shapedIcon);
+ var labelLength = shapedLabelLength * boxScale;
+ var isLineContinued = line[0].x === 0 || line[0].x === tileExtent || line[0].y === 0 || line[0].y === tileExtent;
+ if (spacing - labelLength < spacing / 4) {
+ spacing = labelLength + spacing / 4;
+ }
+ var fixedExtraOffset = glyphSize * 2;
+ var offset = !isLineContinued ? (shapedLabelLength / 2 + fixedExtraOffset) * boxScale * overscaling % spacing : spacing / 2 * overscaling % spacing;
+ return resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, false, tileExtent);
+ }
+ function resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, placeAtMiddle, tileExtent) {
+ var halfLabelLength = labelLength / 2;
+ var lineLength = getLineLength(line);
+ var distance = 0, markedDistance = offset - spacing;
+ var anchors = [];
+ for (var i = 0; i < line.length - 1; i++) {
+ var a = line[i], b = line[i + 1];
+ var segmentDist = a.dist(b), angle = b.angleTo(a);
+ while (markedDistance + spacing < distance + segmentDist) {
+ markedDistance += spacing;
+ var t = (markedDistance - distance) / segmentDist, x = number(a.x, b.x, t), y = number(a.y, b.y, t);
+ if (x >= 0 && x < tileExtent && y >= 0 && y < tileExtent && markedDistance - halfLabelLength >= 0 && markedDistance + halfLabelLength <= lineLength) {
+ var anchor = new Anchor(x, y, angle, i);
+ anchor._round();
+ if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {
+ anchors.push(anchor);
+ }
+ }
+ }
+ distance += segmentDist;
+ }
+ if (!placeAtMiddle && !anchors.length && !isLineContinued) {
+ anchors = resample(line, distance / 2, spacing, angleWindowSize, maxAngle, labelLength, isLineContinued, true, tileExtent);
+ }
+ return anchors;
+ }
+ function clipLine(lines, x1, y1, x2, y2) {
+ var clippedLines = [];
+ for (var l = 0; l < lines.length; l++) {
+ var line = lines[l];
+ var clippedLine = void 0;
+ for (var i = 0; i < line.length - 1; i++) {
+ var p0 = line[i];
+ var p1 = line[i + 1];
+ if (p0.x < x1 && p1.x < x1) {
+ continue;
+ } else if (p0.x < x1) {
+ p0 = new pointGeometry(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();
+ } else if (p1.x < x1) {
+ p1 = new pointGeometry(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round();
+ }
+ if (p0.y < y1 && p1.y < y1) {
+ continue;
+ } else if (p0.y < y1) {
+ p0 = new pointGeometry(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();
+ } else if (p1.y < y1) {
+ p1 = new pointGeometry(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round();
+ }
+ if (p0.x >= x2 && p1.x >= x2) {
+ continue;
+ } else if (p0.x >= x2) {
+ p0 = new pointGeometry(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();
+ } else if (p1.x >= x2) {
+ p1 = new pointGeometry(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round();
+ }
+ if (p0.y >= y2 && p1.y >= y2) {
+ continue;
+ } else if (p0.y >= y2) {
+ p0 = new pointGeometry(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();
+ } else if (p1.y >= y2) {
+ p1 = new pointGeometry(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round();
+ }
+ if (!clippedLine || !p0.equals(clippedLine[clippedLine.length - 1])) {
+ clippedLine = [p0];
+ clippedLines.push(clippedLine);
+ }
+ clippedLine.push(p1);
+ }
+ }
+ return clippedLines;
+ }
+ var border$1 = IMAGE_PADDING;
+ function getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit) {
+ var quads = [];
+ var image = shapedIcon.image;
+ var pixelRatio = image.pixelRatio;
+ var imageWidth = image.paddedRect.w - 2 * border$1;
+ var imageHeight = image.paddedRect.h - 2 * border$1;
+ var iconWidth = shapedIcon.right - shapedIcon.left;
+ var iconHeight = shapedIcon.bottom - shapedIcon.top;
+ var stretchX = image.stretchX || [[
+ 0,
+ imageWidth
+ ]];
+ var stretchY = image.stretchY || [[
+ 0,
+ imageHeight
+ ]];
+ var reduceRanges = function(sum, range) {
+ return sum + range[1] - range[0];
+ };
+ var stretchWidth = stretchX.reduce(reduceRanges, 0);
+ var stretchHeight = stretchY.reduce(reduceRanges, 0);
+ var fixedWidth = imageWidth - stretchWidth;
+ var fixedHeight = imageHeight - stretchHeight;
+ var stretchOffsetX = 0;
+ var stretchContentWidth = stretchWidth;
+ var stretchOffsetY = 0;
+ var stretchContentHeight = stretchHeight;
+ var fixedOffsetX = 0;
+ var fixedContentWidth = fixedWidth;
+ var fixedOffsetY = 0;
+ var fixedContentHeight = fixedHeight;
+ if (image.content && hasIconTextFit) {
+ var content = image.content;
+ stretchOffsetX = sumWithinRange(stretchX, 0, content[0]);
+ stretchOffsetY = sumWithinRange(stretchY, 0, content[1]);
+ stretchContentWidth = sumWithinRange(stretchX, content[0], content[2]);
+ stretchContentHeight = sumWithinRange(stretchY, content[1], content[3]);
+ fixedOffsetX = content[0] - stretchOffsetX;
+ fixedOffsetY = content[1] - stretchOffsetY;
+ fixedContentWidth = content[2] - content[0] - stretchContentWidth;
+ fixedContentHeight = content[3] - content[1] - stretchContentHeight;
+ }
+ var makeBox = function(left, top, right, bottom) {
+ var leftEm = getEmOffset(left.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left);
+ var leftPx = getPxOffset(left.fixed - fixedOffsetX, fixedContentWidth, left.stretch, stretchWidth);
+ var topEm = getEmOffset(top.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top);
+ var topPx = getPxOffset(top.fixed - fixedOffsetY, fixedContentHeight, top.stretch, stretchHeight);
+ var rightEm = getEmOffset(right.stretch - stretchOffsetX, stretchContentWidth, iconWidth, shapedIcon.left);
+ var rightPx = getPxOffset(right.fixed - fixedOffsetX, fixedContentWidth, right.stretch, stretchWidth);
+ var bottomEm = getEmOffset(bottom.stretch - stretchOffsetY, stretchContentHeight, iconHeight, shapedIcon.top);
+ var bottomPx = getPxOffset(bottom.fixed - fixedOffsetY, fixedContentHeight, bottom.stretch, stretchHeight);
+ var tl = new pointGeometry(leftEm, topEm);
+ var tr = new pointGeometry(rightEm, topEm);
+ var br = new pointGeometry(rightEm, bottomEm);
+ var bl = new pointGeometry(leftEm, bottomEm);
+ var pixelOffsetTL = new pointGeometry(leftPx / pixelRatio, topPx / pixelRatio);
+ var pixelOffsetBR = new pointGeometry(rightPx / pixelRatio, bottomPx / pixelRatio);
+ var angle = iconRotate * Math.PI / 180;
+ if (angle) {
+ var sin = Math.sin(angle), cos = Math.cos(angle), matrix = [
+ cos,
+ -sin,
+ sin,
+ cos
+ ];
+ tl._matMult(matrix);
+ tr._matMult(matrix);
+ bl._matMult(matrix);
+ br._matMult(matrix);
+ }
+ var x12 = left.stretch + left.fixed;
+ var x22 = right.stretch + right.fixed;
+ var y12 = top.stretch + top.fixed;
+ var y22 = bottom.stretch + bottom.fixed;
+ var subRect = {
+ x: image.paddedRect.x + border$1 + x12,
+ y: image.paddedRect.y + border$1 + y12,
+ w: x22 - x12,
+ h: y22 - y12
+ };
+ var minFontScaleX = fixedContentWidth / pixelRatio / iconWidth;
+ var minFontScaleY = fixedContentHeight / pixelRatio / iconHeight;
+ return {
+ tl,
+ tr,
+ bl,
+ br,
+ tex: subRect,
+ writingMode: void 0,
+ glyphOffset: [
+ 0,
+ 0
+ ],
+ sectionIndex: 0,
+ pixelOffsetTL,
+ pixelOffsetBR,
+ minFontScaleX,
+ minFontScaleY,
+ isSDF: isSDFIcon
+ };
+ };
+ if (!hasIconTextFit || !image.stretchX && !image.stretchY) {
+ quads.push(makeBox({
+ fixed: 0,
+ stretch: -1
+ }, {
+ fixed: 0,
+ stretch: -1
+ }, {
+ fixed: 0,
+ stretch: imageWidth + 1
+ }, {
+ fixed: 0,
+ stretch: imageHeight + 1
+ }));
+ } else {
+ var xCuts = stretchZonesToCuts(stretchX, fixedWidth, stretchWidth);
+ var yCuts = stretchZonesToCuts(stretchY, fixedHeight, stretchHeight);
+ for (var xi = 0; xi < xCuts.length - 1; xi++) {
+ var x1 = xCuts[xi];
+ var x2 = xCuts[xi + 1];
+ for (var yi = 0; yi < yCuts.length - 1; yi++) {
+ var y1 = yCuts[yi];
+ var y2 = yCuts[yi + 1];
+ quads.push(makeBox(x1, y1, x2, y2));
+ }
+ }
+ }
+ return quads;
+ }
+ function sumWithinRange(ranges, min, max) {
+ var sum = 0;
+ for (var i = 0, list = ranges; i < list.length; i += 1) {
+ var range = list[i];
+ sum += Math.max(min, Math.min(max, range[1])) - Math.max(min, Math.min(max, range[0]));
+ }
+ return sum;
+ }
+ function stretchZonesToCuts(stretchZones, fixedSize, stretchSize) {
+ var cuts = [{
+ fixed: -border$1,
+ stretch: 0
+ }];
+ for (var i = 0, list = stretchZones; i < list.length; i += 1) {
+ var ref = list[i];
+ var c1 = ref[0];
+ var c2 = ref[1];
+ var last = cuts[cuts.length - 1];
+ cuts.push({
+ fixed: c1 - last.stretch,
+ stretch: last.stretch
+ });
+ cuts.push({
+ fixed: c1 - last.stretch,
+ stretch: last.stretch + (c2 - c1)
+ });
+ }
+ cuts.push({
+ fixed: fixedSize + border$1,
+ stretch: stretchSize
+ });
+ return cuts;
+ }
+ function getEmOffset(stretchOffset, stretchSize, iconSize, iconOffset) {
+ return stretchOffset / stretchSize * iconSize + iconOffset;
+ }
+ function getPxOffset(fixedOffset, fixedSize, stretchOffset, stretchSize) {
+ return fixedOffset - fixedSize * stretchOffset / stretchSize;
+ }
+ function getGlyphQuads(anchor, shaping, textOffset, layer2, alongLine, feature, imageMap, allowVerticalPlacement) {
+ var textRotate = layer2.layout.get("text-rotate").evaluate(feature, {}) * Math.PI / 180;
+ var quads = [];
+ for (var i$1 = 0, list$1 = shaping.positionedLines; i$1 < list$1.length; i$1 += 1) {
+ var line = list$1[i$1];
+ for (var i = 0, list = line.positionedGlyphs; i < list.length; i += 1) {
+ var positionedGlyph = list[i];
+ if (!positionedGlyph.rect) {
+ continue;
+ }
+ var textureRect = positionedGlyph.rect || {};
+ var glyphPadding = 1;
+ var rectBuffer = GLYPH_PBF_BORDER + glyphPadding;
+ var isSDF = true;
+ var pixelRatio = 1;
+ var lineOffset = 0;
+ var rotateVerticalGlyph = (alongLine || allowVerticalPlacement) && positionedGlyph.vertical;
+ var halfAdvance = positionedGlyph.metrics.advance * positionedGlyph.scale / 2;
+ if (allowVerticalPlacement && shaping.verticalizable) {
+ var scaledGlyphOffset = (positionedGlyph.scale - 1) * ONE_EM;
+ var imageOffset = (ONE_EM - positionedGlyph.metrics.width * positionedGlyph.scale) / 2;
+ lineOffset = line.lineOffset / 2 - (positionedGlyph.imageName ? -imageOffset : scaledGlyphOffset);
+ }
+ if (positionedGlyph.imageName) {
+ var image = imageMap[positionedGlyph.imageName];
+ isSDF = image.sdf;
+ pixelRatio = image.pixelRatio;
+ rectBuffer = IMAGE_PADDING / pixelRatio;
+ }
+ var glyphOffset2 = alongLine ? [
+ positionedGlyph.x + halfAdvance,
+ positionedGlyph.y
+ ] : [
+ 0,
+ 0
+ ];
+ var builtInOffset = alongLine ? [
+ 0,
+ 0
+ ] : [
+ positionedGlyph.x + halfAdvance + textOffset[0],
+ positionedGlyph.y + textOffset[1] - lineOffset
+ ];
+ var verticalizedLabelOffset = [
+ 0,
+ 0
+ ];
+ if (rotateVerticalGlyph) {
+ verticalizedLabelOffset = builtInOffset;
+ builtInOffset = [
+ 0,
+ 0
+ ];
+ }
+ var x1 = (positionedGlyph.metrics.left - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];
+ var y1 = (-positionedGlyph.metrics.top - rectBuffer) * positionedGlyph.scale + builtInOffset[1];
+ var x2 = x1 + textureRect.w * positionedGlyph.scale / pixelRatio;
+ var y2 = y1 + textureRect.h * positionedGlyph.scale / pixelRatio;
+ var tl = new pointGeometry(x1, y1);
+ var tr = new pointGeometry(x2, y1);
+ var bl = new pointGeometry(x1, y2);
+ var br = new pointGeometry(x2, y2);
+ if (rotateVerticalGlyph) {
+ var center = new pointGeometry(-halfAdvance, halfAdvance - SHAPING_DEFAULT_OFFSET);
+ var verticalRotation = -Math.PI / 2;
+ var xHalfWidthOffsetCorrection = ONE_EM / 2 - halfAdvance;
+ var yImageOffsetCorrection = positionedGlyph.imageName ? xHalfWidthOffsetCorrection : 0;
+ var halfWidthOffsetCorrection = new pointGeometry(5 - SHAPING_DEFAULT_OFFSET - xHalfWidthOffsetCorrection, -yImageOffsetCorrection);
+ var verticalOffsetCorrection = new (Function.prototype.bind.apply(pointGeometry, [null].concat(verticalizedLabelOffset)))();
+ tl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);
+ tr._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);
+ bl._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);
+ br._rotateAround(verticalRotation, center)._add(halfWidthOffsetCorrection)._add(verticalOffsetCorrection);
+ }
+ if (textRotate) {
+ var sin = Math.sin(textRotate), cos = Math.cos(textRotate), matrix = [
+ cos,
+ -sin,
+ sin,
+ cos
+ ];
+ tl._matMult(matrix);
+ tr._matMult(matrix);
+ bl._matMult(matrix);
+ br._matMult(matrix);
+ }
+ var pixelOffsetTL = new pointGeometry(0, 0);
+ var pixelOffsetBR = new pointGeometry(0, 0);
+ var minFontScaleX = 0;
+ var minFontScaleY = 0;
+ quads.push({
+ tl,
+ tr,
+ bl,
+ br,
+ tex: textureRect,
+ writingMode: shaping.writingMode,
+ glyphOffset: glyphOffset2,
+ sectionIndex: positionedGlyph.sectionIndex,
+ isSDF,
+ pixelOffsetTL,
+ pixelOffsetBR,
+ minFontScaleX,
+ minFontScaleY
+ });
+ }
+ }
+ return quads;
+ }
+ var CollisionFeature = function CollisionFeature2(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shaped, boxScale, padding, alignLine, rotate2) {
+ this.boxStartIndex = collisionBoxArray.length;
+ if (alignLine) {
+ var top = shaped.top;
+ var bottom = shaped.bottom;
+ var collisionPadding = shaped.collisionPadding;
+ if (collisionPadding) {
+ top -= collisionPadding[1];
+ bottom += collisionPadding[3];
+ }
+ var height = bottom - top;
+ if (height > 0) {
+ height = Math.max(10, height);
+ this.circleDiameter = height;
+ }
+ } else {
+ var y1 = shaped.top * boxScale - padding;
+ var y2 = shaped.bottom * boxScale + padding;
+ var x1 = shaped.left * boxScale - padding;
+ var x2 = shaped.right * boxScale + padding;
+ var collisionPadding$1 = shaped.collisionPadding;
+ if (collisionPadding$1) {
+ x1 -= collisionPadding$1[0] * boxScale;
+ y1 -= collisionPadding$1[1] * boxScale;
+ x2 += collisionPadding$1[2] * boxScale;
+ y2 += collisionPadding$1[3] * boxScale;
+ }
+ if (rotate2) {
+ var tl = new pointGeometry(x1, y1);
+ var tr = new pointGeometry(x2, y1);
+ var bl = new pointGeometry(x1, y2);
+ var br = new pointGeometry(x2, y2);
+ var rotateRadians = rotate2 * Math.PI / 180;
+ tl._rotate(rotateRadians);
+ tr._rotate(rotateRadians);
+ bl._rotate(rotateRadians);
+ br._rotate(rotateRadians);
+ x1 = Math.min(tl.x, tr.x, bl.x, br.x);
+ x2 = Math.max(tl.x, tr.x, bl.x, br.x);
+ y1 = Math.min(tl.y, tr.y, bl.y, br.y);
+ y2 = Math.max(tl.y, tr.y, bl.y, br.y);
+ }
+ collisionBoxArray.emplaceBack(anchor.x, anchor.y, x1, y1, x2, y2, featureIndex, sourceLayerIndex, bucketIndex);
+ }
+ this.boxEndIndex = collisionBoxArray.length;
+ };
+ var TinyQueue = function TinyQueue2(data, compare2) {
+ if (data === void 0)
+ data = [];
+ if (compare2 === void 0)
+ compare2 = defaultCompare$1;
+ this.data = data;
+ this.length = this.data.length;
+ this.compare = compare2;
+ if (this.length > 0) {
+ for (var i = (this.length >> 1) - 1; i >= 0; i--) {
+ this._down(i);
+ }
+ }
+ };
+ TinyQueue.prototype.push = function push(item) {
+ this.data.push(item);
+ this.length++;
+ this._up(this.length - 1);
+ };
+ TinyQueue.prototype.pop = function pop() {
+ if (this.length === 0) {
+ return void 0;
+ }
+ var top = this.data[0];
+ var bottom = this.data.pop();
+ this.length--;
+ if (this.length > 0) {
+ this.data[0] = bottom;
+ this._down(0);
+ }
+ return top;
+ };
+ TinyQueue.prototype.peek = function peek() {
+ return this.data[0];
+ };
+ TinyQueue.prototype._up = function _up(pos) {
+ var ref = this;
+ var data = ref.data;
+ var compare2 = ref.compare;
+ var item = data[pos];
+ while (pos > 0) {
+ var parent = pos - 1 >> 1;
+ var current = data[parent];
+ if (compare2(item, current) >= 0) {
+ break;
+ }
+ data[pos] = current;
+ pos = parent;
+ }
+ data[pos] = item;
+ };
+ TinyQueue.prototype._down = function _down(pos) {
+ var ref = this;
+ var data = ref.data;
+ var compare2 = ref.compare;
+ var halfLength = this.length >> 1;
+ var item = data[pos];
+ while (pos < halfLength) {
+ var left = (pos << 1) + 1;
+ var best = data[left];
+ var right = left + 1;
+ if (right < this.length && compare2(data[right], best) < 0) {
+ left = right;
+ best = data[right];
+ }
+ if (compare2(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;
+ }
+ function findPoleOfInaccessibility(polygonRings, precision, debug) {
+ if (precision === void 0)
+ precision = 1;
+ if (debug === void 0)
+ debug = false;
+ var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
+ var outerRing = polygonRings[0];
+ for (var i = 0; i < outerRing.length; i++) {
+ var p = outerRing[i];
+ if (!i || p.x < minX) {
+ minX = p.x;
+ }
+ if (!i || p.y < minY) {
+ minY = p.y;
+ }
+ if (!i || p.x > maxX) {
+ maxX = p.x;
+ }
+ if (!i || p.y > maxY) {
+ maxY = p.y;
+ }
+ }
+ var width = maxX - minX;
+ var height = maxY - minY;
+ var cellSize = Math.min(width, height);
+ var h = cellSize / 2;
+ var cellQueue = new TinyQueue([], compareMax);
+ if (cellSize === 0) {
+ return new pointGeometry(minX, minY);
+ }
+ for (var x = minX; x < maxX; x += cellSize) {
+ for (var y = minY; y < maxY; y += cellSize) {
+ cellQueue.push(new Cell(x + h, y + h, h, polygonRings));
+ }
+ }
+ var bestCell = getCentroidCell(polygonRings);
+ var numProbes = cellQueue.length;
+ while (cellQueue.length) {
+ var cell = cellQueue.pop();
+ if (cell.d > bestCell.d || !bestCell.d) {
+ bestCell = cell;
+ if (debug) {
+ console.log("found best %d after %d probes", Math.round(1e4 * cell.d) / 1e4, numProbes);
+ }
+ }
+ if (cell.max - bestCell.d <= precision) {
+ continue;
+ }
+ h = cell.h / 2;
+ cellQueue.push(new Cell(cell.p.x - h, cell.p.y - h, h, polygonRings));
+ cellQueue.push(new Cell(cell.p.x + h, cell.p.y - h, h, polygonRings));
+ cellQueue.push(new Cell(cell.p.x - h, cell.p.y + h, h, polygonRings));
+ cellQueue.push(new Cell(cell.p.x + h, cell.p.y + h, h, polygonRings));
+ numProbes += 4;
+ }
+ if (debug) {
+ console.log("num probes: " + numProbes);
+ console.log("best distance: " + bestCell.d);
+ }
+ return bestCell.p;
+ }
+ function compareMax(a, b) {
+ return b.max - a.max;
+ }
+ function Cell(x, y, h, polygon) {
+ this.p = new pointGeometry(x, y);
+ this.h = h;
+ this.d = pointToPolygonDist(this.p, polygon);
+ this.max = this.d + this.h * Math.SQRT2;
+ }
+ function pointToPolygonDist(p, polygon) {
+ var inside = false;
+ var minDistSq = Infinity;
+ for (var k = 0; k < polygon.length; k++) {
+ var ring = polygon[k];
+ for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) {
+ var a = ring[i];
+ var b = ring[j];
+ if (a.y > p.y !== b.y > p.y && p.x < (b.x - a.x) * (p.y - a.y) / (b.y - a.y) + a.x) {
+ inside = !inside;
+ }
+ minDistSq = Math.min(minDistSq, distToSegmentSquared(p, a, b));
+ }
+ }
+ return (inside ? 1 : -1) * Math.sqrt(minDistSq);
+ }
+ function getCentroidCell(polygon) {
+ var area2 = 0;
+ var x = 0;
+ var y = 0;
+ var points = polygon[0];
+ for (var i = 0, len = points.length, j = len - 1; i < len; j = i++) {
+ var a = points[i];
+ var b = points[j];
+ var f = a.x * b.y - b.x * a.y;
+ x += (a.x + b.x) * f;
+ y += (a.y + b.y) * f;
+ area2 += f * 3;
+ }
+ return new Cell(x / area2, y / area2, 0, polygon);
+ }
+ var baselineOffset = 7;
+ var INVALID_TEXT_OFFSET = Number.POSITIVE_INFINITY;
+ function evaluateVariableOffset(anchor, offset) {
+ function fromRadialOffset(anchor2, radialOffset) {
+ var x = 0, y = 0;
+ if (radialOffset < 0) {
+ radialOffset = 0;
+ }
+ var hypotenuse = radialOffset / Math.sqrt(2);
+ switch (anchor2) {
+ case "top-right":
+ case "top-left":
+ y = hypotenuse - baselineOffset;
+ break;
+ case "bottom-right":
+ case "bottom-left":
+ y = -hypotenuse + baselineOffset;
+ break;
+ case "bottom":
+ y = -radialOffset + baselineOffset;
+ break;
+ case "top":
+ y = radialOffset - baselineOffset;
+ break;
+ }
+ switch (anchor2) {
+ case "top-right":
+ case "bottom-right":
+ x = -hypotenuse;
+ break;
+ case "top-left":
+ case "bottom-left":
+ x = hypotenuse;
+ break;
+ case "left":
+ x = radialOffset;
+ break;
+ case "right":
+ x = -radialOffset;
+ break;
+ }
+ return [
+ x,
+ y
+ ];
+ }
+ function fromTextOffset(anchor2, offsetX, offsetY) {
+ var x = 0, y = 0;
+ offsetX = Math.abs(offsetX);
+ offsetY = Math.abs(offsetY);
+ switch (anchor2) {
+ case "top-right":
+ case "top-left":
+ case "top":
+ y = offsetY - baselineOffset;
+ break;
+ case "bottom-right":
+ case "bottom-left":
+ case "bottom":
+ y = -offsetY + baselineOffset;
+ break;
+ }
+ switch (anchor2) {
+ case "top-right":
+ case "bottom-right":
+ case "right":
+ x = -offsetX;
+ break;
+ case "top-left":
+ case "bottom-left":
+ case "left":
+ x = offsetX;
+ break;
+ }
+ return [
+ x,
+ y
+ ];
+ }
+ return offset[1] !== INVALID_TEXT_OFFSET ? fromTextOffset(anchor, offset[0], offset[1]) : fromRadialOffset(anchor, offset[0]);
+ }
+ function performSymbolLayout(bucket, glyphMap, glyphPositions, imageMap, imagePositions, showCollisionBoxes, canonical) {
+ bucket.createArrays();
+ var tileSize = 512 * bucket.overscaling;
+ bucket.tilePixelRatio = EXTENT$1 / tileSize;
+ bucket.compareText = {};
+ bucket.iconsNeedLinear = false;
+ var layout2 = bucket.layers[0].layout;
+ var unevaluatedLayoutValues = bucket.layers[0]._unevaluatedLayout._values;
+ var sizes = {};
+ if (bucket.textSizeData.kind === "composite") {
+ var ref = bucket.textSizeData;
+ var minZoom = ref.minZoom;
+ var maxZoom = ref.maxZoom;
+ sizes.compositeTextSizes = [
+ unevaluatedLayoutValues["text-size"].possiblyEvaluate(new EvaluationParameters(minZoom), canonical),
+ unevaluatedLayoutValues["text-size"].possiblyEvaluate(new EvaluationParameters(maxZoom), canonical)
+ ];
+ }
+ if (bucket.iconSizeData.kind === "composite") {
+ var ref$1 = bucket.iconSizeData;
+ var minZoom$1 = ref$1.minZoom;
+ var maxZoom$1 = ref$1.maxZoom;
+ sizes.compositeIconSizes = [
+ unevaluatedLayoutValues["icon-size"].possiblyEvaluate(new EvaluationParameters(minZoom$1), canonical),
+ unevaluatedLayoutValues["icon-size"].possiblyEvaluate(new EvaluationParameters(maxZoom$1), canonical)
+ ];
+ }
+ sizes.layoutTextSize = unevaluatedLayoutValues["text-size"].possiblyEvaluate(new EvaluationParameters(bucket.zoom + 1), canonical);
+ sizes.layoutIconSize = unevaluatedLayoutValues["icon-size"].possiblyEvaluate(new EvaluationParameters(bucket.zoom + 1), canonical);
+ sizes.textMaxSize = unevaluatedLayoutValues["text-size"].possiblyEvaluate(new EvaluationParameters(18));
+ var lineHeight = layout2.get("text-line-height") * ONE_EM;
+ var textAlongLine = layout2.get("text-rotation-alignment") === "map" && layout2.get("symbol-placement") !== "point";
+ var keepUpright = layout2.get("text-keep-upright");
+ var textSize = layout2.get("text-size");
+ var loop = function() {
+ var feature = list[i$1];
+ var fontstack = layout2.get("text-font").evaluate(feature, {}, canonical).join(",");
+ var layoutTextSizeThisZoom = textSize.evaluate(feature, {}, canonical);
+ var layoutTextSize = sizes.layoutTextSize.evaluate(feature, {}, canonical);
+ var layoutIconSize = sizes.layoutIconSize.evaluate(feature, {}, canonical);
+ var shapedTextOrientations = {
+ horizontal: {},
+ vertical: void 0
+ };
+ var text = feature.text;
+ var textOffset = [
+ 0,
+ 0
+ ];
+ if (text) {
+ var unformattedText = text.toString();
+ var spacing = layout2.get("text-letter-spacing").evaluate(feature, {}, canonical) * ONE_EM;
+ var spacingIfAllowed = allowsLetterSpacing(unformattedText) ? spacing : 0;
+ var textAnchor = layout2.get("text-anchor").evaluate(feature, {}, canonical);
+ var variableTextAnchor = layout2.get("text-variable-anchor");
+ if (!variableTextAnchor) {
+ var radialOffset = layout2.get("text-radial-offset").evaluate(feature, {}, canonical);
+ if (radialOffset) {
+ textOffset = evaluateVariableOffset(textAnchor, [
+ radialOffset * ONE_EM,
+ INVALID_TEXT_OFFSET
+ ]);
+ } else {
+ textOffset = layout2.get("text-offset").evaluate(feature, {}, canonical).map(function(t) {
+ return t * ONE_EM;
+ });
+ }
+ }
+ var textJustify = textAlongLine ? "center" : layout2.get("text-justify").evaluate(feature, {}, canonical);
+ var symbolPlacement = layout2.get("symbol-placement");
+ var maxWidth = symbolPlacement === "point" ? layout2.get("text-max-width").evaluate(feature, {}, canonical) * ONE_EM : 0;
+ var addVerticalShapingForPointLabelIfNeeded = function() {
+ if (bucket.allowVerticalPlacement && allowsVerticalWritingMode(unformattedText)) {
+ shapedTextOrientations.vertical = shapeText(text, glyphMap, glyphPositions, imagePositions, fontstack, maxWidth, lineHeight, textAnchor, "left", spacingIfAllowed, textOffset, WritingMode.vertical, true, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);
+ }
+ };
+ if (!textAlongLine && variableTextAnchor) {
+ var justifications = textJustify === "auto" ? variableTextAnchor.map(function(a) {
+ return getAnchorJustification(a);
+ }) : [textJustify];
+ var singleLine = false;
+ for (var i = 0; i < justifications.length; i++) {
+ var justification = justifications[i];
+ if (shapedTextOrientations.horizontal[justification]) {
+ continue;
+ }
+ if (singleLine) {
+ shapedTextOrientations.horizontal[justification] = shapedTextOrientations.horizontal[0];
+ } else {
+ var shaping = shapeText(text, glyphMap, glyphPositions, imagePositions, fontstack, maxWidth, lineHeight, "center", justification, spacingIfAllowed, textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);
+ if (shaping) {
+ shapedTextOrientations.horizontal[justification] = shaping;
+ singleLine = shaping.positionedLines.length === 1;
+ }
+ }
+ }
+ addVerticalShapingForPointLabelIfNeeded();
+ } else {
+ if (textJustify === "auto") {
+ textJustify = getAnchorJustification(textAnchor);
+ }
+ var shaping$1 = shapeText(text, glyphMap, glyphPositions, imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed, textOffset, WritingMode.horizontal, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);
+ if (shaping$1) {
+ shapedTextOrientations.horizontal[textJustify] = shaping$1;
+ }
+ addVerticalShapingForPointLabelIfNeeded();
+ if (allowsVerticalWritingMode(unformattedText) && textAlongLine && keepUpright) {
+ shapedTextOrientations.vertical = shapeText(text, glyphMap, glyphPositions, imagePositions, fontstack, maxWidth, lineHeight, textAnchor, textJustify, spacingIfAllowed, textOffset, WritingMode.vertical, false, symbolPlacement, layoutTextSize, layoutTextSizeThisZoom);
+ }
+ }
+ }
+ var shapedIcon = void 0;
+ var isSDFIcon = false;
+ if (feature.icon && feature.icon.name) {
+ var image = imageMap[feature.icon.name];
+ if (image) {
+ shapedIcon = shapeIcon(imagePositions[feature.icon.name], layout2.get("icon-offset").evaluate(feature, {}, canonical), layout2.get("icon-anchor").evaluate(feature, {}, canonical));
+ isSDFIcon = image.sdf;
+ if (bucket.sdfIcons === void 0) {
+ bucket.sdfIcons = image.sdf;
+ } else if (bucket.sdfIcons !== image.sdf) {
+ warnOnce("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer");
+ }
+ if (image.pixelRatio !== bucket.pixelRatio) {
+ bucket.iconsNeedLinear = true;
+ } else if (layout2.get("icon-rotate").constantOr(1) !== 0) {
+ bucket.iconsNeedLinear = true;
+ }
+ }
+ }
+ var shapedText = getDefaultHorizontalShaping(shapedTextOrientations.horizontal) || shapedTextOrientations.vertical;
+ bucket.iconsInText = shapedText ? shapedText.iconsInText : false;
+ if (shapedText || shapedIcon) {
+ addFeature(bucket, feature, shapedTextOrientations, shapedIcon, imageMap, sizes, layoutTextSize, layoutIconSize, textOffset, isSDFIcon, canonical);
+ }
+ };
+ for (var i$1 = 0, list = bucket.features; i$1 < list.length; i$1 += 1)
+ loop();
+ if (showCollisionBoxes) {
+ bucket.generateCollisionDebugBuffers();
+ }
+ }
+ function getAnchorJustification(anchor) {
+ switch (anchor) {
+ case "right":
+ case "top-right":
+ case "bottom-right":
+ return "right";
+ case "left":
+ case "top-left":
+ case "bottom-left":
+ return "left";
+ }
+ return "center";
+ }
+ function addFeature(bucket, feature, shapedTextOrientations, shapedIcon, imageMap, sizes, layoutTextSize, layoutIconSize, textOffset, isSDFIcon, canonical) {
+ var textMaxSize = sizes.textMaxSize.evaluate(feature, {});
+ if (textMaxSize === void 0) {
+ textMaxSize = layoutTextSize;
+ }
+ var layout2 = bucket.layers[0].layout;
+ var iconOffset = layout2.get("icon-offset").evaluate(feature, {}, canonical);
+ var defaultHorizontalShaping = getDefaultHorizontalShaping(shapedTextOrientations.horizontal);
+ var glyphSize = 24, fontScale = layoutTextSize / glyphSize, textBoxScale = bucket.tilePixelRatio * fontScale, textMaxBoxScale = bucket.tilePixelRatio * textMaxSize / glyphSize, iconBoxScale = bucket.tilePixelRatio * layoutIconSize, symbolMinDistance = bucket.tilePixelRatio * layout2.get("symbol-spacing"), textPadding = layout2.get("text-padding") * bucket.tilePixelRatio, iconPadding = layout2.get("icon-padding") * bucket.tilePixelRatio, textMaxAngle = layout2.get("text-max-angle") / 180 * Math.PI, textAlongLine = layout2.get("text-rotation-alignment") === "map" && layout2.get("symbol-placement") !== "point", iconAlongLine = layout2.get("icon-rotation-alignment") === "map" && layout2.get("symbol-placement") !== "point", symbolPlacement = layout2.get("symbol-placement"), textRepeatDistance = symbolMinDistance / 2;
+ var iconTextFit = layout2.get("icon-text-fit");
+ var verticallyShapedIcon;
+ if (shapedIcon && iconTextFit !== "none") {
+ if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {
+ verticallyShapedIcon = fitIconToText(shapedIcon, shapedTextOrientations.vertical, iconTextFit, layout2.get("icon-text-fit-padding"), iconOffset, fontScale);
+ }
+ if (defaultHorizontalShaping) {
+ shapedIcon = fitIconToText(shapedIcon, defaultHorizontalShaping, iconTextFit, layout2.get("icon-text-fit-padding"), iconOffset, fontScale);
+ }
+ }
+ var addSymbolAtAnchor = function(line2, anchor2) {
+ if (anchor2.x < 0 || anchor2.x >= EXTENT$1 || anchor2.y < 0 || anchor2.y >= EXTENT$1) {
+ return;
+ }
+ addSymbol(bucket, anchor2, line2, shapedTextOrientations, shapedIcon, imageMap, verticallyShapedIcon, bucket.layers[0], bucket.collisionBoxArray, feature.index, feature.sourceLayerIndex, bucket.index, textBoxScale, textPadding, textAlongLine, textOffset, iconBoxScale, iconPadding, iconAlongLine, iconOffset, feature, sizes, isSDFIcon, canonical, layoutTextSize);
+ };
+ if (symbolPlacement === "line") {
+ for (var i$1 = 0, list$1 = clipLine(feature.geometry, 0, 0, EXTENT$1, EXTENT$1); i$1 < list$1.length; i$1 += 1) {
+ var line = list$1[i$1];
+ var anchors = getAnchors(line, symbolMinDistance, textMaxAngle, shapedTextOrientations.vertical || defaultHorizontalShaping, shapedIcon, glyphSize, textMaxBoxScale, bucket.overscaling, EXTENT$1);
+ for (var i = 0, list = anchors; i < list.length; i += 1) {
+ var anchor = list[i];
+ var shapedText = defaultHorizontalShaping;
+ if (!shapedText || !anchorIsTooClose(bucket, shapedText.text, textRepeatDistance, anchor)) {
+ addSymbolAtAnchor(line, anchor);
+ }
+ }
+ }
+ } else if (symbolPlacement === "line-center") {
+ for (var i$2 = 0, list$2 = feature.geometry; i$2 < list$2.length; i$2 += 1) {
+ var line$1 = list$2[i$2];
+ if (line$1.length > 1) {
+ var anchor$1 = getCenterAnchor(line$1, textMaxAngle, shapedTextOrientations.vertical || defaultHorizontalShaping, shapedIcon, glyphSize, textMaxBoxScale);
+ if (anchor$1) {
+ addSymbolAtAnchor(line$1, anchor$1);
+ }
+ }
+ }
+ } else if (feature.type === "Polygon") {
+ for (var i$3 = 0, list$3 = classifyRings(feature.geometry, 0); i$3 < list$3.length; i$3 += 1) {
+ var polygon = list$3[i$3];
+ var poi = findPoleOfInaccessibility(polygon, 16);
+ addSymbolAtAnchor(polygon[0], new Anchor(poi.x, poi.y, 0));
+ }
+ } else if (feature.type === "LineString") {
+ for (var i$4 = 0, list$4 = feature.geometry; i$4 < list$4.length; i$4 += 1) {
+ var line$2 = list$4[i$4];
+ addSymbolAtAnchor(line$2, new Anchor(line$2[0].x, line$2[0].y, 0));
+ }
+ } else if (feature.type === "Point") {
+ for (var i$6 = 0, list$6 = feature.geometry; i$6 < list$6.length; i$6 += 1) {
+ var points = list$6[i$6];
+ for (var i$5 = 0, list$5 = points; i$5 < list$5.length; i$5 += 1) {
+ var point = list$5[i$5];
+ addSymbolAtAnchor([point], new Anchor(point.x, point.y, 0));
+ }
+ }
+ }
+ }
+ var MAX_GLYPH_ICON_SIZE = 255;
+ var MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR;
+ function addTextVertices(bucket, anchor, shapedText, imageMap, layer2, textAlongLine, feature, textOffset, lineArray, writingMode, placementTypes, placedTextSymbolIndices, placedIconIndex, sizes, canonical) {
+ var glyphQuads = getGlyphQuads(anchor, shapedText, textOffset, layer2, textAlongLine, feature, imageMap, bucket.allowVerticalPlacement);
+ var sizeData = bucket.textSizeData;
+ var textSizeData = null;
+ if (sizeData.kind === "source") {
+ textSizeData = [SIZE_PACK_FACTOR * layer2.layout.get("text-size").evaluate(feature, {})];
+ if (textSizeData[0] > MAX_PACKED_SIZE) {
+ warnOnce(bucket.layerIds[0] + ': Value for "text-size" is >= ' + MAX_GLYPH_ICON_SIZE + '. Reduce your "text-size".');
+ }
+ } else if (sizeData.kind === "composite") {
+ textSizeData = [
+ SIZE_PACK_FACTOR * sizes.compositeTextSizes[0].evaluate(feature, {}, canonical),
+ SIZE_PACK_FACTOR * sizes.compositeTextSizes[1].evaluate(feature, {}, canonical)
+ ];
+ if (textSizeData[0] > MAX_PACKED_SIZE || textSizeData[1] > MAX_PACKED_SIZE) {
+ warnOnce(bucket.layerIds[0] + ': Value for "text-size" is >= ' + MAX_GLYPH_ICON_SIZE + '. Reduce your "text-size".');
+ }
+ }
+ bucket.addSymbols(bucket.text, glyphQuads, textSizeData, textOffset, textAlongLine, feature, writingMode, anchor, lineArray.lineStartIndex, lineArray.lineLength, placedIconIndex, canonical);
+ for (var i = 0, list = placementTypes; i < list.length; i += 1) {
+ var placementType = list[i];
+ placedTextSymbolIndices[placementType] = bucket.text.placedSymbolArray.length - 1;
+ }
+ return glyphQuads.length * 4;
+ }
+ function getDefaultHorizontalShaping(horizontalShaping) {
+ for (var justification in horizontalShaping) {
+ return horizontalShaping[justification];
+ }
+ return null;
+ }
+ function addSymbol(bucket, anchor, line, shapedTextOrientations, shapedIcon, imageMap, verticallyShapedIcon, layer2, collisionBoxArray, featureIndex, sourceLayerIndex, bucketIndex, textBoxScale, textPadding, textAlongLine, textOffset, iconBoxScale, iconPadding, iconAlongLine, iconOffset, feature, sizes, isSDFIcon, canonical, layoutTextSize) {
+ var assign;
+ var lineArray = bucket.addToLineVertexArray(anchor, line);
+ var textCollisionFeature, iconCollisionFeature, verticalTextCollisionFeature, verticalIconCollisionFeature;
+ var numIconVertices = 0;
+ var numVerticalIconVertices = 0;
+ var numHorizontalGlyphVertices = 0;
+ var numVerticalGlyphVertices = 0;
+ var placedIconSymbolIndex = -1;
+ var verticalPlacedIconSymbolIndex = -1;
+ var placedTextSymbolIndices = {};
+ var key = murmurhashJs("");
+ var textOffset0 = 0;
+ var textOffset1 = 0;
+ if (layer2._unevaluatedLayout.getValue("text-radial-offset") === void 0) {
+ assign = layer2.layout.get("text-offset").evaluate(feature, {}, canonical).map(function(t) {
+ return t * ONE_EM;
+ }), textOffset0 = assign[0], textOffset1 = assign[1];
+ } else {
+ textOffset0 = layer2.layout.get("text-radial-offset").evaluate(feature, {}, canonical) * ONE_EM;
+ textOffset1 = INVALID_TEXT_OFFSET;
+ }
+ if (bucket.allowVerticalPlacement && shapedTextOrientations.vertical) {
+ var textRotation = layer2.layout.get("text-rotate").evaluate(feature, {}, canonical);
+ var verticalTextRotation = textRotation + 90;
+ var verticalShaping = shapedTextOrientations.vertical;
+ verticalTextCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticalShaping, textBoxScale, textPadding, textAlongLine, verticalTextRotation);
+ if (verticallyShapedIcon) {
+ verticalIconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, verticallyShapedIcon, iconBoxScale, iconPadding, textAlongLine, verticalTextRotation);
+ }
+ }
+ if (shapedIcon) {
+ var iconRotate = layer2.layout.get("icon-rotate").evaluate(feature, {});
+ var hasIconTextFit = layer2.layout.get("icon-text-fit") !== "none";
+ var iconQuads = getIconQuads(shapedIcon, iconRotate, isSDFIcon, hasIconTextFit);
+ var verticalIconQuads = verticallyShapedIcon ? getIconQuads(verticallyShapedIcon, iconRotate, isSDFIcon, hasIconTextFit) : void 0;
+ iconCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedIcon, iconBoxScale, iconPadding, false, iconRotate);
+ numIconVertices = iconQuads.length * 4;
+ var sizeData = bucket.iconSizeData;
+ var iconSizeData = null;
+ if (sizeData.kind === "source") {
+ iconSizeData = [SIZE_PACK_FACTOR * layer2.layout.get("icon-size").evaluate(feature, {})];
+ if (iconSizeData[0] > MAX_PACKED_SIZE) {
+ warnOnce(bucket.layerIds[0] + ': Value for "icon-size" is >= ' + MAX_GLYPH_ICON_SIZE + '. Reduce your "icon-size".');
+ }
+ } else if (sizeData.kind === "composite") {
+ iconSizeData = [
+ SIZE_PACK_FACTOR * sizes.compositeIconSizes[0].evaluate(feature, {}, canonical),
+ SIZE_PACK_FACTOR * sizes.compositeIconSizes[1].evaluate(feature, {}, canonical)
+ ];
+ if (iconSizeData[0] > MAX_PACKED_SIZE || iconSizeData[1] > MAX_PACKED_SIZE) {
+ warnOnce(bucket.layerIds[0] + ': Value for "icon-size" is >= ' + MAX_GLYPH_ICON_SIZE + '. Reduce your "icon-size".');
+ }
+ }
+ bucket.addSymbols(bucket.icon, iconQuads, iconSizeData, iconOffset, iconAlongLine, feature, false, anchor, lineArray.lineStartIndex, lineArray.lineLength, -1, canonical);
+ placedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;
+ if (verticalIconQuads) {
+ numVerticalIconVertices = verticalIconQuads.length * 4;
+ bucket.addSymbols(bucket.icon, verticalIconQuads, iconSizeData, iconOffset, iconAlongLine, feature, WritingMode.vertical, anchor, lineArray.lineStartIndex, lineArray.lineLength, -1, canonical);
+ verticalPlacedIconSymbolIndex = bucket.icon.placedSymbolArray.length - 1;
+ }
+ }
+ for (var justification in shapedTextOrientations.horizontal) {
+ var shaping = shapedTextOrientations.horizontal[justification];
+ if (!textCollisionFeature) {
+ key = murmurhashJs(shaping.text);
+ var textRotate = layer2.layout.get("text-rotate").evaluate(feature, {}, canonical);
+ textCollisionFeature = new CollisionFeature(collisionBoxArray, anchor, featureIndex, sourceLayerIndex, bucketIndex, shaping, textBoxScale, textPadding, textAlongLine, textRotate);
+ }
+ var singleLine = shaping.positionedLines.length === 1;
+ numHorizontalGlyphVertices += addTextVertices(bucket, anchor, shaping, imageMap, layer2, textAlongLine, feature, textOffset, lineArray, shapedTextOrientations.vertical ? WritingMode.horizontal : WritingMode.horizontalOnly, singleLine ? Object.keys(shapedTextOrientations.horizontal) : [justification], placedTextSymbolIndices, placedIconSymbolIndex, sizes, canonical);
+ if (singleLine) {
+ break;
+ }
+ }
+ if (shapedTextOrientations.vertical) {
+ numVerticalGlyphVertices += addTextVertices(bucket, anchor, shapedTextOrientations.vertical, imageMap, layer2, textAlongLine, feature, textOffset, lineArray, WritingMode.vertical, ["vertical"], placedTextSymbolIndices, verticalPlacedIconSymbolIndex, sizes, canonical);
+ }
+ var textBoxStartIndex = textCollisionFeature ? textCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;
+ var textBoxEndIndex = textCollisionFeature ? textCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;
+ var verticalTextBoxStartIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;
+ var verticalTextBoxEndIndex = verticalTextCollisionFeature ? verticalTextCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;
+ var iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;
+ var iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;
+ var verticalIconBoxStartIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;
+ var verticalIconBoxEndIndex = verticalIconCollisionFeature ? verticalIconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;
+ var collisionCircleDiameter = -1;
+ var getCollisionCircleHeight = function(feature2, prevHeight) {
+ if (feature2 && feature2.circleDiameter) {
+ return Math.max(feature2.circleDiameter, prevHeight);
+ }
+ return prevHeight;
+ };
+ collisionCircleDiameter = getCollisionCircleHeight(textCollisionFeature, collisionCircleDiameter);
+ collisionCircleDiameter = getCollisionCircleHeight(verticalTextCollisionFeature, collisionCircleDiameter);
+ collisionCircleDiameter = getCollisionCircleHeight(iconCollisionFeature, collisionCircleDiameter);
+ collisionCircleDiameter = getCollisionCircleHeight(verticalIconCollisionFeature, collisionCircleDiameter);
+ var useRuntimeCollisionCircles = collisionCircleDiameter > -1 ? 1 : 0;
+ if (useRuntimeCollisionCircles) {
+ collisionCircleDiameter *= layoutTextSize / ONE_EM;
+ }
+ if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS) {
+ warnOnce("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907");
+ }
+ if (feature.sortKey !== void 0) {
+ bucket.addToSortKeyRanges(bucket.symbolInstances.length, feature.sortKey);
+ }
+ bucket.symbolInstances.emplaceBack(anchor.x, anchor.y, placedTextSymbolIndices.right >= 0 ? placedTextSymbolIndices.right : -1, placedTextSymbolIndices.center >= 0 ? placedTextSymbolIndices.center : -1, placedTextSymbolIndices.left >= 0 ? placedTextSymbolIndices.left : -1, placedTextSymbolIndices.vertical || -1, placedIconSymbolIndex, verticalPlacedIconSymbolIndex, key, textBoxStartIndex, textBoxEndIndex, verticalTextBoxStartIndex, verticalTextBoxEndIndex, iconBoxStartIndex, iconBoxEndIndex, verticalIconBoxStartIndex, verticalIconBoxEndIndex, featureIndex, numHorizontalGlyphVertices, numVerticalGlyphVertices, numIconVertices, numVerticalIconVertices, useRuntimeCollisionCircles, 0, textBoxScale, textOffset0, textOffset1, collisionCircleDiameter);
+ }
+ function anchorIsTooClose(bucket, text, repeatDistance, anchor) {
+ var compareText = bucket.compareText;
+ if (!(text in compareText)) {
+ compareText[text] = [];
+ } else {
+ var otherAnchors = compareText[text];
+ for (var k = otherAnchors.length - 1; k >= 0; k--) {
+ if (anchor.dist(otherAnchors[k]) < repeatDistance) {
+ return true;
+ }
+ }
+ }
+ compareText[text].push(anchor);
+ return false;
+ }
+ var vectorTileFeatureTypes$2 = vectorTile.VectorTileFeature.types;
+ var shaderOpacityAttributes = [{
+ name: "a_fade_opacity",
+ components: 1,
+ type: "Uint8",
+ offset: 0
+ }];
+ function addVertex$1(array2, anchorX, anchorY, ox, oy, tx, ty, sizeVertex, isSDF, pixelOffsetX, pixelOffsetY, minFontScaleX, minFontScaleY) {
+ var aSizeX = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[0])) : 0;
+ var aSizeY = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[1])) : 0;
+ array2.emplaceBack(anchorX, anchorY, Math.round(ox * 32), Math.round(oy * 32), tx, ty, (aSizeX << 1) + (isSDF ? 1 : 0), aSizeY, pixelOffsetX * 16, pixelOffsetY * 16, minFontScaleX * 256, minFontScaleY * 256);
+ }
+ function addDynamicAttributes(dynamicLayoutVertexArray, p, angle) {
+ dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
+ dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
+ dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
+ dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
+ }
+ function containsRTLText(formattedText) {
+ for (var i = 0, list = formattedText.sections; i < list.length; i += 1) {
+ var section = list[i];
+ if (stringContainsRTLText(section.text)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ var SymbolBuffers = function SymbolBuffers2(programConfigurations) {
+ this.layoutVertexArray = new StructArrayLayout4i4ui4i24();
+ this.indexArray = new StructArrayLayout3ui6();
+ this.programConfigurations = programConfigurations;
+ this.segments = new SegmentVector();
+ this.dynamicLayoutVertexArray = new StructArrayLayout3f12();
+ this.opacityVertexArray = new StructArrayLayout1ul4();
+ this.placedSymbolArray = new PlacedSymbolArray();
+ };
+ SymbolBuffers.prototype.isEmpty = function isEmpty2() {
+ return this.layoutVertexArray.length === 0 && this.indexArray.length === 0 && this.dynamicLayoutVertexArray.length === 0 && this.opacityVertexArray.length === 0;
+ };
+ SymbolBuffers.prototype.upload = function upload(context, dynamicIndexBuffer, upload$1, update) {
+ if (this.isEmpty()) {
+ return;
+ }
+ if (upload$1) {
+ this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members);
+ this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer);
+ this.dynamicLayoutVertexBuffer = context.createVertexBuffer(this.dynamicLayoutVertexArray, dynamicLayoutAttributes.members, true);
+ this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true);
+ this.opacityVertexBuffer.itemSize = 1;
+ }
+ if (upload$1 || update) {
+ this.programConfigurations.upload(context);
+ }
+ };
+ SymbolBuffers.prototype.destroy = function destroy() {
+ if (!this.layoutVertexBuffer) {
+ return;
+ }
+ this.layoutVertexBuffer.destroy();
+ this.indexBuffer.destroy();
+ this.programConfigurations.destroy();
+ this.segments.destroy();
+ this.dynamicLayoutVertexBuffer.destroy();
+ this.opacityVertexBuffer.destroy();
+ };
+ register("SymbolBuffers", SymbolBuffers);
+ var CollisionBuffers = function CollisionBuffers2(LayoutArray, layoutAttributes, IndexArray) {
+ this.layoutVertexArray = new LayoutArray();
+ this.layoutAttributes = layoutAttributes;
+ this.indexArray = new IndexArray();
+ this.segments = new SegmentVector();
+ this.collisionVertexArray = new StructArrayLayout2ub2f12();
+ };
+ CollisionBuffers.prototype.upload = function upload(context) {
+ this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes);
+ this.indexBuffer = context.createIndexBuffer(this.indexArray);
+ this.collisionVertexBuffer = context.createVertexBuffer(this.collisionVertexArray, collisionVertexAttributes.members, true);
+ };
+ CollisionBuffers.prototype.destroy = function destroy() {
+ if (!this.layoutVertexBuffer) {
+ return;
+ }
+ this.layoutVertexBuffer.destroy();
+ this.indexBuffer.destroy();
+ this.segments.destroy();
+ this.collisionVertexBuffer.destroy();
+ };
+ register("CollisionBuffers", CollisionBuffers);
+ var SymbolBucket = function SymbolBucket2(options) {
+ this.collisionBoxArray = options.collisionBoxArray;
+ this.zoom = options.zoom;
+ this.overscaling = options.overscaling;
+ this.layers = options.layers;
+ this.layerIds = this.layers.map(function(layer3) {
+ return layer3.id;
+ });
+ this.index = options.index;
+ this.pixelRatio = options.pixelRatio;
+ this.sourceLayerIndex = options.sourceLayerIndex;
+ this.hasPattern = false;
+ this.hasRTLText = false;
+ this.sortKeyRanges = [];
+ this.collisionCircleArray = [];
+ this.placementInvProjMatrix = identity2([]);
+ this.placementViewportMatrix = identity2([]);
+ var layer2 = this.layers[0];
+ var unevaluatedLayoutValues = layer2._unevaluatedLayout._values;
+ this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues["text-size"]);
+ this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues["icon-size"]);
+ var layout2 = this.layers[0].layout;
+ var sortKey = layout2.get("symbol-sort-key");
+ var zOrder2 = layout2.get("symbol-z-order");
+ this.canOverlap = layout2.get("text-allow-overlap") || layout2.get("icon-allow-overlap") || layout2.get("text-ignore-placement") || layout2.get("icon-ignore-placement");
+ this.sortFeaturesByKey = zOrder2 !== "viewport-y" && sortKey.constantOr(1) !== void 0;
+ var zOrderByViewportY = zOrder2 === "viewport-y" || zOrder2 === "auto" && !this.sortFeaturesByKey;
+ this.sortFeaturesByY = zOrderByViewportY && this.canOverlap;
+ if (layout2.get("symbol-placement") === "point") {
+ this.writingModes = layout2.get("text-writing-mode").map(function(wm) {
+ return WritingMode[wm];
+ });
+ }
+ this.stateDependentLayerIds = this.layers.filter(function(l) {
+ return l.isStateDependent();
+ }).map(function(l) {
+ return l.id;
+ });
+ this.sourceID = options.sourceID;
+ };
+ SymbolBucket.prototype.createArrays = function createArrays() {
+ this.text = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, function(property) {
+ return /^text/.test(property);
+ }));
+ this.icon = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, function(property) {
+ return /^icon/.test(property);
+ }));
+ this.glyphOffsetArray = new GlyphOffsetArray();
+ this.lineVertexArray = new SymbolLineVertexArray();
+ this.symbolInstances = new SymbolInstanceArray();
+ };
+ SymbolBucket.prototype.calculateGlyphDependencies = function calculateGlyphDependencies(text, stack, textAlongLine, allowVerticalPlacement, doesAllowVerticalWritingMode) {
+ for (var i = 0; i < text.length; i++) {
+ stack[text.charCodeAt(i)] = true;
+ if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) {
+ var verticalChar = verticalizedCharacterMap[text.charAt(i)];
+ if (verticalChar) {
+ stack[verticalChar.charCodeAt(0)] = true;
+ }
+ }
+ }
+ };
+ SymbolBucket.prototype.populate = function populate(features, options, canonical) {
+ var layer2 = this.layers[0];
+ var layout2 = layer2.layout;
+ var textFont = layout2.get("text-font");
+ var textField = layout2.get("text-field");
+ var iconImage = layout2.get("icon-image");
+ var hasText = (textField.value.kind !== "constant" || textField.value.value instanceof Formatted && !textField.value.value.isEmpty() || textField.value.value.toString().length > 0) && (textFont.value.kind !== "constant" || textFont.value.value.length > 0);
+ var hasIcon = iconImage.value.kind !== "constant" || !!iconImage.value.value || Object.keys(iconImage.parameters).length > 0;
+ var symbolSortKey = layout2.get("symbol-sort-key");
+ this.features = [];
+ if (!hasText && !hasIcon) {
+ return;
+ }
+ var icons = options.iconDependencies;
+ var stacks = options.glyphDependencies;
+ var availableImages = options.availableImages;
+ var globalProperties = new EvaluationParameters(this.zoom);
+ for (var i$1 = 0, list$1 = features; i$1 < list$1.length; i$1 += 1) {
+ var ref = list$1[i$1];
+ var feature = ref.feature;
+ var id2 = ref.id;
+ var index = ref.index;
+ var sourceLayerIndex = ref.sourceLayerIndex;
+ var needGeometry = layer2._featureFilter.needGeometry;
+ var evaluationFeature = toEvaluationFeature(feature, needGeometry);
+ if (!layer2._featureFilter.filter(globalProperties, evaluationFeature, canonical)) {
+ continue;
+ }
+ if (!needGeometry) {
+ evaluationFeature.geometry = loadGeometry(feature);
+ }
+ var text = void 0;
+ if (hasText) {
+ var resolvedTokens = layer2.getValueAndResolveTokens("text-field", evaluationFeature, canonical, availableImages);
+ var formattedText = Formatted.factory(resolvedTokens);
+ if (containsRTLText(formattedText)) {
+ this.hasRTLText = true;
+ }
+ if (!this.hasRTLText || getRTLTextPluginStatus() === "unavailable" || this.hasRTLText && plugin.isParsed()) {
+ text = transformText$1(formattedText, layer2, evaluationFeature);
+ }
+ }
+ var icon = void 0;
+ if (hasIcon) {
+ var resolvedTokens$1 = layer2.getValueAndResolveTokens("icon-image", evaluationFeature, canonical, availableImages);
+ if (resolvedTokens$1 instanceof ResolvedImage) {
+ icon = resolvedTokens$1;
+ } else {
+ icon = ResolvedImage.fromString(resolvedTokens$1);
+ }
+ }
+ if (!text && !icon) {
+ continue;
+ }
+ var sortKey = this.sortFeaturesByKey ? symbolSortKey.evaluate(evaluationFeature, {}, canonical) : void 0;
+ var symbolFeature = {
+ id: id2,
+ text,
+ icon,
+ index,
+ sourceLayerIndex,
+ geometry: evaluationFeature.geometry,
+ properties: feature.properties,
+ type: vectorTileFeatureTypes$2[feature.type],
+ sortKey
+ };
+ this.features.push(symbolFeature);
+ if (icon) {
+ icons[icon.name] = true;
+ }
+ if (text) {
+ var fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(",");
+ var textAlongLine = layout2.get("text-rotation-alignment") === "map" && layout2.get("symbol-placement") !== "point";
+ this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(WritingMode.vertical) >= 0;
+ for (var i = 0, list = text.sections; i < list.length; i += 1) {
+ var section = list[i];
+ if (!section.image) {
+ var doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString());
+ var sectionFont = section.fontStack || fontStack;
+ var sectionStack = stacks[sectionFont] = stacks[sectionFont] || {};
+ this.calculateGlyphDependencies(section.text, sectionStack, textAlongLine, this.allowVerticalPlacement, doesAllowVerticalWritingMode);
+ } else {
+ icons[section.image.name] = true;
+ }
+ }
+ }
+ }
+ if (layout2.get("symbol-placement") === "line") {
+ this.features = mergeLines(this.features);
+ }
+ if (this.sortFeaturesByKey) {
+ this.features.sort(function(a, b) {
+ return a.sortKey - b.sortKey;
+ });
+ }
+ };
+ SymbolBucket.prototype.update = function update(states, vtLayer, imagePositions) {
+ if (!this.stateDependentLayers.length) {
+ return;
+ }
+ this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
+ this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
+ };
+ SymbolBucket.prototype.isEmpty = function isEmpty2() {
+ return this.symbolInstances.length === 0 && !this.hasRTLText;
+ };
+ SymbolBucket.prototype.uploadPending = function uploadPending() {
+ return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;
+ };
+ SymbolBucket.prototype.upload = function upload(context) {
+ if (!this.uploaded && this.hasDebugData()) {
+ this.textCollisionBox.upload(context);
+ this.iconCollisionBox.upload(context);
+ }
+ this.text.upload(context, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload);
+ this.icon.upload(context, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload);
+ this.uploaded = true;
+ };
+ SymbolBucket.prototype.destroyDebugData = function destroyDebugData() {
+ this.textCollisionBox.destroy();
+ this.iconCollisionBox.destroy();
+ };
+ SymbolBucket.prototype.destroy = function destroy() {
+ this.text.destroy();
+ this.icon.destroy();
+ if (this.hasDebugData()) {
+ this.destroyDebugData();
+ }
+ };
+ SymbolBucket.prototype.addToLineVertexArray = function addToLineVertexArray(anchor, line) {
+ var lineStartIndex = this.lineVertexArray.length;
+ if (anchor.segment !== void 0) {
+ var sumForwardLength = anchor.dist(line[anchor.segment + 1]);
+ var sumBackwardLength = anchor.dist(line[anchor.segment]);
+ var vertices = {};
+ for (var i = anchor.segment + 1; i < line.length; i++) {
+ vertices[i] = {
+ x: line[i].x,
+ y: line[i].y,
+ tileUnitDistanceFromAnchor: sumForwardLength
+ };
+ if (i < line.length - 1) {
+ sumForwardLength += line[i + 1].dist(line[i]);
+ }
+ }
+ for (var i$1 = anchor.segment || 0; i$1 >= 0; i$1--) {
+ vertices[i$1] = {
+ x: line[i$1].x,
+ y: line[i$1].y,
+ tileUnitDistanceFromAnchor: sumBackwardLength
+ };
+ if (i$1 > 0) {
+ sumBackwardLength += line[i$1 - 1].dist(line[i$1]);
+ }
+ }
+ for (var i$2 = 0; i$2 < line.length; i$2++) {
+ var vertex = vertices[i$2];
+ this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor);
+ }
+ }
+ return {
+ lineStartIndex,
+ lineLength: this.lineVertexArray.length - lineStartIndex
+ };
+ };
+ SymbolBucket.prototype.addSymbols = function addSymbols(arrays, quads, sizeVertex, lineOffset, alongLine, feature, writingMode, labelAnchor, lineStartIndex, lineLength, associatedIconIndex, canonical) {
+ var indexArray = arrays.indexArray;
+ var layoutVertexArray = arrays.layoutVertexArray;
+ var segment = arrays.segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray, this.canOverlap ? feature.sortKey : void 0);
+ var glyphOffsetArrayStart = this.glyphOffsetArray.length;
+ var vertexStartIndex = segment.vertexLength;
+ var angle = this.allowVerticalPlacement && writingMode === WritingMode.vertical ? Math.PI / 2 : 0;
+ var sections = feature.text && feature.text.sections;
+ for (var i = 0; i < quads.length; i++) {
+ var ref = quads[i];
+ var tl = ref.tl;
+ var tr = ref.tr;
+ var bl = ref.bl;
+ var br = ref.br;
+ var tex = ref.tex;
+ var pixelOffsetTL = ref.pixelOffsetTL;
+ var pixelOffsetBR = ref.pixelOffsetBR;
+ var minFontScaleX = ref.minFontScaleX;
+ var minFontScaleY = ref.minFontScaleY;
+ var glyphOffset2 = ref.glyphOffset;
+ var isSDF = ref.isSDF;
+ var sectionIndex = ref.sectionIndex;
+ var index = segment.vertexLength;
+ var y = glyphOffset2[1];
+ addVertex$1(layoutVertexArray, labelAnchor.x, labelAnchor.y, tl.x, y + tl.y, tex.x, tex.y, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);
+ addVertex$1(layoutVertexArray, labelAnchor.x, labelAnchor.y, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);
+ addVertex$1(layoutVertexArray, labelAnchor.x, labelAnchor.y, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);
+ addVertex$1(layoutVertexArray, labelAnchor.x, labelAnchor.y, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);
+ addDynamicAttributes(arrays.dynamicLayoutVertexArray, labelAnchor, angle);
+ indexArray.emplaceBack(index, index + 1, index + 2);
+ indexArray.emplaceBack(index + 1, index + 2, index + 3);
+ segment.vertexLength += 4;
+ segment.primitiveLength += 2;
+ this.glyphOffsetArray.emplaceBack(glyphOffset2[0]);
+ if (i === quads.length - 1 || sectionIndex !== quads[i + 1].sectionIndex) {
+ arrays.programConfigurations.populatePaintArrays(layoutVertexArray.length, feature, feature.index, {}, canonical, sections && sections[sectionIndex]);
+ }
+ }
+ arrays.placedSymbolArray.emplaceBack(labelAnchor.x, labelAnchor.y, glyphOffsetArrayStart, this.glyphOffsetArray.length - glyphOffsetArrayStart, vertexStartIndex, lineStartIndex, lineLength, labelAnchor.segment, sizeVertex ? sizeVertex[0] : 0, sizeVertex ? sizeVertex[1] : 0, lineOffset[0], lineOffset[1], writingMode, 0, false, 0, associatedIconIndex);
+ };
+ SymbolBucket.prototype._addCollisionDebugVertex = function _addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, point, anchorX, anchorY, extrude) {
+ collisionVertexArray.emplaceBack(0, 0);
+ return layoutVertexArray.emplaceBack(point.x, point.y, anchorX, anchorY, Math.round(extrude.x), Math.round(extrude.y));
+ };
+ SymbolBucket.prototype.addCollisionDebugVertices = function addCollisionDebugVertices(x1, y1, x2, y2, arrays, boxAnchorPoint, symbolInstance2) {
+ var segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray);
+ var index = segment.vertexLength;
+ var layoutVertexArray = arrays.layoutVertexArray;
+ var collisionVertexArray = arrays.collisionVertexArray;
+ var anchorX = symbolInstance2.anchorX;
+ var anchorY = symbolInstance2.anchorY;
+ this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new pointGeometry(x1, y1));
+ this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new pointGeometry(x2, y1));
+ this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new pointGeometry(x2, y2));
+ this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new pointGeometry(x1, y2));
+ segment.vertexLength += 4;
+ var indexArray = arrays.indexArray;
+ indexArray.emplaceBack(index, index + 1);
+ indexArray.emplaceBack(index + 1, index + 2);
+ indexArray.emplaceBack(index + 2, index + 3);
+ indexArray.emplaceBack(index + 3, index);
+ segment.primitiveLength += 4;
+ };
+ SymbolBucket.prototype.addDebugCollisionBoxes = function addDebugCollisionBoxes(startIndex, endIndex, symbolInstance2, isText) {
+ for (var b = startIndex; b < endIndex; b++) {
+ var box = this.collisionBoxArray.get(b);
+ var x1 = box.x1;
+ var y1 = box.y1;
+ var x2 = box.x2;
+ var y2 = box.y2;
+ this.addCollisionDebugVertices(x1, y1, x2, y2, isText ? this.textCollisionBox : this.iconCollisionBox, box.anchorPoint, symbolInstance2);
+ }
+ };
+ SymbolBucket.prototype.generateCollisionDebugBuffers = function generateCollisionDebugBuffers() {
+ if (this.hasDebugData()) {
+ this.destroyDebugData();
+ }
+ this.textCollisionBox = new CollisionBuffers(StructArrayLayout2i2i2i12, collisionBoxLayout.members, StructArrayLayout2ui4);
+ this.iconCollisionBox = new CollisionBuffers(StructArrayLayout2i2i2i12, collisionBoxLayout.members, StructArrayLayout2ui4);
+ for (var i = 0; i < this.symbolInstances.length; i++) {
+ var symbolInstance2 = this.symbolInstances.get(i);
+ this.addDebugCollisionBoxes(symbolInstance2.textBoxStartIndex, symbolInstance2.textBoxEndIndex, symbolInstance2, true);
+ this.addDebugCollisionBoxes(symbolInstance2.verticalTextBoxStartIndex, symbolInstance2.verticalTextBoxEndIndex, symbolInstance2, true);
+ this.addDebugCollisionBoxes(symbolInstance2.iconBoxStartIndex, symbolInstance2.iconBoxEndIndex, symbolInstance2, false);
+ this.addDebugCollisionBoxes(symbolInstance2.verticalIconBoxStartIndex, symbolInstance2.verticalIconBoxEndIndex, symbolInstance2, false);
+ }
+ };
+ SymbolBucket.prototype._deserializeCollisionBoxesForSymbol = function _deserializeCollisionBoxesForSymbol(collisionBoxArray, textStartIndex, textEndIndex, verticalTextStartIndex, verticalTextEndIndex, iconStartIndex, iconEndIndex, verticalIconStartIndex, verticalIconEndIndex) {
+ var collisionArrays = {};
+ for (var k = textStartIndex; k < textEndIndex; k++) {
+ var box = collisionBoxArray.get(k);
+ collisionArrays.textBox = {
+ x1: box.x1,
+ y1: box.y1,
+ x2: box.x2,
+ y2: box.y2,
+ anchorPointX: box.anchorPointX,
+ anchorPointY: box.anchorPointY
+ };
+ collisionArrays.textFeatureIndex = box.featureIndex;
+ break;
+ }
+ for (var k$1 = verticalTextStartIndex; k$1 < verticalTextEndIndex; k$1++) {
+ var box$1 = collisionBoxArray.get(k$1);
+ collisionArrays.verticalTextBox = {
+ x1: box$1.x1,
+ y1: box$1.y1,
+ x2: box$1.x2,
+ y2: box$1.y2,
+ anchorPointX: box$1.anchorPointX,
+ anchorPointY: box$1.anchorPointY
+ };
+ collisionArrays.verticalTextFeatureIndex = box$1.featureIndex;
+ break;
+ }
+ for (var k$2 = iconStartIndex; k$2 < iconEndIndex; k$2++) {
+ var box$2 = collisionBoxArray.get(k$2);
+ collisionArrays.iconBox = {
+ x1: box$2.x1,
+ y1: box$2.y1,
+ x2: box$2.x2,
+ y2: box$2.y2,
+ anchorPointX: box$2.anchorPointX,
+ anchorPointY: box$2.anchorPointY
+ };
+ collisionArrays.iconFeatureIndex = box$2.featureIndex;
+ break;
+ }
+ for (var k$3 = verticalIconStartIndex; k$3 < verticalIconEndIndex; k$3++) {
+ var box$3 = collisionBoxArray.get(k$3);
+ collisionArrays.verticalIconBox = {
+ x1: box$3.x1,
+ y1: box$3.y1,
+ x2: box$3.x2,
+ y2: box$3.y2,
+ anchorPointX: box$3.anchorPointX,
+ anchorPointY: box$3.anchorPointY
+ };
+ collisionArrays.verticalIconFeatureIndex = box$3.featureIndex;
+ break;
+ }
+ return collisionArrays;
+ };
+ SymbolBucket.prototype.deserializeCollisionBoxes = function deserializeCollisionBoxes(collisionBoxArray) {
+ this.collisionArrays = [];
+ for (var i = 0; i < this.symbolInstances.length; i++) {
+ var symbolInstance2 = this.symbolInstances.get(i);
+ this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(collisionBoxArray, symbolInstance2.textBoxStartIndex, symbolInstance2.textBoxEndIndex, symbolInstance2.verticalTextBoxStartIndex, symbolInstance2.verticalTextBoxEndIndex, symbolInstance2.iconBoxStartIndex, symbolInstance2.iconBoxEndIndex, symbolInstance2.verticalIconBoxStartIndex, symbolInstance2.verticalIconBoxEndIndex));
+ }
+ };
+ SymbolBucket.prototype.hasTextData = function hasTextData() {
+ return this.text.segments.get().length > 0;
+ };
+ SymbolBucket.prototype.hasIconData = function hasIconData() {
+ return this.icon.segments.get().length > 0;
+ };
+ SymbolBucket.prototype.hasDebugData = function hasDebugData() {
+ return this.textCollisionBox && this.iconCollisionBox;
+ };
+ SymbolBucket.prototype.hasTextCollisionBoxData = function hasTextCollisionBoxData() {
+ return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;
+ };
+ SymbolBucket.prototype.hasIconCollisionBoxData = function hasIconCollisionBoxData() {
+ return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;
+ };
+ SymbolBucket.prototype.addIndicesForPlacedSymbol = function addIndicesForPlacedSymbol(iconOrText, placedSymbolIndex) {
+ var placedSymbol = iconOrText.placedSymbolArray.get(placedSymbolIndex);
+ var endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4;
+ for (var vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) {
+ iconOrText.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2);
+ iconOrText.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3);
+ }
+ };
+ SymbolBucket.prototype.getSortedSymbolIndexes = function getSortedSymbolIndexes(angle) {
+ if (this.sortedAngle === angle && this.symbolInstanceIndexes !== void 0) {
+ return this.symbolInstanceIndexes;
+ }
+ var sin = Math.sin(angle);
+ var cos = Math.cos(angle);
+ var rotatedYs = [];
+ var featureIndexes = [];
+ var result = [];
+ for (var i = 0; i < this.symbolInstances.length; ++i) {
+ result.push(i);
+ var symbolInstance2 = this.symbolInstances.get(i);
+ rotatedYs.push(Math.round(sin * symbolInstance2.anchorX + cos * symbolInstance2.anchorY) | 0);
+ featureIndexes.push(symbolInstance2.featureIndex);
+ }
+ result.sort(function(aIndex, bIndex) {
+ return rotatedYs[aIndex] - rotatedYs[bIndex] || featureIndexes[bIndex] - featureIndexes[aIndex];
+ });
+ return result;
+ };
+ SymbolBucket.prototype.addToSortKeyRanges = function addToSortKeyRanges(symbolInstanceIndex, sortKey) {
+ var last = this.sortKeyRanges[this.sortKeyRanges.length - 1];
+ if (last && last.sortKey === sortKey) {
+ last.symbolInstanceEnd = symbolInstanceIndex + 1;
+ } else {
+ this.sortKeyRanges.push({
+ sortKey,
+ symbolInstanceStart: symbolInstanceIndex,
+ symbolInstanceEnd: symbolInstanceIndex + 1
+ });
+ }
+ };
+ SymbolBucket.prototype.sortFeatures = function sortFeatures(angle) {
+ var this$1 = this;
+ if (!this.sortFeaturesByY) {
+ return;
+ }
+ if (this.sortedAngle === angle) {
+ return;
+ }
+ if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) {
+ return;
+ }
+ this.symbolInstanceIndexes = this.getSortedSymbolIndexes(angle);
+ this.sortedAngle = angle;
+ this.text.indexArray.clear();
+ this.icon.indexArray.clear();
+ this.featureSortOrder = [];
+ for (var i$1 = 0, list = this.symbolInstanceIndexes; i$1 < list.length; i$1 += 1) {
+ var i = list[i$1];
+ var symbolInstance2 = this.symbolInstances.get(i);
+ this.featureSortOrder.push(symbolInstance2.featureIndex);
+ [
+ symbolInstance2.rightJustifiedTextSymbolIndex,
+ symbolInstance2.centerJustifiedTextSymbolIndex,
+ symbolInstance2.leftJustifiedTextSymbolIndex
+ ].forEach(function(index, i2, array2) {
+ if (index >= 0 && array2.indexOf(index) === i2) {
+ this$1.addIndicesForPlacedSymbol(this$1.text, index);
+ }
+ });
+ if (symbolInstance2.verticalPlacedTextSymbolIndex >= 0) {
+ this.addIndicesForPlacedSymbol(this.text, symbolInstance2.verticalPlacedTextSymbolIndex);
+ }
+ if (symbolInstance2.placedIconSymbolIndex >= 0) {
+ this.addIndicesForPlacedSymbol(this.icon, symbolInstance2.placedIconSymbolIndex);
+ }
+ if (symbolInstance2.verticalPlacedIconSymbolIndex >= 0) {
+ this.addIndicesForPlacedSymbol(this.icon, symbolInstance2.verticalPlacedIconSymbolIndex);
+ }
+ }
+ if (this.text.indexBuffer) {
+ this.text.indexBuffer.updateData(this.text.indexArray);
+ }
+ if (this.icon.indexBuffer) {
+ this.icon.indexBuffer.updateData(this.icon.indexArray);
+ }
+ };
+ register("SymbolBucket", SymbolBucket, {
+ omit: [
+ "layers",
+ "collisionBoxArray",
+ "features",
+ "compareText"
+ ]
+ });
+ SymbolBucket.MAX_GLYPHS = 65535;
+ SymbolBucket.addDynamicAttributes = addDynamicAttributes;
+ function resolveTokens(properties2, text) {
+ return text.replace(/{([^{}]+)}/g, function(match, key) {
+ return key in properties2 ? String(properties2[key]) : "";
+ });
+ }
+ var layout$7 = new Properties({
+ "symbol-placement": new DataConstantProperty(spec["layout_symbol"]["symbol-placement"]),
+ "symbol-spacing": new DataConstantProperty(spec["layout_symbol"]["symbol-spacing"]),
+ "symbol-avoid-edges": new DataConstantProperty(spec["layout_symbol"]["symbol-avoid-edges"]),
+ "symbol-sort-key": new DataDrivenProperty(spec["layout_symbol"]["symbol-sort-key"]),
+ "symbol-z-order": new DataConstantProperty(spec["layout_symbol"]["symbol-z-order"]),
+ "icon-allow-overlap": new DataConstantProperty(spec["layout_symbol"]["icon-allow-overlap"]),
+ "icon-ignore-placement": new DataConstantProperty(spec["layout_symbol"]["icon-ignore-placement"]),
+ "icon-optional": new DataConstantProperty(spec["layout_symbol"]["icon-optional"]),
+ "icon-rotation-alignment": new DataConstantProperty(spec["layout_symbol"]["icon-rotation-alignment"]),
+ "icon-size": new DataDrivenProperty(spec["layout_symbol"]["icon-size"]),
+ "icon-text-fit": new DataConstantProperty(spec["layout_symbol"]["icon-text-fit"]),
+ "icon-text-fit-padding": new DataConstantProperty(spec["layout_symbol"]["icon-text-fit-padding"]),
+ "icon-image": new DataDrivenProperty(spec["layout_symbol"]["icon-image"]),
+ "icon-rotate": new DataDrivenProperty(spec["layout_symbol"]["icon-rotate"]),
+ "icon-padding": new DataConstantProperty(spec["layout_symbol"]["icon-padding"]),
+ "icon-keep-upright": new DataConstantProperty(spec["layout_symbol"]["icon-keep-upright"]),
+ "icon-offset": new DataDrivenProperty(spec["layout_symbol"]["icon-offset"]),
+ "icon-anchor": new DataDrivenProperty(spec["layout_symbol"]["icon-anchor"]),
+ "icon-pitch-alignment": new DataConstantProperty(spec["layout_symbol"]["icon-pitch-alignment"]),
+ "text-pitch-alignment": new DataConstantProperty(spec["layout_symbol"]["text-pitch-alignment"]),
+ "text-rotation-alignment": new DataConstantProperty(spec["layout_symbol"]["text-rotation-alignment"]),
+ "text-field": new DataDrivenProperty(spec["layout_symbol"]["text-field"]),
+ "text-font": new DataDrivenProperty(spec["layout_symbol"]["text-font"]),
+ "text-size": new DataDrivenProperty(spec["layout_symbol"]["text-size"]),
+ "text-max-width": new DataDrivenProperty(spec["layout_symbol"]["text-max-width"]),
+ "text-line-height": new DataConstantProperty(spec["layout_symbol"]["text-line-height"]),
+ "text-letter-spacing": new DataDrivenProperty(spec["layout_symbol"]["text-letter-spacing"]),
+ "text-justify": new DataDrivenProperty(spec["layout_symbol"]["text-justify"]),
+ "text-radial-offset": new DataDrivenProperty(spec["layout_symbol"]["text-radial-offset"]),
+ "text-variable-anchor": new DataConstantProperty(spec["layout_symbol"]["text-variable-anchor"]),
+ "text-anchor": new DataDrivenProperty(spec["layout_symbol"]["text-anchor"]),
+ "text-max-angle": new DataConstantProperty(spec["layout_symbol"]["text-max-angle"]),
+ "text-writing-mode": new DataConstantProperty(spec["layout_symbol"]["text-writing-mode"]),
+ "text-rotate": new DataDrivenProperty(spec["layout_symbol"]["text-rotate"]),
+ "text-padding": new DataConstantProperty(spec["layout_symbol"]["text-padding"]),
+ "text-keep-upright": new DataConstantProperty(spec["layout_symbol"]["text-keep-upright"]),
+ "text-transform": new DataDrivenProperty(spec["layout_symbol"]["text-transform"]),
+ "text-offset": new DataDrivenProperty(spec["layout_symbol"]["text-offset"]),
+ "text-allow-overlap": new DataConstantProperty(spec["layout_symbol"]["text-allow-overlap"]),
+ "text-ignore-placement": new DataConstantProperty(spec["layout_symbol"]["text-ignore-placement"]),
+ "text-optional": new DataConstantProperty(spec["layout_symbol"]["text-optional"])
+ });
+ var paint$7 = new Properties({
+ "icon-opacity": new DataDrivenProperty(spec["paint_symbol"]["icon-opacity"]),
+ "icon-color": new DataDrivenProperty(spec["paint_symbol"]["icon-color"]),
+ "icon-halo-color": new DataDrivenProperty(spec["paint_symbol"]["icon-halo-color"]),
+ "icon-halo-width": new DataDrivenProperty(spec["paint_symbol"]["icon-halo-width"]),
+ "icon-halo-blur": new DataDrivenProperty(spec["paint_symbol"]["icon-halo-blur"]),
+ "icon-translate": new DataConstantProperty(spec["paint_symbol"]["icon-translate"]),
+ "icon-translate-anchor": new DataConstantProperty(spec["paint_symbol"]["icon-translate-anchor"]),
+ "text-opacity": new DataDrivenProperty(spec["paint_symbol"]["text-opacity"]),
+ "text-color": new DataDrivenProperty(spec["paint_symbol"]["text-color"], {
+ runtimeType: ColorType,
+ getOverride: function(o) {
+ return o.textColor;
+ },
+ hasOverride: function(o) {
+ return !!o.textColor;
+ }
+ }),
+ "text-halo-color": new DataDrivenProperty(spec["paint_symbol"]["text-halo-color"]),
+ "text-halo-width": new DataDrivenProperty(spec["paint_symbol"]["text-halo-width"]),
+ "text-halo-blur": new DataDrivenProperty(spec["paint_symbol"]["text-halo-blur"]),
+ "text-translate": new DataConstantProperty(spec["paint_symbol"]["text-translate"]),
+ "text-translate-anchor": new DataConstantProperty(spec["paint_symbol"]["text-translate-anchor"])
+ });
+ var properties$6 = {
+ paint: paint$7,
+ layout: layout$7
+ };
+ var FormatSectionOverride = function FormatSectionOverride2(defaultValue) {
+ this.type = defaultValue.property.overrides ? defaultValue.property.overrides.runtimeType : NullType;
+ this.defaultValue = defaultValue;
+ };
+ FormatSectionOverride.prototype.evaluate = function evaluate(ctx) {
+ if (ctx.formattedSection) {
+ var overrides = this.defaultValue.property.overrides;
+ if (overrides && overrides.hasOverride(ctx.formattedSection)) {
+ return overrides.getOverride(ctx.formattedSection);
+ }
+ }
+ if (ctx.feature && ctx.featureState) {
+ return this.defaultValue.evaluate(ctx.feature, ctx.featureState);
+ }
+ return this.defaultValue.property.specification.default;
+ };
+ FormatSectionOverride.prototype.eachChild = function eachChild(fn) {
+ if (!this.defaultValue.isConstant()) {
+ var expr = this.defaultValue.value;
+ fn(expr._styleExpression.expression);
+ }
+ };
+ FormatSectionOverride.prototype.outputDefined = function outputDefined() {
+ return false;
+ };
+ FormatSectionOverride.prototype.serialize = function serialize2() {
+ return null;
+ };
+ register("FormatSectionOverride", FormatSectionOverride, { omit: ["defaultValue"] });
+ var SymbolStyleLayer = function(StyleLayer2) {
+ function SymbolStyleLayer2(layer2) {
+ StyleLayer2.call(this, layer2, properties$6);
+ }
+ if (StyleLayer2)
+ SymbolStyleLayer2.__proto__ = StyleLayer2;
+ SymbolStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ SymbolStyleLayer2.prototype.constructor = SymbolStyleLayer2;
+ SymbolStyleLayer2.prototype.recalculate = function recalculate(parameters, availableImages) {
+ StyleLayer2.prototype.recalculate.call(this, parameters, availableImages);
+ if (this.layout.get("icon-rotation-alignment") === "auto") {
+ if (this.layout.get("symbol-placement") !== "point") {
+ this.layout._values["icon-rotation-alignment"] = "map";
+ } else {
+ this.layout._values["icon-rotation-alignment"] = "viewport";
+ }
+ }
+ if (this.layout.get("text-rotation-alignment") === "auto") {
+ if (this.layout.get("symbol-placement") !== "point") {
+ this.layout._values["text-rotation-alignment"] = "map";
+ } else {
+ this.layout._values["text-rotation-alignment"] = "viewport";
+ }
+ }
+ if (this.layout.get("text-pitch-alignment") === "auto") {
+ this.layout._values["text-pitch-alignment"] = this.layout.get("text-rotation-alignment");
+ }
+ if (this.layout.get("icon-pitch-alignment") === "auto") {
+ this.layout._values["icon-pitch-alignment"] = this.layout.get("icon-rotation-alignment");
+ }
+ if (this.layout.get("symbol-placement") === "point") {
+ var writingModes = this.layout.get("text-writing-mode");
+ if (writingModes) {
+ var deduped = [];
+ for (var i = 0, list = writingModes; i < list.length; i += 1) {
+ var m = list[i];
+ if (deduped.indexOf(m) < 0) {
+ deduped.push(m);
+ }
+ }
+ this.layout._values["text-writing-mode"] = deduped;
+ } else {
+ this.layout._values["text-writing-mode"] = ["horizontal"];
+ }
+ }
+ this._setPaintOverrides();
+ };
+ SymbolStyleLayer2.prototype.getValueAndResolveTokens = function getValueAndResolveTokens(name3, feature, canonical, availableImages) {
+ var value = this.layout.get(name3).evaluate(feature, {}, canonical, availableImages);
+ var unevaluated = this._unevaluatedLayout._values[name3];
+ if (!unevaluated.isDataDriven() && !isExpression(unevaluated.value) && value) {
+ return resolveTokens(feature.properties, value);
+ }
+ return value;
+ };
+ SymbolStyleLayer2.prototype.createBucket = function createBucket(parameters) {
+ return new SymbolBucket(parameters);
+ };
+ SymbolStyleLayer2.prototype.queryRadius = function queryRadius() {
+ return 0;
+ };
+ SymbolStyleLayer2.prototype.queryIntersectsFeature = function queryIntersectsFeature() {
+ return false;
+ };
+ SymbolStyleLayer2.prototype._setPaintOverrides = function _setPaintOverrides() {
+ for (var i = 0, list = properties$6.paint.overridableProperties; i < list.length; i += 1) {
+ var overridable = list[i];
+ if (!SymbolStyleLayer2.hasPaintOverride(this.layout, overridable)) {
+ continue;
+ }
+ var overriden = this.paint.get(overridable);
+ var override = new FormatSectionOverride(overriden);
+ var styleExpression = new StyleExpression(override, overriden.property.specification);
+ var expression2 = null;
+ if (overriden.value.kind === "constant" || overriden.value.kind === "source") {
+ expression2 = new ZoomConstantExpression("source", styleExpression);
+ } else {
+ expression2 = new ZoomDependentExpression("composite", styleExpression, overriden.value.zoomStops, overriden.value._interpolationType);
+ }
+ this.paint._values[overridable] = new PossiblyEvaluatedPropertyValue(overriden.property, expression2, overriden.parameters);
+ }
+ };
+ SymbolStyleLayer2.prototype._handleOverridablePaintPropertyUpdate = function _handleOverridablePaintPropertyUpdate(name3, oldValue, newValue) {
+ if (!this.layout || oldValue.isDataDriven() || newValue.isDataDriven()) {
+ return false;
+ }
+ return SymbolStyleLayer2.hasPaintOverride(this.layout, name3);
+ };
+ SymbolStyleLayer2.hasPaintOverride = function hasPaintOverride(layout2, propertyName) {
+ var textField = layout2.get("text-field");
+ var property = properties$6.paint.properties[propertyName];
+ var hasOverrides = false;
+ var checkSections = function(sections) {
+ for (var i = 0, list = sections; i < list.length; i += 1) {
+ var section = list[i];
+ if (property.overrides && property.overrides.hasOverride(section)) {
+ hasOverrides = true;
+ return;
+ }
+ }
+ };
+ if (textField.value.kind === "constant" && textField.value.value instanceof Formatted) {
+ checkSections(textField.value.value.sections);
+ } else if (textField.value.kind === "source") {
+ var checkExpression = function(expression2) {
+ if (hasOverrides) {
+ return;
+ }
+ if (expression2 instanceof Literal && typeOf(expression2.value) === FormattedType) {
+ var formatted = expression2.value;
+ checkSections(formatted.sections);
+ } else if (expression2 instanceof FormatExpression) {
+ checkSections(expression2.sections);
+ } else {
+ expression2.eachChild(checkExpression);
+ }
+ };
+ var expr = textField.value;
+ if (expr._styleExpression) {
+ checkExpression(expr._styleExpression.expression);
+ }
+ }
+ return hasOverrides;
+ };
+ return SymbolStyleLayer2;
+ }(StyleLayer);
+ var paint$8 = new Properties({
+ "background-color": new DataConstantProperty(spec["paint_background"]["background-color"]),
+ "background-pattern": new CrossFadedProperty(spec["paint_background"]["background-pattern"]),
+ "background-opacity": new DataConstantProperty(spec["paint_background"]["background-opacity"])
+ });
+ var properties$7 = { paint: paint$8 };
+ var BackgroundStyleLayer = function(StyleLayer2) {
+ function BackgroundStyleLayer2(layer2) {
+ StyleLayer2.call(this, layer2, properties$7);
+ }
+ if (StyleLayer2)
+ BackgroundStyleLayer2.__proto__ = StyleLayer2;
+ BackgroundStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ BackgroundStyleLayer2.prototype.constructor = BackgroundStyleLayer2;
+ return BackgroundStyleLayer2;
+ }(StyleLayer);
+ var paint$9 = new Properties({
+ "raster-opacity": new DataConstantProperty(spec["paint_raster"]["raster-opacity"]),
+ "raster-hue-rotate": new DataConstantProperty(spec["paint_raster"]["raster-hue-rotate"]),
+ "raster-brightness-min": new DataConstantProperty(spec["paint_raster"]["raster-brightness-min"]),
+ "raster-brightness-max": new DataConstantProperty(spec["paint_raster"]["raster-brightness-max"]),
+ "raster-saturation": new DataConstantProperty(spec["paint_raster"]["raster-saturation"]),
+ "raster-contrast": new DataConstantProperty(spec["paint_raster"]["raster-contrast"]),
+ "raster-resampling": new DataConstantProperty(spec["paint_raster"]["raster-resampling"]),
+ "raster-fade-duration": new DataConstantProperty(spec["paint_raster"]["raster-fade-duration"])
+ });
+ var properties$8 = { paint: paint$9 };
+ var RasterStyleLayer = function(StyleLayer2) {
+ function RasterStyleLayer2(layer2) {
+ StyleLayer2.call(this, layer2, properties$8);
+ }
+ if (StyleLayer2)
+ RasterStyleLayer2.__proto__ = StyleLayer2;
+ RasterStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ RasterStyleLayer2.prototype.constructor = RasterStyleLayer2;
+ return RasterStyleLayer2;
+ }(StyleLayer);
+ function validateCustomStyleLayer(layerObject) {
+ var errors = [];
+ var id2 = layerObject.id;
+ if (id2 === void 0) {
+ errors.push({ message: "layers." + id2 + ': missing required property "id"' });
+ }
+ if (layerObject.render === void 0) {
+ errors.push({ message: "layers." + id2 + ': missing required method "render"' });
+ }
+ if (layerObject.renderingMode && layerObject.renderingMode !== "2d" && layerObject.renderingMode !== "3d") {
+ errors.push({ message: "layers." + id2 + ': property "renderingMode" must be either "2d" or "3d"' });
+ }
+ return errors;
+ }
+ var CustomStyleLayer = function(StyleLayer2) {
+ function CustomStyleLayer2(implementation) {
+ StyleLayer2.call(this, implementation, {});
+ this.implementation = implementation;
+ }
+ if (StyleLayer2)
+ CustomStyleLayer2.__proto__ = StyleLayer2;
+ CustomStyleLayer2.prototype = Object.create(StyleLayer2 && StyleLayer2.prototype);
+ CustomStyleLayer2.prototype.constructor = CustomStyleLayer2;
+ CustomStyleLayer2.prototype.is3D = function is3D() {
+ return this.implementation.renderingMode === "3d";
+ };
+ CustomStyleLayer2.prototype.hasOffscreenPass = function hasOffscreenPass() {
+ return this.implementation.prerender !== void 0;
+ };
+ CustomStyleLayer2.prototype.recalculate = function recalculate() {
+ };
+ CustomStyleLayer2.prototype.updateTransitions = function updateTransitions() {
+ };
+ CustomStyleLayer2.prototype.hasTransition = function hasTransition() {
+ };
+ CustomStyleLayer2.prototype.serialize = function serialize2() {
+ };
+ CustomStyleLayer2.prototype.onAdd = function onAdd(map) {
+ if (this.implementation.onAdd) {
+ this.implementation.onAdd(map, map.painter.context.gl);
+ }
+ };
+ CustomStyleLayer2.prototype.onRemove = function onRemove(map) {
+ if (this.implementation.onRemove) {
+ this.implementation.onRemove(map, map.painter.context.gl);
+ }
+ };
+ return CustomStyleLayer2;
+ }(StyleLayer);
+ var subclasses = {
+ circle: CircleStyleLayer,
+ heatmap: HeatmapStyleLayer,
+ hillshade: HillshadeStyleLayer,
+ fill: FillStyleLayer,
+ "fill-extrusion": FillExtrusionStyleLayer,
+ line: LineStyleLayer,
+ symbol: SymbolStyleLayer,
+ background: BackgroundStyleLayer,
+ raster: RasterStyleLayer
+ };
+ function createStyleLayer(layer2) {
+ if (layer2.type === "custom") {
+ return new CustomStyleLayer(layer2);
+ } else {
+ return new subclasses[layer2.type](layer2);
+ }
+ }
+ var HTMLImageElement2 = window$1.HTMLImageElement;
+ var HTMLCanvasElement2 = window$1.HTMLCanvasElement;
+ var HTMLVideoElement2 = window$1.HTMLVideoElement;
+ var ImageData$1 = window$1.ImageData;
+ var ImageBitmap$1 = window$1.ImageBitmap;
+ var Texture = function Texture2(context, image, format, options) {
+ this.context = context;
+ this.format = format;
+ this.texture = context.gl.createTexture();
+ this.update(image, options);
+ };
+ Texture.prototype.update = function update(image, options, position) {
+ var width = image.width;
+ var height = image.height;
+ var resize = (!this.size || this.size[0] !== width || this.size[1] !== height) && !position;
+ var ref = this;
+ var context = ref.context;
+ var gl2 = context.gl;
+ this.useMipmap = Boolean(options && options.useMipmap);
+ gl2.bindTexture(gl2.TEXTURE_2D, this.texture);
+ context.pixelStoreUnpackFlipY.set(false);
+ context.pixelStoreUnpack.set(1);
+ context.pixelStoreUnpackPremultiplyAlpha.set(this.format === gl2.RGBA && (!options || options.premultiply !== false));
+ if (resize) {
+ this.size = [
+ width,
+ height
+ ];
+ if (image instanceof HTMLImageElement2 || image instanceof HTMLCanvasElement2 || image instanceof HTMLVideoElement2 || image instanceof ImageData$1 || ImageBitmap$1 && image instanceof ImageBitmap$1) {
+ gl2.texImage2D(gl2.TEXTURE_2D, 0, this.format, this.format, gl2.UNSIGNED_BYTE, image);
+ } else {
+ gl2.texImage2D(gl2.TEXTURE_2D, 0, this.format, width, height, 0, this.format, gl2.UNSIGNED_BYTE, image.data);
+ }
+ } else {
+ var ref$1 = position || {
+ x: 0,
+ y: 0
+ };
+ var x = ref$1.x;
+ var y = ref$1.y;
+ if (image instanceof HTMLImageElement2 || image instanceof HTMLCanvasElement2 || image instanceof HTMLVideoElement2 || image instanceof ImageData$1 || ImageBitmap$1 && image instanceof ImageBitmap$1) {
+ gl2.texSubImage2D(gl2.TEXTURE_2D, 0, x, y, gl2.RGBA, gl2.UNSIGNED_BYTE, image);
+ } else {
+ gl2.texSubImage2D(gl2.TEXTURE_2D, 0, x, y, width, height, gl2.RGBA, gl2.UNSIGNED_BYTE, image.data);
+ }
+ }
+ if (this.useMipmap && this.isSizePowerOfTwo()) {
+ gl2.generateMipmap(gl2.TEXTURE_2D);
+ }
+ };
+ Texture.prototype.bind = function bind(filter2, wrap2, minFilter) {
+ var ref = this;
+ var context = ref.context;
+ var gl2 = context.gl;
+ gl2.bindTexture(gl2.TEXTURE_2D, this.texture);
+ if (minFilter === gl2.LINEAR_MIPMAP_NEAREST && !this.isSizePowerOfTwo()) {
+ minFilter = gl2.LINEAR;
+ }
+ if (filter2 !== this.filter) {
+ gl2.texParameteri(gl2.TEXTURE_2D, gl2.TEXTURE_MAG_FILTER, filter2);
+ gl2.texParameteri(gl2.TEXTURE_2D, gl2.TEXTURE_MIN_FILTER, minFilter || filter2);
+ this.filter = filter2;
+ }
+ if (wrap2 !== this.wrap) {
+ gl2.texParameteri(gl2.TEXTURE_2D, gl2.TEXTURE_WRAP_S, wrap2);
+ gl2.texParameteri(gl2.TEXTURE_2D, gl2.TEXTURE_WRAP_T, wrap2);
+ this.wrap = wrap2;
+ }
+ };
+ Texture.prototype.isSizePowerOfTwo = function isSizePowerOfTwo() {
+ return this.size[0] === this.size[1] && Math.log(this.size[0]) / Math.LN2 % 1 === 0;
+ };
+ Texture.prototype.destroy = function destroy() {
+ var ref = this.context;
+ var gl2 = ref.gl;
+ gl2.deleteTexture(this.texture);
+ this.texture = null;
+ };
+ var ThrottledInvoker = function ThrottledInvoker2(callback) {
+ var this$1 = this;
+ this._callback = callback;
+ this._triggered = false;
+ if (typeof MessageChannel !== "undefined") {
+ this._channel = new MessageChannel();
+ this._channel.port2.onmessage = function() {
+ this$1._triggered = false;
+ this$1._callback();
+ };
+ }
+ };
+ ThrottledInvoker.prototype.trigger = function trigger() {
+ var this$1 = this;
+ if (!this._triggered) {
+ this._triggered = true;
+ if (this._channel) {
+ this._channel.port1.postMessage(true);
+ } else {
+ setTimeout(function() {
+ this$1._triggered = false;
+ this$1._callback();
+ }, 0);
+ }
+ }
+ };
+ ThrottledInvoker.prototype.remove = function remove() {
+ delete this._channel;
+ this._callback = function() {
+ };
+ };
+ var Actor = function Actor2(target, parent, mapId) {
+ this.target = target;
+ this.parent = parent;
+ this.mapId = mapId;
+ this.callbacks = {};
+ this.tasks = {};
+ this.taskQueue = [];
+ this.cancelCallbacks = {};
+ bindAll([
+ "receive",
+ "process"
+ ], this);
+ this.invoker = new ThrottledInvoker(this.process);
+ this.target.addEventListener("message", this.receive, false);
+ this.globalScope = isWorker() ? target : window$1;
+ };
+ Actor.prototype.send = function send(type, data, callback, targetMapId, mustQueue) {
+ var this$1 = this;
+ if (mustQueue === void 0)
+ mustQueue = false;
+ var id2 = Math.round(Math.random() * 1e18).toString(36).substring(0, 10);
+ if (callback) {
+ this.callbacks[id2] = callback;
+ }
+ var buffers = isSafari(this.globalScope) ? void 0 : [];
+ this.target.postMessage({
+ id: id2,
+ type,
+ hasCallback: !!callback,
+ targetMapId,
+ mustQueue,
+ sourceMapId: this.mapId,
+ data: serialize(data, buffers)
+ }, buffers);
+ return {
+ cancel: function() {
+ if (callback) {
+ delete this$1.callbacks[id2];
+ }
+ this$1.target.postMessage({
+ id: id2,
+ type: "
");
+ attributionText.text(multilineAttributions).attr("data-unformatted", multilineAttributions).call(svgTextUtils.convertToTspans, gd);
+ bBox = Drawing.bBox(attributionText.node());
+ }
+ attributionText.attr("transform", strTranslate(-3, -bBox.height + 8));
+ attributionGroup.insert("rect", ".static-attribution").attr({
+ x: -bBox.width - 6,
+ y: -bBox.height - 3,
+ width: bBox.width + 6,
+ height: bBox.height + 3,
+ fill: "rgba(255, 255, 255, 0.75)"
+ });
+ var scaleRatio = 1;
+ if (bBox.width + 6 > maxWidth) scaleRatio = maxWidth / (bBox.width + 6);
+ var offset = [size.l + size.w * domain.x[1], size.t + size.h * (1 - domain.y[0])];
+ attributionGroup.attr("transform", strTranslate(offset[0], offset[1]) + strScale(scaleRatio));
+ }
+ };
+ function findAccessToken(gd, mapboxIds) {
+ var fullLayout = gd._fullLayout;
+ var context = gd._context;
+ if (context.mapboxAccessToken === "") return "";
+ var tokensUseful = [];
+ var tokensListed = [];
+ var hasOneSetMapboxStyle = false;
+ var wontWork = false;
+ for (var i = 0; i < mapboxIds.length; i++) {
+ var opts = fullLayout[mapboxIds[i]];
+ var token = opts.accesstoken;
+ if (isStyleRequireAccessToken(opts.style)) {
+ if (token) {
+ Lib.pushUnique(tokensUseful, token);
+ } else {
+ if (isStyleRequireAccessToken(opts._input.style)) {
+ Lib.error("Uses Mapbox map style, but did not set an access token.");
+ hasOneSetMapboxStyle = true;
+ }
+ wontWork = true;
+ }
+ }
+ if (token) {
+ Lib.pushUnique(tokensListed, token);
+ }
+ }
+ if (wontWork) {
+ var msg = hasOneSetMapboxStyle ? constants.noAccessTokenErrorMsg : constants.missingStyleErrorMsg;
+ Lib.error(msg);
+ throw new Error(msg);
+ }
+ if (tokensUseful.length) {
+ if (tokensUseful.length > 1) {
+ Lib.warn(constants.multipleTokensErrorMsg);
+ }
+ return tokensUseful[0];
+ } else {
+ if (tokensListed.length) {
+ Lib.log([
+ "Listed mapbox access token(s)",
+ tokensListed.join(","),
+ "but did not use a Mapbox map style, ignoring token(s)."
+ ].join(" "));
+ }
+ return "";
+ }
+ }
+ function isStyleRequireAccessToken(s) {
+ return typeof s === "string" && (constants.styleValuesMapbox.indexOf(s) !== -1 || s.indexOf("mapbox://") === 0 || s.indexOf("stamen") === 0);
+ }
+ exports.updateFx = function(gd) {
+ var fullLayout = gd._fullLayout;
+ var subplotIds = fullLayout._subplots[MAPBOX];
+ for (var i = 0; i < subplotIds.length; i++) {
+ var subplotObj = fullLayout[subplotIds[i]]._subplot;
+ subplotObj.updateFx(fullLayout);
+ }
+ };
+ }
+ });
+
+ // src/traces/scattermapbox/index.js
+ var require_scattermapbox = __commonJS({
+ "src/traces/scattermapbox/index.js"(exports, module) {
+ "use strict";
+ var deprecationWarning = [
+ "*scattermapbox* trace is deprecated!",
+ "Please consider switching to the *scattermap* trace type and `map` subplots.",
+ "Learn more at: https://plotly.com/python/maplibre-migration/",
+ "as well as https://plotly.com/javascript/maplibre-migration/"
+ ].join(" ");
+ module.exports = {
+ attributes: require_attributes54(),
+ supplyDefaults: require_defaults50(),
+ colorbar: require_marker_colorbar(),
+ formatLabels: require_format_labels5(),
+ calc: require_calc27(),
+ plot: require_plot23(),
+ hoverPoints: require_hover18().hoverPoints,
+ eventData: require_event_data11(),
+ selectPoints: require_select9(),
+ styleOnSelect: function(_, cd) {
+ if (cd) {
+ var trace = cd[0].trace;
+ trace._glTrace.update(cd);
+ }
+ },
+ moduleType: "trace",
+ name: "scattermapbox",
+ basePlotModule: require_mapbox2(),
+ categories: ["mapbox", "gl", "symbols", "showLegend", "scatter-like"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/scattermapbox.js
+ var require_scattermapbox2 = __commonJS({
+ "lib/scattermapbox.js"(exports, module) {
+ "use strict";
+ module.exports = require_scattermapbox();
+ }
+ });
+
+ // src/traces/choroplethmapbox/attributes.js
+ var require_attributes55 = __commonJS({
+ "src/traces/choroplethmapbox/attributes.js"(exports, module) {
+ "use strict";
+ var choroplethAttrs = require_attributes49();
+ var colorScaleAttrs = require_attributes8();
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var baseAttrs = require_attributes2();
+ var extendFlat = require_extend().extendFlat;
+ module.exports = extendFlat(
+ {
+ locations: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ // TODO
+ // Maybe start with only one value (that we could name e.g. 'geojson-id'),
+ // but eventually:
+ // - we could also support for our own dist/topojson/*
+ // .. and locationmode: choroplethAttrs.locationmode,
+ z: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ // TODO maybe we could also set a "key" to dig out values out of the
+ // GeoJSON feature `properties` fields?
+ geojson: {
+ valType: "any",
+ editType: "calc"
+ },
+ featureidkey: extendFlat({}, choroplethAttrs.featureidkey, {}),
+ // TODO agree on name / behaviour
+ //
+ // 'below' is used currently for layout.mapbox.layers,
+ // even though it's not very plotly-esque.
+ //
+ // Note also, that the mapbox-gl style don't all have the same layers,
+ // see https://codepen.io/etpinard/pen/ydVMwM for full list
+ below: {
+ valType: "string",
+ editType: "plot"
+ },
+ text: choroplethAttrs.text,
+ hovertext: choroplethAttrs.hovertext,
+ marker: {
+ line: {
+ color: extendFlat({}, choroplethAttrs.marker.line.color, { editType: "plot" }),
+ width: extendFlat({}, choroplethAttrs.marker.line.width, { editType: "plot" }),
+ editType: "calc"
+ },
+ // TODO maybe having a dflt less than 1, together with `below:''` would be better?
+ opacity: extendFlat({}, choroplethAttrs.marker.opacity, { editType: "plot" }),
+ editType: "calc"
+ },
+ selected: {
+ marker: {
+ opacity: extendFlat({}, choroplethAttrs.selected.marker.opacity, { editType: "plot" }),
+ editType: "plot"
+ },
+ editType: "plot"
+ },
+ unselected: {
+ marker: {
+ opacity: extendFlat({}, choroplethAttrs.unselected.marker.opacity, { editType: "plot" }),
+ editType: "plot"
+ },
+ editType: "plot"
+ },
+ hoverinfo: choroplethAttrs.hoverinfo,
+ hovertemplate: hovertemplateAttrs({}, { keys: ["properties"] }),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ },
+ colorScaleAttrs("", {
+ cLetter: "z",
+ editTypeOverride: "calc"
+ })
+ );
+ }
+ });
+
+ // src/traces/choroplethmapbox/defaults.js
+ var require_defaults51 = __commonJS({
+ "src/traces/choroplethmapbox/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var colorscaleDefaults = require_defaults2();
+ var attributes = require_attributes55();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var locations = coerce("locations");
+ var z = coerce("z");
+ var geojson = coerce("geojson");
+ if (!Lib.isArrayOrTypedArray(locations) || !locations.length || !Lib.isArrayOrTypedArray(z) || !z.length || !(typeof geojson === "string" && geojson !== "" || Lib.isPlainObject(geojson))) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("featureidkey");
+ traceOut._length = Math.min(locations.length, z.length);
+ coerce("below");
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ var mlw = coerce("marker.line.width");
+ if (mlw) coerce("marker.line.color");
+ coerce("marker.opacity");
+ colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: "", cLetter: "z" });
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ }
+ });
+
+ // src/traces/choroplethmapbox/convert.js
+ var require_convert12 = __commonJS({
+ "src/traces/choroplethmapbox/convert.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var Lib = require_lib();
+ var Colorscale = require_colorscale();
+ var Drawing = require_drawing();
+ var makeBlank = require_geojson_utils().makeBlank;
+ var geoUtils = require_geo_location_utils();
+ function convert(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var isVisible = trace.visible === true && trace._length !== 0;
+ var fill = {
+ layout: { visibility: "none" },
+ paint: {}
+ };
+ var line = {
+ layout: { visibility: "none" },
+ paint: {}
+ };
+ var opts = trace._opts = {
+ fill,
+ line,
+ geojson: makeBlank()
+ };
+ if (!isVisible) return opts;
+ var features = geoUtils.extractTraceFeature(calcTrace);
+ if (!features) return opts;
+ var sclFunc = Colorscale.makeColorScaleFuncFromTrace(trace);
+ var marker = trace.marker;
+ var markerLine = marker.line || {};
+ var opacityFn;
+ if (Lib.isArrayOrTypedArray(marker.opacity)) {
+ opacityFn = function(d) {
+ var mo = d.mo;
+ return isNumeric(mo) ? +Lib.constrain(mo, 0, 1) : 0;
+ };
+ }
+ var lineColorFn;
+ if (Lib.isArrayOrTypedArray(markerLine.color)) {
+ lineColorFn = function(d) {
+ return d.mlc;
+ };
+ }
+ var lineWidthFn;
+ if (Lib.isArrayOrTypedArray(markerLine.width)) {
+ lineWidthFn = function(d) {
+ return d.mlw;
+ };
+ }
+ for (var i = 0; i < calcTrace.length; i++) {
+ var cdi = calcTrace[i];
+ var fOut = cdi.fOut;
+ if (fOut) {
+ var props = fOut.properties;
+ props.fc = sclFunc(cdi.z);
+ if (opacityFn) props.mo = opacityFn(cdi);
+ if (lineColorFn) props.mlc = lineColorFn(cdi);
+ if (lineWidthFn) props.mlw = lineWidthFn(cdi);
+ cdi.ct = props.ct;
+ cdi._polygons = geoUtils.feature2polygons(fOut);
+ }
+ }
+ var opacitySetting = opacityFn ? { type: "identity", property: "mo" } : marker.opacity;
+ Lib.extendFlat(fill.paint, {
+ "fill-color": { type: "identity", property: "fc" },
+ "fill-opacity": opacitySetting
+ });
+ Lib.extendFlat(line.paint, {
+ "line-color": lineColorFn ? { type: "identity", property: "mlc" } : markerLine.color,
+ "line-width": lineWidthFn ? { type: "identity", property: "mlw" } : markerLine.width,
+ "line-opacity": opacitySetting
+ });
+ fill.layout.visibility = "visible";
+ line.layout.visibility = "visible";
+ opts.geojson = { type: "FeatureCollection", features };
+ convertOnSelect(calcTrace);
+ return opts;
+ }
+ function convertOnSelect(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var opts = trace._opts;
+ var opacitySetting;
+ if (trace.selectedpoints) {
+ var fns = Drawing.makeSelectedPointStyleFns(trace);
+ for (var i = 0; i < calcTrace.length; i++) {
+ var cdi = calcTrace[i];
+ if (cdi.fOut) {
+ cdi.fOut.properties.mo2 = fns.selectedOpacityFn(cdi);
+ }
+ }
+ opacitySetting = { type: "identity", property: "mo2" };
+ } else {
+ opacitySetting = Lib.isArrayOrTypedArray(trace.marker.opacity) ? { type: "identity", property: "mo" } : trace.marker.opacity;
+ }
+ Lib.extendFlat(opts.fill.paint, { "fill-opacity": opacitySetting });
+ Lib.extendFlat(opts.line.paint, { "line-opacity": opacitySetting });
+ return opts;
+ }
+ module.exports = {
+ convert,
+ convertOnSelect
+ };
+ }
+ });
+
+ // src/traces/choroplethmapbox/plot.js
+ var require_plot24 = __commonJS({
+ "src/traces/choroplethmapbox/plot.js"(exports, module) {
+ "use strict";
+ var convert = require_convert12().convert;
+ var convertOnSelect = require_convert12().convertOnSelect;
+ var LAYER_PREFIX = require_constants25().traceLayerPrefix;
+ function ChoroplethMapbox(subplot, uid) {
+ this.type = "choroplethmapbox";
+ this.subplot = subplot;
+ this.uid = uid;
+ this.sourceId = "source-" + uid;
+ this.layerList = [
+ ["fill", LAYER_PREFIX + uid + "-fill"],
+ ["line", LAYER_PREFIX + uid + "-line"]
+ ];
+ this.below = null;
+ }
+ var proto = ChoroplethMapbox.prototype;
+ proto.update = function(calcTrace) {
+ this._update(convert(calcTrace));
+ calcTrace[0].trace._glTrace = this;
+ };
+ proto.updateOnSelect = function(calcTrace) {
+ this._update(convertOnSelect(calcTrace));
+ };
+ proto._update = function(optsAll) {
+ var subplot = this.subplot;
+ var layerList = this.layerList;
+ var below = subplot.belowLookup["trace-" + this.uid];
+ subplot.map.getSource(this.sourceId).setData(optsAll.geojson);
+ if (below !== this.below) {
+ this._removeLayers();
+ this._addLayers(optsAll, below);
+ this.below = below;
+ }
+ for (var i = 0; i < layerList.length; i++) {
+ var item = layerList[i];
+ var k = item[0];
+ var id = item[1];
+ var opts = optsAll[k];
+ subplot.setOptions(id, "setLayoutProperty", opts.layout);
+ if (opts.layout.visibility === "visible") {
+ subplot.setOptions(id, "setPaintProperty", opts.paint);
+ }
+ }
+ };
+ proto._addLayers = function(optsAll, below) {
+ var subplot = this.subplot;
+ var layerList = this.layerList;
+ var sourceId = this.sourceId;
+ for (var i = 0; i < layerList.length; i++) {
+ var item = layerList[i];
+ var k = item[0];
+ var opts = optsAll[k];
+ subplot.addLayer({
+ type: k,
+ id: item[1],
+ source: sourceId,
+ layout: opts.layout,
+ paint: opts.paint
+ }, below);
+ }
+ };
+ proto._removeLayers = function() {
+ var map = this.subplot.map;
+ var layerList = this.layerList;
+ for (var i = layerList.length - 1; i >= 0; i--) {
+ map.removeLayer(layerList[i][1]);
+ }
+ };
+ proto.dispose = function() {
+ var map = this.subplot.map;
+ this._removeLayers();
+ map.removeSource(this.sourceId);
+ };
+ module.exports = function createChoroplethMapbox(subplot, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var choroplethMapbox = new ChoroplethMapbox(subplot, trace.uid);
+ var sourceId = choroplethMapbox.sourceId;
+ var optsAll = convert(calcTrace);
+ var below = choroplethMapbox.below = subplot.belowLookup["trace-" + trace.uid];
+ subplot.map.addSource(sourceId, {
+ type: "geojson",
+ data: optsAll.geojson
+ });
+ choroplethMapbox._addLayers(optsAll, below);
+ calcTrace[0].trace._glTrace = choroplethMapbox;
+ return choroplethMapbox;
+ };
+ }
+ });
+
+ // src/traces/choroplethmapbox/index.js
+ var require_choroplethmapbox = __commonJS({
+ "src/traces/choroplethmapbox/index.js"(exports, module) {
+ "use strict";
+ var deprecationWarning = [
+ "*choroplethmapbox* trace is deprecated!",
+ "Please consider switching to the *choroplethmap* trace type and `map` subplots.",
+ "Learn more at: https://plotly.com/python/maplibre-migration/",
+ "as well as https://plotly.com/javascript/maplibre-migration/"
+ ].join(" ");
+ module.exports = {
+ attributes: require_attributes55(),
+ supplyDefaults: require_defaults51(),
+ colorbar: require_colorbar2(),
+ calc: require_calc28(),
+ plot: require_plot24(),
+ hoverPoints: require_hover15(),
+ eventData: require_event_data10(),
+ selectPoints: require_select6(),
+ styleOnSelect: function(_, cd) {
+ if (cd) {
+ var trace = cd[0].trace;
+ trace._glTrace.updateOnSelect(cd);
+ }
+ },
+ getBelow: function(trace, subplot) {
+ var mapLayers = subplot.getMapLayers();
+ for (var i = mapLayers.length - 2; i >= 0; i--) {
+ var layerId = mapLayers[i].id;
+ if (typeof layerId === "string" && layerId.indexOf("water") === 0) {
+ for (var j = i + 1; j < mapLayers.length; j++) {
+ layerId = mapLayers[j].id;
+ if (typeof layerId === "string" && layerId.indexOf("plotly-") === -1) {
+ return layerId;
+ }
+ }
+ }
+ }
+ },
+ moduleType: "trace",
+ name: "choroplethmapbox",
+ basePlotModule: require_mapbox2(),
+ categories: ["mapbox", "gl", "noOpacity", "showLegend"],
+ meta: {
+ hr_name: "choropleth_mapbox"
+ }
+ };
+ }
+ });
+
+ // lib/choroplethmapbox.js
+ var require_choroplethmapbox2 = __commonJS({
+ "lib/choroplethmapbox.js"(exports, module) {
+ "use strict";
+ module.exports = require_choroplethmapbox();
+ }
+ });
+
+ // src/traces/densitymapbox/attributes.js
+ var require_attributes56 = __commonJS({
+ "src/traces/densitymapbox/attributes.js"(exports, module) {
+ "use strict";
+ var colorScaleAttrs = require_attributes8();
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var baseAttrs = require_attributes2();
+ var scatterMapboxAttrs = require_attributes54();
+ var extendFlat = require_extend().extendFlat;
+ module.exports = extendFlat(
+ {
+ lon: scatterMapboxAttrs.lon,
+ lat: scatterMapboxAttrs.lat,
+ z: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ radius: {
+ valType: "number",
+ editType: "plot",
+ arrayOk: true,
+ min: 1,
+ dflt: 30
+ },
+ below: {
+ valType: "string",
+ editType: "plot"
+ },
+ text: scatterMapboxAttrs.text,
+ hovertext: scatterMapboxAttrs.hovertext,
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ flags: ["lon", "lat", "z", "text", "name"]
+ }),
+ hovertemplate: hovertemplateAttrs(),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ },
+ colorScaleAttrs("", {
+ cLetter: "z",
+ editTypeOverride: "calc"
+ })
+ );
+ }
+ });
+
+ // src/traces/densitymapbox/defaults.js
+ var require_defaults52 = __commonJS({
+ "src/traces/densitymapbox/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var colorscaleDefaults = require_defaults2();
+ var attributes = require_attributes56();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var lon = coerce("lon") || [];
+ var lat = coerce("lat") || [];
+ var len = Math.min(lon.length, lat.length);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ traceOut._length = len;
+ coerce("z");
+ coerce("radius");
+ coerce("below");
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: "", cLetter: "z" });
+ };
+ }
+ });
+
+ // src/traces/densitymapbox/calc.js
+ var require_calc33 = __commonJS({
+ "src/traces/densitymapbox/calc.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ var BADNUM = require_numerical().BADNUM;
+ var colorscaleCalc = require_calc();
+ var _ = require_lib()._;
+ module.exports = function calc(gd, trace) {
+ var len = trace._length;
+ var calcTrace = new Array(len);
+ var z = trace.z;
+ var hasZ = isArrayOrTypedArray(z) && z.length;
+ for (var i = 0; i < len; i++) {
+ var cdi = calcTrace[i] = {};
+ var lon = trace.lon[i];
+ var lat = trace.lat[i];
+ cdi.lonlat = isNumeric(lon) && isNumeric(lat) ? [+lon, +lat] : [BADNUM, BADNUM];
+ if (hasZ) {
+ var zi = z[i];
+ cdi.z = isNumeric(zi) ? zi : BADNUM;
+ }
+ }
+ colorscaleCalc(gd, trace, {
+ vals: hasZ ? z : [0, 1],
+ containerStr: "",
+ cLetter: "z"
+ });
+ if (len) {
+ calcTrace[0].t = {
+ labels: {
+ lat: _(gd, "lat:") + " ",
+ lon: _(gd, "lon:") + " "
+ }
+ };
+ }
+ return calcTrace;
+ };
+ }
+ });
+
+ // src/traces/densitymapbox/convert.js
+ var require_convert13 = __commonJS({
+ "src/traces/densitymapbox/convert.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var Lib = require_lib();
+ var Color2 = require_color();
+ var Colorscale = require_colorscale();
+ var BADNUM = require_numerical().BADNUM;
+ var makeBlank = require_geojson_utils().makeBlank;
+ module.exports = function convert(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var isVisible = trace.visible === true && trace._length !== 0;
+ var heatmap = {
+ layout: { visibility: "none" },
+ paint: {}
+ };
+ var opts = trace._opts = {
+ heatmap,
+ geojson: makeBlank()
+ };
+ if (!isVisible) return opts;
+ var features = [];
+ var i;
+ var z = trace.z;
+ var radius = trace.radius;
+ var hasZ = Lib.isArrayOrTypedArray(z) && z.length;
+ var hasArrayRadius = Lib.isArrayOrTypedArray(radius);
+ for (i = 0; i < calcTrace.length; i++) {
+ var cdi = calcTrace[i];
+ var lonlat = cdi.lonlat;
+ if (lonlat[0] !== BADNUM) {
+ var props = {};
+ if (hasZ) {
+ var zi = cdi.z;
+ props.z = zi !== BADNUM ? zi : 0;
+ }
+ if (hasArrayRadius) {
+ props.r = isNumeric(radius[i]) && radius[i] > 0 ? +radius[i] : 0;
+ }
+ features.push({
+ type: "Feature",
+ geometry: { type: "Point", coordinates: lonlat },
+ properties: props
+ });
+ }
+ }
+ var cOpts = Colorscale.extractOpts(trace);
+ var scl = cOpts.reversescale ? Colorscale.flipScale(cOpts.colorscale) : cOpts.colorscale;
+ var scl01 = scl[0][1];
+ var color0 = Color2.opacity(scl01) < 1 ? scl01 : Color2.addOpacity(scl01, 0);
+ var heatmapColor = [
+ "interpolate",
+ ["linear"],
+ ["heatmap-density"],
+ 0,
+ color0
+ ];
+ for (i = 1; i < scl.length; i++) {
+ heatmapColor.push(scl[i][0], scl[i][1]);
+ }
+ var zExp = [
+ "interpolate",
+ ["linear"],
+ ["get", "z"],
+ cOpts.min,
+ 0,
+ cOpts.max,
+ 1
+ ];
+ Lib.extendFlat(opts.heatmap.paint, {
+ "heatmap-weight": hasZ ? zExp : 1 / (cOpts.max - cOpts.min),
+ "heatmap-color": heatmapColor,
+ "heatmap-radius": hasArrayRadius ? { type: "identity", property: "r" } : trace.radius,
+ "heatmap-opacity": trace.opacity
+ });
+ opts.geojson = { type: "FeatureCollection", features };
+ opts.heatmap.layout.visibility = "visible";
+ return opts;
+ };
+ }
+ });
+
+ // src/traces/densitymapbox/plot.js
+ var require_plot25 = __commonJS({
+ "src/traces/densitymapbox/plot.js"(exports, module) {
+ "use strict";
+ var convert = require_convert13();
+ var LAYER_PREFIX = require_constants25().traceLayerPrefix;
+ function DensityMapbox(subplot, uid) {
+ this.type = "densitymapbox";
+ this.subplot = subplot;
+ this.uid = uid;
+ this.sourceId = "source-" + uid;
+ this.layerList = [
+ ["heatmap", LAYER_PREFIX + uid + "-heatmap"]
+ ];
+ this.below = null;
+ }
+ var proto = DensityMapbox.prototype;
+ proto.update = function(calcTrace) {
+ var subplot = this.subplot;
+ var layerList = this.layerList;
+ var optsAll = convert(calcTrace);
+ var below = subplot.belowLookup["trace-" + this.uid];
+ subplot.map.getSource(this.sourceId).setData(optsAll.geojson);
+ if (below !== this.below) {
+ this._removeLayers();
+ this._addLayers(optsAll, below);
+ this.below = below;
+ }
+ for (var i = 0; i < layerList.length; i++) {
+ var item = layerList[i];
+ var k = item[0];
+ var id = item[1];
+ var opts = optsAll[k];
+ subplot.setOptions(id, "setLayoutProperty", opts.layout);
+ if (opts.layout.visibility === "visible") {
+ subplot.setOptions(id, "setPaintProperty", opts.paint);
+ }
+ }
+ };
+ proto._addLayers = function(optsAll, below) {
+ var subplot = this.subplot;
+ var layerList = this.layerList;
+ var sourceId = this.sourceId;
+ for (var i = 0; i < layerList.length; i++) {
+ var item = layerList[i];
+ var k = item[0];
+ var opts = optsAll[k];
+ subplot.addLayer({
+ type: k,
+ id: item[1],
+ source: sourceId,
+ layout: opts.layout,
+ paint: opts.paint
+ }, below);
+ }
+ };
+ proto._removeLayers = function() {
+ var map = this.subplot.map;
+ var layerList = this.layerList;
+ for (var i = layerList.length - 1; i >= 0; i--) {
+ map.removeLayer(layerList[i][1]);
+ }
+ };
+ proto.dispose = function() {
+ var map = this.subplot.map;
+ this._removeLayers();
+ map.removeSource(this.sourceId);
+ };
+ module.exports = function createDensityMapbox(subplot, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var densityMapbox = new DensityMapbox(subplot, trace.uid);
+ var sourceId = densityMapbox.sourceId;
+ var optsAll = convert(calcTrace);
+ var below = densityMapbox.below = subplot.belowLookup["trace-" + trace.uid];
+ subplot.map.addSource(sourceId, {
+ type: "geojson",
+ data: optsAll.geojson
+ });
+ densityMapbox._addLayers(optsAll, below);
+ return densityMapbox;
+ };
+ }
+ });
+
+ // src/traces/densitymapbox/hover.js
+ var require_hover19 = __commonJS({
+ "src/traces/densitymapbox/hover.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ var scatterMapboxHoverPoints = require_hover18().hoverPoints;
+ var getExtraText = require_hover18().getExtraText;
+ module.exports = function hoverPoints(pointData, xval, yval) {
+ var pts = scatterMapboxHoverPoints(pointData, xval, yval);
+ if (!pts) return;
+ var newPointData = pts[0];
+ var cd = newPointData.cd;
+ var trace = cd[0].trace;
+ var di = cd[newPointData.index];
+ delete newPointData.color;
+ if ("z" in di) {
+ var ax = newPointData.subplot.mockAxis;
+ newPointData.z = di.z;
+ newPointData.zLabel = Axes.tickText(ax, ax.c2l(di.z), "hover").text;
+ }
+ newPointData.extraText = getExtraText(trace, di, cd[0].t.labels);
+ return [newPointData];
+ };
+ }
+ });
+
+ // src/traces/densitymapbox/event_data.js
+ var require_event_data12 = __commonJS({
+ "src/traces/densitymapbox/event_data.js"(exports, module) {
+ "use strict";
+ module.exports = function eventData(out, pt) {
+ out.lon = pt.lon;
+ out.lat = pt.lat;
+ out.z = pt.z;
+ return out;
+ };
+ }
+ });
+
+ // src/traces/densitymapbox/index.js
+ var require_densitymapbox = __commonJS({
+ "src/traces/densitymapbox/index.js"(exports, module) {
+ "use strict";
+ var deprecationWarning = [
+ "*densitymapbox* trace is deprecated!",
+ "Please consider switching to the *densitymap* trace type and `map` subplots.",
+ "Learn more at: https://plotly.com/python/maplibre-migration/",
+ "as well as https://plotly.com/javascript/maplibre-migration/"
+ ].join(" ");
+ module.exports = {
+ attributes: require_attributes56(),
+ supplyDefaults: require_defaults52(),
+ colorbar: require_colorbar2(),
+ formatLabels: require_format_labels5(),
+ calc: require_calc33(),
+ plot: require_plot25(),
+ hoverPoints: require_hover19(),
+ eventData: require_event_data12(),
+ getBelow: function(trace, subplot) {
+ var mapLayers = subplot.getMapLayers();
+ for (var i = 0; i < mapLayers.length; i++) {
+ var layer = mapLayers[i];
+ var layerId = layer.id;
+ if (layer.type === "symbol" && typeof layerId === "string" && layerId.indexOf("plotly-") === -1) {
+ return layerId;
+ }
+ }
+ },
+ moduleType: "trace",
+ name: "densitymapbox",
+ basePlotModule: require_mapbox2(),
+ categories: ["mapbox", "gl", "showLegend"],
+ meta: {
+ hr_name: "density_mapbox"
+ }
+ };
+ }
+ });
+
+ // lib/densitymapbox.js
+ var require_densitymapbox2 = __commonJS({
+ "lib/densitymapbox.js"(exports, module) {
+ "use strict";
+ module.exports = require_densitymapbox();
+ }
+ });
+
+ // src/plots/map/styles/arcgis-sat-hybrid.js
+ var require_arcgis_sat_hybrid = __commonJS({
+ "src/plots/map/styles/arcgis-sat-hybrid.js"(exports, module) {
+ module.exports = {
+ "version": 8,
+ "name": "orto",
+ "metadata": { "maputnik:renderer": "mlgljs" },
+ "center": [1.537786, 41.837539],
+ "zoom": 12,
+ "bearing": 0,
+ "pitch": 0,
+ "light": {
+ "anchor": "viewport",
+ "color": "white",
+ "intensity": 0.4,
+ "position": [1.15, 45, 30]
+ },
+ "sources": {
+ "ortoEsri": {
+ "type": "raster",
+ "tiles": [
+ "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
+ ],
+ "tileSize": 256,
+ "maxzoom": 18,
+ "attribution": "ESRI © ESRI"
+ },
+ "ortoInstaMaps": {
+ "type": "raster",
+ "tiles": [
+ "https://tilemaps.icgc.cat/mapfactory/wmts/orto_8_12/CAT3857/{z}/{x}/{y}.png"
+ ],
+ "tileSize": 256,
+ "maxzoom": 13
+ },
+ "ortoICGC": {
+ "type": "raster",
+ "tiles": [
+ "https://geoserveis.icgc.cat/icc_mapesmultibase/noutm/wmts/orto/GRID3857/{z}/{x}/{y}.jpeg"
+ ],
+ "tileSize": 256,
+ "minzoom": 13.1,
+ "maxzoom": 20
+ },
+ "openmaptiles": {
+ "type": "vector",
+ "url": "https://geoserveis.icgc.cat/contextmaps/basemap.json"
+ }
+ },
+ "sprite": "https://geoserveis.icgc.cat/contextmaps/sprites/sprite@1",
+ "glyphs": "https://geoserveis.icgc.cat/contextmaps/glyphs/{fontstack}/{range}.pbf",
+ "layers": [
+ {
+ "id": "background",
+ "type": "background",
+ "paint": { "background-color": "#F4F9F4" }
+ },
+ {
+ "id": "ortoEsri",
+ "type": "raster",
+ "source": "ortoEsri",
+ "maxzoom": 16,
+ "layout": { "visibility": "visible" }
+ },
+ {
+ "id": "ortoICGC",
+ "type": "raster",
+ "source": "ortoICGC",
+ "minzoom": 13.1,
+ "maxzoom": 19,
+ "layout": { "visibility": "visible" }
+ },
+ {
+ "id": "ortoInstaMaps",
+ "type": "raster",
+ "source": "ortoInstaMaps",
+ "maxzoom": 13,
+ "layout": { "visibility": "visible" }
+ },
+ {
+ "id": "waterway_tunnel",
+ "type": "line",
+ "source": "openmaptiles",
+ "source-layer": "waterway",
+ "minzoom": 14,
+ "filter": [
+ "all",
+ ["in", "class", "river", "stream", "canal"],
+ ["==", "brunnel", "tunnel"]
+ ],
+ "layout": { "line-cap": "round" },
+ "paint": {
+ "line-color": "#a0c8f0",
+ "line-width": { "base": 1.3, "stops": [[13, 0.5], [20, 6]] },
+ "line-dasharray": [2, 4]
+ }
+ },
+ {
+ "id": "waterway-other",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849382550.77" },
+ "source": "openmaptiles",
+ "source-layer": "waterway",
+ "filter": ["!in", "class", "canal", "river", "stream"],
+ "layout": { "line-cap": "round" },
+ "paint": {
+ "line-color": "#a0c8f0",
+ "line-width": { "base": 1.3, "stops": [[13, 0.5], [20, 2]] }
+ }
+ },
+ {
+ "id": "waterway-stream-canal",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849382550.77" },
+ "source": "openmaptiles",
+ "source-layer": "waterway",
+ "filter": [
+ "all",
+ ["in", "class", "canal", "stream"],
+ ["!=", "brunnel", "tunnel"]
+ ],
+ "layout": { "line-cap": "round" },
+ "paint": {
+ "line-color": "#a0c8f0",
+ "line-width": { "base": 1.3, "stops": [[13, 0.5], [20, 6]] }
+ }
+ },
+ {
+ "id": "waterway-river",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849382550.77" },
+ "source": "openmaptiles",
+ "source-layer": "waterway",
+ "filter": ["all", ["==", "class", "river"], ["!=", "brunnel", "tunnel"]],
+ "layout": { "line-cap": "round" },
+ "paint": {
+ "line-color": "#a0c8f0",
+ "line-width": { "base": 1.2, "stops": [[10, 0.8], [20, 4]] },
+ "line-opacity": 0.5
+ }
+ },
+ {
+ "id": "water-offset",
+ "type": "fill",
+ "metadata": { "mapbox:group": "1444849382550.77" },
+ "source": "openmaptiles",
+ "source-layer": "water",
+ "maxzoom": 8,
+ "filter": ["==", "$type", "Polygon"],
+ "layout": { "visibility": "visible" },
+ "paint": {
+ "fill-opacity": 0,
+ "fill-color": "#a0c8f0",
+ "fill-translate": { "base": 1, "stops": [[6, [2, 0]], [8, [0, 0]]] }
+ }
+ },
+ {
+ "id": "water",
+ "type": "fill",
+ "metadata": { "mapbox:group": "1444849382550.77" },
+ "source": "openmaptiles",
+ "source-layer": "water",
+ "layout": { "visibility": "visible" },
+ "paint": { "fill-color": "hsl(210, 67%, 85%)", "fill-opacity": 0 }
+ },
+ {
+ "id": "water-pattern",
+ "type": "fill",
+ "metadata": { "mapbox:group": "1444849382550.77" },
+ "source": "openmaptiles",
+ "source-layer": "water",
+ "layout": { "visibility": "visible" },
+ "paint": {
+ "fill-translate": [0, 2.5],
+ "fill-pattern": "wave",
+ "fill-opacity": 1
+ }
+ },
+ {
+ "id": "landcover-ice-shelf",
+ "type": "fill",
+ "metadata": { "mapbox:group": "1444849382550.77" },
+ "source": "openmaptiles",
+ "source-layer": "landcover",
+ "filter": ["==", "subclass", "ice_shelf"],
+ "layout": { "visibility": "visible" },
+ "paint": {
+ "fill-color": "#fff",
+ "fill-opacity": { "base": 1, "stops": [[0, 0.9], [10, 0.3]] }
+ }
+ },
+ {
+ "id": "tunnel-service-track-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "tunnel"],
+ ["in", "class", "service", "track"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#cfcdca",
+ "line-dasharray": [0.5, 0.25],
+ "line-width": { "base": 1.2, "stops": [[15, 1], [16, 4], [20, 11]] }
+ }
+ },
+ {
+ "id": "tunnel-minor-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": ["all", ["==", "brunnel", "tunnel"], ["==", "class", "minor"]],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#cfcdca",
+ "line-opacity": { "stops": [[12, 0], [12.5, 1]] },
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12, 0.5], [13, 1], [14, 4], [20, 15]]
+ }
+ }
+ },
+ {
+ "id": "tunnel-secondary-tertiary-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "tunnel"],
+ ["in", "class", "secondary", "tertiary"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": 1,
+ "line-width": { "base": 1.2, "stops": [[8, 1.5], [20, 17]] }
+ }
+ },
+ {
+ "id": "tunnel-trunk-primary-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "tunnel"],
+ ["in", "class", "primary", "trunk"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-width": {
+ "base": 1.2,
+ "stops": [[5, 0.4], [6, 0.6], [7, 1.5], [20, 22]]
+ },
+ "line-opacity": 0.7
+ }
+ },
+ {
+ "id": "tunnel-motorway-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "tunnel"],
+ ["==", "class", "motorway"]
+ ],
+ "layout": { "line-join": "round", "visibility": "visible" },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-dasharray": [0.5, 0.25],
+ "line-width": {
+ "base": 1.2,
+ "stops": [[5, 0.4], [6, 0.6], [7, 1.5], [20, 22]]
+ },
+ "line-opacity": 0.5
+ }
+ },
+ {
+ "id": "tunnel-path",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ ["all", ["==", "brunnel", "tunnel"], ["==", "class", "path"]]
+ ],
+ "paint": {
+ "line-color": "#cba",
+ "line-dasharray": [1.5, 0.75],
+ "line-width": { "base": 1.2, "stops": [[15, 1.2], [20, 4]] }
+ }
+ },
+ {
+ "id": "tunnel-service-track",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "tunnel"],
+ ["in", "class", "service", "track"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#fff",
+ "line-width": { "base": 1.2, "stops": [[15.5, 0], [16, 2], [20, 7.5]] }
+ }
+ },
+ {
+ "id": "tunnel-minor",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "tunnel"],
+ ["==", "class", "minor_road"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#fff",
+ "line-opacity": 1,
+ "line-width": { "base": 1.2, "stops": [[13.5, 0], [14, 2.5], [20, 11.5]] }
+ }
+ },
+ {
+ "id": "tunnel-secondary-tertiary",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "tunnel"],
+ ["in", "class", "secondary", "tertiary"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#fff4c6",
+ "line-width": { "base": 1.2, "stops": [[6.5, 0], [7, 0.5], [20, 10]] }
+ }
+ },
+ {
+ "id": "tunnel-trunk-primary",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "tunnel"],
+ ["in", "class", "primary", "trunk"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#fff4c6",
+ "line-width": { "base": 1.2, "stops": [[6.5, 0], [7, 0.5], [20, 18]] },
+ "line-opacity": 0.5
+ }
+ },
+ {
+ "id": "tunnel-motorway",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "tunnel"],
+ ["==", "class", "motorway"]
+ ],
+ "layout": { "line-join": "round", "visibility": "visible" },
+ "paint": {
+ "line-color": "#ffdaa6",
+ "line-width": { "base": 1.2, "stops": [[6.5, 0], [7, 0.5], [20, 18]] },
+ "line-opacity": 0.5
+ }
+ },
+ {
+ "id": "tunnel-railway",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849354174.1904" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": ["all", ["==", "brunnel", "tunnel"], ["==", "class", "rail"]],
+ "paint": {
+ "line-color": "#bbb",
+ "line-width": { "base": 1.4, "stops": [[14, 0.4], [15, 0.75], [20, 2]] },
+ "line-dasharray": [2, 2]
+ }
+ },
+ {
+ "id": "ferry",
+ "type": "line",
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": ["all", ["in", "class", "ferry"]],
+ "layout": { "line-join": "round", "visibility": "visible" },
+ "paint": {
+ "line-color": "rgba(108, 159, 182, 1)",
+ "line-width": 1.1,
+ "line-dasharray": [2, 2]
+ }
+ },
+ {
+ "id": "aeroway-taxiway-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "aeroway",
+ "minzoom": 12,
+ "filter": ["all", ["in", "class", "taxiway"]],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "rgba(153, 153, 153, 1)",
+ "line-width": { "base": 1.5, "stops": [[11, 2], [17, 12]] },
+ "line-opacity": 1
+ }
+ },
+ {
+ "id": "aeroway-runway-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "aeroway",
+ "minzoom": 12,
+ "filter": ["all", ["in", "class", "runway"]],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "rgba(153, 153, 153, 1)",
+ "line-width": { "base": 1.5, "stops": [[11, 5], [17, 55]] },
+ "line-opacity": 1
+ }
+ },
+ {
+ "id": "aeroway-taxiway",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "aeroway",
+ "minzoom": 4,
+ "filter": [
+ "all",
+ ["in", "class", "taxiway"],
+ ["==", "$type", "LineString"]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "rgba(255, 255, 255, 1)",
+ "line-width": { "base": 1.5, "stops": [[11, 1], [17, 10]] },
+ "line-opacity": { "base": 1, "stops": [[11, 0], [12, 1]] }
+ }
+ },
+ {
+ "id": "aeroway-runway",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "aeroway",
+ "minzoom": 4,
+ "filter": [
+ "all",
+ ["in", "class", "runway"],
+ ["==", "$type", "LineString"]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "rgba(255, 255, 255, 1)",
+ "line-width": { "base": 1.5, "stops": [[11, 4], [17, 50]] },
+ "line-opacity": { "base": 1, "stops": [[11, 0], [12, 1]] }
+ }
+ },
+ {
+ "id": "highway-motorway-link-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 12,
+ "filter": [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["==", "class", "motorway_link"]
+ ],
+ "layout": { "line-cap": "round", "line-join": "round" },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12, 1], [13, 3], [14, 4], [20, 15]]
+ }
+ }
+ },
+ {
+ "id": "highway-link-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 13,
+ "filter": [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ [
+ "in",
+ "class",
+ "primary_link",
+ "secondary_link",
+ "tertiary_link",
+ "trunk_link"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12, 1], [13, 3], [14, 4], [20, 15]]
+ }
+ }
+ },
+ {
+ "id": "highway-minor-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ [
+ "all",
+ ["!=", "brunnel", "tunnel"],
+ ["in", "class", "minor", "service", "track"]
+ ]
+ ],
+ "layout": { "line-cap": "round", "line-join": "round" },
+ "paint": {
+ "line-color": "#cfcdca",
+ "line-opacity": { "stops": [[12, 0], [12.5, 0]] },
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12, 0.5], [13, 1], [14, 4], [20, 15]]
+ }
+ }
+ },
+ {
+ "id": "highway-secondary-tertiary-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["in", "class", "secondary", "tertiary"]
+ ],
+ "layout": {
+ "line-cap": "butt",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": 0.5,
+ "line-width": { "base": 1.2, "stops": [[8, 1.5], [20, 17]] }
+ }
+ },
+ {
+ "id": "highway-primary-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 5,
+ "filter": [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["in", "class", "primary"]
+ ],
+ "layout": {
+ "line-cap": "butt",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": { "stops": [[7, 0], [8, 0.6]] },
+ "line-width": {
+ "base": 1.2,
+ "stops": [[7, 0], [8, 0.6], [9, 1.5], [20, 22]]
+ }
+ }
+ },
+ {
+ "id": "highway-trunk-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 5,
+ "filter": [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["in", "class", "trunk"]
+ ],
+ "layout": {
+ "line-cap": "butt",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": { "stops": [[5, 0], [6, 0.5]] },
+ "line-width": {
+ "base": 1.2,
+ "stops": [[5, 0], [6, 0.6], [7, 1.5], [20, 22]]
+ }
+ }
+ },
+ {
+ "id": "highway-motorway-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 4,
+ "filter": [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["==", "class", "motorway"]
+ ],
+ "layout": {
+ "line-cap": "butt",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-width": {
+ "base": 1.2,
+ "stops": [[4, 0], [5, 0.4], [6, 0.6], [7, 1.5], [20, 22]]
+ },
+ "line-opacity": { "stops": [[4, 0], [5, 0.5]] }
+ }
+ },
+ {
+ "id": "highway-path",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ ["all", ["!in", "brunnel", "bridge", "tunnel"], ["==", "class", "path"]]
+ ],
+ "paint": {
+ "line-color": "#cba",
+ "line-dasharray": [1.5, 0.75],
+ "line-width": { "base": 1.2, "stops": [[15, 1.2], [20, 4]] }
+ }
+ },
+ {
+ "id": "highway-motorway-link",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 12,
+ "filter": [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["==", "class", "motorway_link"]
+ ],
+ "layout": { "line-cap": "round", "line-join": "round" },
+ "paint": {
+ "line-color": "#fc8",
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12.5, 0], [13, 1.5], [14, 2.5], [20, 11.5]]
+ }
+ }
+ },
+ {
+ "id": "highway-link",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 13,
+ "filter": [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ [
+ "in",
+ "class",
+ "primary_link",
+ "secondary_link",
+ "tertiary_link",
+ "trunk_link"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#fea",
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12.5, 0], [13, 1.5], [14, 2.5], [20, 11.5]]
+ }
+ }
+ },
+ {
+ "id": "highway-minor",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ [
+ "all",
+ ["!=", "brunnel", "tunnel"],
+ ["in", "class", "minor", "service", "track"]
+ ]
+ ],
+ "layout": { "line-cap": "round", "line-join": "round" },
+ "paint": {
+ "line-color": "#fff",
+ "line-opacity": 0.5,
+ "line-width": { "base": 1.2, "stops": [[13.5, 0], [14, 2.5], [20, 11.5]] }
+ }
+ },
+ {
+ "id": "highway-secondary-tertiary",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["in", "class", "secondary", "tertiary"]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#fea",
+ "line-width": { "base": 1.2, "stops": [[6.5, 0], [8, 0.5], [20, 13]] },
+ "line-opacity": 0.5
+ }
+ },
+ {
+ "id": "highway-primary",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["in", "class", "primary"]
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#fea",
+ "line-width": { "base": 1.2, "stops": [[8.5, 0], [9, 0.5], [20, 18]] },
+ "line-opacity": 0
+ }
+ },
+ {
+ "id": "highway-trunk",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["in", "class", "trunk"]
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#fea",
+ "line-width": { "base": 1.2, "stops": [[6.5, 0], [7, 0.5], [20, 18]] },
+ "line-opacity": 0.5
+ }
+ },
+ {
+ "id": "highway-motorway",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 5,
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ [
+ "all",
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["==", "class", "motorway"]
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#fc8",
+ "line-width": { "base": 1.2, "stops": [[6.5, 0], [7, 0.5], [20, 18]] },
+ "line-opacity": 0.5
+ }
+ },
+ {
+ "id": "railway-transit",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ ["all", ["==", "class", "transit"], ["!in", "brunnel", "tunnel"]]
+ ],
+ "layout": { "visibility": "visible" },
+ "paint": {
+ "line-color": "hsla(0, 0%, 73%, 0.77)",
+ "line-width": { "base": 1.4, "stops": [[14, 0.4], [20, 1]] }
+ }
+ },
+ {
+ "id": "railway-transit-hatching",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ ["all", ["==", "class", "transit"], ["!in", "brunnel", "tunnel"]]
+ ],
+ "layout": { "visibility": "visible" },
+ "paint": {
+ "line-color": "hsla(0, 0%, 73%, 0.68)",
+ "line-dasharray": [0.2, 8],
+ "line-width": { "base": 1.4, "stops": [[14.5, 0], [15, 2], [20, 6]] }
+ }
+ },
+ {
+ "id": "railway-service",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ ["all", ["==", "class", "rail"], ["has", "service"]]
+ ],
+ "paint": {
+ "line-color": "hsla(0, 0%, 73%, 0.77)",
+ "line-width": { "base": 1.4, "stops": [[14, 0.4], [20, 1]] }
+ }
+ },
+ {
+ "id": "railway-service-hatching",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ ["all", ["==", "class", "rail"], ["has", "service"]]
+ ],
+ "layout": { "visibility": "visible" },
+ "paint": {
+ "line-color": "hsla(0, 0%, 73%, 0.68)",
+ "line-dasharray": [0.2, 8],
+ "line-width": { "base": 1.4, "stops": [[14.5, 0], [15, 2], [20, 6]] }
+ }
+ },
+ {
+ "id": "railway",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ [
+ "all",
+ ["!has", "service"],
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["==", "class", "rail"]
+ ]
+ ],
+ "paint": {
+ "line-color": "#bbb",
+ "line-width": { "base": 1.4, "stops": [[14, 0.4], [15, 0.75], [20, 2]] }
+ }
+ },
+ {
+ "id": "railway-hatching",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849345966.4436" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ [
+ "all",
+ ["!has", "service"],
+ ["!in", "brunnel", "bridge", "tunnel"],
+ ["==", "class", "rail"]
+ ]
+ ],
+ "paint": {
+ "line-color": "#bbb",
+ "line-dasharray": [0.2, 8],
+ "line-width": { "base": 1.4, "stops": [[14.5, 0], [15, 3], [20, 8]] }
+ }
+ },
+ {
+ "id": "bridge-motorway-link-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ ["==", "class", "motorway_link"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12, 1], [13, 3], [14, 4], [20, 15]]
+ }
+ }
+ },
+ {
+ "id": "bridge-link-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ [
+ "in",
+ "class",
+ "primary_link",
+ "secondary_link",
+ "tertiary_link",
+ "trunk_link"
+ ]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12, 1], [13, 3], [14, 4], [20, 15]]
+ }
+ }
+ },
+ {
+ "id": "bridge-secondary-tertiary-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ ["in", "class", "secondary", "tertiary"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": 1,
+ "line-width": { "base": 1.2, "stops": [[8, 1.5], [20, 28]] }
+ }
+ },
+ {
+ "id": "bridge-trunk-primary-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ ["in", "class", "primary", "trunk"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "hsl(28, 76%, 67%)",
+ "line-width": {
+ "base": 1.2,
+ "stops": [[5, 0.4], [6, 0.6], [7, 1.5], [20, 26]]
+ }
+ }
+ },
+ {
+ "id": "bridge-motorway-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ ["==", "class", "motorway"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-width": {
+ "base": 1.2,
+ "stops": [[5, 0.4], [6, 0.6], [7, 1.5], [20, 22]]
+ },
+ "line-opacity": 0.5
+ }
+ },
+ {
+ "id": "bridge-path-casing",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ ["all", ["==", "brunnel", "bridge"], ["==", "class", "path"]]
+ ],
+ "paint": {
+ "line-color": "#f8f4f0",
+ "line-width": { "base": 1.2, "stops": [[15, 1.2], [20, 18]] }
+ }
+ },
+ {
+ "id": "bridge-path",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ ["all", ["==", "brunnel", "bridge"], ["==", "class", "path"]]
+ ],
+ "paint": {
+ "line-color": "#cba",
+ "line-width": { "base": 1.2, "stops": [[15, 1.2], [20, 4]] },
+ "line-dasharray": [1.5, 0.75]
+ }
+ },
+ {
+ "id": "bridge-motorway-link",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ ["==", "class", "motorway_link"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#fc8",
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12.5, 0], [13, 1.5], [14, 2.5], [20, 11.5]]
+ }
+ }
+ },
+ {
+ "id": "bridge-link",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ [
+ "in",
+ "class",
+ "primary_link",
+ "secondary_link",
+ "tertiary_link",
+ "trunk_link"
+ ]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#fea",
+ "line-width": {
+ "base": 1.2,
+ "stops": [[12.5, 0], [13, 1.5], [14, 2.5], [20, 11.5]]
+ }
+ }
+ },
+ {
+ "id": "bridge-secondary-tertiary",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ ["in", "class", "secondary", "tertiary"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#fea",
+ "line-width": { "base": 1.2, "stops": [[6.5, 0], [7, 0.5], [20, 20]] }
+ }
+ },
+ {
+ "id": "bridge-trunk-primary",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ ["in", "class", "primary", "trunk"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#fea",
+ "line-width": { "base": 1.2, "stops": [[6.5, 0], [7, 0.5], [20, 18]] }
+ }
+ },
+ {
+ "id": "bridge-motorway",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ ["==", "brunnel", "bridge"],
+ ["==", "class", "motorway"]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#fc8",
+ "line-width": { "base": 1.2, "stops": [[6.5, 0], [7, 0.5], [20, 18]] },
+ "line-opacity": 0.5
+ }
+ },
+ {
+ "id": "bridge-railway",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": ["all", ["==", "brunnel", "bridge"], ["==", "class", "rail"]],
+ "paint": {
+ "line-color": "#bbb",
+ "line-width": { "base": 1.4, "stops": [[14, 0.4], [15, 0.75], [20, 2]] }
+ }
+ },
+ {
+ "id": "bridge-railway-hatching",
+ "type": "line",
+ "metadata": { "mapbox:group": "1444849334699.1902" },
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "filter": ["all", ["==", "brunnel", "bridge"], ["==", "class", "rail"]],
+ "paint": {
+ "line-color": "#bbb",
+ "line-dasharray": [0.2, 8],
+ "line-width": { "base": 1.4, "stops": [[14.5, 0], [15, 3], [20, 8]] }
+ }
+ },
+ {
+ "id": "cablecar",
+ "type": "line",
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 13,
+ "filter": ["==", "class", "cable_car"],
+ "layout": { "visibility": "visible", "line-cap": "round" },
+ "paint": {
+ "line-color": "hsl(0, 0%, 70%)",
+ "line-width": { "base": 1, "stops": [[11, 1], [19, 2.5]] }
+ }
+ },
+ {
+ "id": "cablecar-dash",
+ "type": "line",
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 13,
+ "filter": ["==", "class", "cable_car"],
+ "layout": { "visibility": "visible", "line-cap": "round" },
+ "paint": {
+ "line-color": "hsl(0, 0%, 70%)",
+ "line-width": { "base": 1, "stops": [[11, 3], [19, 5.5]] },
+ "line-dasharray": [2, 3]
+ }
+ },
+ {
+ "id": "boundary-land-level-4",
+ "type": "line",
+ "source": "openmaptiles",
+ "source-layer": "boundary",
+ "filter": [
+ "all",
+ [">=", "admin_level", 4],
+ ["<=", "admin_level", 8],
+ ["!=", "maritime", 1]
+ ],
+ "layout": { "line-join": "round" },
+ "paint": {
+ "line-color": "#9e9cab",
+ "line-dasharray": [3, 1, 1, 1],
+ "line-width": { "base": 1.4, "stops": [[4, 0.4], [5, 1], [12, 3]] },
+ "line-opacity": 0.6
+ }
+ },
+ {
+ "id": "boundary-land-level-2",
+ "type": "line",
+ "source": "openmaptiles",
+ "source-layer": "boundary",
+ "filter": [
+ "all",
+ ["==", "admin_level", 2],
+ ["!=", "maritime", 1],
+ ["!=", "disputed", 1]
+ ],
+ "layout": { "line-cap": "round", "line-join": "round" },
+ "paint": {
+ "line-color": "hsl(248, 7%, 66%)",
+ "line-width": {
+ "base": 1,
+ "stops": [[0, 0.6], [4, 1.4], [5, 2], [12, 2]]
+ }
+ }
+ },
+ {
+ "id": "boundary-land-disputed",
+ "type": "line",
+ "source": "openmaptiles",
+ "source-layer": "boundary",
+ "filter": ["all", ["!=", "maritime", 1], ["==", "disputed", 1]],
+ "layout": { "line-cap": "round", "line-join": "round" },
+ "paint": {
+ "line-color": "hsl(248, 7%, 70%)",
+ "line-dasharray": [1, 3],
+ "line-width": {
+ "base": 1,
+ "stops": [[0, 0.6], [4, 1.4], [5, 2], [12, 8]]
+ }
+ }
+ },
+ {
+ "id": "boundary-water",
+ "type": "line",
+ "source": "openmaptiles",
+ "source-layer": "boundary",
+ "filter": ["all", ["in", "admin_level", 2, 4], ["==", "maritime", 1]],
+ "layout": { "line-cap": "round", "line-join": "round" },
+ "paint": {
+ "line-color": "rgba(154, 189, 214, 1)",
+ "line-width": { "base": 1, "stops": [[0, 0.6], [4, 1], [5, 1], [12, 1]] },
+ "line-opacity": { "stops": [[6, 0], [10, 0]] }
+ }
+ },
+ {
+ "id": "waterway-name",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "waterway",
+ "minzoom": 13,
+ "filter": ["all", ["==", "$type", "LineString"], ["has", "name"]],
+ "layout": {
+ "text-font": ["Noto Sans Italic"],
+ "text-size": 14,
+ "text-field": "{name:latin} {name:nonlatin}",
+ "text-max-width": 5,
+ "text-rotation-alignment": "map",
+ "symbol-placement": "line",
+ "text-letter-spacing": 0.2,
+ "symbol-spacing": 350
+ },
+ "paint": {
+ "text-color": "#74aee9",
+ "text-halo-width": 1.5,
+ "text-halo-color": "rgba(255,255,255,0.7)"
+ }
+ },
+ {
+ "id": "water-name-lakeline",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "water_name",
+ "filter": ["==", "$type", "LineString"],
+ "layout": {
+ "text-font": ["Noto Sans Italic"],
+ "text-size": 14,
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-max-width": 5,
+ "text-rotation-alignment": "map",
+ "symbol-placement": "line",
+ "symbol-spacing": 350,
+ "text-letter-spacing": 0.2
+ },
+ "paint": {
+ "text-color": "#74aee9",
+ "text-halo-width": 1.5,
+ "text-halo-color": "rgba(255,255,255,0.7)"
+ }
+ },
+ {
+ "id": "water-name-ocean",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "water_name",
+ "filter": ["all", ["==", "$type", "Point"], ["==", "class", "ocean"]],
+ "layout": {
+ "text-font": ["Noto Sans Italic"],
+ "text-size": 14,
+ "text-field": "{name:latin}",
+ "text-max-width": 5,
+ "text-rotation-alignment": "map",
+ "symbol-placement": "point",
+ "symbol-spacing": 350,
+ "text-letter-spacing": 0.2
+ },
+ "paint": {
+ "text-color": "#74aee9",
+ "text-halo-width": 1.5,
+ "text-halo-color": "rgba(255,255,255,0.7)"
+ }
+ },
+ {
+ "id": "water-name-other",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "water_name",
+ "filter": ["all", ["==", "$type", "Point"], ["!in", "class", "ocean"]],
+ "layout": {
+ "text-font": ["Noto Sans Italic"],
+ "text-size": { "stops": [[0, 10], [6, 14]] },
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-max-width": 5,
+ "text-rotation-alignment": "map",
+ "symbol-placement": "point",
+ "symbol-spacing": 350,
+ "text-letter-spacing": 0.2,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-color": "#74aee9",
+ "text-halo-width": 1.5,
+ "text-halo-color": "rgba(255,255,255,0.7)"
+ }
+ },
+ {
+ "id": "poi-level-3",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "poi",
+ "minzoom": 16,
+ "filter": ["all", ["==", "$type", "Point"], [">=", "rank", 25]],
+ "layout": {
+ "text-padding": 2,
+ "text-font": ["Noto Sans Regular"],
+ "text-anchor": "top",
+ "icon-image": "{class}_11",
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-offset": [0, 0.6],
+ "text-size": 12,
+ "text-max-width": 9
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#666",
+ "text-halo-width": 1,
+ "text-halo-color": "#ffffff"
+ }
+ },
+ {
+ "id": "poi-level-2",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "poi",
+ "minzoom": 15,
+ "filter": [
+ "all",
+ ["==", "$type", "Point"],
+ ["<=", "rank", 24],
+ [">=", "rank", 15]
+ ],
+ "layout": {
+ "text-padding": 2,
+ "text-font": ["Noto Sans Regular"],
+ "text-anchor": "top",
+ "icon-image": "{class}_11",
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-offset": [0, 0.6],
+ "text-size": 12,
+ "text-max-width": 9
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#666",
+ "text-halo-width": 1,
+ "text-halo-color": "#ffffff"
+ }
+ },
+ {
+ "id": "poi-level-1",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "poi",
+ "minzoom": 14,
+ "filter": [
+ "all",
+ ["==", "$type", "Point"],
+ ["<=", "rank", 14],
+ ["has", "name"]
+ ],
+ "layout": {
+ "text-padding": 2,
+ "text-font": ["Noto Sans Regular"],
+ "text-anchor": "top",
+ "icon-image": "{class}_11",
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-offset": [0, 0.6],
+ "text-size": 11,
+ "text-max-width": 9
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "rgba(191, 228, 172, 1)",
+ "text-halo-width": 1,
+ "text-halo-color": "rgba(30, 29, 29, 1)"
+ }
+ },
+ {
+ "id": "poi-railway",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "poi",
+ "minzoom": 13,
+ "filter": [
+ "all",
+ ["==", "$type", "Point"],
+ ["has", "name"],
+ ["==", "class", "railway"],
+ ["==", "subclass", "station"]
+ ],
+ "layout": {
+ "text-padding": 2,
+ "text-font": ["Noto Sans Regular"],
+ "text-anchor": "top",
+ "icon-image": "{class}_11",
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-offset": [0, 0.6],
+ "text-size": 12,
+ "text-max-width": 9,
+ "icon-optional": false,
+ "icon-ignore-placement": false,
+ "icon-allow-overlap": false,
+ "text-ignore-placement": false,
+ "text-allow-overlap": false,
+ "text-optional": true
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#666",
+ "text-halo-width": 1,
+ "text-halo-color": "#ffffff"
+ }
+ },
+ {
+ "id": "road_oneway",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 15,
+ "filter": [
+ "all",
+ ["==", "oneway", 1],
+ [
+ "in",
+ "class",
+ "motorway",
+ "trunk",
+ "primary",
+ "secondary",
+ "tertiary",
+ "minor",
+ "service"
+ ]
+ ],
+ "layout": {
+ "symbol-placement": "line",
+ "icon-image": "oneway",
+ "symbol-spacing": 75,
+ "icon-padding": 2,
+ "icon-rotation-alignment": "map",
+ "icon-rotate": 90,
+ "icon-size": { "stops": [[15, 0.5], [19, 1]] }
+ },
+ "paint": { "icon-opacity": 0.5 }
+ },
+ {
+ "id": "road_oneway_opposite",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "transportation",
+ "minzoom": 15,
+ "filter": [
+ "all",
+ ["==", "oneway", -1],
+ [
+ "in",
+ "class",
+ "motorway",
+ "trunk",
+ "primary",
+ "secondary",
+ "tertiary",
+ "minor",
+ "service"
+ ]
+ ],
+ "layout": {
+ "symbol-placement": "line",
+ "icon-image": "oneway",
+ "symbol-spacing": 75,
+ "icon-padding": 2,
+ "icon-rotation-alignment": "map",
+ "icon-rotate": -90,
+ "icon-size": { "stops": [[15, 0.5], [19, 1]] }
+ },
+ "paint": { "icon-opacity": 0.5 }
+ },
+ {
+ "id": "highway-name-path",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "transportation_name",
+ "minzoom": 15.5,
+ "filter": ["==", "class", "path"],
+ "layout": {
+ "text-size": { "base": 1, "stops": [[13, 12], [14, 13]] },
+ "text-font": ["Noto Sans Regular"],
+ "text-field": "{name:latin} {name:nonlatin}",
+ "symbol-placement": "line",
+ "text-rotation-alignment": "map"
+ },
+ "paint": {
+ "text-halo-color": "#f8f4f0",
+ "text-color": "hsl(30, 23%, 62%)",
+ "text-halo-width": 0.5
+ }
+ },
+ {
+ "id": "highway-name-minor",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "transportation_name",
+ "minzoom": 15,
+ "filter": [
+ "all",
+ ["==", "$type", "LineString"],
+ ["in", "class", "minor", "service", "track"]
+ ],
+ "layout": {
+ "text-size": { "base": 1, "stops": [[13, 12], [14, 13]] },
+ "text-font": ["Noto Sans Regular"],
+ "text-field": "{name:latin} {name:nonlatin}",
+ "symbol-placement": "line",
+ "text-rotation-alignment": "map"
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#765",
+ "text-halo-width": 1
+ }
+ },
+ {
+ "id": "highway-name-major",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "transportation_name",
+ "minzoom": 12.2,
+ "filter": ["in", "class", "primary", "secondary", "tertiary", "trunk"],
+ "layout": {
+ "text-size": { "base": 1, "stops": [[13, 12], [14, 13]] },
+ "text-font": ["Noto Sans Regular"],
+ "text-field": "{name:latin} {name:nonlatin}",
+ "symbol-placement": "line",
+ "text-rotation-alignment": "map"
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#765",
+ "text-halo-width": 1
+ }
+ },
+ {
+ "id": "highway-shield",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "transportation_name",
+ "minzoom": 8,
+ "filter": [
+ "all",
+ ["<=", "ref_length", 6],
+ ["==", "$type", "LineString"],
+ ["!in", "network", "us-interstate", "us-highway", "us-state"]
+ ],
+ "layout": {
+ "text-size": 10,
+ "icon-image": "road_{ref_length}",
+ "icon-rotation-alignment": "viewport",
+ "symbol-spacing": 200,
+ "text-font": ["Noto Sans Regular"],
+ "symbol-placement": { "base": 1, "stops": [[10, "point"], [11, "line"]] },
+ "text-rotation-alignment": "viewport",
+ "icon-size": 1,
+ "text-field": "{ref}"
+ },
+ "paint": {
+ "text-opacity": 1,
+ "text-color": "rgba(20, 19, 19, 1)",
+ "text-halo-color": "rgba(230, 221, 221, 0)",
+ "text-halo-width": 2,
+ "icon-color": "rgba(183, 18, 18, 1)",
+ "icon-opacity": 0.3,
+ "icon-halo-color": "rgba(183, 55, 55, 0)"
+ }
+ },
+ {
+ "id": "highway-shield-us-interstate",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "transportation_name",
+ "minzoom": 7,
+ "filter": [
+ "all",
+ ["<=", "ref_length", 6],
+ ["==", "$type", "LineString"],
+ ["in", "network", "us-interstate"]
+ ],
+ "layout": {
+ "text-size": 10,
+ "icon-image": "{network}_{ref_length}",
+ "icon-rotation-alignment": "viewport",
+ "symbol-spacing": 200,
+ "text-font": ["Noto Sans Regular"],
+ "symbol-placement": {
+ "base": 1,
+ "stops": [[7, "point"], [7, "line"], [8, "line"]]
+ },
+ "text-rotation-alignment": "viewport",
+ "icon-size": 1,
+ "text-field": "{ref}"
+ },
+ "paint": { "text-color": "rgba(0, 0, 0, 1)" }
+ },
+ {
+ "id": "highway-shield-us-other",
+ "type": "symbol",
+ "source": "openmaptiles",
+ "source-layer": "transportation_name",
+ "minzoom": 9,
+ "filter": [
+ "all",
+ ["<=", "ref_length", 6],
+ ["==", "$type", "LineString"],
+ ["in", "network", "us-highway", "us-state"]
+ ],
+ "layout": {
+ "text-size": 10,
+ "icon-image": "{network}_{ref_length}",
+ "icon-rotation-alignment": "viewport",
+ "symbol-spacing": 200,
+ "text-font": ["Noto Sans Regular"],
+ "symbol-placement": { "base": 1, "stops": [[10, "point"], [11, "line"]] },
+ "text-rotation-alignment": "viewport",
+ "icon-size": 1,
+ "text-field": "{ref}"
+ },
+ "paint": { "text-color": "rgba(0, 0, 0, 1)" }
+ },
+ {
+ "id": "place-other",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "minzoom": 12,
+ "filter": [
+ "!in",
+ "class",
+ "city",
+ "town",
+ "village",
+ "country",
+ "continent"
+ ],
+ "layout": {
+ "text-letter-spacing": 0.1,
+ "text-size": { "base": 1.2, "stops": [[12, 10], [15, 14]] },
+ "text-font": ["Noto Sans Bold"],
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-transform": "uppercase",
+ "text-max-width": 9,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-color": "rgba(255,255,255,1)",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(57, 28, 28, 1)"
+ }
+ },
+ {
+ "id": "place-village",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "minzoom": 10,
+ "filter": ["==", "class", "village"],
+ "layout": {
+ "text-font": ["Noto Sans Regular"],
+ "text-size": { "base": 1.2, "stops": [[10, 12], [15, 16]] },
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-max-width": 8,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-color": "rgba(255, 255, 255, 1)",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(10, 9, 9, 0.8)"
+ }
+ },
+ {
+ "id": "place-town",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "filter": ["==", "class", "town"],
+ "layout": {
+ "text-font": ["Noto Sans Regular"],
+ "text-size": { "base": 1.2, "stops": [[10, 14], [15, 24]] },
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-max-width": 8,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-color": "rgba(255, 255, 255, 1)",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(22, 22, 22, 0.8)"
+ }
+ },
+ {
+ "id": "place-city",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "filter": ["all", ["!=", "capital", 2], ["==", "class", "city"]],
+ "layout": {
+ "text-font": ["Noto Sans Regular"],
+ "text-size": { "base": 1.2, "stops": [[7, 14], [11, 24]] },
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-max-width": 8,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-color": "rgba(0, 0, 0, 1)",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-city-capital",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "filter": ["all", ["==", "capital", 2], ["==", "class", "city"]],
+ "layout": {
+ "text-font": ["Noto Sans Regular"],
+ "text-size": { "base": 1.2, "stops": [[7, 14], [11, 24]] },
+ "text-field": "{name:latin}\n{name:nonlatin}",
+ "text-max-width": 8,
+ "icon-image": "star_11",
+ "text-offset": [0.4, 0],
+ "icon-size": 0.8,
+ "text-anchor": "left",
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-color": "#333",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-country-other",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "filter": [
+ "all",
+ ["==", "class", "country"],
+ [">=", "rank", 3],
+ ["!has", "iso_a2"]
+ ],
+ "layout": {
+ "text-font": ["Noto Sans Italic"],
+ "text-field": "{name:latin}",
+ "text-size": { "stops": [[3, 11], [7, 17]] },
+ "text-transform": "uppercase",
+ "text-max-width": 6.25,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-halo-blur": 1,
+ "text-color": "#334",
+ "text-halo-width": 2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-country-3",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "filter": [
+ "all",
+ ["==", "class", "country"],
+ [">=", "rank", 3],
+ ["has", "iso_a2"]
+ ],
+ "layout": {
+ "text-font": ["Noto Sans Bold"],
+ "text-field": "{name:latin}",
+ "text-size": { "stops": [[3, 11], [7, 17]] },
+ "text-transform": "uppercase",
+ "text-max-width": 6.25,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-halo-blur": 1,
+ "text-color": "#334",
+ "text-halo-width": 2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-country-2",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "filter": [
+ "all",
+ ["==", "class", "country"],
+ ["==", "rank", 2],
+ ["has", "iso_a2"]
+ ],
+ "layout": {
+ "text-font": ["Noto Sans Bold"],
+ "text-field": "{name:latin}",
+ "text-size": { "stops": [[2, 11], [5, 17]] },
+ "text-transform": "uppercase",
+ "text-max-width": 6.25,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-halo-blur": 1,
+ "text-color": "#334",
+ "text-halo-width": 2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-country-1",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "filter": [
+ "all",
+ ["==", "class", "country"],
+ ["==", "rank", 1],
+ ["has", "iso_a2"]
+ ],
+ "layout": {
+ "text-font": ["Noto Sans Bold"],
+ "text-field": "{name:latin}",
+ "text-size": { "stops": [[1, 11], [4, 17]] },
+ "text-transform": "uppercase",
+ "text-max-width": 6.25,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-halo-blur": 1,
+ "text-color": "#334",
+ "text-halo-width": 2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-continent",
+ "type": "symbol",
+ "metadata": { "mapbox:group": "1444849242106.713" },
+ "source": "openmaptiles",
+ "source-layer": "place",
+ "maxzoom": 1,
+ "filter": ["==", "class", "continent"],
+ "layout": {
+ "text-font": ["Noto Sans Bold"],
+ "text-field": "{name:latin}",
+ "text-size": 14,
+ "text-max-width": 6.25,
+ "text-transform": "uppercase",
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-halo-blur": 1,
+ "text-color": "#334",
+ "text-halo-width": 2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ }
+ ],
+ "id": "qebnlkra6"
+ };
+ }
+ });
+
+ // src/plots/map/styles/arcgis-sat.js
+ var require_arcgis_sat = __commonJS({
+ "src/plots/map/styles/arcgis-sat.js"(exports, module) {
+ module.exports = {
+ "version": 8,
+ "name": "orto",
+ "metadata": {},
+ "center": [
+ 1.537786,
+ 41.837539
+ ],
+ "zoom": 12,
+ "bearing": 0,
+ "pitch": 0,
+ "light": {
+ "anchor": "viewport",
+ "color": "white",
+ "intensity": 0.4,
+ "position": [
+ 1.15,
+ 45,
+ 30
+ ]
+ },
+ "sources": {
+ "ortoEsri": {
+ "type": "raster",
+ "tiles": [
+ "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
+ ],
+ "tileSize": 256,
+ "maxzoom": 18,
+ "attribution": "ESRI © ESRI"
+ },
+ "ortoInstaMaps": {
+ "type": "raster",
+ "tiles": [
+ "https://tilemaps.icgc.cat/mapfactory/wmts/orto_8_12/CAT3857/{z}/{x}/{y}.png"
+ ],
+ "tileSize": 256,
+ "maxzoom": 13
+ },
+ "ortoICGC": {
+ "type": "raster",
+ "tiles": [
+ "https://geoserveis.icgc.cat/icc_mapesmultibase/noutm/wmts/orto/GRID3857/{z}/{x}/{y}.jpeg"
+ ],
+ "tileSize": 256,
+ "minzoom": 13.1,
+ "maxzoom": 20
+ },
+ "openmaptiles": {
+ "type": "vector",
+ "url": "https://geoserveis.icgc.cat/contextmaps/basemap.json"
+ }
+ },
+ "sprite": "https://geoserveis.icgc.cat/contextmaps/sprites/sprite@1",
+ "glyphs": "https://geoserveis.icgc.cat/contextmaps/glyphs/{fontstack}/{range}.pbf",
+ "layers": [
+ {
+ "id": "background",
+ "type": "background",
+ "paint": {
+ "background-color": "#F4F9F4"
+ }
+ },
+ {
+ "id": "ortoEsri",
+ "type": "raster",
+ "source": "ortoEsri",
+ "maxzoom": 16,
+ "layout": {
+ "visibility": "visible"
+ }
+ },
+ {
+ "id": "ortoICGC",
+ "type": "raster",
+ "source": "ortoICGC",
+ "minzoom": 13.1,
+ "maxzoom": 19,
+ "layout": {
+ "visibility": "visible"
+ }
+ },
+ {
+ "id": "ortoInstaMaps",
+ "type": "raster",
+ "source": "ortoInstaMaps",
+ "maxzoom": 13,
+ "layout": {
+ "visibility": "visible"
+ }
+ }
+ ]
+ };
+ }
+ });
+
+ // src/plots/map/constants.js
+ var require_constants27 = __commonJS({
+ "src/plots/map/constants.js"(exports, module) {
+ "use strict";
+ var sortObjectKeys = require_sort_object_keys();
+ var arcgisSatHybrid = require_arcgis_sat_hybrid();
+ var arcgisSat = require_arcgis_sat();
+ var OSM = '\xA9 OpenStreetMap contributors';
+ var cartoPositron = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json";
+ var cartoDarkmatter = "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json";
+ var cartoVoyager = "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json";
+ var cartoPositronNoLabels = "https://basemaps.cartocdn.com/gl/positron-nolabels-gl-style/style.json";
+ var cartoDarkmatterNoLabels = "https://basemaps.cartocdn.com/gl/dark-matter-nolabels-gl-style/style.json";
+ var cartoVoyagerNoLabels = "https://basemaps.cartocdn.com/gl/voyager-nolabels-gl-style/style.json";
+ var stylesMap = {
+ basic: cartoVoyager,
+ streets: cartoVoyager,
+ outdoors: cartoVoyager,
+ light: cartoPositron,
+ dark: cartoDarkmatter,
+ satellite: arcgisSat,
+ "satellite-streets": arcgisSatHybrid,
+ "open-street-map": {
+ id: "osm",
+ version: 8,
+ sources: {
+ "plotly-osm-tiles": {
+ type: "raster",
+ attribution: OSM,
+ tiles: [
+ "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
+ ],
+ tileSize: 256
+ }
+ },
+ layers: [{
+ id: "plotly-osm-tiles",
+ type: "raster",
+ source: "plotly-osm-tiles",
+ minzoom: 0,
+ maxzoom: 22
+ }],
+ glyphs: "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
+ },
+ "white-bg": {
+ id: "white-bg",
+ version: 8,
+ sources: {},
+ layers: [{
+ id: "white-bg",
+ type: "background",
+ paint: { "background-color": "#FFFFFF" },
+ minzoom: 0,
+ maxzoom: 22
+ }],
+ glyphs: "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf"
+ },
+ "carto-positron": cartoPositron,
+ "carto-darkmatter": cartoDarkmatter,
+ "carto-voyager": cartoVoyager,
+ "carto-positron-nolabels": cartoPositronNoLabels,
+ "carto-darkmatter-nolabels": cartoDarkmatterNoLabels,
+ "carto-voyager-nolabels": cartoVoyagerNoLabels
+ };
+ var styleValuesMap = sortObjectKeys(stylesMap);
+ module.exports = {
+ styleValueDflt: "basic",
+ stylesMap,
+ styleValuesMap,
+ traceLayerPrefix: "plotly-trace-layer-",
+ layoutLayerPrefix: "plotly-layout-layer-",
+ missingStyleErrorMsg: [
+ "No valid maplibre style found, please set `map.style` to one of:",
+ styleValuesMap.join(", "),
+ "or use a tile service."
+ ].join("\n"),
+ mapOnErrorMsg: "Map error."
+ };
+ }
+ });
+
+ // src/plots/map/layout_attributes.js
+ var require_layout_attributes20 = __commonJS({
+ "src/plots/map/layout_attributes.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var defaultLine = require_color().defaultLine;
+ var domainAttrs = require_domain().attributes;
+ var fontAttrs = require_font_attributes();
+ var textposition = require_attributes12().textposition;
+ var overrideAll = require_edit_types().overrideAll;
+ var templatedArray = require_plot_template().templatedArray;
+ var constants = require_constants27();
+ var fontAttr = fontAttrs({
+ noFontVariant: true,
+ noFontShadow: true,
+ noFontLineposition: true,
+ noFontTextcase: true
+ });
+ fontAttr.family.dflt = "Open Sans Regular, Arial Unicode MS Regular";
+ var attrs = module.exports = overrideAll({
+ _arrayAttrRegexps: [Lib.counterRegex("map", ".layers", true)],
+ domain: domainAttrs({ name: "map" }),
+ style: {
+ valType: "any",
+ values: constants.styleValuesMap,
+ dflt: constants.styleValueDflt
+ },
+ center: {
+ lon: {
+ valType: "number",
+ dflt: 0
+ },
+ lat: {
+ valType: "number",
+ dflt: 0
+ }
+ },
+ zoom: {
+ valType: "number",
+ dflt: 1
+ },
+ bearing: {
+ valType: "number",
+ dflt: 0
+ },
+ pitch: {
+ valType: "number",
+ dflt: 0
+ },
+ bounds: {
+ west: {
+ valType: "number"
+ },
+ east: {
+ valType: "number"
+ },
+ south: {
+ valType: "number"
+ },
+ north: {
+ valType: "number"
+ }
+ },
+ layers: templatedArray("layer", {
+ visible: {
+ valType: "boolean",
+ dflt: true
+ },
+ sourcetype: {
+ valType: "enumerated",
+ values: ["geojson", "vector", "raster", "image"],
+ dflt: "geojson"
+ },
+ source: {
+ valType: "any"
+ },
+ sourcelayer: {
+ valType: "string",
+ dflt: ""
+ },
+ sourceattribution: {
+ valType: "string"
+ },
+ type: {
+ valType: "enumerated",
+ values: ["circle", "line", "fill", "symbol", "raster"],
+ dflt: "circle"
+ },
+ coordinates: {
+ valType: "any"
+ },
+ // attributes shared between all types
+ below: {
+ valType: "string"
+ },
+ color: {
+ valType: "color",
+ dflt: defaultLine
+ },
+ opacity: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1
+ },
+ minzoom: {
+ valType: "number",
+ min: 0,
+ max: 24,
+ dflt: 0
+ },
+ maxzoom: {
+ valType: "number",
+ min: 0,
+ max: 24,
+ dflt: 24
+ },
+ // type-specific style attributes
+ circle: {
+ radius: {
+ valType: "number",
+ dflt: 15
+ }
+ },
+ line: {
+ width: {
+ valType: "number",
+ dflt: 2
+ },
+ dash: {
+ valType: "data_array"
+ }
+ },
+ fill: {
+ outlinecolor: {
+ valType: "color",
+ dflt: defaultLine
+ }
+ },
+ symbol: {
+ icon: {
+ valType: "string",
+ dflt: "marker"
+ },
+ iconsize: {
+ valType: "number",
+ dflt: 10
+ },
+ text: {
+ valType: "string",
+ dflt: ""
+ },
+ placement: {
+ valType: "enumerated",
+ values: ["point", "line", "line-center"],
+ dflt: "point"
+ },
+ textfont: fontAttr,
+ textposition: Lib.extendFlat({}, textposition, { arrayOk: false })
+ }
+ })
+ }, "plot", "from-root");
+ attrs.uirevision = {
+ valType: "any",
+ editType: "none"
+ };
+ }
+ });
+
+ // src/traces/scattermap/attributes.js
+ var require_attributes57 = __commonJS({
+ "src/traces/scattermap/attributes.js"(exports, module) {
+ "use strict";
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var texttemplateAttrs = require_template_attributes().texttemplateAttrs;
+ var makeFillcolorAttr = require_fillcolor_attribute();
+ var scatterGeoAttrs = require_attributes48();
+ var scatterAttrs = require_attributes12();
+ var mapAttrs = require_layout_attributes20();
+ var baseAttrs = require_attributes2();
+ var colorScaleAttrs = require_attributes8();
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var mapLayoutAtributes = require_layout_attributes20();
+ var lineAttrs = scatterGeoAttrs.line;
+ var markerAttrs = scatterGeoAttrs.marker;
+ module.exports = overrideAll({
+ lon: scatterGeoAttrs.lon,
+ lat: scatterGeoAttrs.lat,
+ cluster: {
+ enabled: {
+ valType: "boolean"
+ },
+ maxzoom: extendFlat({}, mapLayoutAtributes.layers.maxzoom, {}),
+ step: {
+ valType: "number",
+ arrayOk: true,
+ dflt: -1,
+ min: -1
+ },
+ size: {
+ valType: "number",
+ arrayOk: true,
+ dflt: 20,
+ min: 0
+ },
+ color: {
+ valType: "color",
+ arrayOk: true
+ },
+ opacity: extendFlat({}, markerAttrs.opacity, {
+ dflt: 1
+ })
+ },
+ // locations
+ // locationmode
+ mode: extendFlat({}, scatterAttrs.mode, {
+ dflt: "markers"
+ }),
+ text: extendFlat({}, scatterAttrs.text, {}),
+ texttemplate: texttemplateAttrs({ editType: "plot" }, {
+ keys: ["lat", "lon", "text"]
+ }),
+ hovertext: extendFlat({}, scatterAttrs.hovertext, {}),
+ line: {
+ color: lineAttrs.color,
+ width: lineAttrs.width
+ // TODO
+ // dash: dash
+ },
+ connectgaps: scatterAttrs.connectgaps,
+ marker: extendFlat(
+ {
+ symbol: {
+ valType: "string",
+ dflt: "circle",
+ arrayOk: true
+ },
+ angle: {
+ valType: "number",
+ dflt: "auto",
+ arrayOk: true
+ },
+ allowoverlap: {
+ valType: "boolean",
+ dflt: false
+ },
+ opacity: markerAttrs.opacity,
+ size: markerAttrs.size,
+ sizeref: markerAttrs.sizeref,
+ sizemin: markerAttrs.sizemin,
+ sizemode: markerAttrs.sizemode
+ },
+ colorScaleAttrs("marker")
+ // line
+ ),
+ fill: scatterGeoAttrs.fill,
+ fillcolor: makeFillcolorAttr(),
+ textfont: mapAttrs.layers.symbol.textfont,
+ textposition: mapAttrs.layers.symbol.textposition,
+ below: {
+ valType: "string"
+ },
+ selected: {
+ marker: scatterAttrs.selected.marker
+ },
+ unselected: {
+ marker: scatterAttrs.unselected.marker
+ },
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ flags: ["lon", "lat", "text", "name"]
+ }),
+ hovertemplate: hovertemplateAttrs()
+ }, "calc", "nested");
+ }
+ });
+
+ // src/traces/scattermap/constants.js
+ var require_constants28 = __commonJS({
+ "src/traces/scattermap/constants.js"(exports, module) {
+ "use strict";
+ var supportedFonts = [
+ "Metropolis Black Italic",
+ "Metropolis Black",
+ "Metropolis Bold Italic",
+ "Metropolis Bold",
+ "Metropolis Extra Bold Italic",
+ "Metropolis Extra Bold",
+ "Metropolis Extra Light Italic",
+ "Metropolis Extra Light",
+ "Metropolis Light Italic",
+ "Metropolis Light",
+ "Metropolis Medium Italic",
+ "Metropolis Medium",
+ "Metropolis Regular Italic",
+ "Metropolis Regular",
+ "Metropolis Semi Bold Italic",
+ "Metropolis Semi Bold",
+ "Metropolis Thin Italic",
+ "Metropolis Thin",
+ "Open Sans Bold Italic",
+ "Open Sans Bold",
+ "Open Sans Extrabold Italic",
+ "Open Sans Extrabold",
+ "Open Sans Italic",
+ "Open Sans Light Italic",
+ "Open Sans Light",
+ "Open Sans Regular",
+ "Open Sans Semibold Italic",
+ "Open Sans Semibold",
+ "Klokantech Noto Sans Bold",
+ "Klokantech Noto Sans CJK Bold",
+ "Klokantech Noto Sans CJK Regular",
+ "Klokantech Noto Sans Italic",
+ "Klokantech Noto Sans Regular"
+ ];
+ module.exports = {
+ isSupportedFont: function(a) {
+ return supportedFonts.indexOf(a) !== -1;
+ }
+ };
+ }
+ });
+
+ // src/traces/scattermap/defaults.js
+ var require_defaults53 = __commonJS({
+ "src/traces/scattermap/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var subTypes = require_subtypes();
+ var handleMarkerDefaults = require_marker_defaults();
+ var handleLineDefaults = require_line_defaults();
+ var handleTextDefaults = require_text_defaults();
+ var handleFillColorDefaults = require_fillcolor_defaults();
+ var attributes = require_attributes57();
+ var isSupportedFont = require_constants28().isSupportedFont;
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ function coerce2(attr, dflt) {
+ return Lib.coerce2(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var len = handleLonLatDefaults(traceIn, traceOut, coerce);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("text");
+ coerce("texttemplate");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ coerce("mode");
+ coerce("below");
+ if (subTypes.hasMarkers(traceOut)) {
+ handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, { noLine: true, noAngle: true });
+ coerce("marker.allowoverlap");
+ coerce("marker.angle");
+ var marker = traceOut.marker;
+ if (marker.symbol !== "circle") {
+ if (Lib.isArrayOrTypedArray(marker.size)) marker.size = marker.size[0];
+ if (Lib.isArrayOrTypedArray(marker.color)) marker.color = marker.color[0];
+ }
+ }
+ if (subTypes.hasLines(traceOut)) {
+ handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce, { noDash: true });
+ coerce("connectgaps");
+ }
+ var clusterMaxzoom = coerce2("cluster.maxzoom");
+ var clusterStep = coerce2("cluster.step");
+ var clusterColor = coerce2("cluster.color", traceOut.marker && traceOut.marker.color || defaultColor);
+ var clusterSize = coerce2("cluster.size");
+ var clusterOpacity = coerce2("cluster.opacity");
+ var clusterEnabledDflt = clusterMaxzoom !== false || clusterStep !== false || clusterColor !== false || clusterSize !== false || clusterOpacity !== false;
+ var clusterEnabled = coerce("cluster.enabled", clusterEnabledDflt);
+ if (clusterEnabled || subTypes.hasText(traceOut)) {
+ var layoutFontFamily = layout.font.family;
+ handleTextDefaults(
+ traceIn,
+ traceOut,
+ layout,
+ coerce,
+ {
+ noSelect: true,
+ noFontVariant: true,
+ noFontShadow: true,
+ noFontLineposition: true,
+ noFontTextcase: true,
+ font: {
+ family: isSupportedFont(layoutFontFamily) ? layoutFontFamily : "Open Sans Regular",
+ weight: layout.font.weight,
+ style: layout.font.style,
+ size: layout.font.size,
+ color: layout.font.color
+ }
+ }
+ );
+ }
+ coerce("fill");
+ if (traceOut.fill !== "none") {
+ handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
+ }
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ function handleLonLatDefaults(traceIn, traceOut, coerce) {
+ var lon = coerce("lon") || [];
+ var lat = coerce("lat") || [];
+ var len = Math.min(lon.length, lat.length);
+ traceOut._length = len;
+ return len;
+ }
+ }
+ });
+
+ // src/traces/scattermap/format_labels.js
+ var require_format_labels6 = __commonJS({
+ "src/traces/scattermap/format_labels.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ module.exports = function formatLabels(cdi, trace, fullLayout) {
+ var labels = {};
+ var subplot = fullLayout[trace.subplot]._subplot;
+ var ax = subplot.mockAxis;
+ var lonlat = cdi.lonlat;
+ labels.lonLabel = Axes.tickText(ax, ax.c2l(lonlat[0]), true).text;
+ labels.latLabel = Axes.tickText(ax, ax.c2l(lonlat[1]), true).text;
+ return labels;
+ };
+ }
+ });
+
+ // src/plots/map/convert_text_opts.js
+ var require_convert_text_opts2 = __commonJS({
+ "src/plots/map/convert_text_opts.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ module.exports = function convertTextOpts(textposition, iconSize) {
+ var parts = textposition.split(" ");
+ var vPos = parts[0];
+ var hPos = parts[1];
+ var factor = Lib.isArrayOrTypedArray(iconSize) ? Lib.mean(iconSize) : iconSize;
+ var xInc = 0.5 + factor / 100;
+ var yInc = 1.5 + factor / 100;
+ var anchorVals = ["", ""];
+ var offset = [0, 0];
+ switch (vPos) {
+ case "top":
+ anchorVals[0] = "top";
+ offset[1] = -yInc;
+ break;
+ case "bottom":
+ anchorVals[0] = "bottom";
+ offset[1] = yInc;
+ break;
+ }
+ switch (hPos) {
+ case "left":
+ anchorVals[1] = "right";
+ offset[0] = -xInc;
+ break;
+ case "right":
+ anchorVals[1] = "left";
+ offset[0] = xInc;
+ break;
+ }
+ var anchor;
+ if (anchorVals[0] && anchorVals[1]) anchor = anchorVals.join("-");
+ else if (anchorVals[0]) anchor = anchorVals[0];
+ else if (anchorVals[1]) anchor = anchorVals[1];
+ else anchor = "center";
+ return { anchor, offset };
+ };
+ }
+ });
+
+ // src/traces/scattermap/convert.js
+ var require_convert14 = __commonJS({
+ "src/traces/scattermap/convert.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var Lib = require_lib();
+ var BADNUM = require_numerical().BADNUM;
+ var geoJsonUtils = require_geojson_utils();
+ var Colorscale = require_colorscale();
+ var Drawing = require_drawing();
+ var makeBubbleSizeFn = require_make_bubble_size_func();
+ var subTypes = require_subtypes();
+ var isSupportedFont = require_constants28().isSupportedFont;
+ var convertTextOpts = require_convert_text_opts2();
+ var appendArrayPointValue = require_helpers2().appendArrayPointValue;
+ var NEWLINES = require_svg_text_utils().NEWLINES;
+ var BR_TAG_ALL = require_svg_text_utils().BR_TAG_ALL;
+ module.exports = function convert(gd, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var isVisible = trace.visible === true && trace._length !== 0;
+ var hasFill = trace.fill !== "none";
+ var hasLines = subTypes.hasLines(trace);
+ var hasMarkers = subTypes.hasMarkers(trace);
+ var hasText = subTypes.hasText(trace);
+ var hasCircles = hasMarkers && trace.marker.symbol === "circle";
+ var hasSymbols = hasMarkers && trace.marker.symbol !== "circle";
+ var hasCluster = trace.cluster && trace.cluster.enabled;
+ var fill = initContainer("fill");
+ var line = initContainer("line");
+ var circle = initContainer("circle");
+ var symbol = initContainer("symbol");
+ var opts = {
+ fill,
+ line,
+ circle,
+ symbol
+ };
+ if (!isVisible) return opts;
+ var lineCoords;
+ if (hasFill || hasLines) {
+ lineCoords = geoJsonUtils.calcTraceToLineCoords(calcTrace);
+ }
+ if (hasFill) {
+ fill.geojson = geoJsonUtils.makePolygon(lineCoords);
+ fill.layout.visibility = "visible";
+ Lib.extendFlat(fill.paint, {
+ "fill-color": trace.fillcolor
+ });
+ }
+ if (hasLines) {
+ line.geojson = geoJsonUtils.makeLine(lineCoords);
+ line.layout.visibility = "visible";
+ Lib.extendFlat(line.paint, {
+ "line-width": trace.line.width,
+ "line-color": trace.line.color,
+ "line-opacity": trace.opacity
+ });
+ }
+ if (hasCircles) {
+ var circleOpts = makeCircleOpts(calcTrace);
+ circle.geojson = circleOpts.geojson;
+ circle.layout.visibility = "visible";
+ if (hasCluster) {
+ circle.filter = ["!", ["has", "point_count"]];
+ opts.cluster = {
+ type: "circle",
+ filter: ["has", "point_count"],
+ layout: { visibility: "visible" },
+ paint: {
+ "circle-color": arrayifyAttribute(trace.cluster.color, trace.cluster.step),
+ "circle-radius": arrayifyAttribute(trace.cluster.size, trace.cluster.step),
+ "circle-opacity": arrayifyAttribute(trace.cluster.opacity, trace.cluster.step)
+ }
+ };
+ opts.clusterCount = {
+ type: "symbol",
+ filter: ["has", "point_count"],
+ paint: {},
+ layout: {
+ "text-field": "{point_count_abbreviated}",
+ "text-font": getTextFont(trace),
+ "text-size": 12
+ }
+ };
+ }
+ Lib.extendFlat(circle.paint, {
+ "circle-color": circleOpts.mcc,
+ "circle-radius": circleOpts.mrc,
+ "circle-opacity": circleOpts.mo
+ });
+ }
+ if (hasCircles && hasCluster) {
+ circle.filter = ["!", ["has", "point_count"]];
+ }
+ if (hasSymbols || hasText) {
+ symbol.geojson = makeSymbolGeoJSON(calcTrace, gd);
+ Lib.extendFlat(symbol.layout, {
+ visibility: "visible",
+ "icon-image": "{symbol}-15",
+ "text-field": "{text}"
+ });
+ if (hasSymbols) {
+ Lib.extendFlat(symbol.layout, {
+ "icon-size": trace.marker.size / 10
+ });
+ if ("angle" in trace.marker && trace.marker.angle !== "auto") {
+ Lib.extendFlat(symbol.layout, {
+ // unfortunately cant use {angle} do to this issue:
+ // https://github.com/mapbox/mapbox-gl-js/issues/873
+ "icon-rotate": {
+ type: "identity",
+ property: "angle"
+ },
+ "icon-rotation-alignment": "map"
+ });
+ }
+ symbol.layout["icon-allow-overlap"] = trace.marker.allowoverlap;
+ Lib.extendFlat(symbol.paint, {
+ "icon-opacity": trace.opacity * trace.marker.opacity,
+ // TODO does not work ??
+ "icon-color": trace.marker.color
+ });
+ }
+ if (hasText) {
+ var iconSize = (trace.marker || {}).size;
+ var textOpts = convertTextOpts(trace.textposition, iconSize);
+ Lib.extendFlat(symbol.layout, {
+ "text-size": trace.textfont.size,
+ "text-anchor": textOpts.anchor,
+ "text-offset": textOpts.offset,
+ "text-font": getTextFont(trace)
+ });
+ Lib.extendFlat(symbol.paint, {
+ "text-color": trace.textfont.color,
+ "text-opacity": trace.opacity
+ });
+ }
+ }
+ return opts;
+ };
+ function initContainer(type) {
+ return {
+ type,
+ geojson: geoJsonUtils.makeBlank(),
+ layout: { visibility: "none" },
+ filter: null,
+ paint: {}
+ };
+ }
+ function makeCircleOpts(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var marker = trace.marker;
+ var selectedpoints = trace.selectedpoints;
+ var arrayColor = Lib.isArrayOrTypedArray(marker.color);
+ var arraySize = Lib.isArrayOrTypedArray(marker.size);
+ var arrayOpacity = Lib.isArrayOrTypedArray(marker.opacity);
+ var i;
+ function addTraceOpacity(o) {
+ return trace.opacity * o;
+ }
+ function size2radius(s) {
+ return s / 2;
+ }
+ var colorFn;
+ if (arrayColor) {
+ if (Colorscale.hasColorscale(trace, "marker")) {
+ colorFn = Colorscale.makeColorScaleFuncFromTrace(marker);
+ } else {
+ colorFn = Lib.identity;
+ }
+ }
+ var sizeFn;
+ if (arraySize) {
+ sizeFn = makeBubbleSizeFn(trace);
+ }
+ var opacityFn;
+ if (arrayOpacity) {
+ opacityFn = function(mo) {
+ var mo2 = isNumeric(mo) ? +Lib.constrain(mo, 0, 1) : 0;
+ return addTraceOpacity(mo2);
+ };
+ }
+ var features = [];
+ for (i = 0; i < calcTrace.length; i++) {
+ var calcPt = calcTrace[i];
+ var lonlat = calcPt.lonlat;
+ if (isBADNUM(lonlat)) continue;
+ var props = {};
+ if (colorFn) props.mcc = calcPt.mcc = colorFn(calcPt.mc);
+ if (sizeFn) props.mrc = calcPt.mrc = sizeFn(calcPt.ms);
+ if (opacityFn) props.mo = opacityFn(calcPt.mo);
+ if (selectedpoints) props.selected = calcPt.selected || 0;
+ features.push({
+ type: "Feature",
+ id: i + 1,
+ geometry: { type: "Point", coordinates: lonlat },
+ properties: props
+ });
+ }
+ var fns;
+ if (selectedpoints) {
+ fns = Drawing.makeSelectedPointStyleFns(trace);
+ for (i = 0; i < features.length; i++) {
+ var d = features[i].properties;
+ if (fns.selectedOpacityFn) {
+ d.mo = addTraceOpacity(fns.selectedOpacityFn(d));
+ }
+ if (fns.selectedColorFn) {
+ d.mcc = fns.selectedColorFn(d);
+ }
+ if (fns.selectedSizeFn) {
+ d.mrc = fns.selectedSizeFn(d);
+ }
+ }
+ }
+ return {
+ geojson: { type: "FeatureCollection", features },
+ mcc: arrayColor || fns && fns.selectedColorFn ? { type: "identity", property: "mcc" } : marker.color,
+ mrc: arraySize || fns && fns.selectedSizeFn ? { type: "identity", property: "mrc" } : size2radius(marker.size),
+ mo: arrayOpacity || fns && fns.selectedOpacityFn ? { type: "identity", property: "mo" } : addTraceOpacity(marker.opacity)
+ };
+ }
+ function makeSymbolGeoJSON(calcTrace, gd) {
+ var fullLayout = gd._fullLayout;
+ var trace = calcTrace[0].trace;
+ var marker = trace.marker || {};
+ var symbol = marker.symbol;
+ var angle = marker.angle;
+ var fillSymbol = symbol !== "circle" ? getFillFunc(symbol) : blankFillFunc;
+ var fillAngle = angle !== "auto" ? getFillFunc(angle, true) : blankFillFunc;
+ var fillText = subTypes.hasText(trace) ? getFillFunc(trace.text) : blankFillFunc;
+ var features = [];
+ for (var i = 0; i < calcTrace.length; i++) {
+ var calcPt = calcTrace[i];
+ if (isBADNUM(calcPt.lonlat)) continue;
+ var texttemplate = trace.texttemplate;
+ var text;
+ if (texttemplate) {
+ var tt = Array.isArray(texttemplate) ? texttemplate[i] || "" : texttemplate;
+ var labels = trace._module.formatLabels(calcPt, trace, fullLayout);
+ var pointValues = {};
+ appendArrayPointValue(pointValues, trace, calcPt.i);
+ var meta = trace._meta || {};
+ text = Lib.texttemplateString(tt, labels, fullLayout._d3locale, pointValues, calcPt, meta);
+ } else {
+ text = fillText(i);
+ }
+ if (text) {
+ text = text.replace(NEWLINES, "").replace(BR_TAG_ALL, "\n");
+ }
+ features.push({
+ type: "Feature",
+ geometry: {
+ type: "Point",
+ coordinates: calcPt.lonlat
+ },
+ properties: {
+ symbol: fillSymbol(i),
+ angle: fillAngle(i),
+ text
+ }
+ });
+ }
+ return {
+ type: "FeatureCollection",
+ features
+ };
+ }
+ function getFillFunc(attr, numeric) {
+ if (Lib.isArrayOrTypedArray(attr)) {
+ if (numeric) {
+ return function(i) {
+ return isNumeric(attr[i]) ? +attr[i] : 0;
+ };
+ }
+ return function(i) {
+ return attr[i];
+ };
+ } else if (attr) {
+ return function() {
+ return attr;
+ };
+ } else {
+ return blankFillFunc;
+ }
+ }
+ function blankFillFunc() {
+ return "";
+ }
+ function isBADNUM(lonlat) {
+ return lonlat[0] === BADNUM;
+ }
+ function arrayifyAttribute(values, step) {
+ var newAttribute;
+ if (Lib.isArrayOrTypedArray(values) && Lib.isArrayOrTypedArray(step)) {
+ newAttribute = ["step", ["get", "point_count"], values[0]];
+ for (var idx = 1; idx < values.length; idx++) {
+ newAttribute.push(step[idx - 1], values[idx]);
+ }
+ } else {
+ newAttribute = values;
+ }
+ return newAttribute;
+ }
+ function getTextFont(trace) {
+ var font = trace.textfont;
+ var family = font.family;
+ var style = font.style;
+ var weight = font.weight;
+ var parts = family.split(" ");
+ var isItalic = parts[parts.length - 1] === "Italic";
+ if (isItalic) parts.pop();
+ isItalic = isItalic || style === "italic";
+ var str = parts.join(" ");
+ if (weight === "bold" && parts.indexOf("Bold") === -1) {
+ str += " Bold";
+ } else if (weight <= 1e3) {
+ if (parts[0] === "Metropolis") {
+ str = "Metropolis";
+ if (weight > 850) str += " Black";
+ else if (weight > 750) str += " Extra Bold";
+ else if (weight > 650) str += " Bold";
+ else if (weight > 550) str += " Semi Bold";
+ else if (weight > 450) str += " Medium";
+ else if (weight > 350) str += " Regular";
+ else if (weight > 250) str += " Light";
+ else if (weight > 150) str += " Extra Light";
+ else str += " Thin";
+ } else if (parts.slice(0, 2).join(" ") === "Open Sans") {
+ str = "Open Sans";
+ if (weight > 750) str += " Extrabold";
+ else if (weight > 650) str += " Bold";
+ else if (weight > 550) str += " Semibold";
+ else if (weight > 350) str += " Regular";
+ else str += " Light";
+ } else if (parts.slice(0, 3).join(" ") === "Klokantech Noto Sans") {
+ str = "Klokantech Noto Sans";
+ if (parts[3] === "CJK") str += " CJK";
+ str += weight > 500 ? " Bold" : " Regular";
+ }
+ }
+ if (isItalic) str += " Italic";
+ if (str === "Open Sans Regular Italic") str = "Open Sans Italic";
+ else if (str === "Open Sans Regular Bold") str = "Open Sans Bold";
+ else if (str === "Open Sans Regular Bold Italic") str = "Open Sans Bold Italic";
+ else if (str === "Klokantech Noto Sans Regular Italic") str = "Klokantech Noto Sans Italic";
+ if (!isSupportedFont(str)) {
+ str = family;
+ }
+ var textFont = str.split(", ");
+ return textFont;
+ }
+ }
+ });
+
+ // src/traces/scattermap/plot.js
+ var require_plot26 = __commonJS({
+ "src/traces/scattermap/plot.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var convert = require_convert14();
+ var LAYER_PREFIX = require_constants27().traceLayerPrefix;
+ var ORDER = {
+ cluster: ["cluster", "clusterCount", "circle"],
+ nonCluster: ["fill", "line", "circle", "symbol"]
+ };
+ function ScatterMap(subplot, uid, clusterEnabled, isHidden) {
+ this.type = "scattermap";
+ this.subplot = subplot;
+ this.uid = uid;
+ this.clusterEnabled = clusterEnabled;
+ this.isHidden = isHidden;
+ this.sourceIds = {
+ fill: "source-" + uid + "-fill",
+ line: "source-" + uid + "-line",
+ circle: "source-" + uid + "-circle",
+ symbol: "source-" + uid + "-symbol",
+ cluster: "source-" + uid + "-circle",
+ clusterCount: "source-" + uid + "-circle"
+ };
+ this.layerIds = {
+ fill: LAYER_PREFIX + uid + "-fill",
+ line: LAYER_PREFIX + uid + "-line",
+ circle: LAYER_PREFIX + uid + "-circle",
+ symbol: LAYER_PREFIX + uid + "-symbol",
+ cluster: LAYER_PREFIX + uid + "-cluster",
+ clusterCount: LAYER_PREFIX + uid + "-cluster-count"
+ };
+ this.below = null;
+ }
+ var proto = ScatterMap.prototype;
+ proto.addSource = function(k, opts, cluster) {
+ var sourceOpts = {
+ type: "geojson",
+ data: opts.geojson
+ };
+ if (cluster && cluster.enabled) {
+ Lib.extendFlat(sourceOpts, {
+ cluster: true,
+ clusterMaxZoom: cluster.maxzoom
+ });
+ }
+ var isSourceExists = this.subplot.map.getSource(this.sourceIds[k]);
+ if (isSourceExists) {
+ isSourceExists.setData(opts.geojson);
+ } else {
+ this.subplot.map.addSource(this.sourceIds[k], sourceOpts);
+ }
+ };
+ proto.setSourceData = function(k, opts) {
+ this.subplot.map.getSource(this.sourceIds[k]).setData(opts.geojson);
+ };
+ proto.addLayer = function(k, opts, below) {
+ var source = {
+ type: opts.type,
+ id: this.layerIds[k],
+ source: this.sourceIds[k],
+ layout: opts.layout,
+ paint: opts.paint
+ };
+ if (opts.filter) {
+ source.filter = opts.filter;
+ }
+ var currentLayerId = this.layerIds[k];
+ var layerExist;
+ var layers = this.subplot.getMapLayers();
+ for (var i = 0; i < layers.length; i++) {
+ if (layers[i].id === currentLayerId) {
+ layerExist = true;
+ break;
+ }
+ }
+ if (layerExist) {
+ this.subplot.setOptions(currentLayerId, "setLayoutProperty", source.layout);
+ if (source.layout.visibility === "visible") {
+ this.subplot.setOptions(currentLayerId, "setPaintProperty", source.paint);
+ }
+ } else {
+ this.subplot.addLayer(source, below);
+ }
+ };
+ proto.update = function update(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var subplot = this.subplot;
+ var map = subplot.map;
+ var optsAll = convert(subplot.gd, calcTrace);
+ var below = subplot.belowLookup["trace-" + this.uid];
+ var hasCluster = !!(trace.cluster && trace.cluster.enabled);
+ var hadCluster = !!this.clusterEnabled;
+ var lThis = this;
+ function addCluster(noSource) {
+ if (!noSource) lThis.addSource("circle", optsAll.circle, trace.cluster);
+ var order = ORDER.cluster;
+ for (var i = 0; i < order.length; i++) {
+ var k = order[i];
+ var opts = optsAll[k];
+ lThis.addLayer(k, opts, below);
+ }
+ }
+ function removeCluster(noSource) {
+ var order = ORDER.cluster;
+ for (var i = order.length - 1; i >= 0; i--) {
+ var k = order[i];
+ map.removeLayer(lThis.layerIds[k]);
+ }
+ if (!noSource) map.removeSource(lThis.sourceIds.circle);
+ }
+ function addNonCluster(noSource) {
+ var order = ORDER.nonCluster;
+ for (var i = 0; i < order.length; i++) {
+ var k = order[i];
+ var opts = optsAll[k];
+ if (!noSource) lThis.addSource(k, opts);
+ lThis.addLayer(k, opts, below);
+ }
+ }
+ function removeNonCluster(noSource) {
+ var order = ORDER.nonCluster;
+ for (var i = order.length - 1; i >= 0; i--) {
+ var k = order[i];
+ map.removeLayer(lThis.layerIds[k]);
+ if (!noSource) map.removeSource(lThis.sourceIds[k]);
+ }
+ }
+ function remove(noSource) {
+ if (hadCluster) removeCluster(noSource);
+ else removeNonCluster(noSource);
+ }
+ function add(noSource) {
+ if (hasCluster) addCluster(noSource);
+ else addNonCluster(noSource);
+ }
+ function repaint() {
+ var order = hasCluster ? ORDER.cluster : ORDER.nonCluster;
+ for (var i = 0; i < order.length; i++) {
+ var k = order[i];
+ var opts = optsAll[k];
+ if (!opts) continue;
+ subplot.setOptions(lThis.layerIds[k], "setLayoutProperty", opts.layout);
+ if (opts.layout.visibility === "visible") {
+ if (k !== "cluster") {
+ lThis.setSourceData(k, opts);
+ }
+ subplot.setOptions(lThis.layerIds[k], "setPaintProperty", opts.paint);
+ }
+ }
+ }
+ var wasHidden = this.isHidden;
+ var isHidden = trace.visible !== true;
+ if (isHidden) {
+ if (!wasHidden) remove();
+ } else if (wasHidden) {
+ if (!isHidden) add();
+ } else if (hadCluster !== hasCluster) {
+ remove();
+ add();
+ } else if (this.below !== below) {
+ remove(true);
+ add(true);
+ repaint();
+ } else {
+ repaint();
+ }
+ this.clusterEnabled = hasCluster;
+ this.isHidden = isHidden;
+ this.below = below;
+ calcTrace[0].trace._glTrace = this;
+ };
+ proto.dispose = function dispose() {
+ var map = this.subplot.map;
+ var order = this.clusterEnabled ? ORDER.cluster : ORDER.nonCluster;
+ for (var i = order.length - 1; i >= 0; i--) {
+ var k = order[i];
+ map.removeLayer(this.layerIds[k]);
+ map.removeSource(this.sourceIds[k]);
+ }
+ };
+ module.exports = function createScatterMap(subplot, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var hasCluster = trace.cluster && trace.cluster.enabled;
+ var isHidden = trace.visible !== true;
+ var scatterMap = new ScatterMap(
+ subplot,
+ trace.uid,
+ hasCluster,
+ isHidden
+ );
+ var optsAll = convert(subplot.gd, calcTrace);
+ var below = scatterMap.below = subplot.belowLookup["trace-" + trace.uid];
+ var i, k, opts;
+ if (hasCluster) {
+ scatterMap.addSource("circle", optsAll.circle, trace.cluster);
+ for (i = 0; i < ORDER.cluster.length; i++) {
+ k = ORDER.cluster[i];
+ opts = optsAll[k];
+ scatterMap.addLayer(k, opts, below);
+ }
+ } else {
+ for (i = 0; i < ORDER.nonCluster.length; i++) {
+ k = ORDER.nonCluster[i];
+ opts = optsAll[k];
+ scatterMap.addSource(k, opts, trace.cluster);
+ scatterMap.addLayer(k, opts, below);
+ }
+ }
+ calcTrace[0].trace._glTrace = scatterMap;
+ return scatterMap;
+ };
+ }
+ });
+
+ // src/traces/scattermap/hover.js
+ var require_hover20 = __commonJS({
+ "src/traces/scattermap/hover.js"(exports, module) {
+ "use strict";
+ var Fx = require_fx();
+ var Lib = require_lib();
+ var getTraceColor = require_get_trace_color();
+ var fillText = Lib.fillText;
+ var BADNUM = require_numerical().BADNUM;
+ var LAYER_PREFIX = require_constants27().traceLayerPrefix;
+ function hoverPoints(pointData, xval, yval) {
+ var cd = pointData.cd;
+ var trace = cd[0].trace;
+ var xa = pointData.xa;
+ var ya = pointData.ya;
+ var subplot = pointData.subplot;
+ var clusteredPointsIds = [];
+ var layer = LAYER_PREFIX + trace.uid + "-circle";
+ var hasCluster = trace.cluster && trace.cluster.enabled;
+ if (hasCluster) {
+ var elems = subplot.map.queryRenderedFeatures(null, { layers: [layer] });
+ clusteredPointsIds = elems.map(function(elem) {
+ return elem.id;
+ });
+ }
+ var winding = xval >= 0 ? Math.floor((xval + 180) / 360) : Math.ceil((xval - 180) / 360);
+ var lonShift = winding * 360;
+ var xval2 = xval - lonShift;
+ function distFn(d) {
+ var lonlat2 = d.lonlat;
+ if (lonlat2[0] === BADNUM) return Infinity;
+ if (hasCluster && clusteredPointsIds.indexOf(d.i + 1) === -1) return Infinity;
+ var lon = Lib.modHalf(lonlat2[0], 360);
+ var lat = lonlat2[1];
+ var pt = subplot.project([lon, lat]);
+ var dx = pt.x - xa.c2p([xval2, lat]);
+ var dy = pt.y - ya.c2p([lon, yval]);
+ var rad2 = Math.max(3, d.mrc || 0);
+ return Math.max(Math.sqrt(dx * dx + dy * dy) - rad2, 1 - 3 / rad2);
+ }
+ Fx.getClosest(cd, distFn, pointData);
+ if (pointData.index === false) return;
+ var di = cd[pointData.index];
+ var lonlat = di.lonlat;
+ var lonlatShifted = [Lib.modHalf(lonlat[0], 360) + lonShift, lonlat[1]];
+ var xc = xa.c2p(lonlatShifted);
+ var yc = ya.c2p(lonlatShifted);
+ var rad = di.mrc || 1;
+ pointData.x0 = xc - rad;
+ pointData.x1 = xc + rad;
+ pointData.y0 = yc - rad;
+ pointData.y1 = yc + rad;
+ var fullLayout = {};
+ fullLayout[trace.subplot] = { _subplot: subplot };
+ var labels = trace._module.formatLabels(di, trace, fullLayout);
+ pointData.lonLabel = labels.lonLabel;
+ pointData.latLabel = labels.latLabel;
+ pointData.color = getTraceColor(trace, di);
+ pointData.extraText = getExtraText(trace, di, cd[0].t.labels);
+ pointData.hovertemplate = trace.hovertemplate;
+ return [pointData];
+ }
+ function getExtraText(trace, di, labels) {
+ if (trace.hovertemplate) return;
+ var hoverinfo = di.hi || trace.hoverinfo;
+ var parts = hoverinfo.split("+");
+ var isAll = parts.indexOf("all") !== -1;
+ var hasLon = parts.indexOf("lon") !== -1;
+ var hasLat = parts.indexOf("lat") !== -1;
+ var lonlat = di.lonlat;
+ var text = [];
+ function format(v) {
+ return v + "\xB0";
+ }
+ if (isAll || hasLon && hasLat) {
+ text.push("(" + format(lonlat[1]) + ", " + format(lonlat[0]) + ")");
+ } else if (hasLon) {
+ text.push(labels.lon + format(lonlat[0]));
+ } else if (hasLat) {
+ text.push(labels.lat + format(lonlat[1]));
+ }
+ if (isAll || parts.indexOf("text") !== -1) {
+ fillText(di, trace, text);
+ }
+ return text.join("
");
+ }
+ module.exports = {
+ hoverPoints,
+ getExtraText
+ };
+ }
+ });
+
+ // src/traces/scattermap/event_data.js
+ var require_event_data13 = __commonJS({
+ "src/traces/scattermap/event_data.js"(exports, module) {
+ "use strict";
+ module.exports = function eventData(out, pt) {
+ out.lon = pt.lon;
+ out.lat = pt.lat;
+ return out;
+ };
+ }
+ });
+
+ // src/traces/scattermap/select.js
+ var require_select10 = __commonJS({
+ "src/traces/scattermap/select.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var subtypes = require_subtypes();
+ var BADNUM = require_numerical().BADNUM;
+ module.exports = function selectPoints(searchInfo, selectionTester) {
+ var cd = searchInfo.cd;
+ var xa = searchInfo.xaxis;
+ var ya = searchInfo.yaxis;
+ var selection = [];
+ var trace = cd[0].trace;
+ var i;
+ if (!subtypes.hasMarkers(trace)) return [];
+ if (selectionTester === false) {
+ for (i = 0; i < cd.length; i++) {
+ cd[i].selected = 0;
+ }
+ } else {
+ for (i = 0; i < cd.length; i++) {
+ var di = cd[i];
+ var lonlat = di.lonlat;
+ if (lonlat[0] !== BADNUM) {
+ var lonlat2 = [Lib.modHalf(lonlat[0], 360), lonlat[1]];
+ var xy = [xa.c2p(lonlat2), ya.c2p(lonlat2)];
+ if (selectionTester.contains(xy, null, i, searchInfo)) {
+ selection.push({
+ pointNumber: i,
+ lon: lonlat[0],
+ lat: lonlat[1]
+ });
+ di.selected = 1;
+ } else {
+ di.selected = 0;
+ }
+ }
+ }
+ }
+ return selection;
+ };
+ }
+ });
+
+ // node_modules/maplibre-gl/dist/maplibre-gl.js
+ var require_maplibre_gl = __commonJS({
+ "node_modules/maplibre-gl/dist/maplibre-gl.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && false ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.maplibregl = factory());
+ })(exports, function() {
+ "use strict";
+ var maplibregl = {};
+ var modules = {};
+ function define2(moduleName, _dependencies, moduleFactory) {
+ modules[moduleName] = moduleFactory;
+ if (moduleName !== "index") {
+ return;
+ }
+ var workerBundleString = "var sharedModule = {}; (" + modules.shared + ")(sharedModule); (" + modules.worker + ")(sharedModule);";
+ var sharedModule = {};
+ modules.shared(sharedModule);
+ modules.index(maplibregl, sharedModule);
+ if (typeof window !== "undefined") {
+ maplibregl.setWorkerUrl(window.URL.createObjectURL(new Blob([workerBundleString], { type: "text/javascript" })));
+ }
+ return maplibregl;
+ }
+ ;
+ define2("shared", ["exports"], function(t) {
+ "use strict";
+ function e(t4, e2, r2, n2) {
+ return new (r2 || (r2 = Promise))(function(i2, s2) {
+ function a2(t5) {
+ try {
+ l2(n2.next(t5));
+ } catch (t6) {
+ s2(t6);
+ }
+ }
+ function o2(t5) {
+ try {
+ l2(n2.throw(t5));
+ } catch (t6) {
+ s2(t6);
+ }
+ }
+ function l2(t5) {
+ var e3;
+ t5.done ? i2(t5.value) : (e3 = t5.value, e3 instanceof r2 ? e3 : new r2(function(t6) {
+ t6(e3);
+ })).then(a2, o2);
+ }
+ l2((n2 = n2.apply(t4, e2 || [])).next());
+ });
+ }
+ function r(t4) {
+ return t4 && t4.__esModule && Object.prototype.hasOwnProperty.call(t4, "default") ? t4.default : t4;
+ }
+ "function" == typeof SuppressedError && SuppressedError;
+ var n = i;
+ function i(t4, e2) {
+ this.x = t4, this.y = e2;
+ }
+ i.prototype = { clone: function() {
+ return new i(this.x, this.y);
+ }, add: function(t4) {
+ return this.clone()._add(t4);
+ }, sub: function(t4) {
+ return this.clone()._sub(t4);
+ }, multByPoint: function(t4) {
+ return this.clone()._multByPoint(t4);
+ }, divByPoint: function(t4) {
+ return this.clone()._divByPoint(t4);
+ }, mult: function(t4) {
+ return this.clone()._mult(t4);
+ }, div: function(t4) {
+ return this.clone()._div(t4);
+ }, rotate: function(t4) {
+ return this.clone()._rotate(t4);
+ }, rotateAround: function(t4, e2) {
+ return this.clone()._rotateAround(t4, e2);
+ }, matMult: function(t4) {
+ return this.clone()._matMult(t4);
+ }, 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(t4) {
+ return this.x === t4.x && this.y === t4.y;
+ }, dist: function(t4) {
+ return Math.sqrt(this.distSqr(t4));
+ }, distSqr: function(t4) {
+ var e2 = t4.x - this.x, r2 = t4.y - this.y;
+ return e2 * e2 + r2 * r2;
+ }, angle: function() {
+ return Math.atan2(this.y, this.x);
+ }, angleTo: function(t4) {
+ return Math.atan2(this.y - t4.y, this.x - t4.x);
+ }, angleWith: function(t4) {
+ return this.angleWithSep(t4.x, t4.y);
+ }, angleWithSep: function(t4, e2) {
+ return Math.atan2(this.x * e2 - this.y * t4, this.x * t4 + this.y * e2);
+ }, _matMult: function(t4) {
+ var e2 = t4[2] * this.x + t4[3] * this.y;
+ return this.x = t4[0] * this.x + t4[1] * this.y, this.y = e2, this;
+ }, _add: function(t4) {
+ return this.x += t4.x, this.y += t4.y, this;
+ }, _sub: function(t4) {
+ return this.x -= t4.x, this.y -= t4.y, this;
+ }, _mult: function(t4) {
+ return this.x *= t4, this.y *= t4, this;
+ }, _div: function(t4) {
+ return this.x /= t4, this.y /= t4, this;
+ }, _multByPoint: function(t4) {
+ return this.x *= t4.x, this.y *= t4.y, this;
+ }, _divByPoint: function(t4) {
+ return this.x /= t4.x, this.y /= t4.y, this;
+ }, _unit: function() {
+ return this._div(this.mag()), this;
+ }, _perp: function() {
+ var t4 = this.y;
+ return this.y = this.x, this.x = -t4, this;
+ }, _rotate: function(t4) {
+ var e2 = Math.cos(t4), r2 = Math.sin(t4), n2 = r2 * this.x + e2 * this.y;
+ return this.x = e2 * this.x - r2 * this.y, this.y = n2, this;
+ }, _rotateAround: function(t4, e2) {
+ var r2 = Math.cos(t4), n2 = Math.sin(t4), i2 = e2.y + n2 * (this.x - e2.x) + r2 * (this.y - e2.y);
+ return this.x = e2.x + r2 * (this.x - e2.x) - n2 * (this.y - e2.y), this.y = i2, this;
+ }, _round: function() {
+ return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
+ } }, i.convert = function(t4) {
+ return t4 instanceof i ? t4 : Array.isArray(t4) ? new i(t4[0], t4[1]) : t4;
+ };
+ var s = r(n), a = o;
+ function o(t4, e2, r2, n2) {
+ this.cx = 3 * t4, this.bx = 3 * (r2 - t4) - this.cx, this.ax = 1 - this.cx - this.bx, this.cy = 3 * e2, this.by = 3 * (n2 - e2) - this.cy, this.ay = 1 - this.cy - this.by, this.p1x = t4, this.p1y = e2, this.p2x = r2, this.p2y = n2;
+ }
+ o.prototype = { sampleCurveX: function(t4) {
+ return ((this.ax * t4 + this.bx) * t4 + this.cx) * t4;
+ }, sampleCurveY: function(t4) {
+ return ((this.ay * t4 + this.by) * t4 + this.cy) * t4;
+ }, sampleCurveDerivativeX: function(t4) {
+ return (3 * this.ax * t4 + 2 * this.bx) * t4 + this.cx;
+ }, solveCurveX: function(t4, e2) {
+ if (void 0 === e2 && (e2 = 1e-6), t4 < 0) return 0;
+ if (t4 > 1) return 1;
+ for (var r2 = t4, n2 = 0; n2 < 8; n2++) {
+ var i2 = this.sampleCurveX(r2) - t4;
+ if (Math.abs(i2) < e2) return r2;
+ var s2 = this.sampleCurveDerivativeX(r2);
+ if (Math.abs(s2) < 1e-6) break;
+ r2 -= i2 / s2;
+ }
+ var a2 = 0, o2 = 1;
+ for (r2 = t4, n2 = 0; n2 < 20 && (i2 = this.sampleCurveX(r2), !(Math.abs(i2 - t4) < e2)); n2++) t4 > i2 ? a2 = r2 : o2 = r2, r2 = 0.5 * (o2 - a2) + a2;
+ return r2;
+ }, solve: function(t4, e2) {
+ return this.sampleCurveY(this.solveCurveX(t4, e2));
+ } };
+ var l = r(a);
+ let u, c;
+ function h() {
+ return null == u && (u = "undefined" != typeof OffscreenCanvas && new OffscreenCanvas(1, 1).getContext("2d") && "function" == typeof createImageBitmap), u;
+ }
+ function p() {
+ if (null == c && (c = false, h())) {
+ const t4 = 5, e2 = new OffscreenCanvas(t4, t4).getContext("2d", { willReadFrequently: true });
+ if (e2) {
+ for (let r3 = 0; r3 < t4 * t4; r3++) {
+ const n2 = 4 * r3;
+ e2.fillStyle = `rgb(${n2},${n2 + 1},${n2 + 2})`, e2.fillRect(r3 % t4, Math.floor(r3 / t4), 1, 1);
+ }
+ const r2 = e2.getImageData(0, 0, t4, t4).data;
+ for (let e3 = 0; e3 < t4 * t4 * 4; e3++) if (e3 % 4 != 3 && r2[e3] !== e3) {
+ c = true;
+ break;
+ }
+ }
+ }
+ return c || false;
+ }
+ function f(t4, e2, r2, n2) {
+ const i2 = new l(t4, e2, r2, n2);
+ return (t5) => i2.solve(t5);
+ }
+ const d = f(0.25, 0.1, 0.25, 1);
+ function y(t4, e2, r2) {
+ return Math.min(r2, Math.max(e2, t4));
+ }
+ function m(t4, e2, r2) {
+ const n2 = r2 - e2, i2 = ((t4 - e2) % n2 + n2) % n2 + e2;
+ return i2 === e2 ? r2 : i2;
+ }
+ function g(t4, ...e2) {
+ for (const r2 of e2) for (const e3 in r2) t4[e3] = r2[e3];
+ return t4;
+ }
+ let x = 1;
+ function v(t4, e2, r2) {
+ const n2 = {};
+ for (const r3 in t4) n2[r3] = e2.call(this, t4[r3], r3, t4);
+ return n2;
+ }
+ function b(t4, e2, r2) {
+ const n2 = {};
+ for (const r3 in t4) e2.call(this, t4[r3], r3, t4) && (n2[r3] = t4[r3]);
+ return n2;
+ }
+ function w(t4) {
+ return Array.isArray(t4) ? t4.map(w) : "object" == typeof t4 && t4 ? v(t4, w) : t4;
+ }
+ const _ = {};
+ function A2(t4) {
+ _[t4] || ("undefined" != typeof console && console.warn(t4), _[t4] = true);
+ }
+ function S(t4, e2, r2) {
+ return (r2.y - t4.y) * (e2.x - t4.x) > (e2.y - t4.y) * (r2.x - t4.x);
+ }
+ function k(t4) {
+ return "undefined" != typeof WorkerGlobalScope && void 0 !== t4 && t4 instanceof WorkerGlobalScope;
+ }
+ let M = null;
+ function I(t4) {
+ return "undefined" != typeof ImageBitmap && t4 instanceof ImageBitmap;
+ }
+ const z = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";
+ function P(t4, r2, n2, i2, s2) {
+ return e(this, void 0, void 0, function* () {
+ if ("undefined" == typeof VideoFrame) throw new Error("VideoFrame not supported");
+ const e2 = new VideoFrame(t4, { timestamp: 0 });
+ try {
+ const a2 = null == e2 ? void 0 : e2.format;
+ if (!a2 || !a2.startsWith("BGR") && !a2.startsWith("RGB")) throw new Error(`Unrecognized format ${a2}`);
+ const o2 = a2.startsWith("BGR"), l2 = new Uint8ClampedArray(i2 * s2 * 4);
+ if (yield e2.copyTo(l2, function(t5, e3, r3, n3, i3) {
+ const s3 = 4 * Math.max(-e3, 0), a3 = (Math.max(0, r3) - r3) * n3 * 4 + s3, o3 = 4 * n3, l3 = Math.max(0, e3), u2 = Math.max(0, r3);
+ return { rect: { x: l3, y: u2, width: Math.min(t5.width, e3 + n3) - l3, height: Math.min(t5.height, r3 + i3) - u2 }, layout: [{ offset: a3, stride: o3 }] };
+ }(t4, r2, n2, i2, s2)), o2) for (let t5 = 0; t5 < l2.length; t5 += 4) {
+ const e3 = l2[t5];
+ l2[t5] = l2[t5 + 2], l2[t5 + 2] = e3;
+ }
+ return l2;
+ } finally {
+ e2.close();
+ }
+ });
+ }
+ let C2, B2;
+ const V = "AbortError";
+ function E2() {
+ return new Error(V);
+ }
+ const F = { MAX_PARALLEL_IMAGE_REQUESTS: 16, MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: 8, MAX_TILE_CACHE_ZOOM_LEVELS: 5, REGISTERED_PROTOCOLS: {}, WORKER_URL: "" };
+ function T(t4) {
+ return F.REGISTERED_PROTOCOLS[t4.substring(0, t4.indexOf("://"))];
+ }
+ const $ = "global-dispatcher";
+ class L extends Error {
+ constructor(t4, e2, r2, n2) {
+ super(`AJAXError: ${e2} (${t4}): ${r2}`), this.status = t4, this.statusText = e2, this.url = r2, this.body = n2;
+ }
+ }
+ const D2 = () => k(self) ? self.worker && self.worker.referrer : ("blob:" === window.location.protocol ? window.parent : window).location.href, O = function(t4, r2) {
+ if (/:\/\//.test(t4.url) && !/^https?:|^file:/.test(t4.url)) {
+ const e2 = T(t4.url);
+ if (e2) return e2(t4, r2);
+ if (k(self) && self.worker && self.worker.actor) return self.worker.actor.sendAsync({ type: "GR", data: t4, targetMapId: $ }, r2);
+ }
+ if (!(/^file:/.test(n2 = t4.url) || /^file:/.test(D2()) && !/^\w+:/.test(n2))) {
+ if (fetch && Request && AbortController && Object.prototype.hasOwnProperty.call(Request.prototype, "signal")) return function(t5, r3) {
+ return e(this, void 0, void 0, function* () {
+ const e2 = new Request(t5.url, { method: t5.method || "GET", body: t5.body, credentials: t5.credentials, headers: t5.headers, cache: t5.cache, referrer: D2(), signal: r3.signal });
+ "json" !== t5.type || e2.headers.has("Accept") || e2.headers.set("Accept", "application/json");
+ const n3 = yield fetch(e2);
+ if (!n3.ok) {
+ const e3 = yield n3.blob();
+ throw new L(n3.status, n3.statusText, t5.url, e3);
+ }
+ let i2;
+ i2 = "arrayBuffer" === t5.type || "image" === t5.type ? n3.arrayBuffer() : "json" === t5.type ? n3.json() : n3.text();
+ const s2 = yield i2;
+ if (r3.signal.aborted) throw E2();
+ return { data: s2, cacheControl: n3.headers.get("Cache-Control"), expires: n3.headers.get("Expires") };
+ });
+ }(t4, r2);
+ if (k(self) && self.worker && self.worker.actor) return self.worker.actor.sendAsync({ type: "GR", data: t4, mustQueue: true, targetMapId: $ }, r2);
+ }
+ var n2;
+ return function(t5, e2) {
+ return new Promise((r3, n3) => {
+ var i2;
+ const s2 = new XMLHttpRequest();
+ s2.open(t5.method || "GET", t5.url, true), "arrayBuffer" !== t5.type && "image" !== t5.type || (s2.responseType = "arraybuffer");
+ for (const e3 in t5.headers) s2.setRequestHeader(e3, t5.headers[e3]);
+ "json" === t5.type && (s2.responseType = "text", (null === (i2 = t5.headers) || void 0 === i2 ? void 0 : i2.Accept) || s2.setRequestHeader("Accept", "application/json")), s2.withCredentials = "include" === t5.credentials, s2.onerror = () => {
+ n3(new Error(s2.statusText));
+ }, s2.onload = () => {
+ if (!e2.signal.aborted) if ((s2.status >= 200 && s2.status < 300 || 0 === s2.status) && null !== s2.response) {
+ let e3 = s2.response;
+ if ("json" === t5.type) try {
+ e3 = JSON.parse(s2.response);
+ } catch (t6) {
+ return void n3(t6);
+ }
+ r3({ data: e3, cacheControl: s2.getResponseHeader("Cache-Control"), expires: s2.getResponseHeader("Expires") });
+ } else {
+ const e3 = new Blob([s2.response], { type: s2.getResponseHeader("Content-Type") });
+ n3(new L(s2.status, s2.statusText, t5.url, e3));
+ }
+ }, e2.signal.addEventListener("abort", () => {
+ s2.abort(), n3(E2());
+ }), s2.send(t5.body);
+ });
+ }(t4, r2);
+ };
+ function j(t4) {
+ if (!t4 || t4.indexOf("://") <= 0 || 0 === t4.indexOf("data:image/") || 0 === t4.indexOf("blob:")) return true;
+ const e2 = new URL(t4), r2 = window.location;
+ return e2.protocol === r2.protocol && e2.host === r2.host;
+ }
+ function R(t4, e2, r2) {
+ r2[t4] && -1 !== r2[t4].indexOf(e2) || (r2[t4] = r2[t4] || [], r2[t4].push(e2));
+ }
+ function U(t4, e2, r2) {
+ if (r2 && r2[t4]) {
+ const n2 = r2[t4].indexOf(e2);
+ -1 !== n2 && r2[t4].splice(n2, 1);
+ }
+ }
+ class q {
+ constructor(t4, e2 = {}) {
+ g(this, e2), this.type = t4;
+ }
+ }
+ class N extends q {
+ constructor(t4, e2 = {}) {
+ super("error", g({ error: t4 }, e2));
+ }
+ }
+ class Z {
+ on(t4, e2) {
+ return this._listeners = this._listeners || {}, R(t4, e2, this._listeners), this;
+ }
+ off(t4, e2) {
+ return U(t4, e2, this._listeners), U(t4, e2, this._oneTimeListeners), this;
+ }
+ once(t4, e2) {
+ return e2 ? (this._oneTimeListeners = this._oneTimeListeners || {}, R(t4, e2, this._oneTimeListeners), this) : new Promise((e3) => this.once(t4, e3));
+ }
+ fire(t4, e2) {
+ "string" == typeof t4 && (t4 = new q(t4, e2 || {}));
+ const r2 = t4.type;
+ if (this.listens(r2)) {
+ t4.target = this;
+ const e3 = this._listeners && this._listeners[r2] ? this._listeners[r2].slice() : [];
+ for (const r3 of e3) r3.call(this, t4);
+ const n2 = this._oneTimeListeners && this._oneTimeListeners[r2] ? this._oneTimeListeners[r2].slice() : [];
+ for (const e4 of n2) U(r2, e4, this._oneTimeListeners), e4.call(this, t4);
+ const i2 = this._eventedParent;
+ i2 && (g(t4, "function" == typeof this._eventedParentData ? this._eventedParentData() : this._eventedParentData), i2.fire(t4));
+ } else t4 instanceof N && console.error(t4.error);
+ return this;
+ }
+ listens(t4) {
+ return this._listeners && this._listeners[t4] && this._listeners[t4].length > 0 || this._oneTimeListeners && this._oneTimeListeners[t4] && this._oneTimeListeners[t4].length > 0 || this._eventedParent && this._eventedParent.listens(t4);
+ }
+ setEventedParent(t4, e2) {
+ return this._eventedParent = t4, this._eventedParentData = e2, this;
+ }
+ }
+ var G = { $version: 8, $root: { version: { required: true, type: "enum", values: [8] }, name: { type: "string" }, metadata: { type: "*" }, center: { type: "array", value: "number" }, zoom: { type: "number" }, bearing: { type: "number", default: 0, period: 360, units: "degrees" }, pitch: { type: "number", default: 0, units: "degrees" }, light: { type: "light" }, sky: { type: "sky" }, projection: { type: "projection" }, terrain: { type: "terrain" }, sources: { required: true, type: "sources" }, sprite: { type: "sprite" }, glyphs: { type: "string" }, transition: { type: "transition" }, layers: { required: true, type: "array", value: "layer" } }, sources: { "*": { type: "source" } }, source: ["source_vector", "source_raster", "source_raster_dem", "source_geojson", "source_video", "source_image"], source_vector: { type: { required: true, type: "enum", values: { vector: {} } }, url: { type: "string" }, tiles: { type: "array", value: "string" }, bounds: { type: "array", value: "number", length: 4, default: [-180, -85.051129, 180, 85.051129] }, scheme: { type: "enum", values: { xyz: {}, tms: {} }, default: "xyz" }, minzoom: { type: "number", default: 0 }, maxzoom: { type: "number", default: 22 }, attribution: { type: "string" }, promoteId: { type: "promoteId" }, volatile: { type: "boolean", default: false }, "*": { type: "*" } }, source_raster: { type: { required: true, type: "enum", values: { raster: {} } }, url: { type: "string" }, tiles: { type: "array", value: "string" }, bounds: { type: "array", value: "number", length: 4, default: [-180, -85.051129, 180, 85.051129] }, minzoom: { type: "number", default: 0 }, maxzoom: { type: "number", default: 22 }, tileSize: { type: "number", default: 512, units: "pixels" }, scheme: { type: "enum", values: { xyz: {}, tms: {} }, default: "xyz" }, attribution: { type: "string" }, volatile: { type: "boolean", default: false }, "*": { type: "*" } }, source_raster_dem: { type: { required: true, type: "enum", values: { "raster-dem": {} } }, url: { type: "string" }, tiles: { type: "array", value: "string" }, bounds: { type: "array", value: "number", length: 4, default: [-180, -85.051129, 180, 85.051129] }, minzoom: { type: "number", default: 0 }, maxzoom: { type: "number", default: 22 }, tileSize: { type: "number", default: 512, units: "pixels" }, attribution: { type: "string" }, encoding: { type: "enum", values: { terrarium: {}, mapbox: {}, custom: {} }, default: "mapbox" }, redFactor: { type: "number", default: 1 }, blueFactor: { type: "number", default: 1 }, greenFactor: { type: "number", default: 1 }, baseShift: { type: "number", default: 0 }, volatile: { type: "boolean", default: false }, "*": { type: "*" } }, source_geojson: { type: { required: true, type: "enum", values: { geojson: {} } }, data: { required: true, type: "*" }, maxzoom: { type: "number", default: 18 }, attribution: { type: "string" }, buffer: { type: "number", default: 128, maximum: 512, minimum: 0 }, filter: { type: "*" }, tolerance: { type: "number", default: 0.375 }, cluster: { type: "boolean", default: false }, clusterRadius: { type: "number", default: 50, minimum: 0 }, clusterMaxZoom: { type: "number" }, clusterMinPoints: { type: "number" }, clusterProperties: { type: "*" }, lineMetrics: { type: "boolean", default: false }, generateId: { type: "boolean", default: false }, promoteId: { type: "promoteId" } }, source_video: { type: { required: true, type: "enum", values: { video: {} } }, urls: { required: true, type: "array", value: "string" }, coordinates: { required: true, type: "array", length: 4, value: { type: "array", length: 2, value: "number" } } }, source_image: { type: { required: true, type: "enum", values: { image: {} } }, url: { required: true, type: "string" }, coordinates: { required: true, type: "array", length: 4, value: { type: "array", length: 2, value: "number" } } }, layer: { id: { type: "string", required: true }, type: { type: "enum", values: { fill: {}, line: {}, symbol: {}, circle: {}, heatmap: {}, "fill-extrusion": {}, raster: {}, hillshade: {}, background: {} }, required: true }, metadata: { type: "*" }, source: { type: "string" }, "source-layer": { type: "string" }, minzoom: { type: "number", minimum: 0, maximum: 24 }, maxzoom: { type: "number", minimum: 0, maximum: 24 }, filter: { type: "filter" }, layout: { type: "layout" }, paint: { type: "paint" } }, layout: ["layout_fill", "layout_line", "layout_circle", "layout_heatmap", "layout_fill-extrusion", "layout_symbol", "layout_raster", "layout_hillshade", "layout_background"], layout_background: { visibility: { type: "enum", values: { visible: {}, none: {} }, default: "visible", "property-type": "constant" } }, layout_fill: { "fill-sort-key": { type: "number", expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, visibility: { type: "enum", values: { visible: {}, none: {} }, default: "visible", "property-type": "constant" } }, layout_circle: { "circle-sort-key": { type: "number", expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, visibility: { type: "enum", values: { visible: {}, none: {} }, default: "visible", "property-type": "constant" } }, layout_heatmap: { visibility: { type: "enum", values: { visible: {}, none: {} }, default: "visible", "property-type": "constant" } }, "layout_fill-extrusion": { visibility: { type: "enum", values: { visible: {}, none: {} }, default: "visible", "property-type": "constant" } }, layout_line: { "line-cap": { type: "enum", values: { butt: {}, round: {}, square: {} }, default: "butt", expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "line-join": { type: "enum", values: { bevel: {}, round: {}, miter: {} }, default: "miter", expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "line-miter-limit": { type: "number", default: 2, requires: [{ "line-join": "miter" }], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "line-round-limit": { type: "number", default: 1.05, requires: [{ "line-join": "round" }], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "line-sort-key": { type: "number", expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, visibility: { type: "enum", values: { visible: {}, none: {} }, default: "visible", "property-type": "constant" } }, layout_symbol: { "symbol-placement": { type: "enum", values: { point: {}, line: {}, "line-center": {} }, default: "point", expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "symbol-spacing": { type: "number", default: 250, minimum: 1, units: "pixels", requires: [{ "symbol-placement": "line" }], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "symbol-avoid-edges": { type: "boolean", default: false, expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "symbol-sort-key": { type: "number", expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "symbol-z-order": { type: "enum", values: { auto: {}, "viewport-y": {}, source: {} }, default: "auto", expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-allow-overlap": { type: "boolean", default: false, requires: ["icon-image", { "!": "icon-overlap" }], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-overlap": { type: "enum", values: { never: {}, always: {}, cooperative: {} }, requires: ["icon-image"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-ignore-placement": { type: "boolean", default: false, requires: ["icon-image"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-optional": { type: "boolean", default: false, requires: ["icon-image", "text-field"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-rotation-alignment": { type: "enum", values: { map: {}, viewport: {}, auto: {} }, default: "auto", requires: ["icon-image"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-size": { type: "number", default: 1, minimum: 0, units: "factor of the original icon size", requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "icon-text-fit": { type: "enum", values: { none: {}, width: {}, height: {}, both: {} }, default: "none", requires: ["icon-image", "text-field"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-text-fit-padding": { type: "array", value: "number", length: 4, default: [0, 0, 0, 0], units: "pixels", requires: ["icon-image", "text-field", { "icon-text-fit": ["both", "width", "height"] }], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-image": { type: "resolvedImage", tokens: true, expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "icon-rotate": { type: "number", default: 0, period: 360, units: "degrees", requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "icon-padding": { type: "padding", default: [2], units: "pixels", requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "icon-keep-upright": { type: "boolean", default: false, requires: ["icon-image", { "icon-rotation-alignment": "map" }, { "symbol-placement": ["line", "line-center"] }], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-offset": { type: "array", value: "number", length: 2, default: [0, 0], requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "icon-anchor": { type: "enum", values: { center: {}, left: {}, right: {}, top: {}, bottom: {}, "top-left": {}, "top-right": {}, "bottom-left": {}, "bottom-right": {} }, default: "center", requires: ["icon-image"], expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "icon-pitch-alignment": { type: "enum", values: { map: {}, viewport: {}, auto: {} }, default: "auto", requires: ["icon-image"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-pitch-alignment": { type: "enum", values: { map: {}, viewport: {}, auto: {} }, default: "auto", requires: ["text-field"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-rotation-alignment": { type: "enum", values: { map: {}, viewport: {}, "viewport-glyph": {}, auto: {} }, default: "auto", requires: ["text-field"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-field": { type: "formatted", default: "", tokens: true, expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-font": { type: "array", value: "string", default: ["Open Sans Regular", "Arial Unicode MS Regular"], requires: ["text-field"], expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-size": { type: "number", default: 16, minimum: 0, units: "pixels", requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-max-width": { type: "number", default: 10, minimum: 0, units: "ems", requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-line-height": { type: "number", default: 1.2, units: "ems", requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-letter-spacing": { type: "number", default: 0, units: "ems", requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-justify": { type: "enum", values: { auto: {}, left: {}, center: {}, right: {} }, default: "center", requires: ["text-field"], expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-radial-offset": { type: "number", units: "ems", default: 0, requires: ["text-field"], "property-type": "data-driven", expression: { interpolated: true, parameters: ["zoom", "feature"] } }, "text-variable-anchor": { type: "array", value: "enum", values: { center: {}, left: {}, right: {}, top: {}, bottom: {}, "top-left": {}, "top-right": {}, "bottom-left": {}, "bottom-right": {} }, requires: ["text-field", { "symbol-placement": ["point"] }], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-variable-anchor-offset": { type: "variableAnchorOffsetCollection", requires: ["text-field", { "symbol-placement": ["point"] }], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-anchor": { type: "enum", values: { center: {}, left: {}, right: {}, top: {}, bottom: {}, "top-left": {}, "top-right": {}, "bottom-left": {}, "bottom-right": {} }, default: "center", requires: ["text-field", { "!": "text-variable-anchor" }], expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-max-angle": { type: "number", default: 45, units: "degrees", requires: ["text-field", { "symbol-placement": ["line", "line-center"] }], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-writing-mode": { type: "array", value: "enum", values: { horizontal: {}, vertical: {} }, requires: ["text-field", { "symbol-placement": ["point"] }], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-rotate": { type: "number", default: 0, period: 360, units: "degrees", requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-padding": { type: "number", default: 2, minimum: 0, units: "pixels", requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-keep-upright": { type: "boolean", default: true, requires: ["text-field", { "text-rotation-alignment": "map" }, { "symbol-placement": ["line", "line-center"] }], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-transform": { type: "enum", values: { none: {}, uppercase: {}, lowercase: {} }, default: "none", requires: ["text-field"], expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-offset": { type: "array", value: "number", units: "ems", length: 2, default: [0, 0], requires: ["text-field", { "!": "text-radial-offset" }], expression: { interpolated: true, parameters: ["zoom", "feature"] }, "property-type": "data-driven" }, "text-allow-overlap": { type: "boolean", default: false, requires: ["text-field", { "!": "text-overlap" }], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-overlap": { type: "enum", values: { never: {}, always: {}, cooperative: {} }, requires: ["text-field"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-ignore-placement": { type: "boolean", default: false, requires: ["text-field"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-optional": { type: "boolean", default: false, requires: ["text-field", "icon-image"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, visibility: { type: "enum", values: { visible: {}, none: {} }, default: "visible", "property-type": "constant" } }, layout_raster: { visibility: { type: "enum", values: { visible: {}, none: {} }, default: "visible", "property-type": "constant" } }, layout_hillshade: { visibility: { type: "enum", values: { visible: {}, none: {} }, default: "visible", "property-type": "constant" } }, filter: { type: "array", value: "*" }, filter_operator: { type: "enum", values: { "==": {}, "!=": {}, ">": {}, ">=": {}, "<": {}, "<=": {}, in: {}, "!in": {}, all: {}, any: {}, none: {}, has: {}, "!has": {} } }, geometry_type: { type: "enum", values: { Point: {}, LineString: {}, Polygon: {} } }, function: { expression: { type: "expression" }, stops: { type: "array", value: "function_stop" }, base: { type: "number", default: 1, minimum: 0 }, property: { type: "string", default: "$zoom" }, type: { type: "enum", values: { identity: {}, exponential: {}, interval: {}, categorical: {} }, default: "exponential" }, colorSpace: { type: "enum", values: { rgb: {}, lab: {}, hcl: {} }, default: "rgb" }, default: { type: "*", required: false } }, function_stop: { type: "array", minimum: 0, maximum: 24, value: ["number", "color"], length: 2 }, expression: { type: "array", value: "*", minimum: 1 }, light: { anchor: { type: "enum", default: "viewport", values: { map: {}, viewport: {} }, "property-type": "data-constant", transition: false, expression: { interpolated: false, parameters: ["zoom"] } }, position: { type: "array", default: [1.15, 210, 30], length: 3, value: "number", "property-type": "data-constant", transition: true, expression: { interpolated: true, parameters: ["zoom"] } }, color: { type: "color", "property-type": "data-constant", default: "#ffffff", expression: { interpolated: true, parameters: ["zoom"] }, transition: true }, intensity: { type: "number", "property-type": "data-constant", default: 0.5, minimum: 0, maximum: 1, expression: { interpolated: true, parameters: ["zoom"] }, transition: true } }, sky: { "sky-color": { type: "color", "property-type": "data-constant", default: "#88C6FC", expression: { interpolated: true, parameters: ["zoom"] }, transition: true }, "horizon-color": { type: "color", "property-type": "data-constant", default: "#ffffff", expression: { interpolated: true, parameters: ["zoom"] }, transition: true }, "fog-color": { type: "color", "property-type": "data-constant", default: "#ffffff", expression: { interpolated: true, parameters: ["zoom"] }, transition: true }, "fog-ground-blend": { type: "number", "property-type": "data-constant", default: 0.5, minimum: 0, maximum: 1, expression: { interpolated: true, parameters: ["zoom"] }, transition: true }, "horizon-fog-blend": { type: "number", "property-type": "data-constant", default: 0.8, minimum: 0, maximum: 1, expression: { interpolated: true, parameters: ["zoom"] }, transition: true }, "sky-horizon-blend": { type: "number", "property-type": "data-constant", default: 0.8, minimum: 0, maximum: 1, expression: { interpolated: true, parameters: ["zoom"] }, transition: true }, "atmosphere-blend": { type: "number", "property-type": "data-constant", default: 0.8, minimum: 0, maximum: 1, expression: { interpolated: true, parameters: ["zoom"] }, transition: true } }, terrain: { source: { type: "string", required: true }, exaggeration: { type: "number", minimum: 0, default: 1 } }, projection: { type: { type: "enum", default: "mercator", values: { mercator: {}, globe: {} } } }, paint: ["paint_fill", "paint_line", "paint_circle", "paint_heatmap", "paint_fill-extrusion", "paint_symbol", "paint_raster", "paint_hillshade", "paint_background"], paint_fill: { "fill-antialias": { type: "boolean", default: true, expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "fill-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "fill-color": { type: "color", default: "#000000", transition: true, requires: [{ "!": "fill-pattern" }], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "fill-outline-color": { type: "color", transition: true, requires: [{ "!": "fill-pattern" }, { "fill-antialias": true }], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "fill-translate": { type: "array", value: "number", length: 2, default: [0, 0], transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "fill-translate-anchor": { type: "enum", values: { map: {}, viewport: {} }, default: "map", requires: ["fill-translate"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "fill-pattern": { type: "resolvedImage", transition: true, expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "cross-faded-data-driven" } }, "paint_fill-extrusion": { "fill-extrusion-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "fill-extrusion-color": { type: "color", default: "#000000", transition: true, requires: [{ "!": "fill-extrusion-pattern" }], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "fill-extrusion-translate": { type: "array", value: "number", length: 2, default: [0, 0], transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "fill-extrusion-translate-anchor": { type: "enum", values: { map: {}, viewport: {} }, default: "map", requires: ["fill-extrusion-translate"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "fill-extrusion-pattern": { type: "resolvedImage", transition: true, expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "cross-faded-data-driven" }, "fill-extrusion-height": { type: "number", default: 0, minimum: 0, units: "meters", transition: true, expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "fill-extrusion-base": { type: "number", default: 0, minimum: 0, units: "meters", transition: true, requires: ["fill-extrusion-height"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "fill-extrusion-vertical-gradient": { type: "boolean", default: true, transition: false, expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" } }, paint_line: { "line-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "line-color": { type: "color", default: "#000000", transition: true, requires: [{ "!": "line-pattern" }], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "line-translate": { type: "array", value: "number", length: 2, default: [0, 0], transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "line-translate-anchor": { type: "enum", values: { map: {}, viewport: {} }, default: "map", requires: ["line-translate"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "line-width": { type: "number", default: 1, minimum: 0, transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "line-gap-width": { type: "number", default: 0, minimum: 0, transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "line-offset": { type: "number", default: 0, transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "line-blur": { type: "number", default: 0, minimum: 0, transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "line-dasharray": { type: "array", value: "number", minimum: 0, transition: true, units: "line widths", requires: [{ "!": "line-pattern" }], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "cross-faded" }, "line-pattern": { type: "resolvedImage", transition: true, expression: { interpolated: false, parameters: ["zoom", "feature"] }, "property-type": "cross-faded-data-driven" }, "line-gradient": { type: "color", transition: false, requires: [{ "!": "line-dasharray" }, { "!": "line-pattern" }, { source: "geojson", has: { lineMetrics: true } }], expression: { interpolated: true, parameters: ["line-progress"] }, "property-type": "color-ramp" } }, paint_circle: { "circle-radius": { type: "number", default: 5, minimum: 0, transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "circle-color": { type: "color", default: "#000000", transition: true, expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "circle-blur": { type: "number", default: 0, transition: true, expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "circle-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "circle-translate": { type: "array", value: "number", length: 2, default: [0, 0], transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "circle-translate-anchor": { type: "enum", values: { map: {}, viewport: {} }, default: "map", requires: ["circle-translate"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "circle-pitch-scale": { type: "enum", values: { map: {}, viewport: {} }, default: "map", expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "circle-pitch-alignment": { type: "enum", values: { map: {}, viewport: {} }, default: "viewport", expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "circle-stroke-width": { type: "number", default: 0, minimum: 0, transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "circle-stroke-color": { type: "color", default: "#000000", transition: true, expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "circle-stroke-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" } }, paint_heatmap: { "heatmap-radius": { type: "number", default: 30, minimum: 1, transition: true, units: "pixels", expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "heatmap-weight": { type: "number", default: 1, minimum: 0, transition: false, expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "heatmap-intensity": { type: "number", default: 1, minimum: 0, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "heatmap-color": { type: "color", default: ["interpolate", ["linear"], ["heatmap-density"], 0, "rgba(0, 0, 255, 0)", 0.1, "royalblue", 0.3, "cyan", 0.5, "lime", 0.7, "yellow", 1, "red"], transition: false, expression: { interpolated: true, parameters: ["heatmap-density"] }, "property-type": "color-ramp" }, "heatmap-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" } }, paint_symbol: { "icon-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "icon-color": { type: "color", default: "#000000", transition: true, requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "icon-halo-color": { type: "color", default: "rgba(0, 0, 0, 0)", transition: true, requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "icon-halo-width": { type: "number", default: 0, minimum: 0, transition: true, units: "pixels", requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "icon-halo-blur": { type: "number", default: 0, minimum: 0, transition: true, units: "pixels", requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "icon-translate": { type: "array", value: "number", length: 2, default: [0, 0], transition: true, units: "pixels", requires: ["icon-image"], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "icon-translate-anchor": { type: "enum", values: { map: {}, viewport: {} }, default: "map", requires: ["icon-image", "icon-translate"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "text-color": { type: "color", default: "#000000", transition: true, overridable: true, requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "text-halo-color": { type: "color", default: "rgba(0, 0, 0, 0)", transition: true, requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "text-halo-width": { type: "number", default: 0, minimum: 0, transition: true, units: "pixels", requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "text-halo-blur": { type: "number", default: 0, minimum: 0, transition: true, units: "pixels", requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom", "feature", "feature-state"] }, "property-type": "data-driven" }, "text-translate": { type: "array", value: "number", length: 2, default: [0, 0], transition: true, units: "pixels", requires: ["text-field"], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "text-translate-anchor": { type: "enum", values: { map: {}, viewport: {} }, default: "map", requires: ["text-field", "text-translate"], expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" } }, paint_raster: { "raster-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "raster-hue-rotate": { type: "number", default: 0, period: 360, transition: true, units: "degrees", expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "raster-brightness-min": { type: "number", default: 0, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "raster-brightness-max": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "raster-saturation": { type: "number", default: 0, minimum: -1, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "raster-contrast": { type: "number", default: 0, minimum: -1, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "raster-resampling": { type: "enum", values: { linear: {}, nearest: {} }, default: "linear", expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "raster-fade-duration": { type: "number", default: 300, minimum: 0, transition: false, units: "milliseconds", expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" } }, paint_hillshade: { "hillshade-illumination-direction": { type: "number", default: 335, minimum: 0, maximum: 359, transition: false, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "hillshade-illumination-anchor": { type: "enum", values: { map: {}, viewport: {} }, default: "viewport", expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "data-constant" }, "hillshade-exaggeration": { type: "number", default: 0.5, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "hillshade-shadow-color": { type: "color", default: "#000000", transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "hillshade-highlight-color": { type: "color", default: "#FFFFFF", transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "hillshade-accent-color": { type: "color", default: "#000000", transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" } }, paint_background: { "background-color": { type: "color", default: "#000000", transition: true, requires: [{ "!": "background-pattern" }], expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" }, "background-pattern": { type: "resolvedImage", transition: true, expression: { interpolated: false, parameters: ["zoom"] }, "property-type": "cross-faded" }, "background-opacity": { type: "number", default: 1, minimum: 0, maximum: 1, transition: true, expression: { interpolated: true, parameters: ["zoom"] }, "property-type": "data-constant" } }, transition: { duration: { type: "number", default: 300, minimum: 0, units: "milliseconds" }, delay: { type: "number", default: 0, minimum: 0, units: "milliseconds" } }, "property-type": { "data-driven": { type: "property-type" }, "cross-faded": { type: "property-type" }, "cross-faded-data-driven": { type: "property-type" }, "color-ramp": { type: "property-type" }, "data-constant": { type: "property-type" }, constant: { type: "property-type" } }, promoteId: { "*": { type: "string" } } };
+ const K2 = ["type", "source", "source-layer", "minzoom", "maxzoom", "filter", "layout"];
+ function X(t4, e2) {
+ const r2 = {};
+ for (const e3 in t4) "ref" !== e3 && (r2[e3] = t4[e3]);
+ return K2.forEach((t5) => {
+ t5 in e2 && (r2[t5] = e2[t5]);
+ }), r2;
+ }
+ function H(t4, e2) {
+ if (Array.isArray(t4)) {
+ if (!Array.isArray(e2) || t4.length !== e2.length) return false;
+ for (let r2 = 0; r2 < t4.length; r2++) if (!H(t4[r2], e2[r2])) return false;
+ return true;
+ }
+ if ("object" == typeof t4 && null !== t4 && null !== e2) {
+ if ("object" != typeof e2) return false;
+ if (Object.keys(t4).length !== Object.keys(e2).length) return false;
+ for (const r2 in t4) if (!H(t4[r2], e2[r2])) return false;
+ return true;
+ }
+ return t4 === e2;
+ }
+ function Y(t4, e2) {
+ t4.push(e2);
+ }
+ function J(t4, e2, r2) {
+ Y(r2, { command: "addSource", args: [t4, e2[t4]] });
+ }
+ function W(t4, e2, r2) {
+ Y(e2, { command: "removeSource", args: [t4] }), r2[t4] = true;
+ }
+ function Q(t4, e2, r2, n2) {
+ W(t4, r2, n2), J(t4, e2, r2);
+ }
+ function tt(t4, e2, r2) {
+ let n2;
+ for (n2 in t4[r2]) if (Object.prototype.hasOwnProperty.call(t4[r2], n2) && "data" !== n2 && !H(t4[r2][n2], e2[r2][n2])) return false;
+ for (n2 in e2[r2]) if (Object.prototype.hasOwnProperty.call(e2[r2], n2) && "data" !== n2 && !H(t4[r2][n2], e2[r2][n2])) return false;
+ return true;
+ }
+ function et(t4, e2, r2, n2, i2, s2) {
+ t4 = t4 || {}, e2 = e2 || {};
+ for (const a2 in t4) Object.prototype.hasOwnProperty.call(t4, a2) && (H(t4[a2], e2[a2]) || r2.push({ command: s2, args: [n2, a2, e2[a2], i2] }));
+ for (const a2 in e2) Object.prototype.hasOwnProperty.call(e2, a2) && !Object.prototype.hasOwnProperty.call(t4, a2) && (H(t4[a2], e2[a2]) || r2.push({ command: s2, args: [n2, a2, e2[a2], i2] }));
+ }
+ function rt(t4) {
+ return t4.id;
+ }
+ function nt(t4, e2) {
+ return t4[e2.id] = e2, t4;
+ }
+ class it {
+ constructor(t4, e2, r2, n2) {
+ this.message = (t4 ? `${t4}: ` : "") + r2, n2 && (this.identifier = n2), null != e2 && e2.__line__ && (this.line = e2.__line__);
+ }
+ }
+ function st(t4, ...e2) {
+ for (const r2 of e2) for (const e3 in r2) t4[e3] = r2[e3];
+ return t4;
+ }
+ class at extends Error {
+ constructor(t4, e2) {
+ super(e2), this.message = e2, this.key = t4;
+ }
+ }
+ class ot {
+ constructor(t4, e2 = []) {
+ this.parent = t4, this.bindings = {};
+ for (const [t5, r2] of e2) this.bindings[t5] = r2;
+ }
+ concat(t4) {
+ return new ot(this, t4);
+ }
+ get(t4) {
+ if (this.bindings[t4]) return this.bindings[t4];
+ if (this.parent) return this.parent.get(t4);
+ throw new Error(`${t4} not found in scope.`);
+ }
+ has(t4) {
+ return !!this.bindings[t4] || !!this.parent && this.parent.has(t4);
+ }
+ }
+ const lt = { kind: "null" }, ut = { kind: "number" }, ct = { kind: "string" }, ht = { kind: "boolean" }, pt = { kind: "color" }, ft = { kind: "object" }, dt = { kind: "value" }, yt = { kind: "collator" }, mt = { kind: "formatted" }, gt = { kind: "padding" }, xt = { kind: "resolvedImage" }, vt = { kind: "variableAnchorOffsetCollection" };
+ function bt(t4, e2) {
+ return { kind: "array", itemType: t4, N: e2 };
+ }
+ function wt(t4) {
+ if ("array" === t4.kind) {
+ const e2 = wt(t4.itemType);
+ return "number" == typeof t4.N ? `array<${e2}, ${t4.N}>` : "value" === t4.itemType.kind ? "array" : `array<${e2}>`;
+ }
+ return t4.kind;
+ }
+ const _t = [lt, ut, ct, ht, pt, mt, ft, bt(dt), gt, xt, vt];
+ function At(t4, e2) {
+ if ("error" === e2.kind) return null;
+ if ("array" === t4.kind) {
+ if ("array" === e2.kind && (0 === e2.N && "value" === e2.itemType.kind || !At(t4.itemType, e2.itemType)) && ("number" != typeof t4.N || t4.N === e2.N)) return null;
+ } else {
+ if (t4.kind === e2.kind) return null;
+ if ("value" === t4.kind) {
+ for (const t5 of _t) if (!At(t5, e2)) return null;
+ }
+ }
+ return `Expected ${wt(t4)} but found ${wt(e2)} instead.`;
+ }
+ function St(t4, e2) {
+ return e2.some((e3) => e3.kind === t4.kind);
+ }
+ function kt(t4, e2) {
+ return e2.some((e3) => "null" === e3 ? null === t4 : "array" === e3 ? Array.isArray(t4) : "object" === e3 ? t4 && !Array.isArray(t4) && "object" == typeof t4 : e3 === typeof t4);
+ }
+ function Mt(t4, e2) {
+ return "array" === t4.kind && "array" === e2.kind ? t4.itemType.kind === e2.itemType.kind && "number" == typeof t4.N : t4.kind === e2.kind;
+ }
+ const It = 0.96422, zt = 0.82521, Pt = 4 / 29, Ct = 6 / 29, Bt = 3 * Ct * Ct, Vt = Ct * Ct * Ct, Et = Math.PI / 180, Ft = 180 / Math.PI;
+ function Tt(t4) {
+ return (t4 %= 360) < 0 && (t4 += 360), t4;
+ }
+ function $t([t4, e2, r2, n2]) {
+ let i2, s2;
+ const a2 = Dt((0.2225045 * (t4 = Lt(t4)) + 0.7168786 * (e2 = Lt(e2)) + 0.0606169 * (r2 = Lt(r2))) / 1);
+ t4 === e2 && e2 === r2 ? i2 = s2 = a2 : (i2 = Dt((0.4360747 * t4 + 0.3850649 * e2 + 0.1430804 * r2) / It), s2 = Dt((0.0139322 * t4 + 0.0971045 * e2 + 0.7141733 * r2) / zt));
+ const o2 = 116 * a2 - 16;
+ return [o2 < 0 ? 0 : o2, 500 * (i2 - a2), 200 * (a2 - s2), n2];
+ }
+ function Lt(t4) {
+ return t4 <= 0.04045 ? t4 / 12.92 : Math.pow((t4 + 0.055) / 1.055, 2.4);
+ }
+ function Dt(t4) {
+ return t4 > Vt ? Math.pow(t4, 1 / 3) : t4 / Bt + Pt;
+ }
+ function Ot([t4, e2, r2, n2]) {
+ let i2 = (t4 + 16) / 116, s2 = isNaN(e2) ? i2 : i2 + e2 / 500, a2 = isNaN(r2) ? i2 : i2 - r2 / 200;
+ return i2 = 1 * Rt(i2), s2 = It * Rt(s2), a2 = zt * Rt(a2), [jt(3.1338561 * s2 - 1.6168667 * i2 - 0.4906146 * a2), jt(-0.9787684 * s2 + 1.9161415 * i2 + 0.033454 * a2), jt(0.0719453 * s2 - 0.2289914 * i2 + 1.4052427 * a2), n2];
+ }
+ function jt(t4) {
+ return (t4 = t4 <= 304e-5 ? 12.92 * t4 : 1.055 * Math.pow(t4, 1 / 2.4) - 0.055) < 0 ? 0 : t4 > 1 ? 1 : t4;
+ }
+ function Rt(t4) {
+ return t4 > Ct ? t4 * t4 * t4 : Bt * (t4 - Pt);
+ }
+ function Ut(t4) {
+ return parseInt(t4.padEnd(2, t4), 16) / 255;
+ }
+ function qt(t4, e2) {
+ return Nt(e2 ? t4 / 100 : t4, 0, 1);
+ }
+ function Nt(t4, e2, r2) {
+ return Math.min(Math.max(e2, t4), r2);
+ }
+ function Zt(t4) {
+ return !t4.some(Number.isNaN);
+ }
+ const Gt = { 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] };
+ class Kt {
+ constructor(t4, e2, r2, n2 = 1, i2 = true) {
+ this.r = t4, this.g = e2, this.b = r2, this.a = n2, i2 || (this.r *= n2, this.g *= n2, this.b *= n2, n2 || this.overwriteGetter("rgb", [t4, e2, r2, n2]));
+ }
+ static parse(t4) {
+ if (t4 instanceof Kt) return t4;
+ if ("string" != typeof t4) return;
+ const e2 = function(t5) {
+ if ("transparent" === (t5 = t5.toLowerCase().trim())) return [0, 0, 0, 0];
+ const e3 = Gt[t5];
+ if (e3) {
+ const [t6, r3, n2] = e3;
+ return [t6 / 255, r3 / 255, n2 / 255, 1];
+ }
+ if (t5.startsWith("#") && /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t5)) {
+ const e4 = t5.length < 6 ? 1 : 2;
+ let r3 = 1;
+ return [Ut(t5.slice(r3, r3 += e4)), Ut(t5.slice(r3, r3 += e4)), Ut(t5.slice(r3, r3 += e4)), Ut(t5.slice(r3, r3 + e4) || "ff")];
+ }
+ if (t5.startsWith("rgb")) {
+ const e4 = t5.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);
+ if (e4) {
+ const [t6, r3, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2] = e4, f2 = [i2 || " ", o2 || " ", c2].join("");
+ if (" " === f2 || " /" === f2 || ",," === f2 || ",,," === f2) {
+ const t7 = [n2, a2, u2].join(""), e5 = "%%%" === t7 ? 100 : "" === t7 ? 255 : 0;
+ if (e5) {
+ const t8 = [Nt(+r3 / e5, 0, 1), Nt(+s2 / e5, 0, 1), Nt(+l2 / e5, 0, 1), h2 ? qt(+h2, p2) : 1];
+ if (Zt(t8)) return t8;
+ }
+ }
+ return;
+ }
+ }
+ const r2 = t5.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);
+ if (r2) {
+ const [t6, e4, n2, i2, s2, a2, o2, l2, u2] = r2, c2 = [n2 || " ", s2 || " ", o2].join("");
+ if (" " === c2 || " /" === c2 || ",," === c2 || ",,," === c2) {
+ const t7 = [+e4, Nt(+i2, 0, 100), Nt(+a2, 0, 100), l2 ? qt(+l2, u2) : 1];
+ if (Zt(t7)) return function([t8, e5, r3, n3]) {
+ function i3(n4) {
+ const i4 = (n4 + t8 / 30) % 12, s3 = e5 * Math.min(r3, 1 - r3);
+ return r3 - s3 * Math.max(-1, Math.min(i4 - 3, 9 - i4, 1));
+ }
+ return t8 = Tt(t8), e5 /= 100, r3 /= 100, [i3(0), i3(8), i3(4), n3];
+ }(t7);
+ }
+ }
+ }(t4);
+ return e2 ? new Kt(...e2, false) : void 0;
+ }
+ get rgb() {
+ const { r: t4, g: e2, b: r2, a: n2 } = this, i2 = n2 || 1 / 0;
+ return this.overwriteGetter("rgb", [t4 / i2, e2 / i2, r2 / i2, n2]);
+ }
+ get hcl() {
+ return this.overwriteGetter("hcl", function(t4) {
+ const [e2, r2, n2, i2] = $t(t4), s2 = Math.sqrt(r2 * r2 + n2 * n2);
+ return [Math.round(1e4 * s2) ? Tt(Math.atan2(n2, r2) * Ft) : NaN, s2, e2, i2];
+ }(this.rgb));
+ }
+ get lab() {
+ return this.overwriteGetter("lab", $t(this.rgb));
+ }
+ overwriteGetter(t4, e2) {
+ return Object.defineProperty(this, t4, { value: e2 }), e2;
+ }
+ toString() {
+ const [t4, e2, r2, n2] = this.rgb;
+ return `rgba(${[t4, e2, r2].map((t5) => Math.round(255 * t5)).join(",")},${n2})`;
+ }
+ }
+ Kt.black = new Kt(0, 0, 0, 1), Kt.white = new Kt(1, 1, 1, 1), Kt.transparent = new Kt(0, 0, 0, 0), Kt.red = new Kt(1, 0, 0, 1);
+ class Xt {
+ constructor(t4, e2, r2) {
+ this.sensitivity = t4 ? e2 ? "variant" : "case" : e2 ? "accent" : "base", this.locale = r2, this.collator = new Intl.Collator(this.locale ? this.locale : [], { sensitivity: this.sensitivity, usage: "search" });
+ }
+ compare(t4, e2) {
+ return this.collator.compare(t4, e2);
+ }
+ resolvedLocale() {
+ return new Intl.Collator(this.locale ? this.locale : []).resolvedOptions().locale;
+ }
+ }
+ class Ht {
+ constructor(t4, e2, r2, n2, i2) {
+ this.text = t4, this.image = e2, this.scale = r2, this.fontStack = n2, this.textColor = i2;
+ }
+ }
+ class Yt {
+ constructor(t4) {
+ this.sections = t4;
+ }
+ static fromString(t4) {
+ return new Yt([new Ht(t4, null, null, null, null)]);
+ }
+ isEmpty() {
+ return 0 === this.sections.length || !this.sections.some((t4) => 0 !== t4.text.length || t4.image && 0 !== t4.image.name.length);
+ }
+ static factory(t4) {
+ return t4 instanceof Yt ? t4 : Yt.fromString(t4);
+ }
+ toString() {
+ return 0 === this.sections.length ? "" : this.sections.map((t4) => t4.text).join("");
+ }
+ }
+ class Jt {
+ constructor(t4) {
+ this.values = t4.slice();
+ }
+ static parse(t4) {
+ if (t4 instanceof Jt) return t4;
+ if ("number" == typeof t4) return new Jt([t4, t4, t4, t4]);
+ if (Array.isArray(t4) && !(t4.length < 1 || t4.length > 4)) {
+ for (const e2 of t4) if ("number" != typeof e2) return;
+ switch (t4.length) {
+ case 1:
+ t4 = [t4[0], t4[0], t4[0], t4[0]];
+ break;
+ case 2:
+ t4 = [t4[0], t4[1], t4[0], t4[1]];
+ break;
+ case 3:
+ t4 = [t4[0], t4[1], t4[2], t4[1]];
+ }
+ return new Jt(t4);
+ }
+ }
+ toString() {
+ return JSON.stringify(this.values);
+ }
+ }
+ const Wt = /* @__PURE__ */ new Set(["center", "left", "right", "top", "bottom", "top-left", "top-right", "bottom-left", "bottom-right"]);
+ class Qt {
+ constructor(t4) {
+ this.values = t4.slice();
+ }
+ static parse(t4) {
+ if (t4 instanceof Qt) return t4;
+ if (Array.isArray(t4) && !(t4.length < 1) && t4.length % 2 == 0) {
+ for (let e2 = 0; e2 < t4.length; e2 += 2) {
+ const r2 = t4[e2], n2 = t4[e2 + 1];
+ if ("string" != typeof r2 || !Wt.has(r2)) return;
+ if (!Array.isArray(n2) || 2 !== n2.length || "number" != typeof n2[0] || "number" != typeof n2[1]) return;
+ }
+ return new Qt(t4);
+ }
+ }
+ toString() {
+ return JSON.stringify(this.values);
+ }
+ }
+ class te {
+ constructor(t4) {
+ this.name = t4.name, this.available = t4.available;
+ }
+ toString() {
+ return this.name;
+ }
+ static fromString(t4) {
+ return t4 ? new te({ name: t4, available: false }) : null;
+ }
+ }
+ function ee(t4, e2, r2, n2) {
+ return "number" == typeof t4 && t4 >= 0 && t4 <= 255 && "number" == typeof e2 && e2 >= 0 && e2 <= 255 && "number" == typeof r2 && r2 >= 0 && r2 <= 255 ? void 0 === n2 || "number" == typeof n2 && n2 >= 0 && n2 <= 1 ? null : `Invalid rgba value [${[t4, e2, r2, n2].join(", ")}]: 'a' must be between 0 and 1.` : `Invalid rgba value [${("number" == typeof n2 ? [t4, e2, r2, n2] : [t4, e2, r2]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`;
+ }
+ function re(t4) {
+ if (null === t4 || "string" == typeof t4 || "boolean" == typeof t4 || "number" == typeof t4 || t4 instanceof Kt || t4 instanceof Xt || t4 instanceof Yt || t4 instanceof Jt || t4 instanceof Qt || t4 instanceof te) return true;
+ if (Array.isArray(t4)) {
+ for (const e2 of t4) if (!re(e2)) return false;
+ return true;
+ }
+ if ("object" == typeof t4) {
+ for (const e2 in t4) if (!re(t4[e2])) return false;
+ return true;
+ }
+ return false;
+ }
+ function ne(t4) {
+ if (null === t4) return lt;
+ if ("string" == typeof t4) return ct;
+ if ("boolean" == typeof t4) return ht;
+ if ("number" == typeof t4) return ut;
+ if (t4 instanceof Kt) return pt;
+ if (t4 instanceof Xt) return yt;
+ if (t4 instanceof Yt) return mt;
+ if (t4 instanceof Jt) return gt;
+ if (t4 instanceof Qt) return vt;
+ if (t4 instanceof te) return xt;
+ if (Array.isArray(t4)) {
+ const e2 = t4.length;
+ let r2;
+ for (const e3 of t4) {
+ const t5 = ne(e3);
+ if (r2) {
+ if (r2 === t5) continue;
+ r2 = dt;
+ break;
+ }
+ r2 = t5;
+ }
+ return bt(r2 || dt, e2);
+ }
+ return ft;
+ }
+ function ie(t4) {
+ const e2 = typeof t4;
+ return null === t4 ? "" : "string" === e2 || "number" === e2 || "boolean" === e2 ? String(t4) : t4 instanceof Kt || t4 instanceof Yt || t4 instanceof Jt || t4 instanceof Qt || t4 instanceof te ? t4.toString() : JSON.stringify(t4);
+ }
+ class se {
+ constructor(t4, e2) {
+ this.type = t4, this.value = e2;
+ }
+ static parse(t4, e2) {
+ if (2 !== t4.length) return e2.error(`'literal' expression requires exactly one argument, but found ${t4.length - 1} instead.`);
+ if (!re(t4[1])) return e2.error("invalid value");
+ const r2 = t4[1];
+ let n2 = ne(r2);
+ const i2 = e2.expectedType;
+ return "array" !== n2.kind || 0 !== n2.N || !i2 || "array" !== i2.kind || "number" == typeof i2.N && 0 !== i2.N || (n2 = i2), new se(n2, r2);
+ }
+ evaluate() {
+ return this.value;
+ }
+ eachChild() {
+ }
+ outputDefined() {
+ return true;
+ }
+ }
+ class ae {
+ constructor(t4) {
+ this.name = "ExpressionEvaluationError", this.message = t4;
+ }
+ toJSON() {
+ return this.message;
+ }
+ }
+ const oe = { string: ct, number: ut, boolean: ht, object: ft };
+ class le {
+ constructor(t4, e2) {
+ this.type = t4, this.args = e2;
+ }
+ static parse(t4, e2) {
+ if (t4.length < 2) return e2.error("Expected at least one argument.");
+ let r2, n2 = 1;
+ const i2 = t4[0];
+ if ("array" === i2) {
+ let i3, s3;
+ if (t4.length > 2) {
+ const r3 = t4[1];
+ if ("string" != typeof r3 || !(r3 in oe) || "object" === r3) return e2.error('The item type argument of "array" must be one of string, number, boolean', 1);
+ i3 = oe[r3], n2++;
+ } else i3 = dt;
+ if (t4.length > 3) {
+ if (null !== t4[2] && ("number" != typeof t4[2] || t4[2] < 0 || t4[2] !== Math.floor(t4[2]))) return e2.error('The length argument to "array" must be a positive integer literal', 2);
+ s3 = t4[2], n2++;
+ }
+ r2 = bt(i3, s3);
+ } else {
+ if (!oe[i2]) throw new Error(`Types doesn't contain name = ${i2}`);
+ r2 = oe[i2];
+ }
+ const s2 = [];
+ for (; n2 < t4.length; n2++) {
+ const r3 = e2.parse(t4[n2], n2, dt);
+ if (!r3) return null;
+ s2.push(r3);
+ }
+ return new le(r2, s2);
+ }
+ evaluate(t4) {
+ for (let e2 = 0; e2 < this.args.length; e2++) {
+ const r2 = this.args[e2].evaluate(t4);
+ if (!At(this.type, ne(r2))) return r2;
+ if (e2 === this.args.length - 1) throw new ae(`Expected value to be of type ${wt(this.type)}, but found ${wt(ne(r2))} instead.`);
+ }
+ throw new Error();
+ }
+ eachChild(t4) {
+ this.args.forEach(t4);
+ }
+ outputDefined() {
+ return this.args.every((t4) => t4.outputDefined());
+ }
+ }
+ const ue = { "to-boolean": ht, "to-color": pt, "to-number": ut, "to-string": ct };
+ class ce {
+ constructor(t4, e2) {
+ this.type = t4, this.args = e2;
+ }
+ static parse(t4, e2) {
+ if (t4.length < 2) return e2.error("Expected at least one argument.");
+ const r2 = t4[0];
+ if (!ue[r2]) throw new Error(`Can't parse ${r2} as it is not part of the known types`);
+ if (("to-boolean" === r2 || "to-string" === r2) && 2 !== t4.length) return e2.error("Expected one argument.");
+ const n2 = ue[r2], i2 = [];
+ for (let r3 = 1; r3 < t4.length; r3++) {
+ const n3 = e2.parse(t4[r3], r3, dt);
+ if (!n3) return null;
+ i2.push(n3);
+ }
+ return new ce(n2, i2);
+ }
+ evaluate(t4) {
+ switch (this.type.kind) {
+ case "boolean":
+ return Boolean(this.args[0].evaluate(t4));
+ case "color": {
+ let e2, r2;
+ for (const n2 of this.args) {
+ if (e2 = n2.evaluate(t4), r2 = null, e2 instanceof Kt) return e2;
+ if ("string" == typeof e2) {
+ const r3 = t4.parseColor(e2);
+ if (r3) return r3;
+ } else if (Array.isArray(e2) && (r2 = e2.length < 3 || e2.length > 4 ? `Invalid rbga value ${JSON.stringify(e2)}: expected an array containing either three or four numeric values.` : ee(e2[0], e2[1], e2[2], e2[3]), !r2)) return new Kt(e2[0] / 255, e2[1] / 255, e2[2] / 255, e2[3]);
+ }
+ throw new ae(r2 || `Could not parse color from value '${"string" == typeof e2 ? e2 : JSON.stringify(e2)}'`);
+ }
+ case "padding": {
+ let e2;
+ for (const r2 of this.args) {
+ e2 = r2.evaluate(t4);
+ const n2 = Jt.parse(e2);
+ if (n2) return n2;
+ }
+ throw new ae(`Could not parse padding from value '${"string" == typeof e2 ? e2 : JSON.stringify(e2)}'`);
+ }
+ case "variableAnchorOffsetCollection": {
+ let e2;
+ for (const r2 of this.args) {
+ e2 = r2.evaluate(t4);
+ const n2 = Qt.parse(e2);
+ if (n2) return n2;
+ }
+ throw new ae(`Could not parse variableAnchorOffsetCollection from value '${"string" == typeof e2 ? e2 : JSON.stringify(e2)}'`);
+ }
+ case "number": {
+ let e2 = null;
+ for (const r2 of this.args) {
+ if (e2 = r2.evaluate(t4), null === e2) return 0;
+ const n2 = Number(e2);
+ if (!isNaN(n2)) return n2;
+ }
+ throw new ae(`Could not convert ${JSON.stringify(e2)} to number.`);
+ }
+ case "formatted":
+ return Yt.fromString(ie(this.args[0].evaluate(t4)));
+ case "resolvedImage":
+ return te.fromString(ie(this.args[0].evaluate(t4)));
+ default:
+ return ie(this.args[0].evaluate(t4));
+ }
+ }
+ eachChild(t4) {
+ this.args.forEach(t4);
+ }
+ outputDefined() {
+ return this.args.every((t4) => t4.outputDefined());
+ }
+ }
+ const he = ["Unknown", "Point", "LineString", "Polygon"];
+ class pe {
+ constructor() {
+ this.globals = null, this.feature = null, this.featureState = null, this.formattedSection = null, this._parseColorCache = {}, this.availableImages = null, this.canonical = null;
+ }
+ id() {
+ return this.feature && "id" in this.feature ? this.feature.id : null;
+ }
+ geometryType() {
+ return this.feature ? "number" == typeof this.feature.type ? he[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 || {};
+ }
+ parseColor(t4) {
+ let e2 = this._parseColorCache[t4];
+ return e2 || (e2 = this._parseColorCache[t4] = Kt.parse(t4)), e2;
+ }
+ }
+ class fe {
+ constructor(t4, e2, r2 = [], n2, i2 = new ot(), s2 = []) {
+ this.registry = t4, this.path = r2, this.key = r2.map((t5) => `[${t5}]`).join(""), this.scope = i2, this.errors = s2, this.expectedType = n2, this._isConstant = e2;
+ }
+ parse(t4, e2, r2, n2, i2 = {}) {
+ return e2 ? this.concat(e2, r2, n2)._parse(t4, i2) : this._parse(t4, i2);
+ }
+ _parse(t4, e2) {
+ function r2(t5, e3, r3) {
+ return "assert" === r3 ? new le(e3, [t5]) : "coerce" === r3 ? new ce(e3, [t5]) : t5;
+ }
+ if (null !== t4 && "string" != typeof t4 && "boolean" != typeof t4 && "number" != typeof t4 || (t4 = ["literal", t4]), Array.isArray(t4)) {
+ if (0 === t4.length) return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');
+ const n2 = t4[0];
+ if ("string" != typeof n2) return this.error(`Expression name must be a string, but found ${typeof n2} instead. If you wanted a literal array, use ["literal", [...]].`, 0), null;
+ const i2 = this.registry[n2];
+ if (i2) {
+ let n3 = i2.parse(t4, this);
+ if (!n3) return null;
+ if (this.expectedType) {
+ const t5 = this.expectedType, i3 = n3.type;
+ if ("string" !== t5.kind && "number" !== t5.kind && "boolean" !== t5.kind && "object" !== t5.kind && "array" !== t5.kind || "value" !== i3.kind) if ("color" !== t5.kind && "formatted" !== t5.kind && "resolvedImage" !== t5.kind || "value" !== i3.kind && "string" !== i3.kind) if ("padding" !== t5.kind || "value" !== i3.kind && "number" !== i3.kind && "array" !== i3.kind) if ("variableAnchorOffsetCollection" !== t5.kind || "value" !== i3.kind && "array" !== i3.kind) {
+ if (this.checkSubtype(t5, i3)) return null;
+ } else n3 = r2(n3, t5, e2.typeAnnotation || "coerce");
+ else n3 = r2(n3, t5, e2.typeAnnotation || "coerce");
+ else n3 = r2(n3, t5, e2.typeAnnotation || "coerce");
+ else n3 = r2(n3, t5, e2.typeAnnotation || "assert");
+ }
+ if (!(n3 instanceof se) && "resolvedImage" !== n3.type.kind && this._isConstant(n3)) {
+ const t5 = new pe();
+ try {
+ n3 = new se(n3.type, n3.evaluate(t5));
+ } catch (t6) {
+ return this.error(t6.message), null;
+ }
+ }
+ return n3;
+ }
+ return this.error(`Unknown expression "${n2}". If you wanted a literal array, use ["literal", [...]].`, 0);
+ }
+ return this.error(void 0 === t4 ? "'undefined' value invalid. Use null instead." : "object" == typeof t4 ? 'Bare objects invalid. Use ["literal", {...}] instead.' : `Expected an array, but found ${typeof t4} instead.`);
+ }
+ concat(t4, e2, r2) {
+ const n2 = "number" == typeof t4 ? this.path.concat(t4) : this.path, i2 = r2 ? this.scope.concat(r2) : this.scope;
+ return new fe(this.registry, this._isConstant, n2, e2 || null, i2, this.errors);
+ }
+ error(t4, ...e2) {
+ const r2 = `${this.key}${e2.map((t5) => `[${t5}]`).join("")}`;
+ this.errors.push(new at(r2, t4));
+ }
+ checkSubtype(t4, e2) {
+ const r2 = At(t4, e2);
+ return r2 && this.error(r2), r2;
+ }
+ }
+ class de {
+ constructor(t4, e2) {
+ this.type = e2.type, this.bindings = [].concat(t4), this.result = e2;
+ }
+ evaluate(t4) {
+ return this.result.evaluate(t4);
+ }
+ eachChild(t4) {
+ for (const e2 of this.bindings) t4(e2[1]);
+ t4(this.result);
+ }
+ static parse(t4, e2) {
+ if (t4.length < 4) return e2.error(`Expected at least 3 arguments, but found ${t4.length - 1} instead.`);
+ const r2 = [];
+ for (let n3 = 1; n3 < t4.length - 1; n3 += 2) {
+ const i2 = t4[n3];
+ if ("string" != typeof i2) return e2.error(`Expected string, but found ${typeof i2} instead.`, n3);
+ if (/[^a-zA-Z0-9_]/.test(i2)) return e2.error("Variable names must contain only alphanumeric characters or '_'.", n3);
+ const s2 = e2.parse(t4[n3 + 1], n3 + 1);
+ if (!s2) return null;
+ r2.push([i2, s2]);
+ }
+ const n2 = e2.parse(t4[t4.length - 1], t4.length - 1, e2.expectedType, r2);
+ return n2 ? new de(r2, n2) : null;
+ }
+ outputDefined() {
+ return this.result.outputDefined();
+ }
+ }
+ class ye {
+ constructor(t4, e2) {
+ this.type = e2.type, this.name = t4, this.boundExpression = e2;
+ }
+ static parse(t4, e2) {
+ if (2 !== t4.length || "string" != typeof t4[1]) return e2.error("'var' expression requires exactly one string literal argument.");
+ const r2 = t4[1];
+ return e2.scope.has(r2) ? new ye(r2, e2.scope.get(r2)) : e2.error(`Unknown variable "${r2}". Make sure "${r2}" has been bound in an enclosing "let" expression before using it.`, 1);
+ }
+ evaluate(t4) {
+ return this.boundExpression.evaluate(t4);
+ }
+ eachChild() {
+ }
+ outputDefined() {
+ return false;
+ }
+ }
+ class me {
+ constructor(t4, e2, r2) {
+ this.type = t4, this.index = e2, this.input = r2;
+ }
+ static parse(t4, e2) {
+ if (3 !== t4.length) return e2.error(`Expected 2 arguments, but found ${t4.length - 1} instead.`);
+ const r2 = e2.parse(t4[1], 1, ut), n2 = e2.parse(t4[2], 2, bt(e2.expectedType || dt));
+ return r2 && n2 ? new me(n2.type.itemType, r2, n2) : null;
+ }
+ evaluate(t4) {
+ const e2 = this.index.evaluate(t4), r2 = this.input.evaluate(t4);
+ if (e2 < 0) throw new ae(`Array index out of bounds: ${e2} < 0.`);
+ if (e2 >= r2.length) throw new ae(`Array index out of bounds: ${e2} > ${r2.length - 1}.`);
+ if (e2 !== Math.floor(e2)) throw new ae(`Array index must be an integer, but found ${e2} instead.`);
+ return r2[e2];
+ }
+ eachChild(t4) {
+ t4(this.index), t4(this.input);
+ }
+ outputDefined() {
+ return false;
+ }
+ }
+ class ge {
+ constructor(t4, e2) {
+ this.type = ht, this.needle = t4, this.haystack = e2;
+ }
+ static parse(t4, e2) {
+ if (3 !== t4.length) return e2.error(`Expected 2 arguments, but found ${t4.length - 1} instead.`);
+ const r2 = e2.parse(t4[1], 1, dt), n2 = e2.parse(t4[2], 2, dt);
+ return r2 && n2 ? St(r2.type, [ht, ct, ut, lt, dt]) ? new ge(r2, n2) : e2.error(`Expected first argument to be of type boolean, string, number or null, but found ${wt(r2.type)} instead`) : null;
+ }
+ evaluate(t4) {
+ const e2 = this.needle.evaluate(t4), r2 = this.haystack.evaluate(t4);
+ if (!r2) return false;
+ if (!kt(e2, ["boolean", "string", "number", "null"])) throw new ae(`Expected first argument to be of type boolean, string, number or null, but found ${wt(ne(e2))} instead.`);
+ if (!kt(r2, ["string", "array"])) throw new ae(`Expected second argument to be of type array or string, but found ${wt(ne(r2))} instead.`);
+ return r2.indexOf(e2) >= 0;
+ }
+ eachChild(t4) {
+ t4(this.needle), t4(this.haystack);
+ }
+ outputDefined() {
+ return true;
+ }
+ }
+ class xe {
+ constructor(t4, e2, r2) {
+ this.type = ut, this.needle = t4, this.haystack = e2, this.fromIndex = r2;
+ }
+ static parse(t4, e2) {
+ if (t4.length <= 2 || t4.length >= 5) return e2.error(`Expected 3 or 4 arguments, but found ${t4.length - 1} instead.`);
+ const r2 = e2.parse(t4[1], 1, dt), n2 = e2.parse(t4[2], 2, dt);
+ if (!r2 || !n2) return null;
+ if (!St(r2.type, [ht, ct, ut, lt, dt])) return e2.error(`Expected first argument to be of type boolean, string, number or null, but found ${wt(r2.type)} instead`);
+ if (4 === t4.length) {
+ const i2 = e2.parse(t4[3], 3, ut);
+ return i2 ? new xe(r2, n2, i2) : null;
+ }
+ return new xe(r2, n2);
+ }
+ evaluate(t4) {
+ const e2 = this.needle.evaluate(t4), r2 = this.haystack.evaluate(t4);
+ if (!kt(e2, ["boolean", "string", "number", "null"])) throw new ae(`Expected first argument to be of type boolean, string, number or null, but found ${wt(ne(e2))} instead.`);
+ let n2;
+ if (this.fromIndex && (n2 = this.fromIndex.evaluate(t4)), kt(r2, ["string"])) {
+ const t5 = r2.indexOf(e2, n2);
+ return -1 === t5 ? -1 : [...r2.slice(0, t5)].length;
+ }
+ if (kt(r2, ["array"])) return r2.indexOf(e2, n2);
+ throw new ae(`Expected second argument to be of type array or string, but found ${wt(ne(r2))} instead.`);
+ }
+ eachChild(t4) {
+ t4(this.needle), t4(this.haystack), this.fromIndex && t4(this.fromIndex);
+ }
+ outputDefined() {
+ return false;
+ }
+ }
+ class ve {
+ constructor(t4, e2, r2, n2, i2, s2) {
+ this.inputType = t4, this.type = e2, this.input = r2, this.cases = n2, this.outputs = i2, this.otherwise = s2;
+ }
+ static parse(t4, e2) {
+ if (t4.length < 5) return e2.error(`Expected at least 4 arguments, but found only ${t4.length - 1}.`);
+ if (t4.length % 2 != 1) return e2.error("Expected an even number of arguments.");
+ let r2, n2;
+ e2.expectedType && "value" !== e2.expectedType.kind && (n2 = e2.expectedType);
+ const i2 = {}, s2 = [];
+ for (let a3 = 2; a3 < t4.length - 1; a3 += 2) {
+ let o3 = t4[a3];
+ const l2 = t4[a3 + 1];
+ Array.isArray(o3) || (o3 = [o3]);
+ const u2 = e2.concat(a3);
+ if (0 === o3.length) return u2.error("Expected at least one branch label.");
+ for (const t5 of o3) {
+ if ("number" != typeof t5 && "string" != typeof t5) return u2.error("Branch labels must be numbers or strings.");
+ if ("number" == typeof t5 && Math.abs(t5) > Number.MAX_SAFE_INTEGER) return u2.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);
+ if ("number" == typeof t5 && Math.floor(t5) !== t5) return u2.error("Numeric branch labels must be integer values.");
+ if (r2) {
+ if (u2.checkSubtype(r2, ne(t5))) return null;
+ } else r2 = ne(t5);
+ if (void 0 !== i2[String(t5)]) return u2.error("Branch labels must be unique.");
+ i2[String(t5)] = s2.length;
+ }
+ const c2 = e2.parse(l2, a3, n2);
+ if (!c2) return null;
+ n2 = n2 || c2.type, s2.push(c2);
+ }
+ const a2 = e2.parse(t4[1], 1, dt);
+ if (!a2) return null;
+ const o2 = e2.parse(t4[t4.length - 1], t4.length - 1, n2);
+ return o2 ? "value" !== a2.type.kind && e2.concat(1).checkSubtype(r2, a2.type) ? null : new ve(r2, n2, a2, i2, s2, o2) : null;
+ }
+ evaluate(t4) {
+ const e2 = this.input.evaluate(t4);
+ return (ne(e2) === this.inputType && this.outputs[this.cases[e2]] || this.otherwise).evaluate(t4);
+ }
+ eachChild(t4) {
+ t4(this.input), this.outputs.forEach(t4), t4(this.otherwise);
+ }
+ outputDefined() {
+ return this.outputs.every((t4) => t4.outputDefined()) && this.otherwise.outputDefined();
+ }
+ }
+ class be {
+ constructor(t4, e2, r2) {
+ this.type = t4, this.branches = e2, this.otherwise = r2;
+ }
+ static parse(t4, e2) {
+ if (t4.length < 4) return e2.error(`Expected at least 3 arguments, but found only ${t4.length - 1}.`);
+ if (t4.length % 2 != 0) return e2.error("Expected an odd number of arguments.");
+ let r2;
+ e2.expectedType && "value" !== e2.expectedType.kind && (r2 = e2.expectedType);
+ const n2 = [];
+ for (let i3 = 1; i3 < t4.length - 1; i3 += 2) {
+ const s2 = e2.parse(t4[i3], i3, ht);
+ if (!s2) return null;
+ const a2 = e2.parse(t4[i3 + 1], i3 + 1, r2);
+ if (!a2) return null;
+ n2.push([s2, a2]), r2 = r2 || a2.type;
+ }
+ const i2 = e2.parse(t4[t4.length - 1], t4.length - 1, r2);
+ if (!i2) return null;
+ if (!r2) throw new Error("Can't infer output type");
+ return new be(r2, n2, i2);
+ }
+ evaluate(t4) {
+ for (const [e2, r2] of this.branches) if (e2.evaluate(t4)) return r2.evaluate(t4);
+ return this.otherwise.evaluate(t4);
+ }
+ eachChild(t4) {
+ for (const [e2, r2] of this.branches) t4(e2), t4(r2);
+ t4(this.otherwise);
+ }
+ outputDefined() {
+ return this.branches.every(([t4, e2]) => e2.outputDefined()) && this.otherwise.outputDefined();
+ }
+ }
+ class we {
+ constructor(t4, e2, r2, n2) {
+ this.type = t4, this.input = e2, this.beginIndex = r2, this.endIndex = n2;
+ }
+ static parse(t4, e2) {
+ if (t4.length <= 2 || t4.length >= 5) return e2.error(`Expected 3 or 4 arguments, but found ${t4.length - 1} instead.`);
+ const r2 = e2.parse(t4[1], 1, dt), n2 = e2.parse(t4[2], 2, ut);
+ if (!r2 || !n2) return null;
+ if (!St(r2.type, [bt(dt), ct, dt])) return e2.error(`Expected first argument to be of type array or string, but found ${wt(r2.type)} instead`);
+ if (4 === t4.length) {
+ const i2 = e2.parse(t4[3], 3, ut);
+ return i2 ? new we(r2.type, r2, n2, i2) : null;
+ }
+ return new we(r2.type, r2, n2);
+ }
+ evaluate(t4) {
+ const e2 = this.input.evaluate(t4), r2 = this.beginIndex.evaluate(t4);
+ let n2;
+ if (this.endIndex && (n2 = this.endIndex.evaluate(t4)), kt(e2, ["string"])) return [...e2].slice(r2, n2).join("");
+ if (kt(e2, ["array"])) return e2.slice(r2, n2);
+ throw new ae(`Expected first argument to be of type array or string, but found ${wt(ne(e2))} instead.`);
+ }
+ eachChild(t4) {
+ t4(this.input), t4(this.beginIndex), this.endIndex && t4(this.endIndex);
+ }
+ outputDefined() {
+ return false;
+ }
+ }
+ function _e(t4, e2) {
+ const r2 = t4.length - 1;
+ let n2, i2, s2 = 0, a2 = r2, o2 = 0;
+ for (; s2 <= a2; ) if (o2 = Math.floor((s2 + a2) / 2), n2 = t4[o2], i2 = t4[o2 + 1], n2 <= e2) {
+ if (o2 === r2 || e2 < i2) return o2;
+ s2 = o2 + 1;
+ } else {
+ if (!(n2 > e2)) throw new ae("Input is not a number.");
+ a2 = o2 - 1;
+ }
+ return 0;
+ }
+ class Ae {
+ constructor(t4, e2, r2) {
+ this.type = t4, this.input = e2, this.labels = [], this.outputs = [];
+ for (const [t5, e3] of r2) this.labels.push(t5), this.outputs.push(e3);
+ }
+ static parse(t4, e2) {
+ if (t4.length - 1 < 4) return e2.error(`Expected at least 4 arguments, but found only ${t4.length - 1}.`);
+ if ((t4.length - 1) % 2 != 0) return e2.error("Expected an even number of arguments.");
+ const r2 = e2.parse(t4[1], 1, ut);
+ if (!r2) return null;
+ const n2 = [];
+ let i2 = null;
+ e2.expectedType && "value" !== e2.expectedType.kind && (i2 = e2.expectedType);
+ for (let r3 = 1; r3 < t4.length; r3 += 2) {
+ const s2 = 1 === r3 ? -1 / 0 : t4[r3], a2 = t4[r3 + 1], o2 = r3, l2 = r3 + 1;
+ if ("number" != typeof s2) return e2.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.', o2);
+ if (n2.length && n2[n2.length - 1][0] >= s2) return e2.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.', o2);
+ const u2 = e2.parse(a2, l2, i2);
+ if (!u2) return null;
+ i2 = i2 || u2.type, n2.push([s2, u2]);
+ }
+ return new Ae(i2, r2, n2);
+ }
+ evaluate(t4) {
+ const e2 = this.labels, r2 = this.outputs;
+ if (1 === e2.length) return r2[0].evaluate(t4);
+ const n2 = this.input.evaluate(t4);
+ if (n2 <= e2[0]) return r2[0].evaluate(t4);
+ const i2 = e2.length;
+ return n2 >= e2[i2 - 1] ? r2[i2 - 1].evaluate(t4) : r2[_e(e2, n2)].evaluate(t4);
+ }
+ eachChild(t4) {
+ t4(this.input);
+ for (const e2 of this.outputs) t4(e2);
+ }
+ outputDefined() {
+ return this.outputs.every((t4) => t4.outputDefined());
+ }
+ }
+ function Se(t4) {
+ return t4 && t4.__esModule && Object.prototype.hasOwnProperty.call(t4, "default") ? t4.default : t4;
+ }
+ var ke = Me;
+ function Me(t4, e2, r2, n2) {
+ this.cx = 3 * t4, this.bx = 3 * (r2 - t4) - this.cx, this.ax = 1 - this.cx - this.bx, this.cy = 3 * e2, this.by = 3 * (n2 - e2) - this.cy, this.ay = 1 - this.cy - this.by, this.p1x = t4, this.p1y = e2, this.p2x = r2, this.p2y = n2;
+ }
+ Me.prototype = { sampleCurveX: function(t4) {
+ return ((this.ax * t4 + this.bx) * t4 + this.cx) * t4;
+ }, sampleCurveY: function(t4) {
+ return ((this.ay * t4 + this.by) * t4 + this.cy) * t4;
+ }, sampleCurveDerivativeX: function(t4) {
+ return (3 * this.ax * t4 + 2 * this.bx) * t4 + this.cx;
+ }, solveCurveX: function(t4, e2) {
+ if (void 0 === e2 && (e2 = 1e-6), t4 < 0) return 0;
+ if (t4 > 1) return 1;
+ for (var r2 = t4, n2 = 0; n2 < 8; n2++) {
+ var i2 = this.sampleCurveX(r2) - t4;
+ if (Math.abs(i2) < e2) return r2;
+ var s2 = this.sampleCurveDerivativeX(r2);
+ if (Math.abs(s2) < 1e-6) break;
+ r2 -= i2 / s2;
+ }
+ var a2 = 0, o2 = 1;
+ for (r2 = t4, n2 = 0; n2 < 20 && (i2 = this.sampleCurveX(r2), !(Math.abs(i2 - t4) < e2)); n2++) t4 > i2 ? a2 = r2 : o2 = r2, r2 = 0.5 * (o2 - a2) + a2;
+ return r2;
+ }, solve: function(t4, e2) {
+ return this.sampleCurveY(this.solveCurveX(t4, e2));
+ } };
+ var Ie = Se(ke);
+ function ze(t4, e2, r2) {
+ return t4 + r2 * (e2 - t4);
+ }
+ function Pe(t4, e2, r2) {
+ return t4.map((t5, n2) => ze(t5, e2[n2], r2));
+ }
+ const Ce = { number: ze, color: function(t4, e2, r2, n2 = "rgb") {
+ switch (n2) {
+ case "rgb": {
+ const [n3, i2, s2, a2] = Pe(t4.rgb, e2.rgb, r2);
+ return new Kt(n3, i2, s2, a2, false);
+ }
+ case "hcl": {
+ const [n3, i2, s2, a2] = t4.hcl, [o2, l2, u2, c2] = e2.hcl;
+ let h2, p2;
+ if (isNaN(n3) || isNaN(o2)) isNaN(n3) ? isNaN(o2) ? h2 = NaN : (h2 = o2, 1 !== s2 && 0 !== s2 || (p2 = l2)) : (h2 = n3, 1 !== u2 && 0 !== u2 || (p2 = i2));
+ else {
+ let t5 = o2 - n3;
+ o2 > n3 && t5 > 180 ? t5 -= 360 : o2 < n3 && n3 - o2 > 180 && (t5 += 360), h2 = n3 + r2 * t5;
+ }
+ const [f2, d2, y2, m2] = function([t5, e3, r3, n4]) {
+ return t5 = isNaN(t5) ? 0 : t5 * Et, Ot([r3, Math.cos(t5) * e3, Math.sin(t5) * e3, n4]);
+ }([h2, null != p2 ? p2 : ze(i2, l2, r2), ze(s2, u2, r2), ze(a2, c2, r2)]);
+ return new Kt(f2, d2, y2, m2, false);
+ }
+ case "lab": {
+ const [n3, i2, s2, a2] = Ot(Pe(t4.lab, e2.lab, r2));
+ return new Kt(n3, i2, s2, a2, false);
+ }
+ }
+ }, array: Pe, padding: function(t4, e2, r2) {
+ return new Jt(Pe(t4.values, e2.values, r2));
+ }, variableAnchorOffsetCollection: function(t4, e2, r2) {
+ const n2 = t4.values, i2 = e2.values;
+ if (n2.length !== i2.length) throw new ae(`Cannot interpolate values of different length. from: ${t4.toString()}, to: ${e2.toString()}`);
+ const s2 = [];
+ for (let t5 = 0; t5 < n2.length; t5 += 2) {
+ if (n2[t5] !== i2[t5]) throw new ae(`Cannot interpolate values containing mismatched anchors. from[${t5}]: ${n2[t5]}, to[${t5}]: ${i2[t5]}`);
+ s2.push(n2[t5]);
+ const [e3, a2] = n2[t5 + 1], [o2, l2] = i2[t5 + 1];
+ s2.push([ze(e3, o2, r2), ze(a2, l2, r2)]);
+ }
+ return new Qt(s2);
+ } };
+ class Be {
+ constructor(t4, e2, r2, n2, i2) {
+ this.type = t4, this.operator = e2, this.interpolation = r2, this.input = n2, this.labels = [], this.outputs = [];
+ for (const [t5, e3] of i2) this.labels.push(t5), this.outputs.push(e3);
+ }
+ static interpolationFactor(t4, e2, r2, n2) {
+ let i2 = 0;
+ if ("exponential" === t4.name) i2 = Ve(e2, t4.base, r2, n2);
+ else if ("linear" === t4.name) i2 = Ve(e2, 1, r2, n2);
+ else if ("cubic-bezier" === t4.name) {
+ const s2 = t4.controlPoints;
+ i2 = new Ie(s2[0], s2[1], s2[2], s2[3]).solve(Ve(e2, 1, r2, n2));
+ }
+ return i2;
+ }
+ static parse(t4, e2) {
+ let [r2, n2, i2, ...s2] = t4;
+ if (!Array.isArray(n2) || 0 === n2.length) return e2.error("Expected an interpolation type expression.", 1);
+ if ("linear" === n2[0]) n2 = { name: "linear" };
+ else if ("exponential" === n2[0]) {
+ const t5 = n2[1];
+ if ("number" != typeof t5) return e2.error("Exponential interpolation requires a numeric base.", 1, 1);
+ n2 = { name: "exponential", base: t5 };
+ } else {
+ if ("cubic-bezier" !== n2[0]) return e2.error(`Unknown interpolation type ${String(n2[0])}`, 1, 0);
+ {
+ const t5 = n2.slice(1);
+ if (4 !== t5.length || t5.some((t6) => "number" != typeof t6 || t6 < 0 || t6 > 1)) return e2.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.", 1);
+ n2 = { name: "cubic-bezier", controlPoints: t5 };
+ }
+ }
+ if (t4.length - 1 < 4) return e2.error(`Expected at least 4 arguments, but found only ${t4.length - 1}.`);
+ if ((t4.length - 1) % 2 != 0) return e2.error("Expected an even number of arguments.");
+ if (i2 = e2.parse(i2, 2, ut), !i2) return null;
+ const a2 = [];
+ let o2 = null;
+ "interpolate-hcl" === r2 || "interpolate-lab" === r2 ? o2 = pt : e2.expectedType && "value" !== e2.expectedType.kind && (o2 = e2.expectedType);
+ for (let t5 = 0; t5 < s2.length; t5 += 2) {
+ const r3 = s2[t5], n3 = s2[t5 + 1], i3 = t5 + 3, l2 = t5 + 4;
+ if ("number" != typeof r3) return e2.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.', i3);
+ if (a2.length && a2[a2.length - 1][0] >= r3) return e2.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.', i3);
+ const u2 = e2.parse(n3, l2, o2);
+ if (!u2) return null;
+ o2 = o2 || u2.type, a2.push([r3, u2]);
+ }
+ return Mt(o2, ut) || Mt(o2, pt) || Mt(o2, gt) || Mt(o2, vt) || Mt(o2, bt(ut)) ? new Be(o2, r2, n2, i2, a2) : e2.error(`Type ${wt(o2)} is not interpolatable.`);
+ }
+ evaluate(t4) {
+ const e2 = this.labels, r2 = this.outputs;
+ if (1 === e2.length) return r2[0].evaluate(t4);
+ const n2 = this.input.evaluate(t4);
+ if (n2 <= e2[0]) return r2[0].evaluate(t4);
+ const i2 = e2.length;
+ if (n2 >= e2[i2 - 1]) return r2[i2 - 1].evaluate(t4);
+ const s2 = _e(e2, n2), a2 = Be.interpolationFactor(this.interpolation, n2, e2[s2], e2[s2 + 1]), o2 = r2[s2].evaluate(t4), l2 = r2[s2 + 1].evaluate(t4);
+ switch (this.operator) {
+ case "interpolate":
+ return Ce[this.type.kind](o2, l2, a2);
+ case "interpolate-hcl":
+ return Ce.color(o2, l2, a2, "hcl");
+ case "interpolate-lab":
+ return Ce.color(o2, l2, a2, "lab");
+ }
+ }
+ eachChild(t4) {
+ t4(this.input);
+ for (const e2 of this.outputs) t4(e2);
+ }
+ outputDefined() {
+ return this.outputs.every((t4) => t4.outputDefined());
+ }
+ }
+ function Ve(t4, e2, r2, n2) {
+ const i2 = n2 - r2, s2 = t4 - r2;
+ return 0 === i2 ? 0 : 1 === e2 ? s2 / i2 : (Math.pow(e2, s2) - 1) / (Math.pow(e2, i2) - 1);
+ }
+ class Ee {
+ constructor(t4, e2) {
+ this.type = t4, this.args = e2;
+ }
+ static parse(t4, e2) {
+ if (t4.length < 2) return e2.error("Expectected at least one argument.");
+ let r2 = null;
+ const n2 = e2.expectedType;
+ n2 && "value" !== n2.kind && (r2 = n2);
+ const i2 = [];
+ for (const n3 of t4.slice(1)) {
+ const t5 = e2.parse(n3, 1 + i2.length, r2, void 0, { typeAnnotation: "omit" });
+ if (!t5) return null;
+ r2 = r2 || t5.type, i2.push(t5);
+ }
+ if (!r2) throw new Error("No output type");
+ const s2 = n2 && i2.some((t5) => At(n2, t5.type));
+ return new Ee(s2 ? dt : r2, i2);
+ }
+ evaluate(t4) {
+ let e2, r2 = null, n2 = 0;
+ for (const i2 of this.args) if (n2++, r2 = i2.evaluate(t4), r2 && r2 instanceof te && !r2.available && (e2 || (e2 = r2.name), r2 = null, n2 === this.args.length && (r2 = e2)), null !== r2) break;
+ return r2;
+ }
+ eachChild(t4) {
+ this.args.forEach(t4);
+ }
+ outputDefined() {
+ return this.args.every((t4) => t4.outputDefined());
+ }
+ }
+ function Fe(t4, e2) {
+ return "==" === t4 || "!=" === t4 ? "boolean" === e2.kind || "string" === e2.kind || "number" === e2.kind || "null" === e2.kind || "value" === e2.kind : "string" === e2.kind || "number" === e2.kind || "value" === e2.kind;
+ }
+ function Te(t4, e2, r2, n2) {
+ return 0 === n2.compare(e2, r2);
+ }
+ function $e(t4, e2, r2) {
+ const n2 = "==" !== t4 && "!=" !== t4;
+ return class i2 {
+ constructor(t5, e3, r3) {
+ this.type = ht, this.lhs = t5, this.rhs = e3, this.collator = r3, this.hasUntypedArgument = "value" === t5.type.kind || "value" === e3.type.kind;
+ }
+ static parse(t5, e3) {
+ if (3 !== t5.length && 4 !== t5.length) return e3.error("Expected two or three arguments.");
+ const r3 = t5[0];
+ let s2 = e3.parse(t5[1], 1, dt);
+ if (!s2) return null;
+ if (!Fe(r3, s2.type)) return e3.concat(1).error(`"${r3}" comparisons are not supported for type '${wt(s2.type)}'.`);
+ let a2 = e3.parse(t5[2], 2, dt);
+ if (!a2) return null;
+ if (!Fe(r3, a2.type)) return e3.concat(2).error(`"${r3}" comparisons are not supported for type '${wt(a2.type)}'.`);
+ if (s2.type.kind !== a2.type.kind && "value" !== s2.type.kind && "value" !== a2.type.kind) return e3.error(`Cannot compare types '${wt(s2.type)}' and '${wt(a2.type)}'.`);
+ n2 && ("value" === s2.type.kind && "value" !== a2.type.kind ? s2 = new le(a2.type, [s2]) : "value" !== s2.type.kind && "value" === a2.type.kind && (a2 = new le(s2.type, [a2])));
+ let o2 = null;
+ if (4 === t5.length) {
+ if ("string" !== s2.type.kind && "string" !== a2.type.kind && "value" !== s2.type.kind && "value" !== a2.type.kind) return e3.error("Cannot use collator to compare non-string types.");
+ if (o2 = e3.parse(t5[3], 3, yt), !o2) return null;
+ }
+ return new i2(s2, a2, o2);
+ }
+ evaluate(i3) {
+ const s2 = this.lhs.evaluate(i3), a2 = this.rhs.evaluate(i3);
+ if (n2 && this.hasUntypedArgument) {
+ const e3 = ne(s2), r3 = ne(a2);
+ if (e3.kind !== r3.kind || "string" !== e3.kind && "number" !== e3.kind) throw new ae(`Expected arguments for "${t4}" to be (string, string) or (number, number), but found (${e3.kind}, ${r3.kind}) instead.`);
+ }
+ if (this.collator && !n2 && this.hasUntypedArgument) {
+ const t5 = ne(s2), r3 = ne(a2);
+ if ("string" !== t5.kind || "string" !== r3.kind) return e2(i3, s2, a2);
+ }
+ return this.collator ? r2(i3, s2, a2, this.collator.evaluate(i3)) : e2(i3, s2, a2);
+ }
+ eachChild(t5) {
+ t5(this.lhs), t5(this.rhs), this.collator && t5(this.collator);
+ }
+ outputDefined() {
+ return true;
+ }
+ };
+ }
+ const Le = $e("==", function(t4, e2, r2) {
+ return e2 === r2;
+ }, Te), De = $e("!=", function(t4, e2, r2) {
+ return e2 !== r2;
+ }, function(t4, e2, r2, n2) {
+ return !Te(0, e2, r2, n2);
+ }), Oe = $e("<", function(t4, e2, r2) {
+ return e2 < r2;
+ }, function(t4, e2, r2, n2) {
+ return n2.compare(e2, r2) < 0;
+ }), je = $e(">", function(t4, e2, r2) {
+ return e2 > r2;
+ }, function(t4, e2, r2, n2) {
+ return n2.compare(e2, r2) > 0;
+ }), Re = $e("<=", function(t4, e2, r2) {
+ return e2 <= r2;
+ }, function(t4, e2, r2, n2) {
+ return n2.compare(e2, r2) <= 0;
+ }), Ue = $e(">=", function(t4, e2, r2) {
+ return e2 >= r2;
+ }, function(t4, e2, r2, n2) {
+ return n2.compare(e2, r2) >= 0;
+ });
+ class qe {
+ constructor(t4, e2, r2) {
+ this.type = yt, this.locale = r2, this.caseSensitive = t4, this.diacriticSensitive = e2;
+ }
+ static parse(t4, e2) {
+ if (2 !== t4.length) return e2.error("Expected one argument.");
+ const r2 = t4[1];
+ if ("object" != typeof r2 || Array.isArray(r2)) return e2.error("Collator options argument must be an object.");
+ const n2 = e2.parse(void 0 !== r2["case-sensitive"] && r2["case-sensitive"], 1, ht);
+ if (!n2) return null;
+ const i2 = e2.parse(void 0 !== r2["diacritic-sensitive"] && r2["diacritic-sensitive"], 1, ht);
+ if (!i2) return null;
+ let s2 = null;
+ return r2.locale && (s2 = e2.parse(r2.locale, 1, ct), !s2) ? null : new qe(n2, i2, s2);
+ }
+ evaluate(t4) {
+ return new Xt(this.caseSensitive.evaluate(t4), this.diacriticSensitive.evaluate(t4), this.locale ? this.locale.evaluate(t4) : null);
+ }
+ eachChild(t4) {
+ t4(this.caseSensitive), t4(this.diacriticSensitive), this.locale && t4(this.locale);
+ }
+ outputDefined() {
+ return false;
+ }
+ }
+ class Ne {
+ constructor(t4, e2, r2, n2, i2) {
+ this.type = ct, this.number = t4, this.locale = e2, this.currency = r2, this.minFractionDigits = n2, this.maxFractionDigits = i2;
+ }
+ static parse(t4, e2) {
+ if (3 !== t4.length) return e2.error("Expected two arguments.");
+ const r2 = e2.parse(t4[1], 1, ut);
+ if (!r2) return null;
+ const n2 = t4[2];
+ if ("object" != typeof n2 || Array.isArray(n2)) return e2.error("NumberFormat options argument must be an object.");
+ let i2 = null;
+ if (n2.locale && (i2 = e2.parse(n2.locale, 1, ct), !i2)) return null;
+ let s2 = null;
+ if (n2.currency && (s2 = e2.parse(n2.currency, 1, ct), !s2)) return null;
+ let a2 = null;
+ if (n2["min-fraction-digits"] && (a2 = e2.parse(n2["min-fraction-digits"], 1, ut), !a2)) return null;
+ let o2 = null;
+ return n2["max-fraction-digits"] && (o2 = e2.parse(n2["max-fraction-digits"], 1, ut), !o2) ? null : new Ne(r2, i2, s2, a2, o2);
+ }
+ evaluate(t4) {
+ return new Intl.NumberFormat(this.locale ? this.locale.evaluate(t4) : [], { style: this.currency ? "currency" : "decimal", currency: this.currency ? this.currency.evaluate(t4) : void 0, minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(t4) : void 0, maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(t4) : void 0 }).format(this.number.evaluate(t4));
+ }
+ eachChild(t4) {
+ t4(this.number), this.locale && t4(this.locale), this.currency && t4(this.currency), this.minFractionDigits && t4(this.minFractionDigits), this.maxFractionDigits && t4(this.maxFractionDigits);
+ }
+ outputDefined() {
+ return false;
+ }
+ }
+ class Ze {
+ constructor(t4) {
+ this.type = mt, this.sections = t4;
+ }
+ static parse(t4, e2) {
+ if (t4.length < 2) return e2.error("Expected at least one argument.");
+ const r2 = t4[1];
+ if (!Array.isArray(r2) && "object" == typeof r2) return e2.error("First argument must be an image or text section.");
+ const n2 = [];
+ let i2 = false;
+ for (let r3 = 1; r3 <= t4.length - 1; ++r3) {
+ const s2 = t4[r3];
+ if (i2 && "object" == typeof s2 && !Array.isArray(s2)) {
+ i2 = false;
+ let t5 = null;
+ if (s2["font-scale"] && (t5 = e2.parse(s2["font-scale"], 1, ut), !t5)) return null;
+ let r4 = null;
+ if (s2["text-font"] && (r4 = e2.parse(s2["text-font"], 1, bt(ct)), !r4)) return null;
+ let a2 = null;
+ if (s2["text-color"] && (a2 = e2.parse(s2["text-color"], 1, pt), !a2)) return null;
+ const o2 = n2[n2.length - 1];
+ o2.scale = t5, o2.font = r4, o2.textColor = a2;
+ } else {
+ const s3 = e2.parse(t4[r3], 1, dt);
+ if (!s3) return null;
+ const a2 = s3.type.kind;
+ if ("string" !== a2 && "value" !== a2 && "null" !== a2 && "resolvedImage" !== a2) return e2.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");
+ i2 = true, n2.push({ content: s3, scale: null, font: null, textColor: null });
+ }
+ }
+ return new Ze(n2);
+ }
+ evaluate(t4) {
+ return new Yt(this.sections.map((e2) => {
+ const r2 = e2.content.evaluate(t4);
+ return ne(r2) === xt ? new Ht("", r2, null, null, null) : new Ht(ie(r2), null, e2.scale ? e2.scale.evaluate(t4) : null, e2.font ? e2.font.evaluate(t4).join(",") : null, e2.textColor ? e2.textColor.evaluate(t4) : null);
+ }));
+ }
+ eachChild(t4) {
+ for (const e2 of this.sections) t4(e2.content), e2.scale && t4(e2.scale), e2.font && t4(e2.font), e2.textColor && t4(e2.textColor);
+ }
+ outputDefined() {
+ return false;
+ }
+ }
+ class Ge {
+ constructor(t4) {
+ this.type = xt, this.input = t4;
+ }
+ static parse(t4, e2) {
+ if (2 !== t4.length) return e2.error("Expected two arguments.");
+ const r2 = e2.parse(t4[1], 1, ct);
+ return r2 ? new Ge(r2) : e2.error("No image name provided.");
+ }
+ evaluate(t4) {
+ const e2 = this.input.evaluate(t4), r2 = te.fromString(e2);
+ return r2 && t4.availableImages && (r2.available = t4.availableImages.indexOf(e2) > -1), r2;
+ }
+ eachChild(t4) {
+ t4(this.input);
+ }
+ outputDefined() {
+ return false;
+ }
+ }
+ class Ke {
+ constructor(t4) {
+ this.type = ut, this.input = t4;
+ }
+ static parse(t4, e2) {
+ if (2 !== t4.length) return e2.error(`Expected 1 argument, but found ${t4.length - 1} instead.`);
+ const r2 = e2.parse(t4[1], 1);
+ return r2 ? "array" !== r2.type.kind && "string" !== r2.type.kind && "value" !== r2.type.kind ? e2.error(`Expected argument of type string or array, but found ${wt(r2.type)} instead.`) : new Ke(r2) : null;
+ }
+ evaluate(t4) {
+ const e2 = this.input.evaluate(t4);
+ if ("string" == typeof e2) return [...e2].length;
+ if (Array.isArray(e2)) return e2.length;
+ throw new ae(`Expected value to be of type string or array, but found ${wt(ne(e2))} instead.`);
+ }
+ eachChild(t4) {
+ t4(this.input);
+ }
+ outputDefined() {
+ return false;
+ }
+ }
+ const Xe = 8192;
+ function He(t4, e2) {
+ const r2 = (180 + t4[0]) / 360, n2 = (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + t4[1] * Math.PI / 360))) / 360, i2 = Math.pow(2, e2.z);
+ return [Math.round(r2 * i2 * Xe), Math.round(n2 * i2 * Xe)];
+ }
+ function Ye(t4, e2) {
+ const r2 = Math.pow(2, e2.z);
+ return [(i2 = (t4[0] / Xe + e2.x) / r2, 360 * i2 - 180), (n2 = (t4[1] / Xe + e2.y) / r2, 360 / Math.PI * Math.atan(Math.exp((180 - 360 * n2) * Math.PI / 180)) - 90)];
+ var n2, i2;
+ }
+ function Je(t4, e2) {
+ t4[0] = Math.min(t4[0], e2[0]), t4[1] = Math.min(t4[1], e2[1]), t4[2] = Math.max(t4[2], e2[0]), t4[3] = Math.max(t4[3], e2[1]);
+ }
+ function We(t4, e2) {
+ return !(t4[0] <= e2[0] || t4[2] >= e2[2] || t4[1] <= e2[1] || t4[3] >= e2[3]);
+ }
+ function Qe(t4, e2, r2) {
+ const n2 = t4[0] - e2[0], i2 = t4[1] - e2[1], s2 = t4[0] - r2[0], a2 = t4[1] - r2[1];
+ return n2 * a2 - s2 * i2 == 0 && n2 * s2 <= 0 && i2 * a2 <= 0;
+ }
+ function tr(t4, e2, r2, n2) {
+ return 0 != (i2 = [n2[0] - r2[0], n2[1] - r2[1]])[0] * (s2 = [e2[0] - t4[0], e2[1] - t4[1]])[1] - i2[1] * s2[0] && !(!ar(t4, e2, r2, n2) || !ar(r2, n2, t4, e2));
+ var i2, s2;
+ }
+ function er(t4, e2, r2) {
+ for (const n2 of r2) for (let r3 = 0; r3 < n2.length - 1; ++r3) if (tr(t4, e2, n2[r3], n2[r3 + 1])) return true;
+ return false;
+ }
+ function rr(t4, e2, r2 = false) {
+ let n2 = false;
+ for (const o2 of e2) for (let e3 = 0; e3 < o2.length - 1; e3++) {
+ if (Qe(t4, o2[e3], o2[e3 + 1])) return r2;
+ (s2 = o2[e3])[1] > (i2 = t4)[1] != (a2 = o2[e3 + 1])[1] > i2[1] && i2[0] < (a2[0] - s2[0]) * (i2[1] - s2[1]) / (a2[1] - s2[1]) + s2[0] && (n2 = !n2);
+ }
+ var i2, s2, a2;
+ return n2;
+ }
+ function nr(t4, e2) {
+ for (const r2 of e2) if (rr(t4, r2)) return true;
+ return false;
+ }
+ function ir(t4, e2) {
+ for (const r2 of t4) if (!rr(r2, e2)) return false;
+ for (let r2 = 0; r2 < t4.length - 1; ++r2) if (er(t4[r2], t4[r2 + 1], e2)) return false;
+ return true;
+ }
+ function sr(t4, e2) {
+ for (const r2 of e2) if (ir(t4, r2)) return true;
+ return false;
+ }
+ function ar(t4, e2, r2, n2) {
+ const i2 = n2[0] - r2[0], s2 = n2[1] - r2[1], a2 = (t4[0] - r2[0]) * s2 - i2 * (t4[1] - r2[1]), o2 = (e2[0] - r2[0]) * s2 - i2 * (e2[1] - r2[1]);
+ return a2 > 0 && o2 < 0 || a2 < 0 && o2 > 0;
+ }
+ function or(t4, e2, r2) {
+ const n2 = [];
+ for (let i2 = 0; i2 < t4.length; i2++) {
+ const s2 = [];
+ for (let n3 = 0; n3 < t4[i2].length; n3++) {
+ const a2 = He(t4[i2][n3], r2);
+ Je(e2, a2), s2.push(a2);
+ }
+ n2.push(s2);
+ }
+ return n2;
+ }
+ function lr(t4, e2, r2) {
+ const n2 = [];
+ for (let i2 = 0; i2 < t4.length; i2++) {
+ const s2 = or(t4[i2], e2, r2);
+ n2.push(s2);
+ }
+ return n2;
+ }
+ function ur(t4, e2, r2, n2) {
+ if (t4[0] < r2[0] || t4[0] > r2[2]) {
+ const e3 = 0.5 * n2;
+ let i2 = t4[0] - r2[0] > e3 ? -n2 : r2[0] - t4[0] > e3 ? n2 : 0;
+ 0 === i2 && (i2 = t4[0] - r2[2] > e3 ? -n2 : r2[2] - t4[0] > e3 ? n2 : 0), t4[0] += i2;
+ }
+ Je(e2, t4);
+ }
+ function cr(t4, e2, r2, n2) {
+ const i2 = Math.pow(2, n2.z) * Xe, s2 = [n2.x * Xe, n2.y * Xe], a2 = [];
+ for (const n3 of t4) for (const t5 of n3) {
+ const n4 = [t5.x + s2[0], t5.y + s2[1]];
+ ur(n4, e2, r2, i2), a2.push(n4);
+ }
+ return a2;
+ }
+ function hr(t4, e2, r2, n2) {
+ const i2 = Math.pow(2, n2.z) * Xe, s2 = [n2.x * Xe, n2.y * Xe], a2 = [];
+ for (const r3 of t4) {
+ const t5 = [];
+ for (const n3 of r3) {
+ const r4 = [n3.x + s2[0], n3.y + s2[1]];
+ Je(e2, r4), t5.push(r4);
+ }
+ a2.push(t5);
+ }
+ if (e2[2] - e2[0] <= i2 / 2) {
+ (o2 = e2)[0] = o2[1] = 1 / 0, o2[2] = o2[3] = -1 / 0;
+ for (const t5 of a2) for (const n3 of t5) ur(n3, e2, r2, i2);
+ }
+ var o2;
+ return a2;
+ }
+ class pr {
+ constructor(t4, e2) {
+ this.type = ht, this.geojson = t4, this.geometries = e2;
+ }
+ static parse(t4, e2) {
+ if (2 !== t4.length) return e2.error(`'within' expression requires exactly one argument, but found ${t4.length - 1} instead.`);
+ if (re(t4[1])) {
+ const e3 = t4[1];
+ if ("FeatureCollection" === e3.type) {
+ const t5 = [];
+ for (const r2 of e3.features) {
+ const { type: e4, coordinates: n2 } = r2.geometry;
+ "Polygon" === e4 && t5.push(n2), "MultiPolygon" === e4 && t5.push(...n2);
+ }
+ if (t5.length) return new pr(e3, { type: "MultiPolygon", coordinates: t5 });
+ } else if ("Feature" === e3.type) {
+ const t5 = e3.geometry.type;
+ if ("Polygon" === t5 || "MultiPolygon" === t5) return new pr(e3, e3.geometry);
+ } else if ("Polygon" === e3.type || "MultiPolygon" === e3.type) return new pr(e3, e3);
+ }
+ return e2.error("'within' expression requires valid geojson object that contains polygon geometry type.");
+ }
+ evaluate(t4) {
+ if (null != t4.geometry() && null != t4.canonicalID()) {
+ if ("Point" === t4.geometryType()) return function(t5, e2) {
+ const r2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], n2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], i2 = t5.canonicalID();
+ if ("Polygon" === e2.type) {
+ const s2 = or(e2.coordinates, n2, i2), a2 = cr(t5.geometry(), r2, n2, i2);
+ if (!We(r2, n2)) return false;
+ for (const t6 of a2) if (!rr(t6, s2)) return false;
+ }
+ if ("MultiPolygon" === e2.type) {
+ const s2 = lr(e2.coordinates, n2, i2), a2 = cr(t5.geometry(), r2, n2, i2);
+ if (!We(r2, n2)) return false;
+ for (const t6 of a2) if (!nr(t6, s2)) return false;
+ }
+ return true;
+ }(t4, this.geometries);
+ if ("LineString" === t4.geometryType()) return function(t5, e2) {
+ const r2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], n2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0], i2 = t5.canonicalID();
+ if ("Polygon" === e2.type) {
+ const s2 = or(e2.coordinates, n2, i2), a2 = hr(t5.geometry(), r2, n2, i2);
+ if (!We(r2, n2)) return false;
+ for (const t6 of a2) if (!ir(t6, s2)) return false;
+ }
+ if ("MultiPolygon" === e2.type) {
+ const s2 = lr(e2.coordinates, n2, i2), a2 = hr(t5.geometry(), r2, n2, i2);
+ if (!We(r2, n2)) return false;
+ for (const t6 of a2) if (!sr(t6, s2)) return false;
+ }
+ return true;
+ }(t4, this.geometries);
+ }
+ return false;
+ }
+ eachChild() {
+ }
+ outputDefined() {
+ return true;
+ }
+ }
+ let fr = class {
+ constructor(t4 = [], e2 = (t5, e3) => t5 < e3 ? -1 : t5 > e3 ? 1 : 0) {
+ if (this.data = t4, this.length = this.data.length, this.compare = e2, this.length > 0) for (let t5 = (this.length >> 1) - 1; t5 >= 0; t5--) this._down(t5);
+ }
+ push(t4) {
+ this.data.push(t4), this._up(this.length++);
+ }
+ pop() {
+ if (0 === this.length) return;
+ const t4 = this.data[0], e2 = this.data.pop();
+ return --this.length > 0 && (this.data[0] = e2, this._down(0)), t4;
+ }
+ peek() {
+ return this.data[0];
+ }
+ _up(t4) {
+ const { data: e2, compare: r2 } = this, n2 = e2[t4];
+ for (; t4 > 0; ) {
+ const i2 = t4 - 1 >> 1, s2 = e2[i2];
+ if (r2(n2, s2) >= 0) break;
+ e2[t4] = s2, t4 = i2;
+ }
+ e2[t4] = n2;
+ }
+ _down(t4) {
+ const { data: e2, compare: r2 } = this, n2 = this.length >> 1, i2 = e2[t4];
+ for (; t4 < n2; ) {
+ let n3 = 1 + (t4 << 1);
+ const s2 = n3 + 1;
+ if (s2 < this.length && r2(e2[s2], e2[n3]) < 0 && (n3 = s2), r2(e2[n3], i2) >= 0) break;
+ e2[t4] = e2[n3], t4 = n3;
+ }
+ e2[t4] = i2;
+ }
+ };
+ function dr(t4, e2, r2, n2, i2) {
+ yr(t4, e2, r2, n2 || t4.length - 1, i2 || gr);
+ }
+ function yr(t4, e2, r2, n2, i2) {
+ for (; n2 > r2; ) {
+ if (n2 - r2 > 600) {
+ var s2 = n2 - r2 + 1, a2 = e2 - r2 + 1, o2 = Math.log(s2), l2 = 0.5 * Math.exp(2 * o2 / 3), u2 = 0.5 * Math.sqrt(o2 * l2 * (s2 - l2) / s2) * (a2 - s2 / 2 < 0 ? -1 : 1);
+ yr(t4, e2, Math.max(r2, Math.floor(e2 - a2 * l2 / s2 + u2)), Math.min(n2, Math.floor(e2 + (s2 - a2) * l2 / s2 + u2)), i2);
+ }
+ var c2 = t4[e2], h2 = r2, p2 = n2;
+ for (mr(t4, r2, e2), i2(t4[n2], c2) > 0 && mr(t4, r2, n2); h2 < p2; ) {
+ for (mr(t4, h2, p2), h2++, p2--; i2(t4[h2], c2) < 0; ) h2++;
+ for (; i2(t4[p2], c2) > 0; ) p2--;
+ }
+ 0 === i2(t4[r2], c2) ? mr(t4, r2, p2) : mr(t4, ++p2, n2), p2 <= e2 && (r2 = p2 + 1), e2 <= p2 && (n2 = p2 - 1);
+ }
+ }
+ function mr(t4, e2, r2) {
+ var n2 = t4[e2];
+ t4[e2] = t4[r2], t4[r2] = n2;
+ }
+ function gr(t4, e2) {
+ return t4 < e2 ? -1 : t4 > e2 ? 1 : 0;
+ }
+ function xr(t4, e2) {
+ if (t4.length <= 1) return [t4];
+ const r2 = [];
+ let n2, i2;
+ for (const e3 of t4) {
+ const t5 = br(e3);
+ 0 !== t5 && (e3.area = Math.abs(t5), void 0 === i2 && (i2 = t5 < 0), i2 === t5 < 0 ? (n2 && r2.push(n2), n2 = [e3]) : n2.push(e3));
+ }
+ if (n2 && r2.push(n2), e2 > 1) for (let t5 = 0; t5 < r2.length; t5++) r2[t5].length <= e2 || (dr(r2[t5], e2, 1, r2[t5].length - 1, vr), r2[t5] = r2[t5].slice(0, e2));
+ return r2;
+ }
+ function vr(t4, e2) {
+ return e2.area - t4.area;
+ }
+ function br(t4) {
+ let e2 = 0;
+ for (let r2, n2, i2 = 0, s2 = t4.length, a2 = s2 - 1; i2 < s2; a2 = i2++) r2 = t4[i2], n2 = t4[a2], e2 += (n2.x - r2.x) * (r2.y + n2.y);
+ return e2;
+ }
+ const wr = 1 / 298.257223563, _r = wr * (2 - wr), Ar = Math.PI / 180;
+ class Sr {
+ constructor(t4) {
+ const e2 = 6378.137 * Ar * 1e3, r2 = Math.cos(t4 * Ar), n2 = 1 / (1 - _r * (1 - r2 * r2)), i2 = Math.sqrt(n2);
+ this.kx = e2 * i2 * r2, this.ky = e2 * i2 * n2 * (1 - _r);
+ }
+ distance(t4, e2) {
+ const r2 = this.wrap(t4[0] - e2[0]) * this.kx, n2 = (t4[1] - e2[1]) * this.ky;
+ return Math.sqrt(r2 * r2 + n2 * n2);
+ }
+ pointOnLine(t4, e2) {
+ let r2, n2, i2, s2, a2 = 1 / 0;
+ for (let o2 = 0; o2 < t4.length - 1; o2++) {
+ let l2 = t4[o2][0], u2 = t4[o2][1], c2 = this.wrap(t4[o2 + 1][0] - l2) * this.kx, h2 = (t4[o2 + 1][1] - u2) * this.ky, p2 = 0;
+ 0 === c2 && 0 === h2 || (p2 = (this.wrap(e2[0] - l2) * this.kx * c2 + (e2[1] - u2) * this.ky * h2) / (c2 * c2 + h2 * h2), p2 > 1 ? (l2 = t4[o2 + 1][0], u2 = t4[o2 + 1][1]) : p2 > 0 && (l2 += c2 / this.kx * p2, u2 += h2 / this.ky * p2)), c2 = this.wrap(e2[0] - l2) * this.kx, h2 = (e2[1] - u2) * this.ky;
+ const f2 = c2 * c2 + h2 * h2;
+ f2 < a2 && (a2 = f2, r2 = l2, n2 = u2, i2 = o2, s2 = p2);
+ }
+ return { point: [r2, n2], index: i2, t: Math.max(0, Math.min(1, s2)) };
+ }
+ wrap(t4) {
+ for (; t4 < -180; ) t4 += 360;
+ for (; t4 > 180; ) t4 -= 360;
+ return t4;
+ }
+ }
+ function kr(t4, e2) {
+ return e2[0] - t4[0];
+ }
+ function Mr(t4) {
+ return t4[1] - t4[0] + 1;
+ }
+ function Ir(t4, e2) {
+ return t4[1] >= t4[0] && t4[1] < e2;
+ }
+ function zr(t4, e2) {
+ if (t4[0] > t4[1]) return [null, null];
+ const r2 = Mr(t4);
+ if (e2) {
+ if (2 === r2) return [t4, null];
+ const e3 = Math.floor(r2 / 2);
+ return [[t4[0], t4[0] + e3], [t4[0] + e3, t4[1]]];
+ }
+ if (1 === r2) return [t4, null];
+ const n2 = Math.floor(r2 / 2) - 1;
+ return [[t4[0], t4[0] + n2], [t4[0] + n2 + 1, t4[1]]];
+ }
+ function Pr(t4, e2) {
+ if (!Ir(e2, t4.length)) return [1 / 0, 1 / 0, -1 / 0, -1 / 0];
+ const r2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
+ for (let n2 = e2[0]; n2 <= e2[1]; ++n2) Je(r2, t4[n2]);
+ return r2;
+ }
+ function Cr(t4) {
+ const e2 = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
+ for (const r2 of t4) for (const t5 of r2) Je(e2, t5);
+ return e2;
+ }
+ function Br(t4) {
+ return t4[0] !== -1 / 0 && t4[1] !== -1 / 0 && t4[2] !== 1 / 0 && t4[3] !== 1 / 0;
+ }
+ function Vr(t4, e2, r2) {
+ if (!Br(t4) || !Br(e2)) return NaN;
+ let n2 = 0, i2 = 0;
+ return t4[2] < e2[0] && (n2 = e2[0] - t4[2]), t4[0] > e2[2] && (n2 = t4[0] - e2[2]), t4[1] > e2[3] && (i2 = t4[1] - e2[3]), t4[3] < e2[1] && (i2 = e2[1] - t4[3]), r2.distance([0, 0], [n2, i2]);
+ }
+ function Er(t4, e2, r2) {
+ const n2 = r2.pointOnLine(e2, t4);
+ return r2.distance(t4, n2.point);
+ }
+ function Fr(t4, e2, r2, n2, i2) {
+ const s2 = Math.min(Er(t4, [r2, n2], i2), Er(e2, [r2, n2], i2)), a2 = Math.min(Er(r2, [t4, e2], i2), Er(n2, [t4, e2], i2));
+ return Math.min(s2, a2);
+ }
+ function Tr(t4, e2, r2, n2, i2) {
+ if (!Ir(e2, t4.length) || !Ir(n2, r2.length)) return 1 / 0;
+ let s2 = 1 / 0;
+ for (let a2 = e2[0]; a2 < e2[1]; ++a2) {
+ const e3 = t4[a2], o2 = t4[a2 + 1];
+ for (let t5 = n2[0]; t5 < n2[1]; ++t5) {
+ const n3 = r2[t5], a3 = r2[t5 + 1];
+ if (tr(e3, o2, n3, a3)) return 0;
+ s2 = Math.min(s2, Fr(e3, o2, n3, a3, i2));
+ }
+ }
+ return s2;
+ }
+ function $r(t4, e2, r2, n2, i2) {
+ if (!Ir(e2, t4.length) || !Ir(n2, r2.length)) return NaN;
+ let s2 = 1 / 0;
+ for (let a2 = e2[0]; a2 <= e2[1]; ++a2) for (let e3 = n2[0]; e3 <= n2[1]; ++e3) if (s2 = Math.min(s2, i2.distance(t4[a2], r2[e3])), 0 === s2) return s2;
+ return s2;
+ }
+ function Lr(t4, e2, r2) {
+ if (rr(t4, e2, true)) return 0;
+ let n2 = 1 / 0;
+ for (const i2 of e2) {
+ const e3 = i2[0], s2 = i2[i2.length - 1];
+ if (e3 !== s2 && (n2 = Math.min(n2, Er(t4, [s2, e3], r2)), 0 === n2)) return n2;
+ const a2 = r2.pointOnLine(i2, t4);
+ if (n2 = Math.min(n2, r2.distance(t4, a2.point)), 0 === n2) return n2;
+ }
+ return n2;
+ }
+ function Dr(t4, e2, r2, n2) {
+ if (!Ir(e2, t4.length)) return NaN;
+ for (let n3 = e2[0]; n3 <= e2[1]; ++n3) if (rr(t4[n3], r2, true)) return 0;
+ let i2 = 1 / 0;
+ for (let s2 = e2[0]; s2 < e2[1]; ++s2) {
+ const e3 = t4[s2], a2 = t4[s2 + 1];
+ for (const t5 of r2) for (let r3 = 0, s3 = t5.length, o2 = s3 - 1; r3 < s3; o2 = r3++) {
+ const s4 = t5[o2], l2 = t5[r3];
+ if (tr(e3, a2, s4, l2)) return 0;
+ i2 = Math.min(i2, Fr(e3, a2, s4, l2, n2));
+ }
+ }
+ return i2;
+ }
+ function Or(t4, e2) {
+ for (const r2 of t4) for (const t5 of r2) if (rr(t5, e2, true)) return true;
+ return false;
+ }
+ function jr(t4, e2, r2, n2 = 1 / 0) {
+ const i2 = Cr(t4), s2 = Cr(e2);
+ if (n2 !== 1 / 0 && Vr(i2, s2, r2) >= n2) return n2;
+ if (We(i2, s2)) {
+ if (Or(t4, e2)) return 0;
+ } else if (Or(e2, t4)) return 0;
+ let a2 = 1 / 0;
+ for (const n3 of t4) for (let t5 = 0, i3 = n3.length, s3 = i3 - 1; t5 < i3; s3 = t5++) {
+ const i4 = n3[s3], o2 = n3[t5];
+ for (const t6 of e2) for (let e3 = 0, n4 = t6.length, s4 = n4 - 1; e3 < n4; s4 = e3++) {
+ const n5 = t6[s4], l2 = t6[e3];
+ if (tr(i4, o2, n5, l2)) return 0;
+ a2 = Math.min(a2, Fr(i4, o2, n5, l2, r2));
+ }
+ }
+ return a2;
+ }
+ function Rr(t4, e2, r2, n2, i2, s2) {
+ if (!s2) return;
+ const a2 = Vr(Pr(n2, s2), i2, r2);
+ a2 < e2 && t4.push([a2, s2, [0, 0]]);
+ }
+ function Ur(t4, e2, r2, n2, i2, s2, a2) {
+ if (!s2 || !a2) return;
+ const o2 = Vr(Pr(n2, s2), Pr(i2, a2), r2);
+ o2 < e2 && t4.push([o2, s2, a2]);
+ }
+ function qr(t4, e2, r2, n2, i2 = 1 / 0) {
+ let s2 = Math.min(n2.distance(t4[0], r2[0][0]), i2);
+ if (0 === s2) return s2;
+ const a2 = new fr([[0, [0, t4.length - 1], [0, 0]]], kr), o2 = Cr(r2);
+ for (; a2.length > 0; ) {
+ const i3 = a2.pop();
+ if (i3[0] >= s2) continue;
+ const l2 = i3[1], u2 = e2 ? 50 : 100;
+ if (Mr(l2) <= u2) {
+ if (!Ir(l2, t4.length)) return NaN;
+ if (e2) {
+ const e3 = Dr(t4, l2, r2, n2);
+ if (isNaN(e3) || 0 === e3) return e3;
+ s2 = Math.min(s2, e3);
+ } else for (let e3 = l2[0]; e3 <= l2[1]; ++e3) {
+ const i4 = Lr(t4[e3], r2, n2);
+ if (s2 = Math.min(s2, i4), 0 === s2) return 0;
+ }
+ } else {
+ const r3 = zr(l2, e2);
+ Rr(a2, s2, n2, t4, o2, r3[0]), Rr(a2, s2, n2, t4, o2, r3[1]);
+ }
+ }
+ return s2;
+ }
+ function Nr(t4, e2, r2, n2, i2, s2 = 1 / 0) {
+ let a2 = Math.min(s2, i2.distance(t4[0], r2[0]));
+ if (0 === a2) return a2;
+ const o2 = new fr([[0, [0, t4.length - 1], [0, r2.length - 1]]], kr);
+ for (; o2.length > 0; ) {
+ const s3 = o2.pop();
+ if (s3[0] >= a2) continue;
+ const l2 = s3[1], u2 = s3[2], c2 = e2 ? 50 : 100, h2 = n2 ? 50 : 100;
+ if (Mr(l2) <= c2 && Mr(u2) <= h2) {
+ if (!Ir(l2, t4.length) && Ir(u2, r2.length)) return NaN;
+ let s4;
+ if (e2 && n2) s4 = Tr(t4, l2, r2, u2, i2), a2 = Math.min(a2, s4);
+ else if (e2 && !n2) {
+ const e3 = t4.slice(l2[0], l2[1] + 1);
+ for (let t5 = u2[0]; t5 <= u2[1]; ++t5) if (s4 = Er(r2[t5], e3, i2), a2 = Math.min(a2, s4), 0 === a2) return a2;
+ } else if (!e2 && n2) {
+ const e3 = r2.slice(u2[0], u2[1] + 1);
+ for (let r3 = l2[0]; r3 <= l2[1]; ++r3) if (s4 = Er(t4[r3], e3, i2), a2 = Math.min(a2, s4), 0 === a2) return a2;
+ } else s4 = $r(t4, l2, r2, u2, i2), a2 = Math.min(a2, s4);
+ } else {
+ const s4 = zr(l2, e2), c3 = zr(u2, n2);
+ Ur(o2, a2, i2, t4, r2, s4[0], c3[0]), Ur(o2, a2, i2, t4, r2, s4[0], c3[1]), Ur(o2, a2, i2, t4, r2, s4[1], c3[0]), Ur(o2, a2, i2, t4, r2, s4[1], c3[1]);
+ }
+ }
+ return a2;
+ }
+ function Zr(t4) {
+ return "MultiPolygon" === t4.type ? t4.coordinates.map((t5) => ({ type: "Polygon", coordinates: t5 })) : "MultiLineString" === t4.type ? t4.coordinates.map((t5) => ({ type: "LineString", coordinates: t5 })) : "MultiPoint" === t4.type ? t4.coordinates.map((t5) => ({ type: "Point", coordinates: t5 })) : [t4];
+ }
+ class Gr {
+ constructor(t4, e2) {
+ this.type = ut, this.geojson = t4, this.geometries = e2;
+ }
+ static parse(t4, e2) {
+ if (2 !== t4.length) return e2.error(`'distance' expression requires exactly one argument, but found ${t4.length - 1} instead.`);
+ if (re(t4[1])) {
+ const e3 = t4[1];
+ if ("FeatureCollection" === e3.type) return new Gr(e3, e3.features.map((t5) => Zr(t5.geometry)).flat());
+ if ("Feature" === e3.type) return new Gr(e3, Zr(e3.geometry));
+ if ("type" in e3 && "coordinates" in e3) return new Gr(e3, Zr(e3));
+ }
+ return e2.error("'distance' expression requires valid geojson object that contains polygon geometry type.");
+ }
+ evaluate(t4) {
+ if (null != t4.geometry() && null != t4.canonicalID()) {
+ if ("Point" === t4.geometryType()) return function(t5, e2) {
+ const r2 = t5.geometry(), n2 = r2.flat().map((e3) => Ye([e3.x, e3.y], t5.canonical));
+ if (0 === r2.length) return NaN;
+ const i2 = new Sr(n2[0][1]);
+ let s2 = 1 / 0;
+ for (const t6 of e2) {
+ switch (t6.type) {
+ case "Point":
+ s2 = Math.min(s2, Nr(n2, false, [t6.coordinates], false, i2, s2));
+ break;
+ case "LineString":
+ s2 = Math.min(s2, Nr(n2, false, t6.coordinates, true, i2, s2));
+ break;
+ case "Polygon":
+ s2 = Math.min(s2, qr(n2, false, t6.coordinates, i2, s2));
+ }
+ if (0 === s2) return s2;
+ }
+ return s2;
+ }(t4, this.geometries);
+ if ("LineString" === t4.geometryType()) return function(t5, e2) {
+ const r2 = t5.geometry(), n2 = r2.flat().map((e3) => Ye([e3.x, e3.y], t5.canonical));
+ if (0 === r2.length) return NaN;
+ const i2 = new Sr(n2[0][1]);
+ let s2 = 1 / 0;
+ for (const t6 of e2) {
+ switch (t6.type) {
+ case "Point":
+ s2 = Math.min(s2, Nr(n2, true, [t6.coordinates], false, i2, s2));
+ break;
+ case "LineString":
+ s2 = Math.min(s2, Nr(n2, true, t6.coordinates, true, i2, s2));
+ break;
+ case "Polygon":
+ s2 = Math.min(s2, qr(n2, true, t6.coordinates, i2, s2));
+ }
+ if (0 === s2) return s2;
+ }
+ return s2;
+ }(t4, this.geometries);
+ if ("Polygon" === t4.geometryType()) return function(t5, e2) {
+ const r2 = t5.geometry();
+ if (0 === r2.length || 0 === r2[0].length) return NaN;
+ const n2 = xr(r2, 0).map((e3) => e3.map((e4) => e4.map((e5) => Ye([e5.x, e5.y], t5.canonical)))), i2 = new Sr(n2[0][0][0][1]);
+ let s2 = 1 / 0;
+ for (const t6 of e2) for (const e3 of n2) {
+ switch (t6.type) {
+ case "Point":
+ s2 = Math.min(s2, qr([t6.coordinates], false, e3, i2, s2));
+ break;
+ case "LineString":
+ s2 = Math.min(s2, qr(t6.coordinates, true, e3, i2, s2));
+ break;
+ case "Polygon":
+ s2 = Math.min(s2, jr(e3, t6.coordinates, i2, s2));
+ }
+ if (0 === s2) return s2;
+ }
+ return s2;
+ }(t4, this.geometries);
+ }
+ return NaN;
+ }
+ eachChild() {
+ }
+ outputDefined() {
+ return true;
+ }
+ }
+ const Kr = { "==": Le, "!=": De, ">": je, "<": Oe, ">=": Ue, "<=": Re, array: le, at: me, boolean: le, case: be, coalesce: Ee, collator: qe, format: Ze, image: Ge, in: ge, "index-of": xe, interpolate: Be, "interpolate-hcl": Be, "interpolate-lab": Be, length: Ke, let: de, literal: se, match: ve, number: le, "number-format": Ne, object: le, slice: we, step: Ae, string: le, "to-boolean": ce, "to-color": ce, "to-number": ce, "to-string": ce, var: ye, within: pr, distance: Gr };
+ class Xr {
+ constructor(t4, e2, r2, n2) {
+ this.name = t4, this.type = e2, this._evaluate = r2, this.args = n2;
+ }
+ evaluate(t4) {
+ return this._evaluate(t4, this.args);
+ }
+ eachChild(t4) {
+ this.args.forEach(t4);
+ }
+ outputDefined() {
+ return false;
+ }
+ static parse(t4, e2) {
+ const r2 = t4[0], n2 = Xr.definitions[r2];
+ if (!n2) return e2.error(`Unknown expression "${r2}". If you wanted a literal array, use ["literal", [...]].`, 0);
+ const i2 = Array.isArray(n2) ? n2[0] : n2.type, s2 = Array.isArray(n2) ? [[n2[1], n2[2]]] : n2.overloads, a2 = s2.filter(([e3]) => !Array.isArray(e3) || e3.length === t4.length - 1);
+ let o2 = null;
+ for (const [n3, s3] of a2) {
+ o2 = new fe(e2.registry, Qr, e2.path, null, e2.scope);
+ const a3 = [];
+ let l2 = false;
+ for (let e3 = 1; e3 < t4.length; e3++) {
+ const r3 = t4[e3], i3 = Array.isArray(n3) ? n3[e3 - 1] : n3.type, s4 = o2.parse(r3, 1 + a3.length, i3);
+ if (!s4) {
+ l2 = true;
+ break;
+ }
+ a3.push(s4);
+ }
+ if (!l2) if (Array.isArray(n3) && n3.length !== a3.length) o2.error(`Expected ${n3.length} arguments, but found ${a3.length} instead.`);
+ else {
+ for (let t5 = 0; t5 < a3.length; t5++) {
+ const e3 = Array.isArray(n3) ? n3[t5] : n3.type, r3 = a3[t5];
+ o2.concat(t5 + 1).checkSubtype(e3, r3.type);
+ }
+ if (0 === o2.errors.length) return new Xr(r2, i2, s3, a3);
+ }
+ }
+ if (1 === a2.length) e2.errors.push(...o2.errors);
+ else {
+ const r3 = (a2.length ? a2 : s2).map(([t5]) => {
+ return e3 = t5, Array.isArray(e3) ? `(${e3.map(wt).join(", ")})` : `(${wt(e3.type)}...)`;
+ var e3;
+ }).join(" | "), n3 = [];
+ for (let r4 = 1; r4 < t4.length; r4++) {
+ const i3 = e2.parse(t4[r4], 1 + n3.length);
+ if (!i3) return null;
+ n3.push(wt(i3.type));
+ }
+ e2.error(`Expected arguments of type ${r3}, but found (${n3.join(", ")}) instead.`);
+ }
+ return null;
+ }
+ static register(t4, e2) {
+ Xr.definitions = e2;
+ for (const r2 in e2) t4[r2] = Xr;
+ }
+ }
+ function Hr(t4, [e2, r2, n2, i2]) {
+ e2 = e2.evaluate(t4), r2 = r2.evaluate(t4), n2 = n2.evaluate(t4);
+ const s2 = i2 ? i2.evaluate(t4) : 1, a2 = ee(e2, r2, n2, s2);
+ if (a2) throw new ae(a2);
+ return new Kt(e2 / 255, r2 / 255, n2 / 255, s2, false);
+ }
+ function Yr(t4, e2) {
+ return t4 in e2;
+ }
+ function Jr(t4, e2) {
+ const r2 = e2[t4];
+ return void 0 === r2 ? null : r2;
+ }
+ function Wr(t4) {
+ return { type: t4 };
+ }
+ function Qr(t4) {
+ if (t4 instanceof ye) return Qr(t4.boundExpression);
+ if (t4 instanceof Xr && "error" === t4.name) return false;
+ if (t4 instanceof qe) return false;
+ if (t4 instanceof pr) return false;
+ if (t4 instanceof Gr) return false;
+ const e2 = t4 instanceof ce || t4 instanceof le;
+ let r2 = true;
+ return t4.eachChild((t5) => {
+ r2 = e2 ? r2 && Qr(t5) : r2 && t5 instanceof se;
+ }), !!r2 && tn(t4) && rn(t4, ["zoom", "heatmap-density", "line-progress", "accumulated", "is-supported-script"]);
+ }
+ function tn(t4) {
+ if (t4 instanceof Xr) {
+ if ("get" === t4.name && 1 === t4.args.length) return false;
+ if ("feature-state" === t4.name) return false;
+ if ("has" === t4.name && 1 === t4.args.length) return false;
+ if ("properties" === t4.name || "geometry-type" === t4.name || "id" === t4.name) return false;
+ if (/^filter-/.test(t4.name)) return false;
+ }
+ if (t4 instanceof pr) return false;
+ if (t4 instanceof Gr) return false;
+ let e2 = true;
+ return t4.eachChild((t5) => {
+ e2 && !tn(t5) && (e2 = false);
+ }), e2;
+ }
+ function en(t4) {
+ if (t4 instanceof Xr && "feature-state" === t4.name) return false;
+ let e2 = true;
+ return t4.eachChild((t5) => {
+ e2 && !en(t5) && (e2 = false);
+ }), e2;
+ }
+ function rn(t4, e2) {
+ if (t4 instanceof Xr && e2.indexOf(t4.name) >= 0) return false;
+ let r2 = true;
+ return t4.eachChild((t5) => {
+ r2 && !rn(t5, e2) && (r2 = false);
+ }), r2;
+ }
+ function nn(t4) {
+ return { result: "success", value: t4 };
+ }
+ function sn(t4) {
+ return { result: "error", value: t4 };
+ }
+ function an(t4) {
+ return "data-driven" === t4["property-type"] || "cross-faded-data-driven" === t4["property-type"];
+ }
+ function on(t4) {
+ return !!t4.expression && t4.expression.parameters.indexOf("zoom") > -1;
+ }
+ function ln(t4) {
+ return !!t4.expression && t4.expression.interpolated;
+ }
+ function un(t4) {
+ return t4 instanceof Number ? "number" : t4 instanceof String ? "string" : t4 instanceof Boolean ? "boolean" : Array.isArray(t4) ? "array" : null === t4 ? "null" : typeof t4;
+ }
+ function cn(t4) {
+ return "object" == typeof t4 && null !== t4 && !Array.isArray(t4);
+ }
+ function hn(t4) {
+ return t4;
+ }
+ function pn(t4, e2) {
+ const r2 = "color" === e2.type, n2 = t4.stops && "object" == typeof t4.stops[0][0], i2 = n2 || !(n2 || void 0 !== t4.property), s2 = t4.type || (ln(e2) ? "exponential" : "interval");
+ if (r2 || "padding" === e2.type) {
+ const n3 = r2 ? Kt.parse : Jt.parse;
+ (t4 = st({}, t4)).stops && (t4.stops = t4.stops.map((t5) => [t5[0], n3(t5[1])])), t4.default = n3(t4.default ? t4.default : e2.default);
+ }
+ if (t4.colorSpace && "rgb" !== (a2 = t4.colorSpace) && "hcl" !== a2 && "lab" !== a2) throw new Error(`Unknown color space: "${t4.colorSpace}"`);
+ var a2;
+ let o2, l2, u2;
+ if ("exponential" === s2) o2 = mn;
+ else if ("interval" === s2) o2 = yn;
+ else if ("categorical" === s2) {
+ o2 = dn, l2 = /* @__PURE__ */ Object.create(null);
+ for (const e3 of t4.stops) l2[e3[0]] = e3[1];
+ u2 = typeof t4.stops[0][0];
+ } else {
+ if ("identity" !== s2) throw new Error(`Unknown function type "${s2}"`);
+ o2 = gn;
+ }
+ if (n2) {
+ const r3 = {}, n3 = [];
+ for (let e3 = 0; e3 < t4.stops.length; e3++) {
+ const i4 = t4.stops[e3], s4 = i4[0].zoom;
+ void 0 === r3[s4] && (r3[s4] = { zoom: s4, type: t4.type, property: t4.property, default: t4.default, stops: [] }, n3.push(s4)), r3[s4].stops.push([i4[0].value, i4[1]]);
+ }
+ const i3 = [];
+ for (const t5 of n3) i3.push([r3[t5].zoom, pn(r3[t5], e2)]);
+ const s3 = { name: "linear" };
+ return { kind: "composite", interpolationType: s3, interpolationFactor: Be.interpolationFactor.bind(void 0, s3), zoomStops: i3.map((t5) => t5[0]), evaluate: ({ zoom: r4 }, n4) => mn({ stops: i3, base: t4.base }, e2, r4).evaluate(r4, n4) };
+ }
+ if (i2) {
+ const r3 = "exponential" === s2 ? { name: "exponential", base: void 0 !== t4.base ? t4.base : 1 } : null;
+ return { kind: "camera", interpolationType: r3, interpolationFactor: Be.interpolationFactor.bind(void 0, r3), zoomStops: t4.stops.map((t5) => t5[0]), evaluate: ({ zoom: r4 }) => o2(t4, e2, r4, l2, u2) };
+ }
+ return { kind: "source", evaluate(r3, n3) {
+ const i3 = n3 && n3.properties ? n3.properties[t4.property] : void 0;
+ return void 0 === i3 ? fn(t4.default, e2.default) : o2(t4, e2, i3, l2, u2);
+ } };
+ }
+ function fn(t4, e2, r2) {
+ return void 0 !== t4 ? t4 : void 0 !== e2 ? e2 : void 0 !== r2 ? r2 : void 0;
+ }
+ function dn(t4, e2, r2, n2, i2) {
+ return fn(typeof r2 === i2 ? n2[r2] : void 0, t4.default, e2.default);
+ }
+ function yn(t4, e2, r2) {
+ if ("number" !== un(r2)) return fn(t4.default, e2.default);
+ const n2 = t4.stops.length;
+ if (1 === n2) return t4.stops[0][1];
+ if (r2 <= t4.stops[0][0]) return t4.stops[0][1];
+ if (r2 >= t4.stops[n2 - 1][0]) return t4.stops[n2 - 1][1];
+ const i2 = _e(t4.stops.map((t5) => t5[0]), r2);
+ return t4.stops[i2][1];
+ }
+ function mn(t4, e2, r2) {
+ const n2 = void 0 !== t4.base ? t4.base : 1;
+ if ("number" !== un(r2)) return fn(t4.default, e2.default);
+ const i2 = t4.stops.length;
+ if (1 === i2) return t4.stops[0][1];
+ if (r2 <= t4.stops[0][0]) return t4.stops[0][1];
+ if (r2 >= t4.stops[i2 - 1][0]) return t4.stops[i2 - 1][1];
+ const s2 = _e(t4.stops.map((t5) => t5[0]), r2), a2 = function(t5, e3, r3, n3) {
+ const i3 = n3 - r3, s3 = t5 - r3;
+ return 0 === i3 ? 0 : 1 === e3 ? s3 / i3 : (Math.pow(e3, s3) - 1) / (Math.pow(e3, i3) - 1);
+ }(r2, n2, t4.stops[s2][0], t4.stops[s2 + 1][0]), o2 = t4.stops[s2][1], l2 = t4.stops[s2 + 1][1], u2 = Ce[e2.type] || hn;
+ return "function" == typeof o2.evaluate ? { evaluate(...e3) {
+ const r3 = o2.evaluate.apply(void 0, e3), n3 = l2.evaluate.apply(void 0, e3);
+ if (void 0 !== r3 && void 0 !== n3) return u2(r3, n3, a2, t4.colorSpace);
+ } } : u2(o2, l2, a2, t4.colorSpace);
+ }
+ function gn(t4, e2, r2) {
+ switch (e2.type) {
+ case "color":
+ r2 = Kt.parse(r2);
+ break;
+ case "formatted":
+ r2 = Yt.fromString(r2.toString());
+ break;
+ case "resolvedImage":
+ r2 = te.fromString(r2.toString());
+ break;
+ case "padding":
+ r2 = Jt.parse(r2);
+ break;
+ default:
+ un(r2) === e2.type || "enum" === e2.type && e2.values[r2] || (r2 = void 0);
+ }
+ return fn(r2, t4.default, e2.default);
+ }
+ Xr.register(Kr, { error: [{ kind: "error" }, [ct], (t4, [e2]) => {
+ throw new ae(e2.evaluate(t4));
+ }], typeof: [ct, [dt], (t4, [e2]) => wt(ne(e2.evaluate(t4)))], "to-rgba": [bt(ut, 4), [pt], (t4, [e2]) => {
+ const [r2, n2, i2, s2] = e2.evaluate(t4).rgb;
+ return [255 * r2, 255 * n2, 255 * i2, s2];
+ }], rgb: [pt, [ut, ut, ut], Hr], rgba: [pt, [ut, ut, ut, ut], Hr], has: { type: ht, overloads: [[[ct], (t4, [e2]) => Yr(e2.evaluate(t4), t4.properties())], [[ct, ft], (t4, [e2, r2]) => Yr(e2.evaluate(t4), r2.evaluate(t4))]] }, get: { type: dt, overloads: [[[ct], (t4, [e2]) => Jr(e2.evaluate(t4), t4.properties())], [[ct, ft], (t4, [e2, r2]) => Jr(e2.evaluate(t4), r2.evaluate(t4))]] }, "feature-state": [dt, [ct], (t4, [e2]) => Jr(e2.evaluate(t4), t4.featureState || {})], properties: [ft, [], (t4) => t4.properties()], "geometry-type": [ct, [], (t4) => t4.geometryType()], id: [dt, [], (t4) => t4.id()], zoom: [ut, [], (t4) => t4.globals.zoom], "heatmap-density": [ut, [], (t4) => t4.globals.heatmapDensity || 0], "line-progress": [ut, [], (t4) => t4.globals.lineProgress || 0], accumulated: [dt, [], (t4) => void 0 === t4.globals.accumulated ? null : t4.globals.accumulated], "+": [ut, Wr(ut), (t4, e2) => {
+ let r2 = 0;
+ for (const n2 of e2) r2 += n2.evaluate(t4);
+ return r2;
+ }], "*": [ut, Wr(ut), (t4, e2) => {
+ let r2 = 1;
+ for (const n2 of e2) r2 *= n2.evaluate(t4);
+ return r2;
+ }], "-": { type: ut, overloads: [[[ut, ut], (t4, [e2, r2]) => e2.evaluate(t4) - r2.evaluate(t4)], [[ut], (t4, [e2]) => -e2.evaluate(t4)]] }, "/": [ut, [ut, ut], (t4, [e2, r2]) => e2.evaluate(t4) / r2.evaluate(t4)], "%": [ut, [ut, ut], (t4, [e2, r2]) => e2.evaluate(t4) % r2.evaluate(t4)], ln2: [ut, [], () => Math.LN2], pi: [ut, [], () => Math.PI], e: [ut, [], () => Math.E], "^": [ut, [ut, ut], (t4, [e2, r2]) => Math.pow(e2.evaluate(t4), r2.evaluate(t4))], sqrt: [ut, [ut], (t4, [e2]) => Math.sqrt(e2.evaluate(t4))], log10: [ut, [ut], (t4, [e2]) => Math.log(e2.evaluate(t4)) / Math.LN10], ln: [ut, [ut], (t4, [e2]) => Math.log(e2.evaluate(t4))], log2: [ut, [ut], (t4, [e2]) => Math.log(e2.evaluate(t4)) / Math.LN2], sin: [ut, [ut], (t4, [e2]) => Math.sin(e2.evaluate(t4))], cos: [ut, [ut], (t4, [e2]) => Math.cos(e2.evaluate(t4))], tan: [ut, [ut], (t4, [e2]) => Math.tan(e2.evaluate(t4))], asin: [ut, [ut], (t4, [e2]) => Math.asin(e2.evaluate(t4))], acos: [ut, [ut], (t4, [e2]) => Math.acos(e2.evaluate(t4))], atan: [ut, [ut], (t4, [e2]) => Math.atan(e2.evaluate(t4))], min: [ut, Wr(ut), (t4, e2) => Math.min(...e2.map((e3) => e3.evaluate(t4)))], max: [ut, Wr(ut), (t4, e2) => Math.max(...e2.map((e3) => e3.evaluate(t4)))], abs: [ut, [ut], (t4, [e2]) => Math.abs(e2.evaluate(t4))], round: [ut, [ut], (t4, [e2]) => {
+ const r2 = e2.evaluate(t4);
+ return r2 < 0 ? -Math.round(-r2) : Math.round(r2);
+ }], floor: [ut, [ut], (t4, [e2]) => Math.floor(e2.evaluate(t4))], ceil: [ut, [ut], (t4, [e2]) => Math.ceil(e2.evaluate(t4))], "filter-==": [ht, [ct, dt], (t4, [e2, r2]) => t4.properties()[e2.value] === r2.value], "filter-id-==": [ht, [dt], (t4, [e2]) => t4.id() === e2.value], "filter-type-==": [ht, [ct], (t4, [e2]) => t4.geometryType() === e2.value], "filter-<": [ht, [ct, dt], (t4, [e2, r2]) => {
+ const n2 = t4.properties()[e2.value], i2 = r2.value;
+ return typeof n2 == typeof i2 && n2 < i2;
+ }], "filter-id-<": [ht, [dt], (t4, [e2]) => {
+ const r2 = t4.id(), n2 = e2.value;
+ return typeof r2 == typeof n2 && r2 < n2;
+ }], "filter->": [ht, [ct, dt], (t4, [e2, r2]) => {
+ const n2 = t4.properties()[e2.value], i2 = r2.value;
+ return typeof n2 == typeof i2 && n2 > i2;
+ }], "filter-id->": [ht, [dt], (t4, [e2]) => {
+ const r2 = t4.id(), n2 = e2.value;
+ return typeof r2 == typeof n2 && r2 > n2;
+ }], "filter-<=": [ht, [ct, dt], (t4, [e2, r2]) => {
+ const n2 = t4.properties()[e2.value], i2 = r2.value;
+ return typeof n2 == typeof i2 && n2 <= i2;
+ }], "filter-id-<=": [ht, [dt], (t4, [e2]) => {
+ const r2 = t4.id(), n2 = e2.value;
+ return typeof r2 == typeof n2 && r2 <= n2;
+ }], "filter->=": [ht, [ct, dt], (t4, [e2, r2]) => {
+ const n2 = t4.properties()[e2.value], i2 = r2.value;
+ return typeof n2 == typeof i2 && n2 >= i2;
+ }], "filter-id->=": [ht, [dt], (t4, [e2]) => {
+ const r2 = t4.id(), n2 = e2.value;
+ return typeof r2 == typeof n2 && r2 >= n2;
+ }], "filter-has": [ht, [dt], (t4, [e2]) => e2.value in t4.properties()], "filter-has-id": [ht, [], (t4) => null !== t4.id() && void 0 !== t4.id()], "filter-type-in": [ht, [bt(ct)], (t4, [e2]) => e2.value.indexOf(t4.geometryType()) >= 0], "filter-id-in": [ht, [bt(dt)], (t4, [e2]) => e2.value.indexOf(t4.id()) >= 0], "filter-in-small": [ht, [ct, bt(dt)], (t4, [e2, r2]) => r2.value.indexOf(t4.properties()[e2.value]) >= 0], "filter-in-large": [ht, [ct, bt(dt)], (t4, [e2, r2]) => function(t5, e3, r3, n2) {
+ for (; r3 <= n2; ) {
+ const i2 = r3 + n2 >> 1;
+ if (e3[i2] === t5) return true;
+ e3[i2] > t5 ? n2 = i2 - 1 : r3 = i2 + 1;
+ }
+ return false;
+ }(t4.properties()[e2.value], r2.value, 0, r2.value.length - 1)], all: { type: ht, overloads: [[[ht, ht], (t4, [e2, r2]) => e2.evaluate(t4) && r2.evaluate(t4)], [Wr(ht), (t4, e2) => {
+ for (const r2 of e2) if (!r2.evaluate(t4)) return false;
+ return true;
+ }]] }, any: { type: ht, overloads: [[[ht, ht], (t4, [e2, r2]) => e2.evaluate(t4) || r2.evaluate(t4)], [Wr(ht), (t4, e2) => {
+ for (const r2 of e2) if (r2.evaluate(t4)) return true;
+ return false;
+ }]] }, "!": [ht, [ht], (t4, [e2]) => !e2.evaluate(t4)], "is-supported-script": [ht, [ct], (t4, [e2]) => {
+ const r2 = t4.globals && t4.globals.isSupportedScript;
+ return !r2 || r2(e2.evaluate(t4));
+ }], upcase: [ct, [ct], (t4, [e2]) => e2.evaluate(t4).toUpperCase()], downcase: [ct, [ct], (t4, [e2]) => e2.evaluate(t4).toLowerCase()], concat: [ct, Wr(dt), (t4, e2) => e2.map((e3) => ie(e3.evaluate(t4))).join("")], "resolved-locale": [ct, [yt], (t4, [e2]) => e2.evaluate(t4).resolvedLocale()] });
+ class xn {
+ constructor(t4, e2) {
+ var r2;
+ this.expression = t4, this._warningHistory = {}, this._evaluator = new pe(), this._defaultValue = e2 ? "color" === (r2 = e2).type && cn(r2.default) ? new Kt(0, 0, 0, 0) : "color" === r2.type ? Kt.parse(r2.default) || null : "padding" === r2.type ? Jt.parse(r2.default) || null : "variableAnchorOffsetCollection" === r2.type ? Qt.parse(r2.default) || null : void 0 === r2.default ? null : r2.default : null, this._enumValues = e2 && "enum" === e2.type ? e2.values : null;
+ }
+ evaluateWithoutErrorHandling(t4, e2, r2, n2, i2, s2) {
+ return this._evaluator.globals = t4, this._evaluator.feature = e2, this._evaluator.featureState = r2, this._evaluator.canonical = n2, this._evaluator.availableImages = i2 || null, this._evaluator.formattedSection = s2, this.expression.evaluate(this._evaluator);
+ }
+ evaluate(t4, e2, r2, n2, i2, s2) {
+ this._evaluator.globals = t4, this._evaluator.feature = e2 || null, this._evaluator.featureState = r2 || null, this._evaluator.canonical = n2, this._evaluator.availableImages = i2 || null, this._evaluator.formattedSection = s2 || null;
+ try {
+ const t5 = this.expression.evaluate(this._evaluator);
+ if (null == t5 || "number" == typeof t5 && t5 != t5) return this._defaultValue;
+ if (this._enumValues && !(t5 in this._enumValues)) throw new ae(`Expected value to be one of ${Object.keys(this._enumValues).map((t6) => JSON.stringify(t6)).join(", ")}, but found ${JSON.stringify(t5)} instead.`);
+ return t5;
+ } catch (t5) {
+ return this._warningHistory[t5.message] || (this._warningHistory[t5.message] = true, "undefined" != typeof console && console.warn(t5.message)), this._defaultValue;
+ }
+ }
+ }
+ function vn(t4) {
+ return Array.isArray(t4) && t4.length > 0 && "string" == typeof t4[0] && t4[0] in Kr;
+ }
+ function bn(t4, e2) {
+ const r2 = new fe(Kr, Qr, [], e2 ? function(t5) {
+ const e3 = { color: pt, string: ct, number: ut, enum: ct, boolean: ht, formatted: mt, padding: gt, resolvedImage: xt, variableAnchorOffsetCollection: vt };
+ return "array" === t5.type ? bt(e3[t5.value] || dt, t5.length) : e3[t5.type];
+ }(e2) : void 0), n2 = r2.parse(t4, void 0, void 0, void 0, e2 && "string" === e2.type ? { typeAnnotation: "coerce" } : void 0);
+ return n2 ? nn(new xn(n2, e2)) : sn(r2.errors);
+ }
+ class wn {
+ constructor(t4, e2) {
+ this.kind = t4, this._styleExpression = e2, this.isStateDependent = "constant" !== t4 && !en(e2.expression);
+ }
+ evaluateWithoutErrorHandling(t4, e2, r2, n2, i2, s2) {
+ return this._styleExpression.evaluateWithoutErrorHandling(t4, e2, r2, n2, i2, s2);
+ }
+ evaluate(t4, e2, r2, n2, i2, s2) {
+ return this._styleExpression.evaluate(t4, e2, r2, n2, i2, s2);
+ }
+ }
+ class _n {
+ constructor(t4, e2, r2, n2) {
+ this.kind = t4, this.zoomStops = r2, this._styleExpression = e2, this.isStateDependent = "camera" !== t4 && !en(e2.expression), this.interpolationType = n2;
+ }
+ evaluateWithoutErrorHandling(t4, e2, r2, n2, i2, s2) {
+ return this._styleExpression.evaluateWithoutErrorHandling(t4, e2, r2, n2, i2, s2);
+ }
+ evaluate(t4, e2, r2, n2, i2, s2) {
+ return this._styleExpression.evaluate(t4, e2, r2, n2, i2, s2);
+ }
+ interpolationFactor(t4, e2, r2) {
+ return this.interpolationType ? Be.interpolationFactor(this.interpolationType, t4, e2, r2) : 0;
+ }
+ }
+ function An(t4, e2) {
+ const r2 = bn(t4, e2);
+ if ("error" === r2.result) return r2;
+ const n2 = r2.value.expression, i2 = tn(n2);
+ if (!i2 && !an(e2)) return sn([new at("", "data expressions not supported")]);
+ const s2 = rn(n2, ["zoom"]);
+ if (!s2 && !on(e2)) return sn([new at("", "zoom expressions not supported")]);
+ const a2 = kn(n2);
+ return a2 || s2 ? a2 instanceof at ? sn([a2]) : a2 instanceof Be && !ln(e2) ? sn([new at("", '"interpolate" expressions cannot be used with this property')]) : nn(a2 ? new _n(i2 ? "camera" : "composite", r2.value, a2.labels, a2 instanceof Be ? a2.interpolation : void 0) : new wn(i2 ? "constant" : "source", r2.value)) : sn([new at("", '"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);
+ }
+ class Sn {
+ constructor(t4, e2) {
+ this._parameters = t4, this._specification = e2, st(this, pn(this._parameters, this._specification));
+ }
+ static deserialize(t4) {
+ return new Sn(t4._parameters, t4._specification);
+ }
+ static serialize(t4) {
+ return { _parameters: t4._parameters, _specification: t4._specification };
+ }
+ }
+ function kn(t4) {
+ let e2 = null;
+ if (t4 instanceof de) e2 = kn(t4.result);
+ else if (t4 instanceof Ee) {
+ for (const r2 of t4.args) if (e2 = kn(r2), e2) break;
+ } else (t4 instanceof Ae || t4 instanceof Be) && t4.input instanceof Xr && "zoom" === t4.input.name && (e2 = t4);
+ return e2 instanceof at || t4.eachChild((t5) => {
+ const r2 = kn(t5);
+ r2 instanceof at ? e2 = r2 : !e2 && r2 ? e2 = new at("", '"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.') : e2 && r2 && e2 !== r2 && (e2 = new at("", 'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));
+ }), e2;
+ }
+ function Mn(t4) {
+ if (true === t4 || false === t4) return true;
+ if (!Array.isArray(t4) || 0 === t4.length) return false;
+ switch (t4[0]) {
+ case "has":
+ return t4.length >= 2 && "$id" !== t4[1] && "$type" !== t4[1];
+ case "in":
+ return t4.length >= 3 && ("string" != typeof t4[1] || Array.isArray(t4[2]));
+ case "!in":
+ case "!has":
+ case "none":
+ return false;
+ case "==":
+ case "!=":
+ case ">":
+ case ">=":
+ case "<":
+ case "<=":
+ return 3 !== t4.length || Array.isArray(t4[1]) || Array.isArray(t4[2]);
+ case "any":
+ case "all":
+ for (const e2 of t4.slice(1)) if (!Mn(e2) && "boolean" != typeof e2) return false;
+ return true;
+ default:
+ return true;
+ }
+ }
+ const In = { type: "boolean", default: false, transition: false, "property-type": "data-driven", expression: { interpolated: false, parameters: ["zoom", "feature"] } };
+ function zn(t4) {
+ if (null == t4) return { filter: () => true, needGeometry: false };
+ Mn(t4) || (t4 = Bn(t4));
+ const e2 = bn(t4, In);
+ if ("error" === e2.result) throw new Error(e2.value.map((t5) => `${t5.key}: ${t5.message}`).join(", "));
+ return { filter: (t5, r2, n2) => e2.value.evaluate(t5, r2, {}, n2), needGeometry: Cn(t4) };
+ }
+ function Pn(t4, e2) {
+ return t4 < e2 ? -1 : t4 > e2 ? 1 : 0;
+ }
+ function Cn(t4) {
+ if (!Array.isArray(t4)) return false;
+ if ("within" === t4[0] || "distance" === t4[0]) return true;
+ for (let e2 = 1; e2 < t4.length; e2++) if (Cn(t4[e2])) return true;
+ return false;
+ }
+ function Bn(t4) {
+ if (!t4) return true;
+ const e2 = t4[0];
+ return t4.length <= 1 ? "any" !== e2 : "==" === e2 ? Vn(t4[1], t4[2], "==") : "!=" === e2 ? Tn(Vn(t4[1], t4[2], "==")) : "<" === e2 || ">" === e2 || "<=" === e2 || ">=" === e2 ? Vn(t4[1], t4[2], e2) : "any" === e2 ? (r2 = t4.slice(1), ["any"].concat(r2.map(Bn))) : "all" === e2 ? ["all"].concat(t4.slice(1).map(Bn)) : "none" === e2 ? ["all"].concat(t4.slice(1).map(Bn).map(Tn)) : "in" === e2 ? En(t4[1], t4.slice(2)) : "!in" === e2 ? Tn(En(t4[1], t4.slice(2))) : "has" === e2 ? Fn(t4[1]) : "!has" !== e2 || Tn(Fn(t4[1]));
+ var r2;
+ }
+ function Vn(t4, e2, r2) {
+ switch (t4) {
+ case "$type":
+ return [`filter-type-${r2}`, e2];
+ case "$id":
+ return [`filter-id-${r2}`, e2];
+ default:
+ return [`filter-${r2}`, t4, e2];
+ }
+ }
+ function En(t4, e2) {
+ if (0 === e2.length) return false;
+ switch (t4) {
+ case "$type":
+ return ["filter-type-in", ["literal", e2]];
+ case "$id":
+ return ["filter-id-in", ["literal", e2]];
+ default:
+ return e2.length > 200 && !e2.some((t5) => typeof t5 != typeof e2[0]) ? ["filter-in-large", t4, ["literal", e2.sort(Pn)]] : ["filter-in-small", t4, ["literal", e2]];
+ }
+ }
+ function Fn(t4) {
+ switch (t4) {
+ case "$type":
+ return true;
+ case "$id":
+ return ["filter-has-id"];
+ default:
+ return ["filter-has", t4];
+ }
+ }
+ function Tn(t4) {
+ return ["!", t4];
+ }
+ function $n(t4) {
+ const e2 = typeof t4;
+ if ("number" === e2 || "boolean" === e2 || "string" === e2 || null == t4) return JSON.stringify(t4);
+ if (Array.isArray(t4)) {
+ let e3 = "[";
+ for (const r3 of t4) e3 += `${$n(r3)},`;
+ return `${e3}]`;
+ }
+ const r2 = Object.keys(t4).sort();
+ let n2 = "{";
+ for (let e3 = 0; e3 < r2.length; e3++) n2 += `${JSON.stringify(r2[e3])}:${$n(t4[r2[e3]])},`;
+ return `${n2}}`;
+ }
+ function Ln(t4) {
+ let e2 = "";
+ for (const r2 of K2) e2 += `/${$n(t4[r2])}`;
+ return e2;
+ }
+ function Dn(t4) {
+ const e2 = t4.value;
+ return e2 ? [new it(t4.key, e2, "constants have been deprecated as of v8")] : [];
+ }
+ function On(t4) {
+ return t4 instanceof Number || t4 instanceof String || t4 instanceof Boolean ? t4.valueOf() : t4;
+ }
+ function jn(t4) {
+ if (Array.isArray(t4)) return t4.map(jn);
+ if (t4 instanceof Object && !(t4 instanceof Number || t4 instanceof String || t4 instanceof Boolean)) {
+ const e2 = {};
+ for (const r2 in t4) e2[r2] = jn(t4[r2]);
+ return e2;
+ }
+ return On(t4);
+ }
+ function Rn(t4) {
+ const e2 = t4.key, r2 = t4.value, n2 = t4.valueSpec || {}, i2 = t4.objectElementValidators || {}, s2 = t4.style, a2 = t4.styleSpec, o2 = t4.validateSpec;
+ let l2 = [];
+ const u2 = un(r2);
+ if ("object" !== u2) return [new it(e2, r2, `object expected, ${u2} found`)];
+ for (const t5 in r2) {
+ const u3 = t5.split(".")[0], c2 = n2[u3] || n2["*"];
+ let h2;
+ if (i2[u3]) h2 = i2[u3];
+ else if (n2[u3]) h2 = o2;
+ else if (i2["*"]) h2 = i2["*"];
+ else {
+ if (!n2["*"]) {
+ l2.push(new it(e2, r2[t5], `unknown property "${t5}"`));
+ continue;
+ }
+ h2 = o2;
+ }
+ l2 = l2.concat(h2({ key: (e2 ? `${e2}.` : e2) + t5, value: r2[t5], valueSpec: c2, style: s2, styleSpec: a2, object: r2, objectKey: t5, validateSpec: o2 }, r2));
+ }
+ for (const t5 in n2) i2[t5] || n2[t5].required && void 0 === n2[t5].default && void 0 === r2[t5] && l2.push(new it(e2, r2, `missing required property "${t5}"`));
+ return l2;
+ }
+ function Un(t4) {
+ const e2 = t4.value, r2 = t4.valueSpec, n2 = t4.style, i2 = t4.styleSpec, s2 = t4.key, a2 = t4.arrayElementValidator || t4.validateSpec;
+ if ("array" !== un(e2)) return [new it(s2, e2, `array expected, ${un(e2)} found`)];
+ if (r2.length && e2.length !== r2.length) return [new it(s2, e2, `array length ${r2.length} expected, length ${e2.length} found`)];
+ if (r2["min-length"] && e2.length < r2["min-length"]) return [new it(s2, e2, `array length at least ${r2["min-length"]} expected, length ${e2.length} found`)];
+ let o2 = { type: r2.value, values: r2.values };
+ i2.$version < 7 && (o2.function = r2.function), "object" === un(r2.value) && (o2 = r2.value);
+ let l2 = [];
+ for (let r3 = 0; r3 < e2.length; r3++) l2 = l2.concat(a2({ array: e2, arrayIndex: r3, value: e2[r3], valueSpec: o2, validateSpec: t4.validateSpec, style: n2, styleSpec: i2, key: `${s2}[${r3}]` }));
+ return l2;
+ }
+ function qn(t4) {
+ const e2 = t4.key, r2 = t4.value, n2 = t4.valueSpec;
+ let i2 = un(r2);
+ return "number" === i2 && r2 != r2 && (i2 = "NaN"), "number" !== i2 ? [new it(e2, r2, `number expected, ${i2} found`)] : "minimum" in n2 && r2 < n2.minimum ? [new it(e2, r2, `${r2} is less than the minimum value ${n2.minimum}`)] : "maximum" in n2 && r2 > n2.maximum ? [new it(e2, r2, `${r2} is greater than the maximum value ${n2.maximum}`)] : [];
+ }
+ function Nn(t4) {
+ const e2 = t4.valueSpec, r2 = On(t4.value.type);
+ let n2, i2, s2, a2 = {};
+ const o2 = "categorical" !== r2 && void 0 === t4.value.property, l2 = !o2, u2 = "array" === un(t4.value.stops) && "array" === un(t4.value.stops[0]) && "object" === un(t4.value.stops[0][0]), c2 = Rn({ key: t4.key, value: t4.value, valueSpec: t4.styleSpec.function, validateSpec: t4.validateSpec, style: t4.style, styleSpec: t4.styleSpec, objectElementValidators: { stops: function(t5) {
+ if ("identity" === r2) return [new it(t5.key, t5.value, 'identity function may not have a "stops" property')];
+ let e3 = [];
+ const n3 = t5.value;
+ return e3 = e3.concat(Un({ key: t5.key, value: n3, valueSpec: t5.valueSpec, validateSpec: t5.validateSpec, style: t5.style, styleSpec: t5.styleSpec, arrayElementValidator: h2 })), "array" === un(n3) && 0 === n3.length && e3.push(new it(t5.key, n3, "array must have at least one stop")), e3;
+ }, default: function(t5) {
+ return t5.validateSpec({ key: t5.key, value: t5.value, valueSpec: e2, validateSpec: t5.validateSpec, style: t5.style, styleSpec: t5.styleSpec });
+ } } });
+ return "identity" === r2 && o2 && c2.push(new it(t4.key, t4.value, 'missing required property "property"')), "identity" === r2 || t4.value.stops || c2.push(new it(t4.key, t4.value, 'missing required property "stops"')), "exponential" === r2 && t4.valueSpec.expression && !ln(t4.valueSpec) && c2.push(new it(t4.key, t4.value, "exponential functions not supported")), t4.styleSpec.$version >= 8 && (l2 && !an(t4.valueSpec) ? c2.push(new it(t4.key, t4.value, "property functions not supported")) : o2 && !on(t4.valueSpec) && c2.push(new it(t4.key, t4.value, "zoom functions not supported"))), "categorical" !== r2 && !u2 || void 0 !== t4.value.property || c2.push(new it(t4.key, t4.value, '"property" property is required')), c2;
+ function h2(t5) {
+ let r3 = [];
+ const n3 = t5.value, o3 = t5.key;
+ if ("array" !== un(n3)) return [new it(o3, n3, `array expected, ${un(n3)} found`)];
+ if (2 !== n3.length) return [new it(o3, n3, `array length 2 expected, length ${n3.length} found`)];
+ if (u2) {
+ if ("object" !== un(n3[0])) return [new it(o3, n3, `object expected, ${un(n3[0])} found`)];
+ if (void 0 === n3[0].zoom) return [new it(o3, n3, "object stop key must have zoom")];
+ if (void 0 === n3[0].value) return [new it(o3, n3, "object stop key must have value")];
+ if (s2 && s2 > On(n3[0].zoom)) return [new it(o3, n3[0].zoom, "stop zoom values must appear in ascending order")];
+ On(n3[0].zoom) !== s2 && (s2 = On(n3[0].zoom), i2 = void 0, a2 = {}), r3 = r3.concat(Rn({ key: `${o3}[0]`, value: n3[0], valueSpec: { zoom: {} }, validateSpec: t5.validateSpec, style: t5.style, styleSpec: t5.styleSpec, objectElementValidators: { zoom: qn, value: p2 } }));
+ } else r3 = r3.concat(p2({ key: `${o3}[0]`, value: n3[0], valueSpec: {}, validateSpec: t5.validateSpec, style: t5.style, styleSpec: t5.styleSpec }, n3));
+ return vn(jn(n3[1])) ? r3.concat([new it(`${o3}[1]`, n3[1], "expressions are not allowed in function stops.")]) : r3.concat(t5.validateSpec({ key: `${o3}[1]`, value: n3[1], valueSpec: e2, validateSpec: t5.validateSpec, style: t5.style, styleSpec: t5.styleSpec }));
+ }
+ function p2(t5, s3) {
+ const o3 = un(t5.value), l3 = On(t5.value), u3 = null !== t5.value ? t5.value : s3;
+ if (n2) {
+ if (o3 !== n2) return [new it(t5.key, u3, `${o3} stop domain type must match previous stop domain type ${n2}`)];
+ } else n2 = o3;
+ if ("number" !== o3 && "string" !== o3 && "boolean" !== o3) return [new it(t5.key, u3, "stop domain value must be a number, string, or boolean")];
+ if ("number" !== o3 && "categorical" !== r2) {
+ let n3 = `number expected, ${o3} found`;
+ return an(e2) && void 0 === r2 && (n3 += '\nIf you intended to use a categorical function, specify `"type": "categorical"`.'), [new it(t5.key, u3, n3)];
+ }
+ return "categorical" !== r2 || "number" !== o3 || isFinite(l3) && Math.floor(l3) === l3 ? "categorical" !== r2 && "number" === o3 && void 0 !== i2 && l3 < i2 ? [new it(t5.key, u3, "stop domain values must appear in ascending order")] : (i2 = l3, "categorical" === r2 && l3 in a2 ? [new it(t5.key, u3, "stop domain values must be unique")] : (a2[l3] = true, [])) : [new it(t5.key, u3, `integer expected, found ${l3}`)];
+ }
+ }
+ function Zn2(t4) {
+ const e2 = ("property" === t4.expressionContext ? An : bn)(jn(t4.value), t4.valueSpec);
+ if ("error" === e2.result) return e2.value.map((e3) => new it(`${t4.key}${e3.key}`, t4.value, e3.message));
+ const r2 = e2.value.expression || e2.value._styleExpression.expression;
+ if ("property" === t4.expressionContext && "text-font" === t4.propertyKey && !r2.outputDefined()) return [new it(t4.key, t4.value, `Invalid data expression for "${t4.propertyKey}". Output values must be contained as literals within the expression.`)];
+ if ("property" === t4.expressionContext && "layout" === t4.propertyType && !en(r2)) return [new it(t4.key, t4.value, '"feature-state" data expressions are not supported with layout properties.')];
+ if ("filter" === t4.expressionContext && !en(r2)) return [new it(t4.key, t4.value, '"feature-state" data expressions are not supported with filters.')];
+ if (t4.expressionContext && 0 === t4.expressionContext.indexOf("cluster")) {
+ if (!rn(r2, ["zoom", "feature-state"])) return [new it(t4.key, t4.value, '"zoom" and "feature-state" expressions are not supported with cluster properties.')];
+ if ("cluster-initial" === t4.expressionContext && !tn(r2)) return [new it(t4.key, t4.value, "Feature data expressions are not supported with initial expression part of cluster properties.")];
+ }
+ return [];
+ }
+ function Gn(t4) {
+ const e2 = t4.key, r2 = t4.value, n2 = t4.valueSpec, i2 = [];
+ return Array.isArray(n2.values) ? -1 === n2.values.indexOf(On(r2)) && i2.push(new it(e2, r2, `expected one of [${n2.values.join(", ")}], ${JSON.stringify(r2)} found`)) : -1 === Object.keys(n2.values).indexOf(On(r2)) && i2.push(new it(e2, r2, `expected one of [${Object.keys(n2.values).join(", ")}], ${JSON.stringify(r2)} found`)), i2;
+ }
+ function Kn(t4) {
+ return Mn(jn(t4.value)) ? Zn2(st({}, t4, { expressionContext: "filter", valueSpec: { value: "boolean" } })) : Xn2(t4);
+ }
+ function Xn2(t4) {
+ const e2 = t4.value, r2 = t4.key;
+ if ("array" !== un(e2)) return [new it(r2, e2, `array expected, ${un(e2)} found`)];
+ const n2 = t4.styleSpec;
+ let i2, s2 = [];
+ if (e2.length < 1) return [new it(r2, e2, "filter array must have at least 1 element")];
+ switch (s2 = s2.concat(Gn({ key: `${r2}[0]`, value: e2[0], valueSpec: n2.filter_operator, style: t4.style, styleSpec: t4.styleSpec })), On(e2[0])) {
+ case "<":
+ case "<=":
+ case ">":
+ case ">=":
+ e2.length >= 2 && "$type" === On(e2[1]) && s2.push(new it(r2, e2, `"$type" cannot be use with operator "${e2[0]}"`));
+ case "==":
+ case "!=":
+ 3 !== e2.length && s2.push(new it(r2, e2, `filter array for operator "${e2[0]}" must have 3 elements`));
+ case "in":
+ case "!in":
+ e2.length >= 2 && (i2 = un(e2[1]), "string" !== i2 && s2.push(new it(`${r2}[1]`, e2[1], `string expected, ${i2} found`)));
+ for (let a2 = 2; a2 < e2.length; a2++) i2 = un(e2[a2]), "$type" === On(e2[1]) ? s2 = s2.concat(Gn({ key: `${r2}[${a2}]`, value: e2[a2], valueSpec: n2.geometry_type, style: t4.style, styleSpec: t4.styleSpec })) : "string" !== i2 && "number" !== i2 && "boolean" !== i2 && s2.push(new it(`${r2}[${a2}]`, e2[a2], `string, number, or boolean expected, ${i2} found`));
+ break;
+ case "any":
+ case "all":
+ case "none":
+ for (let n3 = 1; n3 < e2.length; n3++) s2 = s2.concat(Xn2({ key: `${r2}[${n3}]`, value: e2[n3], style: t4.style, styleSpec: t4.styleSpec }));
+ break;
+ case "has":
+ case "!has":
+ i2 = un(e2[1]), 2 !== e2.length ? s2.push(new it(r2, e2, `filter array for "${e2[0]}" operator must have 2 elements`)) : "string" !== i2 && s2.push(new it(`${r2}[1]`, e2[1], `string expected, ${i2} found`));
+ }
+ return s2;
+ }
+ function Hn(t4, e2) {
+ const r2 = t4.key, n2 = t4.validateSpec, i2 = t4.style, s2 = t4.styleSpec, a2 = t4.value, o2 = t4.objectKey, l2 = s2[`${e2}_${t4.layerType}`];
+ if (!l2) return [];
+ const u2 = o2.match(/^(.*)-transition$/);
+ if ("paint" === e2 && u2 && l2[u2[1]] && l2[u2[1]].transition) return n2({ key: r2, value: a2, valueSpec: s2.transition, style: i2, styleSpec: s2 });
+ const c2 = t4.valueSpec || l2[o2];
+ if (!c2) return [new it(r2, a2, `unknown property "${o2}"`)];
+ let h2;
+ if ("string" === un(a2) && an(c2) && !c2.tokens && (h2 = /^{([^}]+)}$/.exec(a2))) return [new it(r2, a2, `"${o2}" does not support interpolation syntax
+Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h2[1])} }\`.`)];
+ const p2 = [];
+ return "symbol" === t4.layerType && ("text-field" === o2 && i2 && !i2.glyphs && p2.push(new it(r2, a2, 'use of "text-field" requires a style "glyphs" property')), "text-font" === o2 && cn(jn(a2)) && "identity" === On(a2.type) && p2.push(new it(r2, a2, '"text-font" does not support identity functions'))), p2.concat(n2({ key: t4.key, value: a2, valueSpec: c2, style: i2, styleSpec: s2, expressionContext: "property", propertyType: e2, propertyKey: o2 }));
+ }
+ function Yn2(t4) {
+ return Hn(t4, "paint");
+ }
+ function Jn(t4) {
+ return Hn(t4, "layout");
+ }
+ function Wn(t4) {
+ let e2 = [];
+ const r2 = t4.value, n2 = t4.key, i2 = t4.style, s2 = t4.styleSpec;
+ r2.type || r2.ref || e2.push(new it(n2, r2, 'either "type" or "ref" is required'));
+ let a2 = On(r2.type);
+ const o2 = On(r2.ref);
+ if (r2.id) {
+ const s3 = On(r2.id);
+ for (let a3 = 0; a3 < t4.arrayIndex; a3++) {
+ const t5 = i2.layers[a3];
+ On(t5.id) === s3 && e2.push(new it(n2, r2.id, `duplicate layer id "${r2.id}", previously used at line ${t5.id.__line__}`));
+ }
+ }
+ if ("ref" in r2) {
+ let t5;
+ ["type", "source", "source-layer", "filter", "layout"].forEach((t6) => {
+ t6 in r2 && e2.push(new it(n2, r2[t6], `"${t6}" is prohibited for ref layers`));
+ }), i2.layers.forEach((e3) => {
+ On(e3.id) === o2 && (t5 = e3);
+ }), t5 ? t5.ref ? e2.push(new it(n2, r2.ref, "ref cannot reference another ref layer")) : a2 = On(t5.type) : e2.push(new it(n2, r2.ref, `ref layer "${o2}" not found`));
+ } else if ("background" !== a2) if (r2.source) {
+ const t5 = i2.sources && i2.sources[r2.source], s3 = t5 && On(t5.type);
+ t5 ? "vector" === s3 && "raster" === a2 ? e2.push(new it(n2, r2.source, `layer "${r2.id}" requires a raster source`)) : "raster-dem" !== s3 && "hillshade" === a2 ? e2.push(new it(n2, r2.source, `layer "${r2.id}" requires a raster-dem source`)) : "raster" === s3 && "raster" !== a2 ? e2.push(new it(n2, r2.source, `layer "${r2.id}" requires a vector source`)) : "vector" !== s3 || r2["source-layer"] ? "raster-dem" === s3 && "hillshade" !== a2 ? e2.push(new it(n2, r2.source, "raster-dem source can only be used with layer type 'hillshade'.")) : "line" !== a2 || !r2.paint || !r2.paint["line-gradient"] || "geojson" === s3 && t5.lineMetrics || e2.push(new it(n2, r2, `layer "${r2.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)) : e2.push(new it(n2, r2, `layer "${r2.id}" must specify a "source-layer"`)) : e2.push(new it(n2, r2.source, `source "${r2.source}" not found`));
+ } else e2.push(new it(n2, r2, 'missing required property "source"'));
+ return e2 = e2.concat(Rn({ key: n2, value: r2, valueSpec: s2.layer, style: t4.style, styleSpec: t4.styleSpec, validateSpec: t4.validateSpec, objectElementValidators: { "*": () => [], type: () => t4.validateSpec({ key: `${n2}.type`, value: r2.type, valueSpec: s2.layer.type, style: t4.style, styleSpec: t4.styleSpec, validateSpec: t4.validateSpec, object: r2, objectKey: "type" }), filter: Kn, layout: (t5) => Rn({ layer: r2, key: t5.key, value: t5.value, style: t5.style, styleSpec: t5.styleSpec, validateSpec: t5.validateSpec, objectElementValidators: { "*": (t6) => Jn(st({ layerType: a2 }, t6)) } }), paint: (t5) => Rn({ layer: r2, key: t5.key, value: t5.value, style: t5.style, styleSpec: t5.styleSpec, validateSpec: t5.validateSpec, objectElementValidators: { "*": (t6) => Yn2(st({ layerType: a2 }, t6)) } }) } })), e2;
+ }
+ function Qn(t4) {
+ const e2 = t4.value, r2 = t4.key, n2 = un(e2);
+ return "string" !== n2 ? [new it(r2, e2, `string expected, ${n2} found`)] : [];
+ }
+ const ti = { promoteId: function({ key: t4, value: e2 }) {
+ if ("string" === un(e2)) return Qn({ key: t4, value: e2 });
+ {
+ const r2 = [];
+ for (const n2 in e2) r2.push(...Qn({ key: `${t4}.${n2}`, value: e2[n2] }));
+ return r2;
+ }
+ } };
+ function ei(t4) {
+ const e2 = t4.value, r2 = t4.key, n2 = t4.styleSpec, i2 = t4.style, s2 = t4.validateSpec;
+ if (!e2.type) return [new it(r2, e2, '"type" is required')];
+ const a2 = On(e2.type);
+ let o2;
+ switch (a2) {
+ case "vector":
+ case "raster":
+ return o2 = Rn({ key: r2, value: e2, valueSpec: n2[`source_${a2.replace("-", "_")}`], style: t4.style, styleSpec: n2, objectElementValidators: ti, validateSpec: s2 }), o2;
+ case "raster-dem":
+ return o2 = function(t5) {
+ var e3;
+ const r3 = null !== (e3 = t5.sourceName) && void 0 !== e3 ? e3 : "", n3 = t5.value, i3 = t5.styleSpec, s3 = i3.source_raster_dem, a3 = t5.style;
+ let o3 = [];
+ const l2 = un(n3);
+ if (void 0 === n3) return o3;
+ if ("object" !== l2) return o3.push(new it("source_raster_dem", n3, `object expected, ${l2} found`)), o3;
+ const u2 = "custom" === On(n3.encoding), c2 = ["redFactor", "greenFactor", "blueFactor", "baseShift"], h2 = t5.value.encoding ? `"${t5.value.encoding}"` : "Default";
+ for (const e4 in n3) !u2 && c2.includes(e4) ? o3.push(new it(e4, n3[e4], `In "${r3}": "${e4}" is only valid when "encoding" is set to "custom". ${h2} encoding found`)) : s3[e4] ? o3 = o3.concat(t5.validateSpec({ key: e4, value: n3[e4], valueSpec: s3[e4], validateSpec: t5.validateSpec, style: a3, styleSpec: i3 })) : o3.push(new it(e4, n3[e4], `unknown property "${e4}"`));
+ return o3;
+ }({ sourceName: r2, value: e2, style: t4.style, styleSpec: n2, validateSpec: s2 }), o2;
+ case "geojson":
+ if (o2 = Rn({ key: r2, value: e2, valueSpec: n2.source_geojson, style: i2, styleSpec: n2, validateSpec: s2, objectElementValidators: ti }), e2.cluster) for (const t5 in e2.clusterProperties) {
+ const [n3, i3] = e2.clusterProperties[t5], a3 = "string" == typeof n3 ? [n3, ["accumulated"], ["get", t5]] : n3;
+ o2.push(...Zn2({ key: `${r2}.${t5}.map`, value: i3, validateSpec: s2, expressionContext: "cluster-map" })), o2.push(...Zn2({ key: `${r2}.${t5}.reduce`, value: a3, validateSpec: s2, expressionContext: "cluster-reduce" }));
+ }
+ return o2;
+ case "video":
+ return Rn({ key: r2, value: e2, valueSpec: n2.source_video, style: i2, validateSpec: s2, styleSpec: n2 });
+ case "image":
+ return Rn({ key: r2, value: e2, valueSpec: n2.source_image, style: i2, validateSpec: s2, styleSpec: n2 });
+ case "canvas":
+ return [new it(r2, null, "Please use runtime APIs to add canvas sources, rather than including them in stylesheets.", "source.canvas")];
+ default:
+ return Gn({ key: `${r2}.type`, value: e2.type, valueSpec: { values: ["vector", "raster", "raster-dem", "geojson", "video", "image"] }, style: i2, validateSpec: s2, styleSpec: n2 });
+ }
+ }
+ function ri(t4) {
+ const e2 = t4.value, r2 = t4.styleSpec, n2 = r2.light, i2 = t4.style;
+ let s2 = [];
+ const a2 = un(e2);
+ if (void 0 === e2) return s2;
+ if ("object" !== a2) return s2 = s2.concat([new it("light", e2, `object expected, ${a2} found`)]), s2;
+ for (const a3 in e2) {
+ const o2 = a3.match(/^(.*)-transition$/);
+ s2 = s2.concat(o2 && n2[o2[1]] && n2[o2[1]].transition ? t4.validateSpec({ key: a3, value: e2[a3], valueSpec: r2.transition, validateSpec: t4.validateSpec, style: i2, styleSpec: r2 }) : n2[a3] ? t4.validateSpec({ key: a3, value: e2[a3], valueSpec: n2[a3], validateSpec: t4.validateSpec, style: i2, styleSpec: r2 }) : [new it(a3, e2[a3], `unknown property "${a3}"`)]);
+ }
+ return s2;
+ }
+ function ni(t4) {
+ const e2 = t4.value, r2 = t4.styleSpec, n2 = r2.sky, i2 = t4.style, s2 = un(e2);
+ if (void 0 === e2) return [];
+ if ("object" !== s2) return [new it("sky", e2, `object expected, ${s2} found`)];
+ let a2 = [];
+ for (const s3 in e2) a2 = a2.concat(n2[s3] ? t4.validateSpec({ key: s3, value: e2[s3], valueSpec: n2[s3], style: i2, styleSpec: r2 }) : [new it(s3, e2[s3], `unknown property "${s3}"`)]);
+ return a2;
+ }
+ function ii(t4) {
+ const e2 = t4.value, r2 = t4.styleSpec, n2 = r2.terrain, i2 = t4.style;
+ let s2 = [];
+ const a2 = un(e2);
+ if (void 0 === e2) return s2;
+ if ("object" !== a2) return s2 = s2.concat([new it("terrain", e2, `object expected, ${a2} found`)]), s2;
+ for (const a3 in e2) s2 = s2.concat(n2[a3] ? t4.validateSpec({ key: a3, value: e2[a3], valueSpec: n2[a3], validateSpec: t4.validateSpec, style: i2, styleSpec: r2 }) : [new it(a3, e2[a3], `unknown property "${a3}"`)]);
+ return s2;
+ }
+ function si(t4) {
+ let e2 = [];
+ const r2 = t4.value, n2 = t4.key;
+ if (Array.isArray(r2)) {
+ const i2 = [], s2 = [];
+ for (const a2 in r2) r2[a2].id && i2.includes(r2[a2].id) && e2.push(new it(n2, r2, `all the sprites' ids must be unique, but ${r2[a2].id} is duplicated`)), i2.push(r2[a2].id), r2[a2].url && s2.includes(r2[a2].url) && e2.push(new it(n2, r2, `all the sprites' URLs must be unique, but ${r2[a2].url} is duplicated`)), s2.push(r2[a2].url), e2 = e2.concat(Rn({ key: `${n2}[${a2}]`, value: r2[a2], valueSpec: { id: { type: "string", required: true }, url: { type: "string", required: true } }, validateSpec: t4.validateSpec }));
+ return e2;
+ }
+ return Qn({ key: n2, value: r2 });
+ }
+ const ai = { "*": () => [], array: Un, boolean: function(t4) {
+ const e2 = t4.value, r2 = t4.key, n2 = un(e2);
+ return "boolean" !== n2 ? [new it(r2, e2, `boolean expected, ${n2} found`)] : [];
+ }, number: qn, color: function(t4) {
+ const e2 = t4.key, r2 = t4.value, n2 = un(r2);
+ return "string" !== n2 ? [new it(e2, r2, `color expected, ${n2} found`)] : Kt.parse(String(r2)) ? [] : [new it(e2, r2, `color expected, "${r2}" found`)];
+ }, constants: Dn, enum: Gn, filter: Kn, function: Nn, layer: Wn, object: Rn, source: ei, light: ri, sky: ni, terrain: ii, projection: function(t4) {
+ const e2 = t4.value, r2 = t4.styleSpec, n2 = r2.projection, i2 = t4.style, s2 = un(e2);
+ if (void 0 === e2) return [];
+ if ("object" !== s2) return [new it("projection", e2, `object expected, ${s2} found`)];
+ let a2 = [];
+ for (const s3 in e2) a2 = a2.concat(n2[s3] ? t4.validateSpec({ key: s3, value: e2[s3], valueSpec: n2[s3], style: i2, styleSpec: r2 }) : [new it(s3, e2[s3], `unknown property "${s3}"`)]);
+ return a2;
+ }, string: Qn, formatted: function(t4) {
+ return 0 === Qn(t4).length ? [] : Zn2(t4);
+ }, resolvedImage: function(t4) {
+ return 0 === Qn(t4).length ? [] : Zn2(t4);
+ }, padding: function(t4) {
+ const e2 = t4.key, r2 = t4.value;
+ if ("array" === un(r2)) {
+ if (r2.length < 1 || r2.length > 4) return [new it(e2, r2, `padding requires 1 to 4 values; ${r2.length} values found`)];
+ const n2 = { type: "number" };
+ let i2 = [];
+ for (let s2 = 0; s2 < r2.length; s2++) i2 = i2.concat(t4.validateSpec({ key: `${e2}[${s2}]`, value: r2[s2], validateSpec: t4.validateSpec, valueSpec: n2 }));
+ return i2;
+ }
+ return qn({ key: e2, value: r2, valueSpec: {} });
+ }, variableAnchorOffsetCollection: function(t4) {
+ const e2 = t4.key, r2 = t4.value, n2 = un(r2), i2 = t4.styleSpec;
+ if ("array" !== n2 || r2.length < 1 || r2.length % 2 != 0) return [new it(e2, r2, "variableAnchorOffsetCollection requires a non-empty array of even length")];
+ let s2 = [];
+ for (let n3 = 0; n3 < r2.length; n3 += 2) s2 = s2.concat(Gn({ key: `${e2}[${n3}]`, value: r2[n3], valueSpec: i2.layout_symbol["text-anchor"] })), s2 = s2.concat(Un({ key: `${e2}[${n3 + 1}]`, value: r2[n3 + 1], valueSpec: { length: 2, value: "number" }, validateSpec: t4.validateSpec, style: t4.style, styleSpec: i2 }));
+ return s2;
+ }, sprite: si };
+ function oi(t4) {
+ const e2 = t4.value, r2 = t4.valueSpec, n2 = t4.styleSpec;
+ return t4.validateSpec = oi, r2.expression && cn(On(e2)) ? Nn(t4) : r2.expression && vn(jn(e2)) ? Zn2(t4) : r2.type && ai[r2.type] ? ai[r2.type](t4) : Rn(st({}, t4, { valueSpec: r2.type ? n2[r2.type] : r2 }));
+ }
+ function li(t4) {
+ const e2 = t4.value, r2 = t4.key, n2 = Qn(t4);
+ return n2.length || (-1 === e2.indexOf("{fontstack}") && n2.push(new it(r2, e2, '"glyphs" url must include a "{fontstack}" token')), -1 === e2.indexOf("{range}") && n2.push(new it(r2, e2, '"glyphs" url must include a "{range}" token'))), n2;
+ }
+ function ui(t4, e2 = G) {
+ let r2 = [];
+ return r2 = r2.concat(oi({ key: "", value: t4, valueSpec: e2.$root, styleSpec: e2, style: t4, validateSpec: oi, objectElementValidators: { glyphs: li, "*": () => [] } })), t4.constants && (r2 = r2.concat(Dn({ key: "constants", value: t4.constants, style: t4, styleSpec: e2, validateSpec: oi }))), hi(r2);
+ }
+ function ci(t4) {
+ return function(e2) {
+ return t4(__spreadProps(__spreadValues({}, e2), { validateSpec: oi }));
+ };
+ }
+ function hi(t4) {
+ return [].concat(t4).sort((t5, e2) => t5.line - e2.line);
+ }
+ function pi(t4) {
+ return function(...e2) {
+ return hi(t4.apply(this, e2));
+ };
+ }
+ ui.source = pi(ci(ei)), ui.sprite = pi(ci(si)), ui.glyphs = pi(ci(li)), ui.light = pi(ci(ri)), ui.sky = pi(ci(ni)), ui.terrain = pi(ci(ii)), ui.layer = pi(ci(Wn)), ui.filter = pi(ci(Kn)), ui.paintProperty = pi(ci(Yn2)), ui.layoutProperty = pi(ci(Jn));
+ const fi = ui, di = fi.light, yi = fi.sky, mi = fi.paintProperty, gi = fi.layoutProperty;
+ function xi(t4, e2) {
+ let r2 = false;
+ if (e2 && e2.length) for (const n2 of e2) t4.fire(new N(new Error(n2.message))), r2 = true;
+ return r2;
+ }
+ class vi {
+ constructor(t4, e2, r2) {
+ const n2 = this.cells = [];
+ if (t4 instanceof ArrayBuffer) {
+ this.arrayBuffer = t4;
+ const i3 = new Int32Array(this.arrayBuffer);
+ t4 = i3[0], this.d = (e2 = i3[1]) + 2 * (r2 = i3[2]);
+ for (let t5 = 0; t5 < this.d * this.d; t5++) {
+ const e3 = i3[3 + t5], r3 = i3[3 + t5 + 1];
+ n2.push(e3 === r3 ? null : i3.subarray(e3, r3));
+ }
+ const s2 = i3[3 + n2.length + 1];
+ this.keys = i3.subarray(i3[3 + n2.length], s2), this.bboxes = i3.subarray(s2), this.insert = this._insertReadonly;
+ } else {
+ this.d = e2 + 2 * r2;
+ for (let t5 = 0; t5 < this.d * this.d; t5++) n2.push([]);
+ this.keys = [], this.bboxes = [];
+ }
+ this.n = e2, this.extent = t4, this.padding = r2, this.scale = e2 / t4, this.uid = 0;
+ const i2 = r2 / e2 * t4;
+ this.min = -i2, this.max = t4 + i2;
+ }
+ insert(t4, e2, r2, n2, i2) {
+ this._forEachCell(e2, r2, n2, i2, this._insertCell, this.uid++, void 0, void 0), this.keys.push(t4), this.bboxes.push(e2), this.bboxes.push(r2), this.bboxes.push(n2), this.bboxes.push(i2);
+ }
+ _insertReadonly() {
+ throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.");
+ }
+ _insertCell(t4, e2, r2, n2, i2, s2) {
+ this.cells[i2].push(s2);
+ }
+ query(t4, e2, r2, n2, i2) {
+ const s2 = this.min, a2 = this.max;
+ if (t4 <= s2 && e2 <= s2 && a2 <= r2 && a2 <= n2 && !i2) return Array.prototype.slice.call(this.keys);
+ {
+ const s3 = [];
+ return this._forEachCell(t4, e2, r2, n2, this._queryCell, s3, {}, i2), s3;
+ }
+ }
+ _queryCell(t4, e2, r2, n2, i2, s2, a2, o2) {
+ const l2 = this.cells[i2];
+ if (null !== l2) {
+ const i3 = this.keys, u2 = this.bboxes;
+ for (let c2 = 0; c2 < l2.length; c2++) {
+ const h2 = l2[c2];
+ if (void 0 === a2[h2]) {
+ const l3 = 4 * h2;
+ (o2 ? o2(u2[l3 + 0], u2[l3 + 1], u2[l3 + 2], u2[l3 + 3]) : t4 <= u2[l3 + 2] && e2 <= u2[l3 + 3] && r2 >= u2[l3 + 0] && n2 >= u2[l3 + 1]) ? (a2[h2] = true, s2.push(i3[h2])) : a2[h2] = false;
+ }
+ }
+ }
+ }
+ _forEachCell(t4, e2, r2, n2, i2, s2, a2, o2) {
+ const l2 = this._convertToCellCoord(t4), u2 = this._convertToCellCoord(e2), c2 = this._convertToCellCoord(r2), h2 = this._convertToCellCoord(n2);
+ for (let p2 = l2; p2 <= c2; p2++) for (let l3 = u2; l3 <= h2; l3++) {
+ const u3 = this.d * l3 + p2;
+ if ((!o2 || o2(this._convertFromCellCoord(p2), this._convertFromCellCoord(l3), this._convertFromCellCoord(p2 + 1), this._convertFromCellCoord(l3 + 1))) && i2.call(this, t4, e2, r2, n2, u3, s2, a2, o2)) return;
+ }
+ }
+ _convertFromCellCoord(t4) {
+ return (t4 - this.padding) / this.scale;
+ }
+ _convertToCellCoord(t4) {
+ return Math.max(0, Math.min(this.d - 1, Math.floor(t4 * this.scale) + this.padding));
+ }
+ toArrayBuffer() {
+ if (this.arrayBuffer) return this.arrayBuffer;
+ const t4 = this.cells, e2 = 3 + this.cells.length + 1 + 1;
+ let r2 = 0;
+ for (let t5 = 0; t5 < this.cells.length; t5++) r2 += this.cells[t5].length;
+ const n2 = new Int32Array(e2 + r2 + this.keys.length + this.bboxes.length);
+ n2[0] = this.extent, n2[1] = this.n, n2[2] = this.padding;
+ let i2 = e2;
+ for (let e3 = 0; e3 < t4.length; e3++) {
+ const r3 = t4[e3];
+ n2[3 + e3] = i2, n2.set(r3, i2), i2 += r3.length;
+ }
+ return n2[3 + t4.length] = i2, n2.set(this.keys, i2), i2 += this.keys.length, n2[3 + t4.length + 1] = i2, n2.set(this.bboxes, i2), i2 += this.bboxes.length, n2.buffer;
+ }
+ static serialize(t4, e2) {
+ const r2 = t4.toArrayBuffer();
+ return e2 && e2.push(r2), { buffer: r2 };
+ }
+ static deserialize(t4) {
+ return new vi(t4.buffer);
+ }
+ }
+ const bi = {};
+ function wi(t4, e2, r2 = {}) {
+ if (bi[t4]) throw new Error(`${t4} is already registered.`);
+ Object.defineProperty(e2, "_classRegistryKey", { value: t4, writeable: false }), bi[t4] = { klass: e2, omit: r2.omit || [], shallow: r2.shallow || [] };
+ }
+ wi("Object", Object), wi("TransferableGridIndex", vi), wi("Color", Kt), wi("Error", Error), wi("AJAXError", L), wi("ResolvedImage", te), wi("StylePropertyFunction", Sn), wi("StyleExpression", xn, { omit: ["_evaluator"] }), wi("ZoomDependentExpression", _n), wi("ZoomConstantExpression", wn), wi("CompoundExpression", Xr, { omit: ["_evaluate"] });
+ for (const t4 in Kr) Kr[t4]._classRegistryKey || wi(`Expression_${t4}`, Kr[t4]);
+ function _i(t4) {
+ return t4 && "undefined" != typeof ArrayBuffer && (t4 instanceof ArrayBuffer || t4.constructor && "ArrayBuffer" === t4.constructor.name);
+ }
+ function Ai(t4) {
+ return t4.$name || t4.constructor._classRegistryKey;
+ }
+ function Si(t4) {
+ return !function(t5) {
+ if (null === t5 || "object" != typeof t5) return false;
+ const e2 = Ai(t5);
+ return !(!e2 || "Object" === e2);
+ }(t4) && (null == t4 || "boolean" == typeof t4 || "number" == typeof t4 || "string" == typeof t4 || t4 instanceof Boolean || t4 instanceof Number || t4 instanceof String || t4 instanceof Date || t4 instanceof RegExp || t4 instanceof Blob || t4 instanceof Error || _i(t4) || I(t4) || ArrayBuffer.isView(t4) || t4 instanceof ImageData);
+ }
+ function ki(t4, e2) {
+ if (Si(t4)) return (_i(t4) || I(t4)) && e2 && e2.push(t4), ArrayBuffer.isView(t4) && e2 && e2.push(t4.buffer), t4 instanceof ImageData && e2 && e2.push(t4.data.buffer), t4;
+ if (Array.isArray(t4)) {
+ const r3 = [];
+ for (const n3 of t4) r3.push(ki(n3, e2));
+ return r3;
+ }
+ if ("object" != typeof t4) throw new Error("can't serialize object of type " + typeof t4);
+ const r2 = Ai(t4);
+ if (!r2) throw new Error(`can't serialize object of unregistered class ${t4.constructor.name}`);
+ if (!bi[r2]) throw new Error(`${r2} is not registered.`);
+ const { klass: n2 } = bi[r2], i2 = n2.serialize ? n2.serialize(t4, e2) : {};
+ if (n2.serialize) {
+ if (e2 && i2 === e2[e2.length - 1]) throw new Error("statically serialized object won't survive transfer of $name property");
+ } else {
+ for (const n3 in t4) {
+ if (!t4.hasOwnProperty(n3)) continue;
+ if (bi[r2].omit.indexOf(n3) >= 0) continue;
+ const s2 = t4[n3];
+ i2[n3] = bi[r2].shallow.indexOf(n3) >= 0 ? s2 : ki(s2, e2);
+ }
+ t4 instanceof Error && (i2.message = t4.message);
+ }
+ if (i2.$name) throw new Error("$name property is reserved for worker serialization logic.");
+ return "Object" !== r2 && (i2.$name = r2), i2;
+ }
+ function Mi(t4) {
+ if (Si(t4)) return t4;
+ if (Array.isArray(t4)) return t4.map(Mi);
+ if ("object" != typeof t4) throw new Error("can't deserialize object of type " + typeof t4);
+ const e2 = Ai(t4) || "Object";
+ if (!bi[e2]) throw new Error(`can't deserialize unregistered class ${e2}`);
+ const { klass: r2 } = bi[e2];
+ if (!r2) throw new Error(`can't deserialize unregistered class ${e2}`);
+ if (r2.deserialize) return r2.deserialize(t4);
+ const n2 = Object.create(r2.prototype);
+ for (const r3 of Object.keys(t4)) {
+ if ("$name" === r3) continue;
+ const i2 = t4[r3];
+ n2[r3] = bi[e2].shallow.indexOf(r3) >= 0 ? i2 : Mi(i2);
+ }
+ return n2;
+ }
+ class Ii {
+ constructor() {
+ this.first = true;
+ }
+ update(t4, e2) {
+ const r2 = Math.floor(t4);
+ return this.first ? (this.first = false, this.lastIntegerZoom = r2, this.lastIntegerZoomTime = 0, this.lastZoom = t4, this.lastFloorZoom = r2, true) : (this.lastFloorZoom > r2 ? (this.lastIntegerZoom = r2 + 1, this.lastIntegerZoomTime = e2) : this.lastFloorZoom < r2 && (this.lastIntegerZoom = r2, this.lastIntegerZoomTime = e2), t4 !== this.lastZoom && (this.lastZoom = t4, this.lastFloorZoom = r2, true));
+ }
+ }
+ const zi = { "Latin-1 Supplement": (t4) => t4 >= 128 && t4 <= 255, "Hangul Jamo": (t4) => t4 >= 4352 && t4 <= 4607, Khmer: (t4) => t4 >= 6016 && t4 <= 6143, "General Punctuation": (t4) => t4 >= 8192 && t4 <= 8303, "Letterlike Symbols": (t4) => t4 >= 8448 && t4 <= 8527, "Number Forms": (t4) => t4 >= 8528 && t4 <= 8591, "Miscellaneous Technical": (t4) => t4 >= 8960 && t4 <= 9215, "Control Pictures": (t4) => t4 >= 9216 && t4 <= 9279, "Optical Character Recognition": (t4) => t4 >= 9280 && t4 <= 9311, "Enclosed Alphanumerics": (t4) => t4 >= 9312 && t4 <= 9471, "Geometric Shapes": (t4) => t4 >= 9632 && t4 <= 9727, "Miscellaneous Symbols": (t4) => t4 >= 9728 && t4 <= 9983, "Miscellaneous Symbols and Arrows": (t4) => t4 >= 11008 && t4 <= 11263, "Ideographic Description Characters": (t4) => t4 >= 12272 && t4 <= 12287, "CJK Symbols and Punctuation": (t4) => t4 >= 12288 && t4 <= 12351, Katakana: (t4) => t4 >= 12448 && t4 <= 12543, Kanbun: (t4) => t4 >= 12688 && t4 <= 12703, "CJK Strokes": (t4) => t4 >= 12736 && t4 <= 12783, "Enclosed CJK Letters and Months": (t4) => t4 >= 12800 && t4 <= 13055, "CJK Compatibility": (t4) => t4 >= 13056 && t4 <= 13311, "Yijing Hexagram Symbols": (t4) => t4 >= 19904 && t4 <= 19967, "Private Use Area": (t4) => t4 >= 57344 && t4 <= 63743, "Vertical Forms": (t4) => t4 >= 65040 && t4 <= 65055, "CJK Compatibility Forms": (t4) => t4 >= 65072 && t4 <= 65103, "Small Form Variants": (t4) => t4 >= 65104 && t4 <= 65135, "Halfwidth and Fullwidth Forms": (t4) => t4 >= 65280 && t4 <= 65519 };
+ function Pi(t4) {
+ for (const e2 of t4) if (Ti(e2.charCodeAt(0))) return true;
+ return false;
+ }
+ function Ci(t4) {
+ for (const e2 of t4) if (!Ei(e2.charCodeAt(0))) return false;
+ return true;
+ }
+ function Bi(t4) {
+ const e2 = t4.map((t5) => {
+ try {
+ return new RegExp(`\\p{sc=${t5}}`, "u").source;
+ } catch (t6) {
+ return null;
+ }
+ }).filter((t5) => t5);
+ return new RegExp(e2.join("|"), "u");
+ }
+ const Vi = Bi(["Arab", "Dupl", "Mong", "Ougr", "Syrc"]);
+ function Ei(t4) {
+ return !Vi.test(String.fromCodePoint(t4));
+ }
+ const Fi = Bi(["Bopo", "Hani", "Hira", "Kana", "Kits", "Nshu", "Tang", "Yiii"]);
+ function Ti(t4) {
+ return !(746 !== t4 && 747 !== t4 && (t4 < 4352 || !(zi["CJK Compatibility Forms"](t4) && !(t4 >= 65097 && t4 <= 65103) || zi["CJK Compatibility"](t4) || zi["CJK Strokes"](t4) || !(!zi["CJK Symbols and Punctuation"](t4) || t4 >= 12296 && t4 <= 12305 || t4 >= 12308 && t4 <= 12319 || 12336 === t4) || zi["Enclosed CJK Letters and Months"](t4) || zi["Ideographic Description Characters"](t4) || zi.Kanbun(t4) || zi.Katakana(t4) && 12540 !== t4 || !(!zi["Halfwidth and Fullwidth Forms"](t4) || 65288 === t4 || 65289 === t4 || 65293 === t4 || t4 >= 65306 && t4 <= 65310 || 65339 === t4 || 65341 === t4 || 65343 === t4 || t4 >= 65371 && t4 <= 65503 || 65507 === t4 || t4 >= 65512 && t4 <= 65519) || !(!zi["Small Form Variants"](t4) || t4 >= 65112 && t4 <= 65118 || t4 >= 65123 && t4 <= 65126) || zi["Vertical Forms"](t4) || zi["Yijing Hexagram Symbols"](t4) || new RegExp("\\p{sc=Cans}", "u").test(String.fromCodePoint(t4)) || new RegExp("\\p{sc=Hang}", "u").test(String.fromCodePoint(t4)) || Fi.test(String.fromCodePoint(t4)))));
+ }
+ function $i(t4) {
+ return !(Ti(t4) || function(t5) {
+ return !!(zi["Latin-1 Supplement"](t5) && (167 === t5 || 169 === t5 || 174 === t5 || 177 === t5 || 188 === t5 || 189 === t5 || 190 === t5 || 215 === t5 || 247 === t5) || zi["General Punctuation"](t5) && (8214 === t5 || 8224 === t5 || 8225 === t5 || 8240 === t5 || 8241 === t5 || 8251 === t5 || 8252 === t5 || 8258 === t5 || 8263 === t5 || 8264 === t5 || 8265 === t5 || 8273 === t5) || zi["Letterlike Symbols"](t5) || zi["Number Forms"](t5) || zi["Miscellaneous Technical"](t5) && (t5 >= 8960 && t5 <= 8967 || t5 >= 8972 && t5 <= 8991 || t5 >= 8996 && t5 <= 9e3 || 9003 === t5 || t5 >= 9085 && t5 <= 9114 || t5 >= 9150 && t5 <= 9165 || 9167 === t5 || t5 >= 9169 && t5 <= 9179 || t5 >= 9186 && t5 <= 9215) || zi["Control Pictures"](t5) && 9251 !== t5 || zi["Optical Character Recognition"](t5) || zi["Enclosed Alphanumerics"](t5) || zi["Geometric Shapes"](t5) || zi["Miscellaneous Symbols"](t5) && !(t5 >= 9754 && t5 <= 9759) || zi["Miscellaneous Symbols and Arrows"](t5) && (t5 >= 11026 && t5 <= 11055 || t5 >= 11088 && t5 <= 11097 || t5 >= 11192 && t5 <= 11243) || zi["CJK Symbols and Punctuation"](t5) || zi.Katakana(t5) || zi["Private Use Area"](t5) || zi["CJK Compatibility Forms"](t5) || zi["Small Form Variants"](t5) || zi["Halfwidth and Fullwidth Forms"](t5) || 8734 === t5 || 8756 === t5 || 8757 === t5 || t5 >= 9984 && t5 <= 10087 || t5 >= 10102 && t5 <= 10131 || 65532 === t5 || 65533 === t5);
+ }(t4));
+ }
+ const Li = Bi(["Adlm", "Arab", "Armi", "Avst", "Chrs", "Cprt", "Egyp", "Elym", "Gara", "Hatr", "Hebr", "Hung", "Khar", "Lydi", "Mand", "Mani", "Mend", "Merc", "Mero", "Narb", "Nbat", "Nkoo", "Orkh", "Palm", "Phli", "Phlp", "Phnx", "Prti", "Rohg", "Samr", "Sarb", "Sogo", "Syrc", "Thaa", "Todr", "Yezi"]);
+ function Di(t4) {
+ return Li.test(String.fromCodePoint(t4));
+ }
+ function Oi(t4, e2) {
+ return !(!e2 && Di(t4) || t4 >= 2304 && t4 <= 3583 || t4 >= 3840 && t4 <= 4255 || zi.Khmer(t4));
+ }
+ function ji(t4) {
+ for (const e2 of t4) if (Di(e2.charCodeAt(0))) return true;
+ return false;
+ }
+ const Ri = new class {
+ constructor() {
+ this.applyArabicShaping = null, this.processBidirectionalText = null, this.processStyledBidirectionalText = null, this.pluginStatus = "unavailable", this.pluginURL = null;
+ }
+ setState(t4) {
+ this.pluginStatus = t4.pluginStatus, this.pluginURL = t4.pluginURL;
+ }
+ getState() {
+ return { pluginStatus: this.pluginStatus, pluginURL: this.pluginURL };
+ }
+ setMethods(t4) {
+ this.applyArabicShaping = t4.applyArabicShaping, this.processBidirectionalText = t4.processBidirectionalText, this.processStyledBidirectionalText = t4.processStyledBidirectionalText;
+ }
+ isParsed() {
+ return null != this.applyArabicShaping && null != this.processBidirectionalText && null != this.processStyledBidirectionalText;
+ }
+ getPluginURL() {
+ return this.pluginURL;
+ }
+ getRTLTextPluginStatus() {
+ return this.pluginStatus;
+ }
+ }();
+ class Ui {
+ constructor(t4, e2) {
+ this.zoom = t4, e2 ? (this.now = e2.now, this.fadeDuration = e2.fadeDuration, this.zoomHistory = e2.zoomHistory, this.transition = e2.transition) : (this.now = 0, this.fadeDuration = 0, this.zoomHistory = new Ii(), this.transition = {});
+ }
+ isSupportedScript(t4) {
+ return function(t5, e2) {
+ for (const r2 of t5) if (!Oi(r2.charCodeAt(0), e2)) return false;
+ return true;
+ }(t4, "loaded" === Ri.getRTLTextPluginStatus());
+ }
+ crossFadingFactor() {
+ return 0 === this.fadeDuration ? 1 : Math.min((this.now - this.zoomHistory.lastIntegerZoomTime) / this.fadeDuration, 1);
+ }
+ getCrossfadeParameters() {
+ const t4 = this.zoom, e2 = t4 - Math.floor(t4), r2 = this.crossFadingFactor();
+ return t4 > this.zoomHistory.lastIntegerZoom ? { fromScale: 2, toScale: 1, t: e2 + (1 - e2) * r2 } : { fromScale: 0.5, toScale: 1, t: 1 - (1 - r2) * e2 };
+ }
+ }
+ class qi {
+ constructor(t4, e2) {
+ this.property = t4, this.value = e2, this.expression = function(t5, e3) {
+ if (cn(t5)) return new Sn(t5, e3);
+ if (vn(t5)) {
+ const r2 = An(t5, e3);
+ if ("error" === r2.result) throw new Error(r2.value.map((t6) => `${t6.key}: ${t6.message}`).join(", "));
+ return r2.value;
+ }
+ {
+ let r2 = t5;
+ return "color" === e3.type && "string" == typeof t5 ? r2 = Kt.parse(t5) : "padding" !== e3.type || "number" != typeof t5 && !Array.isArray(t5) ? "variableAnchorOffsetCollection" === e3.type && Array.isArray(t5) && (r2 = Qt.parse(t5)) : r2 = Jt.parse(t5), { kind: "constant", evaluate: () => r2 };
+ }
+ }(void 0 === e2 ? t4.specification.default : e2, t4.specification);
+ }
+ isDataDriven() {
+ return "source" === this.expression.kind || "composite" === this.expression.kind;
+ }
+ possiblyEvaluate(t4, e2, r2) {
+ return this.property.possiblyEvaluate(this, t4, e2, r2);
+ }
+ }
+ class Ni {
+ constructor(t4) {
+ this.property = t4, this.value = new qi(t4, void 0);
+ }
+ transitioned(t4, e2) {
+ return new Gi(this.property, this.value, e2, g({}, t4.transition, this.transition), t4.now);
+ }
+ untransitioned() {
+ return new Gi(this.property, this.value, null, {}, 0);
+ }
+ }
+ class Zi {
+ constructor(t4) {
+ this._properties = t4, this._values = Object.create(t4.defaultTransitionablePropertyValues);
+ }
+ getValue(t4) {
+ return w(this._values[t4].value.value);
+ }
+ setValue(t4, e2) {
+ Object.prototype.hasOwnProperty.call(this._values, t4) || (this._values[t4] = new Ni(this._values[t4].property)), this._values[t4].value = new qi(this._values[t4].property, null === e2 ? void 0 : w(e2));
+ }
+ getTransition(t4) {
+ return w(this._values[t4].transition);
+ }
+ setTransition(t4, e2) {
+ Object.prototype.hasOwnProperty.call(this._values, t4) || (this._values[t4] = new Ni(this._values[t4].property)), this._values[t4].transition = w(e2) || void 0;
+ }
+ serialize() {
+ const t4 = {};
+ for (const e2 of Object.keys(this._values)) {
+ const r2 = this.getValue(e2);
+ void 0 !== r2 && (t4[e2] = r2);
+ const n2 = this.getTransition(e2);
+ void 0 !== n2 && (t4[`${e2}-transition`] = n2);
+ }
+ return t4;
+ }
+ transitioned(t4, e2) {
+ const r2 = new Ki(this._properties);
+ for (const n2 of Object.keys(this._values)) r2._values[n2] = this._values[n2].transitioned(t4, e2._values[n2]);
+ return r2;
+ }
+ untransitioned() {
+ const t4 = new Ki(this._properties);
+ for (const e2 of Object.keys(this._values)) t4._values[e2] = this._values[e2].untransitioned();
+ return t4;
+ }
+ }
+ class Gi {
+ constructor(t4, e2, r2, n2, i2) {
+ this.property = t4, this.value = e2, this.begin = i2 + n2.delay || 0, this.end = this.begin + n2.duration || 0, t4.specification.transition && (n2.delay || n2.duration) && (this.prior = r2);
+ }
+ possiblyEvaluate(t4, e2, r2) {
+ const n2 = t4.now || 0, i2 = this.value.possiblyEvaluate(t4, e2, r2), s2 = this.prior;
+ if (s2) {
+ if (n2 > this.end) return this.prior = null, i2;
+ if (this.value.isDataDriven()) return this.prior = null, i2;
+ if (n2 < this.begin) return s2.possiblyEvaluate(t4, e2, r2);
+ {
+ const a2 = (n2 - this.begin) / (this.end - this.begin);
+ return this.property.interpolate(s2.possiblyEvaluate(t4, e2, r2), i2, function(t5) {
+ if (t5 <= 0) return 0;
+ if (t5 >= 1) return 1;
+ const e3 = t5 * t5, r3 = e3 * t5;
+ return 4 * (t5 < 0.5 ? r3 : 3 * (t5 - e3) + r3 - 0.75);
+ }(a2));
+ }
+ }
+ return i2;
+ }
+ }
+ class Ki {
+ constructor(t4) {
+ this._properties = t4, this._values = Object.create(t4.defaultTransitioningPropertyValues);
+ }
+ possiblyEvaluate(t4, e2, r2) {
+ const n2 = new Yi(this._properties);
+ for (const i2 of Object.keys(this._values)) n2._values[i2] = this._values[i2].possiblyEvaluate(t4, e2, r2);
+ return n2;
+ }
+ hasTransition() {
+ for (const t4 of Object.keys(this._values)) if (this._values[t4].prior) return true;
+ return false;
+ }
+ }
+ class Xi {
+ constructor(t4) {
+ this._properties = t4, this._values = Object.create(t4.defaultPropertyValues);
+ }
+ hasValue(t4) {
+ return void 0 !== this._values[t4].value;
+ }
+ getValue(t4) {
+ return w(this._values[t4].value);
+ }
+ setValue(t4, e2) {
+ this._values[t4] = new qi(this._values[t4].property, null === e2 ? void 0 : w(e2));
+ }
+ serialize() {
+ const t4 = {};
+ for (const e2 of Object.keys(this._values)) {
+ const r2 = this.getValue(e2);
+ void 0 !== r2 && (t4[e2] = r2);
+ }
+ return t4;
+ }
+ possiblyEvaluate(t4, e2, r2) {
+ const n2 = new Yi(this._properties);
+ for (const i2 of Object.keys(this._values)) n2._values[i2] = this._values[i2].possiblyEvaluate(t4, e2, r2);
+ return n2;
+ }
+ }
+ class Hi {
+ constructor(t4, e2, r2) {
+ this.property = t4, this.value = e2, this.parameters = r2;
+ }
+ isConstant() {
+ return "constant" === this.value.kind;
+ }
+ constantOr(t4) {
+ return "constant" === this.value.kind ? this.value.value : t4;
+ }
+ evaluate(t4, e2, r2, n2) {
+ return this.property.evaluate(this.value, this.parameters, t4, e2, r2, n2);
+ }
+ }
+ class Yi {
+ constructor(t4) {
+ this._properties = t4, this._values = Object.create(t4.defaultPossiblyEvaluatedValues);
+ }
+ get(t4) {
+ return this._values[t4];
+ }
+ }
+ class Ji {
+ constructor(t4) {
+ this.specification = t4;
+ }
+ possiblyEvaluate(t4, e2) {
+ if (t4.isDataDriven()) throw new Error("Value should not be data driven");
+ return t4.expression.evaluate(e2);
+ }
+ interpolate(t4, e2, r2) {
+ const n2 = Ce[this.specification.type];
+ return n2 ? n2(t4, e2, r2) : t4;
+ }
+ }
+ class Wi {
+ constructor(t4, e2) {
+ this.specification = t4, this.overrides = e2;
+ }
+ possiblyEvaluate(t4, e2, r2, n2) {
+ return new Hi(this, "constant" === t4.expression.kind || "camera" === t4.expression.kind ? { kind: "constant", value: t4.expression.evaluate(e2, null, {}, r2, n2) } : t4.expression, e2);
+ }
+ interpolate(t4, e2, r2) {
+ if ("constant" !== t4.value.kind || "constant" !== e2.value.kind) return t4;
+ if (void 0 === t4.value.value || void 0 === e2.value.value) return new Hi(this, { kind: "constant", value: void 0 }, t4.parameters);
+ const n2 = Ce[this.specification.type];
+ if (n2) {
+ const i2 = n2(t4.value.value, e2.value.value, r2);
+ return new Hi(this, { kind: "constant", value: i2 }, t4.parameters);
+ }
+ return t4;
+ }
+ evaluate(t4, e2, r2, n2, i2, s2) {
+ return "constant" === t4.kind ? t4.value : t4.evaluate(e2, r2, n2, i2, s2);
+ }
+ }
+ class Qi extends Wi {
+ possiblyEvaluate(t4, e2, r2, n2) {
+ if (void 0 === t4.value) return new Hi(this, { kind: "constant", value: void 0 }, e2);
+ if ("constant" === t4.expression.kind) {
+ const i2 = t4.expression.evaluate(e2, null, {}, r2, n2), s2 = "resolvedImage" === t4.property.specification.type && "string" != typeof i2 ? i2.name : i2, a2 = this._calculate(s2, s2, s2, e2);
+ return new Hi(this, { kind: "constant", value: a2 }, e2);
+ }
+ if ("camera" === t4.expression.kind) {
+ const r3 = this._calculate(t4.expression.evaluate({ zoom: e2.zoom - 1 }), t4.expression.evaluate({ zoom: e2.zoom }), t4.expression.evaluate({ zoom: e2.zoom + 1 }), e2);
+ return new Hi(this, { kind: "constant", value: r3 }, e2);
+ }
+ return new Hi(this, t4.expression, e2);
+ }
+ evaluate(t4, e2, r2, n2, i2, s2) {
+ if ("source" === t4.kind) {
+ const a2 = t4.evaluate(e2, r2, n2, i2, s2);
+ return this._calculate(a2, a2, a2, e2);
+ }
+ return "composite" === t4.kind ? this._calculate(t4.evaluate({ zoom: Math.floor(e2.zoom) - 1 }, r2, n2), t4.evaluate({ zoom: Math.floor(e2.zoom) }, r2, n2), t4.evaluate({ zoom: Math.floor(e2.zoom) + 1 }, r2, n2), e2) : t4.value;
+ }
+ _calculate(t4, e2, r2, n2) {
+ return n2.zoom > n2.zoomHistory.lastIntegerZoom ? { from: t4, to: e2 } : { from: r2, to: e2 };
+ }
+ interpolate(t4) {
+ return t4;
+ }
+ }
+ class ts {
+ constructor(t4) {
+ this.specification = t4;
+ }
+ possiblyEvaluate(t4, e2, r2, n2) {
+ if (void 0 !== t4.value) {
+ if ("constant" === t4.expression.kind) {
+ const i2 = t4.expression.evaluate(e2, null, {}, r2, n2);
+ return this._calculate(i2, i2, i2, e2);
+ }
+ return this._calculate(t4.expression.evaluate(new Ui(Math.floor(e2.zoom - 1), e2)), t4.expression.evaluate(new Ui(Math.floor(e2.zoom), e2)), t4.expression.evaluate(new Ui(Math.floor(e2.zoom + 1), e2)), e2);
+ }
+ }
+ _calculate(t4, e2, r2, n2) {
+ return n2.zoom > n2.zoomHistory.lastIntegerZoom ? { from: t4, to: e2 } : { from: r2, to: e2 };
+ }
+ interpolate(t4) {
+ return t4;
+ }
+ }
+ class es {
+ constructor(t4) {
+ this.specification = t4;
+ }
+ possiblyEvaluate(t4, e2, r2, n2) {
+ return !!t4.expression.evaluate(e2, null, {}, r2, n2);
+ }
+ interpolate() {
+ return false;
+ }
+ }
+ class rs {
+ constructor(t4) {
+ this.properties = t4, this.defaultPropertyValues = {}, this.defaultTransitionablePropertyValues = {}, this.defaultTransitioningPropertyValues = {}, this.defaultPossiblyEvaluatedValues = {}, this.overridableProperties = [];
+ for (const e2 in t4) {
+ const r2 = t4[e2];
+ r2.specification.overridable && this.overridableProperties.push(e2);
+ const n2 = this.defaultPropertyValues[e2] = new qi(r2, void 0), i2 = this.defaultTransitionablePropertyValues[e2] = new Ni(r2);
+ this.defaultTransitioningPropertyValues[e2] = i2.untransitioned(), this.defaultPossiblyEvaluatedValues[e2] = n2.possiblyEvaluate({});
+ }
+ }
+ }
+ wi("DataDrivenProperty", Wi), wi("DataConstantProperty", Ji), wi("CrossFadedDataDrivenProperty", Qi), wi("CrossFadedProperty", ts), wi("ColorRampProperty", es);
+ const ns = "-transition";
+ class is extends Z {
+ constructor(t4, e2) {
+ if (super(), this.id = t4.id, this.type = t4.type, this._featureFilter = { filter: () => true, needGeometry: false }, "custom" !== t4.type && (this.metadata = t4.metadata, this.minzoom = t4.minzoom, this.maxzoom = t4.maxzoom, "background" !== t4.type && (this.source = t4.source, this.sourceLayer = t4["source-layer"], this.filter = t4.filter), e2.layout && (this._unevaluatedLayout = new Xi(e2.layout)), e2.paint)) {
+ this._transitionablePaint = new Zi(e2.paint);
+ for (const e3 in t4.paint) this.setPaintProperty(e3, t4.paint[e3], { validate: false });
+ for (const e3 in t4.layout) this.setLayoutProperty(e3, t4.layout[e3], { validate: false });
+ this._transitioningPaint = this._transitionablePaint.untransitioned(), this.paint = new Yi(e2.paint);
+ }
+ }
+ getCrossfadeParameters() {
+ return this._crossfadeParameters;
+ }
+ getLayoutProperty(t4) {
+ return "visibility" === t4 ? this.visibility : this._unevaluatedLayout.getValue(t4);
+ }
+ setLayoutProperty(t4, e2, r2 = {}) {
+ null != e2 && this._validate(gi, `layers.${this.id}.layout.${t4}`, t4, e2, r2) || ("visibility" !== t4 ? this._unevaluatedLayout.setValue(t4, e2) : this.visibility = e2);
+ }
+ getPaintProperty(t4) {
+ return t4.endsWith(ns) ? this._transitionablePaint.getTransition(t4.slice(0, -11)) : this._transitionablePaint.getValue(t4);
+ }
+ setPaintProperty(t4, e2, r2 = {}) {
+ if (null != e2 && this._validate(mi, `layers.${this.id}.paint.${t4}`, t4, e2, r2)) return false;
+ if (t4.endsWith(ns)) return this._transitionablePaint.setTransition(t4.slice(0, -11), e2 || void 0), false;
+ {
+ const r3 = this._transitionablePaint._values[t4], n2 = "cross-faded-data-driven" === r3.property.specification["property-type"], i2 = r3.value.isDataDriven(), s2 = r3.value;
+ this._transitionablePaint.setValue(t4, e2), this._handleSpecialPaintPropertyUpdate(t4);
+ const a2 = this._transitionablePaint._values[t4].value;
+ return a2.isDataDriven() || i2 || n2 || this._handleOverridablePaintPropertyUpdate(t4, s2, a2);
+ }
+ }
+ _handleSpecialPaintPropertyUpdate(t4) {
+ }
+ _handleOverridablePaintPropertyUpdate(t4, e2, r2) {
+ return false;
+ }
+ isHidden(t4) {
+ return !!(this.minzoom && t4 < this.minzoom) || !!(this.maxzoom && t4 >= this.maxzoom) || "none" === this.visibility;
+ }
+ updateTransitions(t4) {
+ this._transitioningPaint = this._transitionablePaint.transitioned(t4, this._transitioningPaint);
+ }
+ hasTransition() {
+ return this._transitioningPaint.hasTransition();
+ }
+ recalculate(t4, e2) {
+ t4.getCrossfadeParameters && (this._crossfadeParameters = t4.getCrossfadeParameters()), this._unevaluatedLayout && (this.layout = this._unevaluatedLayout.possiblyEvaluate(t4, void 0, e2)), this.paint = this._transitioningPaint.possiblyEvaluate(t4, void 0, e2);
+ }
+ serialize() {
+ const t4 = { id: this.id, type: this.type, source: this.source, "source-layer": this.sourceLayer, metadata: this.metadata, minzoom: this.minzoom, maxzoom: this.maxzoom, filter: this.filter, layout: this._unevaluatedLayout && this._unevaluatedLayout.serialize(), paint: this._transitionablePaint && this._transitionablePaint.serialize() };
+ return this.visibility && (t4.layout = t4.layout || {}, t4.layout.visibility = this.visibility), b(t4, (t5, e2) => !(void 0 === t5 || "layout" === e2 && !Object.keys(t5).length || "paint" === e2 && !Object.keys(t5).length));
+ }
+ _validate(t4, e2, r2, n2, i2 = {}) {
+ return (!i2 || false !== i2.validate) && xi(this, t4.call(fi, { key: e2, layerType: this.type, objectKey: r2, value: n2, styleSpec: G, style: { glyphs: true, sprite: true } }));
+ }
+ is3D() {
+ return false;
+ }
+ isTileClipped() {
+ return false;
+ }
+ hasOffscreenPass() {
+ return false;
+ }
+ resize() {
+ }
+ isStateDependent() {
+ for (const t4 in this.paint._values) {
+ const e2 = this.paint.get(t4);
+ if (e2 instanceof Hi && an(e2.property.specification) && ("source" === e2.value.kind || "composite" === e2.value.kind) && e2.value.isStateDependent) return true;
+ }
+ return false;
+ }
+ }
+ const ss = { Int8: Int8Array, Uint8: Uint8Array, Int16: Int16Array, Uint16: Uint16Array, Int32: Int32Array, Uint32: Uint32Array, Float32: Float32Array };
+ class as {
+ constructor(t4, e2) {
+ this._structArray = t4, this._pos1 = e2 * this.size, this._pos2 = this._pos1 / 2, this._pos4 = this._pos1 / 4, this._pos8 = this._pos1 / 8;
+ }
+ }
+ class os {
+ constructor() {
+ this.isTransferred = false, this.capacity = -1, this.resize(0);
+ }
+ static serialize(t4, e2) {
+ return t4._trim(), e2 && (t4.isTransferred = true, e2.push(t4.arrayBuffer)), { length: t4.length, arrayBuffer: t4.arrayBuffer };
+ }
+ static deserialize(t4) {
+ const e2 = Object.create(this.prototype);
+ return e2.arrayBuffer = t4.arrayBuffer, e2.length = t4.length, e2.capacity = t4.arrayBuffer.byteLength / e2.bytesPerElement, e2._refreshViews(), e2;
+ }
+ _trim() {
+ this.length !== this.capacity && (this.capacity = this.length, this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement), this._refreshViews());
+ }
+ clear() {
+ this.length = 0;
+ }
+ resize(t4) {
+ this.reserve(t4), this.length = t4;
+ }
+ reserve(t4) {
+ if (t4 > this.capacity) {
+ this.capacity = Math.max(t4, Math.floor(5 * this.capacity), 128), this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement);
+ const e2 = this.uint8;
+ this._refreshViews(), e2 && this.uint8.set(e2);
+ }
+ }
+ _refreshViews() {
+ throw new Error("_refreshViews() must be implemented by each concrete StructArray layout");
+ }
+ }
+ function ls(t4, e2 = 1) {
+ let r2 = 0, n2 = 0;
+ return { members: t4.map((t5) => {
+ const i2 = ss[t5.type].BYTES_PER_ELEMENT, s2 = r2 = us(r2, Math.max(e2, i2)), a2 = t5.components || 1;
+ return n2 = Math.max(n2, i2), r2 += i2 * a2, { name: t5.name, type: t5.type, components: a2, offset: s2 };
+ }), size: us(r2, Math.max(n2, e2)), alignment: e2 };
+ }
+ function us(t4, e2) {
+ return Math.ceil(t4 / e2) * e2;
+ }
+ class cs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2) {
+ const r2 = this.length;
+ return this.resize(r2 + 1), this.emplace(r2, t4, e2);
+ }
+ emplace(t4, e2, r2) {
+ const n2 = 2 * t4;
+ return this.int16[n2 + 0] = e2, this.int16[n2 + 1] = r2, t4;
+ }
+ }
+ cs.prototype.bytesPerElement = 4, wi("StructArrayLayout2i4", cs);
+ class hs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2) {
+ const n2 = this.length;
+ return this.resize(n2 + 1), this.emplace(n2, t4, e2, r2);
+ }
+ emplace(t4, e2, r2, n2) {
+ const i2 = 3 * t4;
+ return this.int16[i2 + 0] = e2, this.int16[i2 + 1] = r2, this.int16[i2 + 2] = n2, t4;
+ }
+ }
+ hs.prototype.bytesPerElement = 6, wi("StructArrayLayout3i6", hs);
+ class ps extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2) {
+ const i2 = this.length;
+ return this.resize(i2 + 1), this.emplace(i2, t4, e2, r2, n2);
+ }
+ emplace(t4, e2, r2, n2, i2) {
+ const s2 = 4 * t4;
+ return this.int16[s2 + 0] = e2, this.int16[s2 + 1] = r2, this.int16[s2 + 2] = n2, this.int16[s2 + 3] = i2, t4;
+ }
+ }
+ ps.prototype.bytesPerElement = 8, wi("StructArrayLayout4i8", ps);
+ class fs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2, s2) {
+ const a2 = this.length;
+ return this.resize(a2 + 1), this.emplace(a2, t4, e2, r2, n2, i2, s2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2, a2) {
+ const o2 = 6 * t4;
+ return this.int16[o2 + 0] = e2, this.int16[o2 + 1] = r2, this.int16[o2 + 2] = n2, this.int16[o2 + 3] = i2, this.int16[o2 + 4] = s2, this.int16[o2 + 5] = a2, t4;
+ }
+ }
+ fs.prototype.bytesPerElement = 12, wi("StructArrayLayout2i4i12", fs);
+ class ds extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2, s2) {
+ const a2 = this.length;
+ return this.resize(a2 + 1), this.emplace(a2, t4, e2, r2, n2, i2, s2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2, a2) {
+ const o2 = 4 * t4, l2 = 8 * t4;
+ return this.int16[o2 + 0] = e2, this.int16[o2 + 1] = r2, this.uint8[l2 + 4] = n2, this.uint8[l2 + 5] = i2, this.uint8[l2 + 6] = s2, this.uint8[l2 + 7] = a2, t4;
+ }
+ }
+ ds.prototype.bytesPerElement = 8, wi("StructArrayLayout2i4ub8", ds);
+ class ys extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2) {
+ const r2 = this.length;
+ return this.resize(r2 + 1), this.emplace(r2, t4, e2);
+ }
+ emplace(t4, e2, r2) {
+ const n2 = 2 * t4;
+ return this.float32[n2 + 0] = e2, this.float32[n2 + 1] = r2, t4;
+ }
+ }
+ ys.prototype.bytesPerElement = 8, wi("StructArrayLayout2f8", ys);
+ class ms extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2) {
+ const c2 = this.length;
+ return this.resize(c2 + 1), this.emplace(c2, t4, e2, r2, n2, i2, s2, a2, o2, l2, u2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2) {
+ const h2 = 10 * t4;
+ return this.uint16[h2 + 0] = e2, this.uint16[h2 + 1] = r2, this.uint16[h2 + 2] = n2, this.uint16[h2 + 3] = i2, this.uint16[h2 + 4] = s2, this.uint16[h2 + 5] = a2, this.uint16[h2 + 6] = o2, this.uint16[h2 + 7] = l2, this.uint16[h2 + 8] = u2, this.uint16[h2 + 9] = c2, t4;
+ }
+ }
+ ms.prototype.bytesPerElement = 20, wi("StructArrayLayout10ui20", ms);
+ class gs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2) {
+ const p2 = this.length;
+ return this.resize(p2 + 1), this.emplace(p2, t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2) {
+ const f2 = 12 * t4;
+ return this.int16[f2 + 0] = e2, this.int16[f2 + 1] = r2, this.int16[f2 + 2] = n2, this.int16[f2 + 3] = i2, this.uint16[f2 + 4] = s2, this.uint16[f2 + 5] = a2, this.uint16[f2 + 6] = o2, this.uint16[f2 + 7] = l2, this.int16[f2 + 8] = u2, this.int16[f2 + 9] = c2, this.int16[f2 + 10] = h2, this.int16[f2 + 11] = p2, t4;
+ }
+ }
+ gs.prototype.bytesPerElement = 24, wi("StructArrayLayout4i4ui4i24", gs);
+ class xs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2) {
+ const n2 = this.length;
+ return this.resize(n2 + 1), this.emplace(n2, t4, e2, r2);
+ }
+ emplace(t4, e2, r2, n2) {
+ const i2 = 3 * t4;
+ return this.float32[i2 + 0] = e2, this.float32[i2 + 1] = r2, this.float32[i2 + 2] = n2, t4;
+ }
+ }
+ xs.prototype.bytesPerElement = 12, wi("StructArrayLayout3f12", xs);
+ class vs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer);
+ }
+ emplaceBack(t4) {
+ const e2 = this.length;
+ return this.resize(e2 + 1), this.emplace(e2, t4);
+ }
+ emplace(t4, e2) {
+ return this.uint32[1 * t4 + 0] = e2, t4;
+ }
+ }
+ vs.prototype.bytesPerElement = 4, wi("StructArrayLayout1ul4", vs);
+ class bs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2, s2, a2, o2, l2) {
+ const u2 = this.length;
+ return this.resize(u2 + 1), this.emplace(u2, t4, e2, r2, n2, i2, s2, a2, o2, l2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2) {
+ const c2 = 10 * t4, h2 = 5 * t4;
+ return this.int16[c2 + 0] = e2, this.int16[c2 + 1] = r2, this.int16[c2 + 2] = n2, this.int16[c2 + 3] = i2, this.int16[c2 + 4] = s2, this.int16[c2 + 5] = a2, this.uint32[h2 + 3] = o2, this.uint16[c2 + 8] = l2, this.uint16[c2 + 9] = u2, t4;
+ }
+ }
+ bs.prototype.bytesPerElement = 20, wi("StructArrayLayout6i1ul2ui20", bs);
+ class ws extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2, s2) {
+ const a2 = this.length;
+ return this.resize(a2 + 1), this.emplace(a2, t4, e2, r2, n2, i2, s2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2, a2) {
+ const o2 = 6 * t4;
+ return this.int16[o2 + 0] = e2, this.int16[o2 + 1] = r2, this.int16[o2 + 2] = n2, this.int16[o2 + 3] = i2, this.int16[o2 + 4] = s2, this.int16[o2 + 5] = a2, t4;
+ }
+ }
+ ws.prototype.bytesPerElement = 12, wi("StructArrayLayout2i2i2i12", ws);
+ class _s extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2) {
+ const s2 = this.length;
+ return this.resize(s2 + 1), this.emplace(s2, t4, e2, r2, n2, i2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2) {
+ const a2 = 4 * t4, o2 = 8 * t4;
+ return this.float32[a2 + 0] = e2, this.float32[a2 + 1] = r2, this.float32[a2 + 2] = n2, this.int16[o2 + 6] = i2, this.int16[o2 + 7] = s2, t4;
+ }
+ }
+ _s.prototype.bytesPerElement = 16, wi("StructArrayLayout2f1f2i16", _s);
+ class As extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2, s2) {
+ const a2 = this.length;
+ return this.resize(a2 + 1), this.emplace(a2, t4, e2, r2, n2, i2, s2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2, a2) {
+ const o2 = 16 * t4, l2 = 4 * t4, u2 = 8 * t4;
+ return this.uint8[o2 + 0] = e2, this.uint8[o2 + 1] = r2, this.float32[l2 + 1] = n2, this.float32[l2 + 2] = i2, this.int16[u2 + 6] = s2, this.int16[u2 + 7] = a2, t4;
+ }
+ }
+ As.prototype.bytesPerElement = 16, wi("StructArrayLayout2ub2f2i16", As);
+ class Ss extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2) {
+ const n2 = this.length;
+ return this.resize(n2 + 1), this.emplace(n2, t4, e2, r2);
+ }
+ emplace(t4, e2, r2, n2) {
+ const i2 = 3 * t4;
+ return this.uint16[i2 + 0] = e2, this.uint16[i2 + 1] = r2, this.uint16[i2 + 2] = n2, t4;
+ }
+ }
+ Ss.prototype.bytesPerElement = 6, wi("StructArrayLayout3ui6", Ss);
+ class ks extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2) {
+ const g2 = this.length;
+ return this.resize(g2 + 1), this.emplace(g2, t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2) {
+ const x2 = 24 * t4, v2 = 12 * t4, b2 = 48 * t4;
+ return this.int16[x2 + 0] = e2, this.int16[x2 + 1] = r2, this.uint16[x2 + 2] = n2, this.uint16[x2 + 3] = i2, this.uint32[v2 + 2] = s2, this.uint32[v2 + 3] = a2, this.uint32[v2 + 4] = o2, this.uint16[x2 + 10] = l2, this.uint16[x2 + 11] = u2, this.uint16[x2 + 12] = c2, this.float32[v2 + 7] = h2, this.float32[v2 + 8] = p2, this.uint8[b2 + 36] = f2, this.uint8[b2 + 37] = d2, this.uint8[b2 + 38] = y2, this.uint32[v2 + 10] = m2, this.int16[x2 + 22] = g2, t4;
+ }
+ }
+ ks.prototype.bytesPerElement = 48, wi("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48", ks);
+ class Ms extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.int16 = new Int16Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2, w2, _2, A3, S2, k2, M2, I2) {
+ const z2 = this.length;
+ return this.resize(z2 + 1), this.emplace(z2, t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2, w2, _2, A3, S2, k2, M2, I2);
+ }
+ emplace(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2, m2, g2, x2, v2, b2, w2, _2, A3, S2, k2, M2, I2, z2) {
+ const P2 = 32 * t4, C3 = 16 * t4;
+ return this.int16[P2 + 0] = e2, this.int16[P2 + 1] = r2, this.int16[P2 + 2] = n2, this.int16[P2 + 3] = i2, this.int16[P2 + 4] = s2, this.int16[P2 + 5] = a2, this.int16[P2 + 6] = o2, this.int16[P2 + 7] = l2, this.uint16[P2 + 8] = u2, this.uint16[P2 + 9] = c2, this.uint16[P2 + 10] = h2, this.uint16[P2 + 11] = p2, this.uint16[P2 + 12] = f2, this.uint16[P2 + 13] = d2, this.uint16[P2 + 14] = y2, this.uint16[P2 + 15] = m2, this.uint16[P2 + 16] = g2, this.uint16[P2 + 17] = x2, this.uint16[P2 + 18] = v2, this.uint16[P2 + 19] = b2, this.uint16[P2 + 20] = w2, this.uint16[P2 + 21] = _2, this.uint16[P2 + 22] = A3, this.uint32[C3 + 12] = S2, this.float32[C3 + 13] = k2, this.float32[C3 + 14] = M2, this.uint16[P2 + 30] = I2, this.uint16[P2 + 31] = z2, t4;
+ }
+ }
+ Ms.prototype.bytesPerElement = 64, wi("StructArrayLayout8i15ui1ul2f2ui64", Ms);
+ class Is extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
+ }
+ emplaceBack(t4) {
+ const e2 = this.length;
+ return this.resize(e2 + 1), this.emplace(e2, t4);
+ }
+ emplace(t4, e2) {
+ return this.float32[1 * t4 + 0] = e2, t4;
+ }
+ }
+ Is.prototype.bytesPerElement = 4, wi("StructArrayLayout1f4", Is);
+ class zs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2) {
+ const n2 = this.length;
+ return this.resize(n2 + 1), this.emplace(n2, t4, e2, r2);
+ }
+ emplace(t4, e2, r2, n2) {
+ const i2 = 3 * t4;
+ return this.uint16[6 * t4 + 0] = e2, this.float32[i2 + 1] = r2, this.float32[i2 + 2] = n2, t4;
+ }
+ }
+ zs.prototype.bytesPerElement = 12, wi("StructArrayLayout1ui2f12", zs);
+ class Ps extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.uint32 = new Uint32Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2) {
+ const n2 = this.length;
+ return this.resize(n2 + 1), this.emplace(n2, t4, e2, r2);
+ }
+ emplace(t4, e2, r2, n2) {
+ const i2 = 4 * t4;
+ return this.uint32[2 * t4 + 0] = e2, this.uint16[i2 + 2] = r2, this.uint16[i2 + 3] = n2, t4;
+ }
+ }
+ Ps.prototype.bytesPerElement = 8, wi("StructArrayLayout1ul2ui8", Ps);
+ class Cs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2) {
+ const r2 = this.length;
+ return this.resize(r2 + 1), this.emplace(r2, t4, e2);
+ }
+ emplace(t4, e2, r2) {
+ const n2 = 2 * t4;
+ return this.uint16[n2 + 0] = e2, this.uint16[n2 + 1] = r2, t4;
+ }
+ }
+ Cs.prototype.bytesPerElement = 4, wi("StructArrayLayout2ui4", Cs);
+ class Bs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.uint16 = new Uint16Array(this.arrayBuffer);
+ }
+ emplaceBack(t4) {
+ const e2 = this.length;
+ return this.resize(e2 + 1), this.emplace(e2, t4);
+ }
+ emplace(t4, e2) {
+ return this.uint16[1 * t4 + 0] = e2, t4;
+ }
+ }
+ Bs.prototype.bytesPerElement = 2, wi("StructArrayLayout1ui2", Bs);
+ class Vs extends os {
+ _refreshViews() {
+ this.uint8 = new Uint8Array(this.arrayBuffer), this.float32 = new Float32Array(this.arrayBuffer);
+ }
+ emplaceBack(t4, e2, r2, n2) {
+ const i2 = this.length;
+ return this.resize(i2 + 1), this.emplace(i2, t4, e2, r2, n2);
+ }
+ emplace(t4, e2, r2, n2, i2) {
+ const s2 = 4 * t4;
+ return this.float32[s2 + 0] = e2, this.float32[s2 + 1] = r2, this.float32[s2 + 2] = n2, this.float32[s2 + 3] = i2, t4;
+ }
+ }
+ Vs.prototype.bytesPerElement = 16, wi("StructArrayLayout4f16", Vs);
+ class Es extends as {
+ get anchorPointX() {
+ return this._structArray.int16[this._pos2 + 0];
+ }
+ get anchorPointY() {
+ return this._structArray.int16[this._pos2 + 1];
+ }
+ get x1() {
+ return this._structArray.int16[this._pos2 + 2];
+ }
+ get y1() {
+ return this._structArray.int16[this._pos2 + 3];
+ }
+ get x2() {
+ return this._structArray.int16[this._pos2 + 4];
+ }
+ get y2() {
+ return this._structArray.int16[this._pos2 + 5];
+ }
+ get featureIndex() {
+ return this._structArray.uint32[this._pos4 + 3];
+ }
+ get sourceLayerIndex() {
+ return this._structArray.uint16[this._pos2 + 8];
+ }
+ get bucketIndex() {
+ return this._structArray.uint16[this._pos2 + 9];
+ }
+ get anchorPoint() {
+ return new s(this.anchorPointX, this.anchorPointY);
+ }
+ }
+ Es.prototype.size = 20;
+ class Fs extends bs {
+ get(t4) {
+ return new Es(this, t4);
+ }
+ }
+ wi("CollisionBoxArray", Fs);
+ class Ts extends as {
+ get anchorX() {
+ return this._structArray.int16[this._pos2 + 0];
+ }
+ get anchorY() {
+ return this._structArray.int16[this._pos2 + 1];
+ }
+ get glyphStartIndex() {
+ return this._structArray.uint16[this._pos2 + 2];
+ }
+ get numGlyphs() {
+ return this._structArray.uint16[this._pos2 + 3];
+ }
+ get vertexStartIndex() {
+ return this._structArray.uint32[this._pos4 + 2];
+ }
+ get lineStartIndex() {
+ return this._structArray.uint32[this._pos4 + 3];
+ }
+ get lineLength() {
+ return this._structArray.uint32[this._pos4 + 4];
+ }
+ get segment() {
+ return this._structArray.uint16[this._pos2 + 10];
+ }
+ get lowerSize() {
+ return this._structArray.uint16[this._pos2 + 11];
+ }
+ get upperSize() {
+ return this._structArray.uint16[this._pos2 + 12];
+ }
+ get lineOffsetX() {
+ return this._structArray.float32[this._pos4 + 7];
+ }
+ get lineOffsetY() {
+ return this._structArray.float32[this._pos4 + 8];
+ }
+ get writingMode() {
+ return this._structArray.uint8[this._pos1 + 36];
+ }
+ get placedOrientation() {
+ return this._structArray.uint8[this._pos1 + 37];
+ }
+ set placedOrientation(t4) {
+ this._structArray.uint8[this._pos1 + 37] = t4;
+ }
+ get hidden() {
+ return this._structArray.uint8[this._pos1 + 38];
+ }
+ set hidden(t4) {
+ this._structArray.uint8[this._pos1 + 38] = t4;
+ }
+ get crossTileID() {
+ return this._structArray.uint32[this._pos4 + 10];
+ }
+ set crossTileID(t4) {
+ this._structArray.uint32[this._pos4 + 10] = t4;
+ }
+ get associatedIconIndex() {
+ return this._structArray.int16[this._pos2 + 22];
+ }
+ }
+ Ts.prototype.size = 48;
+ class $s extends ks {
+ get(t4) {
+ return new Ts(this, t4);
+ }
+ }
+ wi("PlacedSymbolArray", $s);
+ class Ls extends as {
+ get anchorX() {
+ return this._structArray.int16[this._pos2 + 0];
+ }
+ get anchorY() {
+ return this._structArray.int16[this._pos2 + 1];
+ }
+ get rightJustifiedTextSymbolIndex() {
+ return this._structArray.int16[this._pos2 + 2];
+ }
+ get centerJustifiedTextSymbolIndex() {
+ return this._structArray.int16[this._pos2 + 3];
+ }
+ get leftJustifiedTextSymbolIndex() {
+ return this._structArray.int16[this._pos2 + 4];
+ }
+ get verticalPlacedTextSymbolIndex() {
+ return this._structArray.int16[this._pos2 + 5];
+ }
+ get placedIconSymbolIndex() {
+ return this._structArray.int16[this._pos2 + 6];
+ }
+ get verticalPlacedIconSymbolIndex() {
+ return this._structArray.int16[this._pos2 + 7];
+ }
+ get key() {
+ return this._structArray.uint16[this._pos2 + 8];
+ }
+ get textBoxStartIndex() {
+ return this._structArray.uint16[this._pos2 + 9];
+ }
+ get textBoxEndIndex() {
+ return this._structArray.uint16[this._pos2 + 10];
+ }
+ get verticalTextBoxStartIndex() {
+ return this._structArray.uint16[this._pos2 + 11];
+ }
+ get verticalTextBoxEndIndex() {
+ return this._structArray.uint16[this._pos2 + 12];
+ }
+ get iconBoxStartIndex() {
+ return this._structArray.uint16[this._pos2 + 13];
+ }
+ get iconBoxEndIndex() {
+ return this._structArray.uint16[this._pos2 + 14];
+ }
+ get verticalIconBoxStartIndex() {
+ return this._structArray.uint16[this._pos2 + 15];
+ }
+ get verticalIconBoxEndIndex() {
+ return this._structArray.uint16[this._pos2 + 16];
+ }
+ get featureIndex() {
+ return this._structArray.uint16[this._pos2 + 17];
+ }
+ get numHorizontalGlyphVertices() {
+ return this._structArray.uint16[this._pos2 + 18];
+ }
+ get numVerticalGlyphVertices() {
+ return this._structArray.uint16[this._pos2 + 19];
+ }
+ get numIconVertices() {
+ return this._structArray.uint16[this._pos2 + 20];
+ }
+ get numVerticalIconVertices() {
+ return this._structArray.uint16[this._pos2 + 21];
+ }
+ get useRuntimeCollisionCircles() {
+ return this._structArray.uint16[this._pos2 + 22];
+ }
+ get crossTileID() {
+ return this._structArray.uint32[this._pos4 + 12];
+ }
+ set crossTileID(t4) {
+ this._structArray.uint32[this._pos4 + 12] = t4;
+ }
+ get textBoxScale() {
+ return this._structArray.float32[this._pos4 + 13];
+ }
+ get collisionCircleDiameter() {
+ return this._structArray.float32[this._pos4 + 14];
+ }
+ get textAnchorOffsetStartIndex() {
+ return this._structArray.uint16[this._pos2 + 30];
+ }
+ get textAnchorOffsetEndIndex() {
+ return this._structArray.uint16[this._pos2 + 31];
+ }
+ }
+ Ls.prototype.size = 64;
+ class Ds extends Ms {
+ get(t4) {
+ return new Ls(this, t4);
+ }
+ }
+ wi("SymbolInstanceArray", Ds);
+ class Os extends Is {
+ getoffsetX(t4) {
+ return this.float32[1 * t4 + 0];
+ }
+ }
+ wi("GlyphOffsetArray", Os);
+ class js extends hs {
+ getx(t4) {
+ return this.int16[3 * t4 + 0];
+ }
+ gety(t4) {
+ return this.int16[3 * t4 + 1];
+ }
+ gettileUnitDistanceFromAnchor(t4) {
+ return this.int16[3 * t4 + 2];
+ }
+ }
+ wi("SymbolLineVertexArray", js);
+ class Rs extends as {
+ get textAnchor() {
+ return this._structArray.uint16[this._pos2 + 0];
+ }
+ get textOffset0() {
+ return this._structArray.float32[this._pos4 + 1];
+ }
+ get textOffset1() {
+ return this._structArray.float32[this._pos4 + 2];
+ }
+ }
+ Rs.prototype.size = 12;
+ class Us extends zs {
+ get(t4) {
+ return new Rs(this, t4);
+ }
+ }
+ wi("TextAnchorOffsetArray", Us);
+ class qs extends as {
+ get featureIndex() {
+ return this._structArray.uint32[this._pos4 + 0];
+ }
+ get sourceLayerIndex() {
+ return this._structArray.uint16[this._pos2 + 2];
+ }
+ get bucketIndex() {
+ return this._structArray.uint16[this._pos2 + 3];
+ }
+ }
+ qs.prototype.size = 8;
+ class Ns extends Ps {
+ get(t4) {
+ return new qs(this, t4);
+ }
+ }
+ wi("FeatureIndexArray", Ns);
+ class Zs extends cs {
+ }
+ class Gs extends cs {
+ }
+ class Ks extends cs {
+ }
+ class Xs extends fs {
+ }
+ class Hs extends ds {
+ }
+ class Ys extends ys {
+ }
+ class Js extends ms {
+ }
+ class Ws extends gs {
+ }
+ class Qs extends xs {
+ }
+ class ta extends vs {
+ }
+ class ea extends ws {
+ }
+ class ra extends As {
+ }
+ class na extends Ss {
+ }
+ class ia extends Cs {
+ }
+ const sa = ls([{ name: "a_pos", components: 2, type: "Int16" }], 4), { members: aa } = sa;
+ class oa {
+ constructor(t4 = []) {
+ this.segments = t4;
+ }
+ prepareSegment(t4, e2, r2, n2) {
+ let i2 = this.segments[this.segments.length - 1];
+ return t4 > oa.MAX_VERTEX_ARRAY_LENGTH && A2(`Max vertices per segment is ${oa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t4}`), (!i2 || i2.vertexLength + t4 > oa.MAX_VERTEX_ARRAY_LENGTH || i2.sortKey !== n2) && (i2 = { vertexOffset: e2.length, primitiveOffset: r2.length, vertexLength: 0, primitiveLength: 0 }, void 0 !== n2 && (i2.sortKey = n2), this.segments.push(i2)), i2;
+ }
+ get() {
+ return this.segments;
+ }
+ destroy() {
+ for (const t4 of this.segments) for (const e2 in t4.vaos) t4.vaos[e2].destroy();
+ }
+ static simpleSegment(t4, e2, r2, n2) {
+ return new oa([{ vertexOffset: t4, primitiveOffset: e2, vertexLength: r2, primitiveLength: n2, vaos: {}, sortKey: 0 }]);
+ }
+ }
+ function la(t4, e2) {
+ return 256 * (t4 = y(Math.floor(t4), 0, 255)) + y(Math.floor(e2), 0, 255);
+ }
+ oa.MAX_VERTEX_ARRAY_LENGTH = Math.pow(2, 16) - 1, wi("SegmentVector", oa);
+ const ua = ls([{ name: "a_pattern_from", components: 4, type: "Uint16" }, { name: "a_pattern_to", components: 4, type: "Uint16" }, { name: "a_pixel_ratio_from", components: 1, type: "Uint16" }, { name: "a_pixel_ratio_to", components: 1, type: "Uint16" }]);
+ var ca = { exports: {} }, ha = { exports: {} };
+ ha.exports = function(t4, e2) {
+ var r2, n2, i2, s2, a2, o2, l2, u2;
+ for (n2 = t4.length - (r2 = 3 & t4.length), i2 = e2, a2 = 3432918353, o2 = 461845907, u2 = 0; u2 < n2; ) l2 = 255 & t4.charCodeAt(u2) | (255 & t4.charCodeAt(++u2)) << 8 | (255 & t4.charCodeAt(++u2)) << 16 | (255 & t4.charCodeAt(++u2)) << 24, ++u2, i2 = 27492 + (65535 & (s2 = 5 * (65535 & (i2 = (i2 ^= l2 = (65535 & (l2 = (l2 = (65535 & l2) * a2 + (((l2 >>> 16) * a2 & 65535) << 16) & 4294967295) << 15 | l2 >>> 17)) * o2 + (((l2 >>> 16) * o2 & 65535) << 16) & 4294967295) << 13 | i2 >>> 19)) + ((5 * (i2 >>> 16) & 65535) << 16) & 4294967295)) + ((58964 + (s2 >>> 16) & 65535) << 16);
+ switch (l2 = 0, r2) {
+ case 3:
+ l2 ^= (255 & t4.charCodeAt(u2 + 2)) << 16;
+ case 2:
+ l2 ^= (255 & t4.charCodeAt(u2 + 1)) << 8;
+ case 1:
+ i2 ^= l2 = (65535 & (l2 = (l2 = (65535 & (l2 ^= 255 & t4.charCodeAt(u2))) * a2 + (((l2 >>> 16) * a2 & 65535) << 16) & 4294967295) << 15 | l2 >>> 17)) * o2 + (((l2 >>> 16) * o2 & 65535) << 16) & 4294967295;
+ }
+ return i2 ^= t4.length, i2 = 2246822507 * (65535 & (i2 ^= i2 >>> 16)) + ((2246822507 * (i2 >>> 16) & 65535) << 16) & 4294967295, i2 = 3266489909 * (65535 & (i2 ^= i2 >>> 13)) + ((3266489909 * (i2 >>> 16) & 65535) << 16) & 4294967295, (i2 ^= i2 >>> 16) >>> 0;
+ };
+ var pa = ha.exports, fa = { exports: {} };
+ fa.exports = function(t4, e2) {
+ for (var r2, n2 = t4.length, i2 = e2 ^ n2, s2 = 0; n2 >= 4; ) r2 = 1540483477 * (65535 & (r2 = 255 & t4.charCodeAt(s2) | (255 & t4.charCodeAt(++s2)) << 8 | (255 & t4.charCodeAt(++s2)) << 16 | (255 & t4.charCodeAt(++s2)) << 24)) + ((1540483477 * (r2 >>> 16) & 65535) << 16), i2 = 1540483477 * (65535 & i2) + ((1540483477 * (i2 >>> 16) & 65535) << 16) ^ (r2 = 1540483477 * (65535 & (r2 ^= r2 >>> 24)) + ((1540483477 * (r2 >>> 16) & 65535) << 16)), n2 -= 4, ++s2;
+ switch (n2) {
+ case 3:
+ i2 ^= (255 & t4.charCodeAt(s2 + 2)) << 16;
+ case 2:
+ i2 ^= (255 & t4.charCodeAt(s2 + 1)) << 8;
+ case 1:
+ i2 = 1540483477 * (65535 & (i2 ^= 255 & t4.charCodeAt(s2))) + ((1540483477 * (i2 >>> 16) & 65535) << 16);
+ }
+ return i2 = 1540483477 * (65535 & (i2 ^= i2 >>> 13)) + ((1540483477 * (i2 >>> 16) & 65535) << 16), (i2 ^= i2 >>> 15) >>> 0;
+ };
+ var da = pa, ya = fa.exports;
+ ca.exports = da, ca.exports.murmur3 = da, ca.exports.murmur2 = ya;
+ var ma = r(ca.exports);
+ class ga {
+ constructor() {
+ this.ids = [], this.positions = [], this.indexed = false;
+ }
+ add(t4, e2, r2, n2) {
+ this.ids.push(xa(t4)), this.positions.push(e2, r2, n2);
+ }
+ getPositions(t4) {
+ if (!this.indexed) throw new Error("Trying to get index, but feature positions are not indexed");
+ const e2 = xa(t4);
+ let r2 = 0, n2 = this.ids.length - 1;
+ for (; r2 < n2; ) {
+ const t5 = r2 + n2 >> 1;
+ this.ids[t5] >= e2 ? n2 = t5 : r2 = t5 + 1;
+ }
+ const i2 = [];
+ for (; this.ids[r2] === e2; ) i2.push({ index: this.positions[3 * r2], start: this.positions[3 * r2 + 1], end: this.positions[3 * r2 + 2] }), r2++;
+ return i2;
+ }
+ static serialize(t4, e2) {
+ const r2 = new Float64Array(t4.ids), n2 = new Uint32Array(t4.positions);
+ return va(r2, n2, 0, r2.length - 1), e2 && e2.push(r2.buffer, n2.buffer), { ids: r2, positions: n2 };
+ }
+ static deserialize(t4) {
+ const e2 = new ga();
+ return e2.ids = t4.ids, e2.positions = t4.positions, e2.indexed = true, e2;
+ }
+ }
+ function xa(t4) {
+ const e2 = +t4;
+ return !isNaN(e2) && e2 <= Number.MAX_SAFE_INTEGER ? e2 : ma(String(t4));
+ }
+ function va(t4, e2, r2, n2) {
+ for (; r2 < n2; ) {
+ const i2 = t4[r2 + n2 >> 1];
+ let s2 = r2 - 1, a2 = n2 + 1;
+ for (; ; ) {
+ do {
+ s2++;
+ } while (t4[s2] < i2);
+ do {
+ a2--;
+ } while (t4[a2] > i2);
+ if (s2 >= a2) break;
+ ba(t4, s2, a2), ba(e2, 3 * s2, 3 * a2), ba(e2, 3 * s2 + 1, 3 * a2 + 1), ba(e2, 3 * s2 + 2, 3 * a2 + 2);
+ }
+ a2 - r2 < n2 - a2 ? (va(t4, e2, r2, a2), r2 = a2 + 1) : (va(t4, e2, a2 + 1, n2), n2 = a2);
+ }
+ }
+ function ba(t4, e2, r2) {
+ const n2 = t4[e2];
+ t4[e2] = t4[r2], t4[r2] = n2;
+ }
+ wi("FeaturePositionMap", ga);
+ class wa {
+ constructor(t4, e2) {
+ this.gl = t4.gl, this.location = e2;
+ }
+ }
+ class _a extends wa {
+ constructor(t4, e2) {
+ super(t4, e2), this.current = 0;
+ }
+ set(t4) {
+ this.current !== t4 && (this.current = t4, this.gl.uniform1f(this.location, t4));
+ }
+ }
+ class Aa extends wa {
+ constructor(t4, e2) {
+ super(t4, e2), this.current = [0, 0, 0, 0];
+ }
+ set(t4) {
+ t4[0] === this.current[0] && t4[1] === this.current[1] && t4[2] === this.current[2] && t4[3] === this.current[3] || (this.current = t4, this.gl.uniform4f(this.location, t4[0], t4[1], t4[2], t4[3]));
+ }
+ }
+ class Sa extends wa {
+ constructor(t4, e2) {
+ super(t4, e2), this.current = Kt.transparent;
+ }
+ set(t4) {
+ t4.r === this.current.r && t4.g === this.current.g && t4.b === this.current.b && t4.a === this.current.a || (this.current = t4, this.gl.uniform4f(this.location, t4.r, t4.g, t4.b, t4.a));
+ }
+ }
+ const ka = new Float32Array(16);
+ function Ma(t4) {
+ return [la(255 * t4.r, 255 * t4.g), la(255 * t4.b, 255 * t4.a)];
+ }
+ class Ia {
+ constructor(t4, e2, r2) {
+ this.value = t4, this.uniformNames = e2.map((t5) => `u_${t5}`), this.type = r2;
+ }
+ setUniform(t4, e2, r2) {
+ t4.set(r2.constantOr(this.value));
+ }
+ getBinding(t4, e2, r2) {
+ return "color" === this.type ? new Sa(t4, e2) : new _a(t4, e2);
+ }
+ }
+ class za {
+ constructor(t4, e2) {
+ this.uniformNames = e2.map((t5) => `u_${t5}`), this.patternFrom = null, this.patternTo = null, this.pixelRatioFrom = 1, this.pixelRatioTo = 1;
+ }
+ setConstantPatternPositions(t4, e2) {
+ this.pixelRatioFrom = e2.pixelRatio, this.pixelRatioTo = t4.pixelRatio, this.patternFrom = e2.tlbr, this.patternTo = t4.tlbr;
+ }
+ setUniform(t4, e2, r2, n2) {
+ const i2 = "u_pattern_to" === n2 ? this.patternTo : "u_pattern_from" === n2 ? this.patternFrom : "u_pixel_ratio_to" === n2 ? this.pixelRatioTo : "u_pixel_ratio_from" === n2 ? this.pixelRatioFrom : null;
+ i2 && t4.set(i2);
+ }
+ getBinding(t4, e2, r2) {
+ return "u_pattern" === r2.substr(0, 9) ? new Aa(t4, e2) : new _a(t4, e2);
+ }
+ }
+ class Pa {
+ constructor(t4, e2, r2, n2) {
+ this.expression = t4, this.type = r2, this.maxValue = 0, this.paintVertexAttributes = e2.map((t5) => ({ name: `a_${t5}`, type: "Float32", components: "color" === r2 ? 2 : 1, offset: 0 })), this.paintVertexArray = new n2();
+ }
+ populatePaintArray(t4, e2, r2, n2, i2) {
+ const s2 = this.paintVertexArray.length, a2 = this.expression.evaluate(new Ui(0), e2, {}, n2, [], i2);
+ this.paintVertexArray.resize(t4), this._setPaintValue(s2, t4, a2);
+ }
+ updatePaintArray(t4, e2, r2, n2) {
+ const i2 = this.expression.evaluate({ zoom: 0 }, r2, n2);
+ this._setPaintValue(t4, e2, i2);
+ }
+ _setPaintValue(t4, e2, r2) {
+ if ("color" === this.type) {
+ const n2 = Ma(r2);
+ for (let r3 = t4; r3 < e2; r3++) this.paintVertexArray.emplace(r3, n2[0], n2[1]);
+ } else {
+ for (let n2 = t4; n2 < e2; n2++) this.paintVertexArray.emplace(n2, r2);
+ this.maxValue = Math.max(this.maxValue, Math.abs(r2));
+ }
+ }
+ upload(t4) {
+ this.paintVertexArray && this.paintVertexArray.arrayBuffer && (this.paintVertexBuffer && this.paintVertexBuffer.buffer ? this.paintVertexBuffer.updateData(this.paintVertexArray) : this.paintVertexBuffer = t4.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent));
+ }
+ destroy() {
+ this.paintVertexBuffer && this.paintVertexBuffer.destroy();
+ }
+ }
+ class Ca {
+ constructor(t4, e2, r2, n2, i2, s2) {
+ this.expression = t4, this.uniformNames = e2.map((t5) => `u_${t5}_t`), this.type = r2, this.useIntegerZoom = n2, this.zoom = i2, this.maxValue = 0, this.paintVertexAttributes = e2.map((t5) => ({ name: `a_${t5}`, type: "Float32", components: "color" === r2 ? 4 : 2, offset: 0 })), this.paintVertexArray = new s2();
+ }
+ populatePaintArray(t4, e2, r2, n2, i2) {
+ const s2 = this.expression.evaluate(new Ui(this.zoom), e2, {}, n2, [], i2), a2 = this.expression.evaluate(new Ui(this.zoom + 1), e2, {}, n2, [], i2), o2 = this.paintVertexArray.length;
+ this.paintVertexArray.resize(t4), this._setPaintValue(o2, t4, s2, a2);
+ }
+ updatePaintArray(t4, e2, r2, n2) {
+ const i2 = this.expression.evaluate({ zoom: this.zoom }, r2, n2), s2 = this.expression.evaluate({ zoom: this.zoom + 1 }, r2, n2);
+ this._setPaintValue(t4, e2, i2, s2);
+ }
+ _setPaintValue(t4, e2, r2, n2) {
+ if ("color" === this.type) {
+ const i2 = Ma(r2), s2 = Ma(n2);
+ for (let r3 = t4; r3 < e2; r3++) this.paintVertexArray.emplace(r3, i2[0], i2[1], s2[0], s2[1]);
+ } else {
+ for (let i2 = t4; i2 < e2; i2++) this.paintVertexArray.emplace(i2, r2, n2);
+ this.maxValue = Math.max(this.maxValue, Math.abs(r2), Math.abs(n2));
+ }
+ }
+ upload(t4) {
+ this.paintVertexArray && this.paintVertexArray.arrayBuffer && (this.paintVertexBuffer && this.paintVertexBuffer.buffer ? this.paintVertexBuffer.updateData(this.paintVertexArray) : this.paintVertexBuffer = t4.createVertexBuffer(this.paintVertexArray, this.paintVertexAttributes, this.expression.isStateDependent));
+ }
+ destroy() {
+ this.paintVertexBuffer && this.paintVertexBuffer.destroy();
+ }
+ setUniform(t4, e2) {
+ const r2 = this.useIntegerZoom ? Math.floor(e2.zoom) : e2.zoom, n2 = y(this.expression.interpolationFactor(r2, this.zoom, this.zoom + 1), 0, 1);
+ t4.set(n2);
+ }
+ getBinding(t4, e2, r2) {
+ return new _a(t4, e2);
+ }
+ }
+ class Ba {
+ constructor(t4, e2, r2, n2, i2, s2) {
+ this.expression = t4, this.type = e2, this.useIntegerZoom = r2, this.zoom = n2, this.layerId = s2, this.zoomInPaintVertexArray = new i2(), this.zoomOutPaintVertexArray = new i2();
+ }
+ populatePaintArray(t4, e2, r2) {
+ const n2 = this.zoomInPaintVertexArray.length;
+ this.zoomInPaintVertexArray.resize(t4), this.zoomOutPaintVertexArray.resize(t4), this._setPaintValues(n2, t4, e2.patterns && e2.patterns[this.layerId], r2);
+ }
+ updatePaintArray(t4, e2, r2, n2, i2) {
+ this._setPaintValues(t4, e2, r2.patterns && r2.patterns[this.layerId], i2);
+ }
+ _setPaintValues(t4, e2, r2, n2) {
+ if (!n2 || !r2) return;
+ const { min: i2, mid: s2, max: a2 } = r2, o2 = n2[i2], l2 = n2[s2], u2 = n2[a2];
+ if (o2 && l2 && u2) for (let r3 = t4; r3 < e2; r3++) this.zoomInPaintVertexArray.emplace(r3, l2.tl[0], l2.tl[1], l2.br[0], l2.br[1], o2.tl[0], o2.tl[1], o2.br[0], o2.br[1], l2.pixelRatio, o2.pixelRatio), this.zoomOutPaintVertexArray.emplace(r3, l2.tl[0], l2.tl[1], l2.br[0], l2.br[1], u2.tl[0], u2.tl[1], u2.br[0], u2.br[1], l2.pixelRatio, u2.pixelRatio);
+ }
+ upload(t4) {
+ this.zoomInPaintVertexArray && this.zoomInPaintVertexArray.arrayBuffer && this.zoomOutPaintVertexArray && this.zoomOutPaintVertexArray.arrayBuffer && (this.zoomInPaintVertexBuffer = t4.createVertexBuffer(this.zoomInPaintVertexArray, ua.members, this.expression.isStateDependent), this.zoomOutPaintVertexBuffer = t4.createVertexBuffer(this.zoomOutPaintVertexArray, ua.members, this.expression.isStateDependent));
+ }
+ destroy() {
+ this.zoomOutPaintVertexBuffer && this.zoomOutPaintVertexBuffer.destroy(), this.zoomInPaintVertexBuffer && this.zoomInPaintVertexBuffer.destroy();
+ }
+ }
+ class Va {
+ constructor(t4, e2, r2) {
+ this.binders = {}, this._buffers = [];
+ const n2 = [];
+ for (const i2 in t4.paint._values) {
+ if (!r2(i2)) continue;
+ const s2 = t4.paint.get(i2);
+ if (!(s2 instanceof Hi && an(s2.property.specification))) continue;
+ const a2 = Fa(i2, t4.type), o2 = s2.value, l2 = s2.property.specification.type, u2 = s2.property.useIntegerZoom, c2 = s2.property.specification["property-type"], h2 = "cross-faded" === c2 || "cross-faded-data-driven" === c2;
+ if ("constant" === o2.kind) this.binders[i2] = h2 ? new za(o2.value, a2) : new Ia(o2.value, a2, l2), n2.push(`/u_${i2}`);
+ else if ("source" === o2.kind || h2) {
+ const r3 = Ta(i2, l2, "source");
+ this.binders[i2] = h2 ? new Ba(o2, l2, u2, e2, r3, t4.id) : new Pa(o2, a2, l2, r3), n2.push(`/a_${i2}`);
+ } else {
+ const t5 = Ta(i2, l2, "composite");
+ this.binders[i2] = new Ca(o2, a2, l2, u2, e2, t5), n2.push(`/z_${i2}`);
+ }
+ }
+ this.cacheKey = n2.sort().join("");
+ }
+ getMaxValue(t4) {
+ const e2 = this.binders[t4];
+ return e2 instanceof Pa || e2 instanceof Ca ? e2.maxValue : 0;
+ }
+ populatePaintArrays(t4, e2, r2, n2, i2) {
+ for (const s2 in this.binders) {
+ const a2 = this.binders[s2];
+ (a2 instanceof Pa || a2 instanceof Ca || a2 instanceof Ba) && a2.populatePaintArray(t4, e2, r2, n2, i2);
+ }
+ }
+ setConstantPatternPositions(t4, e2) {
+ for (const r2 in this.binders) {
+ const n2 = this.binders[r2];
+ n2 instanceof za && n2.setConstantPatternPositions(t4, e2);
+ }
+ }
+ updatePaintArrays(t4, e2, r2, n2, i2) {
+ let s2 = false;
+ for (const a2 in t4) {
+ const o2 = e2.getPositions(a2);
+ for (const e3 of o2) {
+ const o3 = r2.feature(e3.index);
+ for (const r3 in this.binders) {
+ const l2 = this.binders[r3];
+ if ((l2 instanceof Pa || l2 instanceof Ca || l2 instanceof Ba) && true === l2.expression.isStateDependent) {
+ const u2 = n2.paint.get(r3);
+ l2.expression = u2.value, l2.updatePaintArray(e3.start, e3.end, o3, t4[a2], i2), s2 = true;
+ }
+ }
+ }
+ }
+ return s2;
+ }
+ defines() {
+ const t4 = [];
+ for (const e2 in this.binders) {
+ const r2 = this.binders[e2];
+ (r2 instanceof Ia || r2 instanceof za) && t4.push(...r2.uniformNames.map((t5) => `#define HAS_UNIFORM_${t5}`));
+ }
+ return t4;
+ }
+ getBinderAttributes() {
+ const t4 = [];
+ for (const e2 in this.binders) {
+ const r2 = this.binders[e2];
+ if (r2 instanceof Pa || r2 instanceof Ca) for (let e3 = 0; e3 < r2.paintVertexAttributes.length; e3++) t4.push(r2.paintVertexAttributes[e3].name);
+ else if (r2 instanceof Ba) for (let e3 = 0; e3 < ua.members.length; e3++) t4.push(ua.members[e3].name);
+ }
+ return t4;
+ }
+ getBinderUniforms() {
+ const t4 = [];
+ for (const e2 in this.binders) {
+ const r2 = this.binders[e2];
+ if (r2 instanceof Ia || r2 instanceof za || r2 instanceof Ca) for (const e3 of r2.uniformNames) t4.push(e3);
+ }
+ return t4;
+ }
+ getPaintVertexBuffers() {
+ return this._buffers;
+ }
+ getUniforms(t4, e2) {
+ const r2 = [];
+ for (const n2 in this.binders) {
+ const i2 = this.binders[n2];
+ if (i2 instanceof Ia || i2 instanceof za || i2 instanceof Ca) {
+ for (const s2 of i2.uniformNames) if (e2[s2]) {
+ const a2 = i2.getBinding(t4, e2[s2], s2);
+ r2.push({ name: s2, property: n2, binding: a2 });
+ }
+ }
+ }
+ return r2;
+ }
+ setUniforms(t4, e2, r2, n2) {
+ for (const { name: t5, property: i2, binding: s2 } of e2) this.binders[i2].setUniform(s2, n2, r2.get(i2), t5);
+ }
+ updatePaintBuffers(t4) {
+ this._buffers = [];
+ for (const e2 in this.binders) {
+ const r2 = this.binders[e2];
+ if (t4 && r2 instanceof Ba) {
+ const e3 = 2 === t4.fromScale ? r2.zoomInPaintVertexBuffer : r2.zoomOutPaintVertexBuffer;
+ e3 && this._buffers.push(e3);
+ } else (r2 instanceof Pa || r2 instanceof Ca) && r2.paintVertexBuffer && this._buffers.push(r2.paintVertexBuffer);
+ }
+ }
+ upload(t4) {
+ for (const e2 in this.binders) {
+ const r2 = this.binders[e2];
+ (r2 instanceof Pa || r2 instanceof Ca || r2 instanceof Ba) && r2.upload(t4);
+ }
+ this.updatePaintBuffers();
+ }
+ destroy() {
+ for (const t4 in this.binders) {
+ const e2 = this.binders[t4];
+ (e2 instanceof Pa || e2 instanceof Ca || e2 instanceof Ba) && e2.destroy();
+ }
+ }
+ }
+ class Ea {
+ constructor(t4, e2, r2 = () => true) {
+ this.programConfigurations = {};
+ for (const n2 of t4) this.programConfigurations[n2.id] = new Va(n2, e2, r2);
+ this.needsUpload = false, this._featureMap = new ga(), this._bufferOffset = 0;
+ }
+ populatePaintArrays(t4, e2, r2, n2, i2, s2) {
+ for (const r3 in this.programConfigurations) this.programConfigurations[r3].populatePaintArrays(t4, e2, n2, i2, s2);
+ void 0 !== e2.id && this._featureMap.add(e2.id, r2, this._bufferOffset, t4), this._bufferOffset = t4, this.needsUpload = true;
+ }
+ updatePaintArrays(t4, e2, r2, n2) {
+ for (const i2 of r2) this.needsUpload = this.programConfigurations[i2.id].updatePaintArrays(t4, this._featureMap, e2, i2, n2) || this.needsUpload;
+ }
+ get(t4) {
+ return this.programConfigurations[t4];
+ }
+ upload(t4) {
+ if (this.needsUpload) {
+ for (const e2 in this.programConfigurations) this.programConfigurations[e2].upload(t4);
+ this.needsUpload = false;
+ }
+ }
+ destroy() {
+ for (const t4 in this.programConfigurations) this.programConfigurations[t4].destroy();
+ }
+ }
+ function Fa(t4, e2) {
+ return { "text-opacity": ["opacity"], "icon-opacity": ["opacity"], "text-color": ["fill_color"], "icon-color": ["fill_color"], "text-halo-color": ["halo_color"], "icon-halo-color": ["halo_color"], "text-halo-blur": ["halo_blur"], "icon-halo-blur": ["halo_blur"], "text-halo-width": ["halo_width"], "icon-halo-width": ["halo_width"], "line-gap-width": ["gapwidth"], "line-pattern": ["pattern_to", "pattern_from", "pixel_ratio_to", "pixel_ratio_from"], "fill-pattern": ["pattern_to", "pattern_from", "pixel_ratio_to", "pixel_ratio_from"], "fill-extrusion-pattern": ["pattern_to", "pattern_from", "pixel_ratio_to", "pixel_ratio_from"] }[t4] || [t4.replace(`${e2}-`, "").replace(/-/g, "_")];
+ }
+ function Ta(t4, e2, r2) {
+ const n2 = { color: { source: ys, composite: Vs }, number: { source: Is, composite: ys } }, i2 = function(t5) {
+ return { "line-pattern": { source: Js, composite: Js }, "fill-pattern": { source: Js, composite: Js }, "fill-extrusion-pattern": { source: Js, composite: Js } }[t5];
+ }(t4);
+ return i2 && i2[r2] || n2[e2][r2];
+ }
+ wi("ConstantBinder", Ia), wi("CrossFadedConstantBinder", za), wi("SourceExpressionBinder", Pa), wi("CrossFadedCompositeBinder", Ba), wi("CompositeExpressionBinder", Ca), wi("ProgramConfiguration", Va, { omit: ["_buffers"] }), wi("ProgramConfigurationSet", Ea);
+ const $a = 8192, La = Math.pow(2, 14) - 1, Da = -La - 1;
+ function Oa(t4) {
+ const e2 = $a / t4.extent, r2 = t4.loadGeometry();
+ for (let t5 = 0; t5 < r2.length; t5++) {
+ const n2 = r2[t5];
+ for (let t6 = 0; t6 < n2.length; t6++) {
+ const r3 = n2[t6], i2 = Math.round(r3.x * e2), s2 = Math.round(r3.y * e2);
+ r3.x = y(i2, Da, La), r3.y = y(s2, Da, La), (i2 < r3.x || i2 > r3.x + 1 || s2 < r3.y || s2 > r3.y + 1) && A2("Geometry exceeds allowed extent, reduce your vector tile buffer size");
+ }
+ }
+ return r2;
+ }
+ function ja(t4, e2) {
+ return { type: t4.type, id: t4.id, properties: t4.properties, geometry: e2 ? Oa(t4) : [] };
+ }
+ function Ra(t4, e2, r2, n2, i2) {
+ t4.emplaceBack(2 * e2 + (n2 + 1) / 2, 2 * r2 + (i2 + 1) / 2);
+ }
+ class Ua {
+ constructor(t4) {
+ this.zoom = t4.zoom, this.overscaling = t4.overscaling, this.layers = t4.layers, this.layerIds = this.layers.map((t5) => t5.id), this.index = t4.index, this.hasPattern = false, this.layoutVertexArray = new Gs(), this.indexArray = new na(), this.segments = new oa(), this.programConfigurations = new Ea(t4.layers, t4.zoom), this.stateDependentLayerIds = this.layers.filter((t5) => t5.isStateDependent()).map((t5) => t5.id);
+ }
+ populate(t4, e2, r2) {
+ const n2 = this.layers[0], i2 = [];
+ let s2 = null, a2 = false;
+ "circle" === n2.type && (s2 = n2.layout.get("circle-sort-key"), a2 = !s2.isConstant());
+ for (const { feature: e3, id: n3, index: o2, sourceLayerIndex: l2 } of t4) {
+ const t5 = this.layers[0]._featureFilter.needGeometry, u2 = ja(e3, t5);
+ if (!this.layers[0]._featureFilter.filter(new Ui(this.zoom), u2, r2)) continue;
+ const c2 = a2 ? s2.evaluate(u2, {}, r2) : void 0, h2 = { id: n3, properties: e3.properties, type: e3.type, sourceLayerIndex: l2, index: o2, geometry: t5 ? u2.geometry : Oa(e3), patterns: {}, sortKey: c2 };
+ i2.push(h2);
+ }
+ a2 && i2.sort((t5, e3) => t5.sortKey - e3.sortKey);
+ for (const n3 of i2) {
+ const { geometry: i3, index: s3, sourceLayerIndex: a3 } = n3, o2 = t4[s3].feature;
+ this.addFeature(n3, i3, s3, r2), e2.featureIndex.insert(o2, i3, s3, a3, this.index);
+ }
+ }
+ update(t4, e2, r2) {
+ this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t4, e2, this.stateDependentLayers, r2);
+ }
+ isEmpty() {
+ return 0 === this.layoutVertexArray.length;
+ }
+ uploadPending() {
+ return !this.uploaded || this.programConfigurations.needsUpload;
+ }
+ upload(t4) {
+ this.uploaded || (this.layoutVertexBuffer = t4.createVertexBuffer(this.layoutVertexArray, aa), this.indexBuffer = t4.createIndexBuffer(this.indexArray)), this.programConfigurations.upload(t4), this.uploaded = true;
+ }
+ destroy() {
+ this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy());
+ }
+ addFeature(t4, e2, r2, n2) {
+ for (const r3 of e2) for (const e3 of r3) {
+ const r4 = e3.x, n3 = e3.y;
+ if (r4 < 0 || r4 >= $a || n3 < 0 || n3 >= $a) continue;
+ const i2 = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray, t4.sortKey), s2 = i2.vertexLength;
+ Ra(this.layoutVertexArray, r4, n3, -1, -1), Ra(this.layoutVertexArray, r4, n3, 1, -1), Ra(this.layoutVertexArray, r4, n3, 1, 1), Ra(this.layoutVertexArray, r4, n3, -1, 1), this.indexArray.emplaceBack(s2, s2 + 1, s2 + 2), this.indexArray.emplaceBack(s2, s2 + 3, s2 + 2), i2.vertexLength += 4, i2.primitiveLength += 2;
+ }
+ this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t4, r2, {}, n2);
+ }
+ }
+ function qa(t4, e2) {
+ for (let r2 = 0; r2 < t4.length; r2++) if (Wa(e2, t4[r2])) return true;
+ for (let r2 = 0; r2 < e2.length; r2++) if (Wa(t4, e2[r2])) return true;
+ return !!Ka(t4, e2);
+ }
+ function Na(t4, e2, r2) {
+ return !!Wa(t4, e2) || !!Ha(e2, t4, r2);
+ }
+ function Za(t4, e2) {
+ if (1 === t4.length) return Ja(e2, t4[0]);
+ for (let r2 = 0; r2 < e2.length; r2++) {
+ const n2 = e2[r2];
+ for (let e3 = 0; e3 < n2.length; e3++) if (Wa(t4, n2[e3])) return true;
+ }
+ for (let r2 = 0; r2 < t4.length; r2++) if (Ja(e2, t4[r2])) return true;
+ for (let r2 = 0; r2 < e2.length; r2++) if (Ka(t4, e2[r2])) return true;
+ return false;
+ }
+ function Ga(t4, e2, r2) {
+ if (t4.length > 1) {
+ if (Ka(t4, e2)) return true;
+ for (let n2 = 0; n2 < e2.length; n2++) if (Ha(e2[n2], t4, r2)) return true;
+ }
+ for (let n2 = 0; n2 < t4.length; n2++) if (Ha(t4[n2], e2, r2)) return true;
+ return false;
+ }
+ function Ka(t4, e2) {
+ if (0 === t4.length || 0 === e2.length) return false;
+ for (let r2 = 0; r2 < t4.length - 1; r2++) {
+ const n2 = t4[r2], i2 = t4[r2 + 1];
+ for (let t5 = 0; t5 < e2.length - 1; t5++) if (Xa(n2, i2, e2[t5], e2[t5 + 1])) return true;
+ }
+ return false;
+ }
+ function Xa(t4, e2, r2, n2) {
+ return S(t4, r2, n2) !== S(e2, r2, n2) && S(t4, e2, r2) !== S(t4, e2, n2);
+ }
+ function Ha(t4, e2, r2) {
+ const n2 = r2 * r2;
+ if (1 === e2.length) return t4.distSqr(e2[0]) < n2;
+ for (let r3 = 1; r3 < e2.length; r3++) if (Ya(t4, e2[r3 - 1], e2[r3]) < n2) return true;
+ return false;
+ }
+ function Ya(t4, e2, r2) {
+ const n2 = e2.distSqr(r2);
+ if (0 === n2) return t4.distSqr(e2);
+ const i2 = ((t4.x - e2.x) * (r2.x - e2.x) + (t4.y - e2.y) * (r2.y - e2.y)) / n2;
+ return t4.distSqr(i2 < 0 ? e2 : i2 > 1 ? r2 : r2.sub(e2)._mult(i2)._add(e2));
+ }
+ function Ja(t4, e2) {
+ let r2, n2, i2, s2 = false;
+ for (let a2 = 0; a2 < t4.length; a2++) {
+ r2 = t4[a2];
+ for (let t5 = 0, a3 = r2.length - 1; t5 < r2.length; a3 = t5++) n2 = r2[t5], i2 = r2[a3], n2.y > e2.y != i2.y > e2.y && e2.x < (i2.x - n2.x) * (e2.y - n2.y) / (i2.y - n2.y) + n2.x && (s2 = !s2);
+ }
+ return s2;
+ }
+ function Wa(t4, e2) {
+ let r2 = false;
+ for (let n2 = 0, i2 = t4.length - 1; n2 < t4.length; i2 = n2++) {
+ const s2 = t4[n2], a2 = t4[i2];
+ s2.y > e2.y != a2.y > e2.y && e2.x < (a2.x - s2.x) * (e2.y - s2.y) / (a2.y - s2.y) + s2.x && (r2 = !r2);
+ }
+ return r2;
+ }
+ function Qa(t4, e2, r2) {
+ const n2 = r2[0], i2 = r2[2];
+ if (t4.x < n2.x && e2.x < n2.x || t4.x > i2.x && e2.x > i2.x || t4.y < n2.y && e2.y < n2.y || t4.y > i2.y && e2.y > i2.y) return false;
+ const s2 = S(t4, e2, r2[0]);
+ return s2 !== S(t4, e2, r2[1]) || s2 !== S(t4, e2, r2[2]) || s2 !== S(t4, e2, r2[3]);
+ }
+ function to(t4, e2, r2) {
+ const n2 = e2.paint.get(t4).value;
+ return "constant" === n2.kind ? n2.value : r2.programConfigurations.get(e2.id).getMaxValue(t4);
+ }
+ function eo(t4) {
+ return Math.sqrt(t4[0] * t4[0] + t4[1] * t4[1]);
+ }
+ function ro(t4, e2, r2, n2, i2) {
+ if (!e2[0] && !e2[1]) return t4;
+ const a2 = s.convert(e2)._mult(i2);
+ "viewport" === r2 && a2._rotate(-n2);
+ const o2 = [];
+ for (let e3 = 0; e3 < t4.length; e3++) o2.push(t4[e3].sub(a2));
+ return o2;
+ }
+ let no, io;
+ wi("CircleBucket", Ua, { omit: ["layers"] });
+ var so = { get paint() {
+ return io = io || new rs({ "circle-radius": new Wi(G.paint_circle["circle-radius"]), "circle-color": new Wi(G.paint_circle["circle-color"]), "circle-blur": new Wi(G.paint_circle["circle-blur"]), "circle-opacity": new Wi(G.paint_circle["circle-opacity"]), "circle-translate": new Ji(G.paint_circle["circle-translate"]), "circle-translate-anchor": new Ji(G.paint_circle["circle-translate-anchor"]), "circle-pitch-scale": new Ji(G.paint_circle["circle-pitch-scale"]), "circle-pitch-alignment": new Ji(G.paint_circle["circle-pitch-alignment"]), "circle-stroke-width": new Wi(G.paint_circle["circle-stroke-width"]), "circle-stroke-color": new Wi(G.paint_circle["circle-stroke-color"]), "circle-stroke-opacity": new Wi(G.paint_circle["circle-stroke-opacity"]) });
+ }, get layout() {
+ return no = no || new rs({ "circle-sort-key": new Wi(G.layout_circle["circle-sort-key"]) });
+ } }, ao = 1e-6, oo = "undefined" != typeof Float32Array ? Float32Array : Array;
+ function lo(t4) {
+ return t4[0] = 1, t4[1] = 0, t4[2] = 0, t4[3] = 0, t4[4] = 0, t4[5] = 1, t4[6] = 0, t4[7] = 0, t4[8] = 0, t4[9] = 0, t4[10] = 1, t4[11] = 0, t4[12] = 0, t4[13] = 0, t4[14] = 0, t4[15] = 1, t4;
+ }
+ function uo(t4, e2, r2) {
+ var n2 = e2[0], i2 = e2[1], s2 = e2[2], a2 = e2[3], o2 = e2[4], l2 = e2[5], u2 = e2[6], c2 = e2[7], h2 = e2[8], p2 = e2[9], f2 = e2[10], d2 = e2[11], y2 = e2[12], m2 = e2[13], g2 = e2[14], x2 = e2[15], v2 = r2[0], b2 = r2[1], w2 = r2[2], _2 = r2[3];
+ return t4[0] = v2 * n2 + b2 * o2 + w2 * h2 + _2 * y2, t4[1] = v2 * i2 + b2 * l2 + w2 * p2 + _2 * m2, t4[2] = v2 * s2 + b2 * u2 + w2 * f2 + _2 * g2, t4[3] = v2 * a2 + b2 * c2 + w2 * d2 + _2 * x2, t4[4] = (v2 = r2[4]) * n2 + (b2 = r2[5]) * o2 + (w2 = r2[6]) * h2 + (_2 = r2[7]) * y2, t4[5] = v2 * i2 + b2 * l2 + w2 * p2 + _2 * m2, t4[6] = v2 * s2 + b2 * u2 + w2 * f2 + _2 * g2, t4[7] = v2 * a2 + b2 * c2 + w2 * d2 + _2 * x2, t4[8] = (v2 = r2[8]) * n2 + (b2 = r2[9]) * o2 + (w2 = r2[10]) * h2 + (_2 = r2[11]) * y2, t4[9] = v2 * i2 + b2 * l2 + w2 * p2 + _2 * m2, t4[10] = v2 * s2 + b2 * u2 + w2 * f2 + _2 * g2, t4[11] = v2 * a2 + b2 * c2 + w2 * d2 + _2 * x2, t4[12] = (v2 = r2[12]) * n2 + (b2 = r2[13]) * o2 + (w2 = r2[14]) * h2 + (_2 = r2[15]) * y2, t4[13] = v2 * i2 + b2 * l2 + w2 * p2 + _2 * m2, t4[14] = v2 * s2 + b2 * u2 + w2 * f2 + _2 * g2, t4[15] = v2 * a2 + b2 * c2 + w2 * d2 + _2 * x2, t4;
+ }
+ Math.hypot || (Math.hypot = function() {
+ for (var t4 = 0, e2 = arguments.length; e2--; ) t4 += arguments[e2] * arguments[e2];
+ return Math.sqrt(t4);
+ });
+ var co, ho = uo;
+ function po(t4, e2, r2) {
+ var n2 = e2[0], i2 = e2[1], s2 = e2[2], a2 = e2[3];
+ return t4[0] = r2[0] * n2 + r2[4] * i2 + r2[8] * s2 + r2[12] * a2, t4[1] = r2[1] * n2 + r2[5] * i2 + r2[9] * s2 + r2[13] * a2, t4[2] = r2[2] * n2 + r2[6] * i2 + r2[10] * s2 + r2[14] * a2, t4[3] = r2[3] * n2 + r2[7] * i2 + r2[11] * s2 + r2[15] * a2, t4;
+ }
+ co = new oo(4), oo != Float32Array && (co[0] = 0, co[1] = 0, co[2] = 0, co[3] = 0);
+ class fo extends is {
+ constructor(t4) {
+ super(t4, so);
+ }
+ createBucket(t4) {
+ return new Ua(t4);
+ }
+ queryRadius(t4) {
+ const e2 = t4;
+ return to("circle-radius", this, e2) + to("circle-stroke-width", this, e2) + eo(this.paint.get("circle-translate"));
+ }
+ queryIntersectsFeature(t4, e2, r2, n2, i2, s2, a2, o2) {
+ const l2 = ro(t4, this.paint.get("circle-translate"), this.paint.get("circle-translate-anchor"), s2.angle, a2), u2 = this.paint.get("circle-radius").evaluate(e2, r2) + this.paint.get("circle-stroke-width").evaluate(e2, r2), c2 = "map" === this.paint.get("circle-pitch-alignment"), h2 = c2 ? l2 : function(t5, e3) {
+ return t5.map((t6) => yo(t6, e3));
+ }(l2, o2), p2 = c2 ? u2 * a2 : u2;
+ for (const t5 of n2) for (const e3 of t5) {
+ const t6 = c2 ? e3 : yo(e3, o2);
+ let r3 = p2;
+ const n3 = po([], [e3.x, e3.y, 0, 1], o2);
+ if ("viewport" === this.paint.get("circle-pitch-scale") && "map" === this.paint.get("circle-pitch-alignment") ? r3 *= n3[3] / s2.cameraToCenterDistance : "map" === this.paint.get("circle-pitch-scale") && "viewport" === this.paint.get("circle-pitch-alignment") && (r3 *= s2.cameraToCenterDistance / n3[3]), Na(h2, t6, r3)) return true;
+ }
+ return false;
+ }
+ }
+ function yo(t4, e2) {
+ const r2 = po([], [t4.x, t4.y, 0, 1], e2);
+ return new s(r2[0] / r2[3], r2[1] / r2[3]);
+ }
+ class mo extends Ua {
+ }
+ let go;
+ wi("HeatmapBucket", mo, { omit: ["layers"] });
+ var xo = { get paint() {
+ return go = go || new rs({ "heatmap-radius": new Wi(G.paint_heatmap["heatmap-radius"]), "heatmap-weight": new Wi(G.paint_heatmap["heatmap-weight"]), "heatmap-intensity": new Ji(G.paint_heatmap["heatmap-intensity"]), "heatmap-color": new es(G.paint_heatmap["heatmap-color"]), "heatmap-opacity": new Ji(G.paint_heatmap["heatmap-opacity"]) });
+ } };
+ function vo(t4, { width: e2, height: r2 }, n2, i2) {
+ if (i2) {
+ if (i2 instanceof Uint8ClampedArray) i2 = new Uint8Array(i2.buffer);
+ else if (i2.length !== e2 * r2 * n2) throw new RangeError(`mismatched image size. expected: ${i2.length} but got: ${e2 * r2 * n2}`);
+ } else i2 = new Uint8Array(e2 * r2 * n2);
+ return t4.width = e2, t4.height = r2, t4.data = i2, t4;
+ }
+ function bo(t4, { width: e2, height: r2 }, n2) {
+ if (e2 === t4.width && r2 === t4.height) return;
+ const i2 = vo({}, { width: e2, height: r2 }, n2);
+ wo(t4, i2, { x: 0, y: 0 }, { x: 0, y: 0 }, { width: Math.min(t4.width, e2), height: Math.min(t4.height, r2) }, n2), t4.width = e2, t4.height = r2, t4.data = i2.data;
+ }
+ function wo(t4, e2, r2, n2, i2, s2) {
+ if (0 === i2.width || 0 === i2.height) return e2;
+ if (i2.width > t4.width || i2.height > t4.height || r2.x > t4.width - i2.width || r2.y > t4.height - i2.height) throw new RangeError("out of range source coordinates for image copy");
+ if (i2.width > e2.width || i2.height > e2.height || n2.x > e2.width - i2.width || n2.y > e2.height - i2.height) throw new RangeError("out of range destination coordinates for image copy");
+ const a2 = t4.data, o2 = e2.data;
+ if (a2 === o2) throw new Error("srcData equals dstData, so image is already copied");
+ for (let l2 = 0; l2 < i2.height; l2++) {
+ const u2 = ((r2.y + l2) * t4.width + r2.x) * s2, c2 = ((n2.y + l2) * e2.width + n2.x) * s2;
+ for (let t5 = 0; t5 < i2.width * s2; t5++) o2[c2 + t5] = a2[u2 + t5];
+ }
+ return e2;
+ }
+ class _o {
+ constructor(t4, e2) {
+ vo(this, t4, 1, e2);
+ }
+ resize(t4) {
+ bo(this, t4, 1);
+ }
+ clone() {
+ return new _o({ width: this.width, height: this.height }, new Uint8Array(this.data));
+ }
+ static copy(t4, e2, r2, n2, i2) {
+ wo(t4, e2, r2, n2, i2, 1);
+ }
+ }
+ class Ao {
+ constructor(t4, e2) {
+ vo(this, t4, 4, e2);
+ }
+ resize(t4) {
+ bo(this, t4, 4);
+ }
+ replace(t4, e2) {
+ e2 ? this.data.set(t4) : this.data = t4 instanceof Uint8ClampedArray ? new Uint8Array(t4.buffer) : t4;
+ }
+ clone() {
+ return new Ao({ width: this.width, height: this.height }, new Uint8Array(this.data));
+ }
+ static copy(t4, e2, r2, n2, i2) {
+ wo(t4, e2, r2, n2, i2, 4);
+ }
+ }
+ function So(t4) {
+ const e2 = {}, r2 = t4.resolution || 256, n2 = t4.clips ? t4.clips.length : 1, i2 = t4.image || new Ao({ width: r2, height: n2 });
+ if (Math.log(r2) / Math.LN2 % 1 != 0) throw new Error(`width is not a power of 2 - ${r2}`);
+ const s2 = (r3, n3, s3) => {
+ e2[t4.evaluationKey] = s3;
+ const a2 = t4.expression.evaluate(e2);
+ i2.data[r3 + n3 + 0] = Math.floor(255 * a2.r / a2.a), i2.data[r3 + n3 + 1] = Math.floor(255 * a2.g / a2.a), i2.data[r3 + n3 + 2] = Math.floor(255 * a2.b / a2.a), i2.data[r3 + n3 + 3] = Math.floor(255 * a2.a);
+ };
+ if (t4.clips) for (let e3 = 0, i3 = 0; e3 < n2; ++e3, i3 += 4 * r2) for (let n3 = 0, a2 = 0; n3 < r2; n3++, a2 += 4) {
+ const o2 = n3 / (r2 - 1), { start: l2, end: u2 } = t4.clips[e3];
+ s2(i3, a2, l2 * (1 - o2) + u2 * o2);
+ }
+ else for (let t5 = 0, e3 = 0; t5 < r2; t5++, e3 += 4) s2(0, e3, t5 / (r2 - 1));
+ return i2;
+ }
+ wi("AlphaImage", _o), wi("RGBAImage", Ao);
+ const ko = "big-fb";
+ class Mo extends is {
+ createBucket(t4) {
+ return new mo(t4);
+ }
+ constructor(t4) {
+ super(t4, xo), this.heatmapFbos = /* @__PURE__ */ new Map(), this._updateColorRamp();
+ }
+ _handleSpecialPaintPropertyUpdate(t4) {
+ "heatmap-color" === t4 && this._updateColorRamp();
+ }
+ _updateColorRamp() {
+ this.colorRamp = So({ expression: this._transitionablePaint._values["heatmap-color"].value.expression, evaluationKey: "heatmapDensity", image: this.colorRamp }), this.colorRampTexture = null;
+ }
+ resize() {
+ this.heatmapFbos.has(ko) && this.heatmapFbos.delete(ko);
+ }
+ queryRadius() {
+ return 0;
+ }
+ queryIntersectsFeature() {
+ return false;
+ }
+ hasOffscreenPass() {
+ return 0 !== this.paint.get("heatmap-opacity") && "none" !== this.visibility;
+ }
+ }
+ let Io;
+ var zo = { get paint() {
+ return Io = Io || new rs({ "hillshade-illumination-direction": new Ji(G.paint_hillshade["hillshade-illumination-direction"]), "hillshade-illumination-anchor": new Ji(G.paint_hillshade["hillshade-illumination-anchor"]), "hillshade-exaggeration": new Ji(G.paint_hillshade["hillshade-exaggeration"]), "hillshade-shadow-color": new Ji(G.paint_hillshade["hillshade-shadow-color"]), "hillshade-highlight-color": new Ji(G.paint_hillshade["hillshade-highlight-color"]), "hillshade-accent-color": new Ji(G.paint_hillshade["hillshade-accent-color"]) });
+ } };
+ class Po extends is {
+ constructor(t4) {
+ super(t4, zo);
+ }
+ hasOffscreenPass() {
+ return 0 !== this.paint.get("hillshade-exaggeration") && "none" !== this.visibility;
+ }
+ }
+ const Co = ls([{ name: "a_pos", components: 2, type: "Int16" }], 4), { members: Bo } = Co;
+ function Vo(t4, e2, r2 = 2) {
+ const n2 = e2 && e2.length, i2 = n2 ? e2[0] * r2 : t4.length;
+ let s2 = Eo(t4, 0, i2, r2, true);
+ const a2 = [];
+ if (!s2 || s2.next === s2.prev) return a2;
+ let o2, l2, u2;
+ if (n2 && (s2 = function(t5, e3, r3, n3) {
+ const i3 = [];
+ for (let r4 = 0, s3 = e3.length; r4 < s3; r4++) {
+ const a3 = Eo(t5, e3[r4] * n3, r4 < s3 - 1 ? e3[r4 + 1] * n3 : t5.length, n3, false);
+ a3 === a3.next && (a3.steiner = true), i3.push(No(a3));
+ }
+ i3.sort(jo);
+ for (let t6 = 0; t6 < i3.length; t6++) r3 = Ro(i3[t6], r3);
+ return r3;
+ }(t4, e2, s2, r2)), t4.length > 80 * r2) {
+ o2 = 1 / 0, l2 = 1 / 0;
+ let e3 = -1 / 0, n3 = -1 / 0;
+ for (let s3 = r2; s3 < i2; s3 += r2) {
+ const r3 = t4[s3], i3 = t4[s3 + 1];
+ r3 < o2 && (o2 = r3), i3 < l2 && (l2 = i3), r3 > e3 && (e3 = r3), i3 > n3 && (n3 = i3);
+ }
+ u2 = Math.max(e3 - o2, n3 - l2), u2 = 0 !== u2 ? 32767 / u2 : 0;
+ }
+ return To(s2, a2, r2, o2, l2, u2, 0), a2;
+ }
+ function Eo(t4, e2, r2, n2, i2) {
+ let s2;
+ if (i2 === function(t5, e3, r3, n3) {
+ let i3 = 0;
+ for (let s3 = e3, a2 = r3 - n3; s3 < r3; s3 += n3) i3 += (t5[a2] - t5[s3]) * (t5[s3 + 1] + t5[a2 + 1]), a2 = s3;
+ return i3;
+ }(t4, e2, r2, n2) > 0) for (let i3 = e2; i3 < r2; i3 += n2) s2 = tl(i3 / n2 | 0, t4[i3], t4[i3 + 1], s2);
+ else for (let i3 = r2 - n2; i3 >= e2; i3 -= n2) s2 = tl(i3 / n2 | 0, t4[i3], t4[i3 + 1], s2);
+ return s2 && Xo(s2, s2.next) && (el(s2), s2 = s2.next), s2;
+ }
+ function Fo(t4, e2) {
+ if (!t4) return t4;
+ e2 || (e2 = t4);
+ let r2, n2 = t4;
+ do {
+ if (r2 = false, n2.steiner || !Xo(n2, n2.next) && 0 !== Ko(n2.prev, n2, n2.next)) n2 = n2.next;
+ else {
+ if (el(n2), n2 = e2 = n2.prev, n2 === n2.next) break;
+ r2 = true;
+ }
+ } while (r2 || n2 !== e2);
+ return e2;
+ }
+ function To(t4, e2, r2, n2, i2, s2, a2) {
+ if (!t4) return;
+ !a2 && s2 && function(t5, e3, r3, n3) {
+ let i3 = t5;
+ do {
+ 0 === i3.z && (i3.z = qo(i3.x, i3.y, e3, r3, n3)), i3.prevZ = i3.prev, i3.nextZ = i3.next, i3 = i3.next;
+ } while (i3 !== t5);
+ i3.prevZ.nextZ = null, i3.prevZ = null, function(t6) {
+ let e4, r4 = 1;
+ do {
+ let n4, i4 = t6;
+ t6 = null;
+ let s3 = null;
+ for (e4 = 0; i4; ) {
+ e4++;
+ let a3 = i4, o3 = 0;
+ for (let t7 = 0; t7 < r4 && (o3++, a3 = a3.nextZ, a3); t7++) ;
+ let l2 = r4;
+ for (; o3 > 0 || l2 > 0 && a3; ) 0 !== o3 && (0 === l2 || !a3 || i4.z <= a3.z) ? (n4 = i4, i4 = i4.nextZ, o3--) : (n4 = a3, a3 = a3.nextZ, l2--), s3 ? s3.nextZ = n4 : t6 = n4, n4.prevZ = s3, s3 = n4;
+ i4 = a3;
+ }
+ s3.nextZ = null, r4 *= 2;
+ } while (e4 > 1);
+ }(i3);
+ }(t4, n2, i2, s2);
+ let o2 = t4;
+ for (; t4.prev !== t4.next; ) {
+ const l2 = t4.prev, u2 = t4.next;
+ if (s2 ? Lo(t4, n2, i2, s2) : $o(t4)) e2.push(l2.i, t4.i, u2.i), el(t4), t4 = u2.next, o2 = u2.next;
+ else if ((t4 = u2) === o2) {
+ a2 ? 1 === a2 ? To(t4 = Do(Fo(t4), e2), e2, r2, n2, i2, s2, 2) : 2 === a2 && Oo(t4, e2, r2, n2, i2, s2) : To(Fo(t4), e2, r2, n2, i2, s2, 1);
+ break;
+ }
+ }
+ }
+ function $o(t4) {
+ const e2 = t4.prev, r2 = t4, n2 = t4.next;
+ if (Ko(e2, r2, n2) >= 0) return false;
+ const i2 = e2.x, s2 = r2.x, a2 = n2.x, o2 = e2.y, l2 = r2.y, u2 = n2.y, c2 = i2 < s2 ? i2 < a2 ? i2 : a2 : s2 < a2 ? s2 : a2, h2 = o2 < l2 ? o2 < u2 ? o2 : u2 : l2 < u2 ? l2 : u2, p2 = i2 > s2 ? i2 > a2 ? i2 : a2 : s2 > a2 ? s2 : a2, f2 = o2 > l2 ? o2 > u2 ? o2 : u2 : l2 > u2 ? l2 : u2;
+ let d2 = n2.next;
+ for (; d2 !== e2; ) {
+ if (d2.x >= c2 && d2.x <= p2 && d2.y >= h2 && d2.y <= f2 && Zo(i2, o2, s2, l2, a2, u2, d2.x, d2.y) && Ko(d2.prev, d2, d2.next) >= 0) return false;
+ d2 = d2.next;
+ }
+ return true;
+ }
+ function Lo(t4, e2, r2, n2) {
+ const i2 = t4.prev, s2 = t4, a2 = t4.next;
+ if (Ko(i2, s2, a2) >= 0) return false;
+ const o2 = i2.x, l2 = s2.x, u2 = a2.x, c2 = i2.y, h2 = s2.y, p2 = a2.y, f2 = o2 < l2 ? o2 < u2 ? o2 : u2 : l2 < u2 ? l2 : u2, d2 = c2 < h2 ? c2 < p2 ? c2 : p2 : h2 < p2 ? h2 : p2, y2 = o2 > l2 ? o2 > u2 ? o2 : u2 : l2 > u2 ? l2 : u2, m2 = c2 > h2 ? c2 > p2 ? c2 : p2 : h2 > p2 ? h2 : p2, g2 = qo(f2, d2, e2, r2, n2), x2 = qo(y2, m2, e2, r2, n2);
+ let v2 = t4.prevZ, b2 = t4.nextZ;
+ for (; v2 && v2.z >= g2 && b2 && b2.z <= x2; ) {
+ if (v2.x >= f2 && v2.x <= y2 && v2.y >= d2 && v2.y <= m2 && v2 !== i2 && v2 !== a2 && Zo(o2, c2, l2, h2, u2, p2, v2.x, v2.y) && Ko(v2.prev, v2, v2.next) >= 0) return false;
+ if (v2 = v2.prevZ, b2.x >= f2 && b2.x <= y2 && b2.y >= d2 && b2.y <= m2 && b2 !== i2 && b2 !== a2 && Zo(o2, c2, l2, h2, u2, p2, b2.x, b2.y) && Ko(b2.prev, b2, b2.next) >= 0) return false;
+ b2 = b2.nextZ;
+ }
+ for (; v2 && v2.z >= g2; ) {
+ if (v2.x >= f2 && v2.x <= y2 && v2.y >= d2 && v2.y <= m2 && v2 !== i2 && v2 !== a2 && Zo(o2, c2, l2, h2, u2, p2, v2.x, v2.y) && Ko(v2.prev, v2, v2.next) >= 0) return false;
+ v2 = v2.prevZ;
+ }
+ for (; b2 && b2.z <= x2; ) {
+ if (b2.x >= f2 && b2.x <= y2 && b2.y >= d2 && b2.y <= m2 && b2 !== i2 && b2 !== a2 && Zo(o2, c2, l2, h2, u2, p2, b2.x, b2.y) && Ko(b2.prev, b2, b2.next) >= 0) return false;
+ b2 = b2.nextZ;
+ }
+ return true;
+ }
+ function Do(t4, e2) {
+ let r2 = t4;
+ do {
+ const n2 = r2.prev, i2 = r2.next.next;
+ !Xo(n2, i2) && Ho(n2, r2, r2.next, i2) && Wo(n2, i2) && Wo(i2, n2) && (e2.push(n2.i, r2.i, i2.i), el(r2), el(r2.next), r2 = t4 = i2), r2 = r2.next;
+ } while (r2 !== t4);
+ return Fo(r2);
+ }
+ function Oo(t4, e2, r2, n2, i2, s2) {
+ let a2 = t4;
+ do {
+ let t5 = a2.next.next;
+ for (; t5 !== a2.prev; ) {
+ if (a2.i !== t5.i && Go(a2, t5)) {
+ let o2 = Qo(a2, t5);
+ return a2 = Fo(a2, a2.next), o2 = Fo(o2, o2.next), To(a2, e2, r2, n2, i2, s2, 0), void To(o2, e2, r2, n2, i2, s2, 0);
+ }
+ t5 = t5.next;
+ }
+ a2 = a2.next;
+ } while (a2 !== t4);
+ }
+ function jo(t4, e2) {
+ return t4.x - e2.x;
+ }
+ function Ro(t4, e2) {
+ const r2 = function(t5, e3) {
+ let r3 = e3;
+ const n3 = t5.x, i2 = t5.y;
+ let s2, a2 = -1 / 0;
+ do {
+ if (i2 <= r3.y && i2 >= r3.next.y && r3.next.y !== r3.y) {
+ const t6 = r3.x + (i2 - r3.y) * (r3.next.x - r3.x) / (r3.next.y - r3.y);
+ if (t6 <= n3 && t6 > a2 && (a2 = t6, s2 = r3.x < r3.next.x ? r3 : r3.next, t6 === n3)) return s2;
+ }
+ r3 = r3.next;
+ } while (r3 !== e3);
+ if (!s2) return null;
+ const o2 = s2, l2 = s2.x, u2 = s2.y;
+ let c2 = 1 / 0;
+ r3 = s2;
+ do {
+ if (n3 >= r3.x && r3.x >= l2 && n3 !== r3.x && Zo(i2 < u2 ? n3 : a2, i2, l2, u2, i2 < u2 ? a2 : n3, i2, r3.x, r3.y)) {
+ const e4 = Math.abs(i2 - r3.y) / (n3 - r3.x);
+ Wo(r3, t5) && (e4 < c2 || e4 === c2 && (r3.x > s2.x || r3.x === s2.x && Uo(s2, r3))) && (s2 = r3, c2 = e4);
+ }
+ r3 = r3.next;
+ } while (r3 !== o2);
+ return s2;
+ }(t4, e2);
+ if (!r2) return e2;
+ const n2 = Qo(r2, t4);
+ return Fo(n2, n2.next), Fo(r2, r2.next);
+ }
+ function Uo(t4, e2) {
+ return Ko(t4.prev, t4, e2.prev) < 0 && Ko(e2.next, t4, t4.next) < 0;
+ }
+ function qo(t4, e2, r2, n2, i2) {
+ return (t4 = 1431655765 & ((t4 = 858993459 & ((t4 = 252645135 & ((t4 = 16711935 & ((t4 = (t4 - r2) * i2 | 0) | t4 << 8)) | t4 << 4)) | t4 << 2)) | t4 << 1)) | (e2 = 1431655765 & ((e2 = 858993459 & ((e2 = 252645135 & ((e2 = 16711935 & ((e2 = (e2 - n2) * i2 | 0) | e2 << 8)) | e2 << 4)) | e2 << 2)) | e2 << 1)) << 1;
+ }
+ function No(t4) {
+ let e2 = t4, r2 = t4;
+ do {
+ (e2.x < r2.x || e2.x === r2.x && e2.y < r2.y) && (r2 = e2), e2 = e2.next;
+ } while (e2 !== t4);
+ return r2;
+ }
+ function Zo(t4, e2, r2, n2, i2, s2, a2, o2) {
+ return (i2 - a2) * (e2 - o2) >= (t4 - a2) * (s2 - o2) && (t4 - a2) * (n2 - o2) >= (r2 - a2) * (e2 - o2) && (r2 - a2) * (s2 - o2) >= (i2 - a2) * (n2 - o2);
+ }
+ function Go(t4, e2) {
+ return t4.next.i !== e2.i && t4.prev.i !== e2.i && !function(t5, e3) {
+ let r2 = t5;
+ do {
+ if (r2.i !== t5.i && r2.next.i !== t5.i && r2.i !== e3.i && r2.next.i !== e3.i && Ho(r2, r2.next, t5, e3)) return true;
+ r2 = r2.next;
+ } while (r2 !== t5);
+ return false;
+ }(t4, e2) && (Wo(t4, e2) && Wo(e2, t4) && function(t5, e3) {
+ let r2 = t5, n2 = false;
+ const i2 = (t5.x + e3.x) / 2, s2 = (t5.y + e3.y) / 2;
+ do {
+ r2.y > s2 != r2.next.y > s2 && r2.next.y !== r2.y && i2 < (r2.next.x - r2.x) * (s2 - r2.y) / (r2.next.y - r2.y) + r2.x && (n2 = !n2), r2 = r2.next;
+ } while (r2 !== t5);
+ return n2;
+ }(t4, e2) && (Ko(t4.prev, t4, e2.prev) || Ko(t4, e2.prev, e2)) || Xo(t4, e2) && Ko(t4.prev, t4, t4.next) > 0 && Ko(e2.prev, e2, e2.next) > 0);
+ }
+ function Ko(t4, e2, r2) {
+ return (e2.y - t4.y) * (r2.x - e2.x) - (e2.x - t4.x) * (r2.y - e2.y);
+ }
+ function Xo(t4, e2) {
+ return t4.x === e2.x && t4.y === e2.y;
+ }
+ function Ho(t4, e2, r2, n2) {
+ const i2 = Jo(Ko(t4, e2, r2)), s2 = Jo(Ko(t4, e2, n2)), a2 = Jo(Ko(r2, n2, t4)), o2 = Jo(Ko(r2, n2, e2));
+ return i2 !== s2 && a2 !== o2 || !(0 !== i2 || !Yo(t4, r2, e2)) || !(0 !== s2 || !Yo(t4, n2, e2)) || !(0 !== a2 || !Yo(r2, t4, n2)) || !(0 !== o2 || !Yo(r2, e2, n2));
+ }
+ function Yo(t4, e2, r2) {
+ return e2.x <= Math.max(t4.x, r2.x) && e2.x >= Math.min(t4.x, r2.x) && e2.y <= Math.max(t4.y, r2.y) && e2.y >= Math.min(t4.y, r2.y);
+ }
+ function Jo(t4) {
+ return t4 > 0 ? 1 : t4 < 0 ? -1 : 0;
+ }
+ function Wo(t4, e2) {
+ return Ko(t4.prev, t4, t4.next) < 0 ? Ko(t4, e2, t4.next) >= 0 && Ko(t4, t4.prev, e2) >= 0 : Ko(t4, e2, t4.prev) < 0 || Ko(t4, t4.next, e2) < 0;
+ }
+ function Qo(t4, e2) {
+ const r2 = rl(t4.i, t4.x, t4.y), n2 = rl(e2.i, e2.x, e2.y), i2 = t4.next, s2 = e2.prev;
+ return t4.next = e2, e2.prev = t4, r2.next = i2, i2.prev = r2, n2.next = r2, r2.prev = n2, s2.next = n2, n2.prev = s2, n2;
+ }
+ function tl(t4, e2, r2, n2) {
+ const i2 = rl(t4, e2, r2);
+ return n2 ? (i2.next = n2.next, i2.prev = n2, n2.next.prev = i2, n2.next = i2) : (i2.prev = i2, i2.next = i2), i2;
+ }
+ function el(t4) {
+ t4.next.prev = t4.prev, t4.prev.next = t4.next, t4.prevZ && (t4.prevZ.nextZ = t4.nextZ), t4.nextZ && (t4.nextZ.prevZ = t4.prevZ);
+ }
+ function rl(t4, e2, r2) {
+ return { i: t4, x: e2, y: r2, prev: null, next: null, z: 0, prevZ: null, nextZ: null, steiner: false };
+ }
+ function nl(t4, e2, r2) {
+ const n2 = r2.patternDependencies;
+ let i2 = false;
+ for (const r3 of e2) {
+ const e3 = r3.paint.get(`${t4}-pattern`);
+ e3.isConstant() || (i2 = true);
+ const s2 = e3.constantOr(null);
+ s2 && (i2 = true, n2[s2.to] = true, n2[s2.from] = true);
+ }
+ return i2;
+ }
+ function il(t4, e2, r2, n2, i2) {
+ const s2 = i2.patternDependencies;
+ for (const a2 of e2) {
+ const e3 = a2.paint.get(`${t4}-pattern`).value;
+ if ("constant" !== e3.kind) {
+ let t5 = e3.evaluate({ zoom: n2 - 1 }, r2, {}, i2.availableImages), o2 = e3.evaluate({ zoom: n2 }, r2, {}, i2.availableImages), l2 = e3.evaluate({ zoom: n2 + 1 }, r2, {}, i2.availableImages);
+ t5 = t5 && t5.name ? t5.name : t5, o2 = o2 && o2.name ? o2.name : o2, l2 = l2 && l2.name ? l2.name : l2, s2[t5] = true, s2[o2] = true, s2[l2] = true, r2.patterns[a2.id] = { min: t5, mid: o2, max: l2 };
+ }
+ }
+ return r2;
+ }
+ class sl {
+ constructor(t4) {
+ this.zoom = t4.zoom, this.overscaling = t4.overscaling, this.layers = t4.layers, this.layerIds = this.layers.map((t5) => t5.id), this.index = t4.index, this.hasPattern = false, this.patternFeatures = [], this.layoutVertexArray = new Ks(), this.indexArray = new na(), this.indexArray2 = new ia(), this.programConfigurations = new Ea(t4.layers, t4.zoom), this.segments = new oa(), this.segments2 = new oa(), this.stateDependentLayerIds = this.layers.filter((t5) => t5.isStateDependent()).map((t5) => t5.id);
+ }
+ populate(t4, e2, r2) {
+ this.hasPattern = nl("fill", this.layers, e2);
+ const n2 = this.layers[0].layout.get("fill-sort-key"), i2 = !n2.isConstant(), s2 = [];
+ for (const { feature: a2, id: o2, index: l2, sourceLayerIndex: u2 } of t4) {
+ const t5 = this.layers[0]._featureFilter.needGeometry, c2 = ja(a2, t5);
+ if (!this.layers[0]._featureFilter.filter(new Ui(this.zoom), c2, r2)) continue;
+ const h2 = i2 ? n2.evaluate(c2, {}, r2, e2.availableImages) : void 0, p2 = { id: o2, properties: a2.properties, type: a2.type, sourceLayerIndex: u2, index: l2, geometry: t5 ? c2.geometry : Oa(a2), patterns: {}, sortKey: h2 };
+ s2.push(p2);
+ }
+ i2 && s2.sort((t5, e3) => t5.sortKey - e3.sortKey);
+ for (const n3 of s2) {
+ const { geometry: i3, index: s3, sourceLayerIndex: a2 } = n3;
+ if (this.hasPattern) {
+ const t5 = il("fill", this.layers, n3, this.zoom, e2);
+ this.patternFeatures.push(t5);
+ } else this.addFeature(n3, i3, s3, r2, {});
+ e2.featureIndex.insert(t4[s3].feature, i3, s3, a2, this.index);
+ }
+ }
+ update(t4, e2, r2) {
+ this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t4, e2, this.stateDependentLayers, r2);
+ }
+ addFeatures(t4, e2, r2) {
+ for (const t5 of this.patternFeatures) this.addFeature(t5, t5.geometry, t5.index, e2, r2);
+ }
+ isEmpty() {
+ return 0 === this.layoutVertexArray.length;
+ }
+ uploadPending() {
+ return !this.uploaded || this.programConfigurations.needsUpload;
+ }
+ upload(t4) {
+ this.uploaded || (this.layoutVertexBuffer = t4.createVertexBuffer(this.layoutVertexArray, Bo), this.indexBuffer = t4.createIndexBuffer(this.indexArray), this.indexBuffer2 = t4.createIndexBuffer(this.indexArray2)), this.programConfigurations.upload(t4), this.uploaded = true;
+ }
+ destroy() {
+ this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.indexBuffer2.destroy(), this.programConfigurations.destroy(), this.segments.destroy(), this.segments2.destroy());
+ }
+ addFeature(t4, e2, r2, n2, i2) {
+ for (const t5 of xr(e2, 500)) {
+ let e3 = 0;
+ for (const r4 of t5) e3 += r4.length;
+ const r3 = this.segments.prepareSegment(e3, this.layoutVertexArray, this.indexArray), n3 = r3.vertexLength, i3 = [], s2 = [];
+ for (const e4 of t5) {
+ if (0 === e4.length) continue;
+ e4 !== t5[0] && s2.push(i3.length / 2);
+ const r4 = this.segments2.prepareSegment(e4.length, this.layoutVertexArray, this.indexArray2), n4 = r4.vertexLength;
+ this.layoutVertexArray.emplaceBack(e4[0].x, e4[0].y), this.indexArray2.emplaceBack(n4 + e4.length - 1, n4), i3.push(e4[0].x), i3.push(e4[0].y);
+ for (let t6 = 1; t6 < e4.length; t6++) this.layoutVertexArray.emplaceBack(e4[t6].x, e4[t6].y), this.indexArray2.emplaceBack(n4 + t6 - 1, n4 + t6), i3.push(e4[t6].x), i3.push(e4[t6].y);
+ r4.vertexLength += e4.length, r4.primitiveLength += e4.length;
+ }
+ const a2 = Vo(i3, s2);
+ for (let t6 = 0; t6 < a2.length; t6 += 3) this.indexArray.emplaceBack(n3 + a2[t6], n3 + a2[t6 + 1], n3 + a2[t6 + 2]);
+ r3.vertexLength += e3, r3.primitiveLength += a2.length / 3;
+ }
+ this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t4, r2, i2, n2);
+ }
+ }
+ let al, ol;
+ wi("FillBucket", sl, { omit: ["layers", "patternFeatures"] });
+ var ll = { get paint() {
+ return ol = ol || new rs({ "fill-antialias": new Ji(G.paint_fill["fill-antialias"]), "fill-opacity": new Wi(G.paint_fill["fill-opacity"]), "fill-color": new Wi(G.paint_fill["fill-color"]), "fill-outline-color": new Wi(G.paint_fill["fill-outline-color"]), "fill-translate": new Ji(G.paint_fill["fill-translate"]), "fill-translate-anchor": new Ji(G.paint_fill["fill-translate-anchor"]), "fill-pattern": new Qi(G.paint_fill["fill-pattern"]) });
+ }, get layout() {
+ return al = al || new rs({ "fill-sort-key": new Wi(G.layout_fill["fill-sort-key"]) });
+ } };
+ class ul extends is {
+ constructor(t4) {
+ super(t4, ll);
+ }
+ recalculate(t4, e2) {
+ super.recalculate(t4, e2);
+ const r2 = this.paint._values["fill-outline-color"];
+ "constant" === r2.value.kind && void 0 === r2.value.value && (this.paint._values["fill-outline-color"] = this.paint._values["fill-color"]);
+ }
+ createBucket(t4) {
+ return new sl(t4);
+ }
+ queryRadius() {
+ return eo(this.paint.get("fill-translate"));
+ }
+ queryIntersectsFeature(t4, e2, r2, n2, i2, s2, a2) {
+ return Za(ro(t4, this.paint.get("fill-translate"), this.paint.get("fill-translate-anchor"), s2.angle, a2), n2);
+ }
+ isTileClipped() {
+ return true;
+ }
+ }
+ const cl = ls([{ name: "a_pos", components: 2, type: "Int16" }, { name: "a_normal_ed", components: 4, type: "Int16" }], 4), hl = ls([{ name: "a_centroid", components: 2, type: "Int16" }], 4), { members: pl } = cl;
+ var fl = {}, dl = n, yl = ml;
+ function ml(t4, e2, r2, n2, i2) {
+ this.properties = {}, this.extent = r2, this.type = 0, this._pbf = t4, this._geometry = -1, this._keys = n2, this._values = i2, t4.readFields(gl2, this, e2);
+ }
+ function gl2(t4, e2, r2) {
+ 1 == t4 ? e2.id = r2.readVarint() : 2 == t4 ? function(t5, e3) {
+ for (var r3 = t5.readVarint() + t5.pos; t5.pos < r3; ) {
+ var n2 = e3._keys[t5.readVarint()], i2 = e3._values[t5.readVarint()];
+ e3.properties[n2] = i2;
+ }
+ }(r2, e2) : 3 == t4 ? e2.type = r2.readVarint() : 4 == t4 && (e2._geometry = r2.pos);
+ }
+ function xl(t4) {
+ for (var e2, r2, n2 = 0, i2 = 0, s2 = t4.length, a2 = s2 - 1; i2 < s2; a2 = i2++) n2 += ((r2 = t4[a2]).x - (e2 = t4[i2]).x) * (e2.y + r2.y);
+ return n2;
+ }
+ ml.types = ["Unknown", "Point", "LineString", "Polygon"], ml.prototype.loadGeometry = function() {
+ var t4 = this._pbf;
+ t4.pos = this._geometry;
+ for (var e2, r2 = t4.readVarint() + t4.pos, n2 = 1, i2 = 0, s2 = 0, a2 = 0, o2 = []; t4.pos < r2; ) {
+ if (i2 <= 0) {
+ var l2 = t4.readVarint();
+ n2 = 7 & l2, i2 = l2 >> 3;
+ }
+ if (i2--, 1 === n2 || 2 === n2) s2 += t4.readSVarint(), a2 += t4.readSVarint(), 1 === n2 && (e2 && o2.push(e2), e2 = []), e2.push(new dl(s2, a2));
+ else {
+ if (7 !== n2) throw new Error("unknown command " + n2);
+ e2 && e2.push(e2[0].clone());
+ }
+ }
+ return e2 && o2.push(e2), o2;
+ }, ml.prototype.bbox = function() {
+ var t4 = this._pbf;
+ t4.pos = this._geometry;
+ for (var e2 = t4.readVarint() + t4.pos, r2 = 1, n2 = 0, i2 = 0, s2 = 0, a2 = 1 / 0, o2 = -1 / 0, l2 = 1 / 0, u2 = -1 / 0; t4.pos < e2; ) {
+ if (n2 <= 0) {
+ var c2 = t4.readVarint();
+ r2 = 7 & c2, n2 = c2 >> 3;
+ }
+ if (n2--, 1 === r2 || 2 === r2) (i2 += t4.readSVarint()) < a2 && (a2 = i2), i2 > o2 && (o2 = i2), (s2 += t4.readSVarint()) < l2 && (l2 = s2), s2 > u2 && (u2 = s2);
+ else if (7 !== r2) throw new Error("unknown command " + r2);
+ }
+ return [a2, l2, o2, u2];
+ }, ml.prototype.toGeoJSON = function(t4, e2, r2) {
+ var n2, i2, s2 = this.extent * Math.pow(2, r2), a2 = this.extent * t4, o2 = this.extent * e2, l2 = this.loadGeometry(), u2 = ml.types[this.type];
+ function c2(t5) {
+ for (var e3 = 0; e3 < t5.length; e3++) {
+ var r3 = t5[e3];
+ t5[e3] = [360 * (r3.x + a2) / s2 - 180, 360 / Math.PI * Math.atan(Math.exp((180 - 360 * (r3.y + o2) / s2) * Math.PI / 180)) - 90];
+ }
+ }
+ switch (this.type) {
+ case 1:
+ var h2 = [];
+ for (n2 = 0; n2 < l2.length; n2++) h2[n2] = l2[n2][0];
+ c2(l2 = h2);
+ break;
+ case 2:
+ for (n2 = 0; n2 < l2.length; n2++) c2(l2[n2]);
+ break;
+ case 3:
+ for (l2 = function(t5) {
+ var e3 = t5.length;
+ if (e3 <= 1) return [t5];
+ for (var r3, n3, i3 = [], s3 = 0; s3 < e3; s3++) {
+ var a3 = xl(t5[s3]);
+ 0 !== a3 && (void 0 === n3 && (n3 = a3 < 0), n3 === a3 < 0 ? (r3 && i3.push(r3), r3 = [t5[s3]]) : r3.push(t5[s3]));
+ }
+ return r3 && i3.push(r3), i3;
+ }(l2), n2 = 0; n2 < l2.length; n2++) for (i2 = 0; i2 < l2[n2].length; i2++) c2(l2[n2][i2]);
+ }
+ 1 === l2.length ? l2 = l2[0] : u2 = "Multi" + u2;
+ var p2 = { type: "Feature", geometry: { type: u2, coordinates: l2 }, properties: this.properties };
+ return "id" in this && (p2.id = this.id), p2;
+ };
+ var vl = yl, bl = wl;
+ function wl(t4, e2) {
+ this.version = 1, this.name = null, this.extent = 4096, this.length = 0, this._pbf = t4, this._keys = [], this._values = [], this._features = [], t4.readFields(_l, this, e2), this.length = this._features.length;
+ }
+ function _l(t4, e2, r2) {
+ 15 === t4 ? e2.version = r2.readVarint() : 1 === t4 ? e2.name = r2.readString() : 5 === t4 ? e2.extent = r2.readVarint() : 2 === t4 ? e2._features.push(r2.pos) : 3 === t4 ? e2._keys.push(r2.readString()) : 4 === t4 && e2._values.push(function(t5) {
+ for (var e3 = null, r3 = t5.readVarint() + t5.pos; t5.pos < r3; ) {
+ var n2 = t5.readVarint() >> 3;
+ e3 = 1 === n2 ? t5.readString() : 2 === n2 ? t5.readFloat() : 3 === n2 ? t5.readDouble() : 4 === n2 ? t5.readVarint64() : 5 === n2 ? t5.readVarint() : 6 === n2 ? t5.readSVarint() : 7 === n2 ? t5.readBoolean() : null;
+ }
+ return e3;
+ }(r2));
+ }
+ wl.prototype.feature = function(t4) {
+ if (t4 < 0 || t4 >= this._features.length) throw new Error("feature index out of bounds");
+ this._pbf.pos = this._features[t4];
+ var e2 = this._pbf.readVarint() + this._pbf.pos;
+ return new vl(this._pbf, e2, this.extent, this._keys, this._values);
+ };
+ var Al = bl;
+ function Sl(t4, e2, r2) {
+ if (3 === t4) {
+ var n2 = new Al(r2, r2.readVarint() + r2.pos);
+ n2.length && (e2[n2.name] = n2);
+ }
+ }
+ fl.VectorTile = function(t4, e2) {
+ this.layers = t4.readFields(Sl, {}, e2);
+ }, fl.VectorTileFeature = yl, fl.VectorTileLayer = bl;
+ const kl = fl.VectorTileFeature.types, Ml = Math.pow(2, 13);
+ function Il(t4, e2, r2, n2, i2, s2, a2, o2) {
+ t4.emplaceBack(e2, r2, 2 * Math.floor(n2 * Ml) + a2, i2 * Ml * 2, s2 * Ml * 2, Math.round(o2));
+ }
+ class zl {
+ constructor(t4) {
+ this.zoom = t4.zoom, this.overscaling = t4.overscaling, this.layers = t4.layers, this.layerIds = this.layers.map((t5) => t5.id), this.index = t4.index, this.hasPattern = false, this.layoutVertexArray = new Xs(), this.centroidVertexArray = new Zs(), this.indexArray = new na(), this.programConfigurations = new Ea(t4.layers, t4.zoom), this.segments = new oa(), this.stateDependentLayerIds = this.layers.filter((t5) => t5.isStateDependent()).map((t5) => t5.id);
+ }
+ populate(t4, e2, r2) {
+ this.features = [], this.hasPattern = nl("fill-extrusion", this.layers, e2);
+ for (const { feature: n2, id: i2, index: s2, sourceLayerIndex: a2 } of t4) {
+ const t5 = this.layers[0]._featureFilter.needGeometry, o2 = ja(n2, t5);
+ if (!this.layers[0]._featureFilter.filter(new Ui(this.zoom), o2, r2)) continue;
+ const l2 = { id: i2, sourceLayerIndex: a2, index: s2, geometry: t5 ? o2.geometry : Oa(n2), properties: n2.properties, type: n2.type, patterns: {} };
+ this.hasPattern ? this.features.push(il("fill-extrusion", this.layers, l2, this.zoom, e2)) : this.addFeature(l2, l2.geometry, s2, r2, {}), e2.featureIndex.insert(n2, l2.geometry, s2, a2, this.index, true);
+ }
+ }
+ addFeatures(t4, e2, r2) {
+ for (const t5 of this.features) {
+ const { geometry: n2 } = t5;
+ this.addFeature(t5, n2, t5.index, e2, r2);
+ }
+ }
+ update(t4, e2, r2) {
+ this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t4, e2, this.stateDependentLayers, r2);
+ }
+ isEmpty() {
+ return 0 === this.layoutVertexArray.length && 0 === this.centroidVertexArray.length;
+ }
+ uploadPending() {
+ return !this.uploaded || this.programConfigurations.needsUpload;
+ }
+ upload(t4) {
+ this.uploaded || (this.layoutVertexBuffer = t4.createVertexBuffer(this.layoutVertexArray, pl), this.centroidVertexBuffer = t4.createVertexBuffer(this.centroidVertexArray, hl.members, true), this.indexBuffer = t4.createIndexBuffer(this.indexArray)), this.programConfigurations.upload(t4), this.uploaded = true;
+ }
+ destroy() {
+ this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy(), this.centroidVertexBuffer.destroy());
+ }
+ addFeature(t4, e2, r2, n2, i2) {
+ for (const r3 of xr(e2, 500)) {
+ const e3 = { x: 0, y: 0, vertexCount: 0 };
+ let n3 = 0;
+ for (const t5 of r3) n3 += t5.length;
+ let i3 = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);
+ for (const t5 of r3) {
+ if (0 === t5.length) continue;
+ if (Cl(t5)) continue;
+ let r4 = 0;
+ for (let n4 = 0; n4 < t5.length; n4++) {
+ const s3 = t5[n4];
+ if (n4 >= 1) {
+ const a3 = t5[n4 - 1];
+ if (!Pl(s3, a3)) {
+ i3.vertexLength + 4 > oa.MAX_VERTEX_ARRAY_LENGTH && (i3 = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray));
+ const t6 = s3.sub(a3)._perp()._unit(), n5 = a3.dist(s3);
+ r4 + n5 > 32768 && (r4 = 0), Il(this.layoutVertexArray, s3.x, s3.y, t6.x, t6.y, 0, 0, r4), Il(this.layoutVertexArray, s3.x, s3.y, t6.x, t6.y, 0, 1, r4), e3.x += 2 * s3.x, e3.y += 2 * s3.y, e3.vertexCount += 2, r4 += n5, Il(this.layoutVertexArray, a3.x, a3.y, t6.x, t6.y, 0, 0, r4), Il(this.layoutVertexArray, a3.x, a3.y, t6.x, t6.y, 0, 1, r4), e3.x += 2 * a3.x, e3.y += 2 * a3.y, e3.vertexCount += 2;
+ const o3 = i3.vertexLength;
+ this.indexArray.emplaceBack(o3, o3 + 2, o3 + 1), this.indexArray.emplaceBack(o3 + 1, o3 + 2, o3 + 3), i3.vertexLength += 4, i3.primitiveLength += 2;
+ }
+ }
+ }
+ }
+ if (i3.vertexLength + n3 > oa.MAX_VERTEX_ARRAY_LENGTH && (i3 = this.segments.prepareSegment(n3, this.layoutVertexArray, this.indexArray)), "Polygon" !== kl[t4.type]) continue;
+ const s2 = [], a2 = [], o2 = i3.vertexLength;
+ for (const t5 of r3) if (0 !== t5.length) {
+ t5 !== r3[0] && a2.push(s2.length / 2);
+ for (let r4 = 0; r4 < t5.length; r4++) {
+ const n4 = t5[r4];
+ Il(this.layoutVertexArray, n4.x, n4.y, 0, 0, 1, 1, 0), e3.x += n4.x, e3.y += n4.y, e3.vertexCount += 1, s2.push(n4.x), s2.push(n4.y);
+ }
+ }
+ const l2 = Vo(s2, a2);
+ for (let t5 = 0; t5 < l2.length; t5 += 3) this.indexArray.emplaceBack(o2 + l2[t5], o2 + l2[t5 + 2], o2 + l2[t5 + 1]);
+ i3.primitiveLength += l2.length / 3, i3.vertexLength += n3;
+ for (let t5 = 0; t5 < e3.vertexCount; t5++) {
+ const t6 = Math.floor(e3.x / e3.vertexCount), r4 = Math.floor(e3.y / e3.vertexCount);
+ this.centroidVertexArray.emplaceBack(t6, r4);
+ }
+ }
+ this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t4, r2, i2, n2);
+ }
+ }
+ function Pl(t4, e2) {
+ return t4.x === e2.x && (t4.x < 0 || t4.x > $a) || t4.y === e2.y && (t4.y < 0 || t4.y > $a);
+ }
+ function Cl(t4) {
+ return t4.every((t5) => t5.x < 0) || t4.every((t5) => t5.x > $a) || t4.every((t5) => t5.y < 0) || t4.every((t5) => t5.y > $a);
+ }
+ let Bl;
+ wi("FillExtrusionBucket", zl, { omit: ["layers", "features"] });
+ var Vl = { get paint() {
+ return Bl = Bl || new rs({ "fill-extrusion-opacity": new Ji(G["paint_fill-extrusion"]["fill-extrusion-opacity"]), "fill-extrusion-color": new Wi(G["paint_fill-extrusion"]["fill-extrusion-color"]), "fill-extrusion-translate": new Ji(G["paint_fill-extrusion"]["fill-extrusion-translate"]), "fill-extrusion-translate-anchor": new Ji(G["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]), "fill-extrusion-pattern": new Qi(G["paint_fill-extrusion"]["fill-extrusion-pattern"]), "fill-extrusion-height": new Wi(G["paint_fill-extrusion"]["fill-extrusion-height"]), "fill-extrusion-base": new Wi(G["paint_fill-extrusion"]["fill-extrusion-base"]), "fill-extrusion-vertical-gradient": new Ji(G["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]) });
+ } };
+ class El extends is {
+ constructor(t4) {
+ super(t4, Vl);
+ }
+ createBucket(t4) {
+ return new zl(t4);
+ }
+ queryRadius() {
+ return eo(this.paint.get("fill-extrusion-translate"));
+ }
+ is3D() {
+ return true;
+ }
+ queryIntersectsFeature(t4, e2, r2, n2, i2, a2, o2, l2) {
+ const u2 = ro(t4, this.paint.get("fill-extrusion-translate"), this.paint.get("fill-extrusion-translate-anchor"), a2.angle, o2), c2 = this.paint.get("fill-extrusion-height").evaluate(e2, r2), h2 = this.paint.get("fill-extrusion-base").evaluate(e2, r2), p2 = function(t5, e3, r3, n3) {
+ const i3 = [];
+ for (const r4 of t5) {
+ const t6 = [r4.x, r4.y, 0, 1];
+ po(t6, t6, e3), i3.push(new s(t6[0] / t6[3], t6[1] / t6[3]));
+ }
+ return i3;
+ }(u2, l2), f2 = function(t5, e3, r3, n3) {
+ const i3 = [], a3 = [], o3 = n3[8] * e3, l3 = n3[9] * e3, u3 = n3[10] * e3, c3 = n3[11] * e3, h3 = n3[8] * r3, p3 = n3[9] * r3, f3 = n3[10] * r3, d2 = n3[11] * r3;
+ for (const e4 of t5) {
+ const t6 = [], r4 = [];
+ for (const i4 of e4) {
+ const e5 = i4.x, a4 = i4.y, y2 = n3[0] * e5 + n3[4] * a4 + n3[12], m2 = n3[1] * e5 + n3[5] * a4 + n3[13], g2 = n3[2] * e5 + n3[6] * a4 + n3[14], x2 = n3[3] * e5 + n3[7] * a4 + n3[15], v2 = g2 + u3, b2 = x2 + c3, w2 = y2 + h3, _2 = m2 + p3, A3 = g2 + f3, S2 = x2 + d2, k2 = new s((y2 + o3) / b2, (m2 + l3) / b2);
+ k2.z = v2 / b2, t6.push(k2);
+ const M2 = new s(w2 / S2, _2 / S2);
+ M2.z = A3 / S2, r4.push(M2);
+ }
+ i3.push(t6), a3.push(r4);
+ }
+ return [i3, a3];
+ }(n2, h2, c2, l2);
+ return function(t5, e3, r3) {
+ let n3 = 1 / 0;
+ Za(r3, e3) && (n3 = Tl(r3, e3[0]));
+ for (let i3 = 0; i3 < e3.length; i3++) {
+ const s2 = e3[i3], a3 = t5[i3];
+ for (let t6 = 0; t6 < s2.length - 1; t6++) {
+ const e4 = s2[t6], i4 = [e4, s2[t6 + 1], a3[t6 + 1], a3[t6], e4];
+ qa(r3, i4) && (n3 = Math.min(n3, Tl(r3, i4)));
+ }
+ }
+ return n3 !== 1 / 0 && n3;
+ }(f2[0], f2[1], p2);
+ }
+ }
+ function Fl(t4, e2) {
+ return t4.x * e2.x + t4.y * e2.y;
+ }
+ function Tl(t4, e2) {
+ if (1 === t4.length) {
+ let r2 = 0;
+ const n2 = e2[r2++];
+ let i2;
+ for (; !i2 || n2.equals(i2); ) if (i2 = e2[r2++], !i2) return 1 / 0;
+ for (; r2 < e2.length; r2++) {
+ const s2 = e2[r2], a2 = t4[0], o2 = i2.sub(n2), l2 = s2.sub(n2), u2 = a2.sub(n2), c2 = Fl(o2, o2), h2 = Fl(o2, l2), p2 = Fl(l2, l2), f2 = Fl(u2, o2), d2 = Fl(u2, l2), y2 = c2 * p2 - h2 * h2, m2 = (p2 * f2 - h2 * d2) / y2, g2 = (c2 * d2 - h2 * f2) / y2, x2 = n2.z * (1 - m2 - g2) + i2.z * m2 + s2.z * g2;
+ if (isFinite(x2)) return x2;
+ }
+ return 1 / 0;
+ }
+ {
+ let t5 = 1 / 0;
+ for (const r2 of e2) t5 = Math.min(t5, r2.z);
+ return t5;
+ }
+ }
+ const $l = ls([{ name: "a_pos_normal", components: 2, type: "Int16" }, { name: "a_data", components: 4, type: "Uint8" }], 4), { members: Ll } = $l, Dl = ls([{ name: "a_uv_x", components: 1, type: "Float32" }, { name: "a_split_index", components: 1, type: "Float32" }]), { members: Ol } = Dl, jl = fl.VectorTileFeature.types, Rl = Math.cos(Math.PI / 180 * 37.5), Ul = Math.pow(2, 14) / 0.5;
+ class ql {
+ constructor(t4) {
+ this.zoom = t4.zoom, this.overscaling = t4.overscaling, this.layers = t4.layers, this.layerIds = this.layers.map((t5) => t5.id), this.index = t4.index, this.hasPattern = false, this.patternFeatures = [], this.lineClipsArray = [], this.gradients = {}, this.layers.forEach((t5) => {
+ this.gradients[t5.id] = {};
+ }), this.layoutVertexArray = new Hs(), this.layoutVertexArray2 = new Ys(), this.indexArray = new na(), this.programConfigurations = new Ea(t4.layers, t4.zoom), this.segments = new oa(), this.maxLineLength = 0, this.stateDependentLayerIds = this.layers.filter((t5) => t5.isStateDependent()).map((t5) => t5.id);
+ }
+ populate(t4, e2, r2) {
+ this.hasPattern = nl("line", this.layers, e2);
+ const n2 = this.layers[0].layout.get("line-sort-key"), i2 = !n2.isConstant(), s2 = [];
+ for (const { feature: e3, id: a2, index: o2, sourceLayerIndex: l2 } of t4) {
+ const t5 = this.layers[0]._featureFilter.needGeometry, u2 = ja(e3, t5);
+ if (!this.layers[0]._featureFilter.filter(new Ui(this.zoom), u2, r2)) continue;
+ const c2 = i2 ? n2.evaluate(u2, {}, r2) : void 0, h2 = { id: a2, properties: e3.properties, type: e3.type, sourceLayerIndex: l2, index: o2, geometry: t5 ? u2.geometry : Oa(e3), patterns: {}, sortKey: c2 };
+ s2.push(h2);
+ }
+ i2 && s2.sort((t5, e3) => t5.sortKey - e3.sortKey);
+ for (const n3 of s2) {
+ const { geometry: i3, index: s3, sourceLayerIndex: a2 } = n3;
+ if (this.hasPattern) {
+ const t5 = il("line", this.layers, n3, this.zoom, e2);
+ this.patternFeatures.push(t5);
+ } else this.addFeature(n3, i3, s3, r2, {});
+ e2.featureIndex.insert(t4[s3].feature, i3, s3, a2, this.index);
+ }
+ }
+ update(t4, e2, r2) {
+ this.stateDependentLayers.length && this.programConfigurations.updatePaintArrays(t4, e2, this.stateDependentLayers, r2);
+ }
+ addFeatures(t4, e2, r2) {
+ for (const t5 of this.patternFeatures) this.addFeature(t5, t5.geometry, t5.index, e2, r2);
+ }
+ isEmpty() {
+ return 0 === this.layoutVertexArray.length;
+ }
+ uploadPending() {
+ return !this.uploaded || this.programConfigurations.needsUpload;
+ }
+ upload(t4) {
+ this.uploaded || (0 !== this.layoutVertexArray2.length && (this.layoutVertexBuffer2 = t4.createVertexBuffer(this.layoutVertexArray2, Ol)), this.layoutVertexBuffer = t4.createVertexBuffer(this.layoutVertexArray, Ll), this.indexBuffer = t4.createIndexBuffer(this.indexArray)), this.programConfigurations.upload(t4), this.uploaded = true;
+ }
+ destroy() {
+ this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy());
+ }
+ lineFeatureClips(t4) {
+ if (t4.properties && Object.prototype.hasOwnProperty.call(t4.properties, "mapbox_clip_start") && Object.prototype.hasOwnProperty.call(t4.properties, "mapbox_clip_end")) return { start: +t4.properties.mapbox_clip_start, end: +t4.properties.mapbox_clip_end };
+ }
+ addFeature(t4, e2, r2, n2, i2) {
+ const s2 = this.layers[0].layout, a2 = s2.get("line-join").evaluate(t4, {}), o2 = s2.get("line-cap"), l2 = s2.get("line-miter-limit"), u2 = s2.get("line-round-limit");
+ this.lineClips = this.lineFeatureClips(t4);
+ for (const r3 of e2) this.addLine(r3, t4, a2, o2, l2, u2);
+ this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length, t4, r2, i2, n2);
+ }
+ addLine(t4, e2, r2, n2, i2, s2) {
+ if (this.distance = 0, this.scaledDistance = 0, this.totalDistance = 0, this.lineClips) {
+ this.lineClipsArray.push(this.lineClips);
+ for (let e3 = 0; e3 < t4.length - 1; e3++) this.totalDistance += t4[e3].dist(t4[e3 + 1]);
+ this.updateScaledDistance(), this.maxLineLength = Math.max(this.maxLineLength, this.totalDistance);
+ }
+ const a2 = "Polygon" === jl[e2.type];
+ let o2 = t4.length;
+ for (; o2 >= 2 && t4[o2 - 1].equals(t4[o2 - 2]); ) o2--;
+ let l2 = 0;
+ for (; l2 < o2 - 1 && t4[l2].equals(t4[l2 + 1]); ) l2++;
+ if (o2 < (a2 ? 3 : 2)) return;
+ "bevel" === r2 && (i2 = 1.05);
+ const u2 = this.overscaling <= 16 ? 15 * $a / (512 * this.overscaling) : 0, c2 = this.segments.prepareSegment(10 * o2, this.layoutVertexArray, this.indexArray);
+ let h2, p2, f2, d2, y2;
+ this.e1 = this.e2 = -1, a2 && (h2 = t4[o2 - 2], y2 = t4[l2].sub(h2)._unit()._perp());
+ for (let e3 = l2; e3 < o2; e3++) {
+ if (f2 = e3 === o2 - 1 ? a2 ? t4[l2 + 1] : void 0 : t4[e3 + 1], f2 && t4[e3].equals(f2)) continue;
+ y2 && (d2 = y2), h2 && (p2 = h2), h2 = t4[e3], y2 = f2 ? f2.sub(h2)._unit()._perp() : d2, d2 = d2 || y2;
+ let m2 = d2.add(y2);
+ 0 === m2.x && 0 === m2.y || m2._unit();
+ const g2 = d2.x * y2.x + d2.y * y2.y, x2 = m2.x * y2.x + m2.y * y2.y, v2 = 0 !== x2 ? 1 / x2 : 1 / 0, b2 = 2 * Math.sqrt(2 - 2 * x2), w2 = x2 < Rl && p2 && f2, _2 = d2.x * y2.y - d2.y * y2.x > 0;
+ if (w2 && e3 > l2) {
+ const t5 = h2.dist(p2);
+ if (t5 > 2 * u2) {
+ const e4 = h2.sub(h2.sub(p2)._mult(u2 / t5)._round());
+ this.updateDistance(p2, e4), this.addCurrentVertex(e4, d2, 0, 0, c2), p2 = e4;
+ }
+ }
+ const A3 = p2 && f2;
+ let S2 = A3 ? r2 : a2 ? "butt" : n2;
+ if (A3 && "round" === S2 && (v2 < s2 ? S2 = "miter" : v2 <= 2 && (S2 = "fakeround")), "miter" === S2 && v2 > i2 && (S2 = "bevel"), "bevel" === S2 && (v2 > 2 && (S2 = "flipbevel"), v2 < i2 && (S2 = "miter")), p2 && this.updateDistance(p2, h2), "miter" === S2) m2._mult(v2), this.addCurrentVertex(h2, m2, 0, 0, c2);
+ else if ("flipbevel" === S2) {
+ if (v2 > 100) m2 = y2.mult(-1);
+ else {
+ const t5 = v2 * d2.add(y2).mag() / d2.sub(y2).mag();
+ m2._perp()._mult(t5 * (_2 ? -1 : 1));
+ }
+ this.addCurrentVertex(h2, m2, 0, 0, c2), this.addCurrentVertex(h2, m2.mult(-1), 0, 0, c2);
+ } else if ("bevel" === S2 || "fakeround" === S2) {
+ const t5 = -Math.sqrt(v2 * v2 - 1), e4 = _2 ? t5 : 0, r3 = _2 ? 0 : t5;
+ if (p2 && this.addCurrentVertex(h2, d2, e4, r3, c2), "fakeround" === S2) {
+ const t6 = Math.round(180 * b2 / Math.PI / 20);
+ for (let e5 = 1; e5 < t6; e5++) {
+ let r4 = e5 / t6;
+ if (0.5 !== r4) {
+ const t7 = r4 - 0.5;
+ r4 += r4 * t7 * (r4 - 1) * ((1.0904 + g2 * (g2 * (3.55645 - 1.43519 * g2) - 3.2452)) * t7 * t7 + (0.848013 + g2 * (0.215638 * g2 - 1.06021)));
+ }
+ const n3 = y2.sub(d2)._mult(r4)._add(d2)._unit()._mult(_2 ? -1 : 1);
+ this.addHalfVertex(h2, n3.x, n3.y, false, _2, 0, c2);
+ }
+ }
+ f2 && this.addCurrentVertex(h2, y2, -e4, -r3, c2);
+ } else if ("butt" === S2) this.addCurrentVertex(h2, m2, 0, 0, c2);
+ else if ("square" === S2) {
+ const t5 = p2 ? 1 : -1;
+ this.addCurrentVertex(h2, m2, t5, t5, c2);
+ } else "round" === S2 && (p2 && (this.addCurrentVertex(h2, d2, 0, 0, c2), this.addCurrentVertex(h2, d2, 1, 1, c2, true)), f2 && (this.addCurrentVertex(h2, y2, -1, -1, c2, true), this.addCurrentVertex(h2, y2, 0, 0, c2)));
+ if (w2 && e3 < o2 - 1) {
+ const t5 = h2.dist(f2);
+ if (t5 > 2 * u2) {
+ const e4 = h2.add(f2.sub(h2)._mult(u2 / t5)._round());
+ this.updateDistance(h2, e4), this.addCurrentVertex(e4, y2, 0, 0, c2), h2 = e4;
+ }
+ }
+ }
+ }
+ addCurrentVertex(t4, e2, r2, n2, i2, s2 = false) {
+ const a2 = e2.y * n2 - e2.x, o2 = -e2.y - e2.x * n2;
+ this.addHalfVertex(t4, e2.x + e2.y * r2, e2.y - e2.x * r2, s2, false, r2, i2), this.addHalfVertex(t4, a2, o2, s2, true, -n2, i2), this.distance > Ul / 2 && 0 === this.totalDistance && (this.distance = 0, this.updateScaledDistance(), this.addCurrentVertex(t4, e2, r2, n2, i2, s2));
+ }
+ addHalfVertex({ x: t4, y: e2 }, r2, n2, i2, s2, a2, o2) {
+ const l2 = 0.5 * (this.lineClips ? this.scaledDistance * (Ul - 1) : this.scaledDistance);
+ this.layoutVertexArray.emplaceBack((t4 << 1) + (i2 ? 1 : 0), (e2 << 1) + (s2 ? 1 : 0), Math.round(63 * r2) + 128, Math.round(63 * n2) + 128, 1 + (0 === a2 ? 0 : a2 < 0 ? -1 : 1) | (63 & l2) << 2, l2 >> 6), this.lineClips && this.layoutVertexArray2.emplaceBack((this.scaledDistance - this.lineClips.start) / (this.lineClips.end - this.lineClips.start), this.lineClipsArray.length);
+ const u2 = o2.vertexLength++;
+ this.e1 >= 0 && this.e2 >= 0 && (this.indexArray.emplaceBack(this.e1, this.e2, u2), o2.primitiveLength++), s2 ? this.e2 = u2 : this.e1 = u2;
+ }
+ updateScaledDistance() {
+ this.scaledDistance = this.lineClips ? this.lineClips.start + (this.lineClips.end - this.lineClips.start) * this.distance / this.totalDistance : this.distance;
+ }
+ updateDistance(t4, e2) {
+ this.distance += t4.dist(e2), this.updateScaledDistance();
+ }
+ }
+ let Nl, Zl;
+ wi("LineBucket", ql, { omit: ["layers", "patternFeatures"] });
+ var Gl = { get paint() {
+ return Zl = Zl || new rs({ "line-opacity": new Wi(G.paint_line["line-opacity"]), "line-color": new Wi(G.paint_line["line-color"]), "line-translate": new Ji(G.paint_line["line-translate"]), "line-translate-anchor": new Ji(G.paint_line["line-translate-anchor"]), "line-width": new Wi(G.paint_line["line-width"]), "line-gap-width": new Wi(G.paint_line["line-gap-width"]), "line-offset": new Wi(G.paint_line["line-offset"]), "line-blur": new Wi(G.paint_line["line-blur"]), "line-dasharray": new ts(G.paint_line["line-dasharray"]), "line-pattern": new Qi(G.paint_line["line-pattern"]), "line-gradient": new es(G.paint_line["line-gradient"]) });
+ }, get layout() {
+ return Nl = Nl || new rs({ "line-cap": new Ji(G.layout_line["line-cap"]), "line-join": new Wi(G.layout_line["line-join"]), "line-miter-limit": new Ji(G.layout_line["line-miter-limit"]), "line-round-limit": new Ji(G.layout_line["line-round-limit"]), "line-sort-key": new Wi(G.layout_line["line-sort-key"]) });
+ } };
+ class Kl extends Wi {
+ possiblyEvaluate(t4, e2) {
+ return e2 = new Ui(Math.floor(e2.zoom), { now: e2.now, fadeDuration: e2.fadeDuration, zoomHistory: e2.zoomHistory, transition: e2.transition }), super.possiblyEvaluate(t4, e2);
+ }
+ evaluate(t4, e2, r2, n2) {
+ return e2 = g({}, e2, { zoom: Math.floor(e2.zoom) }), super.evaluate(t4, e2, r2, n2);
+ }
+ }
+ let Xl;
+ class Hl extends is {
+ constructor(t4) {
+ super(t4, Gl), this.gradientVersion = 0, Xl || (Xl = new Kl(Gl.paint.properties["line-width"].specification), Xl.useIntegerZoom = true);
+ }
+ _handleSpecialPaintPropertyUpdate(t4) {
+ if ("line-gradient" === t4) {
+ const t5 = this.gradientExpression();
+ this.stepInterpolant = !!function(t6) {
+ return void 0 !== t6._styleExpression;
+ }(t5) && t5._styleExpression.expression instanceof Ae, this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;
+ }
+ }
+ gradientExpression() {
+ return this._transitionablePaint._values["line-gradient"].value.expression;
+ }
+ recalculate(t4, e2) {
+ super.recalculate(t4, e2), this.paint._values["line-floorwidth"] = Xl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value, t4);
+ }
+ createBucket(t4) {
+ return new ql(t4);
+ }
+ queryRadius(t4) {
+ const e2 = t4, r2 = Yl(to("line-width", this, e2), to("line-gap-width", this, e2)), n2 = to("line-offset", this, e2);
+ return r2 / 2 + Math.abs(n2) + eo(this.paint.get("line-translate"));
+ }
+ queryIntersectsFeature(t4, e2, r2, n2, i2, a2, o2) {
+ const l2 = ro(t4, this.paint.get("line-translate"), this.paint.get("line-translate-anchor"), a2.angle, o2), u2 = o2 / 2 * Yl(this.paint.get("line-width").evaluate(e2, r2), this.paint.get("line-gap-width").evaluate(e2, r2)), c2 = this.paint.get("line-offset").evaluate(e2, r2);
+ return c2 && (n2 = function(t5, e3) {
+ const r3 = [];
+ for (let n3 = 0; n3 < t5.length; n3++) {
+ const i3 = t5[n3], a3 = [];
+ for (let t6 = 0; t6 < i3.length; t6++) {
+ const r4 = i3[t6 - 1], n4 = i3[t6], o3 = i3[t6 + 1], l3 = 0 === t6 ? new s(0, 0) : n4.sub(r4)._unit()._perp(), u3 = t6 === i3.length - 1 ? new s(0, 0) : o3.sub(n4)._unit()._perp(), c3 = l3._add(u3)._unit(), h2 = c3.x * u3.x + c3.y * u3.y;
+ 0 !== h2 && c3._mult(1 / h2), a3.push(c3._mult(e3)._add(n4));
+ }
+ r3.push(a3);
+ }
+ return r3;
+ }(n2, c2 * o2)), function(t5, e3, r3) {
+ for (let n3 = 0; n3 < e3.length; n3++) {
+ const i3 = e3[n3];
+ if (t5.length >= 3) {
+ for (let e4 = 0; e4 < i3.length; e4++) if (Wa(t5, i3[e4])) return true;
+ }
+ if (Ga(t5, i3, r3)) return true;
+ }
+ return false;
+ }(l2, n2, u2);
+ }
+ isTileClipped() {
+ return true;
+ }
+ }
+ function Yl(t4, e2) {
+ return e2 > 0 ? e2 + 2 * t4 : t4;
+ }
+ const Jl = ls([{ name: "a_pos_offset", components: 4, type: "Int16" }, { name: "a_data", components: 4, type: "Uint16" }, { name: "a_pixeloffset", components: 4, type: "Int16" }], 4), Wl = ls([{ name: "a_projected_pos", components: 3, type: "Float32" }], 4);
+ ls([{ name: "a_fade_opacity", components: 1, type: "Uint32" }], 4);
+ const Ql = ls([{ name: "a_placed", components: 2, type: "Uint8" }, { name: "a_shift", components: 2, type: "Float32" }, { name: "a_box_real", components: 2, type: "Int16" }]);
+ ls([{ type: "Int16", name: "anchorPointX" }, { type: "Int16", name: "anchorPointY" }, { type: "Int16", name: "x1" }, { type: "Int16", name: "y1" }, { type: "Int16", name: "x2" }, { type: "Int16", name: "y2" }, { type: "Uint32", name: "featureIndex" }, { type: "Uint16", name: "sourceLayerIndex" }, { type: "Uint16", name: "bucketIndex" }]);
+ const tu = ls([{ name: "a_pos", components: 2, type: "Int16" }, { name: "a_anchor_pos", components: 2, type: "Int16" }, { name: "a_extrude", components: 2, type: "Int16" }], 4), eu = ls([{ name: "a_pos", components: 2, type: "Float32" }, { name: "a_radius", components: 1, type: "Float32" }, { name: "a_flags", components: 2, type: "Int16" }], 4);
+ function ru(t4, e2, r2) {
+ return t4.sections.forEach((t5) => {
+ t5.text = function(t6, e3, r3) {
+ const n2 = e3.layout.get("text-transform").evaluate(r3, {});
+ return "uppercase" === n2 ? t6 = t6.toLocaleUpperCase() : "lowercase" === n2 && (t6 = t6.toLocaleLowerCase()), Ri.applyArabicShaping && (t6 = Ri.applyArabicShaping(t6)), t6;
+ }(t5.text, e2, r2);
+ }), t4;
+ }
+ ls([{ name: "triangle", components: 3, type: "Uint16" }]), ls([{ type: "Int16", name: "anchorX" }, { type: "Int16", name: "anchorY" }, { type: "Uint16", name: "glyphStartIndex" }, { type: "Uint16", name: "numGlyphs" }, { type: "Uint32", name: "vertexStartIndex" }, { type: "Uint32", name: "lineStartIndex" }, { type: "Uint32", name: "lineLength" }, { type: "Uint16", name: "segment" }, { type: "Uint16", name: "lowerSize" }, { type: "Uint16", name: "upperSize" }, { type: "Float32", name: "lineOffsetX" }, { type: "Float32", name: "lineOffsetY" }, { type: "Uint8", name: "writingMode" }, { type: "Uint8", name: "placedOrientation" }, { type: "Uint8", name: "hidden" }, { type: "Uint32", name: "crossTileID" }, { type: "Int16", name: "associatedIconIndex" }]), ls([{ type: "Int16", name: "anchorX" }, { type: "Int16", name: "anchorY" }, { type: "Int16", name: "rightJustifiedTextSymbolIndex" }, { type: "Int16", name: "centerJustifiedTextSymbolIndex" }, { type: "Int16", name: "leftJustifiedTextSymbolIndex" }, { type: "Int16", name: "verticalPlacedTextSymbolIndex" }, { type: "Int16", name: "placedIconSymbolIndex" }, { type: "Int16", name: "verticalPlacedIconSymbolIndex" }, { type: "Uint16", name: "key" }, { type: "Uint16", name: "textBoxStartIndex" }, { type: "Uint16", name: "textBoxEndIndex" }, { type: "Uint16", name: "verticalTextBoxStartIndex" }, { type: "Uint16", name: "verticalTextBoxEndIndex" }, { type: "Uint16", name: "iconBoxStartIndex" }, { type: "Uint16", name: "iconBoxEndIndex" }, { type: "Uint16", name: "verticalIconBoxStartIndex" }, { type: "Uint16", name: "verticalIconBoxEndIndex" }, { type: "Uint16", name: "featureIndex" }, { type: "Uint16", name: "numHorizontalGlyphVertices" }, { type: "Uint16", name: "numVerticalGlyphVertices" }, { type: "Uint16", name: "numIconVertices" }, { type: "Uint16", name: "numVerticalIconVertices" }, { type: "Uint16", name: "useRuntimeCollisionCircles" }, { type: "Uint32", name: "crossTileID" }, { type: "Float32", name: "textBoxScale" }, { type: "Float32", name: "collisionCircleDiameter" }, { type: "Uint16", name: "textAnchorOffsetStartIndex" }, { type: "Uint16", name: "textAnchorOffsetEndIndex" }]), ls([{ type: "Float32", name: "offsetX" }]), ls([{ type: "Int16", name: "x" }, { type: "Int16", name: "y" }, { type: "Int16", name: "tileUnitDistanceFromAnchor" }]), ls([{ type: "Uint16", name: "textAnchor" }, { type: "Float32", components: 2, name: "textOffset" }]);
+ const nu = { "!": "\uFE15", "#": "\uFF03", $: "\uFF04", "%": "\uFF05", "&": "\uFF06", "(": "\uFE35", ")": "\uFE36", "*": "\uFF0A", "+": "\uFF0B", ",": "\uFE10", "-": "\uFE32", ".": "\u30FB", "/": "\uFF0F", ":": "\uFE13", ";": "\uFE14", "<": "\uFE3F", "=": "\uFF1D", ">": "\uFE40", "?": "\uFE16", "@": "\uFF20", "[": "\uFE47", "\\": "\uFF3C", "]": "\uFE48", "^": "\uFF3E", _: "\uFE33", "`": "\uFF40", "{": "\uFE37", "|": "\u2015", "}": "\uFE38", "~": "\uFF5E", "\xA2": "\uFFE0", "\xA3": "\uFFE1", "\xA5": "\uFFE5", "\xA6": "\uFFE4", "\xAC": "\uFFE2", "\xAF": "\uFFE3", "\u2013": "\uFE32", "\u2014": "\uFE31", "\u2018": "\uFE43", "\u2019": "\uFE44", "\u201C": "\uFE41", "\u201D": "\uFE42", "\u2026": "\uFE19", "\u2027": "\u30FB", "\u20A9": "\uFFE6", "\u3001": "\uFE11", "\u3002": "\uFE12", "\u3008": "\uFE3F", "\u3009": "\uFE40", "\u300A": "\uFE3D", "\u300B": "\uFE3E", "\u300C": "\uFE41", "\u300D": "\uFE42", "\u300E": "\uFE43", "\u300F": "\uFE44", "\u3010": "\uFE3B", "\u3011": "\uFE3C", "\u3014": "\uFE39", "\u3015": "\uFE3A", "\u3016": "\uFE17", "\u3017": "\uFE18", "\uFF01": "\uFE15", "\uFF08": "\uFE35", "\uFF09": "\uFE36", "\uFF0C": "\uFE10", "\uFF0D": "\uFE32", "\uFF0E": "\u30FB", "\uFF1A": "\uFE13", "\uFF1B": "\uFE14", "\uFF1C": "\uFE3F", "\uFF1E": "\uFE40", "\uFF1F": "\uFE16", "\uFF3B": "\uFE47", "\uFF3D": "\uFE48", "\uFF3F": "\uFE33", "\uFF5B": "\uFE37", "\uFF5C": "\u2015", "\uFF5D": "\uFE38", "\uFF5F": "\uFE35", "\uFF60": "\uFE36", "\uFF61": "\uFE12", "\uFF62": "\uFE41", "\uFF63": "\uFE42" };
+ var iu = 24, su = lu, au = function(t4, e2, r2, n2, i2) {
+ var s2, a2, o2 = 8 * i2 - n2 - 1, l2 = (1 << o2) - 1, u2 = l2 >> 1, c2 = -7, h2 = r2 ? i2 - 1 : 0, p2 = r2 ? -1 : 1, f2 = t4[e2 + h2];
+ for (h2 += p2, s2 = f2 & (1 << -c2) - 1, f2 >>= -c2, c2 += o2; c2 > 0; s2 = 256 * s2 + t4[e2 + h2], h2 += p2, c2 -= 8) ;
+ for (a2 = s2 & (1 << -c2) - 1, s2 >>= -c2, c2 += n2; c2 > 0; a2 = 256 * a2 + t4[e2 + h2], h2 += p2, c2 -= 8) ;
+ if (0 === s2) s2 = 1 - u2;
+ else {
+ if (s2 === l2) return a2 ? NaN : 1 / 0 * (f2 ? -1 : 1);
+ a2 += Math.pow(2, n2), s2 -= u2;
+ }
+ return (f2 ? -1 : 1) * a2 * Math.pow(2, s2 - n2);
+ }, ou = function(t4, e2, r2, n2, i2, s2) {
+ var a2, o2, l2, u2 = 8 * s2 - i2 - 1, c2 = (1 << u2) - 1, h2 = c2 >> 1, p2 = 23 === i2 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, f2 = n2 ? 0 : s2 - 1, d2 = n2 ? 1 : -1, y2 = e2 < 0 || 0 === e2 && 1 / e2 < 0 ? 1 : 0;
+ for (e2 = Math.abs(e2), isNaN(e2) || e2 === 1 / 0 ? (o2 = isNaN(e2) ? 1 : 0, a2 = c2) : (a2 = Math.floor(Math.log(e2) / Math.LN2), e2 * (l2 = Math.pow(2, -a2)) < 1 && (a2--, l2 *= 2), (e2 += a2 + h2 >= 1 ? p2 / l2 : p2 * Math.pow(2, 1 - h2)) * l2 >= 2 && (a2++, l2 /= 2), a2 + h2 >= c2 ? (o2 = 0, a2 = c2) : a2 + h2 >= 1 ? (o2 = (e2 * l2 - 1) * Math.pow(2, i2), a2 += h2) : (o2 = e2 * Math.pow(2, h2 - 1) * Math.pow(2, i2), a2 = 0)); i2 >= 8; t4[r2 + f2] = 255 & o2, f2 += d2, o2 /= 256, i2 -= 8) ;
+ for (a2 = a2 << i2 | o2, u2 += i2; u2 > 0; t4[r2 + f2] = 255 & a2, f2 += d2, a2 /= 256, u2 -= 8) ;
+ t4[r2 + f2 - d2] |= 128 * y2;
+ };
+ function lu(t4) {
+ this.buf = ArrayBuffer.isView && ArrayBuffer.isView(t4) ? t4 : new Uint8Array(t4 || 0), this.pos = 0, this.type = 0, this.length = this.buf.length;
+ }
+ lu.Varint = 0, lu.Fixed64 = 1, lu.Bytes = 2, lu.Fixed32 = 5;
+ var uu = 4294967296, cu = 1 / uu, hu = "undefined" == typeof TextDecoder ? null : new TextDecoder("utf-8");
+ function pu(t4) {
+ return t4.type === lu.Bytes ? t4.readVarint() + t4.pos : t4.pos + 1;
+ }
+ function fu(t4, e2, r2) {
+ return r2 ? 4294967296 * e2 + (t4 >>> 0) : 4294967296 * (e2 >>> 0) + (t4 >>> 0);
+ }
+ function du(t4, e2, r2) {
+ var n2 = e2 <= 16383 ? 1 : e2 <= 2097151 ? 2 : e2 <= 268435455 ? 3 : Math.floor(Math.log(e2) / (7 * Math.LN2));
+ r2.realloc(n2);
+ for (var i2 = r2.pos - 1; i2 >= t4; i2--) r2.buf[i2 + n2] = r2.buf[i2];
+ }
+ function yu(t4, e2) {
+ for (var r2 = 0; r2 < t4.length; r2++) e2.writeVarint(t4[r2]);
+ }
+ function mu(t4, e2) {
+ for (var r2 = 0; r2 < t4.length; r2++) e2.writeSVarint(t4[r2]);
+ }
+ function gu(t4, e2) {
+ for (var r2 = 0; r2 < t4.length; r2++) e2.writeFloat(t4[r2]);
+ }
+ function xu(t4, e2) {
+ for (var r2 = 0; r2 < t4.length; r2++) e2.writeDouble(t4[r2]);
+ }
+ function vu(t4, e2) {
+ for (var r2 = 0; r2 < t4.length; r2++) e2.writeBoolean(t4[r2]);
+ }
+ function bu(t4, e2) {
+ for (var r2 = 0; r2 < t4.length; r2++) e2.writeFixed32(t4[r2]);
+ }
+ function wu(t4, e2) {
+ for (var r2 = 0; r2 < t4.length; r2++) e2.writeSFixed32(t4[r2]);
+ }
+ function _u(t4, e2) {
+ for (var r2 = 0; r2 < t4.length; r2++) e2.writeFixed64(t4[r2]);
+ }
+ function Au(t4, e2) {
+ for (var r2 = 0; r2 < t4.length; r2++) e2.writeSFixed64(t4[r2]);
+ }
+ function Su(t4, e2) {
+ return (t4[e2] | t4[e2 + 1] << 8 | t4[e2 + 2] << 16) + 16777216 * t4[e2 + 3];
+ }
+ function ku(t4, e2, r2) {
+ t4[r2] = e2, t4[r2 + 1] = e2 >>> 8, t4[r2 + 2] = e2 >>> 16, t4[r2 + 3] = e2 >>> 24;
+ }
+ function Mu(t4, e2) {
+ return (t4[e2] | t4[e2 + 1] << 8 | t4[e2 + 2] << 16) + (t4[e2 + 3] << 24);
+ }
+ lu.prototype = { destroy: function() {
+ this.buf = null;
+ }, readFields: function(t4, e2, r2) {
+ for (r2 = r2 || this.length; this.pos < r2; ) {
+ var n2 = this.readVarint(), i2 = n2 >> 3, s2 = this.pos;
+ this.type = 7 & n2, t4(i2, e2, this), this.pos === s2 && this.skip(n2);
+ }
+ return e2;
+ }, readMessage: function(t4, e2) {
+ return this.readFields(t4, e2, this.readVarint() + this.pos);
+ }, readFixed32: function() {
+ var t4 = Su(this.buf, this.pos);
+ return this.pos += 4, t4;
+ }, readSFixed32: function() {
+ var t4 = Mu(this.buf, this.pos);
+ return this.pos += 4, t4;
+ }, readFixed64: function() {
+ var t4 = Su(this.buf, this.pos) + Su(this.buf, this.pos + 4) * uu;
+ return this.pos += 8, t4;
+ }, readSFixed64: function() {
+ var t4 = Su(this.buf, this.pos) + Mu(this.buf, this.pos + 4) * uu;
+ return this.pos += 8, t4;
+ }, readFloat: function() {
+ var t4 = au(this.buf, this.pos, true, 23, 4);
+ return this.pos += 4, t4;
+ }, readDouble: function() {
+ var t4 = au(this.buf, this.pos, true, 52, 8);
+ return this.pos += 8, t4;
+ }, readVarint: function(t4) {
+ var e2, r2, n2 = this.buf;
+ return e2 = 127 & (r2 = n2[this.pos++]), r2 < 128 ? e2 : (e2 |= (127 & (r2 = n2[this.pos++])) << 7, r2 < 128 ? e2 : (e2 |= (127 & (r2 = n2[this.pos++])) << 14, r2 < 128 ? e2 : (e2 |= (127 & (r2 = n2[this.pos++])) << 21, r2 < 128 ? e2 : function(t5, e3, r3) {
+ var n3, i2, s2 = r3.buf;
+ if (n3 = (112 & (i2 = s2[r3.pos++])) >> 4, i2 < 128) return fu(t5, n3, e3);
+ if (n3 |= (127 & (i2 = s2[r3.pos++])) << 3, i2 < 128) return fu(t5, n3, e3);
+ if (n3 |= (127 & (i2 = s2[r3.pos++])) << 10, i2 < 128) return fu(t5, n3, e3);
+ if (n3 |= (127 & (i2 = s2[r3.pos++])) << 17, i2 < 128) return fu(t5, n3, e3);
+ if (n3 |= (127 & (i2 = s2[r3.pos++])) << 24, i2 < 128) return fu(t5, n3, e3);
+ if (n3 |= (1 & (i2 = s2[r3.pos++])) << 31, i2 < 128) return fu(t5, n3, e3);
+ throw new Error("Expected varint not more than 10 bytes");
+ }(e2 |= (15 & (r2 = n2[this.pos])) << 28, t4, this))));
+ }, readVarint64: function() {
+ return this.readVarint(true);
+ }, readSVarint: function() {
+ var t4 = this.readVarint();
+ return t4 % 2 == 1 ? (t4 + 1) / -2 : t4 / 2;
+ }, readBoolean: function() {
+ return Boolean(this.readVarint());
+ }, readString: function() {
+ var t4 = this.readVarint() + this.pos, e2 = this.pos;
+ return this.pos = t4, t4 - e2 >= 12 && hu ? function(t5, e3, r2) {
+ return hu.decode(t5.subarray(e3, r2));
+ }(this.buf, e2, t4) : function(t5, e3, r2) {
+ for (var n2 = "", i2 = e3; i2 < r2; ) {
+ var s2, a2, o2, l2 = t5[i2], u2 = null, c2 = l2 > 239 ? 4 : l2 > 223 ? 3 : l2 > 191 ? 2 : 1;
+ if (i2 + c2 > r2) break;
+ 1 === c2 ? l2 < 128 && (u2 = l2) : 2 === c2 ? 128 == (192 & (s2 = t5[i2 + 1])) && (u2 = (31 & l2) << 6 | 63 & s2) <= 127 && (u2 = null) : 3 === c2 ? (a2 = t5[i2 + 2], 128 == (192 & (s2 = t5[i2 + 1])) && 128 == (192 & a2) && ((u2 = (15 & l2) << 12 | (63 & s2) << 6 | 63 & a2) <= 2047 || u2 >= 55296 && u2 <= 57343) && (u2 = null)) : 4 === c2 && (a2 = t5[i2 + 2], o2 = t5[i2 + 3], 128 == (192 & (s2 = t5[i2 + 1])) && 128 == (192 & a2) && 128 == (192 & o2) && ((u2 = (15 & l2) << 18 | (63 & s2) << 12 | (63 & a2) << 6 | 63 & o2) <= 65535 || u2 >= 1114112) && (u2 = null)), null === u2 ? (u2 = 65533, c2 = 1) : u2 > 65535 && (u2 -= 65536, n2 += String.fromCharCode(u2 >>> 10 & 1023 | 55296), u2 = 56320 | 1023 & u2), n2 += String.fromCharCode(u2), i2 += c2;
+ }
+ return n2;
+ }(this.buf, e2, t4);
+ }, readBytes: function() {
+ var t4 = this.readVarint() + this.pos, e2 = this.buf.subarray(this.pos, t4);
+ return this.pos = t4, e2;
+ }, readPackedVarint: function(t4, e2) {
+ if (this.type !== lu.Bytes) return t4.push(this.readVarint(e2));
+ var r2 = pu(this);
+ for (t4 = t4 || []; this.pos < r2; ) t4.push(this.readVarint(e2));
+ return t4;
+ }, readPackedSVarint: function(t4) {
+ if (this.type !== lu.Bytes) return t4.push(this.readSVarint());
+ var e2 = pu(this);
+ for (t4 = t4 || []; this.pos < e2; ) t4.push(this.readSVarint());
+ return t4;
+ }, readPackedBoolean: function(t4) {
+ if (this.type !== lu.Bytes) return t4.push(this.readBoolean());
+ var e2 = pu(this);
+ for (t4 = t4 || []; this.pos < e2; ) t4.push(this.readBoolean());
+ return t4;
+ }, readPackedFloat: function(t4) {
+ if (this.type !== lu.Bytes) return t4.push(this.readFloat());
+ var e2 = pu(this);
+ for (t4 = t4 || []; this.pos < e2; ) t4.push(this.readFloat());
+ return t4;
+ }, readPackedDouble: function(t4) {
+ if (this.type !== lu.Bytes) return t4.push(this.readDouble());
+ var e2 = pu(this);
+ for (t4 = t4 || []; this.pos < e2; ) t4.push(this.readDouble());
+ return t4;
+ }, readPackedFixed32: function(t4) {
+ if (this.type !== lu.Bytes) return t4.push(this.readFixed32());
+ var e2 = pu(this);
+ for (t4 = t4 || []; this.pos < e2; ) t4.push(this.readFixed32());
+ return t4;
+ }, readPackedSFixed32: function(t4) {
+ if (this.type !== lu.Bytes) return t4.push(this.readSFixed32());
+ var e2 = pu(this);
+ for (t4 = t4 || []; this.pos < e2; ) t4.push(this.readSFixed32());
+ return t4;
+ }, readPackedFixed64: function(t4) {
+ if (this.type !== lu.Bytes) return t4.push(this.readFixed64());
+ var e2 = pu(this);
+ for (t4 = t4 || []; this.pos < e2; ) t4.push(this.readFixed64());
+ return t4;
+ }, readPackedSFixed64: function(t4) {
+ if (this.type !== lu.Bytes) return t4.push(this.readSFixed64());
+ var e2 = pu(this);
+ for (t4 = t4 || []; this.pos < e2; ) t4.push(this.readSFixed64());
+ return t4;
+ }, skip: function(t4) {
+ var e2 = 7 & t4;
+ if (e2 === lu.Varint) for (; this.buf[this.pos++] > 127; ) ;
+ else if (e2 === lu.Bytes) this.pos = this.readVarint() + this.pos;
+ else if (e2 === lu.Fixed32) this.pos += 4;
+ else {
+ if (e2 !== lu.Fixed64) throw new Error("Unimplemented type: " + e2);
+ this.pos += 8;
+ }
+ }, writeTag: function(t4, e2) {
+ this.writeVarint(t4 << 3 | e2);
+ }, realloc: function(t4) {
+ for (var e2 = this.length || 16; e2 < this.pos + t4; ) e2 *= 2;
+ if (e2 !== this.length) {
+ var r2 = new Uint8Array(e2);
+ r2.set(this.buf), this.buf = r2, this.length = e2;
+ }
+ }, finish: function() {
+ return this.length = this.pos, this.pos = 0, this.buf.subarray(0, this.length);
+ }, writeFixed32: function(t4) {
+ this.realloc(4), ku(this.buf, t4, this.pos), this.pos += 4;
+ }, writeSFixed32: function(t4) {
+ this.realloc(4), ku(this.buf, t4, this.pos), this.pos += 4;
+ }, writeFixed64: function(t4) {
+ this.realloc(8), ku(this.buf, -1 & t4, this.pos), ku(this.buf, Math.floor(t4 * cu), this.pos + 4), this.pos += 8;
+ }, writeSFixed64: function(t4) {
+ this.realloc(8), ku(this.buf, -1 & t4, this.pos), ku(this.buf, Math.floor(t4 * cu), this.pos + 4), this.pos += 8;
+ }, writeVarint: function(t4) {
+ (t4 = +t4 || 0) > 268435455 || t4 < 0 ? function(t5, e2) {
+ var r2, n2;
+ if (t5 >= 0 ? (r2 = t5 % 4294967296 | 0, n2 = t5 / 4294967296 | 0) : (n2 = ~(-t5 / 4294967296), 4294967295 ^ (r2 = ~(-t5 % 4294967296)) ? r2 = r2 + 1 | 0 : (r2 = 0, n2 = n2 + 1 | 0)), t5 >= 18446744073709552e3 || t5 < -18446744073709552e3) throw new Error("Given varint doesn't fit into 10 bytes");
+ e2.realloc(10), function(t6, e3, r3) {
+ r3.buf[r3.pos++] = 127 & t6 | 128, t6 >>>= 7, r3.buf[r3.pos++] = 127 & t6 | 128, t6 >>>= 7, r3.buf[r3.pos++] = 127 & t6 | 128, t6 >>>= 7, r3.buf[r3.pos++] = 127 & t6 | 128, r3.buf[r3.pos] = 127 & (t6 >>>= 7);
+ }(r2, 0, e2), function(t6, e3) {
+ var r3 = (7 & t6) << 4;
+ e3.buf[e3.pos++] |= r3 | ((t6 >>>= 3) ? 128 : 0), t6 && (e3.buf[e3.pos++] = 127 & t6 | ((t6 >>>= 7) ? 128 : 0), t6 && (e3.buf[e3.pos++] = 127 & t6 | ((t6 >>>= 7) ? 128 : 0), t6 && (e3.buf[e3.pos++] = 127 & t6 | ((t6 >>>= 7) ? 128 : 0), t6 && (e3.buf[e3.pos++] = 127 & t6 | ((t6 >>>= 7) ? 128 : 0), t6 && (e3.buf[e3.pos++] = 127 & t6)))));
+ }(n2, e2);
+ }(t4, this) : (this.realloc(4), this.buf[this.pos++] = 127 & t4 | (t4 > 127 ? 128 : 0), t4 <= 127 || (this.buf[this.pos++] = 127 & (t4 >>>= 7) | (t4 > 127 ? 128 : 0), t4 <= 127 || (this.buf[this.pos++] = 127 & (t4 >>>= 7) | (t4 > 127 ? 128 : 0), t4 <= 127 || (this.buf[this.pos++] = t4 >>> 7 & 127))));
+ }, writeSVarint: function(t4) {
+ this.writeVarint(t4 < 0 ? 2 * -t4 - 1 : 2 * t4);
+ }, writeBoolean: function(t4) {
+ this.writeVarint(Boolean(t4));
+ }, writeString: function(t4) {
+ t4 = String(t4), this.realloc(4 * t4.length), this.pos++;
+ var e2 = this.pos;
+ this.pos = function(t5, e3, r3) {
+ for (var n2, i2, s2 = 0; s2 < e3.length; s2++) {
+ if ((n2 = e3.charCodeAt(s2)) > 55295 && n2 < 57344) {
+ if (!i2) {
+ n2 > 56319 || s2 + 1 === e3.length ? (t5[r3++] = 239, t5[r3++] = 191, t5[r3++] = 189) : i2 = n2;
+ continue;
+ }
+ if (n2 < 56320) {
+ t5[r3++] = 239, t5[r3++] = 191, t5[r3++] = 189, i2 = n2;
+ continue;
+ }
+ n2 = i2 - 55296 << 10 | n2 - 56320 | 65536, i2 = null;
+ } else i2 && (t5[r3++] = 239, t5[r3++] = 191, t5[r3++] = 189, i2 = null);
+ n2 < 128 ? t5[r3++] = n2 : (n2 < 2048 ? t5[r3++] = n2 >> 6 | 192 : (n2 < 65536 ? t5[r3++] = n2 >> 12 | 224 : (t5[r3++] = n2 >> 18 | 240, t5[r3++] = n2 >> 12 & 63 | 128), t5[r3++] = n2 >> 6 & 63 | 128), t5[r3++] = 63 & n2 | 128);
+ }
+ return r3;
+ }(this.buf, t4, this.pos);
+ var r2 = this.pos - e2;
+ r2 >= 128 && du(e2, r2, this), this.pos = e2 - 1, this.writeVarint(r2), this.pos += r2;
+ }, writeFloat: function(t4) {
+ this.realloc(4), ou(this.buf, t4, this.pos, true, 23, 4), this.pos += 4;
+ }, writeDouble: function(t4) {
+ this.realloc(8), ou(this.buf, t4, this.pos, true, 52, 8), this.pos += 8;
+ }, writeBytes: function(t4) {
+ var e2 = t4.length;
+ this.writeVarint(e2), this.realloc(e2);
+ for (var r2 = 0; r2 < e2; r2++) this.buf[this.pos++] = t4[r2];
+ }, writeRawMessage: function(t4, e2) {
+ this.pos++;
+ var r2 = this.pos;
+ t4(e2, this);
+ var n2 = this.pos - r2;
+ n2 >= 128 && du(r2, n2, this), this.pos = r2 - 1, this.writeVarint(n2), this.pos += n2;
+ }, writeMessage: function(t4, e2, r2) {
+ this.writeTag(t4, lu.Bytes), this.writeRawMessage(e2, r2);
+ }, writePackedVarint: function(t4, e2) {
+ e2.length && this.writeMessage(t4, yu, e2);
+ }, writePackedSVarint: function(t4, e2) {
+ e2.length && this.writeMessage(t4, mu, e2);
+ }, writePackedBoolean: function(t4, e2) {
+ e2.length && this.writeMessage(t4, vu, e2);
+ }, writePackedFloat: function(t4, e2) {
+ e2.length && this.writeMessage(t4, gu, e2);
+ }, writePackedDouble: function(t4, e2) {
+ e2.length && this.writeMessage(t4, xu, e2);
+ }, writePackedFixed32: function(t4, e2) {
+ e2.length && this.writeMessage(t4, bu, e2);
+ }, writePackedSFixed32: function(t4, e2) {
+ e2.length && this.writeMessage(t4, wu, e2);
+ }, writePackedFixed64: function(t4, e2) {
+ e2.length && this.writeMessage(t4, _u, e2);
+ }, writePackedSFixed64: function(t4, e2) {
+ e2.length && this.writeMessage(t4, Au, e2);
+ }, writeBytesField: function(t4, e2) {
+ this.writeTag(t4, lu.Bytes), this.writeBytes(e2);
+ }, writeFixed32Field: function(t4, e2) {
+ this.writeTag(t4, lu.Fixed32), this.writeFixed32(e2);
+ }, writeSFixed32Field: function(t4, e2) {
+ this.writeTag(t4, lu.Fixed32), this.writeSFixed32(e2);
+ }, writeFixed64Field: function(t4, e2) {
+ this.writeTag(t4, lu.Fixed64), this.writeFixed64(e2);
+ }, writeSFixed64Field: function(t4, e2) {
+ this.writeTag(t4, lu.Fixed64), this.writeSFixed64(e2);
+ }, writeVarintField: function(t4, e2) {
+ this.writeTag(t4, lu.Varint), this.writeVarint(e2);
+ }, writeSVarintField: function(t4, e2) {
+ this.writeTag(t4, lu.Varint), this.writeSVarint(e2);
+ }, writeStringField: function(t4, e2) {
+ this.writeTag(t4, lu.Bytes), this.writeString(e2);
+ }, writeFloatField: function(t4, e2) {
+ this.writeTag(t4, lu.Fixed32), this.writeFloat(e2);
+ }, writeDoubleField: function(t4, e2) {
+ this.writeTag(t4, lu.Fixed64), this.writeDouble(e2);
+ }, writeBooleanField: function(t4, e2) {
+ this.writeVarintField(t4, Boolean(e2));
+ } };
+ var Iu = r(su);
+ const zu = 3;
+ function Pu(t4, e2, r2) {
+ 1 === t4 && r2.readMessage(Cu, e2);
+ }
+ function Cu(t4, e2, r2) {
+ if (3 === t4) {
+ const { id: t5, bitmap: n2, width: i2, height: s2, left: a2, top: o2, advance: l2 } = r2.readMessage(Bu, {});
+ e2.push({ id: t5, bitmap: new _o({ width: i2 + 2 * zu, height: s2 + 2 * zu }, n2), metrics: { width: i2, height: s2, left: a2, top: o2, advance: l2 } });
+ }
+ }
+ function Bu(t4, e2, r2) {
+ 1 === t4 ? e2.id = r2.readVarint() : 2 === t4 ? e2.bitmap = r2.readBytes() : 3 === t4 ? e2.width = r2.readVarint() : 4 === t4 ? e2.height = r2.readVarint() : 5 === t4 ? e2.left = r2.readSVarint() : 6 === t4 ? e2.top = r2.readSVarint() : 7 === t4 && (e2.advance = r2.readVarint());
+ }
+ const Vu = zu;
+ function Eu(t4) {
+ let e2 = 0, r2 = 0;
+ for (const n3 of t4) e2 += n3.w * n3.h, r2 = Math.max(r2, n3.w);
+ t4.sort((t5, e3) => e3.h - t5.h);
+ const n2 = [{ x: 0, y: 0, w: Math.max(Math.ceil(Math.sqrt(e2 / 0.95)), r2), h: 1 / 0 }];
+ let i2 = 0, s2 = 0;
+ for (const e3 of t4) for (let t5 = n2.length - 1; t5 >= 0; t5--) {
+ const r3 = n2[t5];
+ if (!(e3.w > r3.w || e3.h > r3.h)) {
+ if (e3.x = r3.x, e3.y = r3.y, s2 = Math.max(s2, e3.y + e3.h), i2 = Math.max(i2, e3.x + e3.w), e3.w === r3.w && e3.h === r3.h) {
+ const e4 = n2.pop();
+ t5 < n2.length && (n2[t5] = e4);
+ } else e3.h === r3.h ? (r3.x += e3.w, r3.w -= e3.w) : e3.w === r3.w ? (r3.y += e3.h, r3.h -= e3.h) : (n2.push({ x: r3.x + e3.w, y: r3.y, w: r3.w - e3.w, h: e3.h }), r3.y += e3.h, r3.h -= e3.h);
+ break;
+ }
+ }
+ return { w: i2, h: s2, fill: e2 / (i2 * s2) || 0 };
+ }
+ const Fu = 1;
+ class Tu {
+ constructor(t4, { pixelRatio: e2, version: r2, stretchX: n2, stretchY: i2, content: s2, textFitWidth: a2, textFitHeight: o2 }) {
+ this.paddedRect = t4, this.pixelRatio = e2, this.stretchX = n2, this.stretchY = i2, this.content = s2, this.version = r2, this.textFitWidth = a2, this.textFitHeight = o2;
+ }
+ get tl() {
+ return [this.paddedRect.x + Fu, this.paddedRect.y + Fu];
+ }
+ get br() {
+ return [this.paddedRect.x + this.paddedRect.w - Fu, this.paddedRect.y + this.paddedRect.h - Fu];
+ }
+ get tlbr() {
+ return this.tl.concat(this.br);
+ }
+ get displaySize() {
+ return [(this.paddedRect.w - 2 * Fu) / this.pixelRatio, (this.paddedRect.h - 2 * Fu) / this.pixelRatio];
+ }
+ }
+ class $u {
+ constructor(t4, e2) {
+ const r2 = {}, n2 = {};
+ this.haveRenderCallbacks = [];
+ const i2 = [];
+ this.addImages(t4, r2, i2), this.addImages(e2, n2, i2);
+ const { w: s2, h: a2 } = Eu(i2), o2 = new Ao({ width: s2 || 1, height: a2 || 1 });
+ for (const e3 in t4) {
+ const n3 = t4[e3], i3 = r2[e3].paddedRect;
+ Ao.copy(n3.data, o2, { x: 0, y: 0 }, { x: i3.x + Fu, y: i3.y + Fu }, n3.data);
+ }
+ for (const t5 in e2) {
+ const r3 = e2[t5], i3 = n2[t5].paddedRect, s3 = i3.x + Fu, a3 = i3.y + Fu, l2 = r3.data.width, u2 = r3.data.height;
+ Ao.copy(r3.data, o2, { x: 0, y: 0 }, { x: s3, y: a3 }, r3.data), Ao.copy(r3.data, o2, { x: 0, y: u2 - 1 }, { x: s3, y: a3 - 1 }, { width: l2, height: 1 }), Ao.copy(r3.data, o2, { x: 0, y: 0 }, { x: s3, y: a3 + u2 }, { width: l2, height: 1 }), Ao.copy(r3.data, o2, { x: l2 - 1, y: 0 }, { x: s3 - 1, y: a3 }, { width: 1, height: u2 }), Ao.copy(r3.data, o2, { x: 0, y: 0 }, { x: s3 + l2, y: a3 }, { width: 1, height: u2 });
+ }
+ this.image = o2, this.iconPositions = r2, this.patternPositions = n2;
+ }
+ addImages(t4, e2, r2) {
+ for (const n2 in t4) {
+ const i2 = t4[n2], s2 = { x: 0, y: 0, w: i2.data.width + 2 * Fu, h: i2.data.height + 2 * Fu };
+ r2.push(s2), e2[n2] = new Tu(s2, i2), i2.hasRenderCallback && this.haveRenderCallbacks.push(n2);
+ }
+ }
+ patchUpdatedImages(t4, e2) {
+ t4.dispatchRenderCallbacks(this.haveRenderCallbacks);
+ for (const r2 in t4.updatedImages) this.patchUpdatedImage(this.iconPositions[r2], t4.getImage(r2), e2), this.patchUpdatedImage(this.patternPositions[r2], t4.getImage(r2), e2);
+ }
+ patchUpdatedImage(t4, e2, r2) {
+ if (!t4 || !e2) return;
+ if (t4.version === e2.version) return;
+ t4.version = e2.version;
+ const [n2, i2] = t4.tl;
+ r2.update(e2.data, void 0, { x: n2, y: i2 });
+ }
+ }
+ var Lu;
+ wi("ImagePosition", Tu), wi("ImageAtlas", $u), t.ah = void 0, (Lu = t.ah || (t.ah = {}))[Lu.none = 0] = "none", Lu[Lu.horizontal = 1] = "horizontal", Lu[Lu.vertical = 2] = "vertical", Lu[Lu.horizontalOnly = 3] = "horizontalOnly";
+ const Du = -17;
+ class Ou {
+ constructor() {
+ this.scale = 1, this.fontStack = "", this.imageName = null;
+ }
+ static forText(t4, e2) {
+ const r2 = new Ou();
+ return r2.scale = t4 || 1, r2.fontStack = e2, r2;
+ }
+ static forImage(t4) {
+ const e2 = new Ou();
+ return e2.imageName = t4, e2;
+ }
+ }
+ class ju {
+ constructor() {
+ this.text = "", this.sectionIndex = [], this.sections = [], this.imageSectionID = null;
+ }
+ static fromFeature(t4, e2) {
+ const r2 = new ju();
+ for (let n2 = 0; n2 < t4.sections.length; n2++) {
+ const i2 = t4.sections[n2];
+ i2.image ? r2.addImageSection(i2) : r2.addTextSection(i2, e2);
+ }
+ return r2;
+ }
+ length() {
+ return this.text.length;
+ }
+ getSection(t4) {
+ return this.sections[this.sectionIndex[t4]];
+ }
+ getSectionIndex(t4) {
+ return this.sectionIndex[t4];
+ }
+ getCharCode(t4) {
+ return this.text.charCodeAt(t4);
+ }
+ verticalizePunctuation() {
+ this.text = function(t4) {
+ let e2 = "";
+ for (let r2 = 0; r2 < t4.length; r2++) {
+ const n2 = t4.charCodeAt(r2 + 1) || null, i2 = t4.charCodeAt(r2 - 1) || null;
+ e2 += n2 && $i(n2) && !nu[t4[r2 + 1]] || i2 && $i(i2) && !nu[t4[r2 - 1]] || !nu[t4[r2]] ? t4[r2] : nu[t4[r2]];
+ }
+ return e2;
+ }(this.text);
+ }
+ trim() {
+ let t4 = 0;
+ for (let e3 = 0; e3 < this.text.length && Uu[this.text.charCodeAt(e3)]; e3++) t4++;
+ let e2 = this.text.length;
+ for (let r2 = this.text.length - 1; r2 >= 0 && r2 >= t4 && Uu[this.text.charCodeAt(r2)]; r2--) e2--;
+ this.text = this.text.substring(t4, e2), this.sectionIndex = this.sectionIndex.slice(t4, e2);
+ }
+ substring(t4, e2) {
+ const r2 = new ju();
+ return r2.text = this.text.substring(t4, e2), r2.sectionIndex = this.sectionIndex.slice(t4, e2), r2.sections = this.sections, r2;
+ }
+ toString() {
+ return this.text;
+ }
+ getMaxScale() {
+ return this.sectionIndex.reduce((t4, e2) => Math.max(t4, this.sections[e2].scale), 0);
+ }
+ addTextSection(t4, e2) {
+ this.text += t4.text, this.sections.push(Ou.forText(t4.scale, t4.fontStack || e2));
+ const r2 = this.sections.length - 1;
+ for (let e3 = 0; e3 < t4.text.length; ++e3) this.sectionIndex.push(r2);
+ }
+ addImageSection(t4) {
+ const e2 = t4.image ? t4.image.name : "";
+ if (0 === e2.length) return void A2("Can't add FormattedSection with an empty image.");
+ const r2 = this.getNextImageSectionCharCode();
+ r2 ? (this.text += String.fromCharCode(r2), this.sections.push(Ou.forImage(e2)), this.sectionIndex.push(this.sections.length - 1)) : A2("Reached maximum number of images 6401");
+ }
+ getNextImageSectionCharCode() {
+ return this.imageSectionID ? this.imageSectionID >= 63743 ? null : ++this.imageSectionID : (this.imageSectionID = 57344, this.imageSectionID);
+ }
+ }
+ function Ru(e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2, f2, d2, y2) {
+ const m2 = ju.fromFeature(e2, s2);
+ let g2;
+ p2 === t.ah.vertical && m2.verticalizePunctuation();
+ const { processBidirectionalText: x2, processStyledBidirectionalText: v2 } = Ri;
+ if (x2 && 1 === m2.sections.length) {
+ g2 = [];
+ const t4 = x2(m2.toString(), Yu(m2, c2, a2, r2, i2, d2));
+ for (const e3 of t4) {
+ const t5 = new ju();
+ t5.text = e3, t5.sections = m2.sections;
+ for (let r3 = 0; r3 < e3.length; r3++) t5.sectionIndex.push(0);
+ g2.push(t5);
+ }
+ } else if (v2) {
+ g2 = [];
+ const t4 = v2(m2.text, m2.sectionIndex, Yu(m2, c2, a2, r2, i2, d2));
+ for (const e3 of t4) {
+ const t5 = new ju();
+ t5.text = e3[0], t5.sectionIndex = e3[1], t5.sections = m2.sections, g2.push(t5);
+ }
+ } else g2 = function(t4, e3) {
+ const r3 = [], n3 = t4.text;
+ let i3 = 0;
+ for (const n4 of e3) r3.push(t4.substring(i3, n4)), i3 = n4;
+ return i3 < n3.length && r3.push(t4.substring(i3, n3.length)), r3;
+ }(m2, Yu(m2, c2, a2, r2, i2, d2));
+ const b2 = [], w2 = { positionedLines: b2, text: m2.toString(), top: h2[1], bottom: h2[1], left: h2[0], right: h2[0], writingMode: p2, iconsInText: false, verticalizable: false };
+ return function(e3, r3, n3, i3, s3, a3, o3, l3, u3, c3, h3, p3) {
+ let f3 = 0, d3 = Du, y3 = 0, m3 = 0;
+ const g3 = "right" === l3 ? 1 : "left" === l3 ? 0 : 0.5;
+ let x3 = 0;
+ for (const o4 of s3) {
+ o4.trim();
+ const s4 = o4.getMaxScale(), l4 = (s4 - 1) * iu, b4 = { positionedGlyphs: [], lineOffset: 0 };
+ e3.positionedLines[x3] = b4;
+ const w4 = b4.positionedGlyphs;
+ let _3 = 0;
+ if (!o4.length()) {
+ d3 += a3, ++x3;
+ continue;
+ }
+ for (let a4 = 0; a4 < o4.length(); a4++) {
+ const y4 = o4.getSection(a4), m4 = o4.getSectionIndex(a4), g4 = o4.getCharCode(a4);
+ let x4 = 0, b5 = null, A4 = null, S2 = null, k2 = iu;
+ const M2 = !(u3 === t.ah.horizontal || !h3 && !Ti(g4) || h3 && (Uu[g4] || (v3 = g4, new RegExp("\\p{sc=Arab}", "u").test(String.fromCodePoint(v3)))));
+ if (y4.imageName) {
+ const t4 = i3[y4.imageName];
+ if (!t4) continue;
+ S2 = y4.imageName, e3.iconsInText = e3.iconsInText || true, A4 = t4.paddedRect;
+ const r4 = t4.displaySize;
+ y4.scale = y4.scale * iu / p3, b5 = { width: r4[0], height: r4[1], left: Fu, top: -Vu, advance: M2 ? r4[1] : r4[0] }, x4 = l4 + (iu - r4[1] * y4.scale), k2 = b5.advance;
+ const n4 = M2 ? r4[0] * y4.scale - iu * s4 : r4[1] * y4.scale - iu * s4;
+ n4 > 0 && n4 > _3 && (_3 = n4);
+ } else {
+ const t4 = n3[y4.fontStack], e4 = t4 && t4[g4];
+ if (e4 && e4.rect) A4 = e4.rect, b5 = e4.metrics;
+ else {
+ const t5 = r3[y4.fontStack], e5 = t5 && t5[g4];
+ if (!e5) continue;
+ b5 = e5.metrics;
+ }
+ x4 = (s4 - y4.scale) * iu;
+ }
+ M2 ? (e3.verticalizable = true, w4.push({ glyph: g4, imageName: S2, x: f3, y: d3 + x4, vertical: M2, scale: y4.scale, fontStack: y4.fontStack, sectionIndex: m4, metrics: b5, rect: A4 }), f3 += k2 * y4.scale + c3) : (w4.push({ glyph: g4, imageName: S2, x: f3, y: d3 + x4, vertical: M2, scale: y4.scale, fontStack: y4.fontStack, sectionIndex: m4, metrics: b5, rect: A4 }), f3 += b5.advance * y4.scale + c3);
+ }
+ 0 !== w4.length && (y3 = Math.max(f3 - c3, y3), Wu(w4, 0, w4.length - 1, g3, _3)), f3 = 0;
+ const A3 = a3 * s4 + _3;
+ b4.lineOffset = Math.max(_3, l4), d3 += A3, m3 = Math.max(A3, m3), ++x3;
+ }
+ var v3;
+ const b3 = d3 - Du, { horizontalAlign: w3, verticalAlign: _2 } = Ju(o3);
+ (function(t4, e4, r4, n4, i4, s4, a4, o4, l4) {
+ const u4 = (e4 - r4) * i4;
+ let c4 = 0;
+ c4 = s4 !== a4 ? -o4 * n4 - Du : (-n4 * l4 + 0.5) * a4;
+ for (const e5 of t4) for (const t5 of e5.positionedGlyphs) t5.x += u4, t5.y += c4;
+ })(e3.positionedLines, g3, w3, _2, y3, m3, a3, b3, s3.length), e3.top += -_2 * b3, e3.bottom = e3.top + b3, e3.left += -w3 * y3, e3.right = e3.left + y3;
+ }(w2, r2, n2, i2, g2, o2, l2, u2, p2, c2, f2, y2), !function(t4) {
+ for (const e3 of t4) if (0 !== e3.positionedGlyphs.length) return false;
+ return true;
+ }(b2) && w2;
+ }
+ const Uu = { 9: true, 10: true, 11: true, 12: true, 13: true, 32: true }, qu = { 10: true, 32: true, 38: true, 41: true, 43: true, 45: true, 47: true, 173: true, 183: true, 8203: true, 8208: true, 8211: true, 8231: true }, Nu = { 40: true };
+ function Zu(t4, e2, r2, n2, i2, s2) {
+ if (e2.imageName) {
+ const t5 = n2[e2.imageName];
+ return t5 ? t5.displaySize[0] * e2.scale * iu / s2 + i2 : 0;
+ }
+ {
+ const n3 = r2[e2.fontStack], s3 = n3 && n3[t4];
+ return s3 ? s3.metrics.advance * e2.scale + i2 : 0;
+ }
+ }
+ function Gu(t4, e2, r2, n2) {
+ const i2 = Math.pow(t4 - e2, 2);
+ return n2 ? t4 < e2 ? i2 / 2 : 2 * i2 : i2 + Math.abs(r2) * r2;
+ }
+ function Ku(t4, e2, r2) {
+ let n2 = 0;
+ return 10 === t4 && (n2 -= 1e4), r2 && (n2 += 150), 40 !== t4 && 65288 !== t4 || (n2 += 50), 41 !== e2 && 65289 !== e2 || (n2 += 50), n2;
+ }
+ function Xu(t4, e2, r2, n2, i2, s2) {
+ let a2 = null, o2 = Gu(e2, r2, i2, s2);
+ for (const t5 of n2) {
+ const n3 = Gu(e2 - t5.x, r2, i2, s2) + t5.badness;
+ n3 <= o2 && (a2 = t5, o2 = n3);
+ }
+ return { index: t4, x: e2, priorBreak: a2, badness: o2 };
+ }
+ function Hu(t4) {
+ return t4 ? Hu(t4.priorBreak).concat(t4.index) : [];
+ }
+ function Yu(t4, e2, r2, n2, i2, s2) {
+ if (!t4) return [];
+ const a2 = [], o2 = function(t5, e3, r3, n3, i3, s3) {
+ let a3 = 0;
+ for (let r4 = 0; r4 < t5.length(); r4++) {
+ const o3 = t5.getSection(r4);
+ a3 += Zu(t5.getCharCode(r4), o3, n3, i3, e3, s3);
+ }
+ return a3 / Math.max(1, Math.ceil(a3 / r3));
+ }(t4, e2, r2, n2, i2, s2), l2 = t4.text.indexOf("\u200B") >= 0;
+ let u2 = 0;
+ for (let r3 = 0; r3 < t4.length(); r3++) {
+ const h2 = t4.getSection(r3), p2 = t4.getCharCode(r3);
+ if (Uu[p2] || (u2 += Zu(p2, h2, n2, i2, e2, s2)), r3 < t4.length() - 1) {
+ const e3 = !((c2 = p2) < 11904) && (!!zi["CJK Compatibility Forms"](c2) || !!zi["CJK Compatibility"](c2) || !!zi["CJK Strokes"](c2) || !!zi["CJK Symbols and Punctuation"](c2) || !!zi["Enclosed CJK Letters and Months"](c2) || !!zi["Halfwidth and Fullwidth Forms"](c2) || !!zi["Ideographic Description Characters"](c2) || !!zi["Vertical Forms"](c2) || Fi.test(String.fromCodePoint(c2)));
+ (qu[p2] || e3 || h2.imageName || r3 !== t4.length() - 2 && Nu[t4.getCharCode(r3 + 1)]) && a2.push(Xu(r3 + 1, u2, o2, a2, Ku(p2, t4.getCharCode(r3 + 1), e3 && l2), false));
+ }
+ }
+ var c2;
+ return Hu(Xu(t4.length(), u2, o2, a2, 0, true));
+ }
+ function Ju(t4) {
+ let e2 = 0.5, r2 = 0.5;
+ switch (t4) {
+ case "right":
+ case "top-right":
+ case "bottom-right":
+ e2 = 1;
+ break;
+ case "left":
+ case "top-left":
+ case "bottom-left":
+ e2 = 0;
+ }
+ switch (t4) {
+ case "bottom":
+ case "bottom-right":
+ case "bottom-left":
+ r2 = 1;
+ break;
+ case "top":
+ case "top-right":
+ case "top-left":
+ r2 = 0;
+ }
+ return { horizontalAlign: e2, verticalAlign: r2 };
+ }
+ function Wu(t4, e2, r2, n2, i2) {
+ if (!n2 && !i2) return;
+ const s2 = t4[r2], a2 = (t4[r2].x + s2.metrics.advance * s2.scale) * n2;
+ for (let n3 = e2; n3 <= r2; n3++) t4[n3].x -= a2, t4[n3].y += i2;
+ }
+ function Qu(t4, e2, r2) {
+ const { horizontalAlign: n2, verticalAlign: i2 } = Ju(r2), s2 = e2[0] - t4.displaySize[0] * n2, a2 = e2[1] - t4.displaySize[1] * i2;
+ return { image: t4, top: a2, bottom: a2 + t4.displaySize[1], left: s2, right: s2 + t4.displaySize[0] };
+ }
+ function tc(t4) {
+ var e2, r2;
+ let n2 = t4.left, i2 = t4.top, s2 = t4.right - n2, a2 = t4.bottom - i2;
+ const o2 = null !== (e2 = t4.image.textFitWidth) && void 0 !== e2 ? e2 : "stretchOrShrink", l2 = null !== (r2 = t4.image.textFitHeight) && void 0 !== r2 ? r2 : "stretchOrShrink", u2 = (t4.image.content[2] - t4.image.content[0]) / (t4.image.content[3] - t4.image.content[1]);
+ if ("proportional" === l2) {
+ if ("stretchOnly" === o2 && s2 / a2 < u2 || "proportional" === o2) {
+ const t5 = Math.ceil(a2 * u2);
+ n2 *= t5 / s2, s2 = t5;
+ }
+ } else if ("proportional" === o2 && "stretchOnly" === l2 && 0 !== u2 && s2 / a2 > u2) {
+ const t5 = Math.ceil(s2 / u2);
+ i2 *= t5 / a2, a2 = t5;
+ }
+ return { x1: n2, y1: i2, x2: n2 + s2, y2: i2 + a2 };
+ }
+ function ec(t4, e2, r2, n2, i2, s2) {
+ const a2 = t4.image;
+ let o2;
+ if (a2.content) {
+ const t5 = a2.content, e3 = a2.pixelRatio || 1;
+ o2 = [t5[0] / e3, t5[1] / e3, a2.displaySize[0] - t5[2] / e3, a2.displaySize[1] - t5[3] / e3];
+ }
+ const l2 = e2.left * s2, u2 = e2.right * s2;
+ let c2, h2, p2, f2;
+ "width" === r2 || "both" === r2 ? (f2 = i2[0] + l2 - n2[3], h2 = i2[0] + u2 + n2[1]) : (f2 = i2[0] + (l2 + u2 - a2.displaySize[0]) / 2, h2 = f2 + a2.displaySize[0]);
+ const d2 = e2.top * s2, y2 = e2.bottom * s2;
+ return "height" === r2 || "both" === r2 ? (c2 = i2[1] + d2 - n2[0], p2 = i2[1] + y2 + n2[2]) : (c2 = i2[1] + (d2 + y2 - a2.displaySize[1]) / 2, p2 = c2 + a2.displaySize[1]), { image: a2, top: c2, right: h2, bottom: p2, left: f2, collisionPadding: o2 };
+ }
+ const rc = 255, nc = 128, ic = rc * nc;
+ function sc(t4, e2) {
+ const { expression: r2 } = e2;
+ if ("constant" === r2.kind) return { kind: "constant", layoutSize: r2.evaluate(new Ui(t4 + 1)) };
+ if ("source" === r2.kind) return { kind: "source" };
+ {
+ const { zoomStops: e3, interpolationType: n2 } = r2;
+ let i2 = 0;
+ for (; i2 < e3.length && e3[i2] <= t4; ) i2++;
+ i2 = Math.max(0, i2 - 1);
+ let s2 = i2;
+ for (; s2 < e3.length && e3[s2] < t4 + 1; ) s2++;
+ s2 = Math.min(e3.length - 1, s2);
+ const a2 = e3[i2], o2 = e3[s2];
+ return "composite" === r2.kind ? { kind: "composite", minZoom: a2, maxZoom: o2, interpolationType: n2 } : { kind: "camera", minZoom: a2, maxZoom: o2, minSize: r2.evaluate(new Ui(a2)), maxSize: r2.evaluate(new Ui(o2)), interpolationType: n2 };
+ }
+ }
+ function ac(t4, e2, r2) {
+ let n2 = "never";
+ const i2 = t4.get(e2);
+ return i2 ? n2 = i2 : t4.get(r2) && (n2 = "always"), n2;
+ }
+ const oc = fl.VectorTileFeature.types, lc = [{ name: "a_fade_opacity", components: 1, type: "Uint8", offset: 0 }];
+ function uc(t4, e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2) {
+ const f2 = o2 ? Math.min(ic, Math.round(o2[0])) : 0, d2 = o2 ? Math.min(ic, Math.round(o2[1])) : 0;
+ t4.emplaceBack(e2, r2, Math.round(32 * n2), Math.round(32 * i2), s2, a2, (f2 << 1) + (l2 ? 1 : 0), d2, 16 * u2, 16 * c2, 256 * h2, 256 * p2);
+ }
+ function cc(t4, e2, r2) {
+ t4.emplaceBack(e2.x, e2.y, r2), t4.emplaceBack(e2.x, e2.y, r2), t4.emplaceBack(e2.x, e2.y, r2), t4.emplaceBack(e2.x, e2.y, r2);
+ }
+ function hc(t4) {
+ for (const e2 of t4.sections) if (ji(e2.text)) return true;
+ return false;
+ }
+ class pc {
+ constructor(t4) {
+ this.layoutVertexArray = new Ws(), this.indexArray = new na(), this.programConfigurations = t4, this.segments = new oa(), this.dynamicLayoutVertexArray = new Qs(), this.opacityVertexArray = new ta(), this.hasVisibleVertices = false, this.placedSymbolArray = new $s();
+ }
+ isEmpty() {
+ return 0 === this.layoutVertexArray.length && 0 === this.indexArray.length && 0 === this.dynamicLayoutVertexArray.length && 0 === this.opacityVertexArray.length;
+ }
+ upload(t4, e2, r2, n2) {
+ this.isEmpty() || (r2 && (this.layoutVertexBuffer = t4.createVertexBuffer(this.layoutVertexArray, Jl.members), this.indexBuffer = t4.createIndexBuffer(this.indexArray, e2), this.dynamicLayoutVertexBuffer = t4.createVertexBuffer(this.dynamicLayoutVertexArray, Wl.members, true), this.opacityVertexBuffer = t4.createVertexBuffer(this.opacityVertexArray, lc, true), this.opacityVertexBuffer.itemSize = 1), (r2 || n2) && this.programConfigurations.upload(t4));
+ }
+ destroy() {
+ this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.programConfigurations.destroy(), this.segments.destroy(), this.dynamicLayoutVertexBuffer.destroy(), this.opacityVertexBuffer.destroy());
+ }
+ }
+ wi("SymbolBuffers", pc);
+ class fc {
+ constructor(t4, e2, r2) {
+ this.layoutVertexArray = new t4(), this.layoutAttributes = e2, this.indexArray = new r2(), this.segments = new oa(), this.collisionVertexArray = new ra();
+ }
+ upload(t4) {
+ this.layoutVertexBuffer = t4.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes), this.indexBuffer = t4.createIndexBuffer(this.indexArray), this.collisionVertexBuffer = t4.createVertexBuffer(this.collisionVertexArray, Ql.members, true);
+ }
+ destroy() {
+ this.layoutVertexBuffer && (this.layoutVertexBuffer.destroy(), this.indexBuffer.destroy(), this.segments.destroy(), this.collisionVertexBuffer.destroy());
+ }
+ }
+ wi("CollisionBuffers", fc);
+ class dc {
+ constructor(e2) {
+ this.collisionBoxArray = e2.collisionBoxArray, this.zoom = e2.zoom, this.overscaling = e2.overscaling, this.layers = e2.layers, this.layerIds = this.layers.map((t4) => t4.id), this.index = e2.index, this.pixelRatio = e2.pixelRatio, this.sourceLayerIndex = e2.sourceLayerIndex, this.hasPattern = false, this.hasRTLText = false, this.sortKeyRanges = [], this.collisionCircleArray = [], this.placementInvProjMatrix = lo([]), this.placementViewportMatrix = lo([]);
+ const r2 = this.layers[0]._unevaluatedLayout._values;
+ this.textSizeData = sc(this.zoom, r2["text-size"]), this.iconSizeData = sc(this.zoom, r2["icon-size"]);
+ const n2 = this.layers[0].layout, i2 = n2.get("symbol-sort-key"), s2 = n2.get("symbol-z-order");
+ this.canOverlap = "never" !== ac(n2, "text-overlap", "text-allow-overlap") || "never" !== ac(n2, "icon-overlap", "icon-allow-overlap") || n2.get("text-ignore-placement") || n2.get("icon-ignore-placement"), this.sortFeaturesByKey = "viewport-y" !== s2 && !i2.isConstant(), this.sortFeaturesByY = ("viewport-y" === s2 || "auto" === s2 && !this.sortFeaturesByKey) && this.canOverlap, "point" === n2.get("symbol-placement") && (this.writingModes = n2.get("text-writing-mode").map((e3) => t.ah[e3])), this.stateDependentLayerIds = this.layers.filter((t4) => t4.isStateDependent()).map((t4) => t4.id), this.sourceID = e2.sourceID;
+ }
+ createArrays() {
+ this.text = new pc(new Ea(this.layers, this.zoom, (t4) => /^text/.test(t4))), this.icon = new pc(new Ea(this.layers, this.zoom, (t4) => /^icon/.test(t4))), this.glyphOffsetArray = new Os(), this.lineVertexArray = new js(), this.symbolInstances = new Ds(), this.textAnchorOffsets = new Us();
+ }
+ calculateGlyphDependencies(t4, e2, r2, n2, i2) {
+ for (let s2 = 0; s2 < t4.length; s2++) if (e2[t4.charCodeAt(s2)] = true, (r2 || n2) && i2) {
+ const r3 = nu[t4.charAt(s2)];
+ r3 && (e2[r3.charCodeAt(0)] = true);
+ }
+ }
+ populate(e2, r2, n2) {
+ const i2 = this.layers[0], s2 = i2.layout, a2 = s2.get("text-font"), o2 = s2.get("text-field"), l2 = s2.get("icon-image"), u2 = ("constant" !== o2.value.kind || o2.value.value instanceof Yt && !o2.value.value.isEmpty() || o2.value.value.toString().length > 0) && ("constant" !== a2.value.kind || a2.value.value.length > 0), c2 = "constant" !== l2.value.kind || !!l2.value.value || Object.keys(l2.parameters).length > 0, h2 = s2.get("symbol-sort-key");
+ if (this.features = [], !u2 && !c2) return;
+ const p2 = r2.iconDependencies, f2 = r2.glyphDependencies, d2 = r2.availableImages, y2 = new Ui(this.zoom);
+ for (const { feature: r3, id: o3, index: l3, sourceLayerIndex: m2 } of e2) {
+ const e3 = i2._featureFilter.needGeometry, g2 = ja(r3, e3);
+ if (!i2._featureFilter.filter(y2, g2, n2)) continue;
+ let x2, v2;
+ if (e3 || (g2.geometry = Oa(r3)), u2) {
+ const t4 = i2.getValueAndResolveTokens("text-field", g2, n2, d2), e4 = Yt.factory(t4), r4 = this.hasRTLText = this.hasRTLText || hc(e4);
+ (!r4 || "unavailable" === Ri.getRTLTextPluginStatus() || r4 && Ri.isParsed()) && (x2 = ru(e4, i2, g2));
+ }
+ if (c2) {
+ const t4 = i2.getValueAndResolveTokens("icon-image", g2, n2, d2);
+ v2 = t4 instanceof te ? t4 : te.fromString(t4);
+ }
+ if (!x2 && !v2) continue;
+ const b2 = this.sortFeaturesByKey ? h2.evaluate(g2, {}, n2) : void 0;
+ if (this.features.push({ id: o3, text: x2, icon: v2, index: l3, sourceLayerIndex: m2, geometry: g2.geometry, properties: r3.properties, type: oc[r3.type], sortKey: b2 }), v2 && (p2[v2.name] = true), x2) {
+ const e4 = a2.evaluate(g2, {}, n2).join(","), r4 = "viewport" !== s2.get("text-rotation-alignment") && "point" !== s2.get("symbol-placement");
+ this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(t.ah.vertical) >= 0;
+ for (const t4 of x2.sections) if (t4.image) p2[t4.image.name] = true;
+ else {
+ const n3 = Pi(x2.toString()), i3 = t4.fontStack || e4, s3 = f2[i3] = f2[i3] || {};
+ this.calculateGlyphDependencies(t4.text, s3, r4, this.allowVerticalPlacement, n3);
+ }
+ }
+ }
+ "line" === s2.get("symbol-placement") && (this.features = function(t4) {
+ const e3 = {}, r3 = {}, n3 = [];
+ let i3 = 0;
+ function s3(e4) {
+ n3.push(t4[e4]), i3++;
+ }
+ function a3(t5, e4, i4) {
+ const s4 = r3[t5];
+ return delete r3[t5], r3[e4] = s4, n3[s4].geometry[0].pop(), n3[s4].geometry[0] = n3[s4].geometry[0].concat(i4[0]), s4;
+ }
+ function o3(t5, r4, i4) {
+ const s4 = e3[r4];
+ return delete e3[r4], e3[t5] = s4, n3[s4].geometry[0].shift(), n3[s4].geometry[0] = i4[0].concat(n3[s4].geometry[0]), s4;
+ }
+ function l3(t5, e4, r4) {
+ const n4 = r4 ? e4[0][e4[0].length - 1] : e4[0][0];
+ return `${t5}:${n4.x}:${n4.y}`;
+ }
+ for (let u3 = 0; u3 < t4.length; u3++) {
+ const c3 = t4[u3], h3 = c3.geometry, p3 = c3.text ? c3.text.toString() : null;
+ if (!p3) {
+ s3(u3);
+ continue;
+ }
+ const f3 = l3(p3, h3), d3 = l3(p3, h3, true);
+ if (f3 in r3 && d3 in e3 && r3[f3] !== e3[d3]) {
+ const t5 = o3(f3, d3, h3), i4 = a3(f3, d3, n3[t5].geometry);
+ delete e3[f3], delete r3[d3], r3[l3(p3, n3[i4].geometry, true)] = i4, n3[t5].geometry = null;
+ } else f3 in r3 ? a3(f3, d3, h3) : d3 in e3 ? o3(f3, d3, h3) : (s3(u3), e3[f3] = i3 - 1, r3[d3] = i3 - 1);
+ }
+ return n3.filter((t5) => t5.geometry);
+ }(this.features)), this.sortFeaturesByKey && this.features.sort((t4, e3) => t4.sortKey - e3.sortKey);
+ }
+ update(t4, e2, r2) {
+ this.stateDependentLayers.length && (this.text.programConfigurations.updatePaintArrays(t4, e2, this.layers, r2), this.icon.programConfigurations.updatePaintArrays(t4, e2, this.layers, r2));
+ }
+ isEmpty() {
+ return 0 === this.symbolInstances.length && !this.hasRTLText;
+ }
+ uploadPending() {
+ return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;
+ }
+ upload(t4) {
+ !this.uploaded && this.hasDebugData() && (this.textCollisionBox.upload(t4), this.iconCollisionBox.upload(t4)), this.text.upload(t4, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload), this.icon.upload(t4, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload), this.uploaded = true;
+ }
+ destroyDebugData() {
+ this.textCollisionBox.destroy(), this.iconCollisionBox.destroy();
+ }
+ destroy() {
+ this.text.destroy(), this.icon.destroy(), this.hasDebugData() && this.destroyDebugData();
+ }
+ addToLineVertexArray(t4, e2) {
+ const r2 = this.lineVertexArray.length;
+ if (void 0 !== t4.segment) {
+ let r3 = t4.dist(e2[t4.segment + 1]), n2 = t4.dist(e2[t4.segment]);
+ const i2 = {};
+ for (let n3 = t4.segment + 1; n3 < e2.length; n3++) i2[n3] = { x: e2[n3].x, y: e2[n3].y, tileUnitDistanceFromAnchor: r3 }, n3 < e2.length - 1 && (r3 += e2[n3 + 1].dist(e2[n3]));
+ for (let r4 = t4.segment || 0; r4 >= 0; r4--) i2[r4] = { x: e2[r4].x, y: e2[r4].y, tileUnitDistanceFromAnchor: n2 }, r4 > 0 && (n2 += e2[r4 - 1].dist(e2[r4]));
+ for (let t5 = 0; t5 < e2.length; t5++) {
+ const e3 = i2[t5];
+ this.lineVertexArray.emplaceBack(e3.x, e3.y, e3.tileUnitDistanceFromAnchor);
+ }
+ }
+ return { lineStartIndex: r2, lineLength: this.lineVertexArray.length - r2 };
+ }
+ addSymbols(e2, r2, n2, i2, s2, a2, o2, l2, u2, c2, h2, p2) {
+ const f2 = e2.indexArray, d2 = e2.layoutVertexArray, y2 = e2.segments.prepareSegment(4 * r2.length, d2, f2, this.canOverlap ? a2.sortKey : void 0), m2 = this.glyphOffsetArray.length, g2 = y2.vertexLength, x2 = this.allowVerticalPlacement && o2 === t.ah.vertical ? Math.PI / 2 : 0, v2 = a2.text && a2.text.sections;
+ for (let t4 = 0; t4 < r2.length; t4++) {
+ const { tl: i3, tr: s3, bl: o3, br: u3, tex: c3, pixelOffsetTL: h3, pixelOffsetBR: m3, minFontScaleX: g3, minFontScaleY: b2, glyphOffset: w2, isSDF: _2, sectionIndex: A3 } = r2[t4], S2 = y2.vertexLength, k2 = w2[1];
+ uc(d2, l2.x, l2.y, i3.x, k2 + i3.y, c3.x, c3.y, n2, _2, h3.x, h3.y, g3, b2), uc(d2, l2.x, l2.y, s3.x, k2 + s3.y, c3.x + c3.w, c3.y, n2, _2, m3.x, h3.y, g3, b2), uc(d2, l2.x, l2.y, o3.x, k2 + o3.y, c3.x, c3.y + c3.h, n2, _2, h3.x, m3.y, g3, b2), uc(d2, l2.x, l2.y, u3.x, k2 + u3.y, c3.x + c3.w, c3.y + c3.h, n2, _2, m3.x, m3.y, g3, b2), cc(e2.dynamicLayoutVertexArray, l2, x2), f2.emplaceBack(S2, S2 + 1, S2 + 2), f2.emplaceBack(S2 + 1, S2 + 2, S2 + 3), y2.vertexLength += 4, y2.primitiveLength += 2, this.glyphOffsetArray.emplaceBack(w2[0]), t4 !== r2.length - 1 && A3 === r2[t4 + 1].sectionIndex || e2.programConfigurations.populatePaintArrays(d2.length, a2, a2.index, {}, p2, v2 && v2[A3]);
+ }
+ e2.placedSymbolArray.emplaceBack(l2.x, l2.y, m2, this.glyphOffsetArray.length - m2, g2, u2, c2, l2.segment, n2 ? n2[0] : 0, n2 ? n2[1] : 0, i2[0], i2[1], o2, 0, false, 0, h2);
+ }
+ _addCollisionDebugVertex(t4, e2, r2, n2, i2, s2) {
+ return e2.emplaceBack(0, 0), t4.emplaceBack(r2.x, r2.y, n2, i2, Math.round(s2.x), Math.round(s2.y));
+ }
+ addCollisionDebugVertices(t4, e2, r2, n2, i2, a2, o2) {
+ const l2 = i2.segments.prepareSegment(4, i2.layoutVertexArray, i2.indexArray), u2 = l2.vertexLength, c2 = i2.layoutVertexArray, h2 = i2.collisionVertexArray, p2 = o2.anchorX, f2 = o2.anchorY;
+ this._addCollisionDebugVertex(c2, h2, a2, p2, f2, new s(t4, e2)), this._addCollisionDebugVertex(c2, h2, a2, p2, f2, new s(r2, e2)), this._addCollisionDebugVertex(c2, h2, a2, p2, f2, new s(r2, n2)), this._addCollisionDebugVertex(c2, h2, a2, p2, f2, new s(t4, n2)), l2.vertexLength += 4;
+ const d2 = i2.indexArray;
+ d2.emplaceBack(u2, u2 + 1), d2.emplaceBack(u2 + 1, u2 + 2), d2.emplaceBack(u2 + 2, u2 + 3), d2.emplaceBack(u2 + 3, u2), l2.primitiveLength += 4;
+ }
+ addDebugCollisionBoxes(t4, e2, r2, n2) {
+ for (let i2 = t4; i2 < e2; i2++) {
+ const t5 = this.collisionBoxArray.get(i2);
+ this.addCollisionDebugVertices(t5.x1, t5.y1, t5.x2, t5.y2, n2 ? this.textCollisionBox : this.iconCollisionBox, t5.anchorPoint, r2);
+ }
+ }
+ generateCollisionDebugBuffers() {
+ this.hasDebugData() && this.destroyDebugData(), this.textCollisionBox = new fc(ea, tu.members, ia), this.iconCollisionBox = new fc(ea, tu.members, ia);
+ for (let t4 = 0; t4 < this.symbolInstances.length; t4++) {
+ const e2 = this.symbolInstances.get(t4);
+ this.addDebugCollisionBoxes(e2.textBoxStartIndex, e2.textBoxEndIndex, e2, true), this.addDebugCollisionBoxes(e2.verticalTextBoxStartIndex, e2.verticalTextBoxEndIndex, e2, true), this.addDebugCollisionBoxes(e2.iconBoxStartIndex, e2.iconBoxEndIndex, e2, false), this.addDebugCollisionBoxes(e2.verticalIconBoxStartIndex, e2.verticalIconBoxEndIndex, e2, false);
+ }
+ }
+ _deserializeCollisionBoxesForSymbol(t4, e2, r2, n2, i2, s2, a2, o2, l2) {
+ const u2 = {};
+ for (let n3 = e2; n3 < r2; n3++) {
+ const e3 = t4.get(n3);
+ u2.textBox = { x1: e3.x1, y1: e3.y1, x2: e3.x2, y2: e3.y2, anchorPointX: e3.anchorPointX, anchorPointY: e3.anchorPointY }, u2.textFeatureIndex = e3.featureIndex;
+ break;
+ }
+ for (let e3 = n2; e3 < i2; e3++) {
+ const r3 = t4.get(e3);
+ u2.verticalTextBox = { x1: r3.x1, y1: r3.y1, x2: r3.x2, y2: r3.y2, anchorPointX: r3.anchorPointX, anchorPointY: r3.anchorPointY }, u2.verticalTextFeatureIndex = r3.featureIndex;
+ break;
+ }
+ for (let e3 = s2; e3 < a2; e3++) {
+ const r3 = t4.get(e3);
+ u2.iconBox = { x1: r3.x1, y1: r3.y1, x2: r3.x2, y2: r3.y2, anchorPointX: r3.anchorPointX, anchorPointY: r3.anchorPointY }, u2.iconFeatureIndex = r3.featureIndex;
+ break;
+ }
+ for (let e3 = o2; e3 < l2; e3++) {
+ const r3 = t4.get(e3);
+ u2.verticalIconBox = { x1: r3.x1, y1: r3.y1, x2: r3.x2, y2: r3.y2, anchorPointX: r3.anchorPointX, anchorPointY: r3.anchorPointY }, u2.verticalIconFeatureIndex = r3.featureIndex;
+ break;
+ }
+ return u2;
+ }
+ deserializeCollisionBoxes(t4) {
+ this.collisionArrays = [];
+ for (let e2 = 0; e2 < this.symbolInstances.length; e2++) {
+ const r2 = this.symbolInstances.get(e2);
+ this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t4, r2.textBoxStartIndex, r2.textBoxEndIndex, r2.verticalTextBoxStartIndex, r2.verticalTextBoxEndIndex, r2.iconBoxStartIndex, r2.iconBoxEndIndex, r2.verticalIconBoxStartIndex, r2.verticalIconBoxEndIndex));
+ }
+ }
+ hasTextData() {
+ return this.text.segments.get().length > 0;
+ }
+ hasIconData() {
+ return this.icon.segments.get().length > 0;
+ }
+ hasDebugData() {
+ return this.textCollisionBox && this.iconCollisionBox;
+ }
+ hasTextCollisionBoxData() {
+ return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;
+ }
+ hasIconCollisionBoxData() {
+ return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;
+ }
+ addIndicesForPlacedSymbol(t4, e2) {
+ const r2 = t4.placedSymbolArray.get(e2), n2 = r2.vertexStartIndex + 4 * r2.numGlyphs;
+ for (let e3 = r2.vertexStartIndex; e3 < n2; e3 += 4) t4.indexArray.emplaceBack(e3, e3 + 1, e3 + 2), t4.indexArray.emplaceBack(e3 + 1, e3 + 2, e3 + 3);
+ }
+ getSortedSymbolIndexes(t4) {
+ if (this.sortedAngle === t4 && void 0 !== this.symbolInstanceIndexes) return this.symbolInstanceIndexes;
+ const e2 = Math.sin(t4), r2 = Math.cos(t4), n2 = [], i2 = [], s2 = [];
+ for (let t5 = 0; t5 < this.symbolInstances.length; ++t5) {
+ s2.push(t5);
+ const a2 = this.symbolInstances.get(t5);
+ n2.push(0 | Math.round(e2 * a2.anchorX + r2 * a2.anchorY)), i2.push(a2.featureIndex);
+ }
+ return s2.sort((t5, e3) => n2[t5] - n2[e3] || i2[e3] - i2[t5]), s2;
+ }
+ addToSortKeyRanges(t4, e2) {
+ const r2 = this.sortKeyRanges[this.sortKeyRanges.length - 1];
+ r2 && r2.sortKey === e2 ? r2.symbolInstanceEnd = t4 + 1 : this.sortKeyRanges.push({ sortKey: e2, symbolInstanceStart: t4, symbolInstanceEnd: t4 + 1 });
+ }
+ sortFeatures(t4) {
+ if (this.sortFeaturesByY && this.sortedAngle !== t4 && !(this.text.segments.get().length > 1 || this.icon.segments.get().length > 1)) {
+ this.symbolInstanceIndexes = this.getSortedSymbolIndexes(t4), this.sortedAngle = t4, this.text.indexArray.clear(), this.icon.indexArray.clear(), this.featureSortOrder = [];
+ for (const t5 of this.symbolInstanceIndexes) {
+ const e2 = this.symbolInstances.get(t5);
+ this.featureSortOrder.push(e2.featureIndex), [e2.rightJustifiedTextSymbolIndex, e2.centerJustifiedTextSymbolIndex, e2.leftJustifiedTextSymbolIndex].forEach((t6, e3, r2) => {
+ t6 >= 0 && r2.indexOf(t6) === e3 && this.addIndicesForPlacedSymbol(this.text, t6);
+ }), e2.verticalPlacedTextSymbolIndex >= 0 && this.addIndicesForPlacedSymbol(this.text, e2.verticalPlacedTextSymbolIndex), e2.placedIconSymbolIndex >= 0 && this.addIndicesForPlacedSymbol(this.icon, e2.placedIconSymbolIndex), e2.verticalPlacedIconSymbolIndex >= 0 && this.addIndicesForPlacedSymbol(this.icon, e2.verticalPlacedIconSymbolIndex);
+ }
+ this.text.indexBuffer && this.text.indexBuffer.updateData(this.text.indexArray), this.icon.indexBuffer && this.icon.indexBuffer.updateData(this.icon.indexArray);
+ }
+ }
+ }
+ let yc, mc;
+ wi("SymbolBucket", dc, { omit: ["layers", "collisionBoxArray", "features", "compareText"] }), dc.MAX_GLYPHS = 65535, dc.addDynamicAttributes = cc;
+ var gc = { get paint() {
+ return mc = mc || new rs({ "icon-opacity": new Wi(G.paint_symbol["icon-opacity"]), "icon-color": new Wi(G.paint_symbol["icon-color"]), "icon-halo-color": new Wi(G.paint_symbol["icon-halo-color"]), "icon-halo-width": new Wi(G.paint_symbol["icon-halo-width"]), "icon-halo-blur": new Wi(G.paint_symbol["icon-halo-blur"]), "icon-translate": new Ji(G.paint_symbol["icon-translate"]), "icon-translate-anchor": new Ji(G.paint_symbol["icon-translate-anchor"]), "text-opacity": new Wi(G.paint_symbol["text-opacity"]), "text-color": new Wi(G.paint_symbol["text-color"], { runtimeType: pt, getOverride: (t4) => t4.textColor, hasOverride: (t4) => !!t4.textColor }), "text-halo-color": new Wi(G.paint_symbol["text-halo-color"]), "text-halo-width": new Wi(G.paint_symbol["text-halo-width"]), "text-halo-blur": new Wi(G.paint_symbol["text-halo-blur"]), "text-translate": new Ji(G.paint_symbol["text-translate"]), "text-translate-anchor": new Ji(G.paint_symbol["text-translate-anchor"]) });
+ }, get layout() {
+ return yc = yc || new rs({ "symbol-placement": new Ji(G.layout_symbol["symbol-placement"]), "symbol-spacing": new Ji(G.layout_symbol["symbol-spacing"]), "symbol-avoid-edges": new Ji(G.layout_symbol["symbol-avoid-edges"]), "symbol-sort-key": new Wi(G.layout_symbol["symbol-sort-key"]), "symbol-z-order": new Ji(G.layout_symbol["symbol-z-order"]), "icon-allow-overlap": new Ji(G.layout_symbol["icon-allow-overlap"]), "icon-overlap": new Ji(G.layout_symbol["icon-overlap"]), "icon-ignore-placement": new Ji(G.layout_symbol["icon-ignore-placement"]), "icon-optional": new Ji(G.layout_symbol["icon-optional"]), "icon-rotation-alignment": new Ji(G.layout_symbol["icon-rotation-alignment"]), "icon-size": new Wi(G.layout_symbol["icon-size"]), "icon-text-fit": new Ji(G.layout_symbol["icon-text-fit"]), "icon-text-fit-padding": new Ji(G.layout_symbol["icon-text-fit-padding"]), "icon-image": new Wi(G.layout_symbol["icon-image"]), "icon-rotate": new Wi(G.layout_symbol["icon-rotate"]), "icon-padding": new Wi(G.layout_symbol["icon-padding"]), "icon-keep-upright": new Ji(G.layout_symbol["icon-keep-upright"]), "icon-offset": new Wi(G.layout_symbol["icon-offset"]), "icon-anchor": new Wi(G.layout_symbol["icon-anchor"]), "icon-pitch-alignment": new Ji(G.layout_symbol["icon-pitch-alignment"]), "text-pitch-alignment": new Ji(G.layout_symbol["text-pitch-alignment"]), "text-rotation-alignment": new Ji(G.layout_symbol["text-rotation-alignment"]), "text-field": new Wi(G.layout_symbol["text-field"]), "text-font": new Wi(G.layout_symbol["text-font"]), "text-size": new Wi(G.layout_symbol["text-size"]), "text-max-width": new Wi(G.layout_symbol["text-max-width"]), "text-line-height": new Ji(G.layout_symbol["text-line-height"]), "text-letter-spacing": new Wi(G.layout_symbol["text-letter-spacing"]), "text-justify": new Wi(G.layout_symbol["text-justify"]), "text-radial-offset": new Wi(G.layout_symbol["text-radial-offset"]), "text-variable-anchor": new Ji(G.layout_symbol["text-variable-anchor"]), "text-variable-anchor-offset": new Wi(G.layout_symbol["text-variable-anchor-offset"]), "text-anchor": new Wi(G.layout_symbol["text-anchor"]), "text-max-angle": new Ji(G.layout_symbol["text-max-angle"]), "text-writing-mode": new Ji(G.layout_symbol["text-writing-mode"]), "text-rotate": new Wi(G.layout_symbol["text-rotate"]), "text-padding": new Ji(G.layout_symbol["text-padding"]), "text-keep-upright": new Ji(G.layout_symbol["text-keep-upright"]), "text-transform": new Wi(G.layout_symbol["text-transform"]), "text-offset": new Wi(G.layout_symbol["text-offset"]), "text-allow-overlap": new Ji(G.layout_symbol["text-allow-overlap"]), "text-overlap": new Ji(G.layout_symbol["text-overlap"]), "text-ignore-placement": new Ji(G.layout_symbol["text-ignore-placement"]), "text-optional": new Ji(G.layout_symbol["text-optional"]) });
+ } };
+ class xc {
+ constructor(t4) {
+ if (void 0 === t4.property.overrides) throw new Error("overrides must be provided to instantiate FormatSectionOverride class");
+ this.type = t4.property.overrides ? t4.property.overrides.runtimeType : lt, this.defaultValue = t4;
+ }
+ evaluate(t4) {
+ if (t4.formattedSection) {
+ const e2 = this.defaultValue.property.overrides;
+ if (e2 && e2.hasOverride(t4.formattedSection)) return e2.getOverride(t4.formattedSection);
+ }
+ return t4.feature && t4.featureState ? this.defaultValue.evaluate(t4.feature, t4.featureState) : this.defaultValue.property.specification.default;
+ }
+ eachChild(t4) {
+ this.defaultValue.isConstant() || t4(this.defaultValue.value._styleExpression.expression);
+ }
+ outputDefined() {
+ return false;
+ }
+ serialize() {
+ return null;
+ }
+ }
+ wi("FormatSectionOverride", xc, { omit: ["defaultValue"] });
+ class vc extends is {
+ constructor(t4) {
+ super(t4, gc);
+ }
+ recalculate(t4, e2) {
+ if (super.recalculate(t4, e2), "auto" === this.layout.get("icon-rotation-alignment") && (this.layout._values["icon-rotation-alignment"] = "point" !== this.layout.get("symbol-placement") ? "map" : "viewport"), "auto" === this.layout.get("text-rotation-alignment") && (this.layout._values["text-rotation-alignment"] = "point" !== this.layout.get("symbol-placement") ? "map" : "viewport"), "auto" === this.layout.get("text-pitch-alignment") && (this.layout._values["text-pitch-alignment"] = "map" === this.layout.get("text-rotation-alignment") ? "map" : "viewport"), "auto" === this.layout.get("icon-pitch-alignment") && (this.layout._values["icon-pitch-alignment"] = this.layout.get("icon-rotation-alignment")), "point" === this.layout.get("symbol-placement")) {
+ const t5 = this.layout.get("text-writing-mode");
+ if (t5) {
+ const e3 = [];
+ for (const r2 of t5) e3.indexOf(r2) < 0 && e3.push(r2);
+ this.layout._values["text-writing-mode"] = e3;
+ } else this.layout._values["text-writing-mode"] = ["horizontal"];
+ }
+ this._setPaintOverrides();
+ }
+ getValueAndResolveTokens(t4, e2, r2, n2) {
+ const i2 = this.layout.get(t4).evaluate(e2, {}, r2, n2), s2 = this._unevaluatedLayout._values[t4];
+ return s2.isDataDriven() || vn(s2.value) || !i2 ? i2 : function(t5, e3) {
+ return e3.replace(/{([^{}]+)}/g, (e4, r3) => t5 && r3 in t5 ? String(t5[r3]) : "");
+ }(e2.properties, i2);
+ }
+ createBucket(t4) {
+ return new dc(t4);
+ }
+ queryRadius() {
+ return 0;
+ }
+ queryIntersectsFeature() {
+ throw new Error("Should take a different path in FeatureIndex");
+ }
+ _setPaintOverrides() {
+ for (const t4 of gc.paint.overridableProperties) {
+ if (!vc.hasPaintOverride(this.layout, t4)) continue;
+ const e2 = this.paint.get(t4), r2 = new xc(e2), n2 = new xn(r2, e2.property.specification);
+ let i2 = null;
+ i2 = "constant" === e2.value.kind || "source" === e2.value.kind ? new wn("source", n2) : new _n("composite", n2, e2.value.zoomStops), this.paint._values[t4] = new Hi(e2.property, i2, e2.parameters);
+ }
+ }
+ _handleOverridablePaintPropertyUpdate(t4, e2, r2) {
+ return !(!this.layout || e2.isDataDriven() || r2.isDataDriven()) && vc.hasPaintOverride(this.layout, t4);
+ }
+ static hasPaintOverride(t4, e2) {
+ const r2 = t4.get("text-field"), n2 = gc.paint.properties[e2];
+ let i2 = false;
+ const s2 = (t5) => {
+ for (const e3 of t5) if (n2.overrides && n2.overrides.hasOverride(e3)) return void (i2 = true);
+ };
+ if ("constant" === r2.value.kind && r2.value.value instanceof Yt) s2(r2.value.value.sections);
+ else if ("source" === r2.value.kind) {
+ const t5 = (e4) => {
+ i2 || (e4 instanceof se && ne(e4.value) === mt ? s2(e4.value.sections) : e4 instanceof Ze ? s2(e4.sections) : e4.eachChild(t5));
+ }, e3 = r2.value;
+ e3._styleExpression && t5(e3._styleExpression.expression);
+ }
+ return i2;
+ }
+ }
+ let bc;
+ var wc = { get paint() {
+ return bc = bc || new rs({ "background-color": new Ji(G.paint_background["background-color"]), "background-pattern": new ts(G.paint_background["background-pattern"]), "background-opacity": new Ji(G.paint_background["background-opacity"]) });
+ } };
+ class _c extends is {
+ constructor(t4) {
+ super(t4, wc);
+ }
+ }
+ let Ac;
+ var Sc = { get paint() {
+ return Ac = Ac || new rs({ "raster-opacity": new Ji(G.paint_raster["raster-opacity"]), "raster-hue-rotate": new Ji(G.paint_raster["raster-hue-rotate"]), "raster-brightness-min": new Ji(G.paint_raster["raster-brightness-min"]), "raster-brightness-max": new Ji(G.paint_raster["raster-brightness-max"]), "raster-saturation": new Ji(G.paint_raster["raster-saturation"]), "raster-contrast": new Ji(G.paint_raster["raster-contrast"]), "raster-resampling": new Ji(G.paint_raster["raster-resampling"]), "raster-fade-duration": new Ji(G.paint_raster["raster-fade-duration"]) });
+ } };
+ class kc extends is {
+ constructor(t4) {
+ super(t4, Sc);
+ }
+ }
+ class Mc extends is {
+ constructor(t4) {
+ super(t4, {}), this.onAdd = (t5) => {
+ this.implementation.onAdd && this.implementation.onAdd(t5, t5.painter.context.gl);
+ }, this.onRemove = (t5) => {
+ this.implementation.onRemove && this.implementation.onRemove(t5, t5.painter.context.gl);
+ }, this.implementation = t4;
+ }
+ is3D() {
+ return "3d" === this.implementation.renderingMode;
+ }
+ hasOffscreenPass() {
+ return void 0 !== this.implementation.prerender;
+ }
+ recalculate() {
+ }
+ updateTransitions() {
+ }
+ hasTransition() {
+ return false;
+ }
+ serialize() {
+ throw new Error("Custom layers cannot be serialized");
+ }
+ }
+ class Ic {
+ constructor(t4) {
+ this._methodToThrottle = t4, this._triggered = false, "undefined" != typeof MessageChannel && (this._channel = new MessageChannel(), this._channel.port2.onmessage = () => {
+ this._triggered = false, this._methodToThrottle();
+ });
+ }
+ trigger() {
+ this._triggered || (this._triggered = true, this._channel ? this._channel.port1.postMessage(true) : setTimeout(() => {
+ this._triggered = false, this._methodToThrottle();
+ }, 0));
+ }
+ remove() {
+ delete this._channel, this._methodToThrottle = () => {
+ };
+ }
+ }
+ const zc = 63710088e-1;
+ class Pc {
+ constructor(t4, e2) {
+ if (isNaN(t4) || isNaN(e2)) throw new Error(`Invalid LngLat object: (${t4}, ${e2})`);
+ if (this.lng = +t4, this.lat = +e2, this.lat > 90 || this.lat < -90) throw new Error("Invalid LngLat latitude value: must be between -90 and 90");
+ }
+ wrap() {
+ return new Pc(m(this.lng, -180, 180), this.lat);
+ }
+ toArray() {
+ return [this.lng, this.lat];
+ }
+ toString() {
+ return `LngLat(${this.lng}, ${this.lat})`;
+ }
+ distanceTo(t4) {
+ const e2 = Math.PI / 180, r2 = this.lat * e2, n2 = t4.lat * e2, i2 = Math.sin(r2) * Math.sin(n2) + Math.cos(r2) * Math.cos(n2) * Math.cos((t4.lng - this.lng) * e2);
+ return zc * Math.acos(Math.min(i2, 1));
+ }
+ static convert(t4) {
+ if (t4 instanceof Pc) return t4;
+ if (Array.isArray(t4) && (2 === t4.length || 3 === t4.length)) return new Pc(Number(t4[0]), Number(t4[1]));
+ if (!Array.isArray(t4) && "object" == typeof t4 && null !== t4) return new Pc(Number("lng" in t4 ? t4.lng : t4.lon), Number(t4.lat));
+ throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng:
");
+ attributionText.text(multilineAttributions).attr("data-unformatted", multilineAttributions).call(svgTextUtils.convertToTspans, gd);
+ bBox = Drawing.bBox(attributionText.node());
+ }
+ attributionText.attr("transform", strTranslate(-3, -bBox.height + 8));
+ attributionGroup.insert("rect", ".static-attribution").attr({
+ x: -bBox.width - 6,
+ y: -bBox.height - 3,
+ width: bBox.width + 6,
+ height: bBox.height + 3,
+ fill: "rgba(255, 255, 255, 0.75)"
+ });
+ var scaleRatio = 1;
+ if (bBox.width + 6 > maxWidth) scaleRatio = maxWidth / (bBox.width + 6);
+ var offset = [size.l + size.w * domain.x[1], size.t + size.h * (1 - domain.y[0])];
+ attributionGroup.attr("transform", strTranslate(offset[0], offset[1]) + strScale(scaleRatio));
+ }
+ };
+ exports.updateFx = function(gd) {
+ var fullLayout = gd._fullLayout;
+ var subplotIds = fullLayout._subplots[MAP];
+ for (var i = 0; i < subplotIds.length; i++) {
+ var subplotObj = fullLayout[subplotIds[i]]._subplot;
+ subplotObj.updateFx(fullLayout);
+ }
+ };
+ }
+ });
+
+ // src/traces/scattermap/index.js
+ var require_scattermap = __commonJS({
+ "src/traces/scattermap/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes57(),
+ supplyDefaults: require_defaults53(),
+ colorbar: require_marker_colorbar(),
+ formatLabels: require_format_labels6(),
+ calc: require_calc27(),
+ plot: require_plot26(),
+ hoverPoints: require_hover20().hoverPoints,
+ eventData: require_event_data13(),
+ selectPoints: require_select10(),
+ styleOnSelect: function(_, cd) {
+ if (cd) {
+ var trace = cd[0].trace;
+ trace._glTrace.update(cd);
+ }
+ },
+ moduleType: "trace",
+ name: "scattermap",
+ basePlotModule: require_map3(),
+ categories: ["map", "gl", "symbols", "showLegend", "scatter-like"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/scattermap.js
+ var require_scattermap2 = __commonJS({
+ "lib/scattermap.js"(exports, module) {
+ "use strict";
+ module.exports = require_scattermap();
+ }
+ });
+
+ // src/traces/choroplethmap/attributes.js
+ var require_attributes58 = __commonJS({
+ "src/traces/choroplethmap/attributes.js"(exports, module) {
+ "use strict";
+ var choroplethAttrs = require_attributes49();
+ var colorScaleAttrs = require_attributes8();
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var baseAttrs = require_attributes2();
+ var extendFlat = require_extend().extendFlat;
+ module.exports = extendFlat(
+ {
+ locations: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ // TODO
+ // Maybe start with only one value (that we could name e.g. 'geojson-id'),
+ // but eventually:
+ // - we could also support for our own dist/topojson/*
+ // .. and locationmode: choroplethAttrs.locationmode,
+ z: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ // TODO maybe we could also set a "key" to dig out values out of the
+ // GeoJSON feature `properties` fields?
+ geojson: {
+ valType: "any",
+ editType: "calc"
+ },
+ featureidkey: extendFlat({}, choroplethAttrs.featureidkey, {}),
+ // TODO agree on name / behaviour
+ //
+ // 'below' is used currently for layout.map.layers,
+ // even though it's not very plotly-esque.
+ //
+ // Note also, that the map-gl style don't all have the same layers,
+ // see https://codepen.io/etpinard/pen/ydVMwM for full list
+ below: {
+ valType: "string",
+ editType: "plot"
+ },
+ text: choroplethAttrs.text,
+ hovertext: choroplethAttrs.hovertext,
+ marker: {
+ line: {
+ color: extendFlat({}, choroplethAttrs.marker.line.color, { editType: "plot" }),
+ width: extendFlat({}, choroplethAttrs.marker.line.width, { editType: "plot" }),
+ editType: "calc"
+ },
+ // TODO maybe having a dflt less than 1, together with `below:''` would be better?
+ opacity: extendFlat({}, choroplethAttrs.marker.opacity, { editType: "plot" }),
+ editType: "calc"
+ },
+ selected: {
+ marker: {
+ opacity: extendFlat({}, choroplethAttrs.selected.marker.opacity, { editType: "plot" }),
+ editType: "plot"
+ },
+ editType: "plot"
+ },
+ unselected: {
+ marker: {
+ opacity: extendFlat({}, choroplethAttrs.unselected.marker.opacity, { editType: "plot" }),
+ editType: "plot"
+ },
+ editType: "plot"
+ },
+ hoverinfo: choroplethAttrs.hoverinfo,
+ hovertemplate: hovertemplateAttrs({}, { keys: ["properties"] }),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ },
+ colorScaleAttrs("", {
+ cLetter: "z",
+ editTypeOverride: "calc"
+ })
+ );
+ }
+ });
+
+ // src/traces/choroplethmap/defaults.js
+ var require_defaults54 = __commonJS({
+ "src/traces/choroplethmap/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var colorscaleDefaults = require_defaults2();
+ var attributes = require_attributes58();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var locations = coerce("locations");
+ var z = coerce("z");
+ var geojson = coerce("geojson");
+ if (!Lib.isArrayOrTypedArray(locations) || !locations.length || !Lib.isArrayOrTypedArray(z) || !z.length || !(typeof geojson === "string" && geojson !== "" || Lib.isPlainObject(geojson))) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("featureidkey");
+ traceOut._length = Math.min(locations.length, z.length);
+ coerce("below");
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ var mlw = coerce("marker.line.width");
+ if (mlw) coerce("marker.line.color");
+ coerce("marker.opacity");
+ colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: "", cLetter: "z" });
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ }
+ });
+
+ // src/traces/choroplethmap/convert.js
+ var require_convert15 = __commonJS({
+ "src/traces/choroplethmap/convert.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var Lib = require_lib();
+ var Colorscale = require_colorscale();
+ var Drawing = require_drawing();
+ var makeBlank = require_geojson_utils().makeBlank;
+ var geoUtils = require_geo_location_utils();
+ function convert(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var isVisible = trace.visible === true && trace._length !== 0;
+ var fill = {
+ layout: { visibility: "none" },
+ paint: {}
+ };
+ var line = {
+ layout: { visibility: "none" },
+ paint: {}
+ };
+ var opts = trace._opts = {
+ fill,
+ line,
+ geojson: makeBlank()
+ };
+ if (!isVisible) return opts;
+ var features = geoUtils.extractTraceFeature(calcTrace);
+ if (!features) return opts;
+ var sclFunc = Colorscale.makeColorScaleFuncFromTrace(trace);
+ var marker = trace.marker;
+ var markerLine = marker.line || {};
+ var opacityFn;
+ if (Lib.isArrayOrTypedArray(marker.opacity)) {
+ opacityFn = function(d) {
+ var mo = d.mo;
+ return isNumeric(mo) ? +Lib.constrain(mo, 0, 1) : 0;
+ };
+ }
+ var lineColorFn;
+ if (Lib.isArrayOrTypedArray(markerLine.color)) {
+ lineColorFn = function(d) {
+ return d.mlc;
+ };
+ }
+ var lineWidthFn;
+ if (Lib.isArrayOrTypedArray(markerLine.width)) {
+ lineWidthFn = function(d) {
+ return d.mlw;
+ };
+ }
+ for (var i = 0; i < calcTrace.length; i++) {
+ var cdi = calcTrace[i];
+ var fOut = cdi.fOut;
+ if (fOut) {
+ var props = fOut.properties;
+ props.fc = sclFunc(cdi.z);
+ if (opacityFn) props.mo = opacityFn(cdi);
+ if (lineColorFn) props.mlc = lineColorFn(cdi);
+ if (lineWidthFn) props.mlw = lineWidthFn(cdi);
+ cdi.ct = props.ct;
+ cdi._polygons = geoUtils.feature2polygons(fOut);
+ }
+ }
+ var opacitySetting = opacityFn ? { type: "identity", property: "mo" } : marker.opacity;
+ Lib.extendFlat(fill.paint, {
+ "fill-color": { type: "identity", property: "fc" },
+ "fill-opacity": opacitySetting
+ });
+ Lib.extendFlat(line.paint, {
+ "line-color": lineColorFn ? { type: "identity", property: "mlc" } : markerLine.color,
+ "line-width": lineWidthFn ? { type: "identity", property: "mlw" } : markerLine.width,
+ "line-opacity": opacitySetting
+ });
+ fill.layout.visibility = "visible";
+ line.layout.visibility = "visible";
+ opts.geojson = { type: "FeatureCollection", features };
+ convertOnSelect(calcTrace);
+ return opts;
+ }
+ function convertOnSelect(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var opts = trace._opts;
+ var opacitySetting;
+ if (trace.selectedpoints) {
+ var fns = Drawing.makeSelectedPointStyleFns(trace);
+ for (var i = 0; i < calcTrace.length; i++) {
+ var cdi = calcTrace[i];
+ if (cdi.fOut) {
+ cdi.fOut.properties.mo2 = fns.selectedOpacityFn(cdi);
+ }
+ }
+ opacitySetting = { type: "identity", property: "mo2" };
+ } else {
+ opacitySetting = Lib.isArrayOrTypedArray(trace.marker.opacity) ? { type: "identity", property: "mo" } : trace.marker.opacity;
+ }
+ Lib.extendFlat(opts.fill.paint, { "fill-opacity": opacitySetting });
+ Lib.extendFlat(opts.line.paint, { "line-opacity": opacitySetting });
+ return opts;
+ }
+ module.exports = {
+ convert,
+ convertOnSelect
+ };
+ }
+ });
+
+ // src/traces/choroplethmap/plot.js
+ var require_plot27 = __commonJS({
+ "src/traces/choroplethmap/plot.js"(exports, module) {
+ "use strict";
+ var convert = require_convert15().convert;
+ var convertOnSelect = require_convert15().convertOnSelect;
+ var LAYER_PREFIX = require_constants27().traceLayerPrefix;
+ function ChoroplethMap(subplot, uid) {
+ this.type = "choroplethmap";
+ this.subplot = subplot;
+ this.uid = uid;
+ this.sourceId = "source-" + uid;
+ this.layerList = [
+ ["fill", LAYER_PREFIX + uid + "-fill"],
+ ["line", LAYER_PREFIX + uid + "-line"]
+ ];
+ this.below = null;
+ }
+ var proto = ChoroplethMap.prototype;
+ proto.update = function(calcTrace) {
+ this._update(convert(calcTrace));
+ calcTrace[0].trace._glTrace = this;
+ };
+ proto.updateOnSelect = function(calcTrace) {
+ this._update(convertOnSelect(calcTrace));
+ };
+ proto._update = function(optsAll) {
+ var subplot = this.subplot;
+ var layerList = this.layerList;
+ var below = subplot.belowLookup["trace-" + this.uid];
+ subplot.map.getSource(this.sourceId).setData(optsAll.geojson);
+ if (below !== this.below) {
+ this._removeLayers();
+ this._addLayers(optsAll, below);
+ this.below = below;
+ }
+ for (var i = 0; i < layerList.length; i++) {
+ var item = layerList[i];
+ var k = item[0];
+ var id = item[1];
+ var opts = optsAll[k];
+ subplot.setOptions(id, "setLayoutProperty", opts.layout);
+ if (opts.layout.visibility === "visible") {
+ subplot.setOptions(id, "setPaintProperty", opts.paint);
+ }
+ }
+ };
+ proto._addLayers = function(optsAll, below) {
+ var subplot = this.subplot;
+ var layerList = this.layerList;
+ var sourceId = this.sourceId;
+ for (var i = 0; i < layerList.length; i++) {
+ var item = layerList[i];
+ var k = item[0];
+ var opts = optsAll[k];
+ subplot.addLayer({
+ type: k,
+ id: item[1],
+ source: sourceId,
+ layout: opts.layout,
+ paint: opts.paint
+ }, below);
+ }
+ };
+ proto._removeLayers = function() {
+ var map = this.subplot.map;
+ var layerList = this.layerList;
+ for (var i = layerList.length - 1; i >= 0; i--) {
+ map.removeLayer(layerList[i][1]);
+ }
+ };
+ proto.dispose = function() {
+ var map = this.subplot.map;
+ this._removeLayers();
+ map.removeSource(this.sourceId);
+ };
+ module.exports = function createChoroplethMap(subplot, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var choroplethMap = new ChoroplethMap(subplot, trace.uid);
+ var sourceId = choroplethMap.sourceId;
+ var optsAll = convert(calcTrace);
+ var below = choroplethMap.below = subplot.belowLookup["trace-" + trace.uid];
+ subplot.map.addSource(sourceId, {
+ type: "geojson",
+ data: optsAll.geojson
+ });
+ choroplethMap._addLayers(optsAll, below);
+ calcTrace[0].trace._glTrace = choroplethMap;
+ return choroplethMap;
+ };
+ }
+ });
+
+ // src/traces/choroplethmap/index.js
+ var require_choroplethmap = __commonJS({
+ "src/traces/choroplethmap/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes58(),
+ supplyDefaults: require_defaults54(),
+ colorbar: require_colorbar2(),
+ calc: require_calc28(),
+ plot: require_plot27(),
+ hoverPoints: require_hover15(),
+ eventData: require_event_data10(),
+ selectPoints: require_select6(),
+ styleOnSelect: function(_, cd) {
+ if (cd) {
+ var trace = cd[0].trace;
+ trace._glTrace.updateOnSelect(cd);
+ }
+ },
+ getBelow: function(trace, subplot) {
+ var mapLayers = subplot.getMapLayers();
+ for (var i = mapLayers.length - 2; i >= 0; i--) {
+ var layerId = mapLayers[i].id;
+ if (typeof layerId === "string" && layerId.indexOf("water") === 0) {
+ for (var j = i + 1; j < mapLayers.length; j++) {
+ layerId = mapLayers[j].id;
+ if (typeof layerId === "string" && layerId.indexOf("plotly-") === -1) {
+ return layerId;
+ }
+ }
+ }
+ }
+ },
+ moduleType: "trace",
+ name: "choroplethmap",
+ basePlotModule: require_map3(),
+ categories: ["map", "gl", "noOpacity", "showLegend"],
+ meta: {
+ hr_name: "choropleth_map"
+ }
+ };
+ }
+ });
+
+ // lib/choroplethmap.js
+ var require_choroplethmap2 = __commonJS({
+ "lib/choroplethmap.js"(exports, module) {
+ "use strict";
+ module.exports = require_choroplethmap();
+ }
+ });
+
+ // src/traces/densitymap/attributes.js
+ var require_attributes59 = __commonJS({
+ "src/traces/densitymap/attributes.js"(exports, module) {
+ "use strict";
+ var colorScaleAttrs = require_attributes8();
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var baseAttrs = require_attributes2();
+ var scatterMapAttrs = require_attributes57();
+ var extendFlat = require_extend().extendFlat;
+ module.exports = extendFlat(
+ {
+ lon: scatterMapAttrs.lon,
+ lat: scatterMapAttrs.lat,
+ z: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ radius: {
+ valType: "number",
+ editType: "plot",
+ arrayOk: true,
+ min: 1,
+ dflt: 30
+ },
+ below: {
+ valType: "string",
+ editType: "plot"
+ },
+ text: scatterMapAttrs.text,
+ hovertext: scatterMapAttrs.hovertext,
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ flags: ["lon", "lat", "z", "text", "name"]
+ }),
+ hovertemplate: hovertemplateAttrs(),
+ showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
+ },
+ colorScaleAttrs("", {
+ cLetter: "z",
+ editTypeOverride: "calc"
+ })
+ );
+ }
+ });
+
+ // src/traces/densitymap/defaults.js
+ var require_defaults55 = __commonJS({
+ "src/traces/densitymap/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var colorscaleDefaults = require_defaults2();
+ var attributes = require_attributes59();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var lon = coerce("lon") || [];
+ var lat = coerce("lat") || [];
+ var len = Math.min(lon.length, lat.length);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ traceOut._length = len;
+ coerce("z");
+ coerce("radius");
+ coerce("below");
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ colorscaleDefaults(traceIn, traceOut, layout, coerce, { prefix: "", cLetter: "z" });
+ };
+ }
+ });
+
+ // src/traces/densitymap/calc.js
+ var require_calc34 = __commonJS({
+ "src/traces/densitymap/calc.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ var BADNUM = require_numerical().BADNUM;
+ var colorscaleCalc = require_calc();
+ var _ = require_lib()._;
+ module.exports = function calc(gd, trace) {
+ var len = trace._length;
+ var calcTrace = new Array(len);
+ var z = trace.z;
+ var hasZ = isArrayOrTypedArray(z) && z.length;
+ for (var i = 0; i < len; i++) {
+ var cdi = calcTrace[i] = {};
+ var lon = trace.lon[i];
+ var lat = trace.lat[i];
+ cdi.lonlat = isNumeric(lon) && isNumeric(lat) ? [+lon, +lat] : [BADNUM, BADNUM];
+ if (hasZ) {
+ var zi = z[i];
+ cdi.z = isNumeric(zi) ? zi : BADNUM;
+ }
+ }
+ colorscaleCalc(gd, trace, {
+ vals: hasZ ? z : [0, 1],
+ containerStr: "",
+ cLetter: "z"
+ });
+ if (len) {
+ calcTrace[0].t = {
+ labels: {
+ lat: _(gd, "lat:") + " ",
+ lon: _(gd, "lon:") + " "
+ }
+ };
+ }
+ return calcTrace;
+ };
+ }
+ });
+
+ // src/traces/densitymap/convert.js
+ var require_convert16 = __commonJS({
+ "src/traces/densitymap/convert.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var Lib = require_lib();
+ var Color2 = require_color();
+ var Colorscale = require_colorscale();
+ var BADNUM = require_numerical().BADNUM;
+ var makeBlank = require_geojson_utils().makeBlank;
+ module.exports = function convert(calcTrace) {
+ var trace = calcTrace[0].trace;
+ var isVisible = trace.visible === true && trace._length !== 0;
+ var heatmap = {
+ layout: { visibility: "none" },
+ paint: {}
+ };
+ var opts = trace._opts = {
+ heatmap,
+ geojson: makeBlank()
+ };
+ if (!isVisible) return opts;
+ var features = [];
+ var i;
+ var z = trace.z;
+ var radius = trace.radius;
+ var hasZ = Lib.isArrayOrTypedArray(z) && z.length;
+ var hasArrayRadius = Lib.isArrayOrTypedArray(radius);
+ for (i = 0; i < calcTrace.length; i++) {
+ var cdi = calcTrace[i];
+ var lonlat = cdi.lonlat;
+ if (lonlat[0] !== BADNUM) {
+ var props = {};
+ if (hasZ) {
+ var zi = cdi.z;
+ props.z = zi !== BADNUM ? zi : 0;
+ }
+ if (hasArrayRadius) {
+ props.r = isNumeric(radius[i]) && radius[i] > 0 ? +radius[i] : 0;
+ }
+ features.push({
+ type: "Feature",
+ geometry: { type: "Point", coordinates: lonlat },
+ properties: props
+ });
+ }
+ }
+ var cOpts = Colorscale.extractOpts(trace);
+ var scl = cOpts.reversescale ? Colorscale.flipScale(cOpts.colorscale) : cOpts.colorscale;
+ var scl01 = scl[0][1];
+ var color0 = Color2.opacity(scl01) < 1 ? scl01 : Color2.addOpacity(scl01, 0);
+ var heatmapColor = [
+ "interpolate",
+ ["linear"],
+ ["heatmap-density"],
+ 0,
+ color0
+ ];
+ for (i = 1; i < scl.length; i++) {
+ heatmapColor.push(scl[i][0], scl[i][1]);
+ }
+ var zExp = [
+ "interpolate",
+ ["linear"],
+ ["get", "z"],
+ cOpts.min,
+ 0,
+ cOpts.max,
+ 1
+ ];
+ Lib.extendFlat(opts.heatmap.paint, {
+ "heatmap-weight": hasZ ? zExp : 1 / (cOpts.max - cOpts.min),
+ "heatmap-color": heatmapColor,
+ "heatmap-radius": hasArrayRadius ? { type: "identity", property: "r" } : trace.radius,
+ "heatmap-opacity": trace.opacity
+ });
+ opts.geojson = { type: "FeatureCollection", features };
+ opts.heatmap.layout.visibility = "visible";
+ return opts;
+ };
+ }
+ });
+
+ // src/traces/densitymap/plot.js
+ var require_plot28 = __commonJS({
+ "src/traces/densitymap/plot.js"(exports, module) {
+ "use strict";
+ var convert = require_convert16();
+ var LAYER_PREFIX = require_constants27().traceLayerPrefix;
+ function DensityMap(subplot, uid) {
+ this.type = "densitymap";
+ this.subplot = subplot;
+ this.uid = uid;
+ this.sourceId = "source-" + uid;
+ this.layerList = [
+ ["heatmap", LAYER_PREFIX + uid + "-heatmap"]
+ ];
+ this.below = null;
+ }
+ var proto = DensityMap.prototype;
+ proto.update = function(calcTrace) {
+ var subplot = this.subplot;
+ var layerList = this.layerList;
+ var optsAll = convert(calcTrace);
+ var below = subplot.belowLookup["trace-" + this.uid];
+ subplot.map.getSource(this.sourceId).setData(optsAll.geojson);
+ if (below !== this.below) {
+ this._removeLayers();
+ this._addLayers(optsAll, below);
+ this.below = below;
+ }
+ for (var i = 0; i < layerList.length; i++) {
+ var item = layerList[i];
+ var k = item[0];
+ var id = item[1];
+ var opts = optsAll[k];
+ subplot.setOptions(id, "setLayoutProperty", opts.layout);
+ if (opts.layout.visibility === "visible") {
+ subplot.setOptions(id, "setPaintProperty", opts.paint);
+ }
+ }
+ };
+ proto._addLayers = function(optsAll, below) {
+ var subplot = this.subplot;
+ var layerList = this.layerList;
+ var sourceId = this.sourceId;
+ for (var i = 0; i < layerList.length; i++) {
+ var item = layerList[i];
+ var k = item[0];
+ var opts = optsAll[k];
+ subplot.addLayer({
+ type: k,
+ id: item[1],
+ source: sourceId,
+ layout: opts.layout,
+ paint: opts.paint
+ }, below);
+ }
+ };
+ proto._removeLayers = function() {
+ var map = this.subplot.map;
+ var layerList = this.layerList;
+ for (var i = layerList.length - 1; i >= 0; i--) {
+ map.removeLayer(layerList[i][1]);
+ }
+ };
+ proto.dispose = function() {
+ var map = this.subplot.map;
+ this._removeLayers();
+ map.removeSource(this.sourceId);
+ };
+ module.exports = function createDensityMap(subplot, calcTrace) {
+ var trace = calcTrace[0].trace;
+ var densityMap = new DensityMap(subplot, trace.uid);
+ var sourceId = densityMap.sourceId;
+ var optsAll = convert(calcTrace);
+ var below = densityMap.below = subplot.belowLookup["trace-" + trace.uid];
+ subplot.map.addSource(sourceId, {
+ type: "geojson",
+ data: optsAll.geojson
+ });
+ densityMap._addLayers(optsAll, below);
+ return densityMap;
+ };
+ }
+ });
+
+ // src/traces/densitymap/hover.js
+ var require_hover21 = __commonJS({
+ "src/traces/densitymap/hover.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ var scatterMapHoverPoints = require_hover20().hoverPoints;
+ var getExtraText = require_hover20().getExtraText;
+ module.exports = function hoverPoints(pointData, xval, yval) {
+ var pts = scatterMapHoverPoints(pointData, xval, yval);
+ if (!pts) return;
+ var newPointData = pts[0];
+ var cd = newPointData.cd;
+ var trace = cd[0].trace;
+ var di = cd[newPointData.index];
+ delete newPointData.color;
+ if ("z" in di) {
+ var ax = newPointData.subplot.mockAxis;
+ newPointData.z = di.z;
+ newPointData.zLabel = Axes.tickText(ax, ax.c2l(di.z), "hover").text;
+ }
+ newPointData.extraText = getExtraText(trace, di, cd[0].t.labels);
+ return [newPointData];
+ };
+ }
+ });
+
+ // src/traces/densitymap/event_data.js
+ var require_event_data14 = __commonJS({
+ "src/traces/densitymap/event_data.js"(exports, module) {
+ "use strict";
+ module.exports = function eventData(out, pt) {
+ out.lon = pt.lon;
+ out.lat = pt.lat;
+ out.z = pt.z;
+ return out;
+ };
+ }
+ });
+
+ // src/traces/densitymap/index.js
+ var require_densitymap = __commonJS({
+ "src/traces/densitymap/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes59(),
+ supplyDefaults: require_defaults55(),
+ colorbar: require_colorbar2(),
+ formatLabels: require_format_labels6(),
+ calc: require_calc34(),
+ plot: require_plot28(),
+ hoverPoints: require_hover21(),
+ eventData: require_event_data14(),
+ getBelow: function(trace, subplot) {
+ var mapLayers = subplot.getMapLayers();
+ for (var i = 0; i < mapLayers.length; i++) {
+ var layer = mapLayers[i];
+ var layerId = layer.id;
+ if (layer.type === "symbol" && typeof layerId === "string" && layerId.indexOf("plotly-") === -1) {
+ return layerId;
+ }
+ }
+ },
+ moduleType: "trace",
+ name: "densitymap",
+ basePlotModule: require_map3(),
+ categories: ["map", "gl", "showLegend"],
+ meta: {
+ hr_name: "density_map"
+ }
+ };
+ }
+ });
+
+ // lib/densitymap.js
+ var require_densitymap2 = __commonJS({
+ "lib/densitymap.js"(exports, module) {
+ "use strict";
+ module.exports = require_densitymap();
+ }
+ });
+
+ // src/traces/sankey/attributes.js
+ var require_attributes60 = __commonJS({
+ "src/traces/sankey/attributes.js"(exports, module) {
+ "use strict";
+ var fontAttrs = require_font_attributes();
+ var baseAttrs = require_attributes2();
+ var colorAttrs = require_attributes3();
+ var fxAttrs = require_attributes();
+ var domainAttrs = require_domain().attributes;
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var colorAttributes = require_attributes8();
+ var templatedArray = require_plot_template().templatedArray;
+ var descriptionOnlyNumbers = require_axis_format_attributes().descriptionOnlyNumbers;
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var attrs = module.exports = overrideAll({
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ flags: [],
+ arrayOk: false
+ }),
+ hoverlabel: fxAttrs.hoverlabel,
+ domain: domainAttrs({ name: "sankey", trace: true }),
+ orientation: {
+ valType: "enumerated",
+ values: ["v", "h"],
+ dflt: "h"
+ },
+ valueformat: {
+ valType: "string",
+ dflt: ".3s",
+ description: descriptionOnlyNumbers("value")
+ },
+ valuesuffix: {
+ valType: "string",
+ dflt: ""
+ },
+ arrangement: {
+ valType: "enumerated",
+ values: ["snap", "perpendicular", "freeform", "fixed"],
+ dflt: "snap"
+ },
+ textfont: fontAttrs({
+ autoShadowDflt: true
+ }),
+ // Remove top-level customdata
+ customdata: void 0,
+ node: {
+ label: {
+ valType: "data_array",
+ dflt: []
+ },
+ groups: {
+ valType: "info_array",
+ impliedEdits: { x: [], y: [] },
+ dimensions: 2,
+ freeLength: true,
+ dflt: [],
+ items: { valType: "number", editType: "calc" }
+ },
+ x: {
+ valType: "data_array",
+ dflt: []
+ },
+ y: {
+ valType: "data_array",
+ dflt: []
+ },
+ color: {
+ valType: "color",
+ arrayOk: true
+ },
+ customdata: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ line: {
+ color: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine,
+ arrayOk: true
+ },
+ width: {
+ valType: "number",
+ min: 0,
+ dflt: 0.5,
+ arrayOk: true
+ }
+ },
+ pad: {
+ valType: "number",
+ arrayOk: false,
+ min: 0,
+ dflt: 20
+ },
+ thickness: {
+ valType: "number",
+ arrayOk: false,
+ min: 1,
+ dflt: 20
+ },
+ hoverinfo: {
+ valType: "enumerated",
+ values: ["all", "none", "skip"],
+ dflt: "all"
+ },
+ hoverlabel: fxAttrs.hoverlabel,
+ // needs editType override,
+ hovertemplate: hovertemplateAttrs({}, {
+ keys: ["value", "label"]
+ }),
+ align: {
+ valType: "enumerated",
+ values: ["justify", "left", "right", "center"],
+ dflt: "justify"
+ }
+ },
+ link: {
+ arrowlen: {
+ valType: "number",
+ min: 0,
+ dflt: 0
+ },
+ label: {
+ valType: "data_array",
+ dflt: []
+ },
+ color: {
+ valType: "color",
+ arrayOk: true
+ },
+ hovercolor: {
+ valType: "color",
+ arrayOk: true
+ },
+ customdata: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ line: {
+ color: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine,
+ arrayOk: true
+ },
+ width: {
+ valType: "number",
+ min: 0,
+ dflt: 0,
+ arrayOk: true
+ }
+ },
+ source: {
+ valType: "data_array",
+ dflt: []
+ },
+ target: {
+ valType: "data_array",
+ dflt: []
+ },
+ value: {
+ valType: "data_array",
+ dflt: []
+ },
+ hoverinfo: {
+ valType: "enumerated",
+ values: ["all", "none", "skip"],
+ dflt: "all"
+ },
+ hoverlabel: fxAttrs.hoverlabel,
+ // needs editType override,
+ hovertemplate: hovertemplateAttrs({}, {
+ keys: ["value", "label"]
+ }),
+ colorscales: templatedArray("concentrationscales", {
+ editType: "calc",
+ label: {
+ valType: "string",
+ editType: "calc",
+ dflt: ""
+ },
+ cmax: {
+ valType: "number",
+ editType: "calc",
+ dflt: 1
+ },
+ cmin: {
+ valType: "number",
+ editType: "calc",
+ dflt: 0
+ },
+ colorscale: extendFlat(colorAttributes().colorscale, { dflt: [[0, "white"], [1, "black"]] })
+ })
+ }
+ }, "calc", "nested");
+ }
+ });
+
+ // src/traces/sankey/defaults.js
+ var require_defaults56 = __commonJS({
+ "src/traces/sankey/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var attributes = require_attributes60();
+ var Color2 = require_color();
+ var tinycolor = require_tinycolor();
+ var handleDomainDefaults = require_domain().defaults;
+ var handleHoverLabelDefaults = require_hoverlabel_defaults();
+ var Template = require_plot_template();
+ var handleArrayContainerDefaults = require_array_container_defaults();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var hoverlabelDefault = Lib.extendDeep(layout.hoverlabel, traceIn.hoverlabel);
+ var nodeIn = traceIn.node;
+ var nodeOut = Template.newContainer(traceOut, "node");
+ function coerceNode(attr, dflt) {
+ return Lib.coerce(nodeIn, nodeOut, attributes.node, attr, dflt);
+ }
+ coerceNode("label");
+ coerceNode("groups");
+ coerceNode("x");
+ coerceNode("y");
+ coerceNode("pad");
+ coerceNode("thickness");
+ coerceNode("line.color");
+ coerceNode("line.width");
+ coerceNode("hoverinfo", traceIn.hoverinfo);
+ handleHoverLabelDefaults(nodeIn, nodeOut, coerceNode, hoverlabelDefault);
+ coerceNode("hovertemplate");
+ coerceNode("align");
+ var colors = layout.colorway;
+ var defaultNodePalette = function(i) {
+ return colors[i % colors.length];
+ };
+ coerceNode("color", nodeOut.label.map(function(d, i) {
+ return Color2.addOpacity(defaultNodePalette(i), 0.8);
+ }));
+ coerceNode("customdata");
+ var linkIn = traceIn.link || {};
+ var linkOut = Template.newContainer(traceOut, "link");
+ function coerceLink(attr, dflt) {
+ return Lib.coerce(linkIn, linkOut, attributes.link, attr, dflt);
+ }
+ coerceLink("label");
+ coerceLink("arrowlen");
+ coerceLink("source");
+ coerceLink("target");
+ coerceLink("value");
+ coerceLink("line.color");
+ coerceLink("line.width");
+ coerceLink("hoverinfo", traceIn.hoverinfo);
+ handleHoverLabelDefaults(linkIn, linkOut, coerceLink, hoverlabelDefault);
+ coerceLink("hovertemplate");
+ var darkBG = tinycolor(layout.paper_bgcolor).getLuminance() < 0.333;
+ var defaultLinkColor = darkBG ? "rgba(255, 255, 255, 0.6)" : "rgba(0, 0, 0, 0.2)";
+ var linkColor = coerceLink("color", defaultLinkColor);
+ function makeDefaultHoverColor(_linkColor) {
+ var tc = tinycolor(_linkColor);
+ if (!tc.isValid()) {
+ return _linkColor;
+ }
+ var alpha = tc.getAlpha();
+ if (alpha <= 0.8) {
+ tc.setAlpha(alpha + 0.2);
+ } else {
+ tc = darkBG ? tc.brighten() : tc.darken();
+ }
+ return tc.toRgbString();
+ }
+ coerceLink(
+ "hovercolor",
+ Array.isArray(linkColor) ? linkColor.map(makeDefaultHoverColor) : makeDefaultHoverColor(linkColor)
+ );
+ coerceLink("customdata");
+ handleArrayContainerDefaults(linkIn, linkOut, {
+ name: "colorscales",
+ handleItemDefaults: concentrationscalesDefaults
+ });
+ handleDomainDefaults(traceOut, layout, coerce);
+ coerce("orientation");
+ coerce("valueformat");
+ coerce("valuesuffix");
+ var dfltArrangement;
+ if (nodeOut.x.length && nodeOut.y.length) {
+ dfltArrangement = "freeform";
+ }
+ coerce("arrangement", dfltArrangement);
+ Lib.coerceFont(coerce, "textfont", layout.font, { autoShadowDflt: true });
+ traceOut._length = null;
+ };
+ function concentrationscalesDefaults(In, Out) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(In, Out, attributes.link.colorscales, attr, dflt);
+ }
+ coerce("label");
+ coerce("cmin");
+ coerce("cmax");
+ coerce("colorscale");
+ }
+ }
+ });
+
+ // node_modules/strongly-connected-components/scc.js
+ var require_scc = __commonJS({
+ "node_modules/strongly-connected-components/scc.js"(exports, module) {
+ "use strict";
+ module.exports = stronglyConnectedComponents;
+ function stronglyConnectedComponents(adjList) {
+ var numVertices = adjList.length;
+ var index = new Array(numVertices);
+ var lowValue = new Array(numVertices);
+ var active = new Array(numVertices);
+ var child = new Array(numVertices);
+ var scc = new Array(numVertices);
+ var sccLinks = new Array(numVertices);
+ for (var i = 0; i < numVertices; ++i) {
+ index[i] = -1;
+ lowValue[i] = 0;
+ active[i] = false;
+ child[i] = 0;
+ scc[i] = -1;
+ sccLinks[i] = [];
+ }
+ var count = 0;
+ var components = [];
+ var sccAdjList = [];
+ function strongConnect(v) {
+ var S = [v], T = [v];
+ index[v] = lowValue[v] = count;
+ active[v] = true;
+ count += 1;
+ while (T.length > 0) {
+ v = T[T.length - 1];
+ var e2 = adjList[v];
+ if (child[v] < e2.length) {
+ for (var i2 = child[v]; i2 < e2.length; ++i2) {
+ var u = e2[i2];
+ if (index[u] < 0) {
+ index[u] = lowValue[u] = count;
+ active[u] = true;
+ count += 1;
+ S.push(u);
+ T.push(u);
+ break;
+ } else if (active[u]) {
+ lowValue[v] = Math.min(lowValue[v], lowValue[u]) | 0;
+ }
+ if (scc[u] >= 0) {
+ sccLinks[v].push(scc[u]);
+ }
+ }
+ child[v] = i2;
+ } else {
+ if (lowValue[v] === index[v]) {
+ var component = [];
+ var links = [], linkCount = 0;
+ for (var i2 = S.length - 1; i2 >= 0; --i2) {
+ var w = S[i2];
+ active[w] = false;
+ component.push(w);
+ links.push(sccLinks[w]);
+ linkCount += sccLinks[w].length;
+ scc[w] = components.length;
+ if (w === v) {
+ S.length = i2;
+ break;
+ }
+ }
+ components.push(component);
+ var allLinks = new Array(linkCount);
+ for (var i2 = 0; i2 < links.length; i2++) {
+ for (var j2 = 0; j2 < links[i2].length; j2++) {
+ allLinks[--linkCount] = links[i2][j2];
+ }
+ }
+ sccAdjList.push(allLinks);
+ }
+ T.pop();
+ }
+ }
+ }
+ for (var i = 0; i < numVertices; ++i) {
+ if (index[i] < 0) {
+ strongConnect(i);
+ }
+ }
+ var newE;
+ for (var i = 0; i < sccAdjList.length; i++) {
+ var e = sccAdjList[i];
+ if (e.length === 0) continue;
+ e.sort(function(a, b) {
+ return a - b;
+ });
+ newE = [e[0]];
+ for (var j = 1; j < e.length; j++) {
+ if (e[j] !== e[j - 1]) {
+ newE.push(e[j]);
+ }
+ }
+ sccAdjList[i] = newE;
+ }
+ return { components, adjacencyList: sccAdjList };
+ }
+ }
+ });
+
+ // src/traces/sankey/calc.js
+ var require_calc35 = __commonJS({
+ "src/traces/sankey/calc.js"(exports, module) {
+ "use strict";
+ var tarjan = require_scc();
+ var Lib = require_lib();
+ var wrap = require_gup().wrap;
+ var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
+ var isIndex = Lib.isIndex;
+ var Colorscale = require_colorscale();
+ function convertToD3Sankey(trace) {
+ var nodeSpec = trace.node;
+ var linkSpec = trace.link;
+ var links = [];
+ var hasLinkColorArray = isArrayOrTypedArray(linkSpec.color);
+ var hasLinkHoverColorArray = isArrayOrTypedArray(linkSpec.hovercolor);
+ var hasLinkCustomdataArray = isArrayOrTypedArray(linkSpec.customdata);
+ var linkedNodes = {};
+ var components = {};
+ var componentCount = linkSpec.colorscales.length;
+ var i;
+ for (i = 0; i < componentCount; i++) {
+ var cscale = linkSpec.colorscales[i];
+ var specs = Colorscale.extractScale(cscale, { cLetter: "c" });
+ var scale = Colorscale.makeColorScaleFunc(specs);
+ components[cscale.label] = scale;
+ }
+ var maxNodeId = 0;
+ for (i = 0; i < linkSpec.value.length; i++) {
+ if (linkSpec.source[i] > maxNodeId) maxNodeId = linkSpec.source[i];
+ if (linkSpec.target[i] > maxNodeId) maxNodeId = linkSpec.target[i];
+ }
+ var nodeCount = maxNodeId + 1;
+ trace.node._count = nodeCount;
+ var j;
+ var groups = trace.node.groups;
+ var groupLookup = {};
+ for (i = 0; i < groups.length; i++) {
+ var group = groups[i];
+ for (j = 0; j < group.length; j++) {
+ var nodeIndex = group[j];
+ var groupIndex = nodeCount + i;
+ if (groupLookup.hasOwnProperty(nodeIndex)) {
+ Lib.warn("Node " + nodeIndex + " is already part of a group.");
+ } else {
+ groupLookup[nodeIndex] = groupIndex;
+ }
+ }
+ }
+ var groupedLinks = {
+ source: [],
+ target: []
+ };
+ for (i = 0; i < linkSpec.value.length; i++) {
+ var val = linkSpec.value[i];
+ var source = linkSpec.source[i];
+ var target = linkSpec.target[i];
+ if (!(val > 0 && isIndex(source, nodeCount) && isIndex(target, nodeCount))) {
+ continue;
+ }
+ if (groupLookup.hasOwnProperty(source) && groupLookup.hasOwnProperty(target) && groupLookup[source] === groupLookup[target]) {
+ continue;
+ }
+ if (groupLookup.hasOwnProperty(target)) {
+ target = groupLookup[target];
+ }
+ if (groupLookup.hasOwnProperty(source)) {
+ source = groupLookup[source];
+ }
+ source = +source;
+ target = +target;
+ linkedNodes[source] = linkedNodes[target] = true;
+ var label = "";
+ if (linkSpec.label && linkSpec.label[i]) label = linkSpec.label[i];
+ var concentrationscale = null;
+ if (label && components.hasOwnProperty(label)) concentrationscale = components[label];
+ links.push({
+ pointNumber: i,
+ label,
+ color: hasLinkColorArray ? linkSpec.color[i] : linkSpec.color,
+ hovercolor: hasLinkHoverColorArray ? linkSpec.hovercolor[i] : linkSpec.hovercolor,
+ customdata: hasLinkCustomdataArray ? linkSpec.customdata[i] : linkSpec.customdata,
+ concentrationscale,
+ source,
+ target,
+ value: +val
+ });
+ groupedLinks.source.push(source);
+ groupedLinks.target.push(target);
+ }
+ var totalCount = nodeCount + groups.length;
+ var hasNodeColorArray = isArrayOrTypedArray(nodeSpec.color);
+ var hasNodeCustomdataArray = isArrayOrTypedArray(nodeSpec.customdata);
+ var nodes = [];
+ for (i = 0; i < totalCount; i++) {
+ if (!linkedNodes[i]) continue;
+ var l = nodeSpec.label[i];
+ nodes.push({
+ group: i > nodeCount - 1,
+ childrenNodes: [],
+ pointNumber: i,
+ label: l,
+ color: hasNodeColorArray ? nodeSpec.color[i] : nodeSpec.color,
+ customdata: hasNodeCustomdataArray ? nodeSpec.customdata[i] : nodeSpec.customdata
+ });
+ }
+ var circular = false;
+ if (circularityPresent(totalCount, groupedLinks.source, groupedLinks.target)) {
+ circular = true;
+ }
+ return {
+ circular,
+ links,
+ nodes,
+ // Data structure for groups
+ groups,
+ groupLookup
+ };
+ }
+ function circularityPresent(nodeLen, sources, targets) {
+ var nodes = Lib.init2dArray(nodeLen, 0);
+ for (var i = 0; i < Math.min(sources.length, targets.length); i++) {
+ if (Lib.isIndex(sources[i], nodeLen) && Lib.isIndex(targets[i], nodeLen)) {
+ if (sources[i] === targets[i]) {
+ return true;
+ }
+ nodes[sources[i]].push(targets[i]);
+ }
+ }
+ var scc = tarjan(nodes);
+ return scc.components.some(function(c) {
+ return c.length > 1;
+ });
+ }
+ module.exports = function calc(gd, trace) {
+ var result = convertToD3Sankey(trace);
+ return wrap({
+ circular: result.circular,
+ _nodes: result.nodes,
+ _links: result.links,
+ // Data structure for grouping
+ _groups: result.groups,
+ _groupLookup: result.groupLookup
+ });
+ };
+ }
+ });
+
+ // node_modules/d3-quadtree/dist/d3-quadtree.js
+ var require_d3_quadtree = __commonJS({
+ "node_modules/d3-quadtree/dist/d3-quadtree.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && false ? define(["exports"], factory) : (global2 = global2 || self, factory(global2.d3 = global2.d3 || {}));
+ })(exports, function(exports2) {
+ "use strict";
+ function tree_add(d) {
+ var x = +this._x.call(null, d), y = +this._y.call(null, d);
+ return add(this.cover(x, y), x, y, d);
+ }
+ function add(tree, x, y, d) {
+ if (isNaN(x) || isNaN(y)) return tree;
+ var parent, node = tree._root, leaf = { data: d }, x0 = tree._x0, y0 = tree._y0, x1 = tree._x1, y1 = tree._y1, xm, ym, xp, yp, right, bottom, i, j;
+ if (!node) return tree._root = leaf, tree;
+ while (node.length) {
+ if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm;
+ else x1 = xm;
+ if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym;
+ else y1 = ym;
+ if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree;
+ }
+ xp = +tree._x.call(null, node.data);
+ yp = +tree._y.call(null, node.data);
+ if (x === xp && y === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
+ do {
+ parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
+ if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm;
+ else x1 = xm;
+ if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym;
+ else y1 = ym;
+ } while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | xp >= xm));
+ return parent[j] = node, parent[i] = leaf, tree;
+ }
+ function addAll(data) {
+ var d, i, n = data.length, x, y, xz = new Array(n), yz = new Array(n), x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
+ for (i = 0; i < n; ++i) {
+ if (isNaN(x = +this._x.call(null, d = data[i])) || isNaN(y = +this._y.call(null, d))) continue;
+ xz[i] = x;
+ yz[i] = y;
+ if (x < x0) x0 = x;
+ if (x > x1) x1 = x;
+ if (y < y0) y0 = y;
+ if (y > y1) y1 = y;
+ }
+ if (x0 > x1 || y0 > y1) return this;
+ this.cover(x0, y0).cover(x1, y1);
+ for (i = 0; i < n; ++i) {
+ add(this, xz[i], yz[i], data[i]);
+ }
+ return this;
+ }
+ function tree_cover(x, y) {
+ if (isNaN(x = +x) || isNaN(y = +y)) return this;
+ var x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1;
+ if (isNaN(x0)) {
+ x1 = (x0 = Math.floor(x)) + 1;
+ y1 = (y0 = Math.floor(y)) + 1;
+ } else {
+ var z = x1 - x0, node = this._root, parent, i;
+ while (x0 > x || x >= x1 || y0 > y || y >= y1) {
+ i = (y < y0) << 1 | x < x0;
+ parent = new Array(4), parent[i] = node, node = parent, z *= 2;
+ switch (i) {
+ case 0:
+ x1 = x0 + z, y1 = y0 + z;
+ break;
+ case 1:
+ x0 = x1 - z, y1 = y0 + z;
+ break;
+ case 2:
+ x1 = x0 + z, y0 = y1 - z;
+ break;
+ case 3:
+ x0 = x1 - z, y0 = y1 - z;
+ break;
+ }
+ }
+ if (this._root && this._root.length) this._root = node;
+ }
+ this._x0 = x0;
+ this._y0 = y0;
+ this._x1 = x1;
+ this._y1 = y1;
+ return this;
+ }
+ function tree_data() {
+ var data = [];
+ this.visit(function(node) {
+ if (!node.length) do
+ data.push(node.data);
+ while (node = node.next);
+ });
+ return data;
+ }
+ function tree_extent(_) {
+ return arguments.length ? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0], [this._x1, this._y1]];
+ }
+ function Quad(node, x0, y0, x1, y1) {
+ this.node = node;
+ this.x0 = x0;
+ this.y0 = y0;
+ this.x1 = x1;
+ this.y1 = y1;
+ }
+ function tree_find(x, y, radius) {
+ var data, x0 = this._x0, y0 = this._y0, x1, y1, x2, y2, x3 = this._x1, y3 = this._y1, quads = [], node = this._root, q, i;
+ if (node) quads.push(new Quad(node, x0, y0, x3, y3));
+ if (radius == null) radius = Infinity;
+ else {
+ x0 = x - radius, y0 = y - radius;
+ x3 = x + radius, y3 = y + radius;
+ radius *= radius;
+ }
+ while (q = quads.pop()) {
+ if (!(node = q.node) || (x1 = q.x0) > x3 || (y1 = q.y0) > y3 || (x2 = q.x1) < x0 || (y2 = q.y1) < y0) continue;
+ if (node.length) {
+ var xm = (x1 + x2) / 2, ym = (y1 + y2) / 2;
+ quads.push(
+ new Quad(node[3], xm, ym, x2, y2),
+ new Quad(node[2], x1, ym, xm, y2),
+ new Quad(node[1], xm, y1, x2, ym),
+ new Quad(node[0], x1, y1, xm, ym)
+ );
+ if (i = (y >= ym) << 1 | x >= xm) {
+ q = quads[quads.length - 1];
+ quads[quads.length - 1] = quads[quads.length - 1 - i];
+ quads[quads.length - 1 - i] = q;
+ }
+ } else {
+ var dx = x - +this._x.call(null, node.data), dy = y - +this._y.call(null, node.data), d2 = dx * dx + dy * dy;
+ if (d2 < radius) {
+ var d = Math.sqrt(radius = d2);
+ x0 = x - d, y0 = y - d;
+ x3 = x + d, y3 = y + d;
+ data = node.data;
+ }
+ }
+ }
+ return data;
+ }
+ function tree_remove(d) {
+ if (isNaN(x = +this._x.call(null, d)) || isNaN(y = +this._y.call(null, d))) return this;
+ var parent, node = this._root, retainer, previous, next, x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1, x, y, xm, ym, right, bottom, i, j;
+ if (!node) return this;
+ if (node.length) while (true) {
+ if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm;
+ else x1 = xm;
+ if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym;
+ else y1 = ym;
+ if (!(parent = node, node = node[i = bottom << 1 | right])) return this;
+ if (!node.length) break;
+ if (parent[i + 1 & 3] || parent[i + 2 & 3] || parent[i + 3 & 3]) retainer = parent, j = i;
+ }
+ while (node.data !== d) if (!(previous = node, node = node.next)) return this;
+ if (next = node.next) delete node.next;
+ if (previous) return next ? previous.next = next : delete previous.next, this;
+ if (!parent) return this._root = next, this;
+ next ? parent[i] = next : delete parent[i];
+ if ((node = parent[0] || parent[1] || parent[2] || parent[3]) && node === (parent[3] || parent[2] || parent[1] || parent[0]) && !node.length) {
+ if (retainer) retainer[j] = node;
+ else this._root = node;
+ }
+ return this;
+ }
+ function removeAll(data) {
+ for (var i = 0, n = data.length; i < n; ++i) this.remove(data[i]);
+ return this;
+ }
+ function tree_root() {
+ return this._root;
+ }
+ function tree_size() {
+ var size = 0;
+ this.visit(function(node) {
+ if (!node.length) do
+ ++size;
+ while (node = node.next);
+ });
+ return size;
+ }
+ function tree_visit(callback) {
+ var quads = [], q, node = this._root, child, x0, y0, x1, y1;
+ if (node) quads.push(new Quad(node, this._x0, this._y0, this._x1, this._y1));
+ while (q = quads.pop()) {
+ if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
+ var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
+ if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
+ if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
+ if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
+ if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
+ }
+ }
+ return this;
+ }
+ function tree_visitAfter(callback) {
+ var quads = [], next = [], q;
+ if (this._root) quads.push(new Quad(this._root, this._x0, this._y0, this._x1, this._y1));
+ while (q = quads.pop()) {
+ var node = q.node;
+ if (node.length) {
+ var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
+ if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
+ if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
+ if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
+ if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
+ }
+ next.push(q);
+ }
+ while (q = next.pop()) {
+ callback(q.node, q.x0, q.y0, q.x1, q.y1);
+ }
+ return this;
+ }
+ function defaultX(d) {
+ return d[0];
+ }
+ function tree_x(_) {
+ return arguments.length ? (this._x = _, this) : this._x;
+ }
+ function defaultY(d) {
+ return d[1];
+ }
+ function tree_y(_) {
+ return arguments.length ? (this._y = _, this) : this._y;
+ }
+ function quadtree(nodes, x, y) {
+ var tree = new Quadtree(x == null ? defaultX : x, y == null ? defaultY : y, NaN, NaN, NaN, NaN);
+ return nodes == null ? tree : tree.addAll(nodes);
+ }
+ function Quadtree(x, y, x0, y0, x1, y1) {
+ this._x = x;
+ this._y = y;
+ this._x0 = x0;
+ this._y0 = y0;
+ this._x1 = x1;
+ this._y1 = y1;
+ this._root = void 0;
+ }
+ function leaf_copy(leaf) {
+ var copy = { data: leaf.data }, next = copy;
+ while (leaf = leaf.next) next = next.next = { data: leaf.data };
+ return copy;
+ }
+ var treeProto = quadtree.prototype = Quadtree.prototype;
+ treeProto.copy = function() {
+ var copy = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1), node = this._root, nodes, child;
+ if (!node) return copy;
+ if (!node.length) return copy._root = leaf_copy(node), copy;
+ nodes = [{ source: node, target: copy._root = new Array(4) }];
+ while (node = nodes.pop()) {
+ for (var i = 0; i < 4; ++i) {
+ if (child = node.source[i]) {
+ if (child.length) nodes.push({ source: child, target: node.target[i] = new Array(4) });
+ else node.target[i] = leaf_copy(child);
+ }
+ }
+ }
+ return copy;
+ };
+ treeProto.add = tree_add;
+ treeProto.addAll = addAll;
+ treeProto.cover = tree_cover;
+ treeProto.data = tree_data;
+ treeProto.extent = tree_extent;
+ treeProto.find = tree_find;
+ treeProto.remove = tree_remove;
+ treeProto.removeAll = removeAll;
+ treeProto.root = tree_root;
+ treeProto.size = tree_size;
+ treeProto.visit = tree_visit;
+ treeProto.visitAfter = tree_visitAfter;
+ treeProto.x = tree_x;
+ treeProto.y = tree_y;
+ exports2.quadtree = quadtree;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/d3-collection/dist/d3-collection.js
+ var require_d3_collection = __commonJS({
+ "node_modules/d3-collection/dist/d3-collection.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && false ? define(["exports"], factory) : factory(global2.d3 = global2.d3 || {});
+ })(exports, function(exports2) {
+ "use strict";
+ var prefix = "$";
+ function Map2() {
+ }
+ Map2.prototype = map.prototype = {
+ constructor: Map2,
+ has: function(key) {
+ return prefix + key in this;
+ },
+ get: function(key) {
+ return this[prefix + key];
+ },
+ set: function(key, value) {
+ this[prefix + key] = value;
+ return this;
+ },
+ remove: function(key) {
+ var property = prefix + key;
+ return property in this && delete this[property];
+ },
+ clear: function() {
+ for (var property in this) if (property[0] === prefix) delete this[property];
+ },
+ keys: function() {
+ var keys2 = [];
+ for (var property in this) if (property[0] === prefix) keys2.push(property.slice(1));
+ return keys2;
+ },
+ values: function() {
+ var values2 = [];
+ for (var property in this) if (property[0] === prefix) values2.push(this[property]);
+ return values2;
+ },
+ entries: function() {
+ var entries2 = [];
+ for (var property in this) if (property[0] === prefix) entries2.push({ key: property.slice(1), value: this[property] });
+ return entries2;
+ },
+ size: function() {
+ var size = 0;
+ for (var property in this) if (property[0] === prefix) ++size;
+ return size;
+ },
+ empty: function() {
+ for (var property in this) if (property[0] === prefix) return false;
+ return true;
+ },
+ each: function(f) {
+ for (var property in this) if (property[0] === prefix) f(this[property], property.slice(1), this);
+ }
+ };
+ function map(object, f) {
+ var map2 = new Map2();
+ if (object instanceof Map2) object.each(function(value, key2) {
+ map2.set(key2, value);
+ });
+ else if (Array.isArray(object)) {
+ var i = -1, n = object.length, o;
+ if (f == null) while (++i < n) map2.set(i, object[i]);
+ else while (++i < n) map2.set(f(o = object[i], i, object), o);
+ } else if (object) for (var key in object) map2.set(key, object[key]);
+ return map2;
+ }
+ function nest() {
+ var keys2 = [], sortKeys = [], sortValues, rollup, nest2;
+ function apply(array, depth, createResult, setResult) {
+ if (depth >= keys2.length) {
+ if (sortValues != null) array.sort(sortValues);
+ return rollup != null ? rollup(array) : array;
+ }
+ var i = -1, n = array.length, key = keys2[depth++], keyValue, value, valuesByKey = map(), values2, result = createResult();
+ while (++i < n) {
+ if (values2 = valuesByKey.get(keyValue = key(value = array[i]) + "")) {
+ values2.push(value);
+ } else {
+ valuesByKey.set(keyValue, [value]);
+ }
+ }
+ valuesByKey.each(function(values3, key2) {
+ setResult(result, key2, apply(values3, depth, createResult, setResult));
+ });
+ return result;
+ }
+ function entries2(map$$1, depth) {
+ if (++depth > keys2.length) return map$$1;
+ var array, sortKey = sortKeys[depth - 1];
+ if (rollup != null && depth >= keys2.length) array = map$$1.entries();
+ else array = [], map$$1.each(function(v, k) {
+ array.push({ key: k, values: entries2(v, depth) });
+ });
+ return sortKey != null ? array.sort(function(a, b) {
+ return sortKey(a.key, b.key);
+ }) : array;
+ }
+ return nest2 = {
+ object: function(array) {
+ return apply(array, 0, createObject, setObject);
+ },
+ map: function(array) {
+ return apply(array, 0, createMap, setMap);
+ },
+ entries: function(array) {
+ return entries2(apply(array, 0, createMap, setMap), 0);
+ },
+ key: function(d) {
+ keys2.push(d);
+ return nest2;
+ },
+ sortKeys: function(order) {
+ sortKeys[keys2.length - 1] = order;
+ return nest2;
+ },
+ sortValues: function(order) {
+ sortValues = order;
+ return nest2;
+ },
+ rollup: function(f) {
+ rollup = f;
+ return nest2;
+ }
+ };
+ }
+ function createObject() {
+ return {};
+ }
+ function setObject(object, key, value) {
+ object[key] = value;
+ }
+ function createMap() {
+ return map();
+ }
+ function setMap(map$$1, key, value) {
+ map$$1.set(key, value);
+ }
+ function Set2() {
+ }
+ var proto = map.prototype;
+ Set2.prototype = set.prototype = {
+ constructor: Set2,
+ has: proto.has,
+ add: function(value) {
+ value += "";
+ this[prefix + value] = value;
+ return this;
+ },
+ remove: proto.remove,
+ clear: proto.clear,
+ values: proto.keys,
+ size: proto.size,
+ empty: proto.empty,
+ each: proto.each
+ };
+ function set(object, f) {
+ var set2 = new Set2();
+ if (object instanceof Set2) object.each(function(value) {
+ set2.add(value);
+ });
+ else if (object) {
+ var i = -1, n = object.length;
+ if (f == null) while (++i < n) set2.add(object[i]);
+ else while (++i < n) set2.add(f(object[i], i, object));
+ }
+ return set2;
+ }
+ function keys(map2) {
+ var keys2 = [];
+ for (var key in map2) keys2.push(key);
+ return keys2;
+ }
+ function values(map2) {
+ var values2 = [];
+ for (var key in map2) values2.push(map2[key]);
+ return values2;
+ }
+ function entries(map2) {
+ var entries2 = [];
+ for (var key in map2) entries2.push({ key, value: map2[key] });
+ return entries2;
+ }
+ exports2.nest = nest;
+ exports2.set = set;
+ exports2.map = map;
+ exports2.keys = keys;
+ exports2.values = values;
+ exports2.entries = entries;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/d3-dispatch/dist/d3-dispatch.js
+ var require_d3_dispatch = __commonJS({
+ "node_modules/d3-dispatch/dist/d3-dispatch.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && false ? define(["exports"], factory) : (global2 = global2 || self, factory(global2.d3 = global2.d3 || {}));
+ })(exports, function(exports2) {
+ "use strict";
+ var noop = { value: function() {
+ } };
+ function dispatch() {
+ for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
+ if (!(t = arguments[i] + "") || t in _ || /[\s.]/.test(t)) throw new Error("illegal type: " + t);
+ _[t] = [];
+ }
+ return new Dispatch(_);
+ }
+ function Dispatch(_) {
+ this._ = _;
+ }
+ function parseTypenames(typenames, types) {
+ return typenames.trim().split(/^|\s+/).map(function(t) {
+ var name2 = "", i = t.indexOf(".");
+ if (i >= 0) name2 = t.slice(i + 1), t = t.slice(0, i);
+ if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t);
+ return { type: t, name: name2 };
+ });
+ }
+ Dispatch.prototype = dispatch.prototype = {
+ constructor: Dispatch,
+ on: function(typename, callback) {
+ var _ = this._, T = parseTypenames(typename + "", _), t, i = -1, n = T.length;
+ if (arguments.length < 2) {
+ while (++i < n) if ((t = (typename = T[i]).type) && (t = get(_[t], typename.name))) return t;
+ return;
+ }
+ if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
+ while (++i < n) {
+ if (t = (typename = T[i]).type) _[t] = set(_[t], typename.name, callback);
+ else if (callback == null) for (t in _) _[t] = set(_[t], typename.name, null);
+ }
+ return this;
+ },
+ copy: function() {
+ var copy = {}, _ = this._;
+ for (var t in _) copy[t] = _[t].slice();
+ return new Dispatch(copy);
+ },
+ call: function(type, that) {
+ if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2];
+ if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
+ for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
+ },
+ apply: function(type, that, args) {
+ if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
+ for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
+ }
+ };
+ function get(type, name2) {
+ for (var i = 0, n = type.length, c; i < n; ++i) {
+ if ((c = type[i]).name === name2) {
+ return c.value;
+ }
+ }
+ }
+ function set(type, name2, callback) {
+ for (var i = 0, n = type.length; i < n; ++i) {
+ if (type[i].name === name2) {
+ type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
+ break;
+ }
+ }
+ if (callback != null) type.push({ name: name2, value: callback });
+ return type;
+ }
+ exports2.dispatch = dispatch;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/d3-timer/dist/d3-timer.js
+ var require_d3_timer = __commonJS({
+ "node_modules/d3-timer/dist/d3-timer.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && false ? define(["exports"], factory) : (global2 = global2 || self, factory(global2.d3 = global2.d3 || {}));
+ })(exports, function(exports2) {
+ "use strict";
+ var frame = 0, timeout = 0, interval = 0, pokeDelay = 1e3, taskHead, taskTail, clockLast = 0, clockNow = 0, clockSkew = 0, clock = typeof performance === "object" && performance.now ? performance : Date, setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) {
+ setTimeout(f, 17);
+ };
+ function now() {
+ return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
+ }
+ function clearNow() {
+ clockNow = 0;
+ }
+ function Timer() {
+ this._call = this._time = this._next = null;
+ }
+ Timer.prototype = timer.prototype = {
+ constructor: Timer,
+ restart: function(callback, delay, time) {
+ if (typeof callback !== "function") throw new TypeError("callback is not a function");
+ time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
+ if (!this._next && taskTail !== this) {
+ if (taskTail) taskTail._next = this;
+ else taskHead = this;
+ taskTail = this;
+ }
+ this._call = callback;
+ this._time = time;
+ sleep();
+ },
+ stop: function() {
+ if (this._call) {
+ this._call = null;
+ this._time = Infinity;
+ sleep();
+ }
+ }
+ };
+ function timer(callback, delay, time) {
+ var t = new Timer();
+ t.restart(callback, delay, time);
+ return t;
+ }
+ function timerFlush() {
+ now();
+ ++frame;
+ var t = taskHead, e;
+ while (t) {
+ if ((e = clockNow - t._time) >= 0) t._call.call(null, e);
+ t = t._next;
+ }
+ --frame;
+ }
+ function wake() {
+ clockNow = (clockLast = clock.now()) + clockSkew;
+ frame = timeout = 0;
+ try {
+ timerFlush();
+ } finally {
+ frame = 0;
+ nap();
+ clockNow = 0;
+ }
+ }
+ function poke() {
+ var now2 = clock.now(), delay = now2 - clockLast;
+ if (delay > pokeDelay) clockSkew -= delay, clockLast = now2;
+ }
+ function nap() {
+ var t02, t12 = taskHead, t22, time = Infinity;
+ while (t12) {
+ if (t12._call) {
+ if (time > t12._time) time = t12._time;
+ t02 = t12, t12 = t12._next;
+ } else {
+ t22 = t12._next, t12._next = null;
+ t12 = t02 ? t02._next = t22 : taskHead = t22;
+ }
+ }
+ taskTail = t02;
+ sleep(time);
+ }
+ function sleep(time) {
+ if (frame) return;
+ if (timeout) timeout = clearTimeout(timeout);
+ var delay = time - clockNow;
+ if (delay > 24) {
+ if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
+ if (interval) interval = clearInterval(interval);
+ } else {
+ if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
+ frame = 1, setFrame(wake);
+ }
+ }
+ function timeout$1(callback, delay, time) {
+ var t = new Timer();
+ delay = delay == null ? 0 : +delay;
+ t.restart(function(elapsed) {
+ t.stop();
+ callback(elapsed + delay);
+ }, delay, time);
+ return t;
+ }
+ function interval$1(callback, delay, time) {
+ var t = new Timer(), total = delay;
+ if (delay == null) return t.restart(callback, delay, time), t;
+ delay = +delay, time = time == null ? now() : +time;
+ t.restart(function tick(elapsed) {
+ elapsed += total;
+ t.restart(tick, total += delay, time);
+ callback(elapsed);
+ }, delay, time);
+ return t;
+ }
+ exports2.interval = interval$1;
+ exports2.now = now;
+ exports2.timeout = timeout$1;
+ exports2.timer = timer;
+ exports2.timerFlush = timerFlush;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/d3-force/dist/d3-force.js
+ var require_d3_force = __commonJS({
+ "node_modules/d3-force/dist/d3-force.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_d3_quadtree(), require_d3_collection(), require_d3_dispatch(), require_d3_timer()) : typeof define === "function" && false ? define(["exports", "d3-quadtree", "d3-collection", "d3-dispatch", "d3-timer"], factory) : factory(global2.d3 = global2.d3 || {}, global2.d3, global2.d3, global2.d3, global2.d3);
+ })(exports, function(exports2, d3Quadtree, d3Collection, d3Dispatch, d3Timer) {
+ "use strict";
+ function center(x2, y2) {
+ var nodes;
+ if (x2 == null) x2 = 0;
+ if (y2 == null) y2 = 0;
+ function force() {
+ var i, n = nodes.length, node, sx = 0, sy = 0;
+ for (i = 0; i < n; ++i) {
+ node = nodes[i], sx += node.x, sy += node.y;
+ }
+ for (sx = sx / n - x2, sy = sy / n - y2, i = 0; i < n; ++i) {
+ node = nodes[i], node.x -= sx, node.y -= sy;
+ }
+ }
+ force.initialize = function(_) {
+ nodes = _;
+ };
+ force.x = function(_) {
+ return arguments.length ? (x2 = +_, force) : x2;
+ };
+ force.y = function(_) {
+ return arguments.length ? (y2 = +_, force) : y2;
+ };
+ return force;
+ }
+ function constant(x2) {
+ return function() {
+ return x2;
+ };
+ }
+ function jiggle() {
+ return (Math.random() - 0.5) * 1e-6;
+ }
+ function x(d) {
+ return d.x + d.vx;
+ }
+ function y(d) {
+ return d.y + d.vy;
+ }
+ function collide(radius) {
+ var nodes, radii, strength = 1, iterations = 1;
+ if (typeof radius !== "function") radius = constant(radius == null ? 1 : +radius);
+ function force() {
+ var i, n = nodes.length, tree, node, xi, yi, ri, ri2;
+ for (var k = 0; k < iterations; ++k) {
+ tree = d3Quadtree.quadtree(nodes, x, y).visitAfter(prepare);
+ for (i = 0; i < n; ++i) {
+ node = nodes[i];
+ ri = radii[node.index], ri2 = ri * ri;
+ xi = node.x + node.vx;
+ yi = node.y + node.vy;
+ tree.visit(apply);
+ }
+ }
+ function apply(quad, x0, y0, x1, y1) {
+ var data = quad.data, rj = quad.r, r = ri + rj;
+ if (data) {
+ if (data.index > node.index) {
+ var x2 = xi - data.x - data.vx, y2 = yi - data.y - data.vy, l = x2 * x2 + y2 * y2;
+ if (l < r * r) {
+ if (x2 === 0) x2 = jiggle(), l += x2 * x2;
+ if (y2 === 0) y2 = jiggle(), l += y2 * y2;
+ l = (r - (l = Math.sqrt(l))) / l * strength;
+ node.vx += (x2 *= l) * (r = (rj *= rj) / (ri2 + rj));
+ node.vy += (y2 *= l) * r;
+ data.vx -= x2 * (r = 1 - r);
+ data.vy -= y2 * r;
+ }
+ }
+ return;
+ }
+ return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
+ }
+ }
+ function prepare(quad) {
+ if (quad.data) return quad.r = radii[quad.data.index];
+ for (var i = quad.r = 0; i < 4; ++i) {
+ if (quad[i] && quad[i].r > quad.r) {
+ quad.r = quad[i].r;
+ }
+ }
+ }
+ function initialize() {
+ if (!nodes) return;
+ var i, n = nodes.length, node;
+ radii = new Array(n);
+ for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes);
+ }
+ force.initialize = function(_) {
+ nodes = _;
+ initialize();
+ };
+ force.iterations = function(_) {
+ return arguments.length ? (iterations = +_, force) : iterations;
+ };
+ force.strength = function(_) {
+ return arguments.length ? (strength = +_, force) : strength;
+ };
+ force.radius = function(_) {
+ return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), initialize(), force) : radius;
+ };
+ return force;
+ }
+ function index(d) {
+ return d.index;
+ }
+ function find(nodeById, nodeId) {
+ var node = nodeById.get(nodeId);
+ if (!node) throw new Error("missing: " + nodeId);
+ return node;
+ }
+ function link(links) {
+ var id = index, strength = defaultStrength, strengths, distance = constant(30), distances, nodes, count, bias, iterations = 1;
+ if (links == null) links = [];
+ function defaultStrength(link2) {
+ return 1 / Math.min(count[link2.source.index], count[link2.target.index]);
+ }
+ function force(alpha) {
+ for (var k = 0, n = links.length; k < iterations; ++k) {
+ for (var i = 0, link2, source, target, x2, y2, l, b; i < n; ++i) {
+ link2 = links[i], source = link2.source, target = link2.target;
+ x2 = target.x + target.vx - source.x - source.vx || jiggle();
+ y2 = target.y + target.vy - source.y - source.vy || jiggle();
+ l = Math.sqrt(x2 * x2 + y2 * y2);
+ l = (l - distances[i]) / l * alpha * strengths[i];
+ x2 *= l, y2 *= l;
+ target.vx -= x2 * (b = bias[i]);
+ target.vy -= y2 * b;
+ source.vx += x2 * (b = 1 - b);
+ source.vy += y2 * b;
+ }
+ }
+ }
+ function initialize() {
+ if (!nodes) return;
+ var i, n = nodes.length, m = links.length, nodeById = d3Collection.map(nodes, id), link2;
+ for (i = 0, count = new Array(n); i < m; ++i) {
+ link2 = links[i], link2.index = i;
+ if (typeof link2.source !== "object") link2.source = find(nodeById, link2.source);
+ if (typeof link2.target !== "object") link2.target = find(nodeById, link2.target);
+ count[link2.source.index] = (count[link2.source.index] || 0) + 1;
+ count[link2.target.index] = (count[link2.target.index] || 0) + 1;
+ }
+ for (i = 0, bias = new Array(m); i < m; ++i) {
+ link2 = links[i], bias[i] = count[link2.source.index] / (count[link2.source.index] + count[link2.target.index]);
+ }
+ strengths = new Array(m), initializeStrength();
+ distances = new Array(m), initializeDistance();
+ }
+ function initializeStrength() {
+ if (!nodes) return;
+ for (var i = 0, n = links.length; i < n; ++i) {
+ strengths[i] = +strength(links[i], i, links);
+ }
+ }
+ function initializeDistance() {
+ if (!nodes) return;
+ for (var i = 0, n = links.length; i < n; ++i) {
+ distances[i] = +distance(links[i], i, links);
+ }
+ }
+ force.initialize = function(_) {
+ nodes = _;
+ initialize();
+ };
+ force.links = function(_) {
+ return arguments.length ? (links = _, initialize(), force) : links;
+ };
+ force.id = function(_) {
+ return arguments.length ? (id = _, force) : id;
+ };
+ force.iterations = function(_) {
+ return arguments.length ? (iterations = +_, force) : iterations;
+ };
+ force.strength = function(_) {
+ return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initializeStrength(), force) : strength;
+ };
+ force.distance = function(_) {
+ return arguments.length ? (distance = typeof _ === "function" ? _ : constant(+_), initializeDistance(), force) : distance;
+ };
+ return force;
+ }
+ function x$1(d) {
+ return d.x;
+ }
+ function y$1(d) {
+ return d.y;
+ }
+ var initialRadius = 10, initialAngle = Math.PI * (3 - Math.sqrt(5));
+ function simulation(nodes) {
+ var simulation2, alpha = 1, alphaMin = 1e-3, alphaDecay = 1 - Math.pow(alphaMin, 1 / 300), alphaTarget = 0, velocityDecay = 0.6, forces = d3Collection.map(), stepper = d3Timer.timer(step), event = d3Dispatch.dispatch("tick", "end");
+ if (nodes == null) nodes = [];
+ function step() {
+ tick();
+ event.call("tick", simulation2);
+ if (alpha < alphaMin) {
+ stepper.stop();
+ event.call("end", simulation2);
+ }
+ }
+ function tick(iterations) {
+ var i, n = nodes.length, node;
+ if (iterations === void 0) iterations = 1;
+ for (var k = 0; k < iterations; ++k) {
+ alpha += (alphaTarget - alpha) * alphaDecay;
+ forces.each(function(force) {
+ force(alpha);
+ });
+ for (i = 0; i < n; ++i) {
+ node = nodes[i];
+ if (node.fx == null) node.x += node.vx *= velocityDecay;
+ else node.x = node.fx, node.vx = 0;
+ if (node.fy == null) node.y += node.vy *= velocityDecay;
+ else node.y = node.fy, node.vy = 0;
+ }
+ }
+ return simulation2;
+ }
+ function initializeNodes() {
+ for (var i = 0, n = nodes.length, node; i < n; ++i) {
+ node = nodes[i], node.index = i;
+ if (node.fx != null) node.x = node.fx;
+ if (node.fy != null) node.y = node.fy;
+ if (isNaN(node.x) || isNaN(node.y)) {
+ var radius = initialRadius * Math.sqrt(i), angle = i * initialAngle;
+ node.x = radius * Math.cos(angle);
+ node.y = radius * Math.sin(angle);
+ }
+ if (isNaN(node.vx) || isNaN(node.vy)) {
+ node.vx = node.vy = 0;
+ }
+ }
+ }
+ function initializeForce(force) {
+ if (force.initialize) force.initialize(nodes);
+ return force;
+ }
+ initializeNodes();
+ return simulation2 = {
+ tick,
+ restart: function() {
+ return stepper.restart(step), simulation2;
+ },
+ stop: function() {
+ return stepper.stop(), simulation2;
+ },
+ nodes: function(_) {
+ return arguments.length ? (nodes = _, initializeNodes(), forces.each(initializeForce), simulation2) : nodes;
+ },
+ alpha: function(_) {
+ return arguments.length ? (alpha = +_, simulation2) : alpha;
+ },
+ alphaMin: function(_) {
+ return arguments.length ? (alphaMin = +_, simulation2) : alphaMin;
+ },
+ alphaDecay: function(_) {
+ return arguments.length ? (alphaDecay = +_, simulation2) : +alphaDecay;
+ },
+ alphaTarget: function(_) {
+ return arguments.length ? (alphaTarget = +_, simulation2) : alphaTarget;
+ },
+ velocityDecay: function(_) {
+ return arguments.length ? (velocityDecay = 1 - _, simulation2) : 1 - velocityDecay;
+ },
+ force: function(name2, _) {
+ return arguments.length > 1 ? (_ == null ? forces.remove(name2) : forces.set(name2, initializeForce(_)), simulation2) : forces.get(name2);
+ },
+ find: function(x2, y2, radius) {
+ var i = 0, n = nodes.length, dx, dy, d2, node, closest;
+ if (radius == null) radius = Infinity;
+ else radius *= radius;
+ for (i = 0; i < n; ++i) {
+ node = nodes[i];
+ dx = x2 - node.x;
+ dy = y2 - node.y;
+ d2 = dx * dx + dy * dy;
+ if (d2 < radius) closest = node, radius = d2;
+ }
+ return closest;
+ },
+ on: function(name2, _) {
+ return arguments.length > 1 ? (event.on(name2, _), simulation2) : event.on(name2);
+ }
+ };
+ }
+ function manyBody() {
+ var nodes, node, alpha, strength = constant(-30), strengths, distanceMin2 = 1, distanceMax2 = Infinity, theta2 = 0.81;
+ function force(_) {
+ var i, n = nodes.length, tree = d3Quadtree.quadtree(nodes, x$1, y$1).visitAfter(accumulate);
+ for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply);
+ }
+ function initialize() {
+ if (!nodes) return;
+ var i, n = nodes.length, node2;
+ strengths = new Array(n);
+ for (i = 0; i < n; ++i) node2 = nodes[i], strengths[node2.index] = +strength(node2, i, nodes);
+ }
+ function accumulate(quad) {
+ var strength2 = 0, q, c, weight = 0, x2, y2, i;
+ if (quad.length) {
+ for (x2 = y2 = i = 0; i < 4; ++i) {
+ if ((q = quad[i]) && (c = Math.abs(q.value))) {
+ strength2 += q.value, weight += c, x2 += c * q.x, y2 += c * q.y;
+ }
+ }
+ quad.x = x2 / weight;
+ quad.y = y2 / weight;
+ } else {
+ q = quad;
+ q.x = q.data.x;
+ q.y = q.data.y;
+ do
+ strength2 += strengths[q.data.index];
+ while (q = q.next);
+ }
+ quad.value = strength2;
+ }
+ function apply(quad, x1, _, x2) {
+ if (!quad.value) return true;
+ var x3 = quad.x - node.x, y2 = quad.y - node.y, w = x2 - x1, l = x3 * x3 + y2 * y2;
+ if (w * w / theta2 < l) {
+ if (l < distanceMax2) {
+ if (x3 === 0) x3 = jiggle(), l += x3 * x3;
+ if (y2 === 0) y2 = jiggle(), l += y2 * y2;
+ if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
+ node.vx += x3 * quad.value * alpha / l;
+ node.vy += y2 * quad.value * alpha / l;
+ }
+ return true;
+ } else if (quad.length || l >= distanceMax2) return;
+ if (quad.data !== node || quad.next) {
+ if (x3 === 0) x3 = jiggle(), l += x3 * x3;
+ if (y2 === 0) y2 = jiggle(), l += y2 * y2;
+ if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
+ }
+ do
+ if (quad.data !== node) {
+ w = strengths[quad.data.index] * alpha / l;
+ node.vx += x3 * w;
+ node.vy += y2 * w;
+ }
+ while (quad = quad.next);
+ }
+ force.initialize = function(_) {
+ nodes = _;
+ initialize();
+ };
+ force.strength = function(_) {
+ return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initialize(), force) : strength;
+ };
+ force.distanceMin = function(_) {
+ return arguments.length ? (distanceMin2 = _ * _, force) : Math.sqrt(distanceMin2);
+ };
+ force.distanceMax = function(_) {
+ return arguments.length ? (distanceMax2 = _ * _, force) : Math.sqrt(distanceMax2);
+ };
+ force.theta = function(_) {
+ return arguments.length ? (theta2 = _ * _, force) : Math.sqrt(theta2);
+ };
+ return force;
+ }
+ function radial(radius, x2, y2) {
+ var nodes, strength = constant(0.1), strengths, radiuses;
+ if (typeof radius !== "function") radius = constant(+radius);
+ if (x2 == null) x2 = 0;
+ if (y2 == null) y2 = 0;
+ function force(alpha) {
+ for (var i = 0, n = nodes.length; i < n; ++i) {
+ var node = nodes[i], dx = node.x - x2 || 1e-6, dy = node.y - y2 || 1e-6, r = Math.sqrt(dx * dx + dy * dy), k = (radiuses[i] - r) * strengths[i] * alpha / r;
+ node.vx += dx * k;
+ node.vy += dy * k;
+ }
+ }
+ function initialize() {
+ if (!nodes) return;
+ var i, n = nodes.length;
+ strengths = new Array(n);
+ radiuses = new Array(n);
+ for (i = 0; i < n; ++i) {
+ radiuses[i] = +radius(nodes[i], i, nodes);
+ strengths[i] = isNaN(radiuses[i]) ? 0 : +strength(nodes[i], i, nodes);
+ }
+ }
+ force.initialize = function(_) {
+ nodes = _, initialize();
+ };
+ force.strength = function(_) {
+ return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initialize(), force) : strength;
+ };
+ force.radius = function(_) {
+ return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), initialize(), force) : radius;
+ };
+ force.x = function(_) {
+ return arguments.length ? (x2 = +_, force) : x2;
+ };
+ force.y = function(_) {
+ return arguments.length ? (y2 = +_, force) : y2;
+ };
+ return force;
+ }
+ function x$2(x2) {
+ var strength = constant(0.1), nodes, strengths, xz;
+ if (typeof x2 !== "function") x2 = constant(x2 == null ? 0 : +x2);
+ function force(alpha) {
+ for (var i = 0, n = nodes.length, node; i < n; ++i) {
+ node = nodes[i], node.vx += (xz[i] - node.x) * strengths[i] * alpha;
+ }
+ }
+ function initialize() {
+ if (!nodes) return;
+ var i, n = nodes.length;
+ strengths = new Array(n);
+ xz = new Array(n);
+ for (i = 0; i < n; ++i) {
+ strengths[i] = isNaN(xz[i] = +x2(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
+ }
+ }
+ force.initialize = function(_) {
+ nodes = _;
+ initialize();
+ };
+ force.strength = function(_) {
+ return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initialize(), force) : strength;
+ };
+ force.x = function(_) {
+ return arguments.length ? (x2 = typeof _ === "function" ? _ : constant(+_), initialize(), force) : x2;
+ };
+ return force;
+ }
+ function y$2(y2) {
+ var strength = constant(0.1), nodes, strengths, yz;
+ if (typeof y2 !== "function") y2 = constant(y2 == null ? 0 : +y2);
+ function force(alpha) {
+ for (var i = 0, n = nodes.length, node; i < n; ++i) {
+ node = nodes[i], node.vy += (yz[i] - node.y) * strengths[i] * alpha;
+ }
+ }
+ function initialize() {
+ if (!nodes) return;
+ var i, n = nodes.length;
+ strengths = new Array(n);
+ yz = new Array(n);
+ for (i = 0; i < n; ++i) {
+ strengths[i] = isNaN(yz[i] = +y2(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
+ }
+ }
+ force.initialize = function(_) {
+ nodes = _;
+ initialize();
+ };
+ force.strength = function(_) {
+ return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initialize(), force) : strength;
+ };
+ force.y = function(_) {
+ return arguments.length ? (y2 = typeof _ === "function" ? _ : constant(+_), initialize(), force) : y2;
+ };
+ return force;
+ }
+ exports2.forceCenter = center;
+ exports2.forceCollide = collide;
+ exports2.forceLink = link;
+ exports2.forceManyBody = manyBody;
+ exports2.forceRadial = radial;
+ exports2.forceSimulation = simulation;
+ exports2.forceX = x$2;
+ exports2.forceY = y$2;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/d3-path/dist/d3-path.js
+ var require_d3_path = __commonJS({
+ "node_modules/d3-path/dist/d3-path.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && false ? define(["exports"], factory) : (global2 = global2 || self, factory(global2.d3 = global2.d3 || {}));
+ })(exports, function(exports2) {
+ "use strict";
+ var pi = Math.PI, tau = 2 * pi, epsilon = 1e-6, tauEpsilon = tau - epsilon;
+ function Path() {
+ this._x0 = this._y0 = // start of current subpath
+ this._x1 = this._y1 = null;
+ this._ = "";
+ }
+ function path() {
+ return new Path();
+ }
+ Path.prototype = path.prototype = {
+ constructor: Path,
+ moveTo: function(x, y) {
+ this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y);
+ },
+ closePath: function() {
+ if (this._x1 !== null) {
+ this._x1 = this._x0, this._y1 = this._y0;
+ this._ += "Z";
+ }
+ },
+ lineTo: function(x, y) {
+ this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y);
+ },
+ quadraticCurveTo: function(x1, y1, x, y) {
+ this._ += "Q" + +x1 + "," + +y1 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
+ },
+ bezierCurveTo: function(x1, y1, x2, y2, x, y) {
+ this._ += "C" + +x1 + "," + +y1 + "," + +x2 + "," + +y2 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
+ },
+ arcTo: function(x1, y1, x2, y2, r) {
+ x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
+ var x0 = this._x1, y0 = this._y1, x21 = x2 - x1, y21 = y2 - y1, x01 = x0 - x1, y01 = y0 - y1, l01_2 = x01 * x01 + y01 * y01;
+ if (r < 0) throw new Error("negative radius: " + r);
+ if (this._x1 === null) {
+ this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
+ } else if (!(l01_2 > epsilon)) ;
+ else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {
+ this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
+ } else {
+ var x20 = x2 - x0, y20 = y2 - y0, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21;
+ if (Math.abs(t01 - 1) > epsilon) {
+ this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
+ }
+ this._ += "A" + r + "," + r + ",0,0," + +(y01 * x20 > x01 * y20) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
+ }
+ },
+ arc: function(x, y, r, a0, a1, ccw) {
+ x = +x, y = +y, r = +r, ccw = !!ccw;
+ var dx = r * Math.cos(a0), dy = r * Math.sin(a0), x0 = x + dx, y0 = y + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0;
+ if (r < 0) throw new Error("negative radius: " + r);
+ if (this._x1 === null) {
+ this._ += "M" + x0 + "," + y0;
+ } else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {
+ this._ += "L" + x0 + "," + y0;
+ }
+ if (!r) return;
+ if (da < 0) da = da % tau + tau;
+ if (da > tauEpsilon) {
+ this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
+ } else if (da > epsilon) {
+ this._ += "A" + r + "," + r + ",0," + +(da >= pi) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
+ }
+ },
+ rect: function(x, y, w, h) {
+ this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + +w + "v" + +h + "h" + -w + "Z";
+ },
+ toString: function() {
+ return this._;
+ }
+ };
+ exports2.path = path;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/d3-shape/dist/d3-shape.js
+ var require_d3_shape = __commonJS({
+ "node_modules/d3-shape/dist/d3-shape.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_d3_path()) : typeof define === "function" && false ? define(["exports", "d3-path"], factory) : (global2 = global2 || self, factory(global2.d3 = global2.d3 || {}, global2.d3));
+ })(exports, function(exports2, d3Path) {
+ "use strict";
+ function constant(x2) {
+ return function constant2() {
+ return x2;
+ };
+ }
+ var abs = Math.abs;
+ var atan2 = Math.atan2;
+ var cos = Math.cos;
+ var max = Math.max;
+ var min = Math.min;
+ var sin = Math.sin;
+ var sqrt = Math.sqrt;
+ var epsilon = 1e-12;
+ var pi = Math.PI;
+ var halfPi = pi / 2;
+ var tau = 2 * pi;
+ function acos(x2) {
+ return x2 > 1 ? 0 : x2 < -1 ? pi : Math.acos(x2);
+ }
+ function asin(x2) {
+ return x2 >= 1 ? halfPi : x2 <= -1 ? -halfPi : Math.asin(x2);
+ }
+ function arcInnerRadius(d) {
+ return d.innerRadius;
+ }
+ function arcOuterRadius(d) {
+ return d.outerRadius;
+ }
+ function arcStartAngle(d) {
+ return d.startAngle;
+ }
+ function arcEndAngle(d) {
+ return d.endAngle;
+ }
+ function arcPadAngle(d) {
+ return d && d.padAngle;
+ }
+ function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
+ var x10 = x1 - x0, y10 = y1 - y0, x32 = x3 - x2, y32 = y3 - y2, t = y32 * x10 - x32 * y10;
+ if (t * t < epsilon) return;
+ t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
+ return [x0 + t * x10, y0 + t * y10];
+ }
+ function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
+ var x01 = x0 - x1, y01 = y0 - y1, lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x11 = x0 + ox, y11 = y0 + oy, x10 = x1 + ox, y10 = y1 + oy, x00 = (x11 + x10) / 2, y00 = (y11 + y10) / 2, dx = x10 - x11, dy = y10 - y11, d2 = dx * dx + dy * dy, r = r1 - rc, D2 = x11 * y10 - x10 * y11, d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D2 * D2)), cx0 = (D2 * dy - dx * d) / d2, cy0 = (-D2 * dx - dy * d) / d2, cx1 = (D2 * dy + dx * d) / d2, cy1 = (-D2 * dx + dy * d) / d2, dx0 = cx0 - x00, dy0 = cy0 - y00, dx1 = cx1 - x00, dy1 = cy1 - y00;
+ if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
+ return {
+ cx: cx0,
+ cy: cy0,
+ x01: -ox,
+ y01: -oy,
+ x11: cx0 * (r1 / r - 1),
+ y11: cy0 * (r1 / r - 1)
+ };
+ }
+ function arc() {
+ var innerRadius = arcInnerRadius, outerRadius = arcOuterRadius, cornerRadius = constant(0), padRadius = null, startAngle = arcStartAngle, endAngle = arcEndAngle, padAngle = arcPadAngle, context = null;
+ function arc2() {
+ var buffer, r, r0 = +innerRadius.apply(this, arguments), r1 = +outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) - halfPi, a1 = endAngle.apply(this, arguments) - halfPi, da = abs(a1 - a0), cw = a1 > a0;
+ if (!context) context = buffer = d3Path.path();
+ if (r1 < r0) r = r1, r1 = r0, r0 = r;
+ if (!(r1 > epsilon)) context.moveTo(0, 0);
+ else if (da > tau - epsilon) {
+ context.moveTo(r1 * cos(a0), r1 * sin(a0));
+ context.arc(0, 0, r1, a0, a1, !cw);
+ if (r0 > epsilon) {
+ context.moveTo(r0 * cos(a1), r0 * sin(a1));
+ context.arc(0, 0, r0, a1, a0, cw);
+ }
+ } else {
+ var a01 = a0, a11 = a1, a00 = a0, a10 = a1, da0 = da, da1 = da, ap = padAngle.apply(this, arguments) / 2, rp = ap > epsilon && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)), rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), rc0 = rc, rc1 = rc, t02, t12;
+ if (rp > epsilon) {
+ var p0 = asin(rp / r0 * sin(ap)), p1 = asin(rp / r1 * sin(ap));
+ if ((da0 -= p0 * 2) > epsilon) p0 *= cw ? 1 : -1, a00 += p0, a10 -= p0;
+ else da0 = 0, a00 = a10 = (a0 + a1) / 2;
+ if ((da1 -= p1 * 2) > epsilon) p1 *= cw ? 1 : -1, a01 += p1, a11 -= p1;
+ else da1 = 0, a01 = a11 = (a0 + a1) / 2;
+ }
+ var x01 = r1 * cos(a01), y01 = r1 * sin(a01), x10 = r0 * cos(a10), y10 = r0 * sin(a10);
+ if (rc > epsilon) {
+ var x11 = r1 * cos(a11), y11 = r1 * sin(a11), x00 = r0 * cos(a00), y00 = r0 * sin(a00), oc;
+ if (da < pi && (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10))) {
+ var ax = x01 - oc[0], ay = y01 - oc[1], bx = x11 - oc[0], by = y11 - oc[1], kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2), lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
+ rc0 = min(rc, (r0 - lc) / (kc - 1));
+ rc1 = min(rc, (r1 - lc) / (kc + 1));
+ }
+ }
+ if (!(da1 > epsilon)) context.moveTo(x01, y01);
+ else if (rc1 > epsilon) {
+ t02 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
+ t12 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
+ context.moveTo(t02.cx + t02.x01, t02.cy + t02.y01);
+ if (rc1 < rc) context.arc(t02.cx, t02.cy, rc1, atan2(t02.y01, t02.x01), atan2(t12.y01, t12.x01), !cw);
+ else {
+ context.arc(t02.cx, t02.cy, rc1, atan2(t02.y01, t02.x01), atan2(t02.y11, t02.x11), !cw);
+ context.arc(0, 0, r1, atan2(t02.cy + t02.y11, t02.cx + t02.x11), atan2(t12.cy + t12.y11, t12.cx + t12.x11), !cw);
+ context.arc(t12.cx, t12.cy, rc1, atan2(t12.y11, t12.x11), atan2(t12.y01, t12.x01), !cw);
+ }
+ } else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
+ if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10);
+ else if (rc0 > epsilon) {
+ t02 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
+ t12 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
+ context.lineTo(t02.cx + t02.x01, t02.cy + t02.y01);
+ if (rc0 < rc) context.arc(t02.cx, t02.cy, rc0, atan2(t02.y01, t02.x01), atan2(t12.y01, t12.x01), !cw);
+ else {
+ context.arc(t02.cx, t02.cy, rc0, atan2(t02.y01, t02.x01), atan2(t02.y11, t02.x11), !cw);
+ context.arc(0, 0, r0, atan2(t02.cy + t02.y11, t02.cx + t02.x11), atan2(t12.cy + t12.y11, t12.cx + t12.x11), cw);
+ context.arc(t12.cx, t12.cy, rc0, atan2(t12.y11, t12.x11), atan2(t12.y01, t12.x01), !cw);
+ }
+ } else context.arc(0, 0, r0, a10, a00, cw);
+ }
+ context.closePath();
+ if (buffer) return context = null, buffer + "" || null;
+ }
+ arc2.centroid = function() {
+ var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a2 = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2;
+ return [cos(a2) * r, sin(a2) * r];
+ };
+ arc2.innerRadius = function(_) {
+ return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant(+_), arc2) : innerRadius;
+ };
+ arc2.outerRadius = function(_) {
+ return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant(+_), arc2) : outerRadius;
+ };
+ arc2.cornerRadius = function(_) {
+ return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant(+_), arc2) : cornerRadius;
+ };
+ arc2.padRadius = function(_) {
+ return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant(+_), arc2) : padRadius;
+ };
+ arc2.startAngle = function(_) {
+ return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), arc2) : startAngle;
+ };
+ arc2.endAngle = function(_) {
+ return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), arc2) : endAngle;
+ };
+ arc2.padAngle = function(_) {
+ return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), arc2) : padAngle;
+ };
+ arc2.context = function(_) {
+ return arguments.length ? (context = _ == null ? null : _, arc2) : context;
+ };
+ return arc2;
+ }
+ function Linear(context) {
+ this._context = context;
+ }
+ Linear.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._point = 0;
+ },
+ lineEnd: function() {
+ if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
+ this._line = 1 - this._line;
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2);
+ break;
+ case 1:
+ this._point = 2;
+ // proceed
+ default:
+ this._context.lineTo(x2, y2);
+ break;
+ }
+ }
+ };
+ function curveLinear(context) {
+ return new Linear(context);
+ }
+ function x(p) {
+ return p[0];
+ }
+ function y(p) {
+ return p[1];
+ }
+ function line() {
+ var x$1 = x, y$1 = y, defined = constant(true), context = null, curve = curveLinear, output = null;
+ function line2(data) {
+ var i, n = data.length, d, defined0 = false, buffer;
+ if (context == null) output = curve(buffer = d3Path.path());
+ for (i = 0; i <= n; ++i) {
+ if (!(i < n && defined(d = data[i], i, data)) === defined0) {
+ if (defined0 = !defined0) output.lineStart();
+ else output.lineEnd();
+ }
+ if (defined0) output.point(+x$1(d, i, data), +y$1(d, i, data));
+ }
+ if (buffer) return output = null, buffer + "" || null;
+ }
+ line2.x = function(_) {
+ return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), line2) : x$1;
+ };
+ line2.y = function(_) {
+ return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), line2) : y$1;
+ };
+ line2.defined = function(_) {
+ return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), line2) : defined;
+ };
+ line2.curve = function(_) {
+ return arguments.length ? (curve = _, context != null && (output = curve(context)), line2) : curve;
+ };
+ line2.context = function(_) {
+ return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line2) : context;
+ };
+ return line2;
+ }
+ function area() {
+ var x0 = x, x1 = null, y0 = constant(0), y1 = y, defined = constant(true), context = null, curve = curveLinear, output = null;
+ function area2(data) {
+ var i, j, k2, n = data.length, d, defined0 = false, buffer, x0z = new Array(n), y0z = new Array(n);
+ if (context == null) output = curve(buffer = d3Path.path());
+ for (i = 0; i <= n; ++i) {
+ if (!(i < n && defined(d = data[i], i, data)) === defined0) {
+ if (defined0 = !defined0) {
+ j = i;
+ output.areaStart();
+ output.lineStart();
+ } else {
+ output.lineEnd();
+ output.lineStart();
+ for (k2 = i - 1; k2 >= j; --k2) {
+ output.point(x0z[k2], y0z[k2]);
+ }
+ output.lineEnd();
+ output.areaEnd();
+ }
+ }
+ if (defined0) {
+ x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data);
+ output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]);
+ }
+ }
+ if (buffer) return output = null, buffer + "" || null;
+ }
+ function arealine() {
+ return line().defined(defined).curve(curve).context(context);
+ }
+ area2.x = function(_) {
+ return arguments.length ? (x0 = typeof _ === "function" ? _ : constant(+_), x1 = null, area2) : x0;
+ };
+ area2.x0 = function(_) {
+ return arguments.length ? (x0 = typeof _ === "function" ? _ : constant(+_), area2) : x0;
+ };
+ area2.x1 = function(_) {
+ return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : constant(+_), area2) : x1;
+ };
+ area2.y = function(_) {
+ return arguments.length ? (y0 = typeof _ === "function" ? _ : constant(+_), y1 = null, area2) : y0;
+ };
+ area2.y0 = function(_) {
+ return arguments.length ? (y0 = typeof _ === "function" ? _ : constant(+_), area2) : y0;
+ };
+ area2.y1 = function(_) {
+ return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : constant(+_), area2) : y1;
+ };
+ area2.lineX0 = area2.lineY0 = function() {
+ return arealine().x(x0).y(y0);
+ };
+ area2.lineY1 = function() {
+ return arealine().x(x0).y(y1);
+ };
+ area2.lineX1 = function() {
+ return arealine().x(x1).y(y0);
+ };
+ area2.defined = function(_) {
+ return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), area2) : defined;
+ };
+ area2.curve = function(_) {
+ return arguments.length ? (curve = _, context != null && (output = curve(context)), area2) : curve;
+ };
+ area2.context = function(_) {
+ return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area2) : context;
+ };
+ return area2;
+ }
+ function descending(a2, b) {
+ return b < a2 ? -1 : b > a2 ? 1 : b >= a2 ? 0 : NaN;
+ }
+ function identity2(d) {
+ return d;
+ }
+ function pie() {
+ var value = identity2, sortValues = descending, sort = null, startAngle = constant(0), endAngle = constant(tau), padAngle = constant(0);
+ function pie2(data) {
+ var i, n = data.length, j, k2, sum2 = 0, index = new Array(n), arcs = new Array(n), a0 = +startAngle.apply(this, arguments), da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), a1, p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), pa = p * (da < 0 ? -1 : 1), v;
+ for (i = 0; i < n; ++i) {
+ if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {
+ sum2 += v;
+ }
+ }
+ if (sortValues != null) index.sort(function(i2, j2) {
+ return sortValues(arcs[i2], arcs[j2]);
+ });
+ else if (sort != null) index.sort(function(i2, j2) {
+ return sort(data[i2], data[j2]);
+ });
+ for (i = 0, k2 = sum2 ? (da - n * pa) / sum2 : 0; i < n; ++i, a0 = a1) {
+ j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k2 : 0) + pa, arcs[j] = {
+ data: data[j],
+ index: i,
+ value: v,
+ startAngle: a0,
+ endAngle: a1,
+ padAngle: p
+ };
+ }
+ return arcs;
+ }
+ pie2.value = function(_) {
+ return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), pie2) : value;
+ };
+ pie2.sortValues = function(_) {
+ return arguments.length ? (sortValues = _, sort = null, pie2) : sortValues;
+ };
+ pie2.sort = function(_) {
+ return arguments.length ? (sort = _, sortValues = null, pie2) : sort;
+ };
+ pie2.startAngle = function(_) {
+ return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), pie2) : startAngle;
+ };
+ pie2.endAngle = function(_) {
+ return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), pie2) : endAngle;
+ };
+ pie2.padAngle = function(_) {
+ return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), pie2) : padAngle;
+ };
+ return pie2;
+ }
+ var curveRadialLinear = curveRadial(curveLinear);
+ function Radial(curve) {
+ this._curve = curve;
+ }
+ Radial.prototype = {
+ areaStart: function() {
+ this._curve.areaStart();
+ },
+ areaEnd: function() {
+ this._curve.areaEnd();
+ },
+ lineStart: function() {
+ this._curve.lineStart();
+ },
+ lineEnd: function() {
+ this._curve.lineEnd();
+ },
+ point: function(a2, r) {
+ this._curve.point(r * Math.sin(a2), r * -Math.cos(a2));
+ }
+ };
+ function curveRadial(curve) {
+ function radial(context) {
+ return new Radial(curve(context));
+ }
+ radial._curve = curve;
+ return radial;
+ }
+ function lineRadial(l) {
+ var c2 = l.curve;
+ l.angle = l.x, delete l.x;
+ l.radius = l.y, delete l.y;
+ l.curve = function(_) {
+ return arguments.length ? c2(curveRadial(_)) : c2()._curve;
+ };
+ return l;
+ }
+ function lineRadial$1() {
+ return lineRadial(line().curve(curveRadialLinear));
+ }
+ function areaRadial() {
+ var a2 = area().curve(curveRadialLinear), c2 = a2.curve, x0 = a2.lineX0, x1 = a2.lineX1, y0 = a2.lineY0, y1 = a2.lineY1;
+ a2.angle = a2.x, delete a2.x;
+ a2.startAngle = a2.x0, delete a2.x0;
+ a2.endAngle = a2.x1, delete a2.x1;
+ a2.radius = a2.y, delete a2.y;
+ a2.innerRadius = a2.y0, delete a2.y0;
+ a2.outerRadius = a2.y1, delete a2.y1;
+ a2.lineStartAngle = function() {
+ return lineRadial(x0());
+ }, delete a2.lineX0;
+ a2.lineEndAngle = function() {
+ return lineRadial(x1());
+ }, delete a2.lineX1;
+ a2.lineInnerRadius = function() {
+ return lineRadial(y0());
+ }, delete a2.lineY0;
+ a2.lineOuterRadius = function() {
+ return lineRadial(y1());
+ }, delete a2.lineY1;
+ a2.curve = function(_) {
+ return arguments.length ? c2(curveRadial(_)) : c2()._curve;
+ };
+ return a2;
+ }
+ function pointRadial(x2, y2) {
+ return [(y2 = +y2) * Math.cos(x2 -= Math.PI / 2), y2 * Math.sin(x2)];
+ }
+ var slice = Array.prototype.slice;
+ function linkSource(d) {
+ return d.source;
+ }
+ function linkTarget(d) {
+ return d.target;
+ }
+ function link(curve) {
+ var source = linkSource, target = linkTarget, x$1 = x, y$1 = y, context = null;
+ function link2() {
+ var buffer, argv = slice.call(arguments), s2 = source.apply(this, argv), t = target.apply(this, argv);
+ if (!context) context = buffer = d3Path.path();
+ curve(context, +x$1.apply(this, (argv[0] = s2, argv)), +y$1.apply(this, argv), +x$1.apply(this, (argv[0] = t, argv)), +y$1.apply(this, argv));
+ if (buffer) return context = null, buffer + "" || null;
+ }
+ link2.source = function(_) {
+ return arguments.length ? (source = _, link2) : source;
+ };
+ link2.target = function(_) {
+ return arguments.length ? (target = _, link2) : target;
+ };
+ link2.x = function(_) {
+ return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), link2) : x$1;
+ };
+ link2.y = function(_) {
+ return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), link2) : y$1;
+ };
+ link2.context = function(_) {
+ return arguments.length ? (context = _ == null ? null : _, link2) : context;
+ };
+ return link2;
+ }
+ function curveHorizontal(context, x0, y0, x1, y1) {
+ context.moveTo(x0, y0);
+ context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);
+ }
+ function curveVertical(context, x0, y0, x1, y1) {
+ context.moveTo(x0, y0);
+ context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1);
+ }
+ function curveRadial$1(context, x0, y0, x1, y1) {
+ var p0 = pointRadial(x0, y0), p1 = pointRadial(x0, y0 = (y0 + y1) / 2), p2 = pointRadial(x1, y0), p3 = pointRadial(x1, y1);
+ context.moveTo(p0[0], p0[1]);
+ context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);
+ }
+ function linkHorizontal() {
+ return link(curveHorizontal);
+ }
+ function linkVertical() {
+ return link(curveVertical);
+ }
+ function linkRadial() {
+ var l = link(curveRadial$1);
+ l.angle = l.x, delete l.x;
+ l.radius = l.y, delete l.y;
+ return l;
+ }
+ var circle = {
+ draw: function(context, size) {
+ var r = Math.sqrt(size / pi);
+ context.moveTo(r, 0);
+ context.arc(0, 0, r, 0, tau);
+ }
+ };
+ var cross = {
+ draw: function(context, size) {
+ var r = Math.sqrt(size / 5) / 2;
+ context.moveTo(-3 * r, -r);
+ context.lineTo(-r, -r);
+ context.lineTo(-r, -3 * r);
+ context.lineTo(r, -3 * r);
+ context.lineTo(r, -r);
+ context.lineTo(3 * r, -r);
+ context.lineTo(3 * r, r);
+ context.lineTo(r, r);
+ context.lineTo(r, 3 * r);
+ context.lineTo(-r, 3 * r);
+ context.lineTo(-r, r);
+ context.lineTo(-3 * r, r);
+ context.closePath();
+ }
+ };
+ var tan30 = Math.sqrt(1 / 3), tan30_2 = tan30 * 2;
+ var diamond = {
+ draw: function(context, size) {
+ var y2 = Math.sqrt(size / tan30_2), x2 = y2 * tan30;
+ context.moveTo(0, -y2);
+ context.lineTo(x2, 0);
+ context.lineTo(0, y2);
+ context.lineTo(-x2, 0);
+ context.closePath();
+ }
+ };
+ var ka = 0.8908130915292852, kr = Math.sin(pi / 10) / Math.sin(7 * pi / 10), kx = Math.sin(tau / 10) * kr, ky = -Math.cos(tau / 10) * kr;
+ var star = {
+ draw: function(context, size) {
+ var r = Math.sqrt(size * ka), x2 = kx * r, y2 = ky * r;
+ context.moveTo(0, -r);
+ context.lineTo(x2, y2);
+ for (var i = 1; i < 5; ++i) {
+ var a2 = tau * i / 5, c2 = Math.cos(a2), s2 = Math.sin(a2);
+ context.lineTo(s2 * r, -c2 * r);
+ context.lineTo(c2 * x2 - s2 * y2, s2 * x2 + c2 * y2);
+ }
+ context.closePath();
+ }
+ };
+ var square = {
+ draw: function(context, size) {
+ var w = Math.sqrt(size), x2 = -w / 2;
+ context.rect(x2, x2, w, w);
+ }
+ };
+ var sqrt3 = Math.sqrt(3);
+ var triangle = {
+ draw: function(context, size) {
+ var y2 = -Math.sqrt(size / (sqrt3 * 3));
+ context.moveTo(0, y2 * 2);
+ context.lineTo(-sqrt3 * y2, -y2);
+ context.lineTo(sqrt3 * y2, -y2);
+ context.closePath();
+ }
+ };
+ var c = -0.5, s = Math.sqrt(3) / 2, k = 1 / Math.sqrt(12), a = (k / 2 + 1) * 3;
+ var wye = {
+ draw: function(context, size) {
+ var r = Math.sqrt(size / a), x0 = r / 2, y0 = r * k, x1 = x0, y1 = r * k + r, x2 = -x1, y2 = y1;
+ context.moveTo(x0, y0);
+ context.lineTo(x1, y1);
+ context.lineTo(x2, y2);
+ context.lineTo(c * x0 - s * y0, s * x0 + c * y0);
+ context.lineTo(c * x1 - s * y1, s * x1 + c * y1);
+ context.lineTo(c * x2 - s * y2, s * x2 + c * y2);
+ context.lineTo(c * x0 + s * y0, c * y0 - s * x0);
+ context.lineTo(c * x1 + s * y1, c * y1 - s * x1);
+ context.lineTo(c * x2 + s * y2, c * y2 - s * x2);
+ context.closePath();
+ }
+ };
+ var symbols = [
+ circle,
+ cross,
+ diamond,
+ square,
+ star,
+ triangle,
+ wye
+ ];
+ function symbol() {
+ var type = constant(circle), size = constant(64), context = null;
+ function symbol2() {
+ var buffer;
+ if (!context) context = buffer = d3Path.path();
+ type.apply(this, arguments).draw(context, +size.apply(this, arguments));
+ if (buffer) return context = null, buffer + "" || null;
+ }
+ symbol2.type = function(_) {
+ return arguments.length ? (type = typeof _ === "function" ? _ : constant(_), symbol2) : type;
+ };
+ symbol2.size = function(_) {
+ return arguments.length ? (size = typeof _ === "function" ? _ : constant(+_), symbol2) : size;
+ };
+ symbol2.context = function(_) {
+ return arguments.length ? (context = _ == null ? null : _, symbol2) : context;
+ };
+ return symbol2;
+ }
+ function noop() {
+ }
+ function point(that, x2, y2) {
+ that._context.bezierCurveTo(
+ (2 * that._x0 + that._x1) / 3,
+ (2 * that._y0 + that._y1) / 3,
+ (that._x0 + 2 * that._x1) / 3,
+ (that._y0 + 2 * that._y1) / 3,
+ (that._x0 + 4 * that._x1 + x2) / 6,
+ (that._y0 + 4 * that._y1 + y2) / 6
+ );
+ }
+ function Basis(context) {
+ this._context = context;
+ }
+ Basis.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._x0 = this._x1 = this._y0 = this._y1 = NaN;
+ this._point = 0;
+ },
+ lineEnd: function() {
+ switch (this._point) {
+ case 3:
+ point(this, this._x1, this._y1);
+ // proceed
+ case 2:
+ this._context.lineTo(this._x1, this._y1);
+ break;
+ }
+ if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
+ this._line = 1 - this._line;
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2);
+ break;
+ case 1:
+ this._point = 2;
+ break;
+ case 2:
+ this._point = 3;
+ this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
+ // proceed
+ default:
+ point(this, x2, y2);
+ break;
+ }
+ this._x0 = this._x1, this._x1 = x2;
+ this._y0 = this._y1, this._y1 = y2;
+ }
+ };
+ function basis2(context) {
+ return new Basis(context);
+ }
+ function BasisClosed(context) {
+ this._context = context;
+ }
+ BasisClosed.prototype = {
+ areaStart: noop,
+ areaEnd: noop,
+ lineStart: function() {
+ this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN;
+ this._point = 0;
+ },
+ lineEnd: function() {
+ switch (this._point) {
+ case 1: {
+ this._context.moveTo(this._x2, this._y2);
+ this._context.closePath();
+ break;
+ }
+ case 2: {
+ this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3);
+ this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3);
+ this._context.closePath();
+ break;
+ }
+ case 3: {
+ this.point(this._x2, this._y2);
+ this.point(this._x3, this._y3);
+ this.point(this._x4, this._y4);
+ break;
+ }
+ }
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ this._x2 = x2, this._y2 = y2;
+ break;
+ case 1:
+ this._point = 2;
+ this._x3 = x2, this._y3 = y2;
+ break;
+ case 2:
+ this._point = 3;
+ this._x4 = x2, this._y4 = y2;
+ this._context.moveTo((this._x0 + 4 * this._x1 + x2) / 6, (this._y0 + 4 * this._y1 + y2) / 6);
+ break;
+ default:
+ point(this, x2, y2);
+ break;
+ }
+ this._x0 = this._x1, this._x1 = x2;
+ this._y0 = this._y1, this._y1 = y2;
+ }
+ };
+ function basisClosed(context) {
+ return new BasisClosed(context);
+ }
+ function BasisOpen(context) {
+ this._context = context;
+ }
+ BasisOpen.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._x0 = this._x1 = this._y0 = this._y1 = NaN;
+ this._point = 0;
+ },
+ lineEnd: function() {
+ if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
+ this._line = 1 - this._line;
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ break;
+ case 1:
+ this._point = 2;
+ break;
+ case 2:
+ this._point = 3;
+ var x0 = (this._x0 + 4 * this._x1 + x2) / 6, y0 = (this._y0 + 4 * this._y1 + y2) / 6;
+ this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0);
+ break;
+ case 3:
+ this._point = 4;
+ // proceed
+ default:
+ point(this, x2, y2);
+ break;
+ }
+ this._x0 = this._x1, this._x1 = x2;
+ this._y0 = this._y1, this._y1 = y2;
+ }
+ };
+ function basisOpen(context) {
+ return new BasisOpen(context);
+ }
+ function Bundle(context, beta) {
+ this._basis = new Basis(context);
+ this._beta = beta;
+ }
+ Bundle.prototype = {
+ lineStart: function() {
+ this._x = [];
+ this._y = [];
+ this._basis.lineStart();
+ },
+ lineEnd: function() {
+ var x2 = this._x, y2 = this._y, j = x2.length - 1;
+ if (j > 0) {
+ var x0 = x2[0], y0 = y2[0], dx = x2[j] - x0, dy = y2[j] - y0, i = -1, t;
+ while (++i <= j) {
+ t = i / j;
+ this._basis.point(
+ this._beta * x2[i] + (1 - this._beta) * (x0 + t * dx),
+ this._beta * y2[i] + (1 - this._beta) * (y0 + t * dy)
+ );
+ }
+ }
+ this._x = this._y = null;
+ this._basis.lineEnd();
+ },
+ point: function(x2, y2) {
+ this._x.push(+x2);
+ this._y.push(+y2);
+ }
+ };
+ var bundle = function custom(beta) {
+ function bundle2(context) {
+ return beta === 1 ? new Basis(context) : new Bundle(context, beta);
+ }
+ bundle2.beta = function(beta2) {
+ return custom(+beta2);
+ };
+ return bundle2;
+ }(0.85);
+ function point$1(that, x2, y2) {
+ that._context.bezierCurveTo(
+ that._x1 + that._k * (that._x2 - that._x0),
+ that._y1 + that._k * (that._y2 - that._y0),
+ that._x2 + that._k * (that._x1 - x2),
+ that._y2 + that._k * (that._y1 - y2),
+ that._x2,
+ that._y2
+ );
+ }
+ function Cardinal(context, tension) {
+ this._context = context;
+ this._k = (1 - tension) / 6;
+ }
+ Cardinal.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
+ this._point = 0;
+ },
+ lineEnd: function() {
+ switch (this._point) {
+ case 2:
+ this._context.lineTo(this._x2, this._y2);
+ break;
+ case 3:
+ point$1(this, this._x1, this._y1);
+ break;
+ }
+ if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
+ this._line = 1 - this._line;
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2);
+ break;
+ case 1:
+ this._point = 2;
+ this._x1 = x2, this._y1 = y2;
+ break;
+ case 2:
+ this._point = 3;
+ // proceed
+ default:
+ point$1(this, x2, y2);
+ break;
+ }
+ this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2;
+ this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2;
+ }
+ };
+ var cardinal = function custom(tension) {
+ function cardinal2(context) {
+ return new Cardinal(context, tension);
+ }
+ cardinal2.tension = function(tension2) {
+ return custom(+tension2);
+ };
+ return cardinal2;
+ }(0);
+ function CardinalClosed(context, tension) {
+ this._context = context;
+ this._k = (1 - tension) / 6;
+ }
+ CardinalClosed.prototype = {
+ areaStart: noop,
+ areaEnd: noop,
+ lineStart: function() {
+ this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
+ this._point = 0;
+ },
+ lineEnd: function() {
+ switch (this._point) {
+ case 1: {
+ this._context.moveTo(this._x3, this._y3);
+ this._context.closePath();
+ break;
+ }
+ case 2: {
+ this._context.lineTo(this._x3, this._y3);
+ this._context.closePath();
+ break;
+ }
+ case 3: {
+ this.point(this._x3, this._y3);
+ this.point(this._x4, this._y4);
+ this.point(this._x5, this._y5);
+ break;
+ }
+ }
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ this._x3 = x2, this._y3 = y2;
+ break;
+ case 1:
+ this._point = 2;
+ this._context.moveTo(this._x4 = x2, this._y4 = y2);
+ break;
+ case 2:
+ this._point = 3;
+ this._x5 = x2, this._y5 = y2;
+ break;
+ default:
+ point$1(this, x2, y2);
+ break;
+ }
+ this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2;
+ this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2;
+ }
+ };
+ var cardinalClosed = function custom(tension) {
+ function cardinal2(context) {
+ return new CardinalClosed(context, tension);
+ }
+ cardinal2.tension = function(tension2) {
+ return custom(+tension2);
+ };
+ return cardinal2;
+ }(0);
+ function CardinalOpen(context, tension) {
+ this._context = context;
+ this._k = (1 - tension) / 6;
+ }
+ CardinalOpen.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
+ this._point = 0;
+ },
+ lineEnd: function() {
+ if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
+ this._line = 1 - this._line;
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ break;
+ case 1:
+ this._point = 2;
+ break;
+ case 2:
+ this._point = 3;
+ this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
+ break;
+ case 3:
+ this._point = 4;
+ // proceed
+ default:
+ point$1(this, x2, y2);
+ break;
+ }
+ this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2;
+ this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2;
+ }
+ };
+ var cardinalOpen = function custom(tension) {
+ function cardinal2(context) {
+ return new CardinalOpen(context, tension);
+ }
+ cardinal2.tension = function(tension2) {
+ return custom(+tension2);
+ };
+ return cardinal2;
+ }(0);
+ function point$2(that, x2, y2) {
+ var x1 = that._x1, y1 = that._y1, x22 = that._x2, y22 = that._y2;
+ if (that._l01_a > epsilon) {
+ var a2 = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a, n = 3 * that._l01_a * (that._l01_a + that._l12_a);
+ x1 = (x1 * a2 - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n;
+ y1 = (y1 * a2 - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n;
+ }
+ if (that._l23_a > epsilon) {
+ var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a, m = 3 * that._l23_a * (that._l23_a + that._l12_a);
+ x22 = (x22 * b + that._x1 * that._l23_2a - x2 * that._l12_2a) / m;
+ y22 = (y22 * b + that._y1 * that._l23_2a - y2 * that._l12_2a) / m;
+ }
+ that._context.bezierCurveTo(x1, y1, x22, y22, that._x2, that._y2);
+ }
+ function CatmullRom(context, alpha) {
+ this._context = context;
+ this._alpha = alpha;
+ }
+ CatmullRom.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
+ this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
+ },
+ lineEnd: function() {
+ switch (this._point) {
+ case 2:
+ this._context.lineTo(this._x2, this._y2);
+ break;
+ case 3:
+ this.point(this._x2, this._y2);
+ break;
+ }
+ if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
+ this._line = 1 - this._line;
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ if (this._point) {
+ var x23 = this._x2 - x2, y23 = this._y2 - y2;
+ this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
+ }
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2);
+ break;
+ case 1:
+ this._point = 2;
+ break;
+ case 2:
+ this._point = 3;
+ // proceed
+ default:
+ point$2(this, x2, y2);
+ break;
+ }
+ this._l01_a = this._l12_a, this._l12_a = this._l23_a;
+ this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
+ this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2;
+ this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2;
+ }
+ };
+ var catmullRom = function custom(alpha) {
+ function catmullRom2(context) {
+ return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0);
+ }
+ catmullRom2.alpha = function(alpha2) {
+ return custom(+alpha2);
+ };
+ return catmullRom2;
+ }(0.5);
+ function CatmullRomClosed(context, alpha) {
+ this._context = context;
+ this._alpha = alpha;
+ }
+ CatmullRomClosed.prototype = {
+ areaStart: noop,
+ areaEnd: noop,
+ lineStart: function() {
+ this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
+ this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
+ },
+ lineEnd: function() {
+ switch (this._point) {
+ case 1: {
+ this._context.moveTo(this._x3, this._y3);
+ this._context.closePath();
+ break;
+ }
+ case 2: {
+ this._context.lineTo(this._x3, this._y3);
+ this._context.closePath();
+ break;
+ }
+ case 3: {
+ this.point(this._x3, this._y3);
+ this.point(this._x4, this._y4);
+ this.point(this._x5, this._y5);
+ break;
+ }
+ }
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ if (this._point) {
+ var x23 = this._x2 - x2, y23 = this._y2 - y2;
+ this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
+ }
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ this._x3 = x2, this._y3 = y2;
+ break;
+ case 1:
+ this._point = 2;
+ this._context.moveTo(this._x4 = x2, this._y4 = y2);
+ break;
+ case 2:
+ this._point = 3;
+ this._x5 = x2, this._y5 = y2;
+ break;
+ default:
+ point$2(this, x2, y2);
+ break;
+ }
+ this._l01_a = this._l12_a, this._l12_a = this._l23_a;
+ this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
+ this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2;
+ this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2;
+ }
+ };
+ var catmullRomClosed = function custom(alpha) {
+ function catmullRom2(context) {
+ return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0);
+ }
+ catmullRom2.alpha = function(alpha2) {
+ return custom(+alpha2);
+ };
+ return catmullRom2;
+ }(0.5);
+ function CatmullRomOpen(context, alpha) {
+ this._context = context;
+ this._alpha = alpha;
+ }
+ CatmullRomOpen.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
+ this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
+ },
+ lineEnd: function() {
+ if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
+ this._line = 1 - this._line;
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ if (this._point) {
+ var x23 = this._x2 - x2, y23 = this._y2 - y2;
+ this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
+ }
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ break;
+ case 1:
+ this._point = 2;
+ break;
+ case 2:
+ this._point = 3;
+ this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
+ break;
+ case 3:
+ this._point = 4;
+ // proceed
+ default:
+ point$2(this, x2, y2);
+ break;
+ }
+ this._l01_a = this._l12_a, this._l12_a = this._l23_a;
+ this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
+ this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2;
+ this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2;
+ }
+ };
+ var catmullRomOpen = function custom(alpha) {
+ function catmullRom2(context) {
+ return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0);
+ }
+ catmullRom2.alpha = function(alpha2) {
+ return custom(+alpha2);
+ };
+ return catmullRom2;
+ }(0.5);
+ function LinearClosed(context) {
+ this._context = context;
+ }
+ LinearClosed.prototype = {
+ areaStart: noop,
+ areaEnd: noop,
+ lineStart: function() {
+ this._point = 0;
+ },
+ lineEnd: function() {
+ if (this._point) this._context.closePath();
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ if (this._point) this._context.lineTo(x2, y2);
+ else this._point = 1, this._context.moveTo(x2, y2);
+ }
+ };
+ function linearClosed(context) {
+ return new LinearClosed(context);
+ }
+ function sign(x2) {
+ return x2 < 0 ? -1 : 1;
+ }
+ function slope3(that, x2, y2) {
+ var h0 = that._x1 - that._x0, h1 = x2 - that._x1, s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0), s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0), p = (s0 * h1 + s1 * h0) / (h0 + h1);
+ return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;
+ }
+ function slope2(that, t) {
+ var h = that._x1 - that._x0;
+ return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t;
+ }
+ function point$3(that, t02, t12) {
+ var x0 = that._x0, y0 = that._y0, x1 = that._x1, y1 = that._y1, dx = (x1 - x0) / 3;
+ that._context.bezierCurveTo(x0 + dx, y0 + dx * t02, x1 - dx, y1 - dx * t12, x1, y1);
+ }
+ function MonotoneX(context) {
+ this._context = context;
+ }
+ MonotoneX.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN;
+ this._point = 0;
+ },
+ lineEnd: function() {
+ switch (this._point) {
+ case 2:
+ this._context.lineTo(this._x1, this._y1);
+ break;
+ case 3:
+ point$3(this, this._t0, slope2(this, this._t0));
+ break;
+ }
+ if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
+ this._line = 1 - this._line;
+ },
+ point: function(x2, y2) {
+ var t12 = NaN;
+ x2 = +x2, y2 = +y2;
+ if (x2 === this._x1 && y2 === this._y1) return;
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2);
+ break;
+ case 1:
+ this._point = 2;
+ break;
+ case 2:
+ this._point = 3;
+ point$3(this, slope2(this, t12 = slope3(this, x2, y2)), t12);
+ break;
+ default:
+ point$3(this, this._t0, t12 = slope3(this, x2, y2));
+ break;
+ }
+ this._x0 = this._x1, this._x1 = x2;
+ this._y0 = this._y1, this._y1 = y2;
+ this._t0 = t12;
+ }
+ };
+ function MonotoneY(context) {
+ this._context = new ReflectContext(context);
+ }
+ (MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x2, y2) {
+ MonotoneX.prototype.point.call(this, y2, x2);
+ };
+ function ReflectContext(context) {
+ this._context = context;
+ }
+ ReflectContext.prototype = {
+ moveTo: function(x2, y2) {
+ this._context.moveTo(y2, x2);
+ },
+ closePath: function() {
+ this._context.closePath();
+ },
+ lineTo: function(x2, y2) {
+ this._context.lineTo(y2, x2);
+ },
+ bezierCurveTo: function(x1, y1, x2, y2, x3, y3) {
+ this._context.bezierCurveTo(y1, x1, y2, x2, y3, x3);
+ }
+ };
+ function monotoneX(context) {
+ return new MonotoneX(context);
+ }
+ function monotoneY(context) {
+ return new MonotoneY(context);
+ }
+ function Natural(context) {
+ this._context = context;
+ }
+ Natural.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._x = [];
+ this._y = [];
+ },
+ lineEnd: function() {
+ var x2 = this._x, y2 = this._y, n = x2.length;
+ if (n) {
+ this._line ? this._context.lineTo(x2[0], y2[0]) : this._context.moveTo(x2[0], y2[0]);
+ if (n === 2) {
+ this._context.lineTo(x2[1], y2[1]);
+ } else {
+ var px = controlPoints(x2), py = controlPoints(y2);
+ for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) {
+ this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x2[i1], y2[i1]);
+ }
+ }
+ }
+ if (this._line || this._line !== 0 && n === 1) this._context.closePath();
+ this._line = 1 - this._line;
+ this._x = this._y = null;
+ },
+ point: function(x2, y2) {
+ this._x.push(+x2);
+ this._y.push(+y2);
+ }
+ };
+ function controlPoints(x2) {
+ var i, n = x2.length - 1, m, a2 = new Array(n), b = new Array(n), r = new Array(n);
+ a2[0] = 0, b[0] = 2, r[0] = x2[0] + 2 * x2[1];
+ for (i = 1; i < n - 1; ++i) a2[i] = 1, b[i] = 4, r[i] = 4 * x2[i] + 2 * x2[i + 1];
+ a2[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x2[n - 1] + x2[n];
+ for (i = 1; i < n; ++i) m = a2[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1];
+ a2[n - 1] = r[n - 1] / b[n - 1];
+ for (i = n - 2; i >= 0; --i) a2[i] = (r[i] - a2[i + 1]) / b[i];
+ b[n - 1] = (x2[n] + a2[n - 1]) / 2;
+ for (i = 0; i < n - 1; ++i) b[i] = 2 * x2[i + 1] - a2[i + 1];
+ return [a2, b];
+ }
+ function natural(context) {
+ return new Natural(context);
+ }
+ function Step(context, t) {
+ this._context = context;
+ this._t = t;
+ }
+ Step.prototype = {
+ areaStart: function() {
+ this._line = 0;
+ },
+ areaEnd: function() {
+ this._line = NaN;
+ },
+ lineStart: function() {
+ this._x = this._y = NaN;
+ this._point = 0;
+ },
+ lineEnd: function() {
+ if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y);
+ if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
+ if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line;
+ },
+ point: function(x2, y2) {
+ x2 = +x2, y2 = +y2;
+ switch (this._point) {
+ case 0:
+ this._point = 1;
+ this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2);
+ break;
+ case 1:
+ this._point = 2;
+ // proceed
+ default: {
+ if (this._t <= 0) {
+ this._context.lineTo(this._x, y2);
+ this._context.lineTo(x2, y2);
+ } else {
+ var x1 = this._x * (1 - this._t) + x2 * this._t;
+ this._context.lineTo(x1, this._y);
+ this._context.lineTo(x1, y2);
+ }
+ break;
+ }
+ }
+ this._x = x2, this._y = y2;
+ }
+ };
+ function step(context) {
+ return new Step(context, 0.5);
+ }
+ function stepBefore(context) {
+ return new Step(context, 0);
+ }
+ function stepAfter(context) {
+ return new Step(context, 1);
+ }
+ function none(series, order) {
+ if (!((n = series.length) > 1)) return;
+ for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
+ s0 = s1, s1 = series[order[i]];
+ for (j = 0; j < m; ++j) {
+ s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
+ }
+ }
+ }
+ function none$1(series) {
+ var n = series.length, o = new Array(n);
+ while (--n >= 0) o[n] = n;
+ return o;
+ }
+ function stackValue(d, key) {
+ return d[key];
+ }
+ function stack() {
+ var keys = constant([]), order = none$1, offset = none, value = stackValue;
+ function stack2(data) {
+ var kz = keys.apply(this, arguments), i, m = data.length, n = kz.length, sz = new Array(n), oz;
+ for (i = 0; i < n; ++i) {
+ for (var ki = kz[i], si = sz[i] = new Array(m), j = 0, sij; j < m; ++j) {
+ si[j] = sij = [0, +value(data[j], ki, j, data)];
+ sij.data = data[j];
+ }
+ si.key = ki;
+ }
+ for (i = 0, oz = order(sz); i < n; ++i) {
+ sz[oz[i]].index = i;
+ }
+ offset(sz, oz);
+ return sz;
+ }
+ stack2.keys = function(_) {
+ return arguments.length ? (keys = typeof _ === "function" ? _ : constant(slice.call(_)), stack2) : keys;
+ };
+ stack2.value = function(_) {
+ return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), stack2) : value;
+ };
+ stack2.order = function(_) {
+ return arguments.length ? (order = _ == null ? none$1 : typeof _ === "function" ? _ : constant(slice.call(_)), stack2) : order;
+ };
+ stack2.offset = function(_) {
+ return arguments.length ? (offset = _ == null ? none : _, stack2) : offset;
+ };
+ return stack2;
+ }
+ function expand(series, order) {
+ if (!((n = series.length) > 0)) return;
+ for (var i, n, j = 0, m = series[0].length, y2; j < m; ++j) {
+ for (y2 = i = 0; i < n; ++i) y2 += series[i][j][1] || 0;
+ if (y2) for (i = 0; i < n; ++i) series[i][j][1] /= y2;
+ }
+ none(series, order);
+ }
+ function diverging(series, order) {
+ if (!((n = series.length) > 0)) return;
+ for (var i, j = 0, d, dy, yp, yn, n, m = series[order[0]].length; j < m; ++j) {
+ for (yp = yn = 0, i = 0; i < n; ++i) {
+ if ((dy = (d = series[order[i]][j])[1] - d[0]) > 0) {
+ d[0] = yp, d[1] = yp += dy;
+ } else if (dy < 0) {
+ d[1] = yn, d[0] = yn += dy;
+ } else {
+ d[0] = 0, d[1] = dy;
+ }
+ }
+ }
+ }
+ function silhouette(series, order) {
+ if (!((n = series.length) > 0)) return;
+ for (var j = 0, s0 = series[order[0]], n, m = s0.length; j < m; ++j) {
+ for (var i = 0, y2 = 0; i < n; ++i) y2 += series[i][j][1] || 0;
+ s0[j][1] += s0[j][0] = -y2 / 2;
+ }
+ none(series, order);
+ }
+ function wiggle(series, order) {
+ if (!((n = series.length) > 0) || !((m = (s0 = series[order[0]]).length) > 0)) return;
+ for (var y2 = 0, j = 1, s0, m, n; j < m; ++j) {
+ for (var i = 0, s1 = 0, s2 = 0; i < n; ++i) {
+ var si = series[order[i]], sij0 = si[j][1] || 0, sij1 = si[j - 1][1] || 0, s3 = (sij0 - sij1) / 2;
+ for (var k2 = 0; k2 < i; ++k2) {
+ var sk = series[order[k2]], skj0 = sk[j][1] || 0, skj1 = sk[j - 1][1] || 0;
+ s3 += skj0 - skj1;
+ }
+ s1 += sij0, s2 += s3 * sij0;
+ }
+ s0[j - 1][1] += s0[j - 1][0] = y2;
+ if (s1) y2 -= s2 / s1;
+ }
+ s0[j - 1][1] += s0[j - 1][0] = y2;
+ none(series, order);
+ }
+ function appearance(series) {
+ var peaks = series.map(peak);
+ return none$1(series).sort(function(a2, b) {
+ return peaks[a2] - peaks[b];
+ });
+ }
+ function peak(series) {
+ var i = -1, j = 0, n = series.length, vi, vj = -Infinity;
+ while (++i < n) if ((vi = +series[i][1]) > vj) vj = vi, j = i;
+ return j;
+ }
+ function ascending(series) {
+ var sums = series.map(sum);
+ return none$1(series).sort(function(a2, b) {
+ return sums[a2] - sums[b];
+ });
+ }
+ function sum(series) {
+ var s2 = 0, i = -1, n = series.length, v;
+ while (++i < n) if (v = +series[i][1]) s2 += v;
+ return s2;
+ }
+ function descending$1(series) {
+ return ascending(series).reverse();
+ }
+ function insideOut(series) {
+ var n = series.length, i, j, sums = series.map(sum), order = appearance(series), top = 0, bottom = 0, tops = [], bottoms = [];
+ for (i = 0; i < n; ++i) {
+ j = order[i];
+ if (top < bottom) {
+ top += sums[j];
+ tops.push(j);
+ } else {
+ bottom += sums[j];
+ bottoms.push(j);
+ }
+ }
+ return bottoms.reverse().concat(tops);
+ }
+ function reverse(series) {
+ return none$1(series).reverse();
+ }
+ exports2.arc = arc;
+ exports2.area = area;
+ exports2.areaRadial = areaRadial;
+ exports2.curveBasis = basis2;
+ exports2.curveBasisClosed = basisClosed;
+ exports2.curveBasisOpen = basisOpen;
+ exports2.curveBundle = bundle;
+ exports2.curveCardinal = cardinal;
+ exports2.curveCardinalClosed = cardinalClosed;
+ exports2.curveCardinalOpen = cardinalOpen;
+ exports2.curveCatmullRom = catmullRom;
+ exports2.curveCatmullRomClosed = catmullRomClosed;
+ exports2.curveCatmullRomOpen = catmullRomOpen;
+ exports2.curveLinear = curveLinear;
+ exports2.curveLinearClosed = linearClosed;
+ exports2.curveMonotoneX = monotoneX;
+ exports2.curveMonotoneY = monotoneY;
+ exports2.curveNatural = natural;
+ exports2.curveStep = step;
+ exports2.curveStepAfter = stepAfter;
+ exports2.curveStepBefore = stepBefore;
+ exports2.line = line;
+ exports2.lineRadial = lineRadial$1;
+ exports2.linkHorizontal = linkHorizontal;
+ exports2.linkRadial = linkRadial;
+ exports2.linkVertical = linkVertical;
+ exports2.pie = pie;
+ exports2.pointRadial = pointRadial;
+ exports2.radialArea = areaRadial;
+ exports2.radialLine = lineRadial$1;
+ exports2.stack = stack;
+ exports2.stackOffsetDiverging = diverging;
+ exports2.stackOffsetExpand = expand;
+ exports2.stackOffsetNone = none;
+ exports2.stackOffsetSilhouette = silhouette;
+ exports2.stackOffsetWiggle = wiggle;
+ exports2.stackOrderAppearance = appearance;
+ exports2.stackOrderAscending = ascending;
+ exports2.stackOrderDescending = descending$1;
+ exports2.stackOrderInsideOut = insideOut;
+ exports2.stackOrderNone = none$1;
+ exports2.stackOrderReverse = reverse;
+ exports2.symbol = symbol;
+ exports2.symbolCircle = circle;
+ exports2.symbolCross = cross;
+ exports2.symbolDiamond = diamond;
+ exports2.symbolSquare = square;
+ exports2.symbolStar = star;
+ exports2.symbolTriangle = triangle;
+ exports2.symbolWye = wye;
+ exports2.symbols = symbols;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/@plotly/d3-sankey/build/d3-sankey.js
+ var require_d3_sankey = __commonJS({
+ "node_modules/@plotly/d3-sankey/build/d3-sankey.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_d3_array(), require_d3_collection(), require_d3_shape()) : typeof define === "function" && false ? define(["exports", "d3-array", "d3-collection", "d3-shape"], factory) : factory(global2.d3 = global2.d3 || {}, global2.d3, global2.d3, global2.d3);
+ })(exports, function(exports2, d3Array, d3Collection, d3Shape) {
+ "use strict";
+ function targetDepth(d) {
+ return d.target.depth;
+ }
+ function left(node) {
+ return node.depth;
+ }
+ function right(node, n) {
+ return n - 1 - node.height;
+ }
+ function justify(node, n) {
+ return node.sourceLinks.length ? node.depth : n - 1;
+ }
+ function center(node) {
+ return node.targetLinks.length ? node.depth : node.sourceLinks.length ? d3Array.min(node.sourceLinks, targetDepth) - 1 : 0;
+ }
+ function constant(x) {
+ return function() {
+ return x;
+ };
+ }
+ function ascendingSourceBreadth(a, b) {
+ return ascendingBreadth(a.source, b.source) || a.index - b.index;
+ }
+ function ascendingTargetBreadth(a, b) {
+ return ascendingBreadth(a.target, b.target) || a.index - b.index;
+ }
+ function ascendingBreadth(a, b) {
+ return a.y0 - b.y0;
+ }
+ function value(d) {
+ return d.value;
+ }
+ function nodeCenter(node) {
+ return (node.y0 + node.y1) / 2;
+ }
+ function weightedSource(link) {
+ return nodeCenter(link.source) * link.value;
+ }
+ function weightedTarget(link) {
+ return nodeCenter(link.target) * link.value;
+ }
+ function defaultId(d) {
+ return d.index;
+ }
+ function defaultNodes(graph) {
+ return graph.nodes;
+ }
+ function defaultLinks(graph) {
+ return graph.links;
+ }
+ function find(nodeById, id) {
+ var node = nodeById.get(id);
+ if (!node) throw new Error("missing: " + id);
+ return node;
+ }
+ var sankey = function() {
+ var x0 = 0, y0 = 0, x1 = 1, y1 = 1, dx = 24, py = 8, id = defaultId, align = justify, nodes = defaultNodes, links = defaultLinks, iterations = 32, maxPaddedSpace = 2 / 3;
+ function sankey2() {
+ var graph = { nodes: nodes.apply(null, arguments), links: links.apply(null, arguments) };
+ computeNodeLinks(graph);
+ computeNodeValues(graph);
+ computeNodeDepths(graph);
+ computeNodeBreadths(graph, iterations);
+ computeLinkBreadths(graph);
+ return graph;
+ }
+ sankey2.update = function(graph) {
+ computeLinkBreadths(graph);
+ return graph;
+ };
+ sankey2.nodeId = function(_) {
+ return arguments.length ? (id = typeof _ === "function" ? _ : constant(_), sankey2) : id;
+ };
+ sankey2.nodeAlign = function(_) {
+ return arguments.length ? (align = typeof _ === "function" ? _ : constant(_), sankey2) : align;
+ };
+ sankey2.nodeWidth = function(_) {
+ return arguments.length ? (dx = +_, sankey2) : dx;
+ };
+ sankey2.nodePadding = function(_) {
+ return arguments.length ? (py = +_, sankey2) : py;
+ };
+ sankey2.nodes = function(_) {
+ return arguments.length ? (nodes = typeof _ === "function" ? _ : constant(_), sankey2) : nodes;
+ };
+ sankey2.links = function(_) {
+ return arguments.length ? (links = typeof _ === "function" ? _ : constant(_), sankey2) : links;
+ };
+ sankey2.size = function(_) {
+ return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey2) : [x1 - x0, y1 - y0];
+ };
+ sankey2.extent = function(_) {
+ return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey2) : [[x0, y0], [x1, y1]];
+ };
+ sankey2.iterations = function(_) {
+ return arguments.length ? (iterations = +_, sankey2) : iterations;
+ };
+ function computeNodeLinks(graph) {
+ graph.nodes.forEach(function(node, i) {
+ node.index = i;
+ node.sourceLinks = [];
+ node.targetLinks = [];
+ });
+ var nodeById = d3Collection.map(graph.nodes, id);
+ graph.links.forEach(function(link, i) {
+ link.index = i;
+ var source = link.source, target = link.target;
+ if (typeof source !== "object") source = link.source = find(nodeById, source);
+ if (typeof target !== "object") target = link.target = find(nodeById, target);
+ source.sourceLinks.push(link);
+ target.targetLinks.push(link);
+ });
+ }
+ function computeNodeValues(graph) {
+ graph.nodes.forEach(function(node) {
+ node.value = Math.max(
+ d3Array.sum(node.sourceLinks, value),
+ d3Array.sum(node.targetLinks, value)
+ );
+ });
+ }
+ function computeNodeDepths(graph) {
+ var nodes2, next, x;
+ for (nodes2 = graph.nodes, next = [], x = 0; nodes2.length; ++x, nodes2 = next, next = []) {
+ nodes2.forEach(function(node) {
+ node.depth = x;
+ node.sourceLinks.forEach(function(link) {
+ if (next.indexOf(link.target) < 0) {
+ next.push(link.target);
+ }
+ });
+ });
+ }
+ for (nodes2 = graph.nodes, next = [], x = 0; nodes2.length; ++x, nodes2 = next, next = []) {
+ nodes2.forEach(function(node) {
+ node.height = x;
+ node.targetLinks.forEach(function(link) {
+ if (next.indexOf(link.source) < 0) {
+ next.push(link.source);
+ }
+ });
+ });
+ }
+ var kx = (x1 - x0 - dx) / (x - 1);
+ graph.nodes.forEach(function(node) {
+ node.x1 = (node.x0 = x0 + Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x)))) * kx) + dx;
+ });
+ }
+ function computeNodeBreadths(graph) {
+ var columns = d3Collection.nest().key(function(d) {
+ return d.x0;
+ }).sortKeys(d3Array.ascending).entries(graph.nodes).map(function(d) {
+ return d.values;
+ });
+ initializeNodeBreadth();
+ resolveCollisions();
+ for (var alpha = 1, n = iterations; n > 0; --n) {
+ relaxRightToLeft(alpha *= 0.99);
+ resolveCollisions();
+ relaxLeftToRight(alpha);
+ resolveCollisions();
+ }
+ function initializeNodeBreadth() {
+ var L = d3Array.max(columns, function(nodes2) {
+ return nodes2.length;
+ });
+ var maxNodePadding = maxPaddedSpace * (y1 - y0) / (L - 1);
+ if (py > maxNodePadding) py = maxNodePadding;
+ var ky = d3Array.min(columns, function(nodes2) {
+ return (y1 - y0 - (nodes2.length - 1) * py) / d3Array.sum(nodes2, value);
+ });
+ columns.forEach(function(nodes2) {
+ nodes2.forEach(function(node, i) {
+ node.y1 = (node.y0 = i) + node.value * ky;
+ });
+ });
+ graph.links.forEach(function(link) {
+ link.width = link.value * ky;
+ });
+ }
+ function relaxLeftToRight(alpha2) {
+ columns.forEach(function(nodes2) {
+ nodes2.forEach(function(node) {
+ if (node.targetLinks.length) {
+ var dy = (d3Array.sum(node.targetLinks, weightedSource) / d3Array.sum(node.targetLinks, value) - nodeCenter(node)) * alpha2;
+ node.y0 += dy, node.y1 += dy;
+ }
+ });
+ });
+ }
+ function relaxRightToLeft(alpha2) {
+ columns.slice().reverse().forEach(function(nodes2) {
+ nodes2.forEach(function(node) {
+ if (node.sourceLinks.length) {
+ var dy = (d3Array.sum(node.sourceLinks, weightedTarget) / d3Array.sum(node.sourceLinks, value) - nodeCenter(node)) * alpha2;
+ node.y0 += dy, node.y1 += dy;
+ }
+ });
+ });
+ }
+ function resolveCollisions() {
+ columns.forEach(function(nodes2) {
+ var node, dy, y = y0, n2 = nodes2.length, i;
+ nodes2.sort(ascendingBreadth);
+ for (i = 0; i < n2; ++i) {
+ node = nodes2[i];
+ dy = y - node.y0;
+ if (dy > 0) node.y0 += dy, node.y1 += dy;
+ y = node.y1 + py;
+ }
+ dy = y - py - y1;
+ if (dy > 0) {
+ y = node.y0 -= dy, node.y1 -= dy;
+ for (i = n2 - 2; i >= 0; --i) {
+ node = nodes2[i];
+ dy = node.y1 + py - y;
+ if (dy > 0) node.y0 -= dy, node.y1 -= dy;
+ y = node.y0;
+ }
+ }
+ });
+ }
+ }
+ function computeLinkBreadths(graph) {
+ graph.nodes.forEach(function(node) {
+ node.sourceLinks.sort(ascendingTargetBreadth);
+ node.targetLinks.sort(ascendingSourceBreadth);
+ });
+ graph.nodes.forEach(function(node) {
+ var y02 = node.y0, y12 = y02;
+ node.sourceLinks.forEach(function(link) {
+ link.y0 = y02 + link.width / 2, y02 += link.width;
+ });
+ node.targetLinks.forEach(function(link) {
+ link.y1 = y12 + link.width / 2, y12 += link.width;
+ });
+ });
+ }
+ return sankey2;
+ };
+ function horizontalSource(d) {
+ return [d.source.x1, d.y0];
+ }
+ function horizontalTarget(d) {
+ return [d.target.x0, d.y1];
+ }
+ var sankeyLinkHorizontal = function() {
+ return d3Shape.linkHorizontal().source(horizontalSource).target(horizontalTarget);
+ };
+ exports2.sankey = sankey;
+ exports2.sankeyCenter = center;
+ exports2.sankeyLeft = left;
+ exports2.sankeyRight = right;
+ exports2.sankeyJustify = justify;
+ exports2.sankeyLinkHorizontal = sankeyLinkHorizontal;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // node_modules/elementary-circuits-directed-graph/johnson.js
+ var require_johnson = __commonJS({
+ "node_modules/elementary-circuits-directed-graph/johnson.js"(exports, module) {
+ var tarjan = require_scc();
+ module.exports = function findCircuits(edges, cb) {
+ var circuits = [];
+ var stack = [];
+ var blocked = [];
+ var B2 = {};
+ var Ak = [];
+ var s;
+ function unblock(u) {
+ blocked[u] = false;
+ if (B2.hasOwnProperty(u)) {
+ Object.keys(B2[u]).forEach(function(w) {
+ delete B2[u][w];
+ if (blocked[w]) {
+ unblock(w);
+ }
+ });
+ }
+ }
+ function circuit(v) {
+ var found = false;
+ stack.push(v);
+ blocked[v] = true;
+ var i2;
+ var w;
+ for (i2 = 0; i2 < Ak[v].length; i2++) {
+ w = Ak[v][i2];
+ if (w === s) {
+ output(s, stack);
+ found = true;
+ } else if (!blocked[w]) {
+ found = circuit(w);
+ }
+ }
+ if (found) {
+ unblock(v);
+ } else {
+ for (i2 = 0; i2 < Ak[v].length; i2++) {
+ w = Ak[v][i2];
+ var entry = B2[w];
+ if (!entry) {
+ entry = {};
+ B2[w] = entry;
+ }
+ entry[w] = true;
+ }
+ }
+ stack.pop();
+ return found;
+ }
+ function output(start, stack2) {
+ var cycle = [].concat(stack2).concat(start);
+ if (cb) {
+ cb(circuit);
+ } else {
+ circuits.push(cycle);
+ }
+ }
+ function subgraph(minId) {
+ for (var i2 = 0; i2 < edges.length; i2++) {
+ if (i2 < minId) edges[i2] = [];
+ edges[i2] = edges[i2].filter(function(i3) {
+ return i3 >= minId;
+ });
+ }
+ }
+ function adjacencyStructureSCC(from) {
+ subgraph(from);
+ var g = edges;
+ var sccs = tarjan(g);
+ var ccs = sccs.components.filter(function(scc) {
+ return scc.length > 1;
+ });
+ var leastVertex = Infinity;
+ var leastVertexComponent;
+ for (var i2 = 0; i2 < ccs.length; i2++) {
+ for (var j2 = 0; j2 < ccs[i2].length; j2++) {
+ if (ccs[i2][j2] < leastVertex) {
+ leastVertex = ccs[i2][j2];
+ leastVertexComponent = i2;
+ }
+ }
+ }
+ var cc = ccs[leastVertexComponent];
+ if (!cc) return false;
+ var adjList = edges.map(function(l, index) {
+ if (cc.indexOf(index) === -1) return [];
+ return l.filter(function(i3) {
+ return cc.indexOf(i3) !== -1;
+ });
+ });
+ return {
+ leastVertex,
+ adjList
+ };
+ }
+ s = 0;
+ var n = edges.length;
+ while (s < n) {
+ var p = adjacencyStructureSCC(s);
+ s = p.leastVertex;
+ Ak = p.adjList;
+ if (Ak) {
+ for (var i = 0; i < Ak.length; i++) {
+ for (var j = 0; j < Ak[i].length; j++) {
+ var vertexId = Ak[i][j];
+ blocked[+vertexId] = false;
+ B2[vertexId] = {};
+ }
+ }
+ circuit(s);
+ s = s + 1;
+ } else {
+ s = n;
+ }
+ }
+ if (cb) {
+ return;
+ } else {
+ return circuits;
+ }
+ };
+ }
+ });
+
+ // node_modules/@plotly/d3-sankey-circular/dist/d3-sankey-circular.js
+ var require_d3_sankey_circular = __commonJS({
+ "node_modules/@plotly/d3-sankey-circular/dist/d3-sankey-circular.js"(exports, module) {
+ (function(global2, factory) {
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_d3_array(), require_d3_collection(), require_d3_shape(), require_johnson()) : typeof define === "function" && false ? define(["exports", "d3-array", "d3-collection", "d3-shape", "elementary-circuits-directed-graph"], factory) : factory(global2.d3 = global2.d3 || {}, global2.d3, global2.d3, global2.d3, null);
+ })(exports, function(exports2, d3Array, d3Collection, d3Shape, findCircuits) {
+ "use strict";
+ findCircuits = findCircuits && findCircuits.hasOwnProperty("default") ? findCircuits["default"] : findCircuits;
+ function targetDepth(d) {
+ return d.target.depth;
+ }
+ function left(node) {
+ return node.depth;
+ }
+ function right(node, n) {
+ return n - 1 - node.height;
+ }
+ function justify(node, n) {
+ return node.sourceLinks.length ? node.depth : n - 1;
+ }
+ function center(node) {
+ return node.targetLinks.length ? node.depth : node.sourceLinks.length ? d3Array.min(node.sourceLinks, targetDepth) - 1 : 0;
+ }
+ function constant(x) {
+ return function() {
+ return x;
+ };
+ }
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
+ return typeof obj;
+ } : function(obj) {
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
+ };
+ function ascendingSourceBreadth(a, b) {
+ return ascendingBreadth(a.source, b.source) || a.index - b.index;
+ }
+ function ascendingTargetBreadth(a, b) {
+ return ascendingBreadth(a.target, b.target) || a.index - b.index;
+ }
+ function ascendingBreadth(a, b) {
+ if (a.partOfCycle === b.partOfCycle) {
+ return a.y0 - b.y0;
+ } else {
+ if (a.circularLinkType === "top" || b.circularLinkType === "bottom") {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ }
+ function value(d) {
+ return d.value;
+ }
+ function nodeCenter(node) {
+ return (node.y0 + node.y1) / 2;
+ }
+ function linkSourceCenter(link) {
+ return nodeCenter(link.source);
+ }
+ function linkTargetCenter(link) {
+ return nodeCenter(link.target);
+ }
+ function defaultId(d) {
+ return d.index;
+ }
+ function defaultNodes(graph) {
+ return graph.nodes;
+ }
+ function defaultLinks(graph) {
+ return graph.links;
+ }
+ function find(nodeById, id) {
+ var node = nodeById.get(id);
+ if (!node) throw new Error("missing: " + id);
+ return node;
+ }
+ function getNodeID(node, id) {
+ return id(node);
+ }
+ var verticalMargin = 25;
+ var baseRadius = 10;
+ var scale = 0.3;
+ function sankeyCircular() {
+ var x0 = 0, y0 = 0, x1 = 1, y1 = 1, dx = 24, py, id = defaultId, align = justify, nodes = defaultNodes, links = defaultLinks, iterations = 32, circularLinkGap = 2, paddingRatio, sortNodes = null;
+ function sankeyCircular2() {
+ var graph = {
+ nodes: nodes.apply(null, arguments),
+ links: links.apply(null, arguments)
+ // Process the graph's nodes and links, setting their positions
+ // 1. Associate the nodes with their respective links, and vice versa
+ };
+ computeNodeLinks(graph);
+ identifyCircles(graph, id, sortNodes);
+ computeNodeValues(graph);
+ computeNodeDepths(graph);
+ selectCircularLinkTypes(graph, id);
+ computeNodeBreadths(graph, iterations, id);
+ computeLinkBreadths(graph);
+ var linkSortingIterations = 4;
+ for (var iteration = 0; iteration < linkSortingIterations; iteration++) {
+ sortSourceLinks(graph, y1, id);
+ sortTargetLinks(graph, y1, id);
+ resolveNodeLinkOverlaps(graph, y0, y1, id);
+ sortSourceLinks(graph, y1, id);
+ sortTargetLinks(graph, y1, id);
+ }
+ fillHeight(graph, y0, y1);
+ addCircularPathData(graph, circularLinkGap, y1, id);
+ return graph;
+ }
+ sankeyCircular2.nodeId = function(_) {
+ return arguments.length ? (id = typeof _ === "function" ? _ : constant(_), sankeyCircular2) : id;
+ };
+ sankeyCircular2.nodeAlign = function(_) {
+ return arguments.length ? (align = typeof _ === "function" ? _ : constant(_), sankeyCircular2) : align;
+ };
+ sankeyCircular2.nodeWidth = function(_) {
+ return arguments.length ? (dx = +_, sankeyCircular2) : dx;
+ };
+ sankeyCircular2.nodePadding = function(_) {
+ return arguments.length ? (py = +_, sankeyCircular2) : py;
+ };
+ sankeyCircular2.nodes = function(_) {
+ return arguments.length ? (nodes = typeof _ === "function" ? _ : constant(_), sankeyCircular2) : nodes;
+ };
+ sankeyCircular2.links = function(_) {
+ return arguments.length ? (links = typeof _ === "function" ? _ : constant(_), sankeyCircular2) : links;
+ };
+ sankeyCircular2.size = function(_) {
+ return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankeyCircular2) : [x1 - x0, y1 - y0];
+ };
+ sankeyCircular2.extent = function(_) {
+ return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankeyCircular2) : [[x0, y0], [x1, y1]];
+ };
+ sankeyCircular2.iterations = function(_) {
+ return arguments.length ? (iterations = +_, sankeyCircular2) : iterations;
+ };
+ sankeyCircular2.circularLinkGap = function(_) {
+ return arguments.length ? (circularLinkGap = +_, sankeyCircular2) : circularLinkGap;
+ };
+ sankeyCircular2.nodePaddingRatio = function(_) {
+ return arguments.length ? (paddingRatio = +_, sankeyCircular2) : paddingRatio;
+ };
+ sankeyCircular2.sortNodes = function(_) {
+ return arguments.length ? (sortNodes = _, sankeyCircular2) : sortNodes;
+ };
+ sankeyCircular2.update = function(graph) {
+ selectCircularLinkTypes(graph, id);
+ computeLinkBreadths(graph);
+ graph.links.forEach(function(link) {
+ if (link.circular) {
+ link.circularLinkType = link.y0 + link.y1 < y1 ? "top" : "bottom";
+ link.source.circularLinkType = link.circularLinkType;
+ link.target.circularLinkType = link.circularLinkType;
+ }
+ });
+ sortSourceLinks(graph, y1, id, false);
+ sortTargetLinks(graph, y1, id);
+ addCircularPathData(graph, circularLinkGap, y1, id);
+ return graph;
+ };
+ function computeNodeLinks(graph) {
+ graph.nodes.forEach(function(node, i) {
+ node.index = i;
+ node.sourceLinks = [];
+ node.targetLinks = [];
+ });
+ var nodeById = d3Collection.map(graph.nodes, id);
+ graph.links.forEach(function(link, i) {
+ link.index = i;
+ var source = link.source;
+ var target = link.target;
+ if ((typeof source === "undefined" ? "undefined" : _typeof(source)) !== "object") {
+ source = link.source = find(nodeById, source);
+ }
+ if ((typeof target === "undefined" ? "undefined" : _typeof(target)) !== "object") {
+ target = link.target = find(nodeById, target);
+ }
+ source.sourceLinks.push(link);
+ target.targetLinks.push(link);
+ });
+ return graph;
+ }
+ function computeNodeValues(graph) {
+ graph.nodes.forEach(function(node) {
+ node.partOfCycle = false;
+ node.value = Math.max(d3Array.sum(node.sourceLinks, value), d3Array.sum(node.targetLinks, value));
+ node.sourceLinks.forEach(function(link) {
+ if (link.circular) {
+ node.partOfCycle = true;
+ node.circularLinkType = link.circularLinkType;
+ }
+ });
+ node.targetLinks.forEach(function(link) {
+ if (link.circular) {
+ node.partOfCycle = true;
+ node.circularLinkType = link.circularLinkType;
+ }
+ });
+ });
+ }
+ function getCircleMargins(graph) {
+ var totalTopLinksWidth = 0, totalBottomLinksWidth = 0, totalRightLinksWidth = 0, totalLeftLinksWidth = 0;
+ var maxColumn = d3Array.max(graph.nodes, function(node) {
+ return node.column;
+ });
+ graph.links.forEach(function(link) {
+ if (link.circular) {
+ if (link.circularLinkType == "top") {
+ totalTopLinksWidth = totalTopLinksWidth + link.width;
+ } else {
+ totalBottomLinksWidth = totalBottomLinksWidth + link.width;
+ }
+ if (link.target.column == 0) {
+ totalLeftLinksWidth = totalLeftLinksWidth + link.width;
+ }
+ if (link.source.column == maxColumn) {
+ totalRightLinksWidth = totalRightLinksWidth + link.width;
+ }
+ }
+ });
+ totalTopLinksWidth = totalTopLinksWidth > 0 ? totalTopLinksWidth + verticalMargin + baseRadius : totalTopLinksWidth;
+ totalBottomLinksWidth = totalBottomLinksWidth > 0 ? totalBottomLinksWidth + verticalMargin + baseRadius : totalBottomLinksWidth;
+ totalRightLinksWidth = totalRightLinksWidth > 0 ? totalRightLinksWidth + verticalMargin + baseRadius : totalRightLinksWidth;
+ totalLeftLinksWidth = totalLeftLinksWidth > 0 ? totalLeftLinksWidth + verticalMargin + baseRadius : totalLeftLinksWidth;
+ return { "top": totalTopLinksWidth, "bottom": totalBottomLinksWidth, "left": totalLeftLinksWidth, "right": totalRightLinksWidth };
+ }
+ function scaleSankeySize(graph, margin) {
+ var maxColumn = d3Array.max(graph.nodes, function(node) {
+ return node.column;
+ });
+ var currentWidth = x1 - x0;
+ var currentHeight = y1 - y0;
+ var newWidth = currentWidth + margin.right + margin.left;
+ var newHeight = currentHeight + margin.top + margin.bottom;
+ var scaleX = currentWidth / newWidth;
+ var scaleY = currentHeight / newHeight;
+ x0 = x0 * scaleX + margin.left;
+ x1 = margin.right == 0 ? x1 : x1 * scaleX;
+ y0 = y0 * scaleY + margin.top;
+ y1 = y1 * scaleY;
+ graph.nodes.forEach(function(node) {
+ node.x0 = x0 + node.column * ((x1 - x0 - dx) / maxColumn);
+ node.x1 = node.x0 + dx;
+ });
+ return scaleY;
+ }
+ function computeNodeDepths(graph) {
+ var nodes2, next, x;
+ for (nodes2 = graph.nodes, next = [], x = 0; nodes2.length; ++x, nodes2 = next, next = []) {
+ nodes2.forEach(function(node) {
+ node.depth = x;
+ node.sourceLinks.forEach(function(link) {
+ if (next.indexOf(link.target) < 0 && !link.circular) {
+ next.push(link.target);
+ }
+ });
+ });
+ }
+ for (nodes2 = graph.nodes, next = [], x = 0; nodes2.length; ++x, nodes2 = next, next = []) {
+ nodes2.forEach(function(node) {
+ node.height = x;
+ node.targetLinks.forEach(function(link) {
+ if (next.indexOf(link.source) < 0 && !link.circular) {
+ next.push(link.source);
+ }
+ });
+ });
+ }
+ graph.nodes.forEach(function(node) {
+ node.column = Math.floor(align.call(null, node, x));
+ });
+ }
+ function computeNodeBreadths(graph, iterations2, id2) {
+ var columns = d3Collection.nest().key(function(d) {
+ return d.column;
+ }).sortKeys(d3Array.ascending).entries(graph.nodes).map(function(d) {
+ return d.values;
+ });
+ initializeNodeBreadth(id2);
+ resolveCollisions();
+ for (var alpha = 1, n = iterations2; n > 0; --n) {
+ relaxLeftAndRight(alpha *= 0.99, id2);
+ resolveCollisions();
+ }
+ function initializeNodeBreadth(id3) {
+ if (paddingRatio) {
+ var padding = Infinity;
+ columns.forEach(function(nodes2) {
+ var thisPadding = y1 * paddingRatio / (nodes2.length + 1);
+ padding = thisPadding < padding ? thisPadding : padding;
+ });
+ py = padding;
+ }
+ var ky = d3Array.min(columns, function(nodes2) {
+ return (y1 - y0 - (nodes2.length - 1) * py) / d3Array.sum(nodes2, value);
+ });
+ ky = ky * scale;
+ graph.links.forEach(function(link) {
+ link.width = link.value * ky;
+ });
+ var margin = getCircleMargins(graph);
+ var ratio = scaleSankeySize(graph, margin);
+ ky = ky * ratio;
+ graph.links.forEach(function(link) {
+ link.width = link.value * ky;
+ });
+ columns.forEach(function(nodes2) {
+ var nodesLength = nodes2.length;
+ nodes2.forEach(function(node, i) {
+ if (node.depth == columns.length - 1 && nodesLength == 1) {
+ node.y0 = y1 / 2 - node.value * ky;
+ node.y1 = node.y0 + node.value * ky;
+ } else if (node.depth == 0 && nodesLength == 1) {
+ node.y0 = y1 / 2 - node.value * ky;
+ node.y1 = node.y0 + node.value * ky;
+ } else if (node.partOfCycle) {
+ if (numberOfNonSelfLinkingCycles(node, id3) == 0) {
+ node.y0 = y1 / 2 + i;
+ node.y1 = node.y0 + node.value * ky;
+ } else if (node.circularLinkType == "top") {
+ node.y0 = y0 + i;
+ node.y1 = node.y0 + node.value * ky;
+ } else {
+ node.y0 = y1 - node.value * ky - i;
+ node.y1 = node.y0 + node.value * ky;
+ }
+ } else {
+ if (margin.top == 0 || margin.bottom == 0) {
+ node.y0 = (y1 - y0) / nodesLength * i;
+ node.y1 = node.y0 + node.value * ky;
+ } else {
+ node.y0 = (y1 - y0) / 2 - nodesLength / 2 + i;
+ node.y1 = node.y0 + node.value * ky;
+ }
+ }
+ });
+ });
+ }
+ function relaxLeftAndRight(alpha2, id3) {
+ var columnsLength = columns.length;
+ columns.forEach(function(nodes2) {
+ var n2 = nodes2.length;
+ var depth = nodes2[0].depth;
+ nodes2.forEach(function(node) {
+ var nodeHeight;
+ if (node.sourceLinks.length || node.targetLinks.length) {
+ if (node.partOfCycle && numberOfNonSelfLinkingCycles(node, id3) > 0) ;
+ else if (depth == 0 && n2 == 1) {
+ nodeHeight = node.y1 - node.y0;
+ node.y0 = y1 / 2 - nodeHeight / 2;
+ node.y1 = y1 / 2 + nodeHeight / 2;
+ } else if (depth == columnsLength - 1 && n2 == 1) {
+ nodeHeight = node.y1 - node.y0;
+ node.y0 = y1 / 2 - nodeHeight / 2;
+ node.y1 = y1 / 2 + nodeHeight / 2;
+ } else {
+ var avg = 0;
+ var avgTargetY = d3Array.mean(node.sourceLinks, linkTargetCenter);
+ var avgSourceY = d3Array.mean(node.targetLinks, linkSourceCenter);
+ if (avgTargetY && avgSourceY) {
+ avg = (avgTargetY + avgSourceY) / 2;
+ } else {
+ avg = avgTargetY || avgSourceY;
+ }
+ var dy = (avg - nodeCenter(node)) * alpha2;
+ node.y0 += dy;
+ node.y1 += dy;
+ }
+ }
+ });
+ });
+ }
+ function resolveCollisions() {
+ columns.forEach(function(nodes2) {
+ var node, dy, y = y0, n2 = nodes2.length, i;
+ nodes2.sort(ascendingBreadth);
+ for (i = 0; i < n2; ++i) {
+ node = nodes2[i];
+ dy = y - node.y0;
+ if (dy > 0) {
+ node.y0 += dy;
+ node.y1 += dy;
+ }
+ y = node.y1 + py;
+ }
+ dy = y - py - y1;
+ if (dy > 0) {
+ y = node.y0 -= dy, node.y1 -= dy;
+ for (i = n2 - 2; i >= 0; --i) {
+ node = nodes2[i];
+ dy = node.y1 + py - y;
+ if (dy > 0) node.y0 -= dy, node.y1 -= dy;
+ y = node.y0;
+ }
+ }
+ });
+ }
+ }
+ function computeLinkBreadths(graph) {
+ graph.nodes.forEach(function(node) {
+ node.sourceLinks.sort(ascendingTargetBreadth);
+ node.targetLinks.sort(ascendingSourceBreadth);
+ });
+ graph.nodes.forEach(function(node) {
+ var y02 = node.y0;
+ var y12 = y02;
+ var y0cycle = node.y1;
+ var y1cycle = y0cycle;
+ node.sourceLinks.forEach(function(link) {
+ if (link.circular) {
+ link.y0 = y0cycle - link.width / 2;
+ y0cycle = y0cycle - link.width;
+ } else {
+ link.y0 = y02 + link.width / 2;
+ y02 += link.width;
+ }
+ });
+ node.targetLinks.forEach(function(link) {
+ if (link.circular) {
+ link.y1 = y1cycle - link.width / 2;
+ y1cycle = y1cycle - link.width;
+ } else {
+ link.y1 = y12 + link.width / 2;
+ y12 += link.width;
+ }
+ });
+ });
+ }
+ return sankeyCircular2;
+ }
+ function identifyCircles(graph, id, sortNodes) {
+ var circularLinkID = 0;
+ if (sortNodes === null) {
+ var adjList = [];
+ for (var i = 0; i < graph.links.length; i++) {
+ var link = graph.links[i];
+ var source = link.source.index;
+ var target = link.target.index;
+ if (!adjList[source]) adjList[source] = [];
+ if (!adjList[target]) adjList[target] = [];
+ if (adjList[source].indexOf(target) === -1) adjList[source].push(target);
+ }
+ var cycles = findCircuits(adjList);
+ cycles.sort(function(a, b) {
+ return a.length - b.length;
+ });
+ var circularLinks = {};
+ for (i = 0; i < cycles.length; i++) {
+ var cycle = cycles[i];
+ var last = cycle.slice(-2);
+ if (!circularLinks[last[0]]) circularLinks[last[0]] = {};
+ circularLinks[last[0]][last[1]] = true;
+ }
+ graph.links.forEach(function(link2) {
+ var target2 = link2.target.index;
+ var source2 = link2.source.index;
+ if (target2 === source2 || circularLinks[source2] && circularLinks[source2][target2]) {
+ link2.circular = true;
+ link2.circularLinkID = circularLinkID;
+ circularLinkID = circularLinkID + 1;
+ } else {
+ link2.circular = false;
+ }
+ });
+ } else {
+ graph.links.forEach(function(link2) {
+ if (link2.source[sortNodes] < link2.target[sortNodes]) {
+ link2.circular = false;
+ } else {
+ link2.circular = true;
+ link2.circularLinkID = circularLinkID;
+ circularLinkID = circularLinkID + 1;
+ }
+ });
+ }
+ }
+ function selectCircularLinkTypes(graph, id) {
+ var numberOfTops = 0;
+ var numberOfBottoms = 0;
+ graph.links.forEach(function(link) {
+ if (link.circular) {
+ if (link.source.circularLinkType || link.target.circularLinkType) {
+ link.circularLinkType = link.source.circularLinkType ? link.source.circularLinkType : link.target.circularLinkType;
+ } else {
+ link.circularLinkType = numberOfTops < numberOfBottoms ? "top" : "bottom";
+ }
+ if (link.circularLinkType == "top") {
+ numberOfTops = numberOfTops + 1;
+ } else {
+ numberOfBottoms = numberOfBottoms + 1;
+ }
+ graph.nodes.forEach(function(node) {
+ if (getNodeID(node, id) == getNodeID(link.source, id) || getNodeID(node, id) == getNodeID(link.target, id)) {
+ node.circularLinkType = link.circularLinkType;
+ }
+ });
+ }
+ });
+ graph.links.forEach(function(link) {
+ if (link.circular) {
+ if (link.source.circularLinkType == link.target.circularLinkType) {
+ link.circularLinkType = link.source.circularLinkType;
+ }
+ if (selfLinking(link, id)) {
+ link.circularLinkType = link.source.circularLinkType;
+ }
+ }
+ });
+ }
+ function linkAngle(link) {
+ var adjacent = Math.abs(link.y1 - link.y0);
+ var opposite = Math.abs(link.target.x0 - link.source.x1);
+ return Math.atan(opposite / adjacent);
+ }
+ function circularLinksCross(link1, link2) {
+ if (link1.source.column < link2.target.column) {
+ return false;
+ } else if (link1.target.column > link2.source.column) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ function numberOfNonSelfLinkingCycles(node, id) {
+ var sourceCount = 0;
+ node.sourceLinks.forEach(function(l) {
+ sourceCount = l.circular && !selfLinking(l, id) ? sourceCount + 1 : sourceCount;
+ });
+ var targetCount = 0;
+ node.targetLinks.forEach(function(l) {
+ targetCount = l.circular && !selfLinking(l, id) ? targetCount + 1 : targetCount;
+ });
+ return sourceCount + targetCount;
+ }
+ function onlyCircularLink(link) {
+ var nodeSourceLinks = link.source.sourceLinks;
+ var sourceCount = 0;
+ nodeSourceLinks.forEach(function(l) {
+ sourceCount = l.circular ? sourceCount + 1 : sourceCount;
+ });
+ var nodeTargetLinks = link.target.targetLinks;
+ var targetCount = 0;
+ nodeTargetLinks.forEach(function(l) {
+ targetCount = l.circular ? targetCount + 1 : targetCount;
+ });
+ if (sourceCount > 1 || targetCount > 1) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ function calcVerticalBuffer(links, circularLinkGap, id) {
+ links.sort(sortLinkColumnAscending);
+ links.forEach(function(link, i) {
+ var buffer = 0;
+ if (selfLinking(link, id) && onlyCircularLink(link)) {
+ link.circularPathData.verticalBuffer = buffer + link.width / 2;
+ } else {
+ var j = 0;
+ for (j; j < i; j++) {
+ if (circularLinksCross(links[i], links[j])) {
+ var bufferOverThisLink = links[j].circularPathData.verticalBuffer + links[j].width / 2 + circularLinkGap;
+ buffer = bufferOverThisLink > buffer ? bufferOverThisLink : buffer;
+ }
+ }
+ link.circularPathData.verticalBuffer = buffer + link.width / 2;
+ }
+ });
+ return links;
+ }
+ function addCircularPathData(graph, circularLinkGap, y1, id) {
+ var buffer = 5;
+ var minY = d3Array.min(graph.links, function(link) {
+ return link.source.y0;
+ });
+ graph.links.forEach(function(link) {
+ if (link.circular) {
+ link.circularPathData = {};
+ }
+ });
+ var topLinks = graph.links.filter(function(l) {
+ return l.circularLinkType == "top";
+ });
+ calcVerticalBuffer(topLinks, circularLinkGap, id);
+ var bottomLinks = graph.links.filter(function(l) {
+ return l.circularLinkType == "bottom";
+ });
+ calcVerticalBuffer(bottomLinks, circularLinkGap, id);
+ graph.links.forEach(function(link) {
+ if (link.circular) {
+ link.circularPathData.arcRadius = link.width + baseRadius;
+ link.circularPathData.leftNodeBuffer = buffer;
+ link.circularPathData.rightNodeBuffer = buffer;
+ link.circularPathData.sourceWidth = link.source.x1 - link.source.x0;
+ link.circularPathData.sourceX = link.source.x0 + link.circularPathData.sourceWidth;
+ link.circularPathData.targetX = link.target.x0;
+ link.circularPathData.sourceY = link.y0;
+ link.circularPathData.targetY = link.y1;
+ if (selfLinking(link, id) && onlyCircularLink(link)) {
+ link.circularPathData.leftSmallArcRadius = baseRadius + link.width / 2;
+ link.circularPathData.leftLargeArcRadius = baseRadius + link.width / 2;
+ link.circularPathData.rightSmallArcRadius = baseRadius + link.width / 2;
+ link.circularPathData.rightLargeArcRadius = baseRadius + link.width / 2;
+ if (link.circularLinkType == "bottom") {
+ link.circularPathData.verticalFullExtent = link.source.y1 + verticalMargin + link.circularPathData.verticalBuffer;
+ link.circularPathData.verticalLeftInnerExtent = link.circularPathData.verticalFullExtent - link.circularPathData.leftLargeArcRadius;
+ link.circularPathData.verticalRightInnerExtent = link.circularPathData.verticalFullExtent - link.circularPathData.rightLargeArcRadius;
+ } else {
+ link.circularPathData.verticalFullExtent = link.source.y0 - verticalMargin - link.circularPathData.verticalBuffer;
+ link.circularPathData.verticalLeftInnerExtent = link.circularPathData.verticalFullExtent + link.circularPathData.leftLargeArcRadius;
+ link.circularPathData.verticalRightInnerExtent = link.circularPathData.verticalFullExtent + link.circularPathData.rightLargeArcRadius;
+ }
+ } else {
+ var thisColumn = link.source.column;
+ var thisCircularLinkType = link.circularLinkType;
+ var sameColumnLinks = graph.links.filter(function(l) {
+ return l.source.column == thisColumn && l.circularLinkType == thisCircularLinkType;
+ });
+ if (link.circularLinkType == "bottom") {
+ sameColumnLinks.sort(sortLinkSourceYDescending);
+ } else {
+ sameColumnLinks.sort(sortLinkSourceYAscending);
+ }
+ var radiusOffset = 0;
+ sameColumnLinks.forEach(function(l, i) {
+ if (l.circularLinkID == link.circularLinkID) {
+ link.circularPathData.leftSmallArcRadius = baseRadius + link.width / 2 + radiusOffset;
+ link.circularPathData.leftLargeArcRadius = baseRadius + link.width / 2 + i * circularLinkGap + radiusOffset;
+ }
+ radiusOffset = radiusOffset + l.width;
+ });
+ thisColumn = link.target.column;
+ sameColumnLinks = graph.links.filter(function(l) {
+ return l.target.column == thisColumn && l.circularLinkType == thisCircularLinkType;
+ });
+ if (link.circularLinkType == "bottom") {
+ sameColumnLinks.sort(sortLinkTargetYDescending);
+ } else {
+ sameColumnLinks.sort(sortLinkTargetYAscending);
+ }
+ radiusOffset = 0;
+ sameColumnLinks.forEach(function(l, i) {
+ if (l.circularLinkID == link.circularLinkID) {
+ link.circularPathData.rightSmallArcRadius = baseRadius + link.width / 2 + radiusOffset;
+ link.circularPathData.rightLargeArcRadius = baseRadius + link.width / 2 + i * circularLinkGap + radiusOffset;
+ }
+ radiusOffset = radiusOffset + l.width;
+ });
+ if (link.circularLinkType == "bottom") {
+ link.circularPathData.verticalFullExtent = Math.max(y1, link.source.y1, link.target.y1) + verticalMargin + link.circularPathData.verticalBuffer;
+ link.circularPathData.verticalLeftInnerExtent = link.circularPathData.verticalFullExtent - link.circularPathData.leftLargeArcRadius;
+ link.circularPathData.verticalRightInnerExtent = link.circularPathData.verticalFullExtent - link.circularPathData.rightLargeArcRadius;
+ } else {
+ link.circularPathData.verticalFullExtent = minY - verticalMargin - link.circularPathData.verticalBuffer;
+ link.circularPathData.verticalLeftInnerExtent = link.circularPathData.verticalFullExtent + link.circularPathData.leftLargeArcRadius;
+ link.circularPathData.verticalRightInnerExtent = link.circularPathData.verticalFullExtent + link.circularPathData.rightLargeArcRadius;
+ }
+ }
+ link.circularPathData.leftInnerExtent = link.circularPathData.sourceX + link.circularPathData.leftNodeBuffer;
+ link.circularPathData.rightInnerExtent = link.circularPathData.targetX - link.circularPathData.rightNodeBuffer;
+ link.circularPathData.leftFullExtent = link.circularPathData.sourceX + link.circularPathData.leftLargeArcRadius + link.circularPathData.leftNodeBuffer;
+ link.circularPathData.rightFullExtent = link.circularPathData.targetX - link.circularPathData.rightLargeArcRadius - link.circularPathData.rightNodeBuffer;
+ }
+ if (link.circular) {
+ link.path = createCircularPathString(link);
+ } else {
+ var normalPath = d3Shape.linkHorizontal().source(function(d) {
+ var x = d.source.x0 + (d.source.x1 - d.source.x0);
+ var y = d.y0;
+ return [x, y];
+ }).target(function(d) {
+ var x = d.target.x0;
+ var y = d.y1;
+ return [x, y];
+ });
+ link.path = normalPath(link);
+ }
+ });
+ }
+ function createCircularPathString(link) {
+ var pathString = "";
+ if (link.circularLinkType == "top") {
+ pathString = // start at the right of the source node
+ "M" + link.circularPathData.sourceX + " " + link.circularPathData.sourceY + " L" + link.circularPathData.leftInnerExtent + " " + link.circularPathData.sourceY + " A" + link.circularPathData.leftLargeArcRadius + " " + link.circularPathData.leftSmallArcRadius + " 0 0 0 " + // End of arc X //End of arc Y
+ link.circularPathData.leftFullExtent + " " + (link.circularPathData.sourceY - link.circularPathData.leftSmallArcRadius) + " L" + link.circularPathData.leftFullExtent + " " + link.circularPathData.verticalLeftInnerExtent + " A" + link.circularPathData.leftLargeArcRadius + " " + link.circularPathData.leftLargeArcRadius + " 0 0 0 " + // End of arc X //End of arc Y
+ link.circularPathData.leftInnerExtent + " " + link.circularPathData.verticalFullExtent + " L" + link.circularPathData.rightInnerExtent + " " + link.circularPathData.verticalFullExtent + " A" + link.circularPathData.rightLargeArcRadius + " " + link.circularPathData.rightLargeArcRadius + " 0 0 0 " + // End of arc X //End of arc Y
+ link.circularPathData.rightFullExtent + " " + link.circularPathData.verticalRightInnerExtent + " L" + link.circularPathData.rightFullExtent + " " + (link.circularPathData.targetY - link.circularPathData.rightSmallArcRadius) + " A" + link.circularPathData.rightLargeArcRadius + " " + link.circularPathData.rightSmallArcRadius + " 0 0 0 " + // End of arc X //End of arc Y
+ link.circularPathData.rightInnerExtent + " " + link.circularPathData.targetY + " L" + link.circularPathData.targetX + " " + link.circularPathData.targetY;
+ } else {
+ pathString = // start at the right of the source node
+ "M" + link.circularPathData.sourceX + " " + link.circularPathData.sourceY + " L" + link.circularPathData.leftInnerExtent + " " + link.circularPathData.sourceY + " A" + link.circularPathData.leftLargeArcRadius + " " + link.circularPathData.leftSmallArcRadius + " 0 0 1 " + // End of arc X //End of arc Y
+ link.circularPathData.leftFullExtent + " " + (link.circularPathData.sourceY + link.circularPathData.leftSmallArcRadius) + " L" + link.circularPathData.leftFullExtent + " " + link.circularPathData.verticalLeftInnerExtent + " A" + link.circularPathData.leftLargeArcRadius + " " + link.circularPathData.leftLargeArcRadius + " 0 0 1 " + // End of arc X //End of arc Y
+ link.circularPathData.leftInnerExtent + " " + link.circularPathData.verticalFullExtent + " L" + link.circularPathData.rightInnerExtent + " " + link.circularPathData.verticalFullExtent + " A" + link.circularPathData.rightLargeArcRadius + " " + link.circularPathData.rightLargeArcRadius + " 0 0 1 " + // End of arc X //End of arc Y
+ link.circularPathData.rightFullExtent + " " + link.circularPathData.verticalRightInnerExtent + " L" + link.circularPathData.rightFullExtent + " " + (link.circularPathData.targetY + link.circularPathData.rightSmallArcRadius) + " A" + link.circularPathData.rightLargeArcRadius + " " + link.circularPathData.rightSmallArcRadius + " 0 0 1 " + // End of arc X //End of arc Y
+ link.circularPathData.rightInnerExtent + " " + link.circularPathData.targetY + " L" + link.circularPathData.targetX + " " + link.circularPathData.targetY;
+ }
+ return pathString;
+ }
+ function sortLinkColumnAscending(link1, link2) {
+ if (linkColumnDistance(link1) == linkColumnDistance(link2)) {
+ return link1.circularLinkType == "bottom" ? sortLinkSourceYDescending(link1, link2) : sortLinkSourceYAscending(link1, link2);
+ } else {
+ return linkColumnDistance(link2) - linkColumnDistance(link1);
+ }
+ }
+ function sortLinkSourceYAscending(link1, link2) {
+ return link1.y0 - link2.y0;
+ }
+ function sortLinkSourceYDescending(link1, link2) {
+ return link2.y0 - link1.y0;
+ }
+ function sortLinkTargetYAscending(link1, link2) {
+ return link1.y1 - link2.y1;
+ }
+ function sortLinkTargetYDescending(link1, link2) {
+ return link2.y1 - link1.y1;
+ }
+ function linkColumnDistance(link) {
+ return link.target.column - link.source.column;
+ }
+ function linkXLength(link) {
+ return link.target.x0 - link.source.x1;
+ }
+ function linkPerpendicularYToLinkSource(longerLink, shorterLink) {
+ var angle = linkAngle(longerLink);
+ var heightFromY1ToPependicular = linkXLength(shorterLink) / Math.tan(angle);
+ var yPerpendicular = incline(longerLink) == "up" ? longerLink.y1 + heightFromY1ToPependicular : longerLink.y1 - heightFromY1ToPependicular;
+ return yPerpendicular;
+ }
+ function linkPerpendicularYToLinkTarget(longerLink, shorterLink) {
+ var angle = linkAngle(longerLink);
+ var heightFromY1ToPependicular = linkXLength(shorterLink) / Math.tan(angle);
+ var yPerpendicular = incline(longerLink) == "up" ? longerLink.y1 - heightFromY1ToPependicular : longerLink.y1 + heightFromY1ToPependicular;
+ return yPerpendicular;
+ }
+ function resolveNodeLinkOverlaps(graph, y0, y1, id) {
+ graph.links.forEach(function(link) {
+ if (link.circular) {
+ return;
+ }
+ if (link.target.column - link.source.column > 1) {
+ var columnToTest = link.source.column + 1;
+ var maxColumnToTest = link.target.column - 1;
+ var i = 1;
+ var numberOfColumnsToTest = maxColumnToTest - columnToTest + 1;
+ for (i = 1; columnToTest <= maxColumnToTest; columnToTest++, i++) {
+ graph.nodes.forEach(function(node) {
+ if (node.column == columnToTest) {
+ var t = i / (numberOfColumnsToTest + 1);
+ var B0_t = Math.pow(1 - t, 3);
+ var B1_t = 3 * t * Math.pow(1 - t, 2);
+ var B2_t = 3 * Math.pow(t, 2) * (1 - t);
+ var B3_t = Math.pow(t, 3);
+ var py_t = B0_t * link.y0 + B1_t * link.y0 + B2_t * link.y1 + B3_t * link.y1;
+ var linkY0AtColumn = py_t - link.width / 2;
+ var linkY1AtColumn = py_t + link.width / 2;
+ var dy;
+ if (linkY0AtColumn > node.y0 && linkY0AtColumn < node.y1) {
+ dy = node.y1 - linkY0AtColumn + 10;
+ dy = node.circularLinkType == "bottom" ? dy : -dy;
+ node = adjustNodeHeight(node, dy, y0, y1);
+ graph.nodes.forEach(function(otherNode) {
+ if (getNodeID(otherNode, id) == getNodeID(node, id) || otherNode.column != node.column) {
+ return;
+ }
+ if (nodesOverlap(node, otherNode)) {
+ adjustNodeHeight(otherNode, dy, y0, y1);
+ }
+ });
+ } else if (linkY1AtColumn > node.y0 && linkY1AtColumn < node.y1) {
+ dy = linkY1AtColumn - node.y0 + 10;
+ node = adjustNodeHeight(node, dy, y0, y1);
+ graph.nodes.forEach(function(otherNode) {
+ if (getNodeID(otherNode, id) == getNodeID(node, id) || otherNode.column != node.column) {
+ return;
+ }
+ if (otherNode.y0 < node.y1 && otherNode.y1 > node.y1) {
+ adjustNodeHeight(otherNode, dy, y0, y1);
+ }
+ });
+ } else if (linkY0AtColumn < node.y0 && linkY1AtColumn > node.y1) {
+ dy = linkY1AtColumn - node.y0 + 10;
+ node = adjustNodeHeight(node, dy, y0, y1);
+ graph.nodes.forEach(function(otherNode) {
+ if (getNodeID(otherNode, id) == getNodeID(node, id) || otherNode.column != node.column) {
+ return;
+ }
+ if (otherNode.y0 < node.y1 && otherNode.y1 > node.y1) {
+ adjustNodeHeight(otherNode, dy, y0, y1);
+ }
+ });
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+ function nodesOverlap(nodeA, nodeB) {
+ if (nodeA.y0 > nodeB.y0 && nodeA.y0 < nodeB.y1) {
+ return true;
+ } else if (nodeA.y1 > nodeB.y0 && nodeA.y1 < nodeB.y1) {
+ return true;
+ } else if (nodeA.y0 < nodeB.y0 && nodeA.y1 > nodeB.y1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ function adjustNodeHeight(node, dy, sankeyY0, sankeyY1) {
+ if (node.y0 + dy >= sankeyY0 && node.y1 + dy <= sankeyY1) {
+ node.y0 = node.y0 + dy;
+ node.y1 = node.y1 + dy;
+ node.targetLinks.forEach(function(l) {
+ l.y1 = l.y1 + dy;
+ });
+ node.sourceLinks.forEach(function(l) {
+ l.y0 = l.y0 + dy;
+ });
+ }
+ return node;
+ }
+ function sortSourceLinks(graph, y1, id, moveNodes) {
+ graph.nodes.forEach(function(node) {
+ if (moveNodes && node.y + (node.y1 - node.y0) > y1) {
+ node.y = node.y - (node.y + (node.y1 - node.y0) - y1);
+ }
+ var nodesSourceLinks = graph.links.filter(function(l) {
+ return getNodeID(l.source, id) == getNodeID(node, id);
+ });
+ var nodeSourceLinksLength = nodesSourceLinks.length;
+ if (nodeSourceLinksLength > 1) {
+ nodesSourceLinks.sort(function(link1, link2) {
+ if (!link1.circular && !link2.circular) {
+ if (link1.target.column == link2.target.column) {
+ return link1.y1 - link2.y1;
+ } else if (!sameInclines(link1, link2)) {
+ return link1.y1 - link2.y1;
+ } else {
+ if (link1.target.column > link2.target.column) {
+ var link2Adj = linkPerpendicularYToLinkTarget(link2, link1);
+ return link1.y1 - link2Adj;
+ }
+ if (link2.target.column > link1.target.column) {
+ var link1Adj = linkPerpendicularYToLinkTarget(link1, link2);
+ return link1Adj - link2.y1;
+ }
+ }
+ }
+ if (link1.circular && !link2.circular) {
+ return link1.circularLinkType == "top" ? -1 : 1;
+ } else if (link2.circular && !link1.circular) {
+ return link2.circularLinkType == "top" ? 1 : -1;
+ }
+ if (link1.circular && link2.circular) {
+ if (link1.circularLinkType === link2.circularLinkType && link1.circularLinkType == "top") {
+ if (link1.target.column === link2.target.column) {
+ return link1.target.y1 - link2.target.y1;
+ } else {
+ return link2.target.column - link1.target.column;
+ }
+ } else if (link1.circularLinkType === link2.circularLinkType && link1.circularLinkType == "bottom") {
+ if (link1.target.column === link2.target.column) {
+ return link2.target.y1 - link1.target.y1;
+ } else {
+ return link1.target.column - link2.target.column;
+ }
+ } else {
+ return link1.circularLinkType == "top" ? -1 : 1;
+ }
+ }
+ });
+ }
+ var ySourceOffset = node.y0;
+ nodesSourceLinks.forEach(function(link) {
+ link.y0 = ySourceOffset + link.width / 2;
+ ySourceOffset = ySourceOffset + link.width;
+ });
+ nodesSourceLinks.forEach(function(link, i) {
+ if (link.circularLinkType == "bottom") {
+ var j = i + 1;
+ var offsetFromBottom = 0;
+ for (j; j < nodeSourceLinksLength; j++) {
+ offsetFromBottom = offsetFromBottom + nodesSourceLinks[j].width;
+ }
+ link.y0 = node.y1 - offsetFromBottom - link.width / 2;
+ }
+ });
+ });
+ }
+ function sortTargetLinks(graph, y1, id) {
+ graph.nodes.forEach(function(node) {
+ var nodesTargetLinks = graph.links.filter(function(l) {
+ return getNodeID(l.target, id) == getNodeID(node, id);
+ });
+ var nodesTargetLinksLength = nodesTargetLinks.length;
+ if (nodesTargetLinksLength > 1) {
+ nodesTargetLinks.sort(function(link1, link2) {
+ if (!link1.circular && !link2.circular) {
+ if (link1.source.column == link2.source.column) {
+ return link1.y0 - link2.y0;
+ } else if (!sameInclines(link1, link2)) {
+ return link1.y0 - link2.y0;
+ } else {
+ if (link2.source.column < link1.source.column) {
+ var link2Adj = linkPerpendicularYToLinkSource(link2, link1);
+ return link1.y0 - link2Adj;
+ }
+ if (link1.source.column < link2.source.column) {
+ var link1Adj = linkPerpendicularYToLinkSource(link1, link2);
+ return link1Adj - link2.y0;
+ }
+ }
+ }
+ if (link1.circular && !link2.circular) {
+ return link1.circularLinkType == "top" ? -1 : 1;
+ } else if (link2.circular && !link1.circular) {
+ return link2.circularLinkType == "top" ? 1 : -1;
+ }
+ if (link1.circular && link2.circular) {
+ if (link1.circularLinkType === link2.circularLinkType && link1.circularLinkType == "top") {
+ if (link1.source.column === link2.source.column) {
+ return link1.source.y1 - link2.source.y1;
+ } else {
+ return link1.source.column - link2.source.column;
+ }
+ } else if (link1.circularLinkType === link2.circularLinkType && link1.circularLinkType == "bottom") {
+ if (link1.source.column === link2.source.column) {
+ return link1.source.y1 - link2.source.y1;
+ } else {
+ return link2.source.column - link1.source.column;
+ }
+ } else {
+ return link1.circularLinkType == "top" ? -1 : 1;
+ }
+ }
+ });
+ }
+ var yTargetOffset = node.y0;
+ nodesTargetLinks.forEach(function(link) {
+ link.y1 = yTargetOffset + link.width / 2;
+ yTargetOffset = yTargetOffset + link.width;
+ });
+ nodesTargetLinks.forEach(function(link, i) {
+ if (link.circularLinkType == "bottom") {
+ var j = i + 1;
+ var offsetFromBottom = 0;
+ for (j; j < nodesTargetLinksLength; j++) {
+ offsetFromBottom = offsetFromBottom + nodesTargetLinks[j].width;
+ }
+ link.y1 = node.y1 - offsetFromBottom - link.width / 2;
+ }
+ });
+ });
+ }
+ function sameInclines(link1, link2) {
+ return incline(link1) == incline(link2);
+ }
+ function incline(link) {
+ return link.y0 - link.y1 > 0 ? "up" : "down";
+ }
+ function selfLinking(link, id) {
+ return getNodeID(link.source, id) == getNodeID(link.target, id);
+ }
+ function fillHeight(graph, y0, y1) {
+ var nodes = graph.nodes;
+ var links = graph.links;
+ var top = false;
+ var bottom = false;
+ links.forEach(function(link) {
+ if (link.circularLinkType == "top") {
+ top = true;
+ } else if (link.circularLinkType == "bottom") {
+ bottom = true;
+ }
+ });
+ if (top == false || bottom == false) {
+ var minY0 = d3Array.min(nodes, function(node) {
+ return node.y0;
+ });
+ var maxY1 = d3Array.max(nodes, function(node) {
+ return node.y1;
+ });
+ var currentHeight = maxY1 - minY0;
+ var chartHeight = y1 - y0;
+ var ratio = chartHeight / currentHeight;
+ nodes.forEach(function(node) {
+ var nodeHeight = (node.y1 - node.y0) * ratio;
+ node.y0 = (node.y0 - minY0) * ratio;
+ node.y1 = node.y0 + nodeHeight;
+ });
+ links.forEach(function(link) {
+ link.y0 = (link.y0 - minY0) * ratio;
+ link.y1 = (link.y1 - minY0) * ratio;
+ link.width = link.width * ratio;
+ });
+ }
+ }
+ exports2.sankeyCircular = sankeyCircular;
+ exports2.sankeyCenter = center;
+ exports2.sankeyLeft = left;
+ exports2.sankeyRight = right;
+ exports2.sankeyJustify = justify;
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ });
+ }
+ });
+
+ // src/traces/sankey/constants.js
+ var require_constants29 = __commonJS({
+ "src/traces/sankey/constants.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ nodeTextOffsetHorizontal: 4,
+ nodeTextOffsetVertical: 3,
+ nodePadAcross: 10,
+ sankeyIterations: 50,
+ forceIterations: 5,
+ forceTicksPerFrame: 10,
+ duration: 500,
+ ease: "linear",
+ cn: {
+ sankey: "sankey",
+ sankeyLinks: "sankey-links",
+ sankeyLink: "sankey-link",
+ sankeyNodeSet: "sankey-node-set",
+ sankeyNode: "sankey-node",
+ nodeRect: "node-rect",
+ nodeLabel: "node-label"
+ }
+ };
+ }
+ });
+
+ // src/traces/sankey/render.js
+ var require_render = __commonJS({
+ "src/traces/sankey/render.js"(exports, module) {
+ "use strict";
+ var d3Force = require_d3_force();
+ var interpolateNumber = (init_src2(), __toCommonJS(src_exports)).interpolateNumber;
+ var d3 = require_d3();
+ var d3Sankey = require_d3_sankey();
+ var d3SankeyCircular = require_d3_sankey_circular();
+ var c = require_constants29();
+ var tinycolor = require_tinycolor();
+ var Color2 = require_color();
+ var Drawing = require_drawing();
+ var Lib = require_lib();
+ var strTranslate = Lib.strTranslate;
+ var strRotate = Lib.strRotate;
+ var gup = require_gup();
+ var keyFun = gup.keyFun;
+ var repeat = gup.repeat;
+ var unwrap = gup.unwrap;
+ var svgTextUtils = require_svg_text_utils();
+ var Registry = require_registry();
+ var alignmentConstants = require_alignment();
+ var CAP_SHIFT = alignmentConstants.CAP_SHIFT;
+ var LINE_SPACING = alignmentConstants.LINE_SPACING;
+ var TEXTPAD = 3;
+ function sankeyModel(layout, d, traceIndex) {
+ var calcData = unwrap(d);
+ var trace = calcData.trace;
+ var domain = trace.domain;
+ var horizontal = trace.orientation === "h";
+ var nodePad = trace.node.pad;
+ var nodeThickness = trace.node.thickness;
+ var nodeAlign = {
+ justify: d3Sankey.sankeyJustify,
+ left: d3Sankey.sankeyLeft,
+ right: d3Sankey.sankeyRight,
+ center: d3Sankey.sankeyCenter
+ }[trace.node.align];
+ var width = layout.width * (domain.x[1] - domain.x[0]);
+ var height = layout.height * (domain.y[1] - domain.y[0]);
+ var nodes = calcData._nodes;
+ var links = calcData._links;
+ var circular = calcData.circular;
+ var sankey;
+ if (circular) {
+ sankey = d3SankeyCircular.sankeyCircular().circularLinkGap(0);
+ } else {
+ sankey = d3Sankey.sankey();
+ }
+ sankey.iterations(c.sankeyIterations).size(horizontal ? [width, height] : [height, width]).nodeWidth(nodeThickness).nodePadding(nodePad).nodeId(function(d2) {
+ return d2.pointNumber;
+ }).nodeAlign(nodeAlign).nodes(nodes).links(links);
+ var graph = sankey();
+ if (sankey.nodePadding() < nodePad) {
+ Lib.warn("node.pad was reduced to ", sankey.nodePadding(), " to fit within the figure.");
+ }
+ var i, j, k;
+ for (var nodePointNumber in calcData._groupLookup) {
+ var groupIndex = parseInt(calcData._groupLookup[nodePointNumber]);
+ var groupingNode;
+ for (i = 0; i < graph.nodes.length; i++) {
+ if (graph.nodes[i].pointNumber === groupIndex) {
+ groupingNode = graph.nodes[i];
+ break;
+ }
+ }
+ if (!groupingNode) continue;
+ var child = {
+ pointNumber: parseInt(nodePointNumber),
+ x0: groupingNode.x0,
+ x1: groupingNode.x1,
+ y0: groupingNode.y0,
+ y1: groupingNode.y1,
+ partOfGroup: true,
+ sourceLinks: [],
+ targetLinks: []
+ };
+ graph.nodes.unshift(child);
+ groupingNode.childrenNodes.unshift(child);
+ }
+ function computeLinkConcentrations() {
+ for (i = 0; i < graph.nodes.length; i++) {
+ var node = graph.nodes[i];
+ var flows = {};
+ var flowKey;
+ var link;
+ for (j = 0; j < node.targetLinks.length; j++) {
+ link = node.targetLinks[j];
+ flowKey = link.source.pointNumber + ":" + link.target.pointNumber;
+ if (!flows.hasOwnProperty(flowKey)) flows[flowKey] = [];
+ flows[flowKey].push(link);
+ }
+ var keys = Object.keys(flows);
+ for (j = 0; j < keys.length; j++) {
+ flowKey = keys[j];
+ var flowLinks = flows[flowKey];
+ var total = 0;
+ var totalPerLabel = {};
+ for (k = 0; k < flowLinks.length; k++) {
+ link = flowLinks[k];
+ if (!totalPerLabel[link.label]) totalPerLabel[link.label] = 0;
+ totalPerLabel[link.label] += link.value;
+ total += link.value;
+ }
+ for (k = 0; k < flowLinks.length; k++) {
+ link = flowLinks[k];
+ link.flow = {
+ value: total,
+ labelConcentration: totalPerLabel[link.label] / total,
+ concentration: link.value / total,
+ links: flowLinks
+ };
+ if (link.concentrationscale) {
+ link.color = tinycolor(link.concentrationscale(link.flow.labelConcentration));
+ }
+ }
+ }
+ var totalOutflow = 0;
+ for (j = 0; j < node.sourceLinks.length; j++) {
+ totalOutflow += node.sourceLinks[j].value;
+ }
+ for (j = 0; j < node.sourceLinks.length; j++) {
+ link = node.sourceLinks[j];
+ link.concentrationOut = link.value / totalOutflow;
+ }
+ var totalInflow = 0;
+ for (j = 0; j < node.targetLinks.length; j++) {
+ totalInflow += node.targetLinks[j].value;
+ }
+ for (j = 0; j < node.targetLinks.length; j++) {
+ link = node.targetLinks[j];
+ link.concenrationIn = link.value / totalInflow;
+ }
+ }
+ }
+ computeLinkConcentrations();
+ function resolveCollisionsTopToBottom(columns2) {
+ columns2.forEach(function(nodes2) {
+ var node;
+ var dy;
+ var y = 0;
+ var n = nodes2.length;
+ var i2;
+ nodes2.sort(function(a, b) {
+ return a.y0 - b.y0;
+ });
+ for (i2 = 0; i2 < n; ++i2) {
+ node = nodes2[i2];
+ if (node.y0 >= y) {
+ } else {
+ dy = y - node.y0;
+ if (dy > 1e-6) node.y0 += dy, node.y1 += dy;
+ }
+ y = node.y1 + nodePad;
+ }
+ });
+ }
+ function snapToColumns(nodes2) {
+ var orderedNodes = nodes2.map(function(n, i2) {
+ return {
+ x0: n.x0,
+ index: i2
+ };
+ }).sort(function(a, b) {
+ return a.x0 - b.x0;
+ });
+ var columns2 = [];
+ var colNumber = -1;
+ var colX;
+ var lastX = -Infinity;
+ var dx;
+ for (i = 0; i < orderedNodes.length; i++) {
+ var node = nodes2[orderedNodes[i].index];
+ if (node.x0 > lastX + nodeThickness) {
+ colNumber += 1;
+ colX = node.x0;
+ }
+ lastX = node.x0;
+ if (!columns2[colNumber]) columns2[colNumber] = [];
+ columns2[colNumber].push(node);
+ dx = colX - node.x0;
+ node.x0 += dx, node.x1 += dx;
+ }
+ return columns2;
+ }
+ if (trace.node.x.length && trace.node.y.length) {
+ for (i = 0; i < Math.min(trace.node.x.length, trace.node.y.length, graph.nodes.length); i++) {
+ if (trace.node.x[i] && trace.node.y[i]) {
+ var pos = [trace.node.x[i] * width, trace.node.y[i] * height];
+ graph.nodes[i].x0 = pos[0] - nodeThickness / 2;
+ graph.nodes[i].x1 = pos[0] + nodeThickness / 2;
+ var nodeHeight = graph.nodes[i].y1 - graph.nodes[i].y0;
+ graph.nodes[i].y0 = pos[1] - nodeHeight / 2;
+ graph.nodes[i].y1 = pos[1] + nodeHeight / 2;
+ }
+ }
+ if (trace.arrangement === "snap") {
+ nodes = graph.nodes;
+ var columns = snapToColumns(nodes);
+ resolveCollisionsTopToBottom(columns);
+ }
+ sankey.update(graph);
+ }
+ return {
+ circular,
+ key: traceIndex,
+ trace,
+ guid: Lib.randstr(),
+ horizontal,
+ width,
+ height,
+ nodePad: trace.node.pad,
+ nodeLineColor: trace.node.line.color,
+ nodeLineWidth: trace.node.line.width,
+ linkLineColor: trace.link.line.color,
+ linkLineWidth: trace.link.line.width,
+ linkArrowLength: trace.link.arrowlen,
+ valueFormat: trace.valueformat,
+ valueSuffix: trace.valuesuffix,
+ textFont: trace.textfont,
+ translateX: domain.x[0] * layout.width + layout.margin.l,
+ translateY: layout.height - domain.y[1] * layout.height + layout.margin.t,
+ dragParallel: horizontal ? height : width,
+ dragPerpendicular: horizontal ? width : height,
+ arrangement: trace.arrangement,
+ sankey,
+ graph,
+ forceLayouts: {},
+ interactionState: {
+ dragInProgress: false,
+ hovered: false
+ }
+ };
+ }
+ function linkModel(d, l, i) {
+ var tc = tinycolor(l.color);
+ var htc = tinycolor(l.hovercolor);
+ var basicKey = l.source.label + "|" + l.target.label;
+ var key = basicKey + "__" + i;
+ l.trace = d.trace;
+ l.curveNumber = d.trace.index;
+ return {
+ circular: d.circular,
+ key,
+ traceId: d.key,
+ pointNumber: l.pointNumber,
+ link: l,
+ tinyColorHue: Color2.tinyRGB(tc),
+ tinyColorAlpha: tc.getAlpha(),
+ tinyColorHoverHue: Color2.tinyRGB(htc),
+ tinyColorHoverAlpha: htc.getAlpha(),
+ linkPath,
+ linkLineColor: d.linkLineColor,
+ linkLineWidth: d.linkLineWidth,
+ linkArrowLength: d.linkArrowLength,
+ valueFormat: d.valueFormat,
+ valueSuffix: d.valueSuffix,
+ sankey: d.sankey,
+ parent: d,
+ interactionState: d.interactionState,
+ flow: l.flow
+ };
+ }
+ function createCircularClosedPathString(link, arrowLen) {
+ var pathString = "";
+ var offset = link.width / 2;
+ var coords = link.circularPathData;
+ var isSourceBeforeTarget = coords.sourceX + coords.verticalBuffer < coords.targetX;
+ var isPathOverlapped = coords.rightFullExtent - coords.rightLargeArcRadius - arrowLen <= coords.leftFullExtent - offset;
+ var diff = Math.abs(coords.rightFullExtent - coords.leftFullExtent - offset) < offset;
+ if (link.circularLinkType === "top") {
+ pathString = // start at the left of the target node
+ "M " + (coords.targetX - arrowLen) + " " + (coords.targetY + offset) + " L " + (coords.rightInnerExtent - arrowLen) + " " + (coords.targetY + offset) + "A " + (coords.rightLargeArcRadius + offset) + " " + (coords.rightSmallArcRadius + offset) + " 0 0 1 " + (coords.rightFullExtent - offset - arrowLen) + " " + (coords.targetY - coords.rightSmallArcRadius) + "L " + (coords.rightFullExtent - offset - arrowLen) + " " + coords.verticalRightInnerExtent;
+ if (isSourceBeforeTarget && isPathOverlapped) {
+ pathString += " A " + (coords.rightLargeArcRadius + offset) + " " + (coords.rightLargeArcRadius + offset) + " 0 0 1 " + (coords.rightFullExtent + offset - arrowLen - (coords.rightLargeArcRadius - offset)) + " " + (coords.verticalRightInnerExtent - (coords.rightLargeArcRadius + offset)) + " L " + (coords.rightFullExtent + offset - (coords.rightLargeArcRadius - offset) - arrowLen) + " " + (coords.verticalRightInnerExtent - (coords.rightLargeArcRadius + offset)) + " A " + (coords.leftLargeArcRadius + offset) + " " + (coords.leftLargeArcRadius + offset) + " 0 0 1 " + (coords.leftFullExtent + offset) + " " + coords.verticalRightInnerExtent;
+ } else if (isSourceBeforeTarget) {
+ pathString += " A " + (coords.rightLargeArcRadius - offset) + " " + (coords.rightLargeArcRadius - offset) + " 0 0 0 " + (coords.rightFullExtent - offset - arrowLen - (coords.rightLargeArcRadius - offset)) + " " + (coords.verticalRightInnerExtent - (coords.rightLargeArcRadius - offset)) + " L " + (coords.leftFullExtent + offset + (coords.rightLargeArcRadius - offset)) + " " + (coords.verticalRightInnerExtent - (coords.rightLargeArcRadius - offset)) + " A " + (coords.leftLargeArcRadius - offset) + " " + (coords.leftLargeArcRadius - offset) + " 0 0 0 " + (coords.leftFullExtent + offset) + " " + coords.verticalLeftInnerExtent;
+ } else {
+ pathString += " A " + (coords.rightLargeArcRadius + offset) + " " + (coords.rightLargeArcRadius + offset) + " 0 0 1 " + (coords.rightInnerExtent - arrowLen) + " " + (coords.verticalFullExtent - offset) + " L " + coords.leftInnerExtent + " " + (coords.verticalFullExtent - offset) + " A " + (coords.leftLargeArcRadius + offset) + " " + (coords.leftLargeArcRadius + offset) + " 0 0 1 " + (coords.leftFullExtent + offset) + " " + coords.verticalLeftInnerExtent;
+ }
+ pathString += " L " + (coords.leftFullExtent + offset) + " " + (coords.sourceY - coords.leftSmallArcRadius) + " A " + (coords.leftLargeArcRadius + offset) + " " + (coords.leftSmallArcRadius + offset) + " 0 0 1 " + coords.leftInnerExtent + " " + (coords.sourceY + offset) + " L " + coords.sourceX + " " + (coords.sourceY + offset) + // Walking back
+ " L " + coords.sourceX + " " + (coords.sourceY - offset) + " L " + coords.leftInnerExtent + " " + (coords.sourceY - offset) + " A " + (coords.leftLargeArcRadius - offset) + " " + (coords.leftSmallArcRadius - offset) + " 0 0 0 " + (coords.leftFullExtent - offset) + " " + (coords.sourceY - coords.leftSmallArcRadius) + " L " + (coords.leftFullExtent - offset) + " " + coords.verticalLeftInnerExtent;
+ if (isSourceBeforeTarget && isPathOverlapped) {
+ pathString += " A " + (coords.leftLargeArcRadius + offset) + " " + (coords.leftSmallArcRadius + offset) + " 0 0 0 " + (coords.leftFullExtent - offset) + " " + (coords.verticalFullExtent + offset) + "L" + (coords.rightFullExtent + offset - arrowLen) + " " + (coords.verticalFullExtent + offset) + " A " + (coords.leftLargeArcRadius + offset) + " " + (coords.leftSmallArcRadius + offset) + " 0 0 0 " + (coords.rightFullExtent + offset - arrowLen) + " " + coords.verticalRightInnerExtent;
+ } else if (isSourceBeforeTarget) {
+ pathString += " A " + (coords.leftLargeArcRadius + offset) + " " + (coords.leftSmallArcRadius + offset) + " 0 0 1 " + (coords.leftFullExtent + offset) + " " + (coords.verticalFullExtent - offset) + " L " + (coords.rightFullExtent - offset - arrowLen) + " " + (coords.verticalFullExtent - offset) + " A " + (coords.leftLargeArcRadius + offset) + " " + (coords.leftSmallArcRadius + offset) + " 0 0 1 " + (coords.rightFullExtent + offset - arrowLen) + " " + coords.verticalRightInnerExtent;
+ } else {
+ pathString += " A " + (coords.leftLargeArcRadius - offset) + " " + (coords.leftLargeArcRadius - offset) + " 0 0 0 " + coords.leftInnerExtent + " " + (coords.verticalFullExtent + offset) + " L " + (coords.rightInnerExtent - arrowLen) + " " + (coords.verticalFullExtent + offset) + " A " + (coords.rightLargeArcRadius - offset) + " " + (coords.rightLargeArcRadius - offset) + " 0 0 0 " + (coords.rightFullExtent + offset - arrowLen) + " " + coords.verticalRightInnerExtent;
+ }
+ pathString += " L " + (coords.rightFullExtent + offset - arrowLen) + " " + (coords.targetY - coords.rightSmallArcRadius) + " A " + (coords.rightLargeArcRadius - offset) + " " + (coords.rightSmallArcRadius - offset) + " 0 0 0 " + (coords.rightInnerExtent - arrowLen) + " " + (coords.targetY - offset) + " L " + (coords.targetX - arrowLen) + " " + (coords.targetY - offset) + (arrowLen > 0 ? " L " + coords.targetX + " " + coords.targetY : "") + "Z";
+ } else {
+ pathString = "M " + (coords.targetX - arrowLen) + " " + (coords.targetY - offset) + " L " + (coords.rightInnerExtent - arrowLen) + " " + (coords.targetY - offset) + " A " + (coords.rightLargeArcRadius + offset) + " " + (coords.rightSmallArcRadius + offset) + " 0 0 0 " + (coords.rightFullExtent - offset - arrowLen) + " " + (coords.targetY + coords.rightSmallArcRadius) + " L " + (coords.rightFullExtent - offset - arrowLen) + " " + coords.verticalRightInnerExtent;
+ if (isSourceBeforeTarget && isPathOverlapped) {
+ pathString += " A " + (coords.rightLargeArcRadius + offset) + " " + (coords.rightLargeArcRadius + offset) + " 0 0 0 " + (coords.rightInnerExtent - offset - arrowLen) + " " + (coords.verticalFullExtent + offset) + " L " + (coords.rightFullExtent + offset - arrowLen - (coords.rightLargeArcRadius - offset)) + " " + (coords.verticalFullExtent + offset) + " A " + (coords.rightLargeArcRadius + offset) + " " + (coords.rightLargeArcRadius + offset) + " 0 0 0 " + (coords.leftFullExtent + offset) + " " + coords.verticalLeftInnerExtent;
+ } else if (isSourceBeforeTarget) {
+ pathString += " A " + (coords.rightLargeArcRadius - offset) + " " + (coords.rightSmallArcRadius - offset) + " 0 0 1 " + (coords.rightFullExtent - arrowLen - offset - (coords.rightLargeArcRadius - offset)) + " " + (coords.verticalFullExtent - offset) + " L " + (coords.leftFullExtent + offset + (coords.rightLargeArcRadius - offset)) + " " + (coords.verticalFullExtent - offset) + " A " + (coords.rightLargeArcRadius - offset) + " " + (coords.rightSmallArcRadius - offset) + " 0 0 1 " + (coords.leftFullExtent + offset) + " " + coords.verticalLeftInnerExtent;
+ } else {
+ pathString += " A " + (coords.rightLargeArcRadius + offset) + " " + (coords.rightLargeArcRadius + offset) + " 0 0 0 " + (coords.rightInnerExtent - arrowLen) + " " + (coords.verticalFullExtent + offset) + " L " + coords.leftInnerExtent + " " + (coords.verticalFullExtent + offset) + " A " + (coords.leftLargeArcRadius + offset) + " " + (coords.leftLargeArcRadius + offset) + " 0 0 0 " + (coords.leftFullExtent + offset) + " " + coords.verticalLeftInnerExtent;
+ }
+ pathString += " L " + (coords.leftFullExtent + offset) + " " + (coords.sourceY + coords.leftSmallArcRadius) + " A " + (coords.leftLargeArcRadius + offset) + " " + (coords.leftSmallArcRadius + offset) + " 0 0 0 " + coords.leftInnerExtent + " " + (coords.sourceY - offset) + " L " + coords.sourceX + " " + (coords.sourceY - offset) + // Walking back
+ " L " + coords.sourceX + " " + (coords.sourceY + offset) + " L " + coords.leftInnerExtent + " " + (coords.sourceY + offset) + " A " + (coords.leftLargeArcRadius - offset) + " " + (coords.leftSmallArcRadius - offset) + " 0 0 1 " + (coords.leftFullExtent - offset) + " " + (coords.sourceY + coords.leftSmallArcRadius) + " L " + (coords.leftFullExtent - offset) + " " + coords.verticalLeftInnerExtent;
+ if (isSourceBeforeTarget && isPathOverlapped) {
+ pathString += " A " + (coords.rightLargeArcRadius - offset) + " " + (coords.rightSmallArcRadius - offset) + " 0 0 1 " + (coords.leftFullExtent - offset - (coords.rightLargeArcRadius - offset)) + " " + (coords.verticalFullExtent - offset) + " L " + (coords.rightFullExtent + offset - arrowLen + (coords.rightLargeArcRadius - offset)) + " " + (coords.verticalFullExtent - offset) + " A " + (coords.rightLargeArcRadius - offset) + " " + (coords.rightSmallArcRadius - offset) + " 0 0 1 " + (coords.rightFullExtent + offset - arrowLen) + " " + coords.verticalRightInnerExtent;
+ } else if (isSourceBeforeTarget) {
+ pathString += " A " + (coords.rightLargeArcRadius + offset) + " " + (coords.rightLargeArcRadius + offset) + " 0 0 0 " + (coords.leftFullExtent + offset) + " " + (coords.verticalFullExtent + offset) + " L " + (coords.rightFullExtent - arrowLen - offset) + " " + (coords.verticalFullExtent + offset) + " A " + (coords.rightLargeArcRadius + offset) + " " + (coords.rightLargeArcRadius + offset) + " 0 0 0 " + (coords.rightFullExtent + offset - arrowLen) + " " + coords.verticalRightInnerExtent;
+ } else {
+ pathString += " A " + (coords.leftLargeArcRadius - offset) + " " + (coords.leftLargeArcRadius - offset) + " 0 0 1 " + coords.leftInnerExtent + " " + (coords.verticalFullExtent - offset) + " L " + (coords.rightInnerExtent - arrowLen) + " " + (coords.verticalFullExtent - offset) + " A " + (coords.rightLargeArcRadius - offset) + " " + (coords.rightLargeArcRadius - offset) + " 0 0 1 " + (coords.rightFullExtent + offset - arrowLen) + " " + coords.verticalRightInnerExtent;
+ }
+ pathString += " L " + (coords.rightFullExtent + offset - arrowLen) + " " + (coords.targetY + coords.rightSmallArcRadius) + " A " + (coords.rightLargeArcRadius - offset) + " " + (coords.rightSmallArcRadius - offset) + " 0 0 1 " + (coords.rightInnerExtent - arrowLen) + " " + (coords.targetY + offset) + " L " + (coords.targetX - arrowLen) + " " + (coords.targetY + offset) + (arrowLen > 0 ? " L " + coords.targetX + " " + coords.targetY : "") + "Z";
+ }
+ return pathString;
+ }
+ function linkPath() {
+ var curvature = 0.5;
+ function path(d) {
+ var arrowLen = d.linkArrowLength;
+ if (d.link.circular) {
+ return createCircularClosedPathString(d.link, arrowLen);
+ } else {
+ var maxArrowLength = Math.abs((d.link.target.x0 - d.link.source.x1) / 2);
+ if (arrowLen > maxArrowLength) {
+ arrowLen = maxArrowLength;
+ }
+ var x0 = d.link.source.x1;
+ var x1 = d.link.target.x0 - arrowLen;
+ var xi = interpolateNumber(x0, x1);
+ var x2 = xi(curvature);
+ var x3 = xi(1 - curvature);
+ var y0a = d.link.y0 - d.link.width / 2;
+ var y0b = d.link.y0 + d.link.width / 2;
+ var y1a = d.link.y1 - d.link.width / 2;
+ var y1b = d.link.y1 + d.link.width / 2;
+ var start = "M" + x0 + "," + y0a;
+ var upperCurve = "C" + x2 + "," + y0a + " " + x3 + "," + y1a + " " + x1 + "," + y1a;
+ var lowerCurve = "C" + x3 + "," + y1b + " " + x2 + "," + y0b + " " + x0 + "," + y0b;
+ var rightEnd = arrowLen > 0 ? "L" + (x1 + arrowLen) + "," + (y1a + d.link.width / 2) : "";
+ rightEnd += "L" + x1 + "," + y1b;
+ return start + upperCurve + rightEnd + lowerCurve + "Z";
+ }
+ }
+ return path;
+ }
+ function nodeModel(d, n) {
+ var tc = tinycolor(n.color);
+ var zoneThicknessPad = c.nodePadAcross;
+ var zoneLengthPad = d.nodePad / 2;
+ n.dx = n.x1 - n.x0;
+ n.dy = n.y1 - n.y0;
+ var visibleThickness = n.dx;
+ var visibleLength = Math.max(0.5, n.dy);
+ var key = "node_" + n.pointNumber;
+ if (n.group) {
+ key = Lib.randstr();
+ }
+ n.trace = d.trace;
+ n.curveNumber = d.trace.index;
+ return {
+ index: n.pointNumber,
+ key,
+ partOfGroup: n.partOfGroup || false,
+ group: n.group,
+ traceId: d.key,
+ trace: d.trace,
+ node: n,
+ nodePad: d.nodePad,
+ nodeLineColor: d.nodeLineColor,
+ nodeLineWidth: d.nodeLineWidth,
+ textFont: d.textFont,
+ size: d.horizontal ? d.height : d.width,
+ visibleWidth: Math.ceil(visibleThickness),
+ visibleHeight: visibleLength,
+ zoneX: -zoneThicknessPad,
+ zoneY: -zoneLengthPad,
+ zoneWidth: visibleThickness + 2 * zoneThicknessPad,
+ zoneHeight: visibleLength + 2 * zoneLengthPad,
+ labelY: d.horizontal ? n.dy / 2 + 1 : n.dx / 2 + 1,
+ left: n.originalLayer === 1,
+ sizeAcross: d.width,
+ forceLayouts: d.forceLayouts,
+ horizontal: d.horizontal,
+ darkBackground: tc.getBrightness() <= 128,
+ tinyColorHue: Color2.tinyRGB(tc),
+ tinyColorAlpha: tc.getAlpha(),
+ valueFormat: d.valueFormat,
+ valueSuffix: d.valueSuffix,
+ sankey: d.sankey,
+ graph: d.graph,
+ arrangement: d.arrangement,
+ uniqueNodeLabelPathId: [d.guid, d.key, key].join("_"),
+ interactionState: d.interactionState,
+ figure: d
+ };
+ }
+ function updateNodePositions(sankeyNode) {
+ sankeyNode.attr("transform", function(d) {
+ return strTranslate(d.node.x0.toFixed(3), d.node.y0.toFixed(3));
+ });
+ }
+ function updateNodeShapes(sankeyNode) {
+ sankeyNode.call(updateNodePositions);
+ }
+ function updateShapes(sankeyNode, sankeyLink) {
+ sankeyNode.call(updateNodeShapes);
+ sankeyLink.attr("d", linkPath());
+ }
+ function sizeNode(rect) {
+ rect.attr("width", function(d) {
+ return d.node.x1 - d.node.x0;
+ }).attr("height", function(d) {
+ return d.visibleHeight;
+ });
+ }
+ function salientEnough(d) {
+ return d.link.width > 1 || d.linkLineWidth > 0;
+ }
+ function sankeyTransform(d) {
+ var offset = strTranslate(d.translateX, d.translateY);
+ return offset + (d.horizontal ? "matrix(1 0 0 1 0 0)" : "matrix(0 1 1 0 0 0)");
+ }
+ function attachPointerEvents(selection, sankey, eventSet) {
+ selection.on(".basic", null).on("mouseover.basic", function(d) {
+ if (!d.interactionState.dragInProgress && !d.partOfGroup) {
+ eventSet.hover(this, d, sankey);
+ d.interactionState.hovered = [this, d];
+ }
+ }).on("mousemove.basic", function(d) {
+ if (!d.interactionState.dragInProgress && !d.partOfGroup) {
+ eventSet.follow(this, d);
+ d.interactionState.hovered = [this, d];
+ }
+ }).on("mouseout.basic", function(d) {
+ if (!d.interactionState.dragInProgress && !d.partOfGroup) {
+ eventSet.unhover(this, d, sankey);
+ d.interactionState.hovered = false;
+ }
+ }).on("click.basic", function(d) {
+ if (d.interactionState.hovered) {
+ eventSet.unhover(this, d, sankey);
+ d.interactionState.hovered = false;
+ }
+ if (!d.interactionState.dragInProgress && !d.partOfGroup) {
+ eventSet.select(this, d, sankey);
+ }
+ });
+ }
+ function attachDragHandler(sankeyNode, sankeyLink, callbacks, gd) {
+ var dragBehavior = d3.behavior.drag().origin(function(d) {
+ return {
+ x: d.node.x0 + d.visibleWidth / 2,
+ y: d.node.y0 + d.visibleHeight / 2
+ };
+ }).on("dragstart", function(d) {
+ if (d.arrangement === "fixed") return;
+ Lib.ensureSingle(gd._fullLayout._infolayer, "g", "dragcover", function(s) {
+ gd._fullLayout._dragCover = s;
+ });
+ Lib.raiseToTop(this);
+ d.interactionState.dragInProgress = d.node;
+ saveCurrentDragPosition(d.node);
+ if (d.interactionState.hovered) {
+ callbacks.nodeEvents.unhover.apply(0, d.interactionState.hovered);
+ d.interactionState.hovered = false;
+ }
+ if (d.arrangement === "snap") {
+ var forceKey = d.traceId + "|" + d.key;
+ if (d.forceLayouts[forceKey]) {
+ d.forceLayouts[forceKey].alpha(1);
+ } else {
+ attachForce(sankeyNode, forceKey, d, gd);
+ }
+ startForce(sankeyNode, sankeyLink, d, forceKey, gd);
+ }
+ }).on("drag", function(d) {
+ if (d.arrangement === "fixed") return;
+ var x = d3.event.x;
+ var y = d3.event.y;
+ if (d.arrangement === "snap") {
+ d.node.x0 = x - d.visibleWidth / 2;
+ d.node.x1 = x + d.visibleWidth / 2;
+ d.node.y0 = y - d.visibleHeight / 2;
+ d.node.y1 = y + d.visibleHeight / 2;
+ } else {
+ if (d.arrangement === "freeform") {
+ d.node.x0 = x - d.visibleWidth / 2;
+ d.node.x1 = x + d.visibleWidth / 2;
+ }
+ y = Math.max(0, Math.min(d.size - d.visibleHeight / 2, y));
+ d.node.y0 = y - d.visibleHeight / 2;
+ d.node.y1 = y + d.visibleHeight / 2;
+ }
+ saveCurrentDragPosition(d.node);
+ if (d.arrangement !== "snap") {
+ d.sankey.update(d.graph);
+ updateShapes(sankeyNode.filter(sameLayer(d)), sankeyLink);
+ }
+ }).on("dragend", function(d) {
+ if (d.arrangement === "fixed") return;
+ d.interactionState.dragInProgress = false;
+ for (var i = 0; i < d.node.childrenNodes.length; i++) {
+ d.node.childrenNodes[i].x = d.node.x;
+ d.node.childrenNodes[i].y = d.node.y;
+ }
+ if (d.arrangement !== "snap") persistFinalNodePositions(d, gd);
+ });
+ sankeyNode.on(".drag", null).call(dragBehavior);
+ }
+ function attachForce(sankeyNode, forceKey, d, gd) {
+ switchToForceFormat(d.graph.nodes);
+ var nodes = d.graph.nodes.filter(function(n) {
+ return n.originalX === d.node.originalX;
+ }).filter(function(n) {
+ return !n.partOfGroup;
+ });
+ d.forceLayouts[forceKey] = d3Force.forceSimulation(nodes).alphaDecay(0).force("collide", d3Force.forceCollide().radius(function(n) {
+ return n.dy / 2 + d.nodePad / 2;
+ }).strength(1).iterations(c.forceIterations)).force("constrain", snappingForce(sankeyNode, forceKey, nodes, d, gd)).stop();
+ }
+ function startForce(sankeyNode, sankeyLink, d, forceKey, gd) {
+ window.requestAnimationFrame(function faster() {
+ var i;
+ for (i = 0; i < c.forceTicksPerFrame; i++) {
+ d.forceLayouts[forceKey].tick();
+ }
+ var nodes = d.graph.nodes;
+ switchToSankeyFormat(nodes);
+ d.sankey.update(d.graph);
+ updateShapes(sankeyNode.filter(sameLayer(d)), sankeyLink);
+ if (d.forceLayouts[forceKey].alpha() > 0) {
+ window.requestAnimationFrame(faster);
+ } else {
+ var x = d.node.originalX;
+ d.node.x0 = x - d.visibleWidth / 2;
+ d.node.x1 = x + d.visibleWidth / 2;
+ persistFinalNodePositions(d, gd);
+ }
+ });
+ }
+ function snappingForce(sankeyNode, forceKey, nodes, d) {
+ return function _snappingForce() {
+ var maxVelocity = 0;
+ for (var i = 0; i < nodes.length; i++) {
+ var n = nodes[i];
+ if (n === d.interactionState.dragInProgress) {
+ n.x = n.lastDraggedX;
+ n.y = n.lastDraggedY;
+ } else {
+ n.vx = (n.originalX - n.x) / c.forceTicksPerFrame;
+ n.y = Math.min(d.size - n.dy / 2, Math.max(n.dy / 2, n.y));
+ }
+ maxVelocity = Math.max(maxVelocity, Math.abs(n.vx), Math.abs(n.vy));
+ }
+ if (!d.interactionState.dragInProgress && maxVelocity < 0.1 && d.forceLayouts[forceKey].alpha() > 0) {
+ d.forceLayouts[forceKey].alpha(0);
+ }
+ };
+ }
+ function persistFinalNodePositions(d, gd) {
+ var x = [];
+ var y = [];
+ for (var i = 0; i < d.graph.nodes.length; i++) {
+ var nodeX = (d.graph.nodes[i].x0 + d.graph.nodes[i].x1) / 2;
+ var nodeY = (d.graph.nodes[i].y0 + d.graph.nodes[i].y1) / 2;
+ x.push(nodeX / d.figure.width);
+ y.push(nodeY / d.figure.height);
+ }
+ Registry.call("_guiRestyle", gd, {
+ "node.x": [x],
+ "node.y": [y]
+ }, d.trace.index).then(function() {
+ if (gd._fullLayout._dragCover) gd._fullLayout._dragCover.remove();
+ });
+ }
+ function persistOriginalPlace(nodes) {
+ var distinctLayerPositions = [];
+ var i;
+ for (i = 0; i < nodes.length; i++) {
+ nodes[i].originalX = (nodes[i].x0 + nodes[i].x1) / 2;
+ nodes[i].originalY = (nodes[i].y0 + nodes[i].y1) / 2;
+ if (distinctLayerPositions.indexOf(nodes[i].originalX) === -1) {
+ distinctLayerPositions.push(nodes[i].originalX);
+ }
+ }
+ distinctLayerPositions.sort(function(a, b) {
+ return a - b;
+ });
+ for (i = 0; i < nodes.length; i++) {
+ nodes[i].originalLayerIndex = distinctLayerPositions.indexOf(nodes[i].originalX);
+ nodes[i].originalLayer = nodes[i].originalLayerIndex / (distinctLayerPositions.length - 1);
+ }
+ }
+ function saveCurrentDragPosition(d) {
+ d.lastDraggedX = d.x0 + d.dx / 2;
+ d.lastDraggedY = d.y0 + d.dy / 2;
+ }
+ function sameLayer(d) {
+ return function(n) {
+ return n.node.originalX === d.node.originalX;
+ };
+ }
+ function switchToForceFormat(nodes) {
+ for (var i = 0; i < nodes.length; i++) {
+ nodes[i].y = (nodes[i].y0 + nodes[i].y1) / 2;
+ nodes[i].x = (nodes[i].x0 + nodes[i].x1) / 2;
+ }
+ }
+ function switchToSankeyFormat(nodes) {
+ for (var i = 0; i < nodes.length; i++) {
+ nodes[i].y0 = nodes[i].y - nodes[i].dy / 2;
+ nodes[i].y1 = nodes[i].y0 + nodes[i].dy;
+ nodes[i].x0 = nodes[i].x - nodes[i].dx / 2;
+ nodes[i].x1 = nodes[i].x0 + nodes[i].dx;
+ }
+ }
+ module.exports = function(gd, svg, calcData, layout, callbacks) {
+ var isStatic = gd._context.staticPlot;
+ var firstRender = false;
+ Lib.ensureSingle(gd._fullLayout._infolayer, "g", "first-render", function() {
+ firstRender = true;
+ });
+ var dragcover = gd._fullLayout._dragCover;
+ var styledData = calcData.filter(function(d) {
+ return unwrap(d).trace.visible;
+ }).map(sankeyModel.bind(null, layout));
+ var sankey = svg.selectAll("." + c.cn.sankey).data(styledData, keyFun);
+ sankey.exit().remove();
+ sankey.enter().append("g").classed(c.cn.sankey, true).style("box-sizing", "content-box").style("position", "absolute").style("left", 0).style("shape-rendering", "geometricPrecision").style("pointer-events", isStatic ? "none" : "auto").attr("transform", sankeyTransform);
+ sankey.each(function(d, i) {
+ gd._fullData[i]._sankey = d;
+ var dragboxClassName = "bgsankey-" + d.trace.uid + "-" + i;
+ Lib.ensureSingle(gd._fullLayout._draggers, "rect", dragboxClassName);
+ gd._fullData[i]._bgRect = d3.select("." + dragboxClassName);
+ gd._fullData[i]._bgRect.style("pointer-events", isStatic ? "none" : "all").attr("width", d.width).attr("height", d.height).attr("x", d.translateX).attr("y", d.translateY).classed("bgsankey", true).style({ fill: "transparent", "stroke-width": 0 });
+ });
+ sankey.transition().ease(c.ease).duration(c.duration).attr("transform", sankeyTransform);
+ var sankeyLinks = sankey.selectAll("." + c.cn.sankeyLinks).data(repeat, keyFun);
+ sankeyLinks.enter().append("g").classed(c.cn.sankeyLinks, true).style("fill", "none");
+ var sankeyLink = sankeyLinks.selectAll("." + c.cn.sankeyLink).data(function(d) {
+ var links = d.graph.links;
+ return links.filter(function(l) {
+ return l.value;
+ }).map(linkModel.bind(null, d));
+ }, keyFun);
+ sankeyLink.enter().append("path").classed(c.cn.sankeyLink, true).call(attachPointerEvents, sankey, callbacks.linkEvents);
+ sankeyLink.style("stroke", function(d) {
+ return salientEnough(d) ? Color2.tinyRGB(tinycolor(d.linkLineColor)) : d.tinyColorHue;
+ }).style("stroke-opacity", function(d) {
+ return salientEnough(d) ? Color2.opacity(d.linkLineColor) : d.tinyColorAlpha;
+ }).style("fill", function(d) {
+ return d.tinyColorHue;
+ }).style("fill-opacity", function(d) {
+ return d.tinyColorAlpha;
+ }).style("stroke-width", function(d) {
+ return salientEnough(d) ? d.linkLineWidth : 1;
+ }).attr("d", linkPath());
+ sankeyLink.style("opacity", function() {
+ return gd._context.staticPlot || firstRender || dragcover ? 1 : 0;
+ }).transition().ease(c.ease).duration(c.duration).style("opacity", 1);
+ sankeyLink.exit().transition().ease(c.ease).duration(c.duration).style("opacity", 0).remove();
+ var sankeyNodeSet = sankey.selectAll("." + c.cn.sankeyNodeSet).data(repeat, keyFun);
+ sankeyNodeSet.enter().append("g").classed(c.cn.sankeyNodeSet, true);
+ sankeyNodeSet.style("cursor", function(d) {
+ switch (d.arrangement) {
+ case "fixed":
+ return "default";
+ case "perpendicular":
+ return "ns-resize";
+ default:
+ return "move";
+ }
+ });
+ var sankeyNode = sankeyNodeSet.selectAll("." + c.cn.sankeyNode).data(function(d) {
+ var nodes = d.graph.nodes;
+ persistOriginalPlace(nodes);
+ return nodes.map(nodeModel.bind(null, d));
+ }, keyFun);
+ sankeyNode.enter().append("g").classed(c.cn.sankeyNode, true).call(updateNodePositions).style("opacity", function(n) {
+ return (gd._context.staticPlot || firstRender) && !n.partOfGroup ? 1 : 0;
+ });
+ sankeyNode.call(attachPointerEvents, sankey, callbacks.nodeEvents).call(attachDragHandler, sankeyLink, callbacks, gd);
+ sankeyNode.transition().ease(c.ease).duration(c.duration).call(updateNodePositions).style("opacity", function(n) {
+ return n.partOfGroup ? 0 : 1;
+ });
+ sankeyNode.exit().transition().ease(c.ease).duration(c.duration).style("opacity", 0).remove();
+ var nodeRect = sankeyNode.selectAll("." + c.cn.nodeRect).data(repeat);
+ nodeRect.enter().append("rect").classed(c.cn.nodeRect, true).call(sizeNode);
+ nodeRect.style("stroke-width", function(d) {
+ return d.nodeLineWidth;
+ }).style("stroke", function(d) {
+ return Color2.tinyRGB(tinycolor(d.nodeLineColor));
+ }).style("stroke-opacity", function(d) {
+ return Color2.opacity(d.nodeLineColor);
+ }).style("fill", function(d) {
+ return d.tinyColorHue;
+ }).style("fill-opacity", function(d) {
+ return d.tinyColorAlpha;
+ });
+ nodeRect.transition().ease(c.ease).duration(c.duration).call(sizeNode);
+ var nodeLabel = sankeyNode.selectAll("." + c.cn.nodeLabel).data(repeat);
+ nodeLabel.enter().append("text").classed(c.cn.nodeLabel, true).style("cursor", "default");
+ nodeLabel.attr("data-notex", 1).text(function(d) {
+ return d.node.label;
+ }).each(function(d) {
+ var e = d3.select(this);
+ Drawing.font(e, d.textFont);
+ svgTextUtils.convertToTspans(e, gd);
+ }).attr("text-anchor", function(d) {
+ return d.horizontal && d.left ? "end" : "start";
+ }).attr("transform", function(d) {
+ var e = d3.select(this);
+ var nLines = svgTextUtils.lineCount(e);
+ var blockHeight = d.textFont.size * ((nLines - 1) * LINE_SPACING - CAP_SHIFT);
+ var posX = d.nodeLineWidth / 2 + TEXTPAD;
+ var posY = ((d.horizontal ? d.visibleHeight : d.visibleWidth) - blockHeight) / 2;
+ if (d.horizontal) {
+ if (d.left) {
+ posX = -posX;
+ } else {
+ posX += d.visibleWidth;
+ }
+ }
+ var flipText = d.horizontal ? "" : "scale(-1,1)" + strRotate(90);
+ return strTranslate(
+ d.horizontal ? posX : posY,
+ d.horizontal ? posY : posX
+ ) + flipText;
+ });
+ nodeLabel.transition().ease(c.ease).duration(c.duration);
+ };
+ }
+ });
+
+ // src/traces/sankey/plot.js
+ var require_plot29 = __commonJS({
+ "src/traces/sankey/plot.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var Lib = require_lib();
+ var numberFormat = Lib.numberFormat;
+ var render = require_render();
+ var Fx = require_fx();
+ var Color2 = require_color();
+ var cn = require_constants29().cn;
+ var _ = Lib._;
+ function renderableValuePresent(d) {
+ return d !== "";
+ }
+ function ownTrace(selection, d) {
+ return selection.filter(function(s) {
+ return s.key === d.traceId;
+ });
+ }
+ function makeTranslucent(element, alpha) {
+ d3.select(element).select("path").style("fill-opacity", alpha);
+ d3.select(element).select("rect").style("fill-opacity", alpha);
+ }
+ function makeTextContrasty(element) {
+ d3.select(element).select("text.name").style("fill", "black");
+ }
+ function relatedLinks(d) {
+ return function(l) {
+ return d.node.sourceLinks.indexOf(l.link) !== -1 || d.node.targetLinks.indexOf(l.link) !== -1;
+ };
+ }
+ function relatedNodes(l) {
+ return function(d) {
+ return d.node.sourceLinks.indexOf(l.link) !== -1 || d.node.targetLinks.indexOf(l.link) !== -1;
+ };
+ }
+ function nodeHoveredStyle(sankeyNode, d, sankey) {
+ if (d && sankey) {
+ ownTrace(sankey, d).selectAll("." + cn.sankeyLink).filter(relatedLinks(d)).call(linkHoveredStyle.bind(0, d, sankey, false));
+ }
+ }
+ function nodeNonHoveredStyle(sankeyNode, d, sankey) {
+ if (d && sankey) {
+ ownTrace(sankey, d).selectAll("." + cn.sankeyLink).filter(relatedLinks(d)).call(linkNonHoveredStyle.bind(0, d, sankey, false));
+ }
+ }
+ function linkHoveredStyle(d, sankey, visitNodes, sankeyLink) {
+ sankeyLink.style("fill", function(l) {
+ if (!l.link.concentrationscale) {
+ return l.tinyColorHoverHue;
+ }
+ }).style("fill-opacity", function(l) {
+ if (!l.link.concentrationscale) {
+ return l.tinyColorHoverAlpha;
+ }
+ });
+ sankeyLink.each(function(curLink) {
+ var label = curLink.link.label;
+ if (label !== "") {
+ ownTrace(sankey, d).selectAll("." + cn.sankeyLink).filter(function(l) {
+ return l.link.label === label;
+ }).style("fill", function(l) {
+ if (!l.link.concentrationscale) {
+ return l.tinyColorHoverHue;
+ }
+ }).style("fill-opacity", function(l) {
+ if (!l.link.concentrationscale) {
+ return l.tinyColorHoverAlpha;
+ }
+ });
+ }
+ });
+ if (visitNodes) {
+ ownTrace(sankey, d).selectAll("." + cn.sankeyNode).filter(relatedNodes(d)).call(nodeHoveredStyle);
+ }
+ }
+ function linkNonHoveredStyle(d, sankey, visitNodes, sankeyLink) {
+ sankeyLink.style("fill", function(l) {
+ return l.tinyColorHue;
+ }).style("fill-opacity", function(l) {
+ return l.tinyColorAlpha;
+ });
+ sankeyLink.each(function(curLink) {
+ var label = curLink.link.label;
+ if (label !== "") {
+ ownTrace(sankey, d).selectAll("." + cn.sankeyLink).filter(function(l) {
+ return l.link.label === label;
+ }).style("fill", function(l) {
+ return l.tinyColorHue;
+ }).style("fill-opacity", function(l) {
+ return l.tinyColorAlpha;
+ });
+ }
+ });
+ if (visitNodes) {
+ ownTrace(sankey, d).selectAll(cn.sankeyNode).filter(relatedNodes(d)).call(nodeNonHoveredStyle);
+ }
+ }
+ function castHoverOption(trace, attr) {
+ var labelOpts = trace.hoverlabel || {};
+ var val = Lib.nestedProperty(labelOpts, attr).get();
+ return Array.isArray(val) ? false : val;
+ }
+ module.exports = function plot(gd, calcData) {
+ var fullLayout = gd._fullLayout;
+ var svg = fullLayout._paper;
+ var size = fullLayout._size;
+ for (var i = 0; i < gd._fullData.length; i++) {
+ if (!gd._fullData[i].visible) continue;
+ if (gd._fullData[i].type !== cn.sankey) continue;
+ if (!gd._fullData[i]._viewInitial) {
+ var node = gd._fullData[i].node;
+ gd._fullData[i]._viewInitial = {
+ node: {
+ groups: node.groups.slice(),
+ x: node.x.slice(),
+ y: node.y.slice()
+ }
+ };
+ }
+ }
+ var linkSelect = function(element, d) {
+ var evt = d.link;
+ evt.originalEvent = d3.event;
+ gd._hoverdata = [evt];
+ Fx.click(gd, { target: true });
+ };
+ var linkHover = function(element, d, sankey) {
+ if (gd._fullLayout.hovermode === false) return;
+ d3.select(element).call(linkHoveredStyle.bind(0, d, sankey, true));
+ if (d.link.trace.link.hoverinfo !== "skip") {
+ d.link.fullData = d.link.trace;
+ gd.emit("plotly_hover", {
+ event: d3.event,
+ points: [d.link]
+ });
+ }
+ };
+ var sourceLabel = _(gd, "source:") + " ";
+ var targetLabel = _(gd, "target:") + " ";
+ var concentrationLabel = _(gd, "concentration:") + " ";
+ var incomingLabel = _(gd, "incoming flow count:") + " ";
+ var outgoingLabel = _(gd, "outgoing flow count:") + " ";
+ var linkHoverFollow = function(element, d) {
+ if (gd._fullLayout.hovermode === false) return;
+ var obj = d.link.trace.link;
+ if (obj.hoverinfo === "none" || obj.hoverinfo === "skip") return;
+ var hoverItems = [];
+ function hoverCenterPosition(link2) {
+ var hoverCenterX, hoverCenterY;
+ if (link2.circular) {
+ hoverCenterX = (link2.circularPathData.leftInnerExtent + link2.circularPathData.rightInnerExtent) / 2;
+ hoverCenterY = link2.circularPathData.verticalFullExtent;
+ } else {
+ hoverCenterX = (link2.source.x1 + link2.target.x0) / 2;
+ hoverCenterY = (link2.y0 + link2.y1) / 2;
+ }
+ var center = [hoverCenterX, hoverCenterY];
+ if (link2.trace.orientation === "v") center.reverse();
+ center[0] += d.parent.translateX;
+ center[1] += d.parent.translateY;
+ return center;
+ }
+ var anchorIndex = 0;
+ for (var i2 = 0; i2 < d.flow.links.length; i2++) {
+ var link = d.flow.links[i2];
+ if (gd._fullLayout.hovermode === "closest" && d.link.pointNumber !== link.pointNumber) continue;
+ if (d.link.pointNumber === link.pointNumber) anchorIndex = i2;
+ link.fullData = link.trace;
+ obj = d.link.trace.link;
+ var hoverCenter = hoverCenterPosition(link);
+ var hovertemplateLabels = { valueLabel: numberFormat(d.valueFormat)(link.value) + d.valueSuffix };
+ hoverItems.push({
+ x: hoverCenter[0],
+ y: hoverCenter[1],
+ name: hovertemplateLabels.valueLabel,
+ text: [
+ link.label || "",
+ sourceLabel + link.source.label,
+ targetLabel + link.target.label,
+ link.concentrationscale ? concentrationLabel + numberFormat("%0.2f")(link.flow.labelConcentration) : ""
+ ].filter(renderableValuePresent).join("
"),
+ color: castHoverOption(obj, "bgcolor") || Color2.addOpacity(link.color, 1),
+ borderColor: castHoverOption(obj, "bordercolor"),
+ fontFamily: castHoverOption(obj, "font.family"),
+ fontSize: castHoverOption(obj, "font.size"),
+ fontColor: castHoverOption(obj, "font.color"),
+ fontWeight: castHoverOption(obj, "font.weight"),
+ fontStyle: castHoverOption(obj, "font.style"),
+ fontVariant: castHoverOption(obj, "font.variant"),
+ fontTextcase: castHoverOption(obj, "font.textcase"),
+ fontLineposition: castHoverOption(obj, "font.lineposition"),
+ fontShadow: castHoverOption(obj, "font.shadow"),
+ nameLength: castHoverOption(obj, "namelength"),
+ textAlign: castHoverOption(obj, "align"),
+ idealAlign: d3.event.x < hoverCenter[0] ? "right" : "left",
+ hovertemplate: obj.hovertemplate,
+ hovertemplateLabels,
+ eventData: [link]
+ });
+ }
+ var tooltips = Fx.loneHover(hoverItems, {
+ container: fullLayout._hoverlayer.node(),
+ outerContainer: fullLayout._paper.node(),
+ gd,
+ anchorIndex
+ });
+ tooltips.each(function() {
+ var tooltip = this;
+ if (!d.link.concentrationscale) {
+ makeTranslucent(tooltip, 0.65);
+ }
+ makeTextContrasty(tooltip);
+ });
+ };
+ var linkUnhover = function(element, d, sankey) {
+ if (gd._fullLayout.hovermode === false) return;
+ d3.select(element).call(linkNonHoveredStyle.bind(0, d, sankey, true));
+ if (d.link.trace.link.hoverinfo !== "skip") {
+ d.link.fullData = d.link.trace;
+ gd.emit("plotly_unhover", {
+ event: d3.event,
+ points: [d.link]
+ });
+ }
+ Fx.loneUnhover(fullLayout._hoverlayer.node());
+ };
+ var nodeSelect = function(element, d, sankey) {
+ var evt = d.node;
+ evt.originalEvent = d3.event;
+ gd._hoverdata = [evt];
+ d3.select(element).call(nodeNonHoveredStyle, d, sankey);
+ Fx.click(gd, { target: true });
+ };
+ var nodeHover = function(element, d, sankey) {
+ if (gd._fullLayout.hovermode === false) return;
+ d3.select(element).call(nodeHoveredStyle, d, sankey);
+ if (d.node.trace.node.hoverinfo !== "skip") {
+ d.node.fullData = d.node.trace;
+ gd.emit("plotly_hover", {
+ event: d3.event,
+ points: [d.node]
+ });
+ }
+ };
+ var nodeHoverFollow = function(element, d) {
+ if (gd._fullLayout.hovermode === false) return;
+ var obj = d.node.trace.node;
+ if (obj.hoverinfo === "none" || obj.hoverinfo === "skip") return;
+ var nodeRect = d3.select(element).select("." + cn.nodeRect);
+ var rootBBox = gd._fullLayout._paperdiv.node().getBoundingClientRect();
+ var boundingBox = nodeRect.node().getBoundingClientRect();
+ var hoverCenterX0 = boundingBox.left - 2 - rootBBox.left;
+ var hoverCenterX1 = boundingBox.right + 2 - rootBBox.left;
+ var hoverCenterY = boundingBox.top + boundingBox.height / 4 - rootBBox.top;
+ var hovertemplateLabels = { valueLabel: numberFormat(d.valueFormat)(d.node.value) + d.valueSuffix };
+ d.node.fullData = d.node.trace;
+ gd._fullLayout._calcInverseTransform(gd);
+ var scaleX = gd._fullLayout._invScaleX;
+ var scaleY = gd._fullLayout._invScaleY;
+ var tooltip = Fx.loneHover({
+ x0: scaleX * hoverCenterX0,
+ x1: scaleX * hoverCenterX1,
+ y: scaleY * hoverCenterY,
+ name: numberFormat(d.valueFormat)(d.node.value) + d.valueSuffix,
+ text: [
+ d.node.label,
+ incomingLabel + d.node.targetLinks.length,
+ outgoingLabel + d.node.sourceLinks.length
+ ].filter(renderableValuePresent).join("
"),
+ color: castHoverOption(obj, "bgcolor") || d.tinyColorHue,
+ borderColor: castHoverOption(obj, "bordercolor"),
+ fontFamily: castHoverOption(obj, "font.family"),
+ fontSize: castHoverOption(obj, "font.size"),
+ fontColor: castHoverOption(obj, "font.color"),
+ fontWeight: castHoverOption(obj, "font.weight"),
+ fontStyle: castHoverOption(obj, "font.style"),
+ fontVariant: castHoverOption(obj, "font.variant"),
+ fontTextcase: castHoverOption(obj, "font.textcase"),
+ fontLineposition: castHoverOption(obj, "font.lineposition"),
+ fontShadow: castHoverOption(obj, "font.shadow"),
+ nameLength: castHoverOption(obj, "namelength"),
+ textAlign: castHoverOption(obj, "align"),
+ idealAlign: "left",
+ hovertemplate: obj.hovertemplate,
+ hovertemplateLabels,
+ eventData: [d.node]
+ }, {
+ container: fullLayout._hoverlayer.node(),
+ outerContainer: fullLayout._paper.node(),
+ gd
+ });
+ makeTranslucent(tooltip, 0.85);
+ makeTextContrasty(tooltip);
+ };
+ var nodeUnhover = function(element, d, sankey) {
+ if (gd._fullLayout.hovermode === false) return;
+ d3.select(element).call(nodeNonHoveredStyle, d, sankey);
+ if (d.node.trace.node.hoverinfo !== "skip") {
+ d.node.fullData = d.node.trace;
+ gd.emit("plotly_unhover", {
+ event: d3.event,
+ points: [d.node]
+ });
+ }
+ Fx.loneUnhover(fullLayout._hoverlayer.node());
+ };
+ render(
+ gd,
+ svg,
+ calcData,
+ {
+ width: size.w,
+ height: size.h,
+ margin: {
+ t: size.t,
+ r: size.r,
+ b: size.b,
+ l: size.l
+ }
+ },
+ {
+ linkEvents: {
+ hover: linkHover,
+ follow: linkHoverFollow,
+ unhover: linkUnhover,
+ select: linkSelect
+ },
+ nodeEvents: {
+ hover: nodeHover,
+ follow: nodeHoverFollow,
+ unhover: nodeUnhover,
+ select: nodeSelect
+ }
+ }
+ );
+ };
+ }
+ });
+
+ // src/traces/sankey/base_plot.js
+ var require_base_plot9 = __commonJS({
+ "src/traces/sankey/base_plot.js"(exports) {
+ "use strict";
+ var overrideAll = require_edit_types().overrideAll;
+ var getModuleCalcData = require_get_data().getModuleCalcData;
+ var plot = require_plot29();
+ var fxAttrs = require_layout_attributes();
+ var setCursor = require_setcursor();
+ var dragElement = require_dragelement();
+ var prepSelect = require_selections().prepSelect;
+ var Lib = require_lib();
+ var Registry = require_registry();
+ var SANKEY = "sankey";
+ exports.name = SANKEY;
+ exports.baseLayoutAttrOverrides = overrideAll({
+ hoverlabel: fxAttrs.hoverlabel
+ }, "plot", "nested");
+ exports.plot = function(gd) {
+ var calcData = getModuleCalcData(gd.calcdata, SANKEY)[0];
+ plot(gd, calcData);
+ exports.updateFx(gd);
+ };
+ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
+ var hadPlot = oldFullLayout._has && oldFullLayout._has(SANKEY);
+ var hasPlot = newFullLayout._has && newFullLayout._has(SANKEY);
+ if (hadPlot && !hasPlot) {
+ oldFullLayout._paperdiv.selectAll(".sankey").remove();
+ oldFullLayout._paperdiv.selectAll(".bgsankey").remove();
+ }
+ };
+ exports.updateFx = function(gd) {
+ for (var i = 0; i < gd._fullData.length; i++) {
+ subplotUpdateFx(gd, i);
+ }
+ };
+ function subplotUpdateFx(gd, index) {
+ var trace = gd._fullData[index];
+ var fullLayout = gd._fullLayout;
+ var dragMode = fullLayout.dragmode;
+ var cursor = fullLayout.dragmode === "pan" ? "move" : "crosshair";
+ var bgRect = trace._bgRect;
+ if (!bgRect) return;
+ if (dragMode === "pan" || dragMode === "zoom") return;
+ setCursor(bgRect, cursor);
+ var xaxis = {
+ _id: "x",
+ c2p: Lib.identity,
+ _offset: trace._sankey.translateX,
+ _length: trace._sankey.width
+ };
+ var yaxis = {
+ _id: "y",
+ c2p: Lib.identity,
+ _offset: trace._sankey.translateY,
+ _length: trace._sankey.height
+ };
+ var dragOptions = {
+ gd,
+ element: bgRect.node(),
+ plotinfo: {
+ id: index,
+ xaxis,
+ yaxis,
+ fillRangeItems: Lib.noop
+ },
+ subplot: index,
+ // create mock x/y axes for hover routine
+ xaxes: [xaxis],
+ yaxes: [yaxis],
+ doneFnCompleted: function(selection) {
+ var traceNow = gd._fullData[index];
+ var newGroups;
+ var oldGroups = traceNow.node.groups.slice();
+ var newGroup = [];
+ function findNode(pt) {
+ var nodes = traceNow._sankey.graph.nodes;
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].pointNumber === pt) return nodes[i];
+ }
+ }
+ for (var j = 0; j < selection.length; j++) {
+ var node = findNode(selection[j].pointNumber);
+ if (!node) continue;
+ if (node.group) {
+ for (var k = 0; k < node.childrenNodes.length; k++) {
+ newGroup.push(node.childrenNodes[k].pointNumber);
+ }
+ oldGroups[node.pointNumber - traceNow.node._count] = false;
+ } else {
+ newGroup.push(node.pointNumber);
+ }
+ }
+ newGroups = oldGroups.filter(Boolean).concat([newGroup]);
+ Registry.call("_guiRestyle", gd, {
+ "node.groups": [newGroups]
+ }, index);
+ }
+ };
+ dragOptions.prepFn = function(e, startX, startY) {
+ prepSelect(e, startX, startY, dragOptions, dragMode);
+ };
+ dragElement.init(dragOptions);
+ }
+ }
+ });
+
+ // src/traces/sankey/select.js
+ var require_select11 = __commonJS({
+ "src/traces/sankey/select.js"(exports, module) {
+ "use strict";
+ module.exports = function selectPoints(searchInfo, selectionTester) {
+ var cd = searchInfo.cd;
+ var selection = [];
+ var fullData = cd[0].trace;
+ var nodes = fullData._sankey.graph.nodes;
+ for (var i = 0; i < nodes.length; i++) {
+ var node = nodes[i];
+ if (node.partOfGroup) continue;
+ var pos = [(node.x0 + node.x1) / 2, (node.y0 + node.y1) / 2];
+ if (fullData.orientation === "v") pos.reverse();
+ if (selectionTester && selectionTester.contains(pos, false, i, searchInfo)) {
+ selection.push({
+ pointNumber: node.pointNumber
+ // TODO: add eventData
+ });
+ }
+ }
+ return selection;
+ };
+ }
+ });
+
+ // src/traces/sankey/index.js
+ var require_sankey = __commonJS({
+ "src/traces/sankey/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes60(),
+ supplyDefaults: require_defaults56(),
+ calc: require_calc35(),
+ plot: require_plot29(),
+ moduleType: "trace",
+ name: "sankey",
+ basePlotModule: require_base_plot9(),
+ selectPoints: require_select11(),
+ categories: ["noOpacity"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/sankey.js
+ var require_sankey2 = __commonJS({
+ "lib/sankey.js"(exports, module) {
+ "use strict";
+ module.exports = require_sankey();
+ }
+ });
+
+ // src/traces/indicator/base_plot.js
+ var require_base_plot10 = __commonJS({
+ "src/traces/indicator/base_plot.js"(exports) {
+ "use strict";
+ var plots = require_plots();
+ exports.name = "indicator";
+ exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
+ plots.plotBasePlot(exports.name, gd, traces, transitionOpts, makeOnCompleteCallback);
+ };
+ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
+ plots.cleanBasePlot(exports.name, newFullData, newFullLayout, oldFullData, oldFullLayout);
+ };
+ }
+ });
+
+ // src/traces/indicator/attributes.js
+ var require_attributes61 = __commonJS({
+ "src/traces/indicator/attributes.js"(exports, module) {
+ "use strict";
+ var extendFlat = require_extend().extendFlat;
+ var extendDeep = require_extend().extendDeep;
+ var overrideAll = require_edit_types().overrideAll;
+ var fontAttrs = require_font_attributes();
+ var colorAttrs = require_attributes3();
+ var domainAttrs = require_domain().attributes;
+ var axesAttrs = require_layout_attributes4();
+ var templatedArray = require_plot_template().templatedArray;
+ var delta = require_delta();
+ var descriptionOnlyNumbers = require_axis_format_attributes().descriptionOnlyNumbers;
+ var textFontAttrs = fontAttrs({
+ editType: "plot",
+ colorEditType: "plot"
+ });
+ var gaugeBarAttrs = {
+ color: {
+ valType: "color",
+ editType: "plot"
+ },
+ line: {
+ color: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine,
+ editType: "plot"
+ },
+ width: {
+ valType: "number",
+ min: 0,
+ dflt: 0,
+ editType: "plot"
+ },
+ editType: "calc"
+ },
+ thickness: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 1,
+ editType: "plot"
+ },
+ editType: "calc"
+ };
+ var rangeAttr = {
+ valType: "info_array",
+ items: [
+ { valType: "number", editType: "plot" },
+ { valType: "number", editType: "plot" }
+ ],
+ editType: "plot"
+ };
+ var stepsAttrs = templatedArray("step", extendDeep({}, gaugeBarAttrs, {
+ range: rangeAttr
+ }));
+ module.exports = {
+ mode: {
+ valType: "flaglist",
+ editType: "calc",
+ flags: ["number", "delta", "gauge"],
+ dflt: "number"
+ },
+ value: {
+ valType: "number",
+ editType: "calc",
+ anim: true
+ },
+ align: {
+ valType: "enumerated",
+ values: ["left", "center", "right"],
+ editType: "plot"
+ },
+ // position
+ domain: domainAttrs({ name: "indicator", trace: true, editType: "calc" }),
+ title: {
+ text: {
+ valType: "string",
+ editType: "plot"
+ },
+ align: {
+ valType: "enumerated",
+ values: ["left", "center", "right"],
+ editType: "plot"
+ },
+ font: extendFlat({}, textFontAttrs, {}),
+ editType: "plot"
+ },
+ number: {
+ valueformat: {
+ valType: "string",
+ dflt: "",
+ editType: "plot",
+ description: descriptionOnlyNumbers("value")
+ },
+ font: extendFlat({}, textFontAttrs, {}),
+ prefix: {
+ valType: "string",
+ dflt: "",
+ editType: "plot"
+ },
+ suffix: {
+ valType: "string",
+ dflt: "",
+ editType: "plot"
+ },
+ editType: "plot"
+ },
+ delta: {
+ reference: {
+ valType: "number",
+ editType: "calc"
+ },
+ position: {
+ valType: "enumerated",
+ values: ["top", "bottom", "left", "right"],
+ dflt: "bottom",
+ editType: "plot"
+ },
+ relative: {
+ valType: "boolean",
+ editType: "plot",
+ dflt: false
+ },
+ valueformat: {
+ valType: "string",
+ editType: "plot",
+ description: descriptionOnlyNumbers("value")
+ },
+ increasing: {
+ symbol: {
+ valType: "string",
+ dflt: delta.INCREASING.SYMBOL,
+ editType: "plot"
+ },
+ color: {
+ valType: "color",
+ dflt: delta.INCREASING.COLOR,
+ editType: "plot"
+ },
+ // TODO: add attribute to show sign
+ editType: "plot"
+ },
+ decreasing: {
+ symbol: {
+ valType: "string",
+ dflt: delta.DECREASING.SYMBOL,
+ editType: "plot"
+ },
+ color: {
+ valType: "color",
+ dflt: delta.DECREASING.COLOR,
+ editType: "plot"
+ },
+ // TODO: add attribute to hide sign
+ editType: "plot"
+ },
+ font: extendFlat({}, textFontAttrs, {}),
+ prefix: {
+ valType: "string",
+ dflt: "",
+ editType: "plot"
+ },
+ suffix: {
+ valType: "string",
+ dflt: "",
+ editType: "plot"
+ },
+ editType: "calc"
+ },
+ gauge: {
+ shape: {
+ valType: "enumerated",
+ editType: "plot",
+ dflt: "angular",
+ values: ["angular", "bullet"]
+ },
+ bar: extendDeep({}, gaugeBarAttrs, {
+ color: { dflt: "green" }
+ }),
+ // Background of the gauge
+ bgcolor: {
+ valType: "color",
+ editType: "plot"
+ },
+ bordercolor: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine,
+ editType: "plot"
+ },
+ borderwidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1,
+ editType: "plot"
+ },
+ axis: overrideAll({
+ range: rangeAttr,
+ visible: extendFlat({}, axesAttrs.visible, {
+ dflt: true
+ }),
+ // tick and title properties named and function exactly as in axes
+ tickmode: axesAttrs.minor.tickmode,
+ nticks: axesAttrs.nticks,
+ tick0: axesAttrs.tick0,
+ dtick: axesAttrs.dtick,
+ tickvals: axesAttrs.tickvals,
+ ticktext: axesAttrs.ticktext,
+ ticks: extendFlat({}, axesAttrs.ticks, { dflt: "outside" }),
+ ticklen: axesAttrs.ticklen,
+ tickwidth: axesAttrs.tickwidth,
+ tickcolor: axesAttrs.tickcolor,
+ ticklabelstep: axesAttrs.ticklabelstep,
+ showticklabels: axesAttrs.showticklabels,
+ labelalias: axesAttrs.labelalias,
+ tickfont: fontAttrs({}),
+ tickangle: axesAttrs.tickangle,
+ tickformat: axesAttrs.tickformat,
+ tickformatstops: axesAttrs.tickformatstops,
+ tickprefix: axesAttrs.tickprefix,
+ showtickprefix: axesAttrs.showtickprefix,
+ ticksuffix: axesAttrs.ticksuffix,
+ showticksuffix: axesAttrs.showticksuffix,
+ separatethousands: axesAttrs.separatethousands,
+ exponentformat: axesAttrs.exponentformat,
+ minexponent: axesAttrs.minexponent,
+ showexponent: axesAttrs.showexponent,
+ editType: "plot"
+ }, "plot"),
+ // Steps (or ranges) and thresholds
+ steps: stepsAttrs,
+ threshold: {
+ line: {
+ color: extendFlat({}, gaugeBarAttrs.line.color, {}),
+ width: extendFlat({}, gaugeBarAttrs.line.width, {
+ dflt: 1
+ }),
+ editType: "plot"
+ },
+ thickness: extendFlat({}, gaugeBarAttrs.thickness, {
+ dflt: 0.85
+ }),
+ value: {
+ valType: "number",
+ editType: "calc",
+ dflt: false
+ },
+ editType: "plot"
+ },
+ editType: "plot"
+ // TODO: in future version, add marker: (bar|needle)
+ }
+ };
+ }
+ });
+
+ // src/traces/indicator/constants.js
+ var require_constants30 = __commonJS({
+ "src/traces/indicator/constants.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ // Defaults for delta
+ defaultNumberFontSize: 80,
+ bulletNumberDomainSize: 0.25,
+ bulletPadding: 0.025,
+ innerRadius: 0.75,
+ valueThickness: 0.5,
+ // thickness of value bars relative to full thickness,
+ titlePadding: 5,
+ horizontalPadding: 10
+ };
+ }
+ });
+
+ // src/traces/indicator/defaults.js
+ var require_defaults57 = __commonJS({
+ "src/traces/indicator/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var attributes = require_attributes61();
+ var handleDomainDefaults = require_domain().defaults;
+ var Template = require_plot_template();
+ var handleArrayContainerDefaults = require_array_container_defaults();
+ var cn = require_constants30();
+ var handleTickValueDefaults = require_tick_value_defaults();
+ var handleTickMarkDefaults = require_tick_mark_defaults();
+ var handleTickLabelDefaults = require_tick_label_defaults();
+ var handlePrefixSuffixDefaults = require_prefix_suffix_defaults();
+ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ handleDomainDefaults(traceOut, layout, coerce);
+ coerce("mode");
+ traceOut._hasNumber = traceOut.mode.indexOf("number") !== -1;
+ traceOut._hasDelta = traceOut.mode.indexOf("delta") !== -1;
+ traceOut._hasGauge = traceOut.mode.indexOf("gauge") !== -1;
+ var value = coerce("value");
+ traceOut._range = [0, typeof value === "number" ? 1.5 * value : 1];
+ var auto = new Array(2);
+ var bignumberFontSize;
+ if (traceOut._hasNumber) {
+ coerce("number.valueformat");
+ var numberFontDflt = Lib.extendFlat({}, layout.font);
+ numberFontDflt.size = void 0;
+ Lib.coerceFont(coerce, "number.font", numberFontDflt);
+ if (traceOut.number.font.size === void 0) {
+ traceOut.number.font.size = cn.defaultNumberFontSize;
+ auto[0] = true;
+ }
+ coerce("number.prefix");
+ coerce("number.suffix");
+ bignumberFontSize = traceOut.number.font.size;
+ }
+ var deltaFontSize;
+ if (traceOut._hasDelta) {
+ var deltaFontDflt = Lib.extendFlat({}, layout.font);
+ deltaFontDflt.size = void 0;
+ Lib.coerceFont(coerce, "delta.font", deltaFontDflt);
+ if (traceOut.delta.font.size === void 0) {
+ traceOut.delta.font.size = (traceOut._hasNumber ? 0.5 : 1) * (bignumberFontSize || cn.defaultNumberFontSize);
+ auto[1] = true;
+ }
+ coerce("delta.reference", traceOut.value);
+ coerce("delta.relative");
+ coerce("delta.valueformat", traceOut.delta.relative ? "2%" : "");
+ coerce("delta.increasing.symbol");
+ coerce("delta.increasing.color");
+ coerce("delta.decreasing.symbol");
+ coerce("delta.decreasing.color");
+ coerce("delta.position");
+ coerce("delta.prefix");
+ coerce("delta.suffix");
+ deltaFontSize = traceOut.delta.font.size;
+ }
+ traceOut._scaleNumbers = (!traceOut._hasNumber || auto[0]) && (!traceOut._hasDelta || auto[1]) || false;
+ var titleFontDflt = Lib.extendFlat({}, layout.font);
+ titleFontDflt.size = 0.25 * (bignumberFontSize || deltaFontSize || cn.defaultNumberFontSize);
+ Lib.coerceFont(coerce, "title.font", titleFontDflt);
+ coerce("title.text");
+ var gaugeIn, gaugeOut, axisIn, axisOut;
+ function coerceGauge(attr, dflt) {
+ return Lib.coerce(gaugeIn, gaugeOut, attributes.gauge, attr, dflt);
+ }
+ function coerceGaugeAxis(attr, dflt) {
+ return Lib.coerce(axisIn, axisOut, attributes.gauge.axis, attr, dflt);
+ }
+ if (traceOut._hasGauge) {
+ gaugeIn = traceIn.gauge;
+ if (!gaugeIn) gaugeIn = {};
+ gaugeOut = Template.newContainer(traceOut, "gauge");
+ coerceGauge("shape");
+ var isBullet = traceOut._isBullet = traceOut.gauge.shape === "bullet";
+ if (!isBullet) {
+ coerce("title.align", "center");
+ }
+ var isAngular = traceOut._isAngular = traceOut.gauge.shape === "angular";
+ if (!isAngular) {
+ coerce("align", "center");
+ }
+ coerceGauge("bgcolor", layout.paper_bgcolor);
+ coerceGauge("borderwidth");
+ coerceGauge("bordercolor");
+ coerceGauge("bar.color");
+ coerceGauge("bar.line.color");
+ coerceGauge("bar.line.width");
+ var defaultBarThickness = cn.valueThickness * (traceOut.gauge.shape === "bullet" ? 0.5 : 1);
+ coerceGauge("bar.thickness", defaultBarThickness);
+ handleArrayContainerDefaults(gaugeIn, gaugeOut, {
+ name: "steps",
+ handleItemDefaults: stepDefaults
+ });
+ coerceGauge("threshold.value");
+ coerceGauge("threshold.thickness");
+ coerceGauge("threshold.line.width");
+ coerceGauge("threshold.line.color");
+ axisIn = {};
+ if (gaugeIn) axisIn = gaugeIn.axis || {};
+ axisOut = Template.newContainer(gaugeOut, "axis");
+ coerceGaugeAxis("visible");
+ traceOut._range = coerceGaugeAxis("range", traceOut._range);
+ var opts = {
+ font: layout.font,
+ noAutotickangles: true,
+ outerTicks: true,
+ noTicklabelshift: true,
+ noTicklabelstandoff: true
+ };
+ handleTickValueDefaults(axisIn, axisOut, coerceGaugeAxis, "linear");
+ handlePrefixSuffixDefaults(axisIn, axisOut, coerceGaugeAxis, "linear", opts);
+ handleTickLabelDefaults(axisIn, axisOut, coerceGaugeAxis, "linear", opts);
+ handleTickMarkDefaults(axisIn, axisOut, coerceGaugeAxis, opts);
+ } else {
+ coerce("title.align", "center");
+ coerce("align", "center");
+ traceOut._isAngular = traceOut._isBullet = false;
+ }
+ traceOut._length = null;
+ }
+ function stepDefaults(stepIn, stepOut) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(stepIn, stepOut, attributes.gauge.steps, attr, dflt);
+ }
+ coerce("color");
+ coerce("line.color");
+ coerce("line.width");
+ coerce("range");
+ coerce("thickness");
+ }
+ module.exports = {
+ supplyDefaults
+ };
+ }
+ });
+
+ // src/traces/indicator/calc.js
+ var require_calc36 = __commonJS({
+ "src/traces/indicator/calc.js"(exports, module) {
+ "use strict";
+ function calc(gd, trace) {
+ var cd = [];
+ var lastReading = trace.value;
+ if (!(typeof trace._lastValue === "number")) trace._lastValue = trace.value;
+ var secondLastReading = trace._lastValue;
+ var deltaRef = secondLastReading;
+ if (trace._hasDelta && typeof trace.delta.reference === "number") {
+ deltaRef = trace.delta.reference;
+ }
+ cd[0] = {
+ y: lastReading,
+ lastY: secondLastReading,
+ delta: lastReading - deltaRef,
+ relativeDelta: (lastReading - deltaRef) / deltaRef
+ };
+ return cd;
+ }
+ module.exports = {
+ calc
+ };
+ }
+ });
+
+ // src/traces/indicator/plot.js
+ var require_plot30 = __commonJS({
+ "src/traces/indicator/plot.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var interpolate = (init_src2(), __toCommonJS(src_exports)).interpolate;
+ var interpolateNumber = (init_src2(), __toCommonJS(src_exports)).interpolateNumber;
+ var Lib = require_lib();
+ var strScale = Lib.strScale;
+ var strTranslate = Lib.strTranslate;
+ var rad2deg = Lib.rad2deg;
+ var MID_SHIFT = require_alignment().MID_SHIFT;
+ var Drawing = require_drawing();
+ var cn = require_constants30();
+ var svgTextUtils = require_svg_text_utils();
+ var Axes = require_axes();
+ var handleAxisDefaults = require_axis_defaults();
+ var handleAxisPositionDefaults = require_position_defaults();
+ var axisLayoutAttrs = require_layout_attributes4();
+ var Color2 = require_color();
+ var anchor = {
+ left: "start",
+ center: "middle",
+ right: "end"
+ };
+ var position = {
+ left: 0,
+ center: 0.5,
+ right: 1
+ };
+ var SI_PREFIX = /[yzafpnµmkMGTPEZY]/;
+ function hasTransition(transitionOpts) {
+ return transitionOpts && transitionOpts.duration > 0;
+ }
+ module.exports = function plot(gd, cdModule, transitionOpts, makeOnCompleteCallback) {
+ var fullLayout = gd._fullLayout;
+ var onComplete;
+ if (hasTransition(transitionOpts)) {
+ if (makeOnCompleteCallback) {
+ onComplete = makeOnCompleteCallback();
+ }
+ }
+ Lib.makeTraceGroups(fullLayout._indicatorlayer, cdModule, "trace").each(function(cd) {
+ var cd0 = cd[0];
+ var trace = cd0.trace;
+ var plotGroup = d3.select(this);
+ var hasGauge = trace._hasGauge;
+ var isAngular = trace._isAngular;
+ var isBullet = trace._isBullet;
+ var domain = trace.domain;
+ var size = {
+ w: fullLayout._size.w * (domain.x[1] - domain.x[0]),
+ h: fullLayout._size.h * (domain.y[1] - domain.y[0]),
+ l: fullLayout._size.l + fullLayout._size.w * domain.x[0],
+ r: fullLayout._size.r + fullLayout._size.w * (1 - domain.x[1]),
+ t: fullLayout._size.t + fullLayout._size.h * (1 - domain.y[1]),
+ b: fullLayout._size.b + fullLayout._size.h * domain.y[0]
+ };
+ var centerX = size.l + size.w / 2;
+ var centerY = size.t + size.h / 2;
+ var radius = Math.min(size.w / 2, size.h);
+ var innerRadius = cn.innerRadius * radius;
+ var numbersX, numbersY, numbersScaler;
+ var numbersAlign = trace.align || "center";
+ numbersY = centerY;
+ if (!hasGauge) {
+ numbersX = size.l + position[numbersAlign] * size.w;
+ numbersScaler = function(el) {
+ return fitTextInsideBox(el, size.w, size.h);
+ };
+ } else {
+ if (isAngular) {
+ numbersX = centerX;
+ numbersY = centerY + radius / 2;
+ numbersScaler = function(el) {
+ return fitTextInsideCircle(el, 0.9 * innerRadius);
+ };
+ }
+ if (isBullet) {
+ var padding = cn.bulletPadding;
+ var p = 1 - cn.bulletNumberDomainSize + padding;
+ numbersX = size.l + (p + (1 - p) * position[numbersAlign]) * size.w;
+ numbersScaler = function(el) {
+ return fitTextInsideBox(el, (cn.bulletNumberDomainSize - padding) * size.w, size.h);
+ };
+ }
+ }
+ drawNumbers(gd, plotGroup, cd, {
+ numbersX,
+ numbersY,
+ numbersScaler,
+ transitionOpts,
+ onComplete
+ });
+ var gaugeBg, gaugeOutline;
+ if (hasGauge) {
+ gaugeBg = {
+ range: trace.gauge.axis.range,
+ color: trace.gauge.bgcolor,
+ line: {
+ color: trace.gauge.bordercolor,
+ width: 0
+ },
+ thickness: 1
+ };
+ gaugeOutline = {
+ range: trace.gauge.axis.range,
+ color: "rgba(0, 0, 0, 0)",
+ line: {
+ color: trace.gauge.bordercolor,
+ width: trace.gauge.borderwidth
+ },
+ thickness: 1
+ };
+ }
+ var angularGauge = plotGroup.selectAll("g.angular").data(isAngular ? cd : []);
+ angularGauge.exit().remove();
+ var angularaxisLayer = plotGroup.selectAll("g.angularaxis").data(isAngular ? cd : []);
+ angularaxisLayer.exit().remove();
+ if (isAngular) {
+ drawAngularGauge(gd, plotGroup, cd, {
+ radius,
+ innerRadius,
+ gauge: angularGauge,
+ layer: angularaxisLayer,
+ size,
+ gaugeBg,
+ gaugeOutline,
+ transitionOpts,
+ onComplete
+ });
+ }
+ var bulletGauge = plotGroup.selectAll("g.bullet").data(isBullet ? cd : []);
+ bulletGauge.exit().remove();
+ var bulletaxisLayer = plotGroup.selectAll("g.bulletaxis").data(isBullet ? cd : []);
+ bulletaxisLayer.exit().remove();
+ if (isBullet) {
+ drawBulletGauge(gd, plotGroup, cd, {
+ gauge: bulletGauge,
+ layer: bulletaxisLayer,
+ size,
+ gaugeBg,
+ gaugeOutline,
+ transitionOpts,
+ onComplete
+ });
+ }
+ var title = plotGroup.selectAll("text.title").data(cd);
+ title.exit().remove();
+ title.enter().append("text").classed("title", true);
+ title.attr("text-anchor", function() {
+ return isBullet ? anchor.right : anchor[trace.title.align];
+ }).text(trace.title.text).call(Drawing.font, trace.title.font).call(svgTextUtils.convertToTspans, gd);
+ title.attr("transform", function() {
+ var titleX = size.l + size.w * position[trace.title.align];
+ var titleY;
+ var titlePadding = cn.titlePadding;
+ var titlebBox = Drawing.bBox(title.node());
+ if (hasGauge) {
+ if (isAngular) {
+ if (trace.gauge.axis.visible) {
+ var bBox = Drawing.bBox(angularaxisLayer.node());
+ titleY = bBox.top - titlePadding - titlebBox.bottom;
+ } else {
+ titleY = size.t + size.h / 2 - radius / 2 - titlebBox.bottom - titlePadding;
+ }
+ }
+ if (isBullet) {
+ titleY = numbersY - (titlebBox.top + titlebBox.bottom) / 2;
+ titleX = size.l - cn.bulletPadding * size.w;
+ }
+ } else {
+ titleY = trace._numbersTop - titlePadding - titlebBox.bottom;
+ }
+ return strTranslate(titleX, titleY);
+ });
+ });
+ };
+ function drawBulletGauge(gd, plotGroup, cd, opts) {
+ var trace = cd[0].trace;
+ var bullet = opts.gauge;
+ var axisLayer = opts.layer;
+ var gaugeBg = opts.gaugeBg;
+ var gaugeOutline = opts.gaugeOutline;
+ var size = opts.size;
+ var domain = trace.domain;
+ var transitionOpts = opts.transitionOpts;
+ var onComplete = opts.onComplete;
+ var ax, vals, transFn, tickSign, shift;
+ bullet.enter().append("g").classed("bullet", true);
+ bullet.attr("transform", strTranslate(size.l, size.t));
+ axisLayer.enter().append("g").classed("bulletaxis", true).classed("crisp", true);
+ axisLayer.selectAll("g.xbulletaxistick,path,text").remove();
+ var bulletHeight = size.h;
+ var innerBulletHeight = trace.gauge.bar.thickness * bulletHeight;
+ var bulletLeft = domain.x[0];
+ var bulletRight = domain.x[0] + (domain.x[1] - domain.x[0]) * (trace._hasNumber || trace._hasDelta ? 1 - cn.bulletNumberDomainSize : 1);
+ ax = mockAxis(gd, trace.gauge.axis);
+ ax._id = "xbulletaxis";
+ ax.domain = [bulletLeft, bulletRight];
+ ax.setScale();
+ vals = Axes.calcTicks(ax);
+ transFn = Axes.makeTransTickFn(ax);
+ tickSign = Axes.getTickSigns(ax)[2];
+ shift = size.t + size.h;
+ if (ax.visible) {
+ Axes.drawTicks(gd, ax, {
+ vals: ax.ticks === "inside" ? Axes.clipEnds(ax, vals) : vals,
+ layer: axisLayer,
+ path: Axes.makeTickPath(ax, shift, tickSign),
+ transFn
+ });
+ Axes.drawLabels(gd, ax, {
+ vals,
+ layer: axisLayer,
+ transFn,
+ labelFns: Axes.makeLabelFns(ax, shift)
+ });
+ }
+ function drawRect(s) {
+ s.attr("width", function(d) {
+ return Math.max(0, ax.c2p(d.range[1]) - ax.c2p(d.range[0]));
+ }).attr("x", function(d) {
+ return ax.c2p(d.range[0]);
+ }).attr("y", function(d) {
+ return 0.5 * (1 - d.thickness) * bulletHeight;
+ }).attr("height", function(d) {
+ return d.thickness * bulletHeight;
+ });
+ }
+ var boxes = [gaugeBg].concat(trace.gauge.steps);
+ var bgBullet = bullet.selectAll("g.bg-bullet").data(boxes);
+ bgBullet.enter().append("g").classed("bg-bullet", true).append("rect");
+ bgBullet.select("rect").call(drawRect).call(styleShape);
+ bgBullet.exit().remove();
+ var fgBullet = bullet.selectAll("g.value-bullet").data([trace.gauge.bar]);
+ fgBullet.enter().append("g").classed("value-bullet", true).append("rect");
+ fgBullet.select("rect").attr("height", innerBulletHeight).attr("y", (bulletHeight - innerBulletHeight) / 2).call(styleShape);
+ if (hasTransition(transitionOpts)) {
+ fgBullet.select("rect").transition().duration(transitionOpts.duration).ease(transitionOpts.easing).each("end", function() {
+ onComplete && onComplete();
+ }).each("interrupt", function() {
+ onComplete && onComplete();
+ }).attr("width", Math.max(0, ax.c2p(Math.min(trace.gauge.axis.range[1], cd[0].y))));
+ } else {
+ fgBullet.select("rect").attr("width", typeof cd[0].y === "number" ? Math.max(0, ax.c2p(Math.min(trace.gauge.axis.range[1], cd[0].y))) : 0);
+ }
+ fgBullet.exit().remove();
+ var data = cd.filter(function() {
+ return trace.gauge.threshold.value || trace.gauge.threshold.value === 0;
+ });
+ var threshold = bullet.selectAll("g.threshold-bullet").data(data);
+ threshold.enter().append("g").classed("threshold-bullet", true).append("line");
+ threshold.select("line").attr("x1", ax.c2p(trace.gauge.threshold.value)).attr("x2", ax.c2p(trace.gauge.threshold.value)).attr("y1", (1 - trace.gauge.threshold.thickness) / 2 * bulletHeight).attr("y2", (1 - (1 - trace.gauge.threshold.thickness) / 2) * bulletHeight).call(Color2.stroke, trace.gauge.threshold.line.color).style("stroke-width", trace.gauge.threshold.line.width);
+ threshold.exit().remove();
+ var bulletOutline = bullet.selectAll("g.gauge-outline").data([gaugeOutline]);
+ bulletOutline.enter().append("g").classed("gauge-outline", true).append("rect");
+ bulletOutline.select("rect").call(drawRect).call(styleShape);
+ bulletOutline.exit().remove();
+ }
+ function drawAngularGauge(gd, plotGroup, cd, opts) {
+ var trace = cd[0].trace;
+ var size = opts.size;
+ var radius = opts.radius;
+ var innerRadius = opts.innerRadius;
+ var gaugeBg = opts.gaugeBg;
+ var gaugeOutline = opts.gaugeOutline;
+ var gaugePosition = [size.l + size.w / 2, size.t + size.h / 2 + radius / 2];
+ var gauge = opts.gauge;
+ var axisLayer = opts.layer;
+ var transitionOpts = opts.transitionOpts;
+ var onComplete = opts.onComplete;
+ var theta = Math.PI / 2;
+ function valueToAngle(v2) {
+ var min = trace.gauge.axis.range[0];
+ var max = trace.gauge.axis.range[1];
+ var angle = (v2 - min) / (max - min) * Math.PI - theta;
+ if (angle < -theta) return -theta;
+ if (angle > theta) return theta;
+ return angle;
+ }
+ function arcPathGenerator(size2) {
+ return d3.svg.arc().innerRadius((innerRadius + radius) / 2 - size2 / 2 * (radius - innerRadius)).outerRadius((innerRadius + radius) / 2 + size2 / 2 * (radius - innerRadius)).startAngle(-theta);
+ }
+ function drawArc(p) {
+ p.attr("d", function(d) {
+ return arcPathGenerator(d.thickness).startAngle(valueToAngle(d.range[0])).endAngle(valueToAngle(d.range[1]))();
+ });
+ }
+ var ax, vals, transFn, tickSign;
+ gauge.enter().append("g").classed("angular", true);
+ gauge.attr("transform", strTranslate(gaugePosition[0], gaugePosition[1]));
+ axisLayer.enter().append("g").classed("angularaxis", true).classed("crisp", true);
+ axisLayer.selectAll("g.xangularaxistick,path,text").remove();
+ ax = mockAxis(gd, trace.gauge.axis);
+ ax.type = "linear";
+ ax.range = trace.gauge.axis.range;
+ ax._id = "xangularaxis";
+ ax.ticklabeloverflow = "allow";
+ ax.setScale();
+ var t2g = function(d) {
+ return (ax.range[0] - d.x) / (ax.range[1] - ax.range[0]) * Math.PI + Math.PI;
+ };
+ var labelFns = {};
+ var out = Axes.makeLabelFns(ax, 0);
+ var labelStandoff = out.labelStandoff;
+ labelFns.xFn = function(d) {
+ var rad = t2g(d);
+ return Math.cos(rad) * labelStandoff;
+ };
+ labelFns.yFn = function(d) {
+ var rad = t2g(d);
+ var ff = Math.sin(rad) > 0 ? 0.2 : 1;
+ return -Math.sin(rad) * (labelStandoff + d.fontSize * ff) + Math.abs(Math.cos(rad)) * (d.fontSize * MID_SHIFT);
+ };
+ labelFns.anchorFn = function(d) {
+ var rad = t2g(d);
+ var cos = Math.cos(rad);
+ return Math.abs(cos) < 0.1 ? "middle" : cos > 0 ? "start" : "end";
+ };
+ labelFns.heightFn = function(d, a, h) {
+ var rad = t2g(d);
+ return -0.5 * (1 + Math.sin(rad)) * h;
+ };
+ var _transFn = function(rad) {
+ return strTranslate(
+ gaugePosition[0] + radius * Math.cos(rad),
+ gaugePosition[1] - radius * Math.sin(rad)
+ );
+ };
+ transFn = function(d) {
+ return _transFn(t2g(d));
+ };
+ var transFn2 = function(d) {
+ var rad = t2g(d);
+ return _transFn(rad) + "rotate(" + -rad2deg(rad) + ")";
+ };
+ vals = Axes.calcTicks(ax);
+ tickSign = Axes.getTickSigns(ax)[2];
+ if (ax.visible) {
+ tickSign = ax.ticks === "inside" ? -1 : 1;
+ var pad = (ax.linewidth || 1) / 2;
+ Axes.drawTicks(gd, ax, {
+ vals,
+ layer: axisLayer,
+ path: "M" + tickSign * pad + ",0h" + tickSign * ax.ticklen,
+ transFn: transFn2
+ });
+ Axes.drawLabels(gd, ax, {
+ vals,
+ layer: axisLayer,
+ transFn,
+ labelFns
+ });
+ }
+ var arcs = [gaugeBg].concat(trace.gauge.steps);
+ var bgArc = gauge.selectAll("g.bg-arc").data(arcs);
+ bgArc.enter().append("g").classed("bg-arc", true).append("path");
+ bgArc.select("path").call(drawArc).call(styleShape);
+ bgArc.exit().remove();
+ var valueArcPathGenerator = arcPathGenerator(trace.gauge.bar.thickness);
+ var valueArc = gauge.selectAll("g.value-arc").data([trace.gauge.bar]);
+ valueArc.enter().append("g").classed("value-arc", true).append("path");
+ var valueArcPath = valueArc.select("path");
+ if (hasTransition(transitionOpts)) {
+ valueArcPath.transition().duration(transitionOpts.duration).ease(transitionOpts.easing).each("end", function() {
+ onComplete && onComplete();
+ }).each("interrupt", function() {
+ onComplete && onComplete();
+ }).attrTween("d", arcTween(valueArcPathGenerator, valueToAngle(cd[0].lastY), valueToAngle(cd[0].y)));
+ trace._lastValue = cd[0].y;
+ } else {
+ valueArcPath.attr("d", typeof cd[0].y === "number" ? valueArcPathGenerator.endAngle(valueToAngle(cd[0].y)) : "M0,0Z");
+ }
+ valueArcPath.call(styleShape);
+ valueArc.exit().remove();
+ arcs = [];
+ var v = trace.gauge.threshold.value;
+ if (v || v === 0) {
+ arcs.push({
+ range: [v, v],
+ color: trace.gauge.threshold.color,
+ line: {
+ color: trace.gauge.threshold.line.color,
+ width: trace.gauge.threshold.line.width
+ },
+ thickness: trace.gauge.threshold.thickness
+ });
+ }
+ var thresholdArc = gauge.selectAll("g.threshold-arc").data(arcs);
+ thresholdArc.enter().append("g").classed("threshold-arc", true).append("path");
+ thresholdArc.select("path").call(drawArc).call(styleShape);
+ thresholdArc.exit().remove();
+ var gaugeBorder = gauge.selectAll("g.gauge-outline").data([gaugeOutline]);
+ gaugeBorder.enter().append("g").classed("gauge-outline", true).append("path");
+ gaugeBorder.select("path").call(drawArc).call(styleShape);
+ gaugeBorder.exit().remove();
+ }
+ function drawNumbers(gd, plotGroup, cd, opts) {
+ var trace = cd[0].trace;
+ var numbersX = opts.numbersX;
+ var numbersY = opts.numbersY;
+ var numbersAlign = trace.align || "center";
+ var numbersAnchor = anchor[numbersAlign];
+ var transitionOpts = opts.transitionOpts;
+ var onComplete = opts.onComplete;
+ var numbers = Lib.ensureSingle(plotGroup, "g", "numbers");
+ var bignumberbBox, deltabBox;
+ var numbersbBox;
+ var data = [];
+ if (trace._hasNumber) data.push("number");
+ if (trace._hasDelta) {
+ data.push("delta");
+ if (trace.delta.position === "left") data.reverse();
+ }
+ var sel = numbers.selectAll("text").data(data);
+ sel.enter().append("text");
+ sel.attr("text-anchor", function() {
+ return numbersAnchor;
+ }).attr("class", function(d) {
+ return d;
+ }).attr("x", null).attr("y", null).attr("dx", null).attr("dy", null);
+ sel.exit().remove();
+ function transitionFormat(valueformat, fmt, from, to) {
+ if (valueformat.match("s") && // If using SI prefix
+ from >= 0 !== to >= 0 && // If sign change
+ (!fmt(from).slice(-1).match(SI_PREFIX) && !fmt(to).slice(-1).match(SI_PREFIX))) {
+ var transitionValueFormat = valueformat.slice().replace("s", "f").replace(/\d+/, function(m) {
+ return parseInt(m) - 1;
+ });
+ var transitionAx = mockAxis(gd, { tickformat: transitionValueFormat });
+ return function(v) {
+ if (Math.abs(v) < 1) return Axes.tickText(transitionAx, v).text;
+ return fmt(v);
+ };
+ } else {
+ return fmt;
+ }
+ }
+ function drawBignumber() {
+ var bignumberAx = mockAxis(gd, { tickformat: trace.number.valueformat }, trace._range);
+ bignumberAx.setScale();
+ Axes.prepTicks(bignumberAx);
+ var bignumberFmt = function(v) {
+ return Axes.tickText(bignumberAx, v).text;
+ };
+ var bignumberSuffix = trace.number.suffix;
+ var bignumberPrefix = trace.number.prefix;
+ var number = numbers.select("text.number");
+ function writeNumber() {
+ var txt = typeof cd[0].y === "number" ? bignumberPrefix + bignumberFmt(cd[0].y) + bignumberSuffix : "-";
+ number.text(txt).call(Drawing.font, trace.number.font).call(svgTextUtils.convertToTspans, gd);
+ }
+ if (hasTransition(transitionOpts)) {
+ number.transition().duration(transitionOpts.duration).ease(transitionOpts.easing).each("end", function() {
+ writeNumber();
+ onComplete && onComplete();
+ }).each("interrupt", function() {
+ writeNumber();
+ onComplete && onComplete();
+ }).attrTween("text", function() {
+ var that = d3.select(this);
+ var interpolator = interpolateNumber(cd[0].lastY, cd[0].y);
+ trace._lastValue = cd[0].y;
+ var transitionFmt = transitionFormat(trace.number.valueformat, bignumberFmt, cd[0].lastY, cd[0].y);
+ return function(t) {
+ that.text(bignumberPrefix + transitionFmt(interpolator(t)) + bignumberSuffix);
+ };
+ });
+ } else {
+ writeNumber();
+ }
+ bignumberbBox = measureText(bignumberPrefix + bignumberFmt(cd[0].y) + bignumberSuffix, trace.number.font, numbersAnchor, gd);
+ return number;
+ }
+ function drawDelta() {
+ var deltaAx = mockAxis(gd, { tickformat: trace.delta.valueformat }, trace._range);
+ deltaAx.setScale();
+ Axes.prepTicks(deltaAx);
+ var deltaFmt = function(v) {
+ return Axes.tickText(deltaAx, v).text;
+ };
+ var deltaSuffix = trace.delta.suffix;
+ var deltaPrefix = trace.delta.prefix;
+ var deltaValue = function(d) {
+ var value = trace.delta.relative ? d.relativeDelta : d.delta;
+ return value;
+ };
+ var deltaFormatText = function(value, numberFmt) {
+ if (value === 0 || typeof value !== "number" || isNaN(value)) return "-";
+ return (value > 0 ? trace.delta.increasing.symbol : trace.delta.decreasing.symbol) + deltaPrefix + numberFmt(value) + deltaSuffix;
+ };
+ var deltaFill = function(d) {
+ return d.delta >= 0 ? trace.delta.increasing.color : trace.delta.decreasing.color;
+ };
+ if (trace._deltaLastValue === void 0) {
+ trace._deltaLastValue = deltaValue(cd[0]);
+ }
+ var delta2 = numbers.select("text.delta");
+ delta2.call(Drawing.font, trace.delta.font).call(Color2.fill, deltaFill({ delta: trace._deltaLastValue }));
+ function writeDelta() {
+ delta2.text(deltaFormatText(deltaValue(cd[0]), deltaFmt)).call(Color2.fill, deltaFill(cd[0])).call(svgTextUtils.convertToTspans, gd);
+ }
+ if (hasTransition(transitionOpts)) {
+ delta2.transition().duration(transitionOpts.duration).ease(transitionOpts.easing).tween("text", function() {
+ var that = d3.select(this);
+ var to = deltaValue(cd[0]);
+ var from = trace._deltaLastValue;
+ var transitionFmt = transitionFormat(trace.delta.valueformat, deltaFmt, from, to);
+ var interpolator = interpolateNumber(from, to);
+ trace._deltaLastValue = to;
+ return function(t) {
+ that.text(deltaFormatText(interpolator(t), transitionFmt));
+ that.call(Color2.fill, deltaFill({ delta: interpolator(t) }));
+ };
+ }).each("end", function() {
+ writeDelta();
+ onComplete && onComplete();
+ }).each("interrupt", function() {
+ writeDelta();
+ onComplete && onComplete();
+ });
+ } else {
+ writeDelta();
+ }
+ deltabBox = measureText(deltaFormatText(deltaValue(cd[0]), deltaFmt), trace.delta.font, numbersAnchor, gd);
+ return delta2;
+ }
+ var key = trace.mode + trace.align;
+ var delta;
+ if (trace._hasDelta) {
+ delta = drawDelta();
+ key += trace.delta.position + trace.delta.font.size + trace.delta.font.family + trace.delta.valueformat;
+ key += trace.delta.increasing.symbol + trace.delta.decreasing.symbol;
+ numbersbBox = deltabBox;
+ }
+ if (trace._hasNumber) {
+ drawBignumber();
+ key += trace.number.font.size + trace.number.font.family + trace.number.valueformat + trace.number.suffix + trace.number.prefix;
+ numbersbBox = bignumberbBox;
+ }
+ if (trace._hasDelta && trace._hasNumber) {
+ var bignumberCenter = [
+ (bignumberbBox.left + bignumberbBox.right) / 2,
+ (bignumberbBox.top + bignumberbBox.bottom) / 2
+ ];
+ var deltaCenter = [
+ (deltabBox.left + deltabBox.right) / 2,
+ (deltabBox.top + deltabBox.bottom) / 2
+ ];
+ var dx, dy;
+ var padding = 0.75 * trace.delta.font.size;
+ if (trace.delta.position === "left") {
+ dx = cache(trace, "deltaPos", 0, -1 * (bignumberbBox.width * position[trace.align] + deltabBox.width * (1 - position[trace.align]) + padding), key, Math.min);
+ dy = bignumberCenter[1] - deltaCenter[1];
+ numbersbBox = {
+ width: bignumberbBox.width + deltabBox.width + padding,
+ height: Math.max(bignumberbBox.height, deltabBox.height),
+ left: deltabBox.left + dx,
+ right: bignumberbBox.right,
+ top: Math.min(bignumberbBox.top, deltabBox.top + dy),
+ bottom: Math.max(bignumberbBox.bottom, deltabBox.bottom + dy)
+ };
+ }
+ if (trace.delta.position === "right") {
+ dx = cache(trace, "deltaPos", 0, bignumberbBox.width * (1 - position[trace.align]) + deltabBox.width * position[trace.align] + padding, key, Math.max);
+ dy = bignumberCenter[1] - deltaCenter[1];
+ numbersbBox = {
+ width: bignumberbBox.width + deltabBox.width + padding,
+ height: Math.max(bignumberbBox.height, deltabBox.height),
+ left: bignumberbBox.left,
+ right: deltabBox.right + dx,
+ top: Math.min(bignumberbBox.top, deltabBox.top + dy),
+ bottom: Math.max(bignumberbBox.bottom, deltabBox.bottom + dy)
+ };
+ }
+ if (trace.delta.position === "bottom") {
+ dx = null;
+ dy = deltabBox.height;
+ numbersbBox = {
+ width: Math.max(bignumberbBox.width, deltabBox.width),
+ height: bignumberbBox.height + deltabBox.height,
+ left: Math.min(bignumberbBox.left, deltabBox.left),
+ right: Math.max(bignumberbBox.right, deltabBox.right),
+ top: bignumberbBox.bottom - bignumberbBox.height,
+ bottom: bignumberbBox.bottom + deltabBox.height
+ };
+ }
+ if (trace.delta.position === "top") {
+ dx = null;
+ dy = bignumberbBox.top;
+ numbersbBox = {
+ width: Math.max(bignumberbBox.width, deltabBox.width),
+ height: bignumberbBox.height + deltabBox.height,
+ left: Math.min(bignumberbBox.left, deltabBox.left),
+ right: Math.max(bignumberbBox.right, deltabBox.right),
+ top: bignumberbBox.bottom - bignumberbBox.height - deltabBox.height,
+ bottom: bignumberbBox.bottom
+ };
+ }
+ delta.attr({ dx, dy });
+ }
+ if (trace._hasNumber || trace._hasDelta) {
+ numbers.attr("transform", function() {
+ var m = opts.numbersScaler(numbersbBox);
+ key += m[2];
+ var scaleRatio = cache(trace, "numbersScale", 1, m[0], key, Math.min);
+ var translateY;
+ if (!trace._scaleNumbers) scaleRatio = 1;
+ if (trace._isAngular) {
+ translateY = numbersY - scaleRatio * numbersbBox.bottom;
+ } else {
+ translateY = numbersY - scaleRatio * (numbersbBox.top + numbersbBox.bottom) / 2;
+ }
+ trace._numbersTop = scaleRatio * numbersbBox.top + translateY;
+ var ref = numbersbBox[numbersAlign];
+ if (numbersAlign === "center") ref = (numbersbBox.left + numbersbBox.right) / 2;
+ var translateX = numbersX - scaleRatio * ref;
+ translateX = cache(trace, "numbersTranslate", 0, translateX, key, Math.max);
+ return strTranslate(translateX, translateY) + strScale(scaleRatio);
+ });
+ }
+ }
+ function styleShape(p) {
+ p.each(function(d) {
+ Color2.stroke(d3.select(this), d.line.color);
+ }).each(function(d) {
+ Color2.fill(d3.select(this), d.color);
+ }).style("stroke-width", function(d) {
+ return d.line.width;
+ });
+ }
+ function arcTween(arc, endAngle, newAngle) {
+ return function() {
+ var interp = interpolate(endAngle, newAngle);
+ return function(t) {
+ return arc.endAngle(interp(t))();
+ };
+ };
+ }
+ function mockAxis(gd, opts, zrange) {
+ var fullLayout = gd._fullLayout;
+ var axisIn = Lib.extendFlat({
+ type: "linear",
+ ticks: "outside",
+ range: zrange,
+ showline: true
+ }, opts);
+ var axisOut = {
+ type: "linear",
+ _id: "x" + opts._id
+ };
+ var axisOptions = {
+ letter: "x",
+ font: fullLayout.font,
+ noAutotickangles: true,
+ noHover: true,
+ noTickson: true
+ };
+ function coerce(attr, dflt) {
+ return Lib.coerce(axisIn, axisOut, axisLayoutAttrs, attr, dflt);
+ }
+ handleAxisDefaults(axisIn, axisOut, coerce, axisOptions, fullLayout);
+ handleAxisPositionDefaults(axisIn, axisOut, coerce, axisOptions);
+ return axisOut;
+ }
+ function fitTextInsideBox(textBB, width, height) {
+ var ratio = Math.min(width / textBB.width, height / textBB.height);
+ return [ratio, textBB, width + "x" + height];
+ }
+ function fitTextInsideCircle(textBB, radius) {
+ var elRadius = Math.sqrt(textBB.width / 2 * (textBB.width / 2) + textBB.height * textBB.height);
+ var ratio = radius / elRadius;
+ return [ratio, textBB, radius];
+ }
+ function measureText(txt, font, textAnchor, gd) {
+ var element = document.createElementNS("http://www.w3.org/2000/svg", "text");
+ var sel = d3.select(element);
+ sel.text(txt).attr("x", 0).attr("y", 0).attr("text-anchor", textAnchor).attr("data-unformatted", txt).call(svgTextUtils.convertToTspans, gd).call(Drawing.font, font);
+ return Drawing.bBox(sel.node());
+ }
+ function cache(trace, name2, initialValue, value, key, fn) {
+ var objName = "_cache" + name2;
+ if (!(trace[objName] && trace[objName].key === key)) {
+ trace[objName] = { key, value: initialValue };
+ }
+ var v = Lib.aggNums(fn, null, [trace[objName].value, value], 2);
+ trace[objName].value = v;
+ return v;
+ }
+ }
+ });
+
+ // src/traces/indicator/index.js
+ var require_indicator = __commonJS({
+ "src/traces/indicator/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ moduleType: "trace",
+ name: "indicator",
+ basePlotModule: require_base_plot10(),
+ categories: ["svg", "noOpacity", "noHover"],
+ animatable: true,
+ attributes: require_attributes61(),
+ supplyDefaults: require_defaults57().supplyDefaults,
+ calc: require_calc36().calc,
+ plot: require_plot30(),
+ meta: {}
+ };
+ }
+ });
+
+ // lib/indicator.js
+ var require_indicator2 = __commonJS({
+ "lib/indicator.js"(exports, module) {
+ "use strict";
+ module.exports = require_indicator();
+ }
+ });
+
+ // src/traces/table/attributes.js
+ var require_attributes62 = __commonJS({
+ "src/traces/table/attributes.js"(exports, module) {
+ "use strict";
+ var annAttrs = require_attributes11();
+ var extendFlat = require_extend().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var fontAttrs = require_font_attributes();
+ var domainAttrs = require_domain().attributes;
+ var descriptionOnlyNumbers = require_axis_format_attributes().descriptionOnlyNumbers;
+ var attrs = module.exports = overrideAll({
+ domain: domainAttrs({ name: "table", trace: true }),
+ columnwidth: {
+ valType: "number",
+ arrayOk: true,
+ dflt: null
+ },
+ columnorder: {
+ valType: "data_array"
+ },
+ header: {
+ values: {
+ valType: "data_array",
+ dflt: []
+ },
+ format: {
+ valType: "data_array",
+ dflt: [],
+ description: descriptionOnlyNumbers("cell value")
+ },
+ prefix: {
+ valType: "string",
+ arrayOk: true,
+ dflt: null
+ },
+ suffix: {
+ valType: "string",
+ arrayOk: true,
+ dflt: null
+ },
+ height: {
+ valType: "number",
+ dflt: 28
+ },
+ align: extendFlat({}, annAttrs.align, { arrayOk: true }),
+ line: {
+ width: {
+ valType: "number",
+ arrayOk: true,
+ dflt: 1
+ },
+ color: {
+ valType: "color",
+ arrayOk: true,
+ dflt: "grey"
+ }
+ },
+ fill: {
+ color: {
+ valType: "color",
+ arrayOk: true,
+ dflt: "white"
+ }
+ },
+ font: extendFlat({}, fontAttrs({ arrayOk: true }))
+ },
+ cells: {
+ values: {
+ valType: "data_array",
+ dflt: []
+ },
+ format: {
+ valType: "data_array",
+ dflt: [],
+ description: descriptionOnlyNumbers("cell value")
+ },
+ prefix: {
+ valType: "string",
+ arrayOk: true,
+ dflt: null
+ },
+ suffix: {
+ valType: "string",
+ arrayOk: true,
+ dflt: null
+ },
+ height: {
+ valType: "number",
+ dflt: 20
+ },
+ align: extendFlat({}, annAttrs.align, { arrayOk: true }),
+ line: {
+ width: {
+ valType: "number",
+ arrayOk: true,
+ dflt: 1
+ },
+ color: {
+ valType: "color",
+ arrayOk: true,
+ dflt: "grey"
+ }
+ },
+ fill: {
+ color: {
+ valType: "color",
+ arrayOk: true,
+ dflt: "white"
+ }
+ },
+ font: extendFlat({}, fontAttrs({ arrayOk: true }))
+ }
+ }, "calc", "from-root");
+ }
+ });
+
+ // src/traces/table/defaults.js
+ var require_defaults58 = __commonJS({
+ "src/traces/table/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var attributes = require_attributes62();
+ var handleDomainDefaults = require_domain().defaults;
+ function defaultColumnOrder(traceOut, coerce) {
+ var specifiedColumnOrder = traceOut.columnorder || [];
+ var commonLength = traceOut.header.values.length;
+ var truncated = specifiedColumnOrder.slice(0, commonLength);
+ var sorted = truncated.slice().sort(function(a, b) {
+ return a - b;
+ });
+ var oneStepped = truncated.map(function(d) {
+ return sorted.indexOf(d);
+ });
+ for (var i = oneStepped.length; i < commonLength; i++) {
+ oneStepped.push(i);
+ }
+ coerce("columnorder", oneStepped);
+ }
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ handleDomainDefaults(traceOut, layout, coerce);
+ coerce("columnwidth");
+ coerce("header.values");
+ coerce("header.format");
+ coerce("header.align");
+ coerce("header.prefix");
+ coerce("header.suffix");
+ coerce("header.height");
+ coerce("header.line.width");
+ coerce("header.line.color");
+ coerce("header.fill.color");
+ Lib.coerceFont(coerce, "header.font", layout.font);
+ defaultColumnOrder(traceOut, coerce);
+ coerce("cells.values");
+ coerce("cells.format");
+ coerce("cells.align");
+ coerce("cells.prefix");
+ coerce("cells.suffix");
+ coerce("cells.height");
+ coerce("cells.line.width");
+ coerce("cells.line.color");
+ coerce("cells.fill.color");
+ Lib.coerceFont(coerce, "cells.font", layout.font);
+ traceOut._length = null;
+ };
+ }
+ });
+
+ // src/traces/table/calc.js
+ var require_calc37 = __commonJS({
+ "src/traces/table/calc.js"(exports, module) {
+ "use strict";
+ var wrap = require_gup().wrap;
+ module.exports = function calc() {
+ return wrap({});
+ };
+ }
+ });
+
+ // src/traces/table/constants.js
+ var require_constants31 = __commonJS({
+ "src/traces/table/constants.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ cellPad: 8,
+ columnExtentOffset: 10,
+ columnTitleOffset: 28,
+ emptyHeaderHeight: 16,
+ latexCheck: /^\$.*\$$/,
+ goldenRatio: 1.618,
+ lineBreaker: "
",
+ maxDimensionCount: 60,
+ overdrag: 45,
+ releaseTransitionDuration: 120,
+ releaseTransitionEase: "cubic-out",
+ scrollbarCaptureWidth: 18,
+ scrollbarHideDelay: 1e3,
+ scrollbarHideDuration: 1e3,
+ scrollbarOffset: 5,
+ scrollbarWidth: 8,
+ transitionDuration: 100,
+ transitionEase: "cubic-out",
+ uplift: 5,
+ wrapSpacer: " ",
+ wrapSplitCharacter: " ",
+ cn: {
+ // general class names
+ table: "table",
+ tableControlView: "table-control-view",
+ scrollBackground: "scroll-background",
+ yColumn: "y-column",
+ columnBlock: "column-block",
+ scrollAreaClip: "scroll-area-clip",
+ scrollAreaClipRect: "scroll-area-clip-rect",
+ columnBoundary: "column-boundary",
+ columnBoundaryClippath: "column-boundary-clippath",
+ columnBoundaryRect: "column-boundary-rect",
+ columnCells: "column-cells",
+ columnCell: "column-cell",
+ cellRect: "cell-rect",
+ cellText: "cell-text",
+ cellTextHolder: "cell-text-holder",
+ // scroll related class names
+ scrollbarKit: "scrollbar-kit",
+ scrollbar: "scrollbar",
+ scrollbarSlider: "scrollbar-slider",
+ scrollbarGlyph: "scrollbar-glyph",
+ scrollbarCaptureZone: "scrollbar-capture-zone"
+ }
+ };
+ }
+ });
+
+ // src/traces/table/data_preparation_helper.js
+ var require_data_preparation_helper = __commonJS({
+ "src/traces/table/data_preparation_helper.js"(exports, module) {
+ "use strict";
+ var c = require_constants31();
+ var extendFlat = require_extend().extendFlat;
+ var isNumeric = require_fast_isnumeric();
+ var isTypedArray = require_array().isTypedArray;
+ var isArrayOrTypedArray = require_array().isArrayOrTypedArray;
+ module.exports = function calc(gd, trace) {
+ var cellsValues = squareStringMatrix(trace.cells.values);
+ var slicer = function(a) {
+ return a.slice(trace.header.values.length, a.length);
+ };
+ var headerValuesIn = squareStringMatrix(trace.header.values);
+ if (headerValuesIn.length && !headerValuesIn[0].length) {
+ headerValuesIn[0] = [""];
+ headerValuesIn = squareStringMatrix(headerValuesIn);
+ }
+ var headerValues = headerValuesIn.concat(slicer(cellsValues).map(function() {
+ return emptyStrings((headerValuesIn[0] || [""]).length);
+ }));
+ var domain = trace.domain;
+ var groupWidth = Math.floor(gd._fullLayout._size.w * (domain.x[1] - domain.x[0]));
+ var groupHeight = Math.floor(gd._fullLayout._size.h * (domain.y[1] - domain.y[0]));
+ var headerRowHeights = trace.header.values.length ? headerValues[0].map(function() {
+ return trace.header.height;
+ }) : [c.emptyHeaderHeight];
+ var rowHeights = cellsValues.length ? cellsValues[0].map(function() {
+ return trace.cells.height;
+ }) : [];
+ var headerHeight = headerRowHeights.reduce(sum, 0);
+ var scrollHeight = groupHeight - headerHeight;
+ var minimumFillHeight = scrollHeight + c.uplift;
+ var anchorToRowBlock = makeAnchorToRowBlock(rowHeights, minimumFillHeight);
+ var anchorToHeaderRowBlock = makeAnchorToRowBlock(headerRowHeights, headerHeight);
+ var headerRowBlocks = makeRowBlock(anchorToHeaderRowBlock, []);
+ var rowBlocks = makeRowBlock(anchorToRowBlock, headerRowBlocks);
+ var uniqueKeys = {};
+ var columnOrder = trace._fullInput.columnorder;
+ if (isArrayOrTypedArray(columnOrder)) columnOrder = Array.from(columnOrder);
+ columnOrder = columnOrder.concat(slicer(cellsValues.map(function(d, i) {
+ return i;
+ })));
+ var columnWidths = headerValues.map(function(d, i) {
+ var value = isArrayOrTypedArray(trace.columnwidth) ? trace.columnwidth[Math.min(i, trace.columnwidth.length - 1)] : trace.columnwidth;
+ return isNumeric(value) ? Number(value) : 1;
+ });
+ var totalColumnWidths = columnWidths.reduce(sum, 0);
+ columnWidths = columnWidths.map(function(d) {
+ return d / totalColumnWidths * groupWidth;
+ });
+ var maxLineWidth = Math.max(arrayMax(trace.header.line.width), arrayMax(trace.cells.line.width));
+ var calcdata = {
+ // include staticPlot in the key so if it changes we delete and redraw
+ key: trace.uid + gd._context.staticPlot,
+ translateX: domain.x[0] * gd._fullLayout._size.w,
+ translateY: gd._fullLayout._size.h * (1 - domain.y[1]),
+ size: gd._fullLayout._size,
+ width: groupWidth,
+ maxLineWidth,
+ height: groupHeight,
+ columnOrder,
+ // will be mutated on column move, todo use in callback
+ groupHeight,
+ rowBlocks,
+ headerRowBlocks,
+ scrollY: 0,
+ // will be mutated on scroll
+ cells: extendFlat({}, trace.cells, { values: cellsValues }),
+ headerCells: extendFlat({}, trace.header, { values: headerValues }),
+ gdColumns: headerValues.map(function(d) {
+ return d[0];
+ }),
+ gdColumnsOriginalOrder: headerValues.map(function(d) {
+ return d[0];
+ }),
+ prevPages: [0, 0],
+ scrollbarState: { scrollbarScrollInProgress: false },
+ columns: headerValues.map(function(label, i) {
+ var foundKey = uniqueKeys[label];
+ uniqueKeys[label] = (foundKey || 0) + 1;
+ var key = label + "__" + uniqueKeys[label];
+ return {
+ key,
+ label,
+ specIndex: i,
+ xIndex: columnOrder[i],
+ xScale,
+ x: void 0,
+ // initialized below
+ calcdata: void 0,
+ // initialized below
+ columnWidth: columnWidths[i]
+ };
+ })
+ };
+ calcdata.columns.forEach(function(col) {
+ col.calcdata = calcdata;
+ col.x = xScale(col);
+ });
+ return calcdata;
+ };
+ function arrayMax(maybeArray) {
+ if (isArrayOrTypedArray(maybeArray)) {
+ var max = 0;
+ for (var i = 0; i < maybeArray.length; i++) {
+ max = Math.max(max, arrayMax(maybeArray[i]));
+ }
+ return max;
+ }
+ return maybeArray;
+ }
+ function sum(a, b) {
+ return a + b;
+ }
+ function squareStringMatrix(matrixIn) {
+ var matrix = matrixIn.slice();
+ var minLen = Infinity;
+ var maxLen = 0;
+ var i;
+ for (i = 0; i < matrix.length; i++) {
+ if (isTypedArray(matrix[i])) matrix[i] = Array.from(matrix[i]);
+ else if (!isArrayOrTypedArray(matrix[i])) matrix[i] = [matrix[i]];
+ minLen = Math.min(minLen, matrix[i].length);
+ maxLen = Math.max(maxLen, matrix[i].length);
+ }
+ if (minLen !== maxLen) {
+ for (i = 0; i < matrix.length; i++) {
+ var padLen = maxLen - matrix[i].length;
+ if (padLen) matrix[i] = matrix[i].concat(emptyStrings(padLen));
+ }
+ }
+ return matrix;
+ }
+ function emptyStrings(len) {
+ var padArray = new Array(len);
+ for (var j = 0; j < len; j++) padArray[j] = "";
+ return padArray;
+ }
+ function xScale(d) {
+ return d.calcdata.columns.reduce(function(prev, next) {
+ return next.xIndex < d.xIndex ? prev + next.columnWidth : prev;
+ }, 0);
+ }
+ function makeRowBlock(anchorToRowBlock, auxiliary) {
+ var blockAnchorKeys = Object.keys(anchorToRowBlock);
+ return blockAnchorKeys.map(function(k) {
+ return extendFlat({}, anchorToRowBlock[k], { auxiliaryBlocks: auxiliary });
+ });
+ }
+ function makeAnchorToRowBlock(rowHeights, minimumFillHeight) {
+ var anchorToRowBlock = {};
+ var currentRowHeight;
+ var currentAnchor = 0;
+ var currentBlockHeight = 0;
+ var currentBlock = makeIdentity();
+ var currentFirstRowIndex = 0;
+ var blockCounter = 0;
+ for (var i = 0; i < rowHeights.length; i++) {
+ currentRowHeight = rowHeights[i];
+ currentBlock.rows.push({
+ rowIndex: i,
+ rowHeight: currentRowHeight
+ });
+ currentBlockHeight += currentRowHeight;
+ if (currentBlockHeight >= minimumFillHeight || i === rowHeights.length - 1) {
+ anchorToRowBlock[currentAnchor] = currentBlock;
+ currentBlock.key = blockCounter++;
+ currentBlock.firstRowIndex = currentFirstRowIndex;
+ currentBlock.lastRowIndex = i;
+ currentBlock = makeIdentity();
+ currentAnchor += currentBlockHeight;
+ currentFirstRowIndex = i + 1;
+ currentBlockHeight = 0;
+ }
+ }
+ return anchorToRowBlock;
+ }
+ function makeIdentity() {
+ return {
+ firstRowIndex: null,
+ lastRowIndex: null,
+ rows: []
+ };
+ }
+ }
+ });
+
+ // src/traces/table/data_split_helpers.js
+ var require_data_split_helpers = __commonJS({
+ "src/traces/table/data_split_helpers.js"(exports) {
+ "use strict";
+ var extendFlat = require_extend().extendFlat;
+ exports.splitToPanels = function(d) {
+ var prevPages = [0, 0];
+ var headerPanel = extendFlat({}, d, {
+ key: "header",
+ type: "header",
+ page: 0,
+ prevPages,
+ currentRepaint: [null, null],
+ dragHandle: true,
+ values: d.calcdata.headerCells.values[d.specIndex],
+ rowBlocks: d.calcdata.headerRowBlocks,
+ calcdata: extendFlat({}, d.calcdata, { cells: d.calcdata.headerCells })
+ });
+ var revolverPanel1 = extendFlat({}, d, {
+ key: "cells1",
+ type: "cells",
+ page: 0,
+ prevPages,
+ currentRepaint: [null, null],
+ dragHandle: false,
+ values: d.calcdata.cells.values[d.specIndex],
+ rowBlocks: d.calcdata.rowBlocks
+ });
+ var revolverPanel2 = extendFlat({}, d, {
+ key: "cells2",
+ type: "cells",
+ page: 1,
+ prevPages,
+ currentRepaint: [null, null],
+ dragHandle: false,
+ values: d.calcdata.cells.values[d.specIndex],
+ rowBlocks: d.calcdata.rowBlocks
+ });
+ return [revolverPanel1, revolverPanel2, headerPanel];
+ };
+ exports.splitToCells = function(d) {
+ var fromTo = rowFromTo(d);
+ return (d.values || []).slice(fromTo[0], fromTo[1]).map(function(v, i) {
+ var buster = typeof v === "string" && v.match(/[<$&> ]/) ? "_keybuster_" + Math.random() : "";
+ return {
+ // keyWithinBlock: /*fromTo[0] + */i, // optimized future version - no busting
+ // keyWithinBlock: fromTo[0] + i, // initial always-unoptimized version - janky scrolling with 5+ columns
+ keyWithinBlock: i + buster,
+ // current compromise: regular content is very fast; async content is possible
+ key: fromTo[0] + i,
+ column: d,
+ calcdata: d.calcdata,
+ page: d.page,
+ rowBlocks: d.rowBlocks,
+ value: v
+ };
+ });
+ };
+ function rowFromTo(d) {
+ var rowBlock = d.rowBlocks[d.page];
+ var rowFrom = rowBlock ? rowBlock.rows[0].rowIndex : 0;
+ var rowTo = rowBlock ? rowFrom + rowBlock.rows.length : 0;
+ return [rowFrom, rowTo];
+ }
+ }
+ });
+
+ // src/traces/table/plot.js
+ var require_plot31 = __commonJS({
+ "src/traces/table/plot.js"(exports, module) {
+ "use strict";
+ var c = require_constants31();
+ var d3 = require_d3();
+ var Lib = require_lib();
+ var numberFormat = Lib.numberFormat;
+ var gup = require_gup();
+ var Drawing = require_drawing();
+ var svgUtil = require_svg_text_utils();
+ var raiseToTop = require_lib().raiseToTop;
+ var strTranslate = require_lib().strTranslate;
+ var cancelEeaseColumn = require_lib().cancelTransition;
+ var prepareData = require_data_preparation_helper();
+ var splitData = require_data_split_helpers();
+ var Color2 = require_color();
+ module.exports = function plot(gd, wrappedTraceHolders) {
+ var dynamic = !gd._context.staticPlot;
+ var table = gd._fullLayout._paper.selectAll("." + c.cn.table).data(wrappedTraceHolders.map(function(wrappedTraceHolder) {
+ var traceHolder = gup.unwrap(wrappedTraceHolder);
+ var trace = traceHolder.trace;
+ return prepareData(gd, trace);
+ }), gup.keyFun);
+ table.exit().remove();
+ table.enter().append("g").classed(c.cn.table, true).attr("overflow", "visible").style("box-sizing", "content-box").style("position", "absolute").style("left", 0).style("overflow", "visible").style("shape-rendering", "crispEdges").style("pointer-events", "all");
+ table.attr("width", function(d) {
+ return d.width + d.size.l + d.size.r;
+ }).attr("height", function(d) {
+ return d.height + d.size.t + d.size.b;
+ }).attr("transform", function(d) {
+ return strTranslate(d.translateX, d.translateY);
+ });
+ var tableControlView = table.selectAll("." + c.cn.tableControlView).data(gup.repeat, gup.keyFun);
+ var cvEnter = tableControlView.enter().append("g").classed(c.cn.tableControlView, true).style("box-sizing", "content-box");
+ if (dynamic) {
+ var wheelEvent = "onwheel" in document ? "wheel" : "mousewheel";
+ cvEnter.on("mousemove", function(d) {
+ tableControlView.filter(function(dd) {
+ return d === dd;
+ }).call(renderScrollbarKit, gd);
+ }).on(wheelEvent, function(d) {
+ if (d.scrollbarState.wheeling) return;
+ d.scrollbarState.wheeling = true;
+ var newY = d.scrollY + d3.event.deltaY;
+ var noChange = makeDragRow(gd, tableControlView, null, newY)(d);
+ if (!noChange) {
+ d3.event.stopPropagation();
+ d3.event.preventDefault();
+ }
+ d.scrollbarState.wheeling = false;
+ }).call(renderScrollbarKit, gd, true);
+ }
+ tableControlView.attr("transform", function(d) {
+ return strTranslate(d.size.l, d.size.t);
+ });
+ var scrollBackground = tableControlView.selectAll("." + c.cn.scrollBackground).data(gup.repeat, gup.keyFun);
+ scrollBackground.enter().append("rect").classed(c.cn.scrollBackground, true).attr("fill", "none");
+ scrollBackground.attr("width", function(d) {
+ return d.width;
+ }).attr("height", function(d) {
+ return d.height;
+ });
+ tableControlView.each(function(d) {
+ Drawing.setClipUrl(d3.select(this), scrollAreaBottomClipKey(gd, d), gd);
+ });
+ var yColumn = tableControlView.selectAll("." + c.cn.yColumn).data(function(vm) {
+ return vm.columns;
+ }, gup.keyFun);
+ yColumn.enter().append("g").classed(c.cn.yColumn, true);
+ yColumn.exit().remove();
+ yColumn.attr("transform", function(d) {
+ return strTranslate(d.x, 0);
+ });
+ if (dynamic) {
+ yColumn.call(
+ d3.behavior.drag().origin(function(d) {
+ var movedColumn = d3.select(this);
+ easeColumn(movedColumn, d, -c.uplift);
+ raiseToTop(this);
+ d.calcdata.columnDragInProgress = true;
+ renderScrollbarKit(tableControlView.filter(function(dd) {
+ return d.calcdata.key === dd.key;
+ }), gd);
+ return d;
+ }).on("drag", function(d) {
+ var movedColumn = d3.select(this);
+ var getter = function(dd) {
+ return (d === dd ? d3.event.x : dd.x) + dd.columnWidth / 2;
+ };
+ d.x = Math.max(-c.overdrag, Math.min(d.calcdata.width + c.overdrag - d.columnWidth, d3.event.x));
+ var sortableColumns = flatData(yColumn).filter(function(dd) {
+ return dd.calcdata.key === d.calcdata.key;
+ });
+ var newOrder = sortableColumns.sort(function(a, b) {
+ return getter(a) - getter(b);
+ });
+ newOrder.forEach(function(dd, i) {
+ dd.xIndex = i;
+ dd.x = d === dd ? dd.x : dd.xScale(dd);
+ });
+ yColumn.filter(function(dd) {
+ return d !== dd;
+ }).transition().ease(c.transitionEase).duration(c.transitionDuration).attr("transform", function(d2) {
+ return strTranslate(d2.x, 0);
+ });
+ movedColumn.call(cancelEeaseColumn).attr("transform", strTranslate(d.x, -c.uplift));
+ }).on("dragend", function(d) {
+ var movedColumn = d3.select(this);
+ var p = d.calcdata;
+ d.x = d.xScale(d);
+ d.calcdata.columnDragInProgress = false;
+ easeColumn(movedColumn, d, 0);
+ columnMoved(gd, p, p.columns.map(function(dd) {
+ return dd.xIndex;
+ }));
+ })
+ );
+ }
+ yColumn.each(function(d) {
+ Drawing.setClipUrl(d3.select(this), columnBoundaryClipKey(gd, d), gd);
+ });
+ var columnBlock = yColumn.selectAll("." + c.cn.columnBlock).data(splitData.splitToPanels, gup.keyFun);
+ columnBlock.enter().append("g").classed(c.cn.columnBlock, true).attr("id", function(d) {
+ return d.key;
+ });
+ columnBlock.style("cursor", function(d) {
+ return d.dragHandle ? "ew-resize" : d.calcdata.scrollbarState.barWiggleRoom ? "ns-resize" : "default";
+ });
+ var headerColumnBlock = columnBlock.filter(headerBlock);
+ var cellsColumnBlock = columnBlock.filter(cellsBlock);
+ if (dynamic) {
+ cellsColumnBlock.call(
+ d3.behavior.drag().origin(function(d) {
+ d3.event.stopPropagation();
+ return d;
+ }).on("drag", makeDragRow(gd, tableControlView, -1)).on("dragend", function() {
+ })
+ );
+ }
+ renderColumnCellTree(gd, tableControlView, headerColumnBlock, columnBlock);
+ renderColumnCellTree(gd, tableControlView, cellsColumnBlock, columnBlock);
+ var scrollAreaClip = tableControlView.selectAll("." + c.cn.scrollAreaClip).data(gup.repeat, gup.keyFun);
+ scrollAreaClip.enter().append("clipPath").classed(c.cn.scrollAreaClip, true).attr("id", function(d) {
+ return scrollAreaBottomClipKey(gd, d);
+ });
+ var scrollAreaClipRect = scrollAreaClip.selectAll("." + c.cn.scrollAreaClipRect).data(gup.repeat, gup.keyFun);
+ scrollAreaClipRect.enter().append("rect").classed(c.cn.scrollAreaClipRect, true).attr("x", -c.overdrag).attr("y", -c.uplift).attr("fill", "none");
+ scrollAreaClipRect.attr("width", function(d) {
+ return d.width + 2 * c.overdrag;
+ }).attr("height", function(d) {
+ return d.height + c.uplift;
+ });
+ var columnBoundary = yColumn.selectAll("." + c.cn.columnBoundary).data(gup.repeat, gup.keyFun);
+ columnBoundary.enter().append("g").classed(c.cn.columnBoundary, true);
+ var columnBoundaryClippath = yColumn.selectAll("." + c.cn.columnBoundaryClippath).data(gup.repeat, gup.keyFun);
+ columnBoundaryClippath.enter().append("clipPath").classed(c.cn.columnBoundaryClippath, true);
+ columnBoundaryClippath.attr("id", function(d) {
+ return columnBoundaryClipKey(gd, d);
+ });
+ var columnBoundaryRect = columnBoundaryClippath.selectAll("." + c.cn.columnBoundaryRect).data(gup.repeat, gup.keyFun);
+ columnBoundaryRect.enter().append("rect").classed(c.cn.columnBoundaryRect, true).attr("fill", "none");
+ columnBoundaryRect.attr("width", function(d) {
+ return d.columnWidth + 2 * roundHalfWidth(d);
+ }).attr("height", function(d) {
+ return d.calcdata.height + 2 * roundHalfWidth(d) + c.uplift;
+ }).attr("x", function(d) {
+ return -roundHalfWidth(d);
+ }).attr("y", function(d) {
+ return -roundHalfWidth(d);
+ });
+ updateBlockYPosition(null, cellsColumnBlock, tableControlView);
+ };
+ function roundHalfWidth(d) {
+ return Math.ceil(d.calcdata.maxLineWidth / 2);
+ }
+ function scrollAreaBottomClipKey(gd, d) {
+ return "clip" + gd._fullLayout._uid + "_scrollAreaBottomClip_" + d.key;
+ }
+ function columnBoundaryClipKey(gd, d) {
+ return "clip" + gd._fullLayout._uid + "_columnBoundaryClippath_" + d.calcdata.key + "_" + d.specIndex;
+ }
+ function flatData(selection) {
+ return [].concat.apply([], selection.map(function(g) {
+ return g;
+ })).map(function(g) {
+ return g.__data__;
+ });
+ }
+ function renderScrollbarKit(tableControlView, gd, bypassVisibleBar) {
+ function calcTotalHeight(d) {
+ var blocks = d.rowBlocks;
+ return firstRowAnchor(blocks, blocks.length - 1) + (blocks.length ? rowsHeight(blocks[blocks.length - 1], Infinity) : 1);
+ }
+ var scrollbarKit = tableControlView.selectAll("." + c.cn.scrollbarKit).data(gup.repeat, gup.keyFun);
+ scrollbarKit.enter().append("g").classed(c.cn.scrollbarKit, true).style("shape-rendering", "geometricPrecision");
+ scrollbarKit.each(function(d) {
+ var s = d.scrollbarState;
+ s.totalHeight = calcTotalHeight(d);
+ s.scrollableAreaHeight = d.groupHeight - headerHeight(d);
+ s.currentlyVisibleHeight = Math.min(s.totalHeight, s.scrollableAreaHeight);
+ s.ratio = s.currentlyVisibleHeight / s.totalHeight;
+ s.barLength = Math.max(s.ratio * s.currentlyVisibleHeight, c.goldenRatio * c.scrollbarWidth);
+ s.barWiggleRoom = s.currentlyVisibleHeight - s.barLength;
+ s.wiggleRoom = Math.max(0, s.totalHeight - s.scrollableAreaHeight);
+ s.topY = s.barWiggleRoom === 0 ? 0 : d.scrollY / s.wiggleRoom * s.barWiggleRoom;
+ s.bottomY = s.topY + s.barLength;
+ s.dragMultiplier = s.wiggleRoom / s.barWiggleRoom;
+ }).attr("transform", function(d) {
+ var xPosition2 = d.width + c.scrollbarWidth / 2 + c.scrollbarOffset;
+ return strTranslate(xPosition2, headerHeight(d));
+ });
+ var scrollbar = scrollbarKit.selectAll("." + c.cn.scrollbar).data(gup.repeat, gup.keyFun);
+ scrollbar.enter().append("g").classed(c.cn.scrollbar, true);
+ var scrollbarSlider = scrollbar.selectAll("." + c.cn.scrollbarSlider).data(gup.repeat, gup.keyFun);
+ scrollbarSlider.enter().append("g").classed(c.cn.scrollbarSlider, true);
+ scrollbarSlider.attr("transform", function(d) {
+ return strTranslate(0, d.scrollbarState.topY || 0);
+ });
+ var scrollbarGlyph = scrollbarSlider.selectAll("." + c.cn.scrollbarGlyph).data(gup.repeat, gup.keyFun);
+ scrollbarGlyph.enter().append("line").classed(c.cn.scrollbarGlyph, true).attr("stroke", "black").attr("stroke-width", c.scrollbarWidth).attr("stroke-linecap", "round").attr("y1", c.scrollbarWidth / 2);
+ scrollbarGlyph.attr("y2", function(d) {
+ return d.scrollbarState.barLength - c.scrollbarWidth / 2;
+ }).attr("stroke-opacity", function(d) {
+ return d.columnDragInProgress || !d.scrollbarState.barWiggleRoom || bypassVisibleBar ? 0 : 0.4;
+ });
+ scrollbarGlyph.transition().delay(0).duration(0);
+ scrollbarGlyph.transition().delay(c.scrollbarHideDelay).duration(c.scrollbarHideDuration).attr("stroke-opacity", 0);
+ var scrollbarCaptureZone = scrollbar.selectAll("." + c.cn.scrollbarCaptureZone).data(gup.repeat, gup.keyFun);
+ scrollbarCaptureZone.enter().append("line").classed(c.cn.scrollbarCaptureZone, true).attr("stroke", "white").attr("stroke-opacity", 0.01).attr("stroke-width", c.scrollbarCaptureWidth).attr("stroke-linecap", "butt").attr("y1", 0).on("mousedown", function(d) {
+ var y = d3.event.y;
+ var bbox = this.getBoundingClientRect();
+ var s = d.scrollbarState;
+ var pixelVal = y - bbox.top;
+ var inverseScale = d3.scale.linear().domain([0, s.scrollableAreaHeight]).range([0, s.totalHeight]).clamp(true);
+ if (!(s.topY <= pixelVal && pixelVal <= s.bottomY)) {
+ makeDragRow(gd, tableControlView, null, inverseScale(pixelVal - s.barLength / 2))(d);
+ }
+ }).call(
+ d3.behavior.drag().origin(function(d) {
+ d3.event.stopPropagation();
+ d.scrollbarState.scrollbarScrollInProgress = true;
+ return d;
+ }).on("drag", makeDragRow(gd, tableControlView)).on("dragend", function() {
+ })
+ );
+ scrollbarCaptureZone.attr("y2", function(d) {
+ return d.scrollbarState.scrollableAreaHeight;
+ });
+ if (gd._context.staticPlot) {
+ scrollbarGlyph.remove();
+ scrollbarCaptureZone.remove();
+ }
+ }
+ function renderColumnCellTree(gd, tableControlView, columnBlock, allColumnBlock) {
+ var columnCells = renderColumnCells(columnBlock);
+ var columnCell = renderColumnCell(columnCells);
+ supplyStylingValues(columnCell);
+ var cellRect = renderCellRect(columnCell);
+ sizeAndStyleRect(cellRect);
+ var cellTextHolder = renderCellTextHolder(columnCell);
+ var cellText = renderCellText(cellTextHolder);
+ setFont(cellText);
+ populateCellText(cellText, tableControlView, allColumnBlock, gd);
+ setCellHeightAndPositionY(columnCell);
+ }
+ function renderColumnCells(columnBlock) {
+ var columnCells = columnBlock.selectAll("." + c.cn.columnCells).data(gup.repeat, gup.keyFun);
+ columnCells.enter().append("g").classed(c.cn.columnCells, true);
+ columnCells.exit().remove();
+ return columnCells;
+ }
+ function renderColumnCell(columnCells) {
+ var columnCell = columnCells.selectAll("." + c.cn.columnCell).data(splitData.splitToCells, function(d) {
+ return d.keyWithinBlock;
+ });
+ columnCell.enter().append("g").classed(c.cn.columnCell, true);
+ columnCell.exit().remove();
+ return columnCell;
+ }
+ function renderCellRect(columnCell) {
+ var cellRect = columnCell.selectAll("." + c.cn.cellRect).data(gup.repeat, function(d) {
+ return d.keyWithinBlock;
+ });
+ cellRect.enter().append("rect").classed(c.cn.cellRect, true);
+ return cellRect;
+ }
+ function renderCellText(cellTextHolder) {
+ var cellText = cellTextHolder.selectAll("." + c.cn.cellText).data(gup.repeat, function(d) {
+ return d.keyWithinBlock;
+ });
+ cellText.enter().append("text").classed(c.cn.cellText, true).style("cursor", function() {
+ return "auto";
+ }).on("mousedown", function() {
+ d3.event.stopPropagation();
+ });
+ return cellText;
+ }
+ function renderCellTextHolder(columnCell) {
+ var cellTextHolder = columnCell.selectAll("." + c.cn.cellTextHolder).data(gup.repeat, function(d) {
+ return d.keyWithinBlock;
+ });
+ cellTextHolder.enter().append("g").classed(c.cn.cellTextHolder, true).style("shape-rendering", "geometricPrecision");
+ return cellTextHolder;
+ }
+ function supplyStylingValues(columnCell) {
+ columnCell.each(function(d, i) {
+ var spec = d.calcdata.cells.font;
+ var col = d.column.specIndex;
+ var font = {
+ size: gridPick(spec.size, col, i),
+ color: gridPick(spec.color, col, i),
+ family: gridPick(spec.family, col, i),
+ weight: gridPick(spec.weight, col, i),
+ style: gridPick(spec.style, col, i),
+ variant: gridPick(spec.variant, col, i),
+ textcase: gridPick(spec.textcase, col, i),
+ lineposition: gridPick(spec.lineposition, col, i),
+ shadow: gridPick(spec.shadow, col, i)
+ };
+ d.rowNumber = d.key;
+ d.align = gridPick(d.calcdata.cells.align, col, i);
+ d.cellBorderWidth = gridPick(d.calcdata.cells.line.width, col, i);
+ d.font = font;
+ });
+ }
+ function setFont(cellText) {
+ cellText.each(function(d) {
+ Drawing.font(d3.select(this), d.font);
+ });
+ }
+ function sizeAndStyleRect(cellRect) {
+ cellRect.attr("width", function(d) {
+ return d.column.columnWidth;
+ }).attr("stroke-width", function(d) {
+ return d.cellBorderWidth;
+ }).each(function(d) {
+ var atomicSelection = d3.select(this);
+ Color2.stroke(atomicSelection, gridPick(d.calcdata.cells.line.color, d.column.specIndex, d.rowNumber));
+ Color2.fill(atomicSelection, gridPick(d.calcdata.cells.fill.color, d.column.specIndex, d.rowNumber));
+ });
+ }
+ function populateCellText(cellText, tableControlView, allColumnBlock, gd) {
+ cellText.text(function(d) {
+ var col = d.column.specIndex;
+ var row = d.rowNumber;
+ var userSuppliedContent = d.value;
+ var stringSupplied = typeof userSuppliedContent === "string";
+ var hasBreaks = stringSupplied && userSuppliedContent.match(/
/i);
+ var userBrokenText = !stringSupplied || hasBreaks;
+ d.mayHaveMarkup = stringSupplied && userSuppliedContent.match(/[<&>]/);
+ var latex = isLatex(userSuppliedContent);
+ d.latex = latex;
+ var prefix = latex ? "" : gridPick(d.calcdata.cells.prefix, col, row) || "";
+ var suffix = latex ? "" : gridPick(d.calcdata.cells.suffix, col, row) || "";
+ var format = latex ? null : gridPick(d.calcdata.cells.format, col, row) || null;
+ var prefixSuffixedText = prefix + (format ? numberFormat(format)(d.value) : d.value) + suffix;
+ var hasWrapSplitCharacter;
+ d.wrappingNeeded = !d.wrapped && !userBrokenText && !latex && (hasWrapSplitCharacter = hasWrapCharacter(prefixSuffixedText));
+ d.cellHeightMayIncrease = hasBreaks || latex || d.mayHaveMarkup || (hasWrapSplitCharacter === void 0 ? hasWrapCharacter(prefixSuffixedText) : hasWrapSplitCharacter);
+ d.needsConvertToTspans = d.mayHaveMarkup || d.wrappingNeeded || d.latex;
+ var textToRender;
+ if (d.wrappingNeeded) {
+ var hrefPreservedText = c.wrapSplitCharacter === " " ? prefixSuffixedText.replace(/ pTop) {
+ pages.push(blockIndex);
+ }
+ pTop += rowsHeight2;
+ }
+ return pages;
+ }
+ function updateBlockYPosition(gd, cellsColumnBlock, tableControlView) {
+ var d = flatData(cellsColumnBlock)[0];
+ if (d === void 0) return;
+ var blocks = d.rowBlocks;
+ var calcdata = d.calcdata;
+ var bottom = firstRowAnchor(blocks, blocks.length);
+ var scrollHeight = d.calcdata.groupHeight - headerHeight(d);
+ var scrollY = calcdata.scrollY = Math.max(0, Math.min(bottom - scrollHeight, calcdata.scrollY));
+ var pages = findPagesAndCacheHeights(blocks, scrollY, scrollHeight);
+ if (pages.length === 1) {
+ if (pages[0] === blocks.length - 1) {
+ pages.unshift(pages[0] - 1);
+ } else {
+ pages.push(pages[0] + 1);
+ }
+ }
+ if (pages[0] % 2) {
+ pages.reverse();
+ }
+ cellsColumnBlock.each(function(d2, i) {
+ d2.page = pages[i];
+ d2.scrollY = scrollY;
+ });
+ cellsColumnBlock.attr("transform", function(d2) {
+ var yTranslate = firstRowAnchor(d2.rowBlocks, d2.page) - d2.scrollY;
+ return strTranslate(0, yTranslate);
+ });
+ if (gd) {
+ conditionalPanelRerender(gd, tableControlView, cellsColumnBlock, pages, d.prevPages, d, 0);
+ conditionalPanelRerender(gd, tableControlView, cellsColumnBlock, pages, d.prevPages, d, 1);
+ renderScrollbarKit(tableControlView, gd);
+ }
+ }
+ function makeDragRow(gd, allTableControlView, optionalMultiplier, optionalPosition) {
+ return function dragRow(eventD) {
+ var d = eventD.calcdata ? eventD.calcdata : eventD;
+ var tableControlView = allTableControlView.filter(function(dd) {
+ return d.key === dd.key;
+ });
+ var multiplier = optionalMultiplier || d.scrollbarState.dragMultiplier;
+ var initialScrollY = d.scrollY;
+ d.scrollY = optionalPosition === void 0 ? d.scrollY + multiplier * d3.event.dy : optionalPosition;
+ var cellsColumnBlock = tableControlView.selectAll("." + c.cn.yColumn).selectAll("." + c.cn.columnBlock).filter(cellsBlock);
+ updateBlockYPosition(gd, cellsColumnBlock, tableControlView);
+ return d.scrollY === initialScrollY;
+ };
+ }
+ function conditionalPanelRerender(gd, tableControlView, cellsColumnBlock, pages, prevPages, d, revolverIndex) {
+ var shouldComponentUpdate = pages[revolverIndex] !== prevPages[revolverIndex];
+ if (shouldComponentUpdate) {
+ clearTimeout(d.currentRepaint[revolverIndex]);
+ d.currentRepaint[revolverIndex] = setTimeout(function() {
+ var toRerender = cellsColumnBlock.filter(function(d2, i) {
+ return i === revolverIndex && pages[i] !== prevPages[i];
+ });
+ renderColumnCellTree(gd, tableControlView, toRerender, cellsColumnBlock);
+ prevPages[revolverIndex] = pages[revolverIndex];
+ });
+ }
+ }
+ function wrapTextMaker(columnBlock, element, tableControlView, gd) {
+ return function wrapText() {
+ var cellTextHolder = d3.select(element.parentNode);
+ cellTextHolder.each(function(d) {
+ var fragments = d.fragments;
+ cellTextHolder.selectAll("tspan.line").each(function(dd, i) {
+ fragments[i].width = this.getComputedTextLength();
+ });
+ var separatorLength = fragments[fragments.length - 1].width;
+ var rest = fragments.slice(0, -1);
+ var currentRow = [];
+ var currentAddition, currentAdditionLength;
+ var currentRowLength = 0;
+ var rowLengthLimit = d.column.columnWidth - 2 * c.cellPad;
+ d.value = "";
+ while (rest.length) {
+ currentAddition = rest.shift();
+ currentAdditionLength = currentAddition.width + separatorLength;
+ if (currentRowLength + currentAdditionLength > rowLengthLimit) {
+ d.value += currentRow.join(c.wrapSpacer) + c.lineBreaker;
+ currentRow = [];
+ currentRowLength = 0;
+ }
+ currentRow.push(currentAddition.text);
+ currentRowLength += currentAdditionLength;
+ }
+ if (currentRowLength) {
+ d.value += currentRow.join(c.wrapSpacer);
+ }
+ d.wrapped = true;
+ });
+ cellTextHolder.selectAll("tspan.line").remove();
+ populateCellText(cellTextHolder.select("." + c.cn.cellText), tableControlView, columnBlock, gd);
+ d3.select(element.parentNode.parentNode).call(setCellHeightAndPositionY);
+ };
+ }
+ function updateYPositionMaker(columnBlock, element, tableControlView, gd, d) {
+ return function updateYPosition() {
+ if (d.settledY) return;
+ var cellTextHolder = d3.select(element.parentNode);
+ var l = getBlock(d);
+ var rowIndex = d.key - l.firstRowIndex;
+ var declaredRowHeight = l.rows[rowIndex].rowHeight;
+ var requiredHeight = d.cellHeightMayIncrease ? element.parentNode.getBoundingClientRect().height + 2 * c.cellPad : declaredRowHeight;
+ var finalHeight = Math.max(requiredHeight, declaredRowHeight);
+ var increase = finalHeight - l.rows[rowIndex].rowHeight;
+ if (increase) {
+ l.rows[rowIndex].rowHeight = finalHeight;
+ columnBlock.selectAll("." + c.cn.columnCell).call(setCellHeightAndPositionY);
+ updateBlockYPosition(null, columnBlock.filter(cellsBlock), 0);
+ renderScrollbarKit(tableControlView, gd, true);
+ }
+ cellTextHolder.attr("transform", function() {
+ var element2 = this;
+ var columnCellElement = element2.parentNode;
+ var box = columnCellElement.getBoundingClientRect();
+ var rectBox = d3.select(element2.parentNode).select("." + c.cn.cellRect).node().getBoundingClientRect();
+ var currentTransform = element2.transform.baseVal.consolidate();
+ var yPosition = rectBox.top - box.top + (currentTransform ? currentTransform.matrix.f : c.cellPad);
+ return strTranslate(xPosition(d, d3.select(element2.parentNode).select("." + c.cn.cellTextHolder).node().getBoundingClientRect().width), yPosition);
+ });
+ d.settledY = true;
+ };
+ }
+ function xPosition(d, optionalWidth) {
+ switch (d.align) {
+ case "left":
+ return c.cellPad;
+ case "right":
+ return d.column.columnWidth - (optionalWidth || 0) - c.cellPad;
+ case "center":
+ return (d.column.columnWidth - (optionalWidth || 0)) / 2;
+ default:
+ return c.cellPad;
+ }
+ }
+ function setCellHeightAndPositionY(columnCell) {
+ columnCell.attr("transform", function(d) {
+ var headerHeight2 = d.rowBlocks[0].auxiliaryBlocks.reduce(function(p, n) {
+ return p + rowsHeight(n, Infinity);
+ }, 0);
+ var l = getBlock(d);
+ var rowAnchor = rowsHeight(l, d.key);
+ var yOffset = rowAnchor + headerHeight2;
+ return strTranslate(0, yOffset);
+ }).selectAll("." + c.cn.cellRect).attr("height", function(d) {
+ return getRow(getBlock(d), d.key).rowHeight;
+ });
+ }
+ function firstRowAnchor(blocks, page) {
+ var total = 0;
+ for (var i = page - 1; i >= 0; i--) {
+ total += allRowsHeight(blocks[i]);
+ }
+ return total;
+ }
+ function rowsHeight(rowBlock, key) {
+ var total = 0;
+ for (var i = 0; i < rowBlock.rows.length && rowBlock.rows[i].rowIndex < key; i++) {
+ total += rowBlock.rows[i].rowHeight;
+ }
+ return total;
+ }
+ function allRowsHeight(rowBlock) {
+ var cached = rowBlock.allRowsHeight;
+ if (cached !== void 0) {
+ return cached;
+ }
+ var total = 0;
+ for (var i = 0; i < rowBlock.rows.length; i++) {
+ total += rowBlock.rows[i].rowHeight;
+ }
+ rowBlock.allRowsHeight = total;
+ return total;
+ }
+ function getBlock(d) {
+ return d.rowBlocks[d.page];
+ }
+ function getRow(l, i) {
+ return l.rows[i - l.firstRowIndex];
+ }
+ }
+ });
+
+ // src/traces/table/base_plot.js
+ var require_base_plot11 = __commonJS({
+ "src/traces/table/base_plot.js"(exports) {
+ "use strict";
+ var getModuleCalcData = require_get_data().getModuleCalcData;
+ var tablePlot = require_plot31();
+ var TABLE = "table";
+ exports.name = TABLE;
+ exports.plot = function(gd) {
+ var calcData = getModuleCalcData(gd.calcdata, TABLE)[0];
+ if (calcData.length) tablePlot(gd, calcData);
+ };
+ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
+ var hadTable = oldFullLayout._has && oldFullLayout._has(TABLE);
+ var hasTable = newFullLayout._has && newFullLayout._has(TABLE);
+ if (hadTable && !hasTable) {
+ oldFullLayout._paperdiv.selectAll(".table").remove();
+ }
+ };
+ }
+ });
+
+ // src/traces/table/index.js
+ var require_table = __commonJS({
+ "src/traces/table/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes62(),
+ supplyDefaults: require_defaults58(),
+ calc: require_calc37(),
+ plot: require_plot31(),
+ moduleType: "trace",
+ name: "table",
+ basePlotModule: require_base_plot11(),
+ categories: ["noOpacity"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/table.js
+ var require_table2 = __commonJS({
+ "lib/table.js"(exports, module) {
+ "use strict";
+ module.exports = require_table();
+ }
+ });
+
+ // src/traces/carpet/axis_attributes.js
+ var require_axis_attributes2 = __commonJS({
+ "src/traces/carpet/axis_attributes.js"(exports, module) {
+ "use strict";
+ var fontAttrs = require_font_attributes();
+ var colorAttrs = require_attributes3();
+ var axesAttrs = require_layout_attributes4();
+ var descriptionWithDates = require_axis_format_attributes().descriptionWithDates;
+ var overrideAll = require_edit_types().overrideAll;
+ var dash = require_attributes4().dash;
+ var extendFlat = require_extend().extendFlat;
+ module.exports = {
+ color: {
+ valType: "color",
+ editType: "calc"
+ },
+ smoothing: {
+ valType: "number",
+ dflt: 1,
+ min: 0,
+ max: 1.3,
+ editType: "calc"
+ },
+ title: {
+ text: {
+ valType: "string",
+ dflt: "",
+ editType: "calc"
+ },
+ font: fontAttrs({
+ editType: "calc"
+ }),
+ // TODO how is this different than `title.standoff`
+ offset: {
+ valType: "number",
+ dflt: 10,
+ editType: "calc"
+ },
+ editType: "calc"
+ },
+ type: {
+ valType: "enumerated",
+ // '-' means we haven't yet run autotype or couldn't find any data
+ // it gets turned into linear in gd._fullLayout but not copied back
+ // to gd.data like the others are.
+ values: ["-", "linear", "date", "category"],
+ dflt: "-",
+ editType: "calc"
+ },
+ autotypenumbers: axesAttrs.autotypenumbers,
+ autorange: {
+ valType: "enumerated",
+ values: [true, false, "reversed"],
+ dflt: true,
+ editType: "calc"
+ },
+ rangemode: {
+ valType: "enumerated",
+ values: ["normal", "tozero", "nonnegative"],
+ dflt: "normal",
+ editType: "calc"
+ },
+ range: {
+ valType: "info_array",
+ editType: "calc",
+ items: [
+ { valType: "any", editType: "calc" },
+ { valType: "any", editType: "calc" }
+ ]
+ },
+ fixedrange: {
+ valType: "boolean",
+ dflt: false,
+ editType: "calc"
+ },
+ cheatertype: {
+ valType: "enumerated",
+ values: ["index", "value"],
+ dflt: "value",
+ editType: "calc"
+ },
+ tickmode: {
+ valType: "enumerated",
+ values: ["linear", "array"],
+ dflt: "array",
+ editType: "calc"
+ },
+ nticks: {
+ valType: "integer",
+ min: 0,
+ dflt: 0,
+ editType: "calc"
+ },
+ tickvals: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ ticktext: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ showticklabels: {
+ valType: "enumerated",
+ values: ["start", "end", "both", "none"],
+ dflt: "start",
+ editType: "calc"
+ },
+ labelalias: extendFlat({}, axesAttrs.labelalias, { editType: "calc" }),
+ tickfont: fontAttrs({
+ editType: "calc"
+ }),
+ tickangle: {
+ valType: "angle",
+ dflt: "auto",
+ editType: "calc"
+ },
+ tickprefix: {
+ valType: "string",
+ dflt: "",
+ editType: "calc"
+ },
+ showtickprefix: {
+ valType: "enumerated",
+ values: ["all", "first", "last", "none"],
+ dflt: "all",
+ editType: "calc"
+ },
+ ticksuffix: {
+ valType: "string",
+ dflt: "",
+ editType: "calc"
+ },
+ showticksuffix: {
+ valType: "enumerated",
+ values: ["all", "first", "last", "none"],
+ dflt: "all",
+ editType: "calc"
+ },
+ showexponent: {
+ valType: "enumerated",
+ values: ["all", "first", "last", "none"],
+ dflt: "all",
+ editType: "calc"
+ },
+ exponentformat: {
+ valType: "enumerated",
+ values: ["none", "e", "E", "power", "SI", "B"],
+ dflt: "B",
+ editType: "calc"
+ },
+ minexponent: {
+ valType: "number",
+ dflt: 3,
+ min: 0,
+ editType: "calc"
+ },
+ separatethousands: {
+ valType: "boolean",
+ dflt: false,
+ editType: "calc"
+ },
+ tickformat: {
+ valType: "string",
+ dflt: "",
+ editType: "calc",
+ description: descriptionWithDates("tick label")
+ },
+ tickformatstops: overrideAll(axesAttrs.tickformatstops, "calc", "from-root"),
+ categoryorder: {
+ valType: "enumerated",
+ values: [
+ "trace",
+ "category ascending",
+ "category descending",
+ "array"
+ /* , 'value ascending', 'value descending'*/
+ // value ascending / descending to be implemented later
+ ],
+ dflt: "trace",
+ editType: "calc"
+ },
+ categoryarray: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ labelpadding: {
+ valType: "integer",
+ dflt: 10,
+ editType: "calc"
+ },
+ labelprefix: {
+ valType: "string",
+ editType: "calc"
+ },
+ labelsuffix: {
+ valType: "string",
+ dflt: "",
+ editType: "calc"
+ },
+ // lines and grids
+ showline: {
+ valType: "boolean",
+ dflt: false,
+ editType: "calc"
+ },
+ linecolor: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine,
+ editType: "calc"
+ },
+ linewidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1,
+ editType: "calc"
+ },
+ gridcolor: {
+ valType: "color",
+ editType: "calc"
+ },
+ gridwidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1,
+ editType: "calc"
+ },
+ griddash: extendFlat({}, dash, { editType: "calc" }),
+ showgrid: {
+ valType: "boolean",
+ dflt: true,
+ editType: "calc"
+ },
+ minorgridcount: {
+ valType: "integer",
+ min: 0,
+ dflt: 0,
+ editType: "calc"
+ },
+ minorgridwidth: {
+ valType: "number",
+ min: 0,
+ dflt: 1,
+ editType: "calc"
+ },
+ minorgriddash: extendFlat({}, dash, { editType: "calc" }),
+ minorgridcolor: {
+ valType: "color",
+ dflt: colorAttrs.lightLine,
+ editType: "calc"
+ },
+ startline: {
+ valType: "boolean",
+ editType: "calc"
+ },
+ startlinecolor: {
+ valType: "color",
+ editType: "calc"
+ },
+ startlinewidth: {
+ valType: "number",
+ dflt: 1,
+ editType: "calc"
+ },
+ endline: {
+ valType: "boolean",
+ editType: "calc"
+ },
+ endlinewidth: {
+ valType: "number",
+ dflt: 1,
+ editType: "calc"
+ },
+ endlinecolor: {
+ valType: "color",
+ editType: "calc"
+ },
+ tick0: {
+ valType: "number",
+ min: 0,
+ dflt: 0,
+ editType: "calc"
+ },
+ dtick: {
+ valType: "number",
+ min: 0,
+ dflt: 1,
+ editType: "calc"
+ },
+ arraytick0: {
+ valType: "integer",
+ min: 0,
+ dflt: 0,
+ editType: "calc"
+ },
+ arraydtick: {
+ valType: "integer",
+ min: 1,
+ dflt: 1,
+ editType: "calc"
+ },
+ editType: "calc"
+ };
+ }
+ });
+
+ // src/traces/carpet/attributes.js
+ var require_attributes63 = __commonJS({
+ "src/traces/carpet/attributes.js"(exports, module) {
+ "use strict";
+ var fontAttrs = require_font_attributes();
+ var axisAttrs = require_axis_attributes2();
+ var colorAttrs = require_attributes3();
+ var carpetFont = fontAttrs({
+ editType: "calc"
+ });
+ var zorder = require_attributes12().zorder;
+ carpetFont.family.dflt = '"Open Sans", verdana, arial, sans-serif';
+ carpetFont.size.dflt = 12;
+ carpetFont.color.dflt = colorAttrs.defaultLine;
+ module.exports = {
+ carpet: {
+ valType: "string",
+ editType: "calc"
+ },
+ x: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ y: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ a: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ a0: {
+ valType: "number",
+ dflt: 0,
+ editType: "calc"
+ },
+ da: {
+ valType: "number",
+ dflt: 1,
+ editType: "calc"
+ },
+ b: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ b0: {
+ valType: "number",
+ dflt: 0,
+ editType: "calc"
+ },
+ db: {
+ valType: "number",
+ dflt: 1,
+ editType: "calc"
+ },
+ cheaterslope: {
+ valType: "number",
+ dflt: 1,
+ editType: "calc"
+ },
+ aaxis: axisAttrs,
+ baxis: axisAttrs,
+ font: carpetFont,
+ color: {
+ valType: "color",
+ dflt: colorAttrs.defaultLine,
+ editType: "plot"
+ },
+ zorder
+ };
+ }
+ });
+
+ // src/traces/carpet/xy_defaults.js
+ var require_xy_defaults2 = __commonJS({
+ "src/traces/carpet/xy_defaults.js"(exports, module) {
+ "use strict";
+ var isArray1D = require_lib().isArray1D;
+ module.exports = function handleXYDefaults(traceIn, traceOut, coerce) {
+ var x = coerce("x");
+ var hasX = x && x.length;
+ var y = coerce("y");
+ var hasY = y && y.length;
+ if (!hasX && !hasY) return false;
+ traceOut._cheater = !x;
+ if ((!hasX || isArray1D(x)) && (!hasY || isArray1D(y))) {
+ var len = hasX ? x.length : Infinity;
+ if (hasY) len = Math.min(len, y.length);
+ if (traceOut.a && traceOut.a.length) len = Math.min(len, traceOut.a.length);
+ if (traceOut.b && traceOut.b.length) len = Math.min(len, traceOut.b.length);
+ traceOut._length = len;
+ } else traceOut._length = null;
+ return true;
+ };
+ }
+ });
+
+ // src/traces/carpet/axis_defaults.js
+ var require_axis_defaults3 = __commonJS({
+ "src/traces/carpet/axis_defaults.js"(exports, module) {
+ "use strict";
+ var carpetAttrs = require_attributes63();
+ var addOpacity = require_color().addOpacity;
+ var Registry = require_registry();
+ var Lib = require_lib();
+ var handleTickValueDefaults = require_tick_value_defaults();
+ var handleTickLabelDefaults = require_tick_label_defaults();
+ var handlePrefixSuffixDefaults = require_prefix_suffix_defaults();
+ var handleCategoryOrderDefaults = require_category_order_defaults();
+ var setConvert = require_set_convert();
+ var autoType = require_axis_autotype();
+ module.exports = function handleAxisDefaults(containerIn, containerOut, options) {
+ var letter = options.letter;
+ var font = options.font || {};
+ var attributes = carpetAttrs[letter + "axis"];
+ function coerce(attr, dflt) {
+ return Lib.coerce(containerIn, containerOut, attributes, attr, dflt);
+ }
+ function coerce2(attr, dflt) {
+ return Lib.coerce2(containerIn, containerOut, attributes, attr, dflt);
+ }
+ if (options.name) {
+ containerOut._name = options.name;
+ containerOut._id = options.name;
+ }
+ coerce("autotypenumbers", options.autotypenumbersDflt);
+ var axType = coerce("type");
+ if (axType === "-") {
+ if (options.data) setAutoType(containerOut, options.data);
+ if (containerOut.type === "-") {
+ containerOut.type = "linear";
+ } else {
+ axType = containerIn.type = containerOut.type;
+ }
+ }
+ coerce("smoothing");
+ coerce("cheatertype");
+ coerce("showticklabels");
+ coerce("labelprefix", letter + " = ");
+ coerce("labelsuffix");
+ coerce("showtickprefix");
+ coerce("showticksuffix");
+ coerce("separatethousands");
+ coerce("tickformat");
+ coerce("exponentformat");
+ coerce("minexponent");
+ coerce("showexponent");
+ coerce("categoryorder");
+ coerce("tickmode");
+ coerce("tickvals");
+ coerce("ticktext");
+ coerce("tick0");
+ coerce("dtick");
+ if (containerOut.tickmode === "array") {
+ coerce("arraytick0");
+ coerce("arraydtick");
+ }
+ coerce("labelpadding");
+ containerOut._hovertitle = letter;
+ if (axType === "date") {
+ var handleCalendarDefaults = Registry.getComponentMethod("calendars", "handleDefaults");
+ handleCalendarDefaults(containerIn, containerOut, "calendar", options.calendar);
+ }
+ setConvert(containerOut, options.fullLayout);
+ containerOut.c2p = Lib.identity;
+ var dfltColor = coerce("color", options.dfltColor);
+ var dfltFontColor = dfltColor === containerIn.color ? dfltColor : font.color;
+ var title = coerce("title.text");
+ if (title) {
+ Lib.coerceFont(coerce, "title.font", font, { overrideDflt: {
+ size: Lib.bigFont(font.size),
+ color: dfltFontColor
+ } });
+ coerce("title.offset");
+ }
+ coerce("tickangle");
+ var autoRange = coerce("autorange", !containerOut.isValidRange(containerIn.range));
+ if (autoRange) coerce("rangemode");
+ coerce("range");
+ containerOut.cleanRange();
+ coerce("fixedrange");
+ handleTickValueDefaults(containerIn, containerOut, coerce, axType);
+ handlePrefixSuffixDefaults(containerIn, containerOut, coerce, axType, options);
+ handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options);
+ handleCategoryOrderDefaults(containerIn, containerOut, coerce, {
+ data: options.data,
+ dataAttr: letter
+ });
+ var gridColor = coerce2("gridcolor", addOpacity(dfltColor, 0.3));
+ var gridWidth = coerce2("gridwidth");
+ var gridDash = coerce2("griddash");
+ var showGrid = coerce("showgrid");
+ if (!showGrid) {
+ delete containerOut.gridcolor;
+ delete containerOut.gridwidth;
+ delete containerOut.griddash;
+ }
+ var startLineColor = coerce2("startlinecolor", dfltColor);
+ var startLineWidth = coerce2("startlinewidth", gridWidth);
+ var showStartLine = coerce("startline", containerOut.showgrid || !!startLineColor || !!startLineWidth);
+ if (!showStartLine) {
+ delete containerOut.startlinecolor;
+ delete containerOut.startlinewidth;
+ }
+ var endLineColor = coerce2("endlinecolor", dfltColor);
+ var endLineWidth = coerce2("endlinewidth", gridWidth);
+ var showEndLine = coerce("endline", containerOut.showgrid || !!endLineColor || !!endLineWidth);
+ if (!showEndLine) {
+ delete containerOut.endlinecolor;
+ delete containerOut.endlinewidth;
+ }
+ if (!showGrid) {
+ delete containerOut.gridcolor;
+ delete containerOut.gridwidth;
+ delete containerOut.griddash;
+ } else {
+ coerce("minorgridcount");
+ coerce("minorgridwidth", gridWidth);
+ coerce("minorgriddash", gridDash);
+ coerce("minorgridcolor", addOpacity(gridColor, 0.06));
+ if (!containerOut.minorgridcount) {
+ delete containerOut.minorgridwidth;
+ delete containerOut.minorgriddash;
+ delete containerOut.minorgridcolor;
+ }
+ }
+ if (containerOut.showticklabels === "none") {
+ delete containerOut.tickfont;
+ delete containerOut.tickangle;
+ delete containerOut.showexponent;
+ delete containerOut.exponentformat;
+ delete containerOut.minexponent;
+ delete containerOut.tickformat;
+ delete containerOut.showticksuffix;
+ delete containerOut.showtickprefix;
+ }
+ if (!containerOut.showticksuffix) {
+ delete containerOut.ticksuffix;
+ }
+ if (!containerOut.showtickprefix) {
+ delete containerOut.tickprefix;
+ }
+ coerce("tickmode");
+ return containerOut;
+ };
+ function setAutoType(ax, data) {
+ if (ax.type !== "-") return;
+ var id = ax._id;
+ var axLetter = id.charAt(0);
+ var calAttr = axLetter + "calendar";
+ var calendar = ax[calAttr];
+ ax.type = autoType(data, calendar, {
+ autotypenumbers: ax.autotypenumbers
+ });
+ }
+ }
+ });
+
+ // src/traces/carpet/ab_defaults.js
+ var require_ab_defaults = __commonJS({
+ "src/traces/carpet/ab_defaults.js"(exports, module) {
+ "use strict";
+ var handleAxisDefaults = require_axis_defaults3();
+ var Template = require_plot_template();
+ module.exports = function handleABDefaults(traceIn, traceOut, fullLayout, coerce, dfltColor) {
+ var a = coerce("a");
+ if (!a) {
+ coerce("da");
+ coerce("a0");
+ }
+ var b = coerce("b");
+ if (!b) {
+ coerce("db");
+ coerce("b0");
+ }
+ mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor);
+ };
+ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) {
+ var axesList = ["aaxis", "baxis"];
+ axesList.forEach(function(axName) {
+ var axLetter = axName.charAt(0);
+ var axIn = traceIn[axName] || {};
+ var axOut = Template.newContainer(traceOut, axName);
+ var defaultOptions = {
+ noAutotickangles: true,
+ noTicklabelshift: true,
+ noTicklabelstandoff: true,
+ noTicklabelstep: true,
+ tickfont: "x",
+ id: axLetter + "axis",
+ letter: axLetter,
+ font: traceOut.font,
+ name: axName,
+ data: traceIn[axLetter],
+ calendar: traceOut.calendar,
+ dfltColor,
+ bgColor: fullLayout.paper_bgcolor,
+ autotypenumbersDflt: fullLayout.autotypenumbers,
+ fullLayout
+ };
+ handleAxisDefaults(axIn, axOut, defaultOptions);
+ axOut._categories = axOut._categories || [];
+ if (!traceIn[axName] && axIn.type !== "-") {
+ traceIn[axName] = { type: axIn.type };
+ }
+ });
+ }
+ }
+ });
+
+ // src/traces/carpet/defaults.js
+ var require_defaults59 = __commonJS({
+ "src/traces/carpet/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var handleXYDefaults = require_xy_defaults2();
+ var handleABDefaults = require_ab_defaults();
+ var attributes = require_attributes63();
+ var colorAttrs = require_attributes3();
+ module.exports = function supplyDefaults(traceIn, traceOut, dfltColor, fullLayout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ traceOut._clipPathId = "clip" + traceOut.uid + "carpet";
+ var defaultColor = coerce("color", colorAttrs.defaultLine);
+ Lib.coerceFont(coerce, "font", fullLayout.font);
+ coerce("carpet");
+ handleABDefaults(traceIn, traceOut, fullLayout, coerce, defaultColor);
+ if (!traceOut.a || !traceOut.b) {
+ traceOut.visible = false;
+ return;
+ }
+ if (traceOut.a.length < 3) {
+ traceOut.aaxis.smoothing = 0;
+ }
+ if (traceOut.b.length < 3) {
+ traceOut.baxis.smoothing = 0;
+ }
+ var validData = handleXYDefaults(traceIn, traceOut, coerce);
+ if (!validData) {
+ traceOut.visible = false;
+ }
+ if (traceOut._cheater) {
+ coerce("cheaterslope");
+ }
+ coerce("zorder");
+ };
+ }
+ });
+
+ // src/traces/carpet/map_1d_array.js
+ var require_map_1d_array = __commonJS({
+ "src/traces/carpet/map_1d_array.js"(exports, module) {
+ "use strict";
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ module.exports = function mapArray(out, data, func) {
+ var i;
+ if (!isArrayOrTypedArray(out)) {
+ out = [];
+ } else if (out.length > data.length) {
+ out = out.slice(0, data.length);
+ }
+ for (i = 0; i < data.length; i++) {
+ out[i] = func(data[i]);
+ }
+ return out;
+ };
+ }
+ });
+
+ // src/traces/carpet/makepath.js
+ var require_makepath = __commonJS({
+ "src/traces/carpet/makepath.js"(exports, module) {
+ "use strict";
+ module.exports = function makePath(xp, yp, isBicubic) {
+ if (xp.length === 0) return "";
+ var i;
+ var path = [];
+ var stride = isBicubic ? 3 : 1;
+ for (i = 0; i < xp.length; i += stride) {
+ path.push(xp[i] + "," + yp[i]);
+ if (isBicubic && i < xp.length - stride) {
+ path.push("C");
+ path.push([
+ xp[i + 1] + "," + yp[i + 1],
+ xp[i + 2] + "," + yp[i + 2] + " "
+ ].join(" "));
+ }
+ }
+ return path.join(isBicubic ? "" : "L");
+ };
+ }
+ });
+
+ // src/traces/carpet/orient_text.js
+ var require_orient_text = __commonJS({
+ "src/traces/carpet/orient_text.js"(exports, module) {
+ "use strict";
+ module.exports = function orientText(trace, xaxis, yaxis, xy, dxy, refDxy) {
+ var dx = dxy[0] * trace.dpdx(xaxis);
+ var dy = dxy[1] * trace.dpdy(yaxis);
+ var flip = 1;
+ var offsetMultiplier = 1;
+ if (refDxy) {
+ var l1 = Math.sqrt(dxy[0] * dxy[0] + dxy[1] * dxy[1]);
+ var l2 = Math.sqrt(refDxy[0] * refDxy[0] + refDxy[1] * refDxy[1]);
+ var dot = (dxy[0] * refDxy[0] + dxy[1] * refDxy[1]) / l1 / l2;
+ offsetMultiplier = Math.max(0, dot);
+ }
+ var angle = Math.atan2(dy, dx) * 180 / Math.PI;
+ if (angle < -90) {
+ angle += 180;
+ flip = -flip;
+ } else if (angle > 90) {
+ angle -= 180;
+ flip = -flip;
+ }
+ return {
+ angle,
+ flip,
+ p: trace.c2p(xy, xaxis, yaxis),
+ offsetMultplier: offsetMultiplier
+ };
+ };
+ }
+ });
+
+ // src/traces/carpet/plot.js
+ var require_plot32 = __commonJS({
+ "src/traces/carpet/plot.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var Drawing = require_drawing();
+ var map1dArray = require_map_1d_array();
+ var makepath = require_makepath();
+ var orientText = require_orient_text();
+ var svgTextUtils = require_svg_text_utils();
+ var Lib = require_lib();
+ var strRotate = Lib.strRotate;
+ var strTranslate = Lib.strTranslate;
+ var alignmentConstants = require_alignment();
+ module.exports = function plot(gd, plotinfo, cdcarpet, carpetLayer) {
+ var isStatic = gd._context.staticPlot;
+ var xa = plotinfo.xaxis;
+ var ya = plotinfo.yaxis;
+ var fullLayout = gd._fullLayout;
+ var clipLayer = fullLayout._clips;
+ Lib.makeTraceGroups(carpetLayer, cdcarpet, "trace").each(function(cd) {
+ var axisLayer = d3.select(this);
+ var cd0 = cd[0];
+ var trace = cd0.trace;
+ var aax = trace.aaxis;
+ var bax = trace.baxis;
+ var minorLayer = Lib.ensureSingle(axisLayer, "g", "minorlayer");
+ var majorLayer = Lib.ensureSingle(axisLayer, "g", "majorlayer");
+ var boundaryLayer = Lib.ensureSingle(axisLayer, "g", "boundarylayer");
+ var labelLayer = Lib.ensureSingle(axisLayer, "g", "labellayer");
+ axisLayer.style("opacity", trace.opacity);
+ drawGridLines(xa, ya, majorLayer, aax, "a", aax._gridlines, true, isStatic);
+ drawGridLines(xa, ya, majorLayer, bax, "b", bax._gridlines, true, isStatic);
+ drawGridLines(xa, ya, minorLayer, aax, "a", aax._minorgridlines, true, isStatic);
+ drawGridLines(xa, ya, minorLayer, bax, "b", bax._minorgridlines, true, isStatic);
+ drawGridLines(xa, ya, boundaryLayer, aax, "a-boundary", aax._boundarylines, isStatic);
+ drawGridLines(xa, ya, boundaryLayer, bax, "b-boundary", bax._boundarylines, isStatic);
+ var labelOrientationA = drawAxisLabels(gd, xa, ya, trace, cd0, labelLayer, aax._labels, "a-label");
+ var labelOrientationB = drawAxisLabels(gd, xa, ya, trace, cd0, labelLayer, bax._labels, "b-label");
+ drawAxisTitles(gd, labelLayer, trace, cd0, xa, ya, labelOrientationA, labelOrientationB);
+ drawClipPath(trace, cd0, clipLayer, xa, ya);
+ });
+ };
+ function drawClipPath(trace, t, layer, xaxis, yaxis) {
+ var seg, xp, yp, i;
+ var clip = layer.select("#" + trace._clipPathId);
+ if (!clip.size()) {
+ clip = layer.append("clipPath").classed("carpetclip", true);
+ }
+ var path = Lib.ensureSingle(clip, "path", "carpetboundary");
+ var segments = t.clipsegments;
+ var segs = [];
+ for (i = 0; i < segments.length; i++) {
+ seg = segments[i];
+ xp = map1dArray([], seg.x, xaxis.c2p);
+ yp = map1dArray([], seg.y, yaxis.c2p);
+ segs.push(makepath(xp, yp, seg.bicubic));
+ }
+ var clipPathData = "M" + segs.join("L") + "Z";
+ clip.attr("id", trace._clipPathId);
+ path.attr("d", clipPathData);
+ }
+ function drawGridLines(xaxis, yaxis, layer, axis, axisLetter, gridlines, isStatic) {
+ var lineClass = "const-" + axisLetter + "-lines";
+ var gridJoin = layer.selectAll("." + lineClass).data(gridlines);
+ gridJoin.enter().append("path").classed(lineClass, true).style("vector-effect", isStatic ? "none" : "non-scaling-stroke");
+ gridJoin.each(function(d) {
+ var gridline = d;
+ var x = gridline.x;
+ var y = gridline.y;
+ var xp = map1dArray([], x, xaxis.c2p);
+ var yp = map1dArray([], y, yaxis.c2p);
+ var path = "M" + makepath(xp, yp, gridline.smoothing);
+ var el = d3.select(this);
+ el.attr("d", path).style("stroke-width", gridline.width).style("stroke", gridline.color).style("stroke-dasharray", Drawing.dashStyle(gridline.dash, gridline.width)).style("fill", "none");
+ });
+ gridJoin.exit().remove();
+ }
+ function drawAxisLabels(gd, xaxis, yaxis, trace, t, layer, labels, labelClass) {
+ var labelJoin = layer.selectAll("text." + labelClass).data(labels);
+ labelJoin.enter().append("text").classed(labelClass, true);
+ var maxExtent = 0;
+ var labelOrientation = {};
+ labelJoin.each(function(label, i) {
+ var orientation;
+ if (label.axis.tickangle === "auto") {
+ orientation = orientText(trace, xaxis, yaxis, label.xy, label.dxy);
+ } else {
+ var angle = (label.axis.tickangle + 180) * Math.PI / 180;
+ orientation = orientText(trace, xaxis, yaxis, label.xy, [Math.cos(angle), Math.sin(angle)]);
+ }
+ if (!i) {
+ labelOrientation = { angle: orientation.angle, flip: orientation.flip };
+ }
+ var direction = (label.endAnchor ? -1 : 1) * orientation.flip;
+ var labelEl = d3.select(this).attr({
+ "text-anchor": direction > 0 ? "start" : "end",
+ "data-notex": 1
+ }).call(Drawing.font, label.font).text(label.text).call(svgTextUtils.convertToTspans, gd);
+ var bbox = Drawing.bBox(this);
+ labelEl.attr(
+ "transform",
+ // Translate to the correct point:
+ strTranslate(orientation.p[0], orientation.p[1]) + // Rotate to line up with grid line tangent:
+ strRotate(orientation.angle) + // Adjust the baseline and indentation:
+ strTranslate(label.axis.labelpadding * direction, bbox.height * 0.3)
+ );
+ maxExtent = Math.max(maxExtent, bbox.width + label.axis.labelpadding);
+ });
+ labelJoin.exit().remove();
+ labelOrientation.maxExtent = maxExtent;
+ return labelOrientation;
+ }
+ function drawAxisTitles(gd, layer, trace, t, xa, ya, labelOrientationA, labelOrientationB) {
+ var a, b, xy, dxy;
+ var aMin = Lib.aggNums(Math.min, null, trace.a);
+ var aMax = Lib.aggNums(Math.max, null, trace.a);
+ var bMin = Lib.aggNums(Math.min, null, trace.b);
+ var bMax = Lib.aggNums(Math.max, null, trace.b);
+ a = 0.5 * (aMin + aMax);
+ b = bMin;
+ xy = trace.ab2xy(a, b, true);
+ dxy = trace.dxyda_rough(a, b);
+ if (labelOrientationA.angle === void 0) {
+ Lib.extendFlat(labelOrientationA, orientText(trace, xa, ya, xy, trace.dxydb_rough(a, b)));
+ }
+ drawAxisTitle(gd, layer, trace, t, xy, dxy, trace.aaxis, xa, ya, labelOrientationA, "a-title");
+ a = aMin;
+ b = 0.5 * (bMin + bMax);
+ xy = trace.ab2xy(a, b, true);
+ dxy = trace.dxydb_rough(a, b);
+ if (labelOrientationB.angle === void 0) {
+ Lib.extendFlat(labelOrientationB, orientText(trace, xa, ya, xy, trace.dxyda_rough(a, b)));
+ }
+ drawAxisTitle(gd, layer, trace, t, xy, dxy, trace.baxis, xa, ya, labelOrientationB, "b-title");
+ }
+ var lineSpacing = alignmentConstants.LINE_SPACING;
+ var midShift = (1 - alignmentConstants.MID_SHIFT) / lineSpacing + 1;
+ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientation, labelClass) {
+ var data = [];
+ if (axis.title.text) data.push(axis.title.text);
+ var titleJoin = layer.selectAll("text." + labelClass).data(data);
+ var offset = labelOrientation.maxExtent;
+ titleJoin.enter().append("text").classed(labelClass, true);
+ titleJoin.each(function() {
+ var orientation = orientText(trace, xa, ya, xy, dxy);
+ if (["start", "both"].indexOf(axis.showticklabels) === -1) {
+ offset = 0;
+ }
+ var titleSize = axis.title.font.size;
+ offset += titleSize + axis.title.offset;
+ var labelNorm = labelOrientation.angle + (labelOrientation.flip < 0 ? 180 : 0);
+ var angleDiff = (labelNorm - orientation.angle + 450) % 360;
+ var reverseTitle = angleDiff > 90 && angleDiff < 270;
+ var el = d3.select(this);
+ el.text(axis.title.text).call(svgTextUtils.convertToTspans, gd);
+ if (reverseTitle) {
+ offset = (-svgTextUtils.lineCount(el) + midShift) * lineSpacing * titleSize - offset;
+ }
+ el.attr(
+ "transform",
+ strTranslate(orientation.p[0], orientation.p[1]) + strRotate(orientation.angle) + strTranslate(0, offset)
+ ).attr("text-anchor", "middle").call(Drawing.font, axis.title.font);
+ });
+ titleJoin.exit().remove();
+ }
+ }
+ });
+
+ // src/traces/carpet/cheater_basis.js
+ var require_cheater_basis = __commonJS({
+ "src/traces/carpet/cheater_basis.js"(exports, module) {
+ "use strict";
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ module.exports = function(a, b, cheaterslope) {
+ var i, j, ascal, bscal, aval, bval;
+ var data = [];
+ var na = isArrayOrTypedArray(a) ? a.length : a;
+ var nb = isArrayOrTypedArray(b) ? b.length : b;
+ var adata = isArrayOrTypedArray(a) ? a : null;
+ var bdata = isArrayOrTypedArray(b) ? b : null;
+ if (adata) {
+ ascal = (adata.length - 1) / (adata[adata.length - 1] - adata[0]) / (na - 1);
+ }
+ if (bdata) {
+ bscal = (bdata.length - 1) / (bdata[bdata.length - 1] - bdata[0]) / (nb - 1);
+ }
+ var xval;
+ var xmin = Infinity;
+ var xmax = -Infinity;
+ for (j = 0; j < nb; j++) {
+ data[j] = [];
+ bval = bdata ? (bdata[j] - bdata[0]) * bscal : j / (nb - 1);
+ for (i = 0; i < na; i++) {
+ aval = adata ? (adata[i] - adata[0]) * ascal : i / (na - 1);
+ xval = aval - bval * cheaterslope;
+ xmin = Math.min(xval, xmin);
+ xmax = Math.max(xval, xmax);
+ data[j][i] = xval;
+ }
+ }
+ var slope = 1 / (xmax - xmin);
+ var offset = -xmin * slope;
+ for (j = 0; j < nb; j++) {
+ for (i = 0; i < na; i++) {
+ data[j][i] = slope * data[j][i] + offset;
+ }
+ }
+ return data;
+ };
+ }
+ });
+
+ // src/traces/carpet/array_minmax.js
+ var require_array_minmax = __commonJS({
+ "src/traces/carpet/array_minmax.js"(exports, module) {
+ "use strict";
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ module.exports = function(a) {
+ return minMax(a, 0);
+ };
+ function minMax(a, depth) {
+ if (!isArrayOrTypedArray(a) || depth >= 10) {
+ return null;
+ }
+ var min = Infinity;
+ var max = -Infinity;
+ var n = a.length;
+ for (var i = 0; i < n; i++) {
+ var datum = a[i];
+ if (isArrayOrTypedArray(datum)) {
+ var result = minMax(datum, depth + 1);
+ if (result) {
+ min = Math.min(result[0], min);
+ max = Math.max(result[1], max);
+ }
+ } else {
+ min = Math.min(datum, min);
+ max = Math.max(datum, max);
+ }
+ }
+ return [min, max];
+ }
+ }
+ });
+
+ // src/traces/carpet/calc_gridlines.js
+ var require_calc_gridlines = __commonJS({
+ "src/traces/carpet/calc_gridlines.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ var extendFlat = require_extend().extendFlat;
+ module.exports = function calcGridlines(trace, axisLetter, crossAxisLetter) {
+ var i, j, j0;
+ var eps, bounds, n1, n2, n, value, v;
+ var j1, v0, v1, d;
+ var data = trace["_" + axisLetter];
+ var axis = trace[axisLetter + "axis"];
+ var gridlines = axis._gridlines = [];
+ var minorgridlines = axis._minorgridlines = [];
+ var boundarylines = axis._boundarylines = [];
+ var crossData = trace["_" + crossAxisLetter];
+ var crossAxis = trace[crossAxisLetter + "axis"];
+ if (axis.tickmode === "array") {
+ axis.tickvals = data.slice();
+ }
+ var xcp = trace._xctrl;
+ var ycp = trace._yctrl;
+ var nea = xcp[0].length;
+ var neb = xcp.length;
+ var na = trace._a.length;
+ var nb = trace._b.length;
+ Axes.prepTicks(axis);
+ if (axis.tickmode === "array") delete axis.tickvals;
+ var stride = axis.smoothing ? 3 : 1;
+ function constructValueGridline(value2) {
+ var i2, j2, j02, tj, pxy, i0, ti, xy, dxydi0, dxydi1, dxydj0, dxydj1;
+ var xpoints = [];
+ var ypoints = [];
+ var ret = {};
+ if (axisLetter === "b") {
+ j2 = trace.b2j(value2);
+ j02 = Math.floor(Math.max(0, Math.min(nb - 2, j2)));
+ tj = j2 - j02;
+ ret.length = nb;
+ ret.crossLength = na;
+ ret.xy = function(i3) {
+ return trace.evalxy([], i3, j2);
+ };
+ ret.dxy = function(i02, ti2) {
+ return trace.dxydi([], i02, j02, ti2, tj);
+ };
+ for (i2 = 0; i2 < na; i2++) {
+ i0 = Math.min(na - 2, i2);
+ ti = i2 - i0;
+ xy = trace.evalxy([], i2, j2);
+ if (crossAxis.smoothing && i2 > 0) {
+ dxydi0 = trace.dxydi([], i2 - 1, j02, 0, tj);
+ xpoints.push(pxy[0] + dxydi0[0] / 3);
+ ypoints.push(pxy[1] + dxydi0[1] / 3);
+ dxydi1 = trace.dxydi([], i2 - 1, j02, 1, tj);
+ xpoints.push(xy[0] - dxydi1[0] / 3);
+ ypoints.push(xy[1] - dxydi1[1] / 3);
+ }
+ xpoints.push(xy[0]);
+ ypoints.push(xy[1]);
+ pxy = xy;
+ }
+ } else {
+ i2 = trace.a2i(value2);
+ i0 = Math.floor(Math.max(0, Math.min(na - 2, i2)));
+ ti = i2 - i0;
+ ret.length = na;
+ ret.crossLength = nb;
+ ret.xy = function(j3) {
+ return trace.evalxy([], i2, j3);
+ };
+ ret.dxy = function(j03, tj2) {
+ return trace.dxydj([], i0, j03, ti, tj2);
+ };
+ for (j2 = 0; j2 < nb; j2++) {
+ j02 = Math.min(nb - 2, j2);
+ tj = j2 - j02;
+ xy = trace.evalxy([], i2, j2);
+ if (crossAxis.smoothing && j2 > 0) {
+ dxydj0 = trace.dxydj([], i0, j2 - 1, ti, 0);
+ xpoints.push(pxy[0] + dxydj0[0] / 3);
+ ypoints.push(pxy[1] + dxydj0[1] / 3);
+ dxydj1 = trace.dxydj([], i0, j2 - 1, ti, 1);
+ xpoints.push(xy[0] - dxydj1[0] / 3);
+ ypoints.push(xy[1] - dxydj1[1] / 3);
+ }
+ xpoints.push(xy[0]);
+ ypoints.push(xy[1]);
+ pxy = xy;
+ }
+ }
+ ret.axisLetter = axisLetter;
+ ret.axis = axis;
+ ret.crossAxis = crossAxis;
+ ret.value = value2;
+ ret.constvar = crossAxisLetter;
+ ret.index = n;
+ ret.x = xpoints;
+ ret.y = ypoints;
+ ret.smoothing = crossAxis.smoothing;
+ return ret;
+ }
+ function constructArrayGridline(idx) {
+ var j2, i0, j02, ti, tj;
+ var xpoints = [];
+ var ypoints = [];
+ var ret = {};
+ ret.length = data.length;
+ ret.crossLength = crossData.length;
+ if (axisLetter === "b") {
+ j02 = Math.max(0, Math.min(nb - 2, idx));
+ tj = Math.min(1, Math.max(0, idx - j02));
+ ret.xy = function(i2) {
+ return trace.evalxy([], i2, idx);
+ };
+ ret.dxy = function(i02, ti2) {
+ return trace.dxydi([], i02, j02, ti2, tj);
+ };
+ for (j2 = 0; j2 < nea; j2++) {
+ xpoints[j2] = xcp[idx * stride][j2];
+ ypoints[j2] = ycp[idx * stride][j2];
+ }
+ } else {
+ i0 = Math.max(0, Math.min(na - 2, idx));
+ ti = Math.min(1, Math.max(0, idx - i0));
+ ret.xy = function(j3) {
+ return trace.evalxy([], idx, j3);
+ };
+ ret.dxy = function(j03, tj2) {
+ return trace.dxydj([], i0, j03, ti, tj2);
+ };
+ for (j2 = 0; j2 < neb; j2++) {
+ xpoints[j2] = xcp[j2][idx * stride];
+ ypoints[j2] = ycp[j2][idx * stride];
+ }
+ }
+ ret.axisLetter = axisLetter;
+ ret.axis = axis;
+ ret.crossAxis = crossAxis;
+ ret.value = data[idx];
+ ret.constvar = crossAxisLetter;
+ ret.index = idx;
+ ret.x = xpoints;
+ ret.y = ypoints;
+ ret.smoothing = crossAxis.smoothing;
+ return ret;
+ }
+ if (axis.tickmode === "array") {
+ eps = 5e-15;
+ bounds = [
+ Math.floor((data.length - 1 - axis.arraytick0) / axis.arraydtick * (1 + eps)),
+ Math.ceil(-axis.arraytick0 / axis.arraydtick / (1 + eps))
+ ].sort(function(a, b) {
+ return a - b;
+ });
+ n1 = bounds[0] - 1;
+ n2 = bounds[1] + 1;
+ for (n = n1; n < n2; n++) {
+ j = axis.arraytick0 + axis.arraydtick * n;
+ if (j < 0 || j > data.length - 1) continue;
+ gridlines.push(extendFlat(constructArrayGridline(j), {
+ color: axis.gridcolor,
+ width: axis.gridwidth,
+ dash: axis.griddash
+ }));
+ }
+ for (n = n1; n < n2; n++) {
+ j0 = axis.arraytick0 + axis.arraydtick * n;
+ j1 = Math.min(j0 + axis.arraydtick, data.length - 1);
+ if (j0 < 0 || j0 > data.length - 1) continue;
+ if (j1 < 0 || j1 > data.length - 1) continue;
+ v0 = data[j0];
+ v1 = data[j1];
+ for (i = 0; i < axis.minorgridcount; i++) {
+ d = j1 - j0;
+ if (d <= 0) continue;
+ v = v0 + (v1 - v0) * (i + 1) / (axis.minorgridcount + 1) * (axis.arraydtick / d);
+ if (v < data[0] || v > data[data.length - 1]) continue;
+ minorgridlines.push(extendFlat(constructValueGridline(v), {
+ color: axis.minorgridcolor,
+ width: axis.minorgridwidth,
+ dash: axis.minorgriddash
+ }));
+ }
+ }
+ if (axis.startline) {
+ boundarylines.push(extendFlat(constructArrayGridline(0), {
+ color: axis.startlinecolor,
+ width: axis.startlinewidth
+ }));
+ }
+ if (axis.endline) {
+ boundarylines.push(extendFlat(constructArrayGridline(data.length - 1), {
+ color: axis.endlinecolor,
+ width: axis.endlinewidth
+ }));
+ }
+ } else {
+ eps = 5e-15;
+ bounds = [
+ Math.floor((data[data.length - 1] - axis.tick0) / axis.dtick * (1 + eps)),
+ Math.ceil((data[0] - axis.tick0) / axis.dtick / (1 + eps))
+ ].sort(function(a, b) {
+ return a - b;
+ });
+ n1 = bounds[0];
+ n2 = bounds[1];
+ for (n = n1; n <= n2; n++) {
+ value = axis.tick0 + axis.dtick * n;
+ gridlines.push(extendFlat(constructValueGridline(value), {
+ color: axis.gridcolor,
+ width: axis.gridwidth,
+ dash: axis.griddash
+ }));
+ }
+ for (n = n1 - 1; n < n2 + 1; n++) {
+ value = axis.tick0 + axis.dtick * n;
+ for (i = 0; i < axis.minorgridcount; i++) {
+ v = value + axis.dtick * (i + 1) / (axis.minorgridcount + 1);
+ if (v < data[0] || v > data[data.length - 1]) continue;
+ minorgridlines.push(extendFlat(constructValueGridline(v), {
+ color: axis.minorgridcolor,
+ width: axis.minorgridwidth,
+ dash: axis.minorgriddash
+ }));
+ }
+ }
+ if (axis.startline) {
+ boundarylines.push(extendFlat(constructValueGridline(data[0]), {
+ color: axis.startlinecolor,
+ width: axis.startlinewidth
+ }));
+ }
+ if (axis.endline) {
+ boundarylines.push(extendFlat(constructValueGridline(data[data.length - 1]), {
+ color: axis.endlinecolor,
+ width: axis.endlinewidth
+ }));
+ }
+ }
+ };
+ }
+ });
+
+ // src/traces/carpet/calc_labels.js
+ var require_calc_labels = __commonJS({
+ "src/traces/carpet/calc_labels.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ var extendFlat = require_extend().extendFlat;
+ module.exports = function calcLabels(trace, axis) {
+ var i, tobj, prefix, suffix, gridline;
+ var labels = axis._labels = [];
+ var gridlines = axis._gridlines;
+ for (i = 0; i < gridlines.length; i++) {
+ gridline = gridlines[i];
+ if (["start", "both"].indexOf(axis.showticklabels) !== -1) {
+ tobj = Axes.tickText(axis, gridline.value);
+ extendFlat(tobj, {
+ prefix,
+ suffix,
+ endAnchor: true,
+ xy: gridline.xy(0),
+ dxy: gridline.dxy(0, 0),
+ axis: gridline.axis,
+ length: gridline.crossAxis.length,
+ font: gridline.axis.tickfont,
+ isFirst: i === 0,
+ isLast: i === gridlines.length - 1
+ });
+ labels.push(tobj);
+ }
+ if (["end", "both"].indexOf(axis.showticklabels) !== -1) {
+ tobj = Axes.tickText(axis, gridline.value);
+ extendFlat(tobj, {
+ endAnchor: false,
+ xy: gridline.xy(gridline.crossLength - 1),
+ dxy: gridline.dxy(gridline.crossLength - 2, 1),
+ axis: gridline.axis,
+ length: gridline.crossAxis.length,
+ font: gridline.axis.tickfont,
+ isFirst: i === 0,
+ isLast: i === gridlines.length - 1
+ });
+ labels.push(tobj);
+ }
+ }
+ };
+ }
+ });
+
+ // src/traces/carpet/calc_clippath.js
+ var require_calc_clippath = __commonJS({
+ "src/traces/carpet/calc_clippath.js"(exports, module) {
+ "use strict";
+ module.exports = function makeClipPath(xctrl, yctrl, aax, bax) {
+ var i, x, y;
+ var segments = [];
+ var asmoothing = !!aax.smoothing;
+ var bsmoothing = !!bax.smoothing;
+ var nea1 = xctrl[0].length - 1;
+ var neb1 = xctrl.length - 1;
+ for (i = 0, x = [], y = []; i <= nea1; i++) {
+ x[i] = xctrl[0][i];
+ y[i] = yctrl[0][i];
+ }
+ segments.push({ x, y, bicubic: asmoothing });
+ for (i = 0, x = [], y = []; i <= neb1; i++) {
+ x[i] = xctrl[i][nea1];
+ y[i] = yctrl[i][nea1];
+ }
+ segments.push({ x, y, bicubic: bsmoothing });
+ for (i = nea1, x = [], y = []; i >= 0; i--) {
+ x[nea1 - i] = xctrl[neb1][i];
+ y[nea1 - i] = yctrl[neb1][i];
+ }
+ segments.push({ x, y, bicubic: asmoothing });
+ for (i = neb1, x = [], y = []; i >= 0; i--) {
+ x[neb1 - i] = xctrl[i][0];
+ y[neb1 - i] = yctrl[i][0];
+ }
+ segments.push({ x, y, bicubic: bsmoothing });
+ return segments;
+ };
+ }
+ });
+
+ // src/traces/carpet/smooth_fill_2d_array.js
+ var require_smooth_fill_2d_array = __commonJS({
+ "src/traces/carpet/smooth_fill_2d_array.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ module.exports = function smoothFill2dArray(data, a, b) {
+ var i, j, k;
+ var ip = [];
+ var jp = [];
+ var ni = data[0].length;
+ var nj = data.length;
+ function avgSurrounding(i2, j2) {
+ var sum = 0;
+ var val;
+ var cnt = 0;
+ if (i2 > 0 && (val = data[j2][i2 - 1]) !== void 0) {
+ cnt++;
+ sum += val;
+ }
+ if (i2 < ni - 1 && (val = data[j2][i2 + 1]) !== void 0) {
+ cnt++;
+ sum += val;
+ }
+ if (j2 > 0 && (val = data[j2 - 1][i2]) !== void 0) {
+ cnt++;
+ sum += val;
+ }
+ if (j2 < nj - 1 && (val = data[j2 + 1][i2]) !== void 0) {
+ cnt++;
+ sum += val;
+ }
+ return sum / Math.max(1, cnt);
+ }
+ var dmax = 0;
+ for (i = 0; i < ni; i++) {
+ for (j = 0; j < nj; j++) {
+ if (data[j][i] === void 0) {
+ ip.push(i);
+ jp.push(j);
+ data[j][i] = avgSurrounding(i, j);
+ }
+ dmax = Math.max(dmax, Math.abs(data[j][i]));
+ }
+ }
+ if (!ip.length) return data;
+ var dxp, dxm, dap, dam, dbp, dbm, c, d, diff, reldiff, overrelaxation;
+ var tol = 1e-5;
+ var resid = 0;
+ var itermax = 100;
+ var iter = 0;
+ var n = ip.length;
+ do {
+ resid = 0;
+ for (k = 0; k < n; k++) {
+ i = ip[k];
+ j = jp[k];
+ var boundaryCnt = 0;
+ var newVal = 0;
+ var d0, d1, x0, x1, i0, j0;
+ if (i === 0) {
+ i0 = Math.min(ni - 1, 2);
+ x0 = a[i0];
+ x1 = a[1];
+ d0 = data[j][i0];
+ d1 = data[j][1];
+ newVal += d1 + (d1 - d0) * (a[0] - x1) / (x1 - x0);
+ boundaryCnt++;
+ } else if (i === ni - 1) {
+ i0 = Math.max(0, ni - 3);
+ x0 = a[i0];
+ x1 = a[ni - 2];
+ d0 = data[j][i0];
+ d1 = data[j][ni - 2];
+ newVal += d1 + (d1 - d0) * (a[ni - 1] - x1) / (x1 - x0);
+ boundaryCnt++;
+ }
+ if ((i === 0 || i === ni - 1) && (j > 0 && j < nj - 1)) {
+ dxp = b[j + 1] - b[j];
+ dxm = b[j] - b[j - 1];
+ newVal += (dxm * data[j + 1][i] + dxp * data[j - 1][i]) / (dxm + dxp);
+ boundaryCnt++;
+ }
+ if (j === 0) {
+ j0 = Math.min(nj - 1, 2);
+ x0 = b[j0];
+ x1 = b[1];
+ d0 = data[j0][i];
+ d1 = data[1][i];
+ newVal += d1 + (d1 - d0) * (b[0] - x1) / (x1 - x0);
+ boundaryCnt++;
+ } else if (j === nj - 1) {
+ j0 = Math.max(0, nj - 3);
+ x0 = b[j0];
+ x1 = b[nj - 2];
+ d0 = data[j0][i];
+ d1 = data[nj - 2][i];
+ newVal += d1 + (d1 - d0) * (b[nj - 1] - x1) / (x1 - x0);
+ boundaryCnt++;
+ }
+ if ((j === 0 || j === nj - 1) && (i > 0 && i < ni - 1)) {
+ dxp = a[i + 1] - a[i];
+ dxm = a[i] - a[i - 1];
+ newVal += (dxm * data[j][i + 1] + dxp * data[j][i - 1]) / (dxm + dxp);
+ boundaryCnt++;
+ }
+ if (!boundaryCnt) {
+ dap = a[i + 1] - a[i];
+ dam = a[i] - a[i - 1];
+ dbp = b[j + 1] - b[j];
+ dbm = b[j] - b[j - 1];
+ c = dap * dam * (dap + dam);
+ d = dbp * dbm * (dbp + dbm);
+ newVal = (c * (dbm * data[j + 1][i] + dbp * data[j - 1][i]) + d * (dam * data[j][i + 1] + dap * data[j][i - 1])) / (d * (dam + dap) + c * (dbm + dbp));
+ } else {
+ newVal /= boundaryCnt;
+ }
+ diff = newVal - data[j][i];
+ reldiff = diff / dmax;
+ resid += reldiff * reldiff;
+ overrelaxation = boundaryCnt ? 0 : 0.85;
+ data[j][i] += diff * (1 + overrelaxation);
+ }
+ resid = Math.sqrt(resid);
+ } while (iter++ < itermax && resid > tol);
+ Lib.log("Smoother converged to", resid, "after", iter, "iterations");
+ return data;
+ };
+ }
+ });
+
+ // src/traces/carpet/constants.js
+ var require_constants32 = __commonJS({
+ "src/traces/carpet/constants.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ RELATIVE_CULL_TOLERANCE: 1e-6
+ };
+ }
+ });
+
+ // src/traces/carpet/catmull_rom.js
+ var require_catmull_rom = __commonJS({
+ "src/traces/carpet/catmull_rom.js"(exports, module) {
+ "use strict";
+ var CatmullRomExp = 0.5;
+ module.exports = function makeControlPoints(p0, p1, p2, smoothness) {
+ var d1x = p0[0] - p1[0];
+ var d1y = p0[1] - p1[1];
+ var d2x = p2[0] - p1[0];
+ var d2y = p2[1] - p1[1];
+ var d1a = Math.pow(d1x * d1x + d1y * d1y, CatmullRomExp / 2);
+ var d2a = Math.pow(d2x * d2x + d2y * d2y, CatmullRomExp / 2);
+ var numx = (d2a * d2a * d1x - d1a * d1a * d2x) * smoothness;
+ var numy = (d2a * d2a * d1y - d1a * d1a * d2y) * smoothness;
+ var denom1 = d2a * (d1a + d2a) * 3;
+ var denom2 = d1a * (d1a + d2a) * 3;
+ return [[
+ p1[0] + (denom1 && numx / denom1),
+ p1[1] + (denom1 && numy / denom1)
+ ], [
+ p1[0] - (denom2 && numx / denom2),
+ p1[1] - (denom2 && numy / denom2)
+ ]];
+ };
+ }
+ });
+
+ // src/traces/carpet/compute_control_points.js
+ var require_compute_control_points = __commonJS({
+ "src/traces/carpet/compute_control_points.js"(exports, module) {
+ "use strict";
+ var makeControlPoints = require_catmull_rom();
+ var ensureArray = require_lib().ensureArray;
+ function inferCubicControlPoint(p0, p2, p3) {
+ var p2e0 = -0.5 * p3[0] + 1.5 * p2[0];
+ var p2e1 = -0.5 * p3[1] + 1.5 * p2[1];
+ return [
+ (2 * p2e0 + p0[0]) / 3,
+ (2 * p2e1 + p0[1]) / 3
+ ];
+ }
+ module.exports = function computeControlPoints(xe, ye, x, y, asmoothing, bsmoothing) {
+ var i, j, ie, je, xej, yej, xj, yj, cp, p1;
+ var na = x[0].length;
+ var nb = x.length;
+ var nea = asmoothing ? 3 * na - 2 : na;
+ var neb = bsmoothing ? 3 * nb - 2 : nb;
+ xe = ensureArray(xe, neb);
+ ye = ensureArray(ye, neb);
+ for (ie = 0; ie < neb; ie++) {
+ xe[ie] = ensureArray(xe[ie], nea);
+ ye[ie] = ensureArray(ye[ie], nea);
+ }
+ for (j = 0, je = 0; j < nb; j++, je += bsmoothing ? 3 : 1) {
+ xej = xe[je];
+ yej = ye[je];
+ xj = x[j];
+ yj = y[j];
+ for (i = 0, ie = 0; i < na; i++, ie += asmoothing ? 3 : 1) {
+ xej[ie] = xj[i];
+ yej[ie] = yj[i];
+ }
+ }
+ if (asmoothing) {
+ for (j = 0, je = 0; j < nb; j++, je += bsmoothing ? 3 : 1) {
+ for (i = 1, ie = 3; i < na - 1; i++, ie += 3) {
+ cp = makeControlPoints(
+ [x[j][i - 1], y[j][i - 1]],
+ [x[j][i], y[j][i]],
+ [x[j][i + 1], y[j][i + 1]],
+ asmoothing
+ );
+ xe[je][ie - 1] = cp[0][0];
+ ye[je][ie - 1] = cp[0][1];
+ xe[je][ie + 1] = cp[1][0];
+ ye[je][ie + 1] = cp[1][1];
+ }
+ p1 = inferCubicControlPoint(
+ [xe[je][0], ye[je][0]],
+ [xe[je][2], ye[je][2]],
+ [xe[je][3], ye[je][3]]
+ );
+ xe[je][1] = p1[0];
+ ye[je][1] = p1[1];
+ p1 = inferCubicControlPoint(
+ [xe[je][nea - 1], ye[je][nea - 1]],
+ [xe[je][nea - 3], ye[je][nea - 3]],
+ [xe[je][nea - 4], ye[je][nea - 4]]
+ );
+ xe[je][nea - 2] = p1[0];
+ ye[je][nea - 2] = p1[1];
+ }
+ }
+ if (bsmoothing) {
+ for (ie = 0; ie < nea; ie++) {
+ for (je = 3; je < neb - 3; je += 3) {
+ cp = makeControlPoints(
+ [xe[je - 3][ie], ye[je - 3][ie]],
+ [xe[je][ie], ye[je][ie]],
+ [xe[je + 3][ie], ye[je + 3][ie]],
+ bsmoothing
+ );
+ xe[je - 1][ie] = cp[0][0];
+ ye[je - 1][ie] = cp[0][1];
+ xe[je + 1][ie] = cp[1][0];
+ ye[je + 1][ie] = cp[1][1];
+ }
+ p1 = inferCubicControlPoint(
+ [xe[0][ie], ye[0][ie]],
+ [xe[2][ie], ye[2][ie]],
+ [xe[3][ie], ye[3][ie]]
+ );
+ xe[1][ie] = p1[0];
+ ye[1][ie] = p1[1];
+ p1 = inferCubicControlPoint(
+ [xe[neb - 1][ie], ye[neb - 1][ie]],
+ [xe[neb - 3][ie], ye[neb - 3][ie]],
+ [xe[neb - 4][ie], ye[neb - 4][ie]]
+ );
+ xe[neb - 2][ie] = p1[0];
+ ye[neb - 2][ie] = p1[1];
+ }
+ }
+ if (asmoothing && bsmoothing) {
+ for (je = 1; je < neb; je += (je + 1) % 3 === 0 ? 2 : 1) {
+ for (ie = 3; ie < nea - 3; ie += 3) {
+ cp = makeControlPoints(
+ [xe[je][ie - 3], ye[je][ie - 3]],
+ [xe[je][ie], ye[je][ie]],
+ [xe[je][ie + 3], ye[je][ie + 3]],
+ asmoothing
+ );
+ xe[je][ie - 1] = 0.5 * (xe[je][ie - 1] + cp[0][0]);
+ ye[je][ie - 1] = 0.5 * (ye[je][ie - 1] + cp[0][1]);
+ xe[je][ie + 1] = 0.5 * (xe[je][ie + 1] + cp[1][0]);
+ ye[je][ie + 1] = 0.5 * (ye[je][ie + 1] + cp[1][1]);
+ }
+ p1 = inferCubicControlPoint(
+ [xe[je][0], ye[je][0]],
+ [xe[je][2], ye[je][2]],
+ [xe[je][3], ye[je][3]]
+ );
+ xe[je][1] = 0.5 * (xe[je][1] + p1[0]);
+ ye[je][1] = 0.5 * (ye[je][1] + p1[1]);
+ p1 = inferCubicControlPoint(
+ [xe[je][nea - 1], ye[je][nea - 1]],
+ [xe[je][nea - 3], ye[je][nea - 3]],
+ [xe[je][nea - 4], ye[je][nea - 4]]
+ );
+ xe[je][nea - 2] = 0.5 * (xe[je][nea - 2] + p1[0]);
+ ye[je][nea - 2] = 0.5 * (ye[je][nea - 2] + p1[1]);
+ }
+ }
+ return [xe, ye];
+ };
+ }
+ });
+
+ // src/traces/carpet/create_spline_evaluator.js
+ var require_create_spline_evaluator = __commonJS({
+ "src/traces/carpet/create_spline_evaluator.js"(exports, module) {
+ "use strict";
+ module.exports = function(arrays, na, nb, asmoothing, bsmoothing) {
+ var imax = na - 2;
+ var jmax = nb - 2;
+ if (asmoothing && bsmoothing) {
+ return function(out, i, j) {
+ if (!out) out = [];
+ var f0, f1, f2, f3, ak, k;
+ var i0 = Math.max(0, Math.min(Math.floor(i), imax));
+ var j0 = Math.max(0, Math.min(Math.floor(j), jmax));
+ var u = Math.max(0, Math.min(1, i - i0));
+ var v = Math.max(0, Math.min(1, j - j0));
+ i0 *= 3;
+ j0 *= 3;
+ var u2 = u * u;
+ var u3 = u2 * u;
+ var ou = 1 - u;
+ var ou2 = ou * ou;
+ var ou3 = ou2 * ou;
+ var v2 = v * v;
+ var v3 = v2 * v;
+ var ov = 1 - v;
+ var ov2 = ov * ov;
+ var ov3 = ov2 * ov;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = ou3 * ak[j0][i0] + 3 * (ou2 * u * ak[j0][i0 + 1] + ou * u2 * ak[j0][i0 + 2]) + u3 * ak[j0][i0 + 3];
+ f1 = ou3 * ak[j0 + 1][i0] + 3 * (ou2 * u * ak[j0 + 1][i0 + 1] + ou * u2 * ak[j0 + 1][i0 + 2]) + u3 * ak[j0 + 1][i0 + 3];
+ f2 = ou3 * ak[j0 + 2][i0] + 3 * (ou2 * u * ak[j0 + 2][i0 + 1] + ou * u2 * ak[j0 + 2][i0 + 2]) + u3 * ak[j0 + 2][i0 + 3];
+ f3 = ou3 * ak[j0 + 3][i0] + 3 * (ou2 * u * ak[j0 + 3][i0 + 1] + ou * u2 * ak[j0 + 3][i0 + 2]) + u3 * ak[j0 + 3][i0 + 3];
+ out[k] = ov3 * f0 + 3 * (ov2 * v * f1 + ov * v2 * f2) + v3 * f3;
+ }
+ return out;
+ };
+ } else if (asmoothing) {
+ return function(out, i, j) {
+ if (!out) out = [];
+ var i0 = Math.max(0, Math.min(Math.floor(i), imax));
+ var j0 = Math.max(0, Math.min(Math.floor(j), jmax));
+ var u = Math.max(0, Math.min(1, i - i0));
+ var v = Math.max(0, Math.min(1, j - j0));
+ var f0, f1, f2, f3, k, ak;
+ i0 *= 3;
+ var u2 = u * u;
+ var u3 = u2 * u;
+ var ou = 1 - u;
+ var ou2 = ou * ou;
+ var ou3 = ou2 * ou;
+ var ov = 1 - v;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = ov * ak[j0][i0] + v * ak[j0 + 1][i0];
+ f1 = ov * ak[j0][i0 + 1] + v * ak[j0 + 1][i0 + 1];
+ f2 = ov * ak[j0][i0 + 2] + v * ak[j0 + 1][i0 + 1];
+ f3 = ov * ak[j0][i0 + 3] + v * ak[j0 + 1][i0 + 1];
+ out[k] = ou3 * f0 + 3 * (ou2 * u * f1 + ou * u2 * f2) + u3 * f3;
+ }
+ return out;
+ };
+ } else if (bsmoothing) {
+ return function(out, i, j) {
+ if (!out) out = [];
+ var i0 = Math.max(0, Math.min(Math.floor(i), imax));
+ var j0 = Math.max(0, Math.min(Math.floor(j), jmax));
+ var u = Math.max(0, Math.min(1, i - i0));
+ var v = Math.max(0, Math.min(1, j - j0));
+ var f0, f1, f2, f3, k, ak;
+ j0 *= 3;
+ var v2 = v * v;
+ var v3 = v2 * v;
+ var ov = 1 - v;
+ var ov2 = ov * ov;
+ var ov3 = ov2 * ov;
+ var ou = 1 - u;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = ou * ak[j0][i0] + u * ak[j0][i0 + 1];
+ f1 = ou * ak[j0 + 1][i0] + u * ak[j0 + 1][i0 + 1];
+ f2 = ou * ak[j0 + 2][i0] + u * ak[j0 + 2][i0 + 1];
+ f3 = ou * ak[j0 + 3][i0] + u * ak[j0 + 3][i0 + 1];
+ out[k] = ov3 * f0 + 3 * (ov2 * v * f1 + ov * v2 * f2) + v3 * f3;
+ }
+ return out;
+ };
+ } else {
+ return function(out, i, j) {
+ if (!out) out = [];
+ var i0 = Math.max(0, Math.min(Math.floor(i), imax));
+ var j0 = Math.max(0, Math.min(Math.floor(j), jmax));
+ var u = Math.max(0, Math.min(1, i - i0));
+ var v = Math.max(0, Math.min(1, j - j0));
+ var f0, f1, k, ak;
+ var ov = 1 - v;
+ var ou = 1 - u;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = ou * ak[j0][i0] + u * ak[j0][i0 + 1];
+ f1 = ou * ak[j0 + 1][i0] + u * ak[j0 + 1][i0 + 1];
+ out[k] = ov * f0 + v * f1;
+ }
+ return out;
+ };
+ }
+ };
+ }
+ });
+
+ // src/traces/carpet/create_i_derivative_evaluator.js
+ var require_create_i_derivative_evaluator = __commonJS({
+ "src/traces/carpet/create_i_derivative_evaluator.js"(exports, module) {
+ "use strict";
+ module.exports = function(arrays, asmoothing, bsmoothing) {
+ if (asmoothing && bsmoothing) {
+ return function(out, i0, j0, u, v) {
+ if (!out) out = [];
+ var f0, f1, f2, f3, ak, k;
+ i0 *= 3;
+ j0 *= 3;
+ var u2 = u * u;
+ var ou = 1 - u;
+ var ou2 = ou * ou;
+ var ouu2 = ou * u * 2;
+ var a = -3 * ou2;
+ var b = 3 * (ou2 - ouu2);
+ var c = 3 * (ouu2 - u2);
+ var d = 3 * u2;
+ var v2 = v * v;
+ var v3 = v2 * v;
+ var ov = 1 - v;
+ var ov2 = ov * ov;
+ var ov3 = ov2 * ov;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = a * ak[j0][i0] + b * ak[j0][i0 + 1] + c * ak[j0][i0 + 2] + d * ak[j0][i0 + 3];
+ f1 = a * ak[j0 + 1][i0] + b * ak[j0 + 1][i0 + 1] + c * ak[j0 + 1][i0 + 2] + d * ak[j0 + 1][i0 + 3];
+ f2 = a * ak[j0 + 2][i0] + b * ak[j0 + 2][i0 + 1] + c * ak[j0 + 2][i0 + 2] + d * ak[j0 + 2][i0 + 3];
+ f3 = a * ak[j0 + 3][i0] + b * ak[j0 + 3][i0 + 1] + c * ak[j0 + 3][i0 + 2] + d * ak[j0 + 3][i0 + 3];
+ out[k] = ov3 * f0 + 3 * (ov2 * v * f1 + ov * v2 * f2) + v3 * f3;
+ }
+ return out;
+ };
+ } else if (asmoothing) {
+ return function(out, i0, j0, u, v) {
+ if (!out) out = [];
+ var f0, f1, k, ak;
+ i0 *= 3;
+ var u2 = u * u;
+ var ou = 1 - u;
+ var ou2 = ou * ou;
+ var ouu2 = ou * u * 2;
+ var a = -3 * ou2;
+ var b = 3 * (ou2 - ouu2);
+ var c = 3 * (ouu2 - u2);
+ var d = 3 * u2;
+ var ov = 1 - v;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = a * ak[j0][i0] + b * ak[j0][i0 + 1] + c * ak[j0][i0 + 2] + d * ak[j0][i0 + 3];
+ f1 = a * ak[j0 + 1][i0] + b * ak[j0 + 1][i0 + 1] + c * ak[j0 + 1][i0 + 2] + d * ak[j0 + 1][i0 + 3];
+ out[k] = ov * f0 + v * f1;
+ }
+ return out;
+ };
+ } else if (bsmoothing) {
+ return function(out, i0, j0, u, v) {
+ if (!out) out = [];
+ var f0, f1, f2, f3, k, ak;
+ j0 *= 3;
+ var v2 = v * v;
+ var v3 = v2 * v;
+ var ov = 1 - v;
+ var ov2 = ov * ov;
+ var ov3 = ov2 * ov;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = ak[j0][i0 + 1] - ak[j0][i0];
+ f1 = ak[j0 + 1][i0 + 1] - ak[j0 + 1][i0];
+ f2 = ak[j0 + 2][i0 + 1] - ak[j0 + 2][i0];
+ f3 = ak[j0 + 3][i0 + 1] - ak[j0 + 3][i0];
+ out[k] = ov3 * f0 + 3 * (ov2 * v * f1 + ov * v2 * f2) + v3 * f3;
+ }
+ return out;
+ };
+ } else {
+ return function(out, i0, j0, u, v) {
+ if (!out) out = [];
+ var f0, f1, k, ak;
+ var ov = 1 - v;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = ak[j0][i0 + 1] - ak[j0][i0];
+ f1 = ak[j0 + 1][i0 + 1] - ak[j0 + 1][i0];
+ out[k] = ov * f0 + v * f1;
+ }
+ return out;
+ };
+ }
+ };
+ }
+ });
+
+ // src/traces/carpet/create_j_derivative_evaluator.js
+ var require_create_j_derivative_evaluator = __commonJS({
+ "src/traces/carpet/create_j_derivative_evaluator.js"(exports, module) {
+ "use strict";
+ module.exports = function(arrays, asmoothing, bsmoothing) {
+ if (asmoothing && bsmoothing) {
+ return function(out, i0, j0, u, v) {
+ if (!out) out = [];
+ var f0, f1, f2, f3, ak, k;
+ i0 *= 3;
+ j0 *= 3;
+ var u2 = u * u;
+ var u3 = u2 * u;
+ var ou = 1 - u;
+ var ou2 = ou * ou;
+ var ou3 = ou2 * ou;
+ var v2 = v * v;
+ var ov = 1 - v;
+ var ov2 = ov * ov;
+ var ovv2 = ov * v * 2;
+ var a = -3 * ov2;
+ var b = 3 * (ov2 - ovv2);
+ var c = 3 * (ovv2 - v2);
+ var d = 3 * v2;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = a * ak[j0][i0] + b * ak[j0 + 1][i0] + c * ak[j0 + 2][i0] + d * ak[j0 + 3][i0];
+ f1 = a * ak[j0][i0 + 1] + b * ak[j0 + 1][i0 + 1] + c * ak[j0 + 2][i0 + 1] + d * ak[j0 + 3][i0 + 1];
+ f2 = a * ak[j0][i0 + 2] + b * ak[j0 + 1][i0 + 2] + c * ak[j0 + 2][i0 + 2] + d * ak[j0 + 3][i0 + 2];
+ f3 = a * ak[j0][i0 + 3] + b * ak[j0 + 1][i0 + 3] + c * ak[j0 + 2][i0 + 3] + d * ak[j0 + 3][i0 + 3];
+ out[k] = ou3 * f0 + 3 * (ou2 * u * f1 + ou * u2 * f2) + u3 * f3;
+ }
+ return out;
+ };
+ } else if (asmoothing) {
+ return function(out, i0, j0, v, u) {
+ if (!out) out = [];
+ var f0, f1, f2, f3, k, ak;
+ i0 *= 3;
+ var u2 = u * u;
+ var u3 = u2 * u;
+ var ou = 1 - u;
+ var ou2 = ou * ou;
+ var ou3 = ou2 * ou;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = ak[j0 + 1][i0] - ak[j0][i0];
+ f1 = ak[j0 + 1][i0 + 1] - ak[j0][i0 + 1];
+ f2 = ak[j0 + 1][i0 + 2] - ak[j0][i0 + 2];
+ f3 = ak[j0 + 1][i0 + 3] - ak[j0][i0 + 3];
+ out[k] = ou3 * f0 + 3 * (ou2 * u * f1 + ou * u2 * f2) + u3 * f3;
+ }
+ return out;
+ };
+ } else if (bsmoothing) {
+ return function(out, i0, j0, u, v) {
+ if (!out) out = [];
+ var f0, f1, k, ak;
+ j0 *= 3;
+ var ou = 1 - u;
+ var v2 = v * v;
+ var ov = 1 - v;
+ var ov2 = ov * ov;
+ var ovv2 = ov * v * 2;
+ var a = -3 * ov2;
+ var b = 3 * (ov2 - ovv2);
+ var c = 3 * (ovv2 - v2);
+ var d = 3 * v2;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = a * ak[j0][i0] + b * ak[j0 + 1][i0] + c * ak[j0 + 2][i0] + d * ak[j0 + 3][i0];
+ f1 = a * ak[j0][i0 + 1] + b * ak[j0 + 1][i0 + 1] + c * ak[j0 + 2][i0 + 1] + d * ak[j0 + 3][i0 + 1];
+ out[k] = ou * f0 + u * f1;
+ }
+ return out;
+ };
+ } else {
+ return function(out, i0, j0, v, u) {
+ if (!out) out = [];
+ var f0, f1, k, ak;
+ var ov = 1 - v;
+ for (k = 0; k < arrays.length; k++) {
+ ak = arrays[k];
+ f0 = ak[j0 + 1][i0] - ak[j0][i0];
+ f1 = ak[j0 + 1][i0 + 1] - ak[j0][i0 + 1];
+ out[k] = ov * f0 + v * f1;
+ }
+ return out;
+ };
+ }
+ };
+ }
+ });
+
+ // src/traces/carpet/set_convert.js
+ var require_set_convert2 = __commonJS({
+ "src/traces/carpet/set_convert.js"(exports, module) {
+ "use strict";
+ var constants = require_constants32();
+ var search = require_search().findBin;
+ var computeControlPoints = require_compute_control_points();
+ var createSplineEvaluator = require_create_spline_evaluator();
+ var createIDerivativeEvaluator = require_create_i_derivative_evaluator();
+ var createJDerivativeEvaluator = require_create_j_derivative_evaluator();
+ module.exports = function setConvert(trace) {
+ var a = trace._a;
+ var b = trace._b;
+ var na = a.length;
+ var nb = b.length;
+ var aax = trace.aaxis;
+ var bax = trace.baxis;
+ var amin = a[0];
+ var amax = a[na - 1];
+ var bmin = b[0];
+ var bmax = b[nb - 1];
+ var arange = a[a.length - 1] - a[0];
+ var brange = b[b.length - 1] - b[0];
+ var atol = arange * constants.RELATIVE_CULL_TOLERANCE;
+ var btol = brange * constants.RELATIVE_CULL_TOLERANCE;
+ amin -= atol;
+ amax += atol;
+ bmin -= btol;
+ bmax += btol;
+ trace.isVisible = function(a2, b2) {
+ return a2 > amin && a2 < amax && b2 > bmin && b2 < bmax;
+ };
+ trace.isOccluded = function(a2, b2) {
+ return a2 < amin || a2 > amax || b2 < bmin || b2 > bmax;
+ };
+ trace.setScale = function() {
+ var x = trace._x;
+ var y = trace._y;
+ var result = computeControlPoints(trace._xctrl, trace._yctrl, x, y, aax.smoothing, bax.smoothing);
+ trace._xctrl = result[0];
+ trace._yctrl = result[1];
+ trace.evalxy = createSplineEvaluator([trace._xctrl, trace._yctrl], na, nb, aax.smoothing, bax.smoothing);
+ trace.dxydi = createIDerivativeEvaluator([trace._xctrl, trace._yctrl], aax.smoothing, bax.smoothing);
+ trace.dxydj = createJDerivativeEvaluator([trace._xctrl, trace._yctrl], aax.smoothing, bax.smoothing);
+ };
+ trace.i2a = function(i) {
+ var i0 = Math.max(0, Math.floor(i[0]), na - 2);
+ var ti = i[0] - i0;
+ return (1 - ti) * a[i0] + ti * a[i0 + 1];
+ };
+ trace.j2b = function(j) {
+ var j0 = Math.max(0, Math.floor(j[1]), na - 2);
+ var tj = j[1] - j0;
+ return (1 - tj) * b[j0] + tj * b[j0 + 1];
+ };
+ trace.ij2ab = function(ij) {
+ return [trace.i2a(ij[0]), trace.j2b(ij[1])];
+ };
+ trace.a2i = function(aval) {
+ var i0 = Math.max(0, Math.min(search(aval, a), na - 2));
+ var a0 = a[i0];
+ var a1 = a[i0 + 1];
+ return Math.max(0, Math.min(na - 1, i0 + (aval - a0) / (a1 - a0)));
+ };
+ trace.b2j = function(bval) {
+ var j0 = Math.max(0, Math.min(search(bval, b), nb - 2));
+ var b0 = b[j0];
+ var b1 = b[j0 + 1];
+ return Math.max(0, Math.min(nb - 1, j0 + (bval - b0) / (b1 - b0)));
+ };
+ trace.ab2ij = function(ab) {
+ return [trace.a2i(ab[0]), trace.b2j(ab[1])];
+ };
+ trace.i2c = function(i, j) {
+ return trace.evalxy([], i, j);
+ };
+ trace.ab2xy = function(aval, bval, extrapolate) {
+ if (!extrapolate && (aval < a[0] || aval > a[na - 1] | bval < b[0] || bval > b[nb - 1])) {
+ return [false, false];
+ }
+ var i = trace.a2i(aval);
+ var j = trace.b2j(bval);
+ var pt = trace.evalxy([], i, j);
+ if (extrapolate) {
+ var iex = 0;
+ var jex = 0;
+ var der = [];
+ var i0, ti, j0, tj;
+ if (aval < a[0]) {
+ i0 = 0;
+ ti = 0;
+ iex = (aval - a[0]) / (a[1] - a[0]);
+ } else if (aval > a[na - 1]) {
+ i0 = na - 2;
+ ti = 1;
+ iex = (aval - a[na - 1]) / (a[na - 1] - a[na - 2]);
+ } else {
+ i0 = Math.max(0, Math.min(na - 2, Math.floor(i)));
+ ti = i - i0;
+ }
+ if (bval < b[0]) {
+ j0 = 0;
+ tj = 0;
+ jex = (bval - b[0]) / (b[1] - b[0]);
+ } else if (bval > b[nb - 1]) {
+ j0 = nb - 2;
+ tj = 1;
+ jex = (bval - b[nb - 1]) / (b[nb - 1] - b[nb - 2]);
+ } else {
+ j0 = Math.max(0, Math.min(nb - 2, Math.floor(j)));
+ tj = j - j0;
+ }
+ if (iex) {
+ trace.dxydi(der, i0, j0, ti, tj);
+ pt[0] += der[0] * iex;
+ pt[1] += der[1] * iex;
+ }
+ if (jex) {
+ trace.dxydj(der, i0, j0, ti, tj);
+ pt[0] += der[0] * jex;
+ pt[1] += der[1] * jex;
+ }
+ }
+ return pt;
+ };
+ trace.c2p = function(xy, xa, ya) {
+ return [xa.c2p(xy[0]), ya.c2p(xy[1])];
+ };
+ trace.p2x = function(p, xa, ya) {
+ return [xa.p2c(p[0]), ya.p2c(p[1])];
+ };
+ trace.dadi = function(i) {
+ var i0 = Math.max(0, Math.min(a.length - 2, i));
+ return a[i0 + 1] - a[i0];
+ };
+ trace.dbdj = function(j) {
+ var j0 = Math.max(0, Math.min(b.length - 2, j));
+ return b[j0 + 1] - b[j0];
+ };
+ trace.dxyda = function(i0, j0, u, v) {
+ var dxydi = trace.dxydi(null, i0, j0, u, v);
+ var dadi = trace.dadi(i0, u);
+ return [dxydi[0] / dadi, dxydi[1] / dadi];
+ };
+ trace.dxydb = function(i0, j0, u, v) {
+ var dxydj = trace.dxydj(null, i0, j0, u, v);
+ var dbdj = trace.dbdj(j0, v);
+ return [dxydj[0] / dbdj, dxydj[1] / dbdj];
+ };
+ trace.dxyda_rough = function(a2, b2, reldiff) {
+ var h = arange * (reldiff || 0.1);
+ var plus = trace.ab2xy(a2 + h, b2, true);
+ var minus = trace.ab2xy(a2 - h, b2, true);
+ return [
+ (plus[0] - minus[0]) * 0.5 / h,
+ (plus[1] - minus[1]) * 0.5 / h
+ ];
+ };
+ trace.dxydb_rough = function(a2, b2, reldiff) {
+ var h = brange * (reldiff || 0.1);
+ var plus = trace.ab2xy(a2, b2 + h, true);
+ var minus = trace.ab2xy(a2, b2 - h, true);
+ return [
+ (plus[0] - minus[0]) * 0.5 / h,
+ (plus[1] - minus[1]) * 0.5 / h
+ ];
+ };
+ trace.dpdx = function(xa) {
+ return xa._m;
+ };
+ trace.dpdy = function(ya) {
+ return ya._m;
+ };
+ };
+ }
+ });
+
+ // src/traces/carpet/calc.js
+ var require_calc38 = __commonJS({
+ "src/traces/carpet/calc.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ var isArray1D = require_lib().isArray1D;
+ var cheaterBasis = require_cheater_basis();
+ var arrayMinmax = require_array_minmax();
+ var calcGridlines = require_calc_gridlines();
+ var calcLabels = require_calc_labels();
+ var calcClipPath = require_calc_clippath();
+ var clean2dArray = require_clean_2d_array();
+ var smoothFill2dArray = require_smooth_fill_2d_array();
+ var convertColumnData = require_convert_column_xyz();
+ var setConvert = require_set_convert2();
+ module.exports = function calc(gd, trace) {
+ var xa = Axes.getFromId(gd, trace.xaxis);
+ var ya = Axes.getFromId(gd, trace.yaxis);
+ var aax = trace.aaxis;
+ var bax = trace.baxis;
+ var x = trace.x;
+ var y = trace.y;
+ var cols = [];
+ if (x && isArray1D(x)) cols.push("x");
+ if (y && isArray1D(y)) cols.push("y");
+ if (cols.length) {
+ convertColumnData(trace, aax, bax, "a", "b", cols);
+ }
+ var a = trace._a = trace._a || trace.a;
+ var b = trace._b = trace._b || trace.b;
+ x = trace._x || trace.x;
+ y = trace._y || trace.y;
+ var t = {};
+ if (trace._cheater) {
+ var avals = aax.cheatertype === "index" ? a.length : a;
+ var bvals = bax.cheatertype === "index" ? b.length : b;
+ x = cheaterBasis(avals, bvals, trace.cheaterslope);
+ }
+ trace._x = x = clean2dArray(x);
+ trace._y = y = clean2dArray(y);
+ smoothFill2dArray(x, a, b);
+ smoothFill2dArray(y, a, b);
+ setConvert(trace);
+ trace.setScale();
+ var xrange = arrayMinmax(x);
+ var yrange = arrayMinmax(y);
+ var dx = 0.5 * (xrange[1] - xrange[0]);
+ var xc = 0.5 * (xrange[1] + xrange[0]);
+ var dy = 0.5 * (yrange[1] - yrange[0]);
+ var yc = 0.5 * (yrange[1] + yrange[0]);
+ var grow = 1.3;
+ xrange = [xc - dx * grow, xc + dx * grow];
+ yrange = [yc - dy * grow, yc + dy * grow];
+ trace._extremes[xa._id] = Axes.findExtremes(xa, xrange, { padded: true });
+ trace._extremes[ya._id] = Axes.findExtremes(ya, yrange, { padded: true });
+ calcGridlines(trace, "a", "b");
+ calcGridlines(trace, "b", "a");
+ calcLabels(trace, aax);
+ calcLabels(trace, bax);
+ t.clipsegments = calcClipPath(trace._xctrl, trace._yctrl, aax, bax);
+ t.x = x;
+ t.y = y;
+ t.a = a;
+ t.b = b;
+ return [t];
+ };
+ }
+ });
+
+ // src/traces/carpet/index.js
+ var require_carpet = __commonJS({
+ "src/traces/carpet/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes63(),
+ supplyDefaults: require_defaults59(),
+ plot: require_plot32(),
+ calc: require_calc38(),
+ animatable: true,
+ isContainer: true,
+ // so carpet traces get `calc` before other traces
+ moduleType: "trace",
+ name: "carpet",
+ basePlotModule: require_cartesian(),
+ categories: ["cartesian", "svg", "carpet", "carpetAxis", "notLegendIsolatable", "noMultiCategory", "noHover", "noSortingByValue"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/carpet.js
+ var require_carpet2 = __commonJS({
+ "lib/carpet.js"(exports, module) {
+ "use strict";
+ module.exports = require_carpet();
+ }
+ });
+
+ // src/traces/scattercarpet/attributes.js
+ var require_attributes64 = __commonJS({
+ "src/traces/scattercarpet/attributes.js"(exports, module) {
+ "use strict";
+ var makeFillcolorAttr = require_fillcolor_attribute();
+ var scatterAttrs = require_attributes12();
+ var baseAttrs = require_attributes2();
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var texttemplateAttrs = require_template_attributes().texttemplateAttrs;
+ var colorScaleAttrs = require_attributes8();
+ var extendFlat = require_extend().extendFlat;
+ var scatterMarkerAttrs = scatterAttrs.marker;
+ var scatterLineAttrs = scatterAttrs.line;
+ var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
+ module.exports = {
+ carpet: {
+ valType: "string",
+ editType: "calc"
+ },
+ a: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ b: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ mode: extendFlat({}, scatterAttrs.mode, { dflt: "markers" }),
+ text: extendFlat({}, scatterAttrs.text, {}),
+ texttemplate: texttemplateAttrs({ editType: "plot" }, {
+ keys: ["a", "b", "text"]
+ }),
+ hovertext: extendFlat({}, scatterAttrs.hovertext, {}),
+ line: {
+ color: scatterLineAttrs.color,
+ width: scatterLineAttrs.width,
+ dash: scatterLineAttrs.dash,
+ backoff: scatterLineAttrs.backoff,
+ shape: extendFlat(
+ {},
+ scatterLineAttrs.shape,
+ { values: ["linear", "spline"] }
+ ),
+ smoothing: scatterLineAttrs.smoothing,
+ editType: "calc"
+ },
+ connectgaps: scatterAttrs.connectgaps,
+ fill: extendFlat({}, scatterAttrs.fill, {
+ values: ["none", "toself", "tonext"],
+ dflt: "none"
+ }),
+ fillcolor: makeFillcolorAttr(),
+ marker: extendFlat(
+ {
+ symbol: scatterMarkerAttrs.symbol,
+ opacity: scatterMarkerAttrs.opacity,
+ maxdisplayed: scatterMarkerAttrs.maxdisplayed,
+ angle: scatterMarkerAttrs.angle,
+ angleref: scatterMarkerAttrs.angleref,
+ standoff: scatterMarkerAttrs.standoff,
+ size: scatterMarkerAttrs.size,
+ sizeref: scatterMarkerAttrs.sizeref,
+ sizemin: scatterMarkerAttrs.sizemin,
+ sizemode: scatterMarkerAttrs.sizemode,
+ line: extendFlat(
+ {
+ width: scatterMarkerLineAttrs.width,
+ editType: "calc"
+ },
+ colorScaleAttrs("marker.line")
+ ),
+ gradient: scatterMarkerAttrs.gradient,
+ editType: "calc"
+ },
+ colorScaleAttrs("marker")
+ ),
+ textfont: scatterAttrs.textfont,
+ textposition: scatterAttrs.textposition,
+ selected: scatterAttrs.selected,
+ unselected: scatterAttrs.unselected,
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ flags: ["a", "b", "text", "name"]
+ }),
+ hoveron: scatterAttrs.hoveron,
+ hovertemplate: hovertemplateAttrs(),
+ zorder: scatterAttrs.zorder
+ };
+ }
+ });
+
+ // src/traces/scattercarpet/defaults.js
+ var require_defaults60 = __commonJS({
+ "src/traces/scattercarpet/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var constants = require_constants8();
+ var subTypes = require_subtypes();
+ var handleMarkerDefaults = require_marker_defaults();
+ var handleLineDefaults = require_line_defaults();
+ var handleLineShapeDefaults = require_line_shape_defaults();
+ var handleTextDefaults = require_text_defaults();
+ var handleFillColorDefaults = require_fillcolor_defaults();
+ var attributes = require_attributes64();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ coerce("carpet");
+ traceOut.xaxis = "x";
+ traceOut.yaxis = "y";
+ var a = coerce("a");
+ var b = coerce("b");
+ var len = Math.min(a.length, b.length);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ traceOut._length = len;
+ coerce("text");
+ coerce("texttemplate");
+ coerce("hovertext");
+ var defaultMode = len < constants.PTS_LINESONLY ? "lines+markers" : "lines";
+ coerce("mode", defaultMode);
+ if (subTypes.hasMarkers(traceOut)) {
+ handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, { gradient: true });
+ }
+ if (subTypes.hasLines(traceOut)) {
+ handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce, { backoff: true });
+ handleLineShapeDefaults(traceIn, traceOut, coerce);
+ coerce("connectgaps");
+ }
+ if (subTypes.hasText(traceOut)) {
+ handleTextDefaults(traceIn, traceOut, layout, coerce);
+ }
+ var dfltHoverOn = [];
+ if (subTypes.hasMarkers(traceOut) || subTypes.hasText(traceOut)) {
+ coerce("marker.maxdisplayed");
+ dfltHoverOn.push("points");
+ }
+ coerce("fill");
+ if (traceOut.fill !== "none") {
+ handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
+ if (!subTypes.hasLines(traceOut)) handleLineShapeDefaults(traceIn, traceOut, coerce);
+ }
+ if (traceOut.fill === "tonext" || traceOut.fill === "toself") {
+ dfltHoverOn.push("fills");
+ }
+ var hoverOn = coerce("hoveron", dfltHoverOn.join("+") || "points");
+ if (hoverOn !== "fills") coerce("hovertemplate");
+ coerce("zorder");
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ }
+ });
+
+ // src/traces/scattercarpet/format_labels.js
+ var require_format_labels7 = __commonJS({
+ "src/traces/scattercarpet/format_labels.js"(exports, module) {
+ "use strict";
+ module.exports = function formatLabels(cdi, trace) {
+ var labels = {};
+ var carpet = trace._carpet;
+ var ij = carpet.ab2ij([cdi.a, cdi.b]);
+ var i0 = Math.floor(ij[0]);
+ var ti = ij[0] - i0;
+ var j0 = Math.floor(ij[1]);
+ var tj = ij[1] - j0;
+ var xy = carpet.evalxy([], i0, j0, ti, tj);
+ labels.yLabel = xy[1].toFixed(3);
+ return labels;
+ };
+ }
+ });
+
+ // src/traces/carpet/lookup_carpetid.js
+ var require_lookup_carpetid = __commonJS({
+ "src/traces/carpet/lookup_carpetid.js"(exports, module) {
+ "use strict";
+ module.exports = function(gd, trace) {
+ var n = gd._fullData.length;
+ var firstAxis;
+ for (var i = 0; i < n; i++) {
+ var maybeCarpet = gd._fullData[i];
+ if (maybeCarpet.index === trace.index) continue;
+ if (maybeCarpet.type === "carpet") {
+ if (!firstAxis) {
+ firstAxis = maybeCarpet;
+ }
+ if (maybeCarpet.carpet === trace.carpet) {
+ return maybeCarpet;
+ }
+ }
+ }
+ return firstAxis;
+ };
+ }
+ });
+
+ // src/traces/scattercarpet/calc.js
+ var require_calc39 = __commonJS({
+ "src/traces/scattercarpet/calc.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var calcColorscale = require_colorscale_calc();
+ var arraysToCalcdata = require_arrays_to_calcdata();
+ var calcSelection = require_calc_selection();
+ var calcMarkerSize = require_calc3().calcMarkerSize;
+ var lookupCarpet = require_lookup_carpetid();
+ module.exports = function calc(gd, trace) {
+ var carpet = trace._carpetTrace = lookupCarpet(gd, trace);
+ if (!carpet || !carpet.visible || carpet.visible === "legendonly") return;
+ var i;
+ trace.xaxis = carpet.xaxis;
+ trace.yaxis = carpet.yaxis;
+ var serieslen = trace._length;
+ var cd = new Array(serieslen);
+ var a, b;
+ var needsCull = false;
+ for (i = 0; i < serieslen; i++) {
+ a = trace.a[i];
+ b = trace.b[i];
+ if (isNumeric(a) && isNumeric(b)) {
+ var xy = carpet.ab2xy(+a, +b, true);
+ var visible = carpet.isVisible(+a, +b);
+ if (!visible) needsCull = true;
+ cd[i] = { x: xy[0], y: xy[1], a, b, vis: visible };
+ } else cd[i] = { x: false, y: false };
+ }
+ trace._needsCull = needsCull;
+ cd[0].carpet = carpet;
+ cd[0].trace = trace;
+ calcMarkerSize(trace, serieslen);
+ calcColorscale(gd, trace);
+ arraysToCalcdata(cd, trace);
+ calcSelection(cd, trace);
+ return cd;
+ };
+ }
+ });
+
+ // src/traces/scattercarpet/plot.js
+ var require_plot33 = __commonJS({
+ "src/traces/scattercarpet/plot.js"(exports, module) {
+ "use strict";
+ var scatterPlot = require_plot();
+ var Axes = require_axes();
+ var Drawing = require_drawing();
+ module.exports = function plot(gd, plotinfoproxy, data, layer) {
+ var i, trace, node;
+ var carpet = data[0][0].carpet;
+ var xaxis = Axes.getFromId(gd, carpet.xaxis || "x");
+ var yaxis = Axes.getFromId(gd, carpet.yaxis || "y");
+ var plotinfo = {
+ xaxis,
+ yaxis,
+ plot: plotinfoproxy.plot
+ };
+ for (i = 0; i < data.length; i++) {
+ trace = data[i][0].trace;
+ trace._xA = xaxis;
+ trace._yA = yaxis;
+ }
+ scatterPlot(gd, plotinfo, data, layer);
+ for (i = 0; i < data.length; i++) {
+ trace = data[i][0].trace;
+ node = layer.selectAll("g.trace" + trace.uid + " .js-line");
+ Drawing.setClipUrl(node, data[i][0].carpet._clipPathId, gd);
+ }
+ };
+ }
+ });
+
+ // src/traces/scattercarpet/hover.js
+ var require_hover22 = __commonJS({
+ "src/traces/scattercarpet/hover.js"(exports, module) {
+ "use strict";
+ var scatterHover = require_hover2();
+ var fillText = require_lib().fillText;
+ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
+ var scatterPointData = scatterHover(pointData, xval, yval, hovermode);
+ if (!scatterPointData || scatterPointData[0].index === false) return;
+ var newPointData = scatterPointData[0];
+ if (newPointData.index === void 0) {
+ var yFracUp = 1 - newPointData.y0 / pointData.ya._length;
+ var xLen = pointData.xa._length;
+ var xMin = xLen * yFracUp / 2;
+ var xMax = xLen - xMin;
+ newPointData.x0 = Math.max(Math.min(newPointData.x0, xMax), xMin);
+ newPointData.x1 = Math.max(Math.min(newPointData.x1, xMax), xMin);
+ return scatterPointData;
+ }
+ var cdi = newPointData.cd[newPointData.index];
+ newPointData.a = cdi.a;
+ newPointData.b = cdi.b;
+ newPointData.xLabelVal = void 0;
+ newPointData.yLabelVal = void 0;
+ var trace = newPointData.trace;
+ var carpet = trace._carpet;
+ var labels = trace._module.formatLabels(cdi, trace);
+ newPointData.yLabel = labels.yLabel;
+ delete newPointData.text;
+ var text = [];
+ function textPart(ax, val) {
+ var prefix;
+ if (ax.labelprefix && ax.labelprefix.length > 0) {
+ prefix = ax.labelprefix.replace(/ = $/, "");
+ } else {
+ prefix = ax._hovertitle;
+ }
+ text.push(prefix + ": " + val.toFixed(3) + ax.labelsuffix);
+ }
+ if (!trace.hovertemplate) {
+ var hoverinfo = cdi.hi || trace.hoverinfo;
+ var parts = hoverinfo.split("+");
+ if (parts.indexOf("all") !== -1) parts = ["a", "b", "text"];
+ if (parts.indexOf("a") !== -1) textPart(carpet.aaxis, cdi.a);
+ if (parts.indexOf("b") !== -1) textPart(carpet.baxis, cdi.b);
+ text.push("y: " + newPointData.yLabel);
+ if (parts.indexOf("text") !== -1) {
+ fillText(cdi, trace, text);
+ }
+ newPointData.extraText = text.join("
");
+ }
+ return scatterPointData;
+ };
+ }
+ });
+
+ // src/traces/scattercarpet/event_data.js
+ var require_event_data15 = __commonJS({
+ "src/traces/scattercarpet/event_data.js"(exports, module) {
+ "use strict";
+ module.exports = function eventData(out, pt, trace, cd, pointNumber) {
+ var cdi = cd[pointNumber];
+ out.a = cdi.a;
+ out.b = cdi.b;
+ out.y = cdi.y;
+ return out;
+ };
+ }
+ });
+
+ // src/traces/scattercarpet/index.js
+ var require_scattercarpet = __commonJS({
+ "src/traces/scattercarpet/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes64(),
+ supplyDefaults: require_defaults60(),
+ colorbar: require_marker_colorbar(),
+ formatLabels: require_format_labels7(),
+ calc: require_calc39(),
+ plot: require_plot33(),
+ style: require_style2().style,
+ styleOnSelect: require_style2().styleOnSelect,
+ hoverPoints: require_hover22(),
+ selectPoints: require_select2(),
+ eventData: require_event_data15(),
+ moduleType: "trace",
+ name: "scattercarpet",
+ basePlotModule: require_cartesian(),
+ categories: ["svg", "carpet", "symbols", "showLegend", "carpetDependent", "zoomScale"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/scattercarpet.js
+ var require_scattercarpet2 = __commonJS({
+ "lib/scattercarpet.js"(exports, module) {
+ "use strict";
+ module.exports = require_scattercarpet();
+ }
+ });
+
+ // src/traces/contourcarpet/attributes.js
+ var require_attributes65 = __commonJS({
+ "src/traces/contourcarpet/attributes.js"(exports, module) {
+ "use strict";
+ var heatmapAttrs = require_attributes25();
+ var contourAttrs = require_attributes28();
+ var colorScaleAttrs = require_attributes8();
+ var extendFlat = require_extend().extendFlat;
+ var contourContourAttrs = contourAttrs.contours;
+ module.exports = extendFlat(
+ {
+ carpet: {
+ valType: "string",
+ editType: "calc"
+ },
+ z: heatmapAttrs.z,
+ a: heatmapAttrs.x,
+ a0: heatmapAttrs.x0,
+ da: heatmapAttrs.dx,
+ b: heatmapAttrs.y,
+ b0: heatmapAttrs.y0,
+ db: heatmapAttrs.dy,
+ text: heatmapAttrs.text,
+ hovertext: heatmapAttrs.hovertext,
+ transpose: heatmapAttrs.transpose,
+ atype: heatmapAttrs.xtype,
+ btype: heatmapAttrs.ytype,
+ fillcolor: contourAttrs.fillcolor,
+ autocontour: contourAttrs.autocontour,
+ ncontours: contourAttrs.ncontours,
+ contours: {
+ type: contourContourAttrs.type,
+ start: contourContourAttrs.start,
+ end: contourContourAttrs.end,
+ size: contourContourAttrs.size,
+ coloring: {
+ // from contourAttrs.contours.coloring but no 'heatmap' option
+ valType: "enumerated",
+ values: ["fill", "lines", "none"],
+ dflt: "fill",
+ editType: "calc"
+ },
+ showlines: contourContourAttrs.showlines,
+ showlabels: contourContourAttrs.showlabels,
+ labelfont: contourContourAttrs.labelfont,
+ labelformat: contourContourAttrs.labelformat,
+ operation: contourContourAttrs.operation,
+ value: contourContourAttrs.value,
+ editType: "calc",
+ impliedEdits: { autocontour: false }
+ },
+ line: {
+ color: contourAttrs.line.color,
+ width: contourAttrs.line.width,
+ dash: contourAttrs.line.dash,
+ smoothing: contourAttrs.line.smoothing,
+ editType: "plot"
+ },
+ zorder: contourAttrs.zorder
+ },
+ colorScaleAttrs("", {
+ cLetter: "z",
+ autoColorDflt: false
+ })
+ );
+ }
+ });
+
+ // src/traces/contourcarpet/defaults.js
+ var require_defaults61 = __commonJS({
+ "src/traces/contourcarpet/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var handleXYZDefaults = require_xyz_defaults();
+ var attributes = require_attributes65();
+ var handleConstraintDefaults = require_constraint_defaults();
+ var handleContoursDefaults = require_contours_defaults();
+ var handleStyleDefaults = require_style_defaults3();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ function coerce2(attr) {
+ return Lib.coerce2(traceIn, traceOut, attributes, attr);
+ }
+ coerce("carpet");
+ if (traceIn.a && traceIn.b) {
+ var len = handleXYZDefaults(traceIn, traceOut, coerce, layout, "a", "b");
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("text");
+ var isConstraint = coerce("contours.type") === "constraint";
+ if (isConstraint) {
+ handleConstraintDefaults(traceIn, traceOut, coerce, layout, defaultColor, { hasHover: false });
+ } else {
+ handleContoursDefaults(traceIn, traceOut, coerce, coerce2);
+ handleStyleDefaults(traceIn, traceOut, coerce, layout, { hasHover: false });
+ }
+ } else {
+ traceOut._defaultColor = defaultColor;
+ traceOut._length = null;
+ }
+ coerce("zorder");
+ };
+ }
+ });
+
+ // src/traces/contourcarpet/calc.js
+ var require_calc40 = __commonJS({
+ "src/traces/contourcarpet/calc.js"(exports, module) {
+ "use strict";
+ var colorscaleCalc = require_calc();
+ var Lib = require_lib();
+ var convertColumnData = require_convert_column_xyz();
+ var clean2dArray = require_clean_2d_array();
+ var interp2d = require_interp2d();
+ var findEmpties = require_find_empties();
+ var makeBoundArray = require_make_bound_array();
+ var supplyDefaults = require_defaults61();
+ var lookupCarpet = require_lookup_carpetid();
+ var setContours = require_set_contours();
+ module.exports = function calc(gd, trace) {
+ var carpet = trace._carpetTrace = lookupCarpet(gd, trace);
+ if (!carpet || !carpet.visible || carpet.visible === "legendonly") return;
+ if (!trace.a || !trace.b) {
+ var carpetdata = gd.data[carpet.index];
+ var tracedata = gd.data[trace.index];
+ if (!tracedata.a) tracedata.a = carpetdata.a;
+ if (!tracedata.b) tracedata.b = carpetdata.b;
+ supplyDefaults(tracedata, trace, trace._defaultColor, gd._fullLayout);
+ }
+ var cd = heatmappishCalc(gd, trace);
+ setContours(trace, trace._z);
+ return cd;
+ };
+ function heatmappishCalc(gd, trace) {
+ var carpet = trace._carpetTrace;
+ var aax = carpet.aaxis;
+ var bax = carpet.baxis;
+ var a, a0, da, b, b0, db, z;
+ aax._minDtick = 0;
+ bax._minDtick = 0;
+ if (Lib.isArray1D(trace.z)) convertColumnData(trace, aax, bax, "a", "b", ["z"]);
+ a = trace._a = trace._a || trace.a;
+ b = trace._b = trace._b || trace.b;
+ a = a ? aax.makeCalcdata(trace, "_a") : [];
+ b = b ? bax.makeCalcdata(trace, "_b") : [];
+ a0 = trace.a0 || 0;
+ da = trace.da || 1;
+ b0 = trace.b0 || 0;
+ db = trace.db || 1;
+ z = trace._z = clean2dArray(trace._z || trace.z, trace.transpose);
+ trace._emptypoints = findEmpties(z);
+ interp2d(z, trace._emptypoints);
+ var xlen = Lib.maxRowLength(z);
+ var xIn = trace.xtype === "scaled" ? "" : a;
+ var xArray = makeBoundArray(trace, xIn, a0, da, xlen, aax);
+ var yIn = trace.ytype === "scaled" ? "" : b;
+ var yArray = makeBoundArray(trace, yIn, b0, db, z.length, bax);
+ var cd0 = {
+ a: xArray,
+ b: yArray,
+ z
+ };
+ if (trace.contours.type === "levels" && trace.contours.coloring !== "none") {
+ colorscaleCalc(gd, trace, {
+ vals: z,
+ containerStr: "",
+ cLetter: "z"
+ });
+ }
+ return [cd0];
+ }
+ }
+ });
+
+ // src/traces/carpet/axis_aligned_line.js
+ var require_axis_aligned_line = __commonJS({
+ "src/traces/carpet/axis_aligned_line.js"(exports, module) {
+ "use strict";
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ module.exports = function(carpet, carpetcd, a, b) {
+ var idx, tangent, tanIsoIdx, tanIsoPar, segment, refidx;
+ var p0, p1, v0, v1, start, end, range;
+ var axis = isArrayOrTypedArray(a) ? "a" : "b";
+ var ax = axis === "a" ? carpet.aaxis : carpet.baxis;
+ var smoothing = ax.smoothing;
+ var toIdx = axis === "a" ? carpet.a2i : carpet.b2j;
+ var pt = axis === "a" ? a : b;
+ var iso = axis === "a" ? b : a;
+ var n = axis === "a" ? carpetcd.a.length : carpetcd.b.length;
+ var m = axis === "a" ? carpetcd.b.length : carpetcd.a.length;
+ var isoIdx = Math.floor(axis === "a" ? carpet.b2j(iso) : carpet.a2i(iso));
+ var xy = axis === "a" ? function(value) {
+ return carpet.evalxy([], value, isoIdx);
+ } : function(value) {
+ return carpet.evalxy([], isoIdx, value);
+ };
+ if (smoothing) {
+ tanIsoIdx = Math.max(0, Math.min(m - 2, isoIdx));
+ tanIsoPar = isoIdx - tanIsoIdx;
+ tangent = axis === "a" ? function(i, ti) {
+ return carpet.dxydi([], i, tanIsoIdx, ti, tanIsoPar);
+ } : function(j, tj) {
+ return carpet.dxydj([], tanIsoIdx, j, tanIsoPar, tj);
+ };
+ }
+ var vstart = toIdx(pt[0]);
+ var vend = toIdx(pt[1]);
+ var dir = vstart < vend ? 1 : -1;
+ var tol = (vend - vstart) * 1e-8;
+ var dirfloor = dir > 0 ? Math.floor : Math.ceil;
+ var dirceil = dir > 0 ? Math.ceil : Math.floor;
+ var dirmin = dir > 0 ? Math.min : Math.max;
+ var dirmax = dir > 0 ? Math.max : Math.min;
+ var idx0 = dirfloor(vstart + tol);
+ var idx1 = dirceil(vend - tol);
+ p0 = xy(vstart);
+ var segments = [[p0]];
+ for (idx = idx0; idx * dir < idx1 * dir; idx += dir) {
+ segment = [];
+ start = dirmax(vstart, idx);
+ end = dirmin(vend, idx + dir);
+ range = end - start;
+ refidx = Math.max(0, Math.min(n - 2, Math.floor(0.5 * (start + end))));
+ p1 = xy(end);
+ if (smoothing) {
+ v0 = tangent(refidx, start - refidx);
+ v1 = tangent(refidx, end - refidx);
+ segment.push([
+ p0[0] + v0[0] / 3 * range,
+ p0[1] + v0[1] / 3 * range
+ ]);
+ segment.push([
+ p1[0] - v1[0] / 3 * range,
+ p1[1] - v1[1] / 3 * range
+ ]);
+ }
+ segment.push(p1);
+ segments.push(segment);
+ p0 = p1;
+ }
+ return segments;
+ };
+ }
+ });
+
+ // src/traces/contourcarpet/plot.js
+ var require_plot34 = __commonJS({
+ "src/traces/contourcarpet/plot.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var map1dArray = require_map_1d_array();
+ var makepath = require_makepath();
+ var Drawing = require_drawing();
+ var Lib = require_lib();
+ var makeCrossings = require_make_crossings();
+ var findAllPaths = require_find_all_paths();
+ var contourPlot = require_plot6();
+ var constants = require_constants16();
+ var convertToConstraints = require_convert_to_constraints();
+ var emptyPathinfo = require_empty_pathinfo();
+ var closeBoundaries = require_close_boundaries();
+ var lookupCarpet = require_lookup_carpetid();
+ var axisAlignedLine = require_axis_aligned_line();
+ module.exports = function plot(gd, plotinfo, cdcontours, contourcarpetLayer) {
+ var xa = plotinfo.xaxis;
+ var ya = plotinfo.yaxis;
+ Lib.makeTraceGroups(contourcarpetLayer, cdcontours, "contour").each(function(cd) {
+ var plotGroup = d3.select(this);
+ var cd0 = cd[0];
+ var trace = cd0.trace;
+ var carpet = trace._carpetTrace = lookupCarpet(gd, trace);
+ var carpetcd = gd.calcdata[carpet.index][0];
+ if (!carpet.visible || carpet.visible === "legendonly") return;
+ var a = cd0.a;
+ var b = cd0.b;
+ var contours = trace.contours;
+ var pathinfo = emptyPathinfo(contours, plotinfo, cd0);
+ var isConstraint = contours.type === "constraint";
+ var operation = contours._operation;
+ var coloring = isConstraint ? operation === "=" ? "lines" : "fill" : contours.coloring;
+ function ab2p(ab) {
+ var pt = carpet.ab2xy(ab[0], ab[1], true);
+ return [xa.c2p(pt[0]), ya.c2p(pt[1])];
+ }
+ var perimeter = [
+ [a[0], b[b.length - 1]],
+ [a[a.length - 1], b[b.length - 1]],
+ [a[a.length - 1], b[0]],
+ [a[0], b[0]]
+ ];
+ makeCrossings(pathinfo);
+ var atol = (a[a.length - 1] - a[0]) * 1e-8;
+ var btol = (b[b.length - 1] - b[0]) * 1e-8;
+ findAllPaths(pathinfo, atol, btol);
+ var fillPathinfo = pathinfo;
+ if (contours.type === "constraint") {
+ fillPathinfo = convertToConstraints(pathinfo, operation);
+ }
+ mapPathinfo(pathinfo, ab2p);
+ var seg, xp, yp, i;
+ var segs = [];
+ for (i = carpetcd.clipsegments.length - 1; i >= 0; i--) {
+ seg = carpetcd.clipsegments[i];
+ xp = map1dArray([], seg.x, xa.c2p);
+ yp = map1dArray([], seg.y, ya.c2p);
+ xp.reverse();
+ yp.reverse();
+ segs.push(makepath(xp, yp, seg.bicubic));
+ }
+ var boundaryPath = "M" + segs.join("L") + "Z";
+ makeBackground(plotGroup, carpetcd.clipsegments, xa, ya, isConstraint, coloring);
+ makeFills(trace, plotGroup, xa, ya, fillPathinfo, perimeter, ab2p, carpet, carpetcd, coloring, boundaryPath);
+ makeLinesAndLabels(plotGroup, pathinfo, gd, cd0, contours, plotinfo, carpet);
+ Drawing.setClipUrl(plotGroup, carpet._clipPathId, gd);
+ });
+ };
+ function mapPathinfo(pathinfo, map) {
+ var i, j, k, pi, pedgepaths, ppaths, pedgepath, ppath, path;
+ for (i = 0; i < pathinfo.length; i++) {
+ pi = pathinfo[i];
+ pedgepaths = pi.pedgepaths = [];
+ ppaths = pi.ppaths = [];
+ for (j = 0; j < pi.edgepaths.length; j++) {
+ path = pi.edgepaths[j];
+ pedgepath = [];
+ for (k = 0; k < path.length; k++) {
+ pedgepath[k] = map(path[k]);
+ }
+ pedgepaths.push(pedgepath);
+ }
+ for (j = 0; j < pi.paths.length; j++) {
+ path = pi.paths[j];
+ ppath = [];
+ for (k = 0; k < path.length; k++) {
+ ppath[k] = map(path[k]);
+ }
+ ppaths.push(ppath);
+ }
+ }
+ }
+ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, plotinfo, carpet) {
+ var isStatic = gd._context.staticPlot;
+ var lineContainer = Lib.ensureSingle(plotgroup, "g", "contourlines");
+ var showLines = contours.showlines !== false;
+ var showLabels = contours.showlabels;
+ var clipLinesForLabels = showLines && showLabels;
+ var linegroup = contourPlot.createLines(lineContainer, showLines || showLabels, pathinfo, isStatic);
+ var lineClip = contourPlot.createLineClip(lineContainer, clipLinesForLabels, gd, cd0.trace.uid);
+ var labelGroup = plotgroup.selectAll("g.contourlabels").data(showLabels ? [0] : []);
+ labelGroup.exit().remove();
+ labelGroup.enter().append("g").classed("contourlabels", true);
+ if (showLabels) {
+ var xa = plotinfo.xaxis;
+ var ya = plotinfo.yaxis;
+ var xLen = xa._length;
+ var yLen = ya._length;
+ var labelClipPathData = [[
+ [0, 0],
+ [xLen, 0],
+ [xLen, yLen],
+ [0, yLen]
+ ]];
+ var labelData = [];
+ Lib.clearLocationCache();
+ var contourFormat = contourPlot.labelFormatter(gd, cd0);
+ var dummyText = Drawing.tester.append("text").attr("data-notex", 1).call(Drawing.font, contours.labelfont);
+ var bounds = {
+ left: 0,
+ right: xLen,
+ center: xLen / 2,
+ top: 0,
+ bottom: yLen,
+ middle: yLen / 2
+ };
+ var plotDiagonal = Math.sqrt(xLen * xLen + yLen * yLen);
+ var normLength = constants.LABELDISTANCE * plotDiagonal / Math.max(1, pathinfo.length / constants.LABELINCREASE);
+ linegroup.each(function(d) {
+ var textOpts = contourPlot.calcTextOpts(d.level, contourFormat, dummyText, gd);
+ d3.select(this).selectAll("path").each(function(pathData) {
+ var path = this;
+ var pathBounds = Lib.getVisibleSegment(path, bounds, textOpts.height / 2);
+ if (!pathBounds) return;
+ constrainToCarpet(path, pathData, d, pathBounds, carpet, textOpts.height);
+ if (pathBounds.len < (textOpts.width + textOpts.height) * constants.LABELMIN) return;
+ var maxLabels = Math.min(
+ Math.ceil(pathBounds.len / normLength),
+ constants.LABELMAX
+ );
+ for (var i = 0; i < maxLabels; i++) {
+ var loc = contourPlot.findBestTextLocation(
+ path,
+ pathBounds,
+ textOpts,
+ labelData,
+ bounds
+ );
+ if (!loc) break;
+ contourPlot.addLabelData(loc, textOpts, labelData, labelClipPathData);
+ }
+ });
+ });
+ dummyText.remove();
+ contourPlot.drawLabels(
+ labelGroup,
+ labelData,
+ gd,
+ lineClip,
+ clipLinesForLabels ? labelClipPathData : null
+ );
+ }
+ if (showLabels && !showLines) linegroup.remove();
+ }
+ function constrainToCarpet(path, pathData, levelData, pathBounds, carpet, textHeight) {
+ var pathABData;
+ for (var i = 0; i < levelData.pedgepaths.length; i++) {
+ if (pathData === levelData.pedgepaths[i]) {
+ pathABData = levelData.edgepaths[i];
+ }
+ }
+ if (!pathABData) return;
+ var aMin = carpet.a[0];
+ var aMax = carpet.a[carpet.a.length - 1];
+ var bMin = carpet.b[0];
+ var bMax = carpet.b[carpet.b.length - 1];
+ function getOffset(abPt, pathVector) {
+ var offset = 0;
+ var edgeVector;
+ var dAB = 0.1;
+ if (Math.abs(abPt[0] - aMin) < dAB || Math.abs(abPt[0] - aMax) < dAB) {
+ edgeVector = normalizeVector(carpet.dxydb_rough(abPt[0], abPt[1], dAB));
+ offset = Math.max(offset, textHeight * vectorTan(pathVector, edgeVector) / 2);
+ }
+ if (Math.abs(abPt[1] - bMin) < dAB || Math.abs(abPt[1] - bMax) < dAB) {
+ edgeVector = normalizeVector(carpet.dxyda_rough(abPt[0], abPt[1], dAB));
+ offset = Math.max(offset, textHeight * vectorTan(pathVector, edgeVector) / 2);
+ }
+ return offset;
+ }
+ var startVector = getUnitVector(path, 0, 1);
+ var endVector = getUnitVector(path, pathBounds.total, pathBounds.total - 1);
+ var minStart = getOffset(pathABData[0], startVector);
+ var maxEnd = pathBounds.total - getOffset(pathABData[pathABData.length - 1], endVector);
+ if (pathBounds.min < minStart) pathBounds.min = minStart;
+ if (pathBounds.max > maxEnd) pathBounds.max = maxEnd;
+ pathBounds.len = pathBounds.max - pathBounds.min;
+ }
+ function getUnitVector(path, p0, p1) {
+ var pt0 = path.getPointAtLength(p0);
+ var pt1 = path.getPointAtLength(p1);
+ var dx = pt1.x - pt0.x;
+ var dy = pt1.y - pt0.y;
+ var len = Math.sqrt(dx * dx + dy * dy);
+ return [dx / len, dy / len];
+ }
+ function normalizeVector(v) {
+ var len = Math.sqrt(v[0] * v[0] + v[1] * v[1]);
+ return [v[0] / len, v[1] / len];
+ }
+ function vectorTan(v0, v1) {
+ var cos = Math.abs(v0[0] * v1[0] + v0[1] * v1[1]);
+ var sin = Math.sqrt(1 - cos * cos);
+ return sin / cos;
+ }
+ function makeBackground(plotgroup, clipsegments, xaxis, yaxis, isConstraint, coloring) {
+ var seg, xp, yp, i;
+ var bggroup = Lib.ensureSingle(plotgroup, "g", "contourbg");
+ var bgfill = bggroup.selectAll("path").data(coloring === "fill" && !isConstraint ? [0] : []);
+ bgfill.enter().append("path");
+ bgfill.exit().remove();
+ var segs = [];
+ for (i = 0; i < clipsegments.length; i++) {
+ seg = clipsegments[i];
+ xp = map1dArray([], seg.x, xaxis.c2p);
+ yp = map1dArray([], seg.y, yaxis.c2p);
+ segs.push(makepath(xp, yp, seg.bicubic));
+ }
+ bgfill.attr("d", "M" + segs.join("L") + "Z").style("stroke", "none");
+ }
+ function makeFills(trace, plotgroup, xa, ya, pathinfo, perimeter, ab2p, carpet, carpetcd, coloring, boundaryPath) {
+ var hasFills = coloring === "fill";
+ if (hasFills) {
+ closeBoundaries(pathinfo, trace.contours);
+ }
+ var fillgroup = Lib.ensureSingle(plotgroup, "g", "contourfill");
+ var fillitems = fillgroup.selectAll("path").data(hasFills ? pathinfo : []);
+ fillitems.enter().append("path");
+ fillitems.exit().remove();
+ fillitems.each(function(pi) {
+ var fullpath = (pi.prefixBoundary ? boundaryPath : "") + joinAllPaths(trace, pi, perimeter, ab2p, carpet, carpetcd, xa, ya);
+ if (!fullpath) {
+ d3.select(this).remove();
+ } else {
+ d3.select(this).attr("d", fullpath).style("stroke", "none");
+ }
+ });
+ }
+ function joinAllPaths(trace, pi, perimeter, ab2p, carpet, carpetcd, xa, ya) {
+ var i;
+ var fullpath = "";
+ var startsleft = pi.edgepaths.map(function(v, i2) {
+ return i2;
+ });
+ var newloop = true;
+ var endpt, newendpt, cnt, nexti, possiblei, addpath;
+ var atol = Math.abs(perimeter[0][0] - perimeter[2][0]) * 1e-4;
+ var btol = Math.abs(perimeter[0][1] - perimeter[2][1]) * 1e-4;
+ function istop(pt) {
+ return Math.abs(pt[1] - perimeter[0][1]) < btol;
+ }
+ function isbottom(pt) {
+ return Math.abs(pt[1] - perimeter[2][1]) < btol;
+ }
+ function isleft(pt) {
+ return Math.abs(pt[0] - perimeter[0][0]) < atol;
+ }
+ function isright(pt) {
+ return Math.abs(pt[0] - perimeter[2][0]) < atol;
+ }
+ function pathto(pt0, pt1) {
+ var i2, j, segments, axis;
+ var path = "";
+ if (istop(pt0) && !isright(pt0) || isbottom(pt0) && !isleft(pt0)) {
+ axis = carpet.aaxis;
+ segments = axisAlignedLine(carpet, carpetcd, [pt0[0], pt1[0]], 0.5 * (pt0[1] + pt1[1]));
+ } else {
+ axis = carpet.baxis;
+ segments = axisAlignedLine(carpet, carpetcd, 0.5 * (pt0[0] + pt1[0]), [pt0[1], pt1[1]]);
+ }
+ for (i2 = 1; i2 < segments.length; i2++) {
+ path += axis.smoothing ? "C" : "L";
+ for (j = 0; j < segments[i2].length; j++) {
+ var pt = segments[i2][j];
+ path += [xa.c2p(pt[0]), ya.c2p(pt[1])] + " ";
+ }
+ }
+ return path;
+ }
+ i = 0;
+ endpt = null;
+ while (startsleft.length) {
+ var startpt = pi.edgepaths[i][0];
+ if (endpt) {
+ fullpath += pathto(endpt, startpt);
+ }
+ addpath = Drawing.smoothopen(pi.edgepaths[i].map(ab2p), pi.smoothing);
+ fullpath += newloop ? addpath : addpath.replace(/^M/, "L");
+ startsleft.splice(startsleft.indexOf(i), 1);
+ endpt = pi.edgepaths[i][pi.edgepaths[i].length - 1];
+ nexti = -1;
+ for (cnt = 0; cnt < 4; cnt++) {
+ if (!endpt) {
+ Lib.log("Missing end?", i, pi);
+ break;
+ }
+ if (istop(endpt) && !isright(endpt)) {
+ newendpt = perimeter[1];
+ } else if (isleft(endpt)) {
+ newendpt = perimeter[0];
+ } else if (isbottom(endpt)) {
+ newendpt = perimeter[3];
+ } else if (isright(endpt)) {
+ newendpt = perimeter[2];
+ }
+ for (possiblei = 0; possiblei < pi.edgepaths.length; possiblei++) {
+ var ptNew = pi.edgepaths[possiblei][0];
+ if (Math.abs(endpt[0] - newendpt[0]) < atol) {
+ if (Math.abs(endpt[0] - ptNew[0]) < atol && (ptNew[1] - endpt[1]) * (newendpt[1] - ptNew[1]) >= 0) {
+ newendpt = ptNew;
+ nexti = possiblei;
+ }
+ } else if (Math.abs(endpt[1] - newendpt[1]) < btol) {
+ if (Math.abs(endpt[1] - ptNew[1]) < btol && (ptNew[0] - endpt[0]) * (newendpt[0] - ptNew[0]) >= 0) {
+ newendpt = ptNew;
+ nexti = possiblei;
+ }
+ } else {
+ Lib.log("endpt to newendpt is not vert. or horz.", endpt, newendpt, ptNew);
+ }
+ }
+ if (nexti >= 0) break;
+ fullpath += pathto(endpt, newendpt);
+ endpt = newendpt;
+ }
+ if (nexti === pi.edgepaths.length) {
+ Lib.log("unclosed perimeter path");
+ break;
+ }
+ i = nexti;
+ newloop = startsleft.indexOf(i) === -1;
+ if (newloop) {
+ i = startsleft[0];
+ fullpath += pathto(endpt, newendpt) + "Z";
+ endpt = null;
+ }
+ }
+ for (i = 0; i < pi.paths.length; i++) {
+ fullpath += Drawing.smoothclosed(pi.paths[i].map(ab2p), pi.smoothing);
+ }
+ return fullpath;
+ }
+ }
+ });
+
+ // src/traces/contourcarpet/index.js
+ var require_contourcarpet = __commonJS({
+ "src/traces/contourcarpet/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attributes: require_attributes65(),
+ supplyDefaults: require_defaults61(),
+ colorbar: require_colorbar3(),
+ calc: require_calc40(),
+ plot: require_plot34(),
+ style: require_style7(),
+ moduleType: "trace",
+ name: "contourcarpet",
+ basePlotModule: require_cartesian(),
+ categories: ["cartesian", "svg", "carpet", "contour", "symbols", "showLegend", "hasLines", "carpetDependent", "noHover", "noSortingByValue"],
+ meta: {}
+ };
+ }
+ });
+
+ // lib/contourcarpet.js
+ var require_contourcarpet2 = __commonJS({
+ "lib/contourcarpet.js"(exports, module) {
+ "use strict";
+ module.exports = require_contourcarpet();
+ }
+ });
+
+ // src/traces/ohlc/attributes.js
+ var require_attributes66 = __commonJS({
+ "src/traces/ohlc/attributes.js"(exports, module) {
+ "use strict";
+ var extendFlat = require_lib().extendFlat;
+ var scatterAttrs = require_attributes12();
+ var axisHoverFormat = require_axis_format_attributes().axisHoverFormat;
+ var dash = require_attributes4().dash;
+ var fxAttrs = require_attributes();
+ var delta = require_delta();
+ var INCREASING_COLOR = delta.INCREASING.COLOR;
+ var DECREASING_COLOR = delta.DECREASING.COLOR;
+ var lineAttrs = scatterAttrs.line;
+ function directionAttrs(lineColorDefault) {
+ return {
+ line: {
+ color: extendFlat({}, lineAttrs.color, { dflt: lineColorDefault }),
+ width: lineAttrs.width,
+ dash,
+ editType: "style"
+ },
+ editType: "style"
+ };
+ }
+ module.exports = {
+ xperiod: scatterAttrs.xperiod,
+ xperiod0: scatterAttrs.xperiod0,
+ xperiodalignment: scatterAttrs.xperiodalignment,
+ xhoverformat: axisHoverFormat("x"),
+ yhoverformat: axisHoverFormat("y"),
+ x: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ open: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ high: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ low: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ close: {
+ valType: "data_array",
+ editType: "calc"
+ },
+ line: {
+ width: extendFlat({}, lineAttrs.width, {}),
+ dash: extendFlat({}, dash, {}),
+ editType: "style"
+ },
+ increasing: directionAttrs(INCREASING_COLOR),
+ decreasing: directionAttrs(DECREASING_COLOR),
+ text: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true,
+ editType: "calc"
+ },
+ hovertext: {
+ valType: "string",
+ dflt: "",
+ arrayOk: true,
+ editType: "calc"
+ },
+ tickwidth: {
+ valType: "number",
+ min: 0,
+ max: 0.5,
+ dflt: 0.3,
+ editType: "calc"
+ },
+ hoverlabel: extendFlat({}, fxAttrs.hoverlabel, {
+ split: {
+ valType: "boolean",
+ dflt: false,
+ editType: "style"
+ }
+ }),
+ zorder: scatterAttrs.zorder
+ };
+ }
+ });
+
+ // src/traces/ohlc/ohlc_defaults.js
+ var require_ohlc_defaults = __commonJS({
+ "src/traces/ohlc/ohlc_defaults.js"(exports, module) {
+ "use strict";
+ var Registry = require_registry();
+ var Lib = require_lib();
+ module.exports = function handleOHLC(traceIn, traceOut, coerce, layout) {
+ var x = coerce("x");
+ var open = coerce("open");
+ var high = coerce("high");
+ var low = coerce("low");
+ var close = coerce("close");
+ coerce("hoverlabel.split");
+ var handleCalendarDefaults = Registry.getComponentMethod("calendars", "handleTraceDefaults");
+ handleCalendarDefaults(traceIn, traceOut, ["x"], layout);
+ if (!(open && high && low && close)) return;
+ var len = Math.min(open.length, high.length, low.length, close.length);
+ if (x) len = Math.min(len, Lib.minRowLength(x));
+ traceOut._length = len;
+ return len;
+ };
+ }
+ });
+
+ // src/traces/ohlc/defaults.js
+ var require_defaults62 = __commonJS({
+ "src/traces/ohlc/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var handleOHLC = require_ohlc_defaults();
+ var handlePeriodDefaults = require_period_defaults();
+ var attributes = require_attributes66();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var len = handleOHLC(traceIn, traceOut, coerce, layout);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ handlePeriodDefaults(traceIn, traceOut, layout, coerce, { x: true });
+ coerce("xhoverformat");
+ coerce("yhoverformat");
+ coerce("line.width");
+ coerce("line.dash");
+ handleDirection(traceIn, traceOut, coerce, "increasing");
+ handleDirection(traceIn, traceOut, coerce, "decreasing");
+ coerce("text");
+ coerce("hovertext");
+ coerce("tickwidth");
+ layout._requestRangeslider[traceOut.xaxis] = true;
+ coerce("zorder");
+ };
+ function handleDirection(traceIn, traceOut, coerce, direction) {
+ coerce(direction + ".line.color");
+ coerce(direction + ".line.width", traceOut.line.width);
+ coerce(direction + ".line.dash", traceOut.line.dash);
+ }
+ }
+ });
+
+ // src/traces/ohlc/calc.js
+ var require_calc41 = __commonJS({
+ "src/traces/ohlc/calc.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var _ = Lib._;
+ var Axes = require_axes();
+ var alignPeriod = require_align_period();
+ var BADNUM = require_numerical().BADNUM;
+ function calc(gd, trace) {
+ var xa = Axes.getFromId(gd, trace.xaxis);
+ var ya = Axes.getFromId(gd, trace.yaxis);
+ var tickLen = convertTickWidth(gd, xa, trace);
+ var minDiff = trace._minDiff;
+ trace._minDiff = null;
+ var origX = trace._origX;
+ trace._origX = null;
+ var x = trace._xcalc;
+ trace._xcalc = null;
+ var cd = calcCommon(gd, trace, origX, x, ya, ptFunc);
+ trace._extremes[xa._id] = Axes.findExtremes(xa, x, { vpad: minDiff / 2 });
+ if (cd.length) {
+ Lib.extendFlat(cd[0].t, {
+ wHover: minDiff / 2,
+ tickLen
+ });
+ return cd;
+ } else {
+ return [{ t: { empty: true } }];
+ }
+ }
+ function ptFunc(o, h, l, c) {
+ return {
+ o,
+ h,
+ l,
+ c
+ };
+ }
+ function calcCommon(gd, trace, origX, x, ya, ptFunc2) {
+ var o = ya.makeCalcdata(trace, "open");
+ var h = ya.makeCalcdata(trace, "high");
+ var l = ya.makeCalcdata(trace, "low");
+ var c = ya.makeCalcdata(trace, "close");
+ var hasTextArray = Lib.isArrayOrTypedArray(trace.text);
+ var hasHovertextArray = Lib.isArrayOrTypedArray(trace.hovertext);
+ var increasing = true;
+ var cPrev = null;
+ var hasPeriod = !!trace.xperiodalignment;
+ var cd = [];
+ for (var i = 0; i < x.length; i++) {
+ var xi = x[i];
+ var oi = o[i];
+ var hi = h[i];
+ var li = l[i];
+ var ci = c[i];
+ if (xi !== BADNUM && oi !== BADNUM && hi !== BADNUM && li !== BADNUM && ci !== BADNUM) {
+ if (ci === oi) {
+ if (cPrev !== null && ci !== cPrev) increasing = ci > cPrev;
+ } else increasing = ci > oi;
+ cPrev = ci;
+ var pt = ptFunc2(oi, hi, li, ci);
+ pt.pos = xi;
+ pt.yc = (oi + ci) / 2;
+ pt.i = i;
+ pt.dir = increasing ? "increasing" : "decreasing";
+ pt.x = pt.pos;
+ pt.y = [li, hi];
+ if (hasPeriod) pt.orig_p = origX[i];
+ if (hasTextArray) pt.tx = trace.text[i];
+ if (hasHovertextArray) pt.htx = trace.hovertext[i];
+ cd.push(pt);
+ } else {
+ cd.push({ pos: xi, empty: true });
+ }
+ }
+ trace._extremes[ya._id] = Axes.findExtremes(ya, Lib.concat(l, h), { padded: true });
+ if (cd.length) {
+ cd[0].t = {
+ labels: {
+ open: _(gd, "open:") + " ",
+ high: _(gd, "high:") + " ",
+ low: _(gd, "low:") + " ",
+ close: _(gd, "close:") + " "
+ }
+ };
+ }
+ return cd;
+ }
+ function convertTickWidth(gd, xa, trace) {
+ var minDiff = trace._minDiff;
+ if (!minDiff) {
+ var fullData = gd._fullData;
+ var ohlcTracesOnThisXaxis = [];
+ minDiff = Infinity;
+ var i;
+ for (i = 0; i < fullData.length; i++) {
+ var tracei = fullData[i];
+ if (tracei.type === "ohlc" && tracei.visible === true && tracei.xaxis === xa._id) {
+ ohlcTracesOnThisXaxis.push(tracei);
+ var origX = xa.makeCalcdata(tracei, "x");
+ tracei._origX = origX;
+ var xcalc = alignPeriod(trace, xa, "x", origX).vals;
+ tracei._xcalc = xcalc;
+ var _minDiff = Lib.distinctVals(xcalc).minDiff;
+ if (_minDiff && isFinite(_minDiff)) {
+ minDiff = Math.min(minDiff, _minDiff);
+ }
+ }
+ }
+ if (minDiff === Infinity) minDiff = 1;
+ for (i = 0; i < ohlcTracesOnThisXaxis.length; i++) {
+ ohlcTracesOnThisXaxis[i]._minDiff = minDiff;
+ }
+ }
+ return minDiff * trace.tickwidth;
+ }
+ module.exports = {
+ calc,
+ calcCommon
+ };
+ }
+ });
+
+ // src/traces/ohlc/plot.js
+ var require_plot35 = __commonJS({
+ "src/traces/ohlc/plot.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var Lib = require_lib();
+ module.exports = function plot(gd, plotinfo, cdOHLC, ohlcLayer) {
+ var ya = plotinfo.yaxis;
+ var xa = plotinfo.xaxis;
+ var posHasRangeBreaks = !!xa.rangebreaks;
+ Lib.makeTraceGroups(ohlcLayer, cdOHLC, "trace ohlc").each(function(cd) {
+ var plotGroup = d3.select(this);
+ var cd0 = cd[0];
+ var t = cd0.t;
+ var trace = cd0.trace;
+ if (trace.visible !== true || t.empty) {
+ plotGroup.remove();
+ return;
+ }
+ var tickLen = t.tickLen;
+ var paths = plotGroup.selectAll("path").data(Lib.identity);
+ paths.enter().append("path");
+ paths.exit().remove();
+ paths.attr("d", function(d) {
+ if (d.empty) return "M0,0Z";
+ var xo = xa.c2p(d.pos - tickLen, true);
+ var xc = xa.c2p(d.pos + tickLen, true);
+ var x = posHasRangeBreaks ? (xo + xc) / 2 : xa.c2p(d.pos, true);
+ var yo = ya.c2p(d.o, true);
+ var yh = ya.c2p(d.h, true);
+ var yl = ya.c2p(d.l, true);
+ var yc = ya.c2p(d.c, true);
+ return "M" + xo + "," + yo + "H" + x + "M" + x + "," + yh + "V" + yl + "M" + xc + "," + yc + "H" + x;
+ });
+ });
+ };
+ }
+ });
+
+ // src/traces/ohlc/style.js
+ var require_style19 = __commonJS({
+ "src/traces/ohlc/style.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var Drawing = require_drawing();
+ var Color2 = require_color();
+ module.exports = function style(gd, cd, sel) {
+ var s = sel ? sel : d3.select(gd).selectAll("g.ohlclayer").selectAll("g.trace");
+ s.style("opacity", function(d) {
+ return d[0].trace.opacity;
+ });
+ s.each(function(d) {
+ var trace = d[0].trace;
+ d3.select(this).selectAll("path").each(function(di) {
+ if (di.empty) return;
+ var dirLine = trace[di.dir].line;
+ d3.select(this).style("fill", "none").call(Color2.stroke, dirLine.color).call(Drawing.dashLine, dirLine.dash, dirLine.width).style("opacity", trace.selectedpoints && !di.selected ? 0.3 : 1);
+ });
+ });
+ };
+ }
+ });
+
+ // src/traces/ohlc/hover.js
+ var require_hover23 = __commonJS({
+ "src/traces/ohlc/hover.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ var Lib = require_lib();
+ var Fx = require_fx();
+ var Color2 = require_color();
+ var fillText = require_lib().fillText;
+ var delta = require_delta();
+ var DIRSYMBOL = {
+ increasing: delta.INCREASING.SYMBOL,
+ decreasing: delta.DECREASING.SYMBOL
+ };
+ function hoverPoints(pointData, xval, yval, hovermode) {
+ var cd = pointData.cd;
+ var trace = cd[0].trace;
+ if (trace.hoverlabel.split) {
+ return hoverSplit(pointData, xval, yval, hovermode);
+ }
+ return hoverOnPoints(pointData, xval, yval, hovermode);
+ }
+ function _getClosestPoint(pointData, xval, yval, hovermode) {
+ var cd = pointData.cd;
+ var xa = pointData.xa;
+ var trace = cd[0].trace;
+ var t = cd[0].t;
+ var type = trace.type;
+ var minAttr = type === "ohlc" ? "l" : "min";
+ var maxAttr = type === "ohlc" ? "h" : "max";
+ var hoverPseudoDistance, spikePseudoDistance;
+ var centerShift = t.bPos || 0;
+ var shiftPos = function(di2) {
+ return di2.pos + centerShift - xval;
+ };
+ var displayHalfWidth = t.bdPos || t.tickLen;
+ var hoverHalfWidth = t.wHover;
+ var pseudoDistance = Math.min(1, displayHalfWidth / Math.abs(xa.r2c(xa.range[1]) - xa.r2c(xa.range[0])));
+ hoverPseudoDistance = pointData.maxHoverDistance - pseudoDistance;
+ spikePseudoDistance = pointData.maxSpikeDistance - pseudoDistance;
+ function dx(di2) {
+ var pos = shiftPos(di2);
+ return Fx.inbox(pos - hoverHalfWidth, pos + hoverHalfWidth, hoverPseudoDistance);
+ }
+ function dy(di2) {
+ var min = di2[minAttr];
+ var max = di2[maxAttr];
+ return min === max || Fx.inbox(min - yval, max - yval, hoverPseudoDistance);
+ }
+ function dxy(di2) {
+ return (dx(di2) + dy(di2)) / 2;
+ }
+ var distfn = Fx.getDistanceFunction(hovermode, dx, dy, dxy);
+ Fx.getClosest(cd, distfn, pointData);
+ if (pointData.index === false) return null;
+ var di = cd[pointData.index];
+ if (di.empty) return null;
+ var dir = di.dir;
+ var container = trace[dir];
+ var lc = container.line.color;
+ if (Color2.opacity(lc) && container.line.width) pointData.color = lc;
+ else pointData.color = container.fillcolor;
+ pointData.x0 = xa.c2p(di.pos + centerShift - displayHalfWidth, true);
+ pointData.x1 = xa.c2p(di.pos + centerShift + displayHalfWidth, true);
+ pointData.xLabelVal = di.orig_p !== void 0 ? di.orig_p : di.pos;
+ pointData.spikeDistance = dxy(di) * spikePseudoDistance / hoverPseudoDistance;
+ pointData.xSpike = xa.c2p(di.pos, true);
+ return pointData;
+ }
+ function hoverSplit(pointData, xval, yval, hovermode) {
+ var cd = pointData.cd;
+ var ya = pointData.ya;
+ var trace = cd[0].trace;
+ var t = cd[0].t;
+ var closeBoxData = [];
+ var closestPoint = _getClosestPoint(pointData, xval, yval, hovermode);
+ if (!closestPoint) return [];
+ var cdIndex = closestPoint.index;
+ var di = cd[cdIndex];
+ var hoverinfo = di.hi || trace.hoverinfo;
+ var hoverParts = hoverinfo.split("+");
+ var isAll = hoverinfo === "all";
+ var hasY = isAll || hoverParts.indexOf("y") !== -1;
+ if (!hasY) return [];
+ var attrs = ["high", "open", "close", "low"];
+ var usedVals = {};
+ for (var i = 0; i < attrs.length; i++) {
+ var attr = attrs[i];
+ var val = trace[attr][closestPoint.index];
+ var valPx = ya.c2p(val, true);
+ var pointData2;
+ if (val in usedVals) {
+ pointData2 = usedVals[val];
+ pointData2.yLabel += "
" + t.labels[attr] + Axes.hoverLabelText(ya, val, trace.yhoverformat);
+ } else {
+ pointData2 = Lib.extendFlat({}, closestPoint);
+ pointData2.y0 = pointData2.y1 = valPx;
+ pointData2.yLabelVal = val;
+ pointData2.yLabel = t.labels[attr] + Axes.hoverLabelText(ya, val, trace.yhoverformat);
+ pointData2.name = "";
+ closeBoxData.push(pointData2);
+ usedVals[val] = pointData2;
+ }
+ }
+ return closeBoxData;
+ }
+ function hoverOnPoints(pointData, xval, yval, hovermode) {
+ var cd = pointData.cd;
+ var ya = pointData.ya;
+ var trace = cd[0].trace;
+ var t = cd[0].t;
+ var closestPoint = _getClosestPoint(pointData, xval, yval, hovermode);
+ if (!closestPoint) return [];
+ var cdIndex = closestPoint.index;
+ var di = cd[cdIndex];
+ var i = closestPoint.index = di.i;
+ var dir = di.dir;
+ function getLabelLine(attr) {
+ return t.labels[attr] + Axes.hoverLabelText(ya, trace[attr][i], trace.yhoverformat);
+ }
+ var hoverinfo = di.hi || trace.hoverinfo;
+ var hoverParts = hoverinfo.split("+");
+ var isAll = hoverinfo === "all";
+ var hasY = isAll || hoverParts.indexOf("y") !== -1;
+ var hasText = isAll || hoverParts.indexOf("text") !== -1;
+ var textParts = hasY ? [
+ getLabelLine("open"),
+ getLabelLine("high"),
+ getLabelLine("low"),
+ getLabelLine("close") + " " + DIRSYMBOL[dir]
+ ] : [];
+ if (hasText) fillText(di, trace, textParts);
+ closestPoint.extraText = textParts.join("
");
+ closestPoint.y0 = closestPoint.y1 = ya.c2p(di.yc, true);
+ return [closestPoint];
+ }
+ module.exports = {
+ hoverPoints,
+ hoverSplit,
+ hoverOnPoints
+ };
+ }
+ });
+
+ // src/traces/ohlc/select.js
+ var require_select12 = __commonJS({
+ "src/traces/ohlc/select.js"(exports, module) {
+ "use strict";
+ module.exports = function selectPoints(searchInfo, selectionTester) {
+ var cd = searchInfo.cd;
+ var xa = searchInfo.xaxis;
+ var ya = searchInfo.yaxis;
+ var selection = [];
+ var i;
+ var posOffset = cd[0].t.bPos || 0;
+ if (selectionTester === false) {
+ for (i = 0; i < cd.length; i++) {
+ cd[i].selected = 0;
+ }
+ } else {
+ for (i = 0; i < cd.length; i++) {
+ var di = cd[i];
+ if (selectionTester.contains([xa.c2p(di.pos + posOffset), ya.c2p(di.yc)], null, di.i, searchInfo)) {
+ selection.push({
+ pointNumber: di.i,
+ x: xa.c2d(di.pos),
+ y: ya.c2d(di.yc)
+ });
+ di.selected = 1;
+ } else {
+ di.selected = 0;
+ }
+ }
+ }
+ return selection;
+ };
+ }
+ });
+
+ // src/traces/ohlc/index.js
+ var require_ohlc = __commonJS({
+ "src/traces/ohlc/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ moduleType: "trace",
+ name: "ohlc",
+ basePlotModule: require_cartesian(),
+ categories: ["cartesian", "svg", "showLegend"],
+ meta: {},
+ attributes: require_attributes66(),
+ supplyDefaults: require_defaults62(),
+ calc: require_calc41().calc,
+ plot: require_plot35(),
+ style: require_style19(),
+ hoverPoints: require_hover23().hoverPoints,
+ selectPoints: require_select12()
+ };
+ }
+ });
+
+ // lib/ohlc.js
+ var require_ohlc2 = __commonJS({
+ "lib/ohlc.js"(exports, module) {
+ "use strict";
+ module.exports = require_ohlc();
+ }
+ });
+
+ // src/traces/candlestick/attributes.js
+ var require_attributes67 = __commonJS({
+ "src/traces/candlestick/attributes.js"(exports, module) {
+ "use strict";
+ var extendFlat = require_lib().extendFlat;
+ var axisHoverFormat = require_axis_format_attributes().axisHoverFormat;
+ var OHLCattrs = require_attributes66();
+ var boxAttrs = require_attributes24();
+ function directionAttrs(lineColorDefault) {
+ return {
+ line: {
+ color: extendFlat({}, boxAttrs.line.color, { dflt: lineColorDefault }),
+ width: boxAttrs.line.width,
+ editType: "style"
+ },
+ fillcolor: boxAttrs.fillcolor,
+ editType: "style"
+ };
+ }
+ module.exports = {
+ xperiod: OHLCattrs.xperiod,
+ xperiod0: OHLCattrs.xperiod0,
+ xperiodalignment: OHLCattrs.xperiodalignment,
+ xhoverformat: axisHoverFormat("x"),
+ yhoverformat: axisHoverFormat("y"),
+ x: OHLCattrs.x,
+ open: OHLCattrs.open,
+ high: OHLCattrs.high,
+ low: OHLCattrs.low,
+ close: OHLCattrs.close,
+ line: {
+ width: extendFlat({}, boxAttrs.line.width, {}),
+ editType: "style"
+ },
+ increasing: directionAttrs(OHLCattrs.increasing.line.color.dflt),
+ decreasing: directionAttrs(OHLCattrs.decreasing.line.color.dflt),
+ text: OHLCattrs.text,
+ hovertext: OHLCattrs.hovertext,
+ whiskerwidth: extendFlat({}, boxAttrs.whiskerwidth, { dflt: 0 }),
+ hoverlabel: OHLCattrs.hoverlabel,
+ zorder: boxAttrs.zorder
+ };
+ }
+ });
+
+ // src/traces/candlestick/defaults.js
+ var require_defaults63 = __commonJS({
+ "src/traces/candlestick/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var Color2 = require_color();
+ var handleOHLC = require_ohlc_defaults();
+ var handlePeriodDefaults = require_period_defaults();
+ var attributes = require_attributes67();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var len = handleOHLC(traceIn, traceOut, coerce, layout);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ handlePeriodDefaults(traceIn, traceOut, layout, coerce, { x: true });
+ coerce("xhoverformat");
+ coerce("yhoverformat");
+ coerce("line.width");
+ handleDirection(traceIn, traceOut, coerce, "increasing");
+ handleDirection(traceIn, traceOut, coerce, "decreasing");
+ coerce("text");
+ coerce("hovertext");
+ coerce("whiskerwidth");
+ layout._requestRangeslider[traceOut.xaxis] = true;
+ coerce("zorder");
+ };
+ function handleDirection(traceIn, traceOut, coerce, direction) {
+ var lineColor = coerce(direction + ".line.color");
+ coerce(direction + ".line.width", traceOut.line.width);
+ coerce(direction + ".fillcolor", Color2.addOpacity(lineColor, 0.5));
+ }
+ }
+ });
+
+ // src/traces/candlestick/calc.js
+ var require_calc42 = __commonJS({
+ "src/traces/candlestick/calc.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var Axes = require_axes();
+ var alignPeriod = require_align_period();
+ var calcCommon = require_calc41().calcCommon;
+ module.exports = function(gd, trace) {
+ var fullLayout = gd._fullLayout;
+ var xa = Axes.getFromId(gd, trace.xaxis);
+ var ya = Axes.getFromId(gd, trace.yaxis);
+ var origX = xa.makeCalcdata(trace, "x");
+ var x = alignPeriod(trace, xa, "x", origX).vals;
+ var cd = calcCommon(gd, trace, origX, x, ya, ptFunc);
+ if (cd.length) {
+ Lib.extendFlat(cd[0].t, {
+ num: fullLayout._numBoxes,
+ dPos: Lib.distinctVals(x).minDiff / 2,
+ posLetter: "x",
+ valLetter: "y"
+ });
+ fullLayout._numBoxes++;
+ return cd;
+ } else {
+ return [{ t: { empty: true } }];
+ }
+ };
+ function ptFunc(o, h, l, c) {
+ return {
+ min: l,
+ q1: Math.min(o, c),
+ med: c,
+ q3: Math.max(o, c),
+ max: h
+ };
+ }
+ }
+ });
+
+ // src/traces/candlestick/index.js
+ var require_candlestick = __commonJS({
+ "src/traces/candlestick/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ moduleType: "trace",
+ name: "candlestick",
+ basePlotModule: require_cartesian(),
+ categories: ["cartesian", "svg", "showLegend", "candlestick", "boxLayout"],
+ meta: {},
+ attributes: require_attributes67(),
+ layoutAttributes: require_layout_attributes7(),
+ supplyLayoutDefaults: require_layout_defaults6().supplyLayoutDefaults,
+ crossTraceCalc: require_cross_trace_calc3().crossTraceCalc,
+ supplyDefaults: require_defaults63(),
+ calc: require_calc42(),
+ plot: require_plot4().plot,
+ layerName: "boxlayer",
+ style: require_style5().style,
+ hoverPoints: require_hover23().hoverPoints,
+ selectPoints: require_select12()
+ };
+ }
+ });
+
+ // lib/candlestick.js
+ var require_candlestick2 = __commonJS({
+ "lib/candlestick.js"(exports, module) {
+ "use strict";
+ module.exports = require_candlestick();
+ }
+ });
+
+ // src/plots/polar/set_convert.js
+ var require_set_convert3 = __commonJS({
+ "src/plots/polar/set_convert.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var setConvertCartesian = require_set_convert();
+ var deg2rad = Lib.deg2rad;
+ var rad2deg = Lib.rad2deg;
+ module.exports = function setConvert(ax, polarLayout, fullLayout) {
+ setConvertCartesian(ax, fullLayout);
+ switch (ax._id) {
+ case "x":
+ case "radialaxis":
+ setConvertRadial(ax, polarLayout);
+ break;
+ case "angularaxis":
+ setConvertAngular(ax, polarLayout);
+ break;
+ }
+ };
+ function setConvertRadial(ax, polarLayout) {
+ var subplot = polarLayout._subplot;
+ ax.setGeometry = function() {
+ var rl0 = ax._rl[0];
+ var rl1 = ax._rl[1];
+ var b = subplot.innerRadius;
+ var m = (subplot.radius - b) / (rl1 - rl0);
+ var b2 = b / m;
+ var rFilter = rl0 > rl1 ? function(v) {
+ return v <= 0;
+ } : function(v) {
+ return v >= 0;
+ };
+ ax.c2g = function(v) {
+ var r = ax.c2l(v) - rl0;
+ return (rFilter(r) ? r : 0) + b2;
+ };
+ ax.g2c = function(v) {
+ return ax.l2c(v + rl0 - b2);
+ };
+ ax.g2p = function(v) {
+ return v * m;
+ };
+ ax.c2p = function(v) {
+ return ax.g2p(ax.c2g(v));
+ };
+ };
+ }
+ function toRadians(v, unit) {
+ return unit === "degrees" ? deg2rad(v) : v;
+ }
+ function fromRadians(v, unit) {
+ return unit === "degrees" ? rad2deg(v) : v;
+ }
+ function setConvertAngular(ax, polarLayout) {
+ var axType = ax.type;
+ if (axType === "linear") {
+ var _d2c = ax.d2c;
+ var _c2d = ax.c2d;
+ ax.d2c = function(v, unit) {
+ return toRadians(_d2c(v), unit);
+ };
+ ax.c2d = function(v, unit) {
+ return _c2d(fromRadians(v, unit));
+ };
+ }
+ ax.makeCalcdata = function(trace, coord) {
+ var arrayIn = trace[coord];
+ var len = trace._length;
+ var arrayOut, i;
+ var _d2c2 = function(v) {
+ return ax.d2c(v, trace.thetaunit);
+ };
+ if (arrayIn) {
+ arrayOut = new Array(len);
+ for (i = 0; i < len; i++) {
+ arrayOut[i] = _d2c2(arrayIn[i]);
+ }
+ } else {
+ var coord0 = coord + "0";
+ var dcoord = "d" + coord;
+ var v0 = coord0 in trace ? _d2c2(trace[coord0]) : 0;
+ var dv = trace[dcoord] ? _d2c2(trace[dcoord]) : (ax.period || 2 * Math.PI) / len;
+ arrayOut = new Array(len);
+ for (i = 0; i < len; i++) {
+ arrayOut[i] = v0 + i * dv;
+ }
+ }
+ return arrayOut;
+ };
+ ax.setGeometry = function() {
+ var sector = polarLayout.sector;
+ var sectorInRad = sector.map(deg2rad);
+ var dir = { clockwise: -1, counterclockwise: 1 }[ax.direction];
+ var rot = deg2rad(ax.rotation);
+ var rad2g = function(v) {
+ return dir * v + rot;
+ };
+ var g2rad = function(v) {
+ return (v - rot) / dir;
+ };
+ var rad2c, c2rad;
+ var rad2t, t2rad;
+ switch (axType) {
+ case "linear":
+ c2rad = rad2c = Lib.identity;
+ t2rad = deg2rad;
+ rad2t = rad2deg;
+ ax.range = Lib.isFullCircle(sectorInRad) ? [sector[0], sector[0] + 360] : sectorInRad.map(g2rad).map(rad2deg);
+ break;
+ case "category":
+ var catLen = ax._categories.length;
+ var _period = ax.period ? Math.max(ax.period, catLen) : catLen;
+ if (_period === 0) _period = 1;
+ c2rad = t2rad = function(v) {
+ return v * 2 * Math.PI / _period;
+ };
+ rad2c = rad2t = function(v) {
+ return v * _period / Math.PI / 2;
+ };
+ ax.range = [0, _period];
+ break;
+ }
+ ax.c2g = function(v) {
+ return rad2g(c2rad(v));
+ };
+ ax.g2c = function(v) {
+ return rad2c(g2rad(v));
+ };
+ ax.t2g = function(v) {
+ return rad2g(t2rad(v));
+ };
+ ax.g2t = function(v) {
+ return rad2t(g2rad(v));
+ };
+ };
+ }
+ }
+ });
+
+ // src/plots/polar/constants.js
+ var require_constants33 = __commonJS({
+ "src/plots/polar/constants.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attr: "subplot",
+ name: "polar",
+ axisNames: ["angularaxis", "radialaxis"],
+ axisName2dataArray: { angularaxis: "theta", radialaxis: "r" },
+ layerNames: [
+ "draglayer",
+ "plotbg",
+ "backplot",
+ "angular-grid",
+ "radial-grid",
+ "frontplot",
+ "angular-line",
+ "radial-line",
+ "angular-axis",
+ "radial-axis"
+ ],
+ radialDragBoxSize: 50,
+ angularDragBoxSize: 30,
+ cornerLen: 25,
+ cornerHalfWidth: 2,
+ // pixels to move mouse before you stop clamping to starting point
+ MINDRAG: 8,
+ // smallest radial distance [px] allowed for a zoombox
+ MINZOOM: 20,
+ // distance [px] off (r=0) or (r=radius) where we transition
+ // from single-sided to two-sided radial zoom
+ OFFEDGE: 20
+ };
+ }
+ });
+
+ // src/plots/polar/helpers.js
+ var require_helpers19 = __commonJS({
+ "src/plots/polar/helpers.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var polygonTester = require_polygon().tester;
+ var findIndexOfMin = Lib.findIndexOfMin;
+ var isAngleInsideSector = Lib.isAngleInsideSector;
+ var angleDelta = Lib.angleDelta;
+ var angleDist = Lib.angleDist;
+ function isPtInsidePolygon(r, a, rBnds, aBnds, vangles) {
+ if (!isAngleInsideSector(a, aBnds)) return false;
+ var r0, r1;
+ if (rBnds[0] < rBnds[1]) {
+ r0 = rBnds[0];
+ r1 = rBnds[1];
+ } else {
+ r0 = rBnds[1];
+ r1 = rBnds[0];
+ }
+ var polygonIn = polygonTester(makePolygon(r0, aBnds[0], aBnds[1], vangles));
+ var polygonOut = polygonTester(makePolygon(r1, aBnds[0], aBnds[1], vangles));
+ var xy = [r * Math.cos(a), r * Math.sin(a)];
+ return polygonOut.contains(xy) && !polygonIn.contains(xy);
+ }
+ function findIntersectionXY(v0, v1, a, xpyp) {
+ var xstar, ystar;
+ var xp = xpyp[0];
+ var yp = xpyp[1];
+ var dsin = clampTiny(Math.sin(v1) - Math.sin(v0));
+ var dcos = clampTiny(Math.cos(v1) - Math.cos(v0));
+ var tanA = Math.tan(a);
+ var cotanA = clampTiny(1 / tanA);
+ var m = dsin / dcos;
+ var b = yp - m * xp;
+ if (cotanA) {
+ if (dsin && dcos) {
+ xstar = b / (tanA - m);
+ ystar = tanA * xstar;
+ } else if (dcos) {
+ xstar = yp * cotanA;
+ ystar = yp;
+ } else {
+ xstar = xp;
+ ystar = xp * tanA;
+ }
+ } else {
+ if (dsin && dcos) {
+ xstar = 0;
+ ystar = b;
+ } else if (dcos) {
+ xstar = 0;
+ ystar = yp;
+ } else {
+ xstar = ystar = NaN;
+ }
+ }
+ return [xstar, ystar];
+ }
+ function findXYatLength(l, m, xp, yp) {
+ var t = -m * xp;
+ var a = m * m + 1;
+ var b = 2 * (m * t - xp);
+ var c = t * t + xp * xp - l * l;
+ var del = Math.sqrt(b * b - 4 * a * c);
+ var x0 = (-b + del) / (2 * a);
+ var x1 = (-b - del) / (2 * a);
+ return [
+ [x0, m * x0 + t + yp],
+ [x1, m * x1 + t + yp]
+ ];
+ }
+ function makeRegularPolygon(r, vangles) {
+ var len = vangles.length;
+ var vertices = new Array(len + 1);
+ var i;
+ for (i = 0; i < len; i++) {
+ var va = vangles[i];
+ vertices[i] = [r * Math.cos(va), r * Math.sin(va)];
+ }
+ vertices[i] = vertices[0].slice();
+ return vertices;
+ }
+ function makeClippedPolygon(r, a0, a1, vangles) {
+ var len = vangles.length;
+ var vertices = [];
+ var i, j;
+ function a2xy(a) {
+ return [r * Math.cos(a), r * Math.sin(a)];
+ }
+ function findXY(va0, va1, s) {
+ return findIntersectionXY(va0, va1, s, a2xy(va0));
+ }
+ function cycleIndex(ind) {
+ return Lib.mod(ind, len);
+ }
+ function isInside(v) {
+ return isAngleInsideSector(v, [a0, a1]);
+ }
+ var i0 = findIndexOfMin(vangles, function(v) {
+ return isInside(v) ? angleDist(v, a0) : Infinity;
+ });
+ var xy0 = findXY(vangles[i0], vangles[cycleIndex(i0 - 1)], a0);
+ vertices.push(xy0);
+ for (i = i0, j = 0; j < len; i++, j++) {
+ var va = vangles[cycleIndex(i)];
+ if (!isInside(va)) break;
+ vertices.push(a2xy(va));
+ }
+ var iN = findIndexOfMin(vangles, function(v) {
+ return isInside(v) ? angleDist(v, a1) : Infinity;
+ });
+ var xyN = findXY(vangles[iN], vangles[cycleIndex(iN + 1)], a1);
+ vertices.push(xyN);
+ vertices.push([0, 0]);
+ vertices.push(vertices[0].slice());
+ return vertices;
+ }
+ function makePolygon(r, a0, a1, vangles) {
+ return Lib.isFullCircle([a0, a1]) ? makeRegularPolygon(r, vangles) : makeClippedPolygon(r, a0, a1, vangles);
+ }
+ function findPolygonOffset(r, a0, a1, vangles) {
+ var minX = Infinity;
+ var minY = Infinity;
+ var vertices = makePolygon(r, a0, a1, vangles);
+ for (var i = 0; i < vertices.length; i++) {
+ var v = vertices[i];
+ minX = Math.min(minX, v[0]);
+ minY = Math.min(minY, -v[1]);
+ }
+ return [minX, minY];
+ }
+ function findEnclosingVertexAngles(a, vangles) {
+ var minFn = function(v) {
+ var adelta = angleDelta(v, a);
+ return adelta > 0 ? adelta : Infinity;
+ };
+ var i0 = findIndexOfMin(vangles, minFn);
+ var i1 = Lib.mod(i0 + 1, vangles.length);
+ return [vangles[i0], vangles[i1]];
+ }
+ function clampTiny(v) {
+ return Math.abs(v) > 1e-10 ? v : 0;
+ }
+ function transformForSVG(pts0, cx, cy) {
+ cx = cx || 0;
+ cy = cy || 0;
+ var len = pts0.length;
+ var pts1 = new Array(len);
+ for (var i = 0; i < len; i++) {
+ var pt = pts0[i];
+ pts1[i] = [cx + pt[0], cy - pt[1]];
+ }
+ return pts1;
+ }
+ function pathPolygon(r, a0, a1, vangles, cx, cy) {
+ var poly = makePolygon(r, a0, a1, vangles);
+ return "M" + transformForSVG(poly, cx, cy).join("L");
+ }
+ function pathPolygonAnnulus(r0, r1, a0, a1, vangles, cx, cy) {
+ var rStart, rEnd;
+ if (r0 < r1) {
+ rStart = r0;
+ rEnd = r1;
+ } else {
+ rStart = r1;
+ rEnd = r0;
+ }
+ var inner = transformForSVG(makePolygon(rStart, a0, a1, vangles), cx, cy);
+ var outer = transformForSVG(makePolygon(rEnd, a0, a1, vangles), cx, cy);
+ return "M" + outer.reverse().join("L") + "M" + inner.join("L");
+ }
+ module.exports = {
+ isPtInsidePolygon,
+ findPolygonOffset,
+ findEnclosingVertexAngles,
+ findIntersectionXY,
+ findXYatLength,
+ clampTiny,
+ pathPolygon,
+ pathPolygonAnnulus
+ };
+ }
+ });
+
+ // src/plots/smith/helpers.js
+ var require_helpers20 = __commonJS({
+ "src/plots/smith/helpers.js"(exports, module) {
+ "use strict";
+ function sign(x) {
+ return x < 0 ? -1 : x > 0 ? 1 : 0;
+ }
+ function smith(a) {
+ var R = a[0];
+ var X = a[1];
+ if (!isFinite(R) || !isFinite(X)) return [1, 0];
+ var D2 = (R + 1) * (R + 1) + X * X;
+ return [(R * R + X * X - 1) / D2, 2 * X / D2];
+ }
+ function transform(subplot, a) {
+ var x = a[0];
+ var y = a[1];
+ return [
+ x * subplot.radius + subplot.cx,
+ -y * subplot.radius + subplot.cy
+ ];
+ }
+ function scale(subplot, r) {
+ return r * subplot.radius;
+ }
+ function reactanceArc(subplot, X, R1, R2) {
+ var t12 = transform(subplot, smith([R1, X]));
+ var x1 = t12[0];
+ var y1 = t12[1];
+ var t22 = transform(subplot, smith([R2, X]));
+ var x2 = t22[0];
+ var y2 = t22[1];
+ if (X === 0) {
+ return [
+ "M" + x1 + "," + y1,
+ "L" + x2 + "," + y2
+ ].join(" ");
+ }
+ var r = scale(subplot, 1 / Math.abs(X));
+ return [
+ "M" + x1 + "," + y1,
+ "A" + r + "," + r + " 0 0," + (X < 0 ? 1 : 0) + " " + x2 + "," + y2
+ ].join(" ");
+ }
+ function resistanceArc(subplot, R, X1, X2) {
+ var r = scale(subplot, 1 / (R + 1));
+ var t12 = transform(subplot, smith([R, X1]));
+ var x1 = t12[0];
+ var y1 = t12[1];
+ var t22 = transform(subplot, smith([R, X2]));
+ var x2 = t22[0];
+ var y2 = t22[1];
+ if (sign(X1) !== sign(X2)) {
+ var t02 = transform(subplot, smith([R, 0]));
+ var x0 = t02[0];
+ var y0 = t02[1];
+ return [
+ "M" + x1 + "," + y1,
+ "A" + r + "," + r + " 0 0," + (0 < X1 ? 0 : 1) + " " + x0 + "," + y0,
+ "A" + r + "," + r + " 0 0," + (X2 < 0 ? 0 : 1) + x2 + "," + y2
+ ].join(" ");
+ }
+ return [
+ "M" + x1 + "," + y1,
+ "A" + r + "," + r + " 0 0," + (X2 < X1 ? 0 : 1) + " " + x2 + "," + y2
+ ].join(" ");
+ }
+ module.exports = {
+ smith,
+ reactanceArc,
+ resistanceArc,
+ smithTransform: transform
+ };
+ }
+ });
+
+ // src/plots/polar/polar.js
+ var require_polar = __commonJS({
+ "src/plots/polar/polar.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var tinycolor = require_tinycolor();
+ var Registry = require_registry();
+ var Lib = require_lib();
+ var strRotate = Lib.strRotate;
+ var strTranslate = Lib.strTranslate;
+ var Color2 = require_color();
+ var Drawing = require_drawing();
+ var Plots = require_plots();
+ var Axes = require_axes();
+ var setConvertCartesian = require_set_convert();
+ var setConvertPolar = require_set_convert3();
+ var doAutoRange = require_autorange().doAutoRange;
+ var dragBox = require_dragbox();
+ var dragElement = require_dragelement();
+ var Fx = require_fx();
+ var Titles = require_titles();
+ var prepSelect = require_selections().prepSelect;
+ var selectOnClick = require_selections().selectOnClick;
+ var clearOutline = require_selections().clearOutline;
+ var setCursor = require_setcursor();
+ var clearGlCanvases = require_clear_gl_canvases();
+ var redrawReglTraces = require_subroutines().redrawReglTraces;
+ var MID_SHIFT = require_alignment().MID_SHIFT;
+ var constants = require_constants33();
+ var helpers = require_helpers19();
+ var smithHelpers = require_helpers20();
+ var smith = smithHelpers.smith;
+ var reactanceArc = smithHelpers.reactanceArc;
+ var resistanceArc = smithHelpers.resistanceArc;
+ var smithTransform = smithHelpers.smithTransform;
+ var _ = Lib._;
+ var mod = Lib.mod;
+ var deg2rad = Lib.deg2rad;
+ var rad2deg = Lib.rad2deg;
+ function Polar(gd, id, isSmith) {
+ this.isSmith = isSmith || false;
+ this.id = id;
+ this.gd = gd;
+ this._hasClipOnAxisFalse = null;
+ this.vangles = null;
+ this.radialAxisAngle = null;
+ this.traceHash = {};
+ this.layers = {};
+ this.clipPaths = {};
+ this.clipIds = {};
+ this.viewInitial = {};
+ var fullLayout = gd._fullLayout;
+ var clipIdBase = "clip" + fullLayout._uid + id;
+ this.clipIds.forTraces = clipIdBase + "-for-traces";
+ this.clipPaths.forTraces = fullLayout._clips.append("clipPath").attr("id", this.clipIds.forTraces);
+ this.clipPaths.forTraces.append("path");
+ this.framework = fullLayout["_" + (isSmith ? "smith" : "polar") + "layer"].append("g").attr("class", id);
+ this.getHole = function(s) {
+ return this.isSmith ? 0 : s.hole;
+ };
+ this.getSector = function(s) {
+ return this.isSmith ? [0, 360] : s.sector;
+ };
+ this.getRadial = function(s) {
+ return this.isSmith ? s.realaxis : s.radialaxis;
+ };
+ this.getAngular = function(s) {
+ return this.isSmith ? s.imaginaryaxis : s.angularaxis;
+ };
+ if (!isSmith) {
+ this.radialTickLayout = null;
+ this.angularTickLayout = null;
+ }
+ }
+ var proto = Polar.prototype;
+ module.exports = function createPolar(gd, id, isSmith) {
+ return new Polar(gd, id, isSmith);
+ };
+ proto.plot = function(polarCalcData, fullLayout) {
+ var _this = this;
+ var polarLayout = fullLayout[_this.id];
+ var found = false;
+ for (var i = 0; i < polarCalcData.length; i++) {
+ var trace = polarCalcData[i][0].trace;
+ if (trace.cliponaxis === false) {
+ found = true;
+ break;
+ }
+ }
+ _this._hasClipOnAxisFalse = found;
+ _this.updateLayers(fullLayout, polarLayout);
+ _this.updateLayout(fullLayout, polarLayout);
+ Plots.generalUpdatePerTraceModule(_this.gd, _this, polarCalcData, polarLayout);
+ _this.updateFx(fullLayout, polarLayout);
+ if (_this.isSmith) {
+ delete polarLayout.realaxis.range;
+ delete polarLayout.imaginaryaxis.range;
+ }
+ };
+ proto.updateLayers = function(fullLayout, polarLayout) {
+ var _this = this;
+ var isSmith = _this.isSmith;
+ var layers = _this.layers;
+ var radialLayout = _this.getRadial(polarLayout);
+ var angularLayout = _this.getAngular(polarLayout);
+ var layerNames = constants.layerNames;
+ var frontPlotIndex = layerNames.indexOf("frontplot");
+ var layerData = layerNames.slice(0, frontPlotIndex);
+ var isAngularAxisBelowTraces = angularLayout.layer === "below traces";
+ var isRadialAxisBelowTraces = radialLayout.layer === "below traces";
+ if (isAngularAxisBelowTraces) layerData.push("angular-line");
+ if (isRadialAxisBelowTraces) layerData.push("radial-line");
+ if (isAngularAxisBelowTraces) layerData.push("angular-axis");
+ if (isRadialAxisBelowTraces) layerData.push("radial-axis");
+ layerData.push("frontplot");
+ if (!isAngularAxisBelowTraces) layerData.push("angular-line");
+ if (!isRadialAxisBelowTraces) layerData.push("radial-line");
+ if (!isAngularAxisBelowTraces) layerData.push("angular-axis");
+ if (!isRadialAxisBelowTraces) layerData.push("radial-axis");
+ var subLayer = (isSmith ? "smith" : "polar") + "sublayer";
+ var join = _this.framework.selectAll("." + subLayer).data(layerData, String);
+ join.enter().append("g").attr("class", function(d) {
+ return subLayer + " " + d;
+ }).each(function(d) {
+ var sel = layers[d] = d3.select(this);
+ switch (d) {
+ case "frontplot":
+ if (!isSmith) {
+ sel.append("g").classed("barlayer", true);
+ }
+ sel.append("g").classed("scatterlayer", true);
+ break;
+ case "backplot":
+ sel.append("g").classed("maplayer", true);
+ break;
+ case "plotbg":
+ layers.bg = sel.append("path");
+ break;
+ case "radial-grid":
+ sel.style("fill", "none");
+ break;
+ case "angular-grid":
+ sel.style("fill", "none");
+ break;
+ case "radial-line":
+ sel.append("line").style("fill", "none");
+ break;
+ case "angular-line":
+ sel.append("path").style("fill", "none");
+ break;
+ }
+ });
+ join.order();
+ };
+ proto.updateLayout = function(fullLayout, polarLayout) {
+ var _this = this;
+ var layers = _this.layers;
+ var gs = fullLayout._size;
+ var radialLayout = _this.getRadial(polarLayout);
+ var angularLayout = _this.getAngular(polarLayout);
+ var xDomain = polarLayout.domain.x;
+ var yDomain = polarLayout.domain.y;
+ _this.xOffset = gs.l + gs.w * xDomain[0];
+ _this.yOffset = gs.t + gs.h * (1 - yDomain[1]);
+ var xLength = _this.xLength = gs.w * (xDomain[1] - xDomain[0]);
+ var yLength = _this.yLength = gs.h * (yDomain[1] - yDomain[0]);
+ var sector = _this.getSector(polarLayout);
+ _this.sectorInRad = sector.map(deg2rad);
+ var sectorBBox = _this.sectorBBox = computeSectorBBox(sector);
+ var dxSectorBBox = sectorBBox[2] - sectorBBox[0];
+ var dySectorBBox = sectorBBox[3] - sectorBBox[1];
+ var arDomain = yLength / xLength;
+ var arSector = Math.abs(dySectorBBox / dxSectorBBox);
+ var xLength2, yLength2;
+ var xDomain2, yDomain2;
+ var gap;
+ if (arDomain > arSector) {
+ xLength2 = xLength;
+ yLength2 = xLength * arSector;
+ gap = (yLength - yLength2) / gs.h / 2;
+ xDomain2 = [xDomain[0], xDomain[1]];
+ yDomain2 = [yDomain[0] + gap, yDomain[1] - gap];
+ } else {
+ xLength2 = yLength / arSector;
+ yLength2 = yLength;
+ gap = (xLength - xLength2) / gs.w / 2;
+ xDomain2 = [xDomain[0] + gap, xDomain[1] - gap];
+ yDomain2 = [yDomain[0], yDomain[1]];
+ }
+ _this.xLength2 = xLength2;
+ _this.yLength2 = yLength2;
+ _this.xDomain2 = xDomain2;
+ _this.yDomain2 = yDomain2;
+ var xOffset2 = _this.xOffset2 = gs.l + gs.w * xDomain2[0];
+ var yOffset2 = _this.yOffset2 = gs.t + gs.h * (1 - yDomain2[1]);
+ var radius = _this.radius = xLength2 / dxSectorBBox;
+ var innerRadius = _this.innerRadius = _this.getHole(polarLayout) * radius;
+ var cx = _this.cx = xOffset2 - radius * sectorBBox[0];
+ var cy = _this.cy = yOffset2 + radius * sectorBBox[3];
+ var cxx = _this.cxx = cx - xOffset2;
+ var cyy = _this.cyy = cy - yOffset2;
+ var side = radialLayout.side;
+ var trueSide;
+ if (side === "counterclockwise") {
+ trueSide = side;
+ side = "top";
+ } else if (side === "clockwise") {
+ trueSide = side;
+ side = "bottom";
+ }
+ _this.radialAxis = _this.mockAxis(fullLayout, polarLayout, radialLayout, {
+ // make this an 'x' axis to make positioning (especially rotation) easier
+ _id: "x",
+ // convert to 'x' axis equivalent
+ side,
+ // keep track of real side
+ _trueSide: trueSide,
+ // spans length 1 radius
+ domain: [innerRadius / gs.w, radius / gs.w]
+ });
+ _this.angularAxis = _this.mockAxis(fullLayout, polarLayout, angularLayout, {
+ side: "right",
+ // to get auto nticks right
+ domain: [0, Math.PI],
+ // don't pass through autorange logic
+ autorange: false
+ });
+ _this.doAutoRange(fullLayout, polarLayout);
+ _this.updateAngularAxis(fullLayout, polarLayout);
+ _this.updateRadialAxis(fullLayout, polarLayout);
+ _this.updateRadialAxisTitle(fullLayout, polarLayout);
+ _this.xaxis = _this.mockCartesianAxis(fullLayout, polarLayout, {
+ _id: "x",
+ domain: xDomain2
+ });
+ _this.yaxis = _this.mockCartesianAxis(fullLayout, polarLayout, {
+ _id: "y",
+ domain: yDomain2
+ });
+ var dPath = _this.pathSubplot();
+ _this.clipPaths.forTraces.select("path").attr("d", dPath).attr("transform", strTranslate(cxx, cyy));
+ layers.frontplot.attr("transform", strTranslate(xOffset2, yOffset2)).call(Drawing.setClipUrl, _this._hasClipOnAxisFalse ? null : _this.clipIds.forTraces, _this.gd);
+ layers.bg.attr("d", dPath).attr("transform", strTranslate(cx, cy)).call(Color2.fill, polarLayout.bgcolor);
+ };
+ proto.mockAxis = function(fullLayout, polarLayout, axLayout, opts) {
+ var ax = Lib.extendFlat({}, axLayout, opts);
+ setConvertPolar(ax, polarLayout, fullLayout);
+ return ax;
+ };
+ proto.mockCartesianAxis = function(fullLayout, polarLayout, opts) {
+ var _this = this;
+ var isSmith = _this.isSmith;
+ var axId = opts._id;
+ var ax = Lib.extendFlat({ type: "linear" }, opts);
+ setConvertCartesian(ax, fullLayout);
+ var bboxIndices = {
+ x: [0, 2],
+ y: [1, 3]
+ };
+ ax.setRange = function() {
+ var sectorBBox = _this.sectorBBox;
+ var ind = bboxIndices[axId];
+ var rl = _this.radialAxis._rl;
+ var drl = (rl[1] - rl[0]) / (1 - _this.getHole(polarLayout));
+ ax.range = [sectorBBox[ind[0]] * drl, sectorBBox[ind[1]] * drl];
+ };
+ ax.isPtWithinRange = axId === "x" && !isSmith ? function(d) {
+ return _this.isPtInside(d);
+ } : function() {
+ return true;
+ };
+ ax.setRange();
+ ax.setScale();
+ return ax;
+ };
+ proto.doAutoRange = function(fullLayout, polarLayout) {
+ var _this = this;
+ var gd = _this.gd;
+ var radialAxis = _this.radialAxis;
+ var radialLayout = _this.getRadial(polarLayout);
+ doAutoRange(gd, radialAxis);
+ var rng = radialAxis.range;
+ radialLayout.range = rng.slice();
+ radialLayout._input.range = rng.slice();
+ radialAxis._rl = [
+ radialAxis.r2l(rng[0], null, "gregorian"),
+ radialAxis.r2l(rng[1], null, "gregorian")
+ ];
+ if (radialAxis.minallowed !== void 0) {
+ var minallowed = radialAxis.r2l(radialAxis.minallowed);
+ if (radialAxis._rl[0] > radialAxis._rl[1]) {
+ radialAxis._rl[1] = Math.max(radialAxis._rl[1], minallowed);
+ } else {
+ radialAxis._rl[0] = Math.max(radialAxis._rl[0], minallowed);
+ }
+ }
+ if (radialAxis.maxallowed !== void 0) {
+ var maxallowed = radialAxis.r2l(radialAxis.maxallowed);
+ if (radialAxis._rl[0] < radialAxis._rl[1]) {
+ radialAxis._rl[1] = Math.min(radialAxis._rl[1], maxallowed);
+ } else {
+ radialAxis._rl[0] = Math.min(radialAxis._rl[0], maxallowed);
+ }
+ }
+ };
+ proto.updateRadialAxis = function(fullLayout, polarLayout) {
+ var _this = this;
+ var gd = _this.gd;
+ var layers = _this.layers;
+ var radius = _this.radius;
+ var innerRadius = _this.innerRadius;
+ var cx = _this.cx;
+ var cy = _this.cy;
+ var radialLayout = _this.getRadial(polarLayout);
+ var a0 = mod(_this.getSector(polarLayout)[0], 360);
+ var ax = _this.radialAxis;
+ var hasRoomForIt = innerRadius < radius;
+ var isSmith = _this.isSmith;
+ if (!isSmith) {
+ _this.fillViewInitialKey("radialaxis.angle", radialLayout.angle);
+ _this.fillViewInitialKey("radialaxis.range", ax.range.slice());
+ ax.setGeometry();
+ }
+ if (ax.tickangle === "auto" && (a0 > 90 && a0 <= 270)) {
+ ax.tickangle = 180;
+ }
+ var transFn = isSmith ? function(d) {
+ var t = smithTransform(_this, smith([d.x, 0]));
+ return strTranslate(t[0] - cx, t[1] - cy);
+ } : function(d) {
+ return strTranslate(ax.l2p(d.x) + innerRadius, 0);
+ };
+ var gridPathFn = isSmith ? function(d) {
+ return resistanceArc(_this, d.x, -Infinity, Infinity);
+ } : function(d) {
+ return _this.pathArc(ax.r2p(d.x) + innerRadius);
+ };
+ var newTickLayout = strTickLayout(radialLayout);
+ if (_this.radialTickLayout !== newTickLayout) {
+ layers["radial-axis"].selectAll(".xtick").remove();
+ _this.radialTickLayout = newTickLayout;
+ }
+ if (hasRoomForIt) {
+ ax.setScale();
+ var labelShift = 0;
+ var vals = isSmith ? (ax.tickvals || []).filter(function(x) {
+ return x >= 0;
+ }).map(function(x) {
+ return Axes.tickText(ax, x, true, false);
+ }) : Axes.calcTicks(ax);
+ var valsClipped = isSmith ? vals : Axes.clipEnds(ax, vals);
+ var tickSign = Axes.getTickSigns(ax)[2];
+ if (isSmith) {
+ if (ax.ticks === "top" && ax.side === "bottom" || ax.ticks === "bottom" && ax.side === "top") {
+ tickSign = -tickSign;
+ }
+ if (ax.ticks === "top" && ax.side === "top") labelShift = -ax.ticklen;
+ if (ax.ticks === "bottom" && ax.side === "bottom") labelShift = ax.ticklen;
+ }
+ Axes.drawTicks(gd, ax, {
+ vals,
+ layer: layers["radial-axis"],
+ path: Axes.makeTickPath(ax, 0, tickSign),
+ transFn,
+ crisp: false
+ });
+ Axes.drawGrid(gd, ax, {
+ vals: valsClipped,
+ layer: layers["radial-grid"],
+ path: gridPathFn,
+ transFn: Lib.noop,
+ crisp: false
+ });
+ Axes.drawLabels(gd, ax, {
+ vals,
+ layer: layers["radial-axis"],
+ transFn,
+ labelFns: Axes.makeLabelFns(ax, labelShift)
+ });
+ }
+ var angle = _this.radialAxisAngle = _this.vangles ? rad2deg(snapToVertexAngle(deg2rad(radialLayout.angle), _this.vangles)) : radialLayout.angle;
+ var tLayer = strTranslate(cx, cy);
+ var tLayer2 = tLayer + strRotate(-angle);
+ updateElement(
+ layers["radial-axis"],
+ hasRoomForIt && (radialLayout.showticklabels || radialLayout.ticks),
+ { transform: tLayer2 }
+ );
+ updateElement(
+ layers["radial-grid"],
+ hasRoomForIt && radialLayout.showgrid,
+ { transform: isSmith ? "" : tLayer }
+ );
+ updateElement(
+ layers["radial-line"].select("line"),
+ hasRoomForIt && radialLayout.showline,
+ {
+ x1: isSmith ? -radius : innerRadius,
+ y1: 0,
+ x2: radius,
+ y2: 0,
+ transform: tLayer2
+ }
+ ).attr("stroke-width", radialLayout.linewidth).call(Color2.stroke, radialLayout.linecolor);
+ };
+ proto.updateRadialAxisTitle = function(fullLayout, polarLayout, _angle) {
+ if (this.isSmith) return;
+ var _this = this;
+ var gd = _this.gd;
+ var radius = _this.radius;
+ var cx = _this.cx;
+ var cy = _this.cy;
+ var radialLayout = _this.getRadial(polarLayout);
+ var titleClass = _this.id + "title";
+ var pad = 0;
+ if (radialLayout.title) {
+ var h = Drawing.bBox(_this.layers["radial-axis"].node()).height;
+ var ts = radialLayout.title.font.size;
+ var side = radialLayout.side;
+ pad = side === "top" ? ts : side === "counterclockwise" ? -(h + ts * 0.4) : h + ts * 0.8;
+ }
+ var angle = _angle !== void 0 ? _angle : _this.radialAxisAngle;
+ var angleRad = deg2rad(angle);
+ var cosa = Math.cos(angleRad);
+ var sina = Math.sin(angleRad);
+ var x = cx + radius / 2 * cosa + pad * sina;
+ var y = cy - radius / 2 * sina + pad * cosa;
+ _this.layers["radial-axis-title"] = Titles.draw(gd, titleClass, {
+ propContainer: radialLayout,
+ propName: _this.id + ".radialaxis.title",
+ placeholder: _(gd, "Click to enter radial axis title"),
+ attributes: {
+ x,
+ y,
+ "text-anchor": "middle"
+ },
+ transform: { rotate: -angle }
+ });
+ };
+ proto.updateAngularAxis = function(fullLayout, polarLayout) {
+ var _this = this;
+ var gd = _this.gd;
+ var layers = _this.layers;
+ var radius = _this.radius;
+ var innerRadius = _this.innerRadius;
+ var cx = _this.cx;
+ var cy = _this.cy;
+ var angularLayout = _this.getAngular(polarLayout);
+ var ax = _this.angularAxis;
+ var isSmith = _this.isSmith;
+ if (!isSmith) {
+ _this.fillViewInitialKey("angularaxis.rotation", angularLayout.rotation);
+ ax.setGeometry();
+ ax.setScale();
+ }
+ var t2g = isSmith ? function(d) {
+ var t = smithTransform(_this, smith([0, d.x]));
+ return Math.atan2(t[0] - cx, t[1] - cy) - Math.PI / 2;
+ } : function(d) {
+ return ax.t2g(d.x);
+ };
+ if (ax.type === "linear" && ax.thetaunit === "radians") {
+ ax.tick0 = rad2deg(ax.tick0);
+ ax.dtick = rad2deg(ax.dtick);
+ }
+ var _transFn = function(rad) {
+ return strTranslate(cx + radius * Math.cos(rad), cy - radius * Math.sin(rad));
+ };
+ var transFn = isSmith ? function(d) {
+ var t = smithTransform(_this, smith([0, d.x]));
+ return strTranslate(t[0], t[1]);
+ } : function(d) {
+ return _transFn(t2g(d));
+ };
+ var transFn2 = isSmith ? function(d) {
+ var t = smithTransform(_this, smith([0, d.x]));
+ var rad = Math.atan2(t[0] - cx, t[1] - cy) - Math.PI / 2;
+ return strTranslate(t[0], t[1]) + strRotate(-rad2deg(rad));
+ } : function(d) {
+ var rad = t2g(d);
+ return _transFn(rad) + strRotate(-rad2deg(rad));
+ };
+ var gridPathFn = isSmith ? function(d) {
+ return reactanceArc(_this, d.x, 0, Infinity);
+ } : function(d) {
+ var rad = t2g(d);
+ var cosRad = Math.cos(rad);
+ var sinRad = Math.sin(rad);
+ return "M" + [cx + innerRadius * cosRad, cy - innerRadius * sinRad] + "L" + [cx + radius * cosRad, cy - radius * sinRad];
+ };
+ var out = Axes.makeLabelFns(ax, 0);
+ var labelStandoff = out.labelStandoff;
+ var labelFns = {};
+ labelFns.xFn = function(d) {
+ var rad = t2g(d);
+ return Math.cos(rad) * labelStandoff;
+ };
+ labelFns.yFn = function(d) {
+ var rad = t2g(d);
+ var ff = Math.sin(rad) > 0 ? 0.2 : 1;
+ return -Math.sin(rad) * (labelStandoff + d.fontSize * ff) + Math.abs(Math.cos(rad)) * (d.fontSize * MID_SHIFT);
+ };
+ labelFns.anchorFn = function(d) {
+ var rad = t2g(d);
+ var cos = Math.cos(rad);
+ return Math.abs(cos) < 0.1 ? "middle" : cos > 0 ? "start" : "end";
+ };
+ labelFns.heightFn = function(d, a, h) {
+ var rad = t2g(d);
+ return -0.5 * (1 + Math.sin(rad)) * h;
+ };
+ var newTickLayout = strTickLayout(angularLayout);
+ if (_this.angularTickLayout !== newTickLayout) {
+ layers["angular-axis"].selectAll("." + ax._id + "tick").remove();
+ _this.angularTickLayout = newTickLayout;
+ }
+ var vals = isSmith ? [Infinity].concat(ax.tickvals || []).map(function(x) {
+ return Axes.tickText(ax, x, true, false);
+ }) : Axes.calcTicks(ax);
+ if (isSmith) {
+ vals[0].text = "\u221E";
+ vals[0].fontSize *= 1.75;
+ }
+ var vangles;
+ if (polarLayout.gridshape === "linear") {
+ vangles = vals.map(t2g);
+ if (Lib.angleDelta(vangles[0], vangles[1]) < 0) {
+ vangles = vangles.slice().reverse();
+ }
+ } else {
+ vangles = null;
+ }
+ _this.vangles = vangles;
+ if (ax.type === "category") {
+ vals = vals.filter(function(d) {
+ return Lib.isAngleInsideSector(t2g(d), _this.sectorInRad);
+ });
+ }
+ if (ax.visible) {
+ var tickSign = ax.ticks === "inside" ? -1 : 1;
+ var pad = (ax.linewidth || 1) / 2;
+ Axes.drawTicks(gd, ax, {
+ vals,
+ layer: layers["angular-axis"],
+ path: "M" + tickSign * pad + ",0h" + tickSign * ax.ticklen,
+ transFn: transFn2,
+ crisp: false
+ });
+ Axes.drawGrid(gd, ax, {
+ vals,
+ layer: layers["angular-grid"],
+ path: gridPathFn,
+ transFn: Lib.noop,
+ crisp: false
+ });
+ Axes.drawLabels(gd, ax, {
+ vals,
+ layer: layers["angular-axis"],
+ repositionOnUpdate: true,
+ transFn,
+ labelFns
+ });
+ }
+ updateElement(layers["angular-line"].select("path"), angularLayout.showline, {
+ d: _this.pathSubplot(),
+ transform: strTranslate(cx, cy)
+ }).attr("stroke-width", angularLayout.linewidth).call(Color2.stroke, angularLayout.linecolor);
+ };
+ proto.updateFx = function(fullLayout, polarLayout) {
+ if (!this.gd._context.staticPlot) {
+ var hasDrag = !this.isSmith;
+ if (hasDrag) {
+ this.updateAngularDrag(fullLayout);
+ this.updateRadialDrag(fullLayout, polarLayout, 0);
+ this.updateRadialDrag(fullLayout, polarLayout, 1);
+ }
+ this.updateHoverAndMainDrag(fullLayout);
+ }
+ };
+ proto.updateHoverAndMainDrag = function(fullLayout) {
+ var _this = this;
+ var isSmith = _this.isSmith;
+ var gd = _this.gd;
+ var layers = _this.layers;
+ var zoomlayer = fullLayout._zoomlayer;
+ var MINZOOM = constants.MINZOOM;
+ var OFFEDGE = constants.OFFEDGE;
+ var radius = _this.radius;
+ var innerRadius = _this.innerRadius;
+ var cx = _this.cx;
+ var cy = _this.cy;
+ var cxx = _this.cxx;
+ var cyy = _this.cyy;
+ var sectorInRad = _this.sectorInRad;
+ var vangles = _this.vangles;
+ var radialAxis = _this.radialAxis;
+ var clampTiny = helpers.clampTiny;
+ var findXYatLength = helpers.findXYatLength;
+ var findEnclosingVertexAngles = helpers.findEnclosingVertexAngles;
+ var chw = constants.cornerHalfWidth;
+ var chl = constants.cornerLen / 2;
+ var scaleX;
+ var scaleY;
+ var mainDrag = dragBox.makeDragger(layers, "path", "maindrag", fullLayout.dragmode === false ? "none" : "crosshair");
+ d3.select(mainDrag).attr("d", _this.pathSubplot()).attr("transform", strTranslate(cx, cy));
+ mainDrag.onmousemove = function(evt) {
+ Fx.hover(gd, evt, _this.id);
+ gd._fullLayout._lasthover = mainDrag;
+ gd._fullLayout._hoversubplot = _this.id;
+ };
+ mainDrag.onmouseout = function(evt) {
+ if (gd._dragging) return;
+ dragElement.unhover(gd, evt);
+ };
+ var dragOpts = {
+ element: mainDrag,
+ gd,
+ subplot: _this.id,
+ plotinfo: {
+ id: _this.id,
+ xaxis: _this.xaxis,
+ yaxis: _this.yaxis
+ },
+ xaxes: [_this.xaxis],
+ yaxes: [_this.yaxis]
+ };
+ var x0, y0;
+ var r0, r1;
+ var path0, dimmed, lum;
+ var zb, corners;
+ function norm(x, y) {
+ return Math.sqrt(x * x + y * y);
+ }
+ function xy2r(x, y) {
+ return norm(x - cxx, y - cyy);
+ }
+ function xy2a(x, y) {
+ return Math.atan2(cyy - y, x - cxx);
+ }
+ function ra2xy(r, a) {
+ return [r * Math.cos(a), r * Math.sin(-a)];
+ }
+ function pathCorner(r, a) {
+ if (r === 0) return _this.pathSector(2 * chw);
+ var da = chl / r;
+ var am = a - da;
+ var ap = a + da;
+ var rb = Math.max(0, Math.min(r, radius));
+ var rm = rb - chw;
+ var rp = rb + chw;
+ return "M" + ra2xy(rm, am) + "A" + [rm, rm] + " 0,0,0 " + ra2xy(rm, ap) + "L" + ra2xy(rp, ap) + "A" + [rp, rp] + " 0,0,1 " + ra2xy(rp, am) + "Z";
+ }
+ function pathCornerForPolygons(r, va0, va1) {
+ if (r === 0) return _this.pathSector(2 * chw);
+ var xy0 = ra2xy(r, va0);
+ var xy1 = ra2xy(r, va1);
+ var x = clampTiny((xy0[0] + xy1[0]) / 2);
+ var y = clampTiny((xy0[1] + xy1[1]) / 2);
+ var innerPts, outerPts;
+ if (x && y) {
+ var m = y / x;
+ var mperp = -1 / m;
+ var midPts = findXYatLength(chw, m, x, y);
+ innerPts = findXYatLength(chl, mperp, midPts[0][0], midPts[0][1]);
+ outerPts = findXYatLength(chl, mperp, midPts[1][0], midPts[1][1]);
+ } else {
+ var dx, dy;
+ if (y) {
+ dx = chl;
+ dy = chw;
+ } else {
+ dx = chw;
+ dy = chl;
+ }
+ innerPts = [[x - dx, y - dy], [x + dx, y - dy]];
+ outerPts = [[x - dx, y + dy], [x + dx, y + dy]];
+ }
+ return "M" + innerPts.join("L") + "L" + outerPts.reverse().join("L") + "Z";
+ }
+ function zoomPrep() {
+ r0 = null;
+ r1 = null;
+ path0 = _this.pathSubplot();
+ dimmed = false;
+ var polarLayoutNow = gd._fullLayout[_this.id];
+ lum = tinycolor(polarLayoutNow.bgcolor).getLuminance();
+ zb = dragBox.makeZoombox(zoomlayer, lum, cx, cy, path0);
+ zb.attr("fill-rule", "evenodd");
+ corners = dragBox.makeCorners(zoomlayer, cx, cy);
+ clearOutline(gd);
+ }
+ function clampAndSetR0R1(rr0, rr1) {
+ rr1 = Math.max(Math.min(rr1, radius), innerRadius);
+ if (rr0 < OFFEDGE) rr0 = 0;
+ else if (radius - rr0 < OFFEDGE) rr0 = radius;
+ else if (rr1 < OFFEDGE) rr1 = 0;
+ else if (radius - rr1 < OFFEDGE) rr1 = radius;
+ if (Math.abs(rr1 - rr0) > MINZOOM) {
+ if (rr0 < rr1) {
+ r0 = rr0;
+ r1 = rr1;
+ } else {
+ r0 = rr1;
+ r1 = rr0;
+ }
+ return true;
+ } else {
+ r0 = null;
+ r1 = null;
+ return false;
+ }
+ }
+ function applyZoomMove(path1, cpath) {
+ path1 = path1 || path0;
+ cpath = cpath || "M0,0Z";
+ zb.attr("d", path1);
+ corners.attr("d", cpath);
+ dragBox.transitionZoombox(zb, corners, dimmed, lum);
+ dimmed = true;
+ var updateObj = {};
+ computeZoomUpdates(updateObj);
+ gd.emit("plotly_relayouting", updateObj);
+ }
+ function zoomMove(dx, dy) {
+ dx = dx * scaleX;
+ dy = dy * scaleY;
+ var x1 = x0 + dx;
+ var y1 = y0 + dy;
+ var rr0 = xy2r(x0, y0);
+ var rr1 = Math.min(xy2r(x1, y1), radius);
+ var a0 = xy2a(x0, y0);
+ var path1;
+ var cpath;
+ if (clampAndSetR0R1(rr0, rr1)) {
+ path1 = path0 + _this.pathSector(r1);
+ if (r0) path1 += _this.pathSector(r0);
+ cpath = pathCorner(r0, a0) + pathCorner(r1, a0);
+ }
+ applyZoomMove(path1, cpath);
+ }
+ function findPolygonRadius(x, y, va0, va1) {
+ var xy = helpers.findIntersectionXY(va0, va1, va0, [x - cxx, cyy - y]);
+ return norm(xy[0], xy[1]);
+ }
+ function zoomMoveForPolygons(dx, dy) {
+ var x1 = x0 + dx;
+ var y1 = y0 + dy;
+ var a0 = xy2a(x0, y0);
+ var a1 = xy2a(x1, y1);
+ var vangles0 = findEnclosingVertexAngles(a0, vangles);
+ var vangles1 = findEnclosingVertexAngles(a1, vangles);
+ var rr0 = findPolygonRadius(x0, y0, vangles0[0], vangles0[1]);
+ var rr1 = Math.min(findPolygonRadius(x1, y1, vangles1[0], vangles1[1]), radius);
+ var path1;
+ var cpath;
+ if (clampAndSetR0R1(rr0, rr1)) {
+ path1 = path0 + _this.pathSector(r1);
+ if (r0) path1 += _this.pathSector(r0);
+ cpath = [
+ pathCornerForPolygons(r0, vangles0[0], vangles0[1]),
+ pathCornerForPolygons(r1, vangles0[0], vangles0[1])
+ ].join(" ");
+ }
+ applyZoomMove(path1, cpath);
+ }
+ function zoomDone() {
+ dragBox.removeZoombox(gd);
+ if (r0 === null || r1 === null) return;
+ var updateObj = {};
+ computeZoomUpdates(updateObj);
+ dragBox.showDoubleClickNotifier(gd);
+ Registry.call("_guiRelayout", gd, updateObj);
+ }
+ function computeZoomUpdates(update) {
+ var rl = radialAxis._rl;
+ var m = (rl[1] - rl[0]) / (1 - innerRadius / radius) / radius;
+ var newRng = [
+ rl[0] + (r0 - innerRadius) * m,
+ rl[0] + (r1 - innerRadius) * m
+ ];
+ update[_this.id + ".radialaxis.range"] = newRng;
+ }
+ function zoomClick(numClicks, evt) {
+ var clickMode = gd._fullLayout.clickmode;
+ dragBox.removeZoombox(gd);
+ if (numClicks === 2) {
+ var updateObj = {};
+ for (var k in _this.viewInitial) {
+ updateObj[_this.id + "." + k] = _this.viewInitial[k];
+ }
+ gd.emit("plotly_doubleclick", null);
+ Registry.call("_guiRelayout", gd, updateObj);
+ }
+ if (clickMode.indexOf("select") > -1 && numClicks === 1) {
+ selectOnClick(evt, gd, [_this.xaxis], [_this.yaxis], _this.id, dragOpts);
+ }
+ if (clickMode.indexOf("event") > -1) {
+ Fx.click(gd, evt, _this.id);
+ }
+ }
+ dragOpts.prepFn = function(evt, startX, startY) {
+ var dragModeNow = gd._fullLayout.dragmode;
+ var bbox = mainDrag.getBoundingClientRect();
+ gd._fullLayout._calcInverseTransform(gd);
+ var inverse = gd._fullLayout._invTransform;
+ scaleX = gd._fullLayout._invScaleX;
+ scaleY = gd._fullLayout._invScaleY;
+ var transformedCoords = Lib.apply3DTransform(inverse)(startX - bbox.left, startY - bbox.top);
+ x0 = transformedCoords[0];
+ y0 = transformedCoords[1];
+ if (vangles) {
+ var offset = helpers.findPolygonOffset(radius, sectorInRad[0], sectorInRad[1], vangles);
+ x0 += cxx + offset[0];
+ y0 += cyy + offset[1];
+ }
+ switch (dragModeNow) {
+ case "zoom":
+ dragOpts.clickFn = zoomClick;
+ if (!isSmith) {
+ if (vangles) {
+ dragOpts.moveFn = zoomMoveForPolygons;
+ } else {
+ dragOpts.moveFn = zoomMove;
+ }
+ dragOpts.doneFn = zoomDone;
+ zoomPrep(evt, startX, startY);
+ }
+ break;
+ case "select":
+ case "lasso":
+ prepSelect(evt, startX, startY, dragOpts, dragModeNow);
+ break;
+ }
+ };
+ dragElement.init(dragOpts);
+ };
+ proto.updateRadialDrag = function(fullLayout, polarLayout, rngIndex) {
+ var _this = this;
+ var gd = _this.gd;
+ var layers = _this.layers;
+ var radius = _this.radius;
+ var innerRadius = _this.innerRadius;
+ var cx = _this.cx;
+ var cy = _this.cy;
+ var radialAxis = _this.radialAxis;
+ var bl = constants.radialDragBoxSize;
+ var bl2 = bl / 2;
+ if (!radialAxis.visible) return;
+ var angle0 = deg2rad(_this.radialAxisAngle);
+ var rl = radialAxis._rl;
+ var rl0 = rl[0];
+ var rl1 = rl[1];
+ var rbase = rl[rngIndex];
+ var m = 0.75 * (rl[1] - rl[0]) / (1 - _this.getHole(polarLayout)) / radius;
+ var tx, ty, className;
+ if (rngIndex) {
+ tx = cx + (radius + bl2) * Math.cos(angle0);
+ ty = cy - (radius + bl2) * Math.sin(angle0);
+ className = "radialdrag";
+ } else {
+ tx = cx + (innerRadius - bl2) * Math.cos(angle0);
+ ty = cy - (innerRadius - bl2) * Math.sin(angle0);
+ className = "radialdrag-inner";
+ }
+ var radialDrag = dragBox.makeRectDragger(layers, className, "crosshair", -bl2, -bl2, bl, bl);
+ var dragOpts = { element: radialDrag, gd };
+ if (fullLayout.dragmode === false) {
+ dragOpts.dragmode = false;
+ }
+ updateElement(d3.select(radialDrag), radialAxis.visible && innerRadius < radius, {
+ transform: strTranslate(tx, ty)
+ });
+ var moveFn2;
+ var angle1;
+ var rprime;
+ function moveFn(dx, dy) {
+ if (moveFn2) {
+ moveFn2(dx, dy);
+ } else {
+ var dvec = [dx, -dy];
+ var rvec = [Math.cos(angle0), Math.sin(angle0)];
+ var comp = Math.abs(Lib.dot(dvec, rvec) / Math.sqrt(Lib.dot(dvec, dvec)));
+ if (!isNaN(comp)) {
+ moveFn2 = comp < 0.5 ? rotateMove : rerangeMove;
+ }
+ }
+ var update = {};
+ computeRadialAxisUpdates(update);
+ gd.emit("plotly_relayouting", update);
+ }
+ function computeRadialAxisUpdates(update) {
+ if (angle1 !== null) {
+ update[_this.id + ".radialaxis.angle"] = angle1;
+ } else if (rprime !== null) {
+ update[_this.id + ".radialaxis.range[" + rngIndex + "]"] = rprime;
+ }
+ }
+ function doneFn() {
+ if (angle1 !== null) {
+ Registry.call("_guiRelayout", gd, _this.id + ".radialaxis.angle", angle1);
+ } else if (rprime !== null) {
+ Registry.call("_guiRelayout", gd, _this.id + ".radialaxis.range[" + rngIndex + "]", rprime);
+ }
+ }
+ function rotateMove(dx, dy) {
+ if (rngIndex === 0) return;
+ var x1 = tx + dx;
+ var y1 = ty + dy;
+ angle1 = Math.atan2(cy - y1, x1 - cx);
+ if (_this.vangles) angle1 = snapToVertexAngle(angle1, _this.vangles);
+ angle1 = rad2deg(angle1);
+ var transform = strTranslate(cx, cy) + strRotate(-angle1);
+ layers["radial-axis"].attr("transform", transform);
+ layers["radial-line"].select("line").attr("transform", transform);
+ var fullLayoutNow = _this.gd._fullLayout;
+ var polarLayoutNow = fullLayoutNow[_this.id];
+ _this.updateRadialAxisTitle(fullLayoutNow, polarLayoutNow, angle1);
+ }
+ function rerangeMove(dx, dy) {
+ var dr = Lib.dot([dx, -dy], [Math.cos(angle0), Math.sin(angle0)]);
+ rprime = rbase - m * dr;
+ if (m > 0 !== (rngIndex ? rprime > rl0 : rprime < rl1)) {
+ rprime = null;
+ return;
+ }
+ var fullLayoutNow = gd._fullLayout;
+ var polarLayoutNow = fullLayoutNow[_this.id];
+ radialAxis.range[rngIndex] = rprime;
+ radialAxis._rl[rngIndex] = rprime;
+ _this.updateRadialAxis(fullLayoutNow, polarLayoutNow);
+ _this.xaxis.setRange();
+ _this.xaxis.setScale();
+ _this.yaxis.setRange();
+ _this.yaxis.setScale();
+ var hasRegl = false;
+ for (var traceType in _this.traceHash) {
+ var moduleCalcData = _this.traceHash[traceType];
+ var moduleCalcDataVisible = Lib.filterVisible(moduleCalcData);
+ var _module = moduleCalcData[0][0].trace._module;
+ _module.plot(gd, _this, moduleCalcDataVisible, polarLayoutNow);
+ if (Registry.traceIs(traceType, "gl") && moduleCalcDataVisible.length) hasRegl = true;
+ }
+ if (hasRegl) {
+ clearGlCanvases(gd);
+ redrawReglTraces(gd);
+ }
+ }
+ dragOpts.prepFn = function() {
+ moveFn2 = null;
+ angle1 = null;
+ rprime = null;
+ dragOpts.moveFn = moveFn;
+ dragOpts.doneFn = doneFn;
+ clearOutline(gd);
+ };
+ dragOpts.clampFn = function(dx, dy) {
+ if (Math.sqrt(dx * dx + dy * dy) < constants.MINDRAG) {
+ dx = 0;
+ dy = 0;
+ }
+ return [dx, dy];
+ };
+ dragElement.init(dragOpts);
+ };
+ proto.updateAngularDrag = function(fullLayout) {
+ var _this = this;
+ var gd = _this.gd;
+ var layers = _this.layers;
+ var radius = _this.radius;
+ var angularAxis = _this.angularAxis;
+ var cx = _this.cx;
+ var cy = _this.cy;
+ var cxx = _this.cxx;
+ var cyy = _this.cyy;
+ var dbs = constants.angularDragBoxSize;
+ var angularDrag = dragBox.makeDragger(layers, "path", "angulardrag", fullLayout.dragmode === false ? "none" : "move");
+ var dragOpts = { element: angularDrag, gd };
+ if (fullLayout.dragmode === false) {
+ dragOpts.dragmode = false;
+ } else {
+ d3.select(angularDrag).attr("d", _this.pathAnnulus(radius, radius + dbs)).attr("transform", strTranslate(cx, cy)).call(setCursor, "move");
+ }
+ function xy2a(x, y) {
+ return Math.atan2(cyy + dbs - y, x - cxx - dbs);
+ }
+ var scatterTraces = layers.frontplot.select(".scatterlayer").selectAll(".trace");
+ var scatterPoints = scatterTraces.selectAll(".point");
+ var scatterTextPoints = scatterTraces.selectAll(".textpoint");
+ var x0, y0;
+ var rot0, rot1;
+ var rrot1;
+ var a0;
+ function moveFn(dx, dy) {
+ var fullLayoutNow = _this.gd._fullLayout;
+ var polarLayoutNow = fullLayoutNow[_this.id];
+ var x1 = x0 + dx * fullLayout._invScaleX;
+ var y1 = y0 + dy * fullLayout._invScaleY;
+ var a1 = xy2a(x1, y1);
+ var da = rad2deg(a1 - a0);
+ rot1 = rot0 + da;
+ layers.frontplot.attr(
+ "transform",
+ strTranslate(_this.xOffset2, _this.yOffset2) + strRotate([-da, cxx, cyy])
+ );
+ if (_this.vangles) {
+ rrot1 = _this.radialAxisAngle + da;
+ var trans = strTranslate(cx, cy) + strRotate(-da);
+ var trans2 = strTranslate(cx, cy) + strRotate(-rrot1);
+ layers.bg.attr("transform", trans);
+ layers["radial-grid"].attr("transform", trans);
+ layers["radial-axis"].attr("transform", trans2);
+ layers["radial-line"].select("line").attr("transform", trans2);
+ _this.updateRadialAxisTitle(fullLayoutNow, polarLayoutNow, rrot1);
+ } else {
+ _this.clipPaths.forTraces.select("path").attr(
+ "transform",
+ strTranslate(cxx, cyy) + strRotate(da)
+ );
+ }
+ scatterPoints.each(function() {
+ var sel = d3.select(this);
+ var xy = Drawing.getTranslate(sel);
+ sel.attr("transform", strTranslate(xy.x, xy.y) + strRotate([da]));
+ });
+ scatterTextPoints.each(function() {
+ var sel = d3.select(this);
+ var tx = sel.select("text");
+ var xy = Drawing.getTranslate(sel);
+ sel.attr("transform", strRotate([da, tx.attr("x"), tx.attr("y")]) + strTranslate(xy.x, xy.y));
+ });
+ angularAxis.rotation = Lib.modHalf(rot1, 360);
+ _this.updateAngularAxis(fullLayoutNow, polarLayoutNow);
+ if (_this._hasClipOnAxisFalse && !Lib.isFullCircle(_this.sectorInRad)) {
+ scatterTraces.call(Drawing.hideOutsideRangePoints, _this);
+ }
+ var hasRegl = false;
+ for (var traceType in _this.traceHash) {
+ if (Registry.traceIs(traceType, "gl")) {
+ var moduleCalcData = _this.traceHash[traceType];
+ var moduleCalcDataVisible = Lib.filterVisible(moduleCalcData);
+ var _module = moduleCalcData[0][0].trace._module;
+ _module.plot(gd, _this, moduleCalcDataVisible, polarLayoutNow);
+ if (moduleCalcDataVisible.length) hasRegl = true;
+ }
+ }
+ if (hasRegl) {
+ clearGlCanvases(gd);
+ redrawReglTraces(gd);
+ }
+ var update = {};
+ computeRotationUpdates(update);
+ gd.emit("plotly_relayouting", update);
+ }
+ function computeRotationUpdates(updateObj) {
+ updateObj[_this.id + ".angularaxis.rotation"] = rot1;
+ if (_this.vangles) {
+ updateObj[_this.id + ".radialaxis.angle"] = rrot1;
+ }
+ }
+ function doneFn() {
+ scatterTextPoints.select("text").attr("transform", null);
+ var updateObj = {};
+ computeRotationUpdates(updateObj);
+ Registry.call("_guiRelayout", gd, updateObj);
+ }
+ dragOpts.prepFn = function(evt, startX, startY) {
+ var polarLayoutNow = fullLayout[_this.id];
+ rot0 = polarLayoutNow.angularaxis.rotation;
+ var bbox = angularDrag.getBoundingClientRect();
+ x0 = startX - bbox.left;
+ y0 = startY - bbox.top;
+ gd._fullLayout._calcInverseTransform(gd);
+ var transformedCoords = Lib.apply3DTransform(fullLayout._invTransform)(x0, y0);
+ x0 = transformedCoords[0];
+ y0 = transformedCoords[1];
+ a0 = xy2a(x0, y0);
+ dragOpts.moveFn = moveFn;
+ dragOpts.doneFn = doneFn;
+ clearOutline(gd);
+ };
+ if (_this.vangles && !Lib.isFullCircle(_this.sectorInRad)) {
+ dragOpts.prepFn = Lib.noop;
+ setCursor(d3.select(angularDrag), null);
+ }
+ dragElement.init(dragOpts);
+ };
+ proto.isPtInside = function(d) {
+ if (this.isSmith) return true;
+ var sectorInRad = this.sectorInRad;
+ var vangles = this.vangles;
+ var thetag = this.angularAxis.c2g(d.theta);
+ var radialAxis = this.radialAxis;
+ var r = radialAxis.c2l(d.r);
+ var rl = radialAxis._rl;
+ var fn = vangles ? helpers.isPtInsidePolygon : Lib.isPtInsideSector;
+ return fn(r, thetag, rl, sectorInRad, vangles);
+ };
+ proto.pathArc = function(r) {
+ var sectorInRad = this.sectorInRad;
+ var vangles = this.vangles;
+ var fn = vangles ? helpers.pathPolygon : Lib.pathArc;
+ return fn(r, sectorInRad[0], sectorInRad[1], vangles);
+ };
+ proto.pathSector = function(r) {
+ var sectorInRad = this.sectorInRad;
+ var vangles = this.vangles;
+ var fn = vangles ? helpers.pathPolygon : Lib.pathSector;
+ return fn(r, sectorInRad[0], sectorInRad[1], vangles);
+ };
+ proto.pathAnnulus = function(r0, r1) {
+ var sectorInRad = this.sectorInRad;
+ var vangles = this.vangles;
+ var fn = vangles ? helpers.pathPolygonAnnulus : Lib.pathAnnulus;
+ return fn(r0, r1, sectorInRad[0], sectorInRad[1], vangles);
+ };
+ proto.pathSubplot = function() {
+ var r0 = this.innerRadius;
+ var r1 = this.radius;
+ return r0 ? this.pathAnnulus(r0, r1) : this.pathSector(r1);
+ };
+ proto.fillViewInitialKey = function(key, val) {
+ if (!(key in this.viewInitial)) {
+ this.viewInitial[key] = val;
+ }
+ };
+ function strTickLayout(axLayout) {
+ var out = axLayout.ticks + String(axLayout.ticklen) + String(axLayout.showticklabels);
+ if ("side" in axLayout) out += axLayout.side;
+ return out;
+ }
+ function computeSectorBBox(sector) {
+ var s0 = sector[0];
+ var s1 = sector[1];
+ var arc = s1 - s0;
+ var a0 = mod(s0, 360);
+ var a1 = a0 + arc;
+ var ax0 = Math.cos(deg2rad(a0));
+ var ay0 = Math.sin(deg2rad(a0));
+ var ax1 = Math.cos(deg2rad(a1));
+ var ay1 = Math.sin(deg2rad(a1));
+ var x0, y0, x1, y1;
+ if (a0 <= 90 && a1 >= 90 || a0 > 90 && a1 >= 450) {
+ y1 = 1;
+ } else if (ay0 <= 0 && ay1 <= 0) {
+ y1 = 0;
+ } else {
+ y1 = Math.max(ay0, ay1);
+ }
+ if (a0 <= 180 && a1 >= 180 || a0 > 180 && a1 >= 540) {
+ x0 = -1;
+ } else if (ax0 >= 0 && ax1 >= 0) {
+ x0 = 0;
+ } else {
+ x0 = Math.min(ax0, ax1);
+ }
+ if (a0 <= 270 && a1 >= 270 || a0 > 270 && a1 >= 630) {
+ y0 = -1;
+ } else if (ay0 >= 0 && ay1 >= 0) {
+ y0 = 0;
+ } else {
+ y0 = Math.min(ay0, ay1);
+ }
+ if (a1 >= 360) {
+ x1 = 1;
+ } else if (ax0 <= 0 && ax1 <= 0) {
+ x1 = 0;
+ } else {
+ x1 = Math.max(ax0, ax1);
+ }
+ return [x0, y0, x1, y1];
+ }
+ function snapToVertexAngle(a, vangles) {
+ var fn = function(v) {
+ return Lib.angleDist(a, v);
+ };
+ var ind = Lib.findIndexOfMin(vangles, fn);
+ return vangles[ind];
+ }
+ function updateElement(sel, showAttr, attrs) {
+ if (showAttr) {
+ sel.attr("display", null);
+ sel.attr(attrs);
+ } else if (sel) {
+ sel.attr("display", "none");
+ }
+ return sel;
+ }
+ }
+ });
+
+ // src/plots/polar/layout_attributes.js
+ var require_layout_attributes21 = __commonJS({
+ "src/plots/polar/layout_attributes.js"(exports, module) {
+ "use strict";
+ var colorAttrs = require_attributes3();
+ var axesAttrs = require_layout_attributes4();
+ var domainAttrs = require_domain().attributes;
+ var extendFlat = require_lib().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var axisLineGridAttr = overrideAll({
+ color: axesAttrs.color,
+ showline: extendFlat({}, axesAttrs.showline, { dflt: true }),
+ linecolor: axesAttrs.linecolor,
+ linewidth: axesAttrs.linewidth,
+ showgrid: extendFlat({}, axesAttrs.showgrid, { dflt: true }),
+ gridcolor: axesAttrs.gridcolor,
+ gridwidth: axesAttrs.gridwidth,
+ griddash: axesAttrs.griddash
+ // TODO add spike* attributes down the road
+ // should we add zeroline* attributes?
+ }, "plot", "from-root");
+ var axisTickAttrs = overrideAll({
+ tickmode: axesAttrs.minor.tickmode,
+ nticks: axesAttrs.nticks,
+ tick0: axesAttrs.tick0,
+ dtick: axesAttrs.dtick,
+ tickvals: axesAttrs.tickvals,
+ ticktext: axesAttrs.ticktext,
+ ticks: axesAttrs.ticks,
+ ticklen: axesAttrs.ticklen,
+ tickwidth: axesAttrs.tickwidth,
+ tickcolor: axesAttrs.tickcolor,
+ ticklabelstep: axesAttrs.ticklabelstep,
+ showticklabels: axesAttrs.showticklabels,
+ labelalias: axesAttrs.labelalias,
+ showtickprefix: axesAttrs.showtickprefix,
+ tickprefix: axesAttrs.tickprefix,
+ showticksuffix: axesAttrs.showticksuffix,
+ ticksuffix: axesAttrs.ticksuffix,
+ showexponent: axesAttrs.showexponent,
+ exponentformat: axesAttrs.exponentformat,
+ minexponent: axesAttrs.minexponent,
+ separatethousands: axesAttrs.separatethousands,
+ tickfont: axesAttrs.tickfont,
+ tickangle: axesAttrs.tickangle,
+ tickformat: axesAttrs.tickformat,
+ tickformatstops: axesAttrs.tickformatstops,
+ layer: axesAttrs.layer
+ }, "plot", "from-root");
+ var radialAxisAttrs = {
+ visible: extendFlat({}, axesAttrs.visible, { dflt: true }),
+ type: extendFlat({}, axesAttrs.type, {
+ values: ["-", "linear", "log", "date", "category"]
+ }),
+ autotypenumbers: axesAttrs.autotypenumbers,
+ autorangeoptions: {
+ minallowed: axesAttrs.autorangeoptions.minallowed,
+ maxallowed: axesAttrs.autorangeoptions.maxallowed,
+ clipmin: axesAttrs.autorangeoptions.clipmin,
+ clipmax: axesAttrs.autorangeoptions.clipmax,
+ include: axesAttrs.autorangeoptions.include,
+ editType: "plot"
+ },
+ autorange: extendFlat({}, axesAttrs.autorange, { editType: "plot" }),
+ rangemode: {
+ valType: "enumerated",
+ values: ["tozero", "nonnegative", "normal"],
+ dflt: "tozero",
+ editType: "calc"
+ },
+ minallowed: extendFlat({}, axesAttrs.minallowed, { editType: "plot" }),
+ maxallowed: extendFlat({}, axesAttrs.maxallowed, { editType: "plot" }),
+ range: extendFlat({}, axesAttrs.range, {
+ items: [
+ { valType: "any", editType: "plot", impliedEdits: { "^autorange": false } },
+ { valType: "any", editType: "plot", impliedEdits: { "^autorange": false } }
+ ],
+ editType: "plot"
+ }),
+ categoryorder: axesAttrs.categoryorder,
+ categoryarray: axesAttrs.categoryarray,
+ angle: {
+ valType: "angle",
+ editType: "plot"
+ },
+ autotickangles: axesAttrs.autotickangles,
+ side: {
+ valType: "enumerated",
+ // TODO add 'center' for `showline: false` radial axes
+ values: ["clockwise", "counterclockwise"],
+ dflt: "clockwise",
+ editType: "plot"
+ },
+ title: {
+ // radial title is not gui-editable at the moment,
+ // so it needs dflt: '', similar to carpet axes.
+ text: extendFlat({}, axesAttrs.title.text, { editType: "plot", dflt: "" }),
+ font: extendFlat({}, axesAttrs.title.font, { editType: "plot" }),
+ // TODO
+ // - might need a 'titleside' and even 'titledirection' down the road
+ // - what about standoff ??
+ editType: "plot"
+ },
+ hoverformat: axesAttrs.hoverformat,
+ uirevision: {
+ valType: "any",
+ editType: "none"
+ },
+ editType: "calc"
+ };
+ extendFlat(
+ radialAxisAttrs,
+ // N.B. radialaxis grid lines are circular,
+ // but radialaxis lines are straight from circle center to outer bound
+ axisLineGridAttr,
+ axisTickAttrs
+ );
+ var angularAxisAttrs = {
+ visible: extendFlat({}, axesAttrs.visible, { dflt: true }),
+ type: {
+ valType: "enumerated",
+ // 'linear' should maybe be called 'angle' or 'angular' here
+ // to make clear that axis here is periodic and more tightly match
+ // `thetaunit`?
+ //
+ // skip 'date' for first push
+ // no 'log' for now
+ values: ["-", "linear", "category"],
+ dflt: "-",
+ editType: "calc",
+ _noTemplating: true
+ },
+ autotypenumbers: axesAttrs.autotypenumbers,
+ categoryorder: axesAttrs.categoryorder,
+ categoryarray: axesAttrs.categoryarray,
+ thetaunit: {
+ valType: "enumerated",
+ values: ["radians", "degrees"],
+ dflt: "degrees",
+ editType: "calc"
+ },
+ period: {
+ valType: "number",
+ editType: "calc",
+ min: 0
+ // Examples for date axes:
+ //
+ // - period that equals the timeseries length
+ // http://flowingdata.com/2017/01/24/one-dataset-visualized-25-ways/18-polar-coordinates/
+ // - and 1-year periods (focusing on seasonal change0
+ // http://otexts.org/fpp2/seasonal-plots.html
+ // https://blogs.scientificamerican.com/sa-visual/why-are-so-many-babies-born-around-8-00-a-m/
+ // http://www.seasonaladjustment.com/2012/09/05/clock-plot-visualising-seasonality-using-r-and-ggplot2-part-3/
+ // https://i.pinimg.com/736x/49/b9/72/49b972ccb3206a1a6d6f870dac543280.jpg
+ // https://www.climate-lab-book.ac.uk/spirals/
+ },
+ direction: {
+ valType: "enumerated",
+ values: ["counterclockwise", "clockwise"],
+ dflt: "counterclockwise",
+ editType: "calc"
+ },
+ rotation: {
+ valType: "angle",
+ editType: "calc"
+ },
+ hoverformat: axesAttrs.hoverformat,
+ uirevision: {
+ valType: "any",
+ editType: "none"
+ },
+ editType: "calc"
+ };
+ extendFlat(
+ angularAxisAttrs,
+ // N.B. angular grid lines are straight lines from circle center to outer bound
+ // the angular line is circular bounding the polar plot area.
+ axisLineGridAttr,
+ // N.B. ticksuffix defaults to '°' for angular axes with `thetaunit: 'degrees'`
+ axisTickAttrs
+ );
+ module.exports = {
+ // TODO for x/y/zoom system for paper-based zooming:
+ // x: {},
+ // y: {},
+ // zoom: {},
+ domain: domainAttrs({ name: "polar", editType: "plot" }),
+ sector: {
+ valType: "info_array",
+ items: [
+ { valType: "number", editType: "plot" },
+ { valType: "number", editType: "plot" }
+ ],
+ dflt: [0, 360],
+ editType: "plot"
+ },
+ hole: {
+ valType: "number",
+ min: 0,
+ max: 1,
+ dflt: 0,
+ editType: "plot"
+ },
+ bgcolor: {
+ valType: "color",
+ editType: "plot",
+ dflt: colorAttrs.background
+ },
+ radialaxis: radialAxisAttrs,
+ angularaxis: angularAxisAttrs,
+ gridshape: {
+ valType: "enumerated",
+ values: ["circular", "linear"],
+ dflt: "circular",
+ editType: "plot"
+ },
+ // TODO maybe?
+ // annotations:
+ uirevision: {
+ valType: "any",
+ editType: "none"
+ },
+ editType: "calc"
+ };
+ }
+ });
+
+ // src/plots/polar/layout_defaults.js
+ var require_layout_defaults19 = __commonJS({
+ "src/plots/polar/layout_defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var Color2 = require_color();
+ var Template = require_plot_template();
+ var handleSubplotDefaults = require_subplot_defaults();
+ var getSubplotData = require_get_data().getSubplotData;
+ var handleTickValueDefaults = require_tick_value_defaults();
+ var handleTickMarkDefaults = require_tick_mark_defaults();
+ var handleTickLabelDefaults = require_tick_label_defaults();
+ var handlePrefixSuffixDefaults = require_prefix_suffix_defaults();
+ var handleCategoryOrderDefaults = require_category_order_defaults();
+ var handleLineGridDefaults = require_line_grid_defaults();
+ var handleAutorangeOptionsDefaults = require_autorange_options_defaults();
+ var autoType = require_axis_autotype();
+ var layoutAttributes = require_layout_attributes21();
+ var setConvert = require_set_convert3();
+ var constants = require_constants33();
+ var axisNames = constants.axisNames;
+ function handleDefaults(contIn, contOut, coerce, opts) {
+ var bgColor = coerce("bgcolor");
+ opts.bgColor = Color2.combine(bgColor, opts.paper_bgcolor);
+ var sector = coerce("sector");
+ coerce("hole");
+ var subplotData = getSubplotData(opts.fullData, constants.name, opts.id);
+ var layoutOut = opts.layoutOut;
+ var axName;
+ function coerceAxis(attr, dflt) {
+ return coerce(axName + "." + attr, dflt);
+ }
+ for (var i = 0; i < axisNames.length; i++) {
+ axName = axisNames[i];
+ if (!Lib.isPlainObject(contIn[axName])) {
+ contIn[axName] = {};
+ }
+ var axIn = contIn[axName];
+ var axOut = Template.newContainer(contOut, axName);
+ axOut._id = axOut._name = axName;
+ axOut._attr = opts.id + "." + axName;
+ axOut._traceIndices = subplotData.map(function(t) {
+ return t.index;
+ });
+ var dataAttr = constants.axisName2dataArray[axName];
+ var axType = handleAxisTypeDefaults(axIn, axOut, coerceAxis, subplotData, dataAttr, opts);
+ handleCategoryOrderDefaults(axIn, axOut, coerceAxis, {
+ axData: subplotData,
+ dataAttr
+ });
+ var visible = coerceAxis("visible");
+ setConvert(axOut, contOut, layoutOut);
+ coerceAxis("uirevision", contOut.uirevision);
+ axOut._m = 1;
+ switch (axName) {
+ case "radialaxis":
+ coerceAxis("minallowed");
+ coerceAxis("maxallowed");
+ var range = coerceAxis("range");
+ var autorangeDflt = axOut.getAutorangeDflt(range);
+ var autorange = coerceAxis("autorange", autorangeDflt);
+ var shouldAutorange;
+ if (range && (range[0] === null && range[1] === null || (range[0] === null || range[1] === null) && (autorange === "reversed" || autorange === true) || range[0] !== null && (autorange === "min" || autorange === "max reversed") || range[1] !== null && (autorange === "max" || autorange === "min reversed"))) {
+ range = void 0;
+ delete axOut.range;
+ axOut.autorange = true;
+ shouldAutorange = true;
+ }
+ if (!shouldAutorange) {
+ autorangeDflt = axOut.getAutorangeDflt(range);
+ autorange = coerceAxis("autorange", autorangeDflt);
+ }
+ axIn.autorange = autorange;
+ if (autorange) {
+ handleAutorangeOptionsDefaults(coerceAxis, autorange, range);
+ if (axType === "linear" || axType === "-") coerceAxis("rangemode");
+ if (axOut.isReversed()) axOut._m = -1;
+ }
+ axOut.cleanRange("range", { dfltRange: [0, 1] });
+ break;
+ case "angularaxis":
+ if (axType === "date") {
+ Lib.log("Polar plots do not support date angular axes yet.");
+ for (var j = 0; j < subplotData.length; j++) {
+ subplotData[j].visible = false;
+ }
+ axType = axIn.type = axOut.type = "linear";
+ }
+ if (axType === "linear") {
+ coerceAxis("thetaunit");
+ } else {
+ coerceAxis("period");
+ }
+ var direction = coerceAxis("direction");
+ coerceAxis("rotation", { counterclockwise: 0, clockwise: 90 }[direction]);
+ break;
+ }
+ handlePrefixSuffixDefaults(axIn, axOut, coerceAxis, axOut.type, {
+ tickSuffixDflt: axOut.thetaunit === "degrees" ? "\xB0" : void 0
+ });
+ if (visible) {
+ var dfltColor;
+ var dfltFontColor;
+ var dfltFontSize;
+ var dfltFontFamily;
+ var dfltFontWeight;
+ var dfltFontStyle;
+ var dfltFontVariant;
+ var dfltFontTextcase;
+ var dfltFontLineposition;
+ var dfltFontShadow;
+ var font = opts.font || {};
+ dfltColor = coerceAxis("color");
+ dfltFontColor = dfltColor === axIn.color ? dfltColor : font.color;
+ dfltFontSize = font.size;
+ dfltFontFamily = font.family;
+ dfltFontWeight = font.weight;
+ dfltFontStyle = font.style;
+ dfltFontVariant = font.variant;
+ dfltFontTextcase = font.textcase;
+ dfltFontLineposition = font.lineposition;
+ dfltFontShadow = font.shadow;
+ handleTickValueDefaults(axIn, axOut, coerceAxis, axOut.type);
+ handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
+ font: {
+ weight: dfltFontWeight,
+ style: dfltFontStyle,
+ variant: dfltFontVariant,
+ textcase: dfltFontTextcase,
+ lineposition: dfltFontLineposition,
+ shadow: dfltFontShadow,
+ color: dfltFontColor,
+ size: dfltFontSize,
+ family: dfltFontFamily
+ },
+ noAutotickangles: axName === "angularaxis",
+ noTicklabelshift: true,
+ noTicklabelstandoff: true
+ });
+ handleTickMarkDefaults(axIn, axOut, coerceAxis, { outerTicks: true });
+ handleLineGridDefaults(axIn, axOut, coerceAxis, {
+ dfltColor,
+ bgColor: opts.bgColor,
+ // default grid color is darker here (60%, vs cartesian default ~91%)
+ // because the grid is not square so the eye needs heavier cues to follow
+ blend: 60,
+ showLine: true,
+ showGrid: true,
+ noZeroLine: true,
+ attributes: layoutAttributes[axName]
+ });
+ coerceAxis("layer");
+ if (axName === "radialaxis") {
+ coerceAxis("side");
+ coerceAxis("angle", sector[0]);
+ coerceAxis("title.text");
+ Lib.coerceFont(coerceAxis, "title.font", {
+ weight: dfltFontWeight,
+ style: dfltFontStyle,
+ variant: dfltFontVariant,
+ textcase: dfltFontTextcase,
+ lineposition: dfltFontLineposition,
+ shadow: dfltFontShadow,
+ color: dfltFontColor,
+ size: Lib.bigFont(dfltFontSize),
+ family: dfltFontFamily
+ });
+ }
+ }
+ if (axType !== "category") coerceAxis("hoverformat");
+ axOut._input = axIn;
+ }
+ if (contOut.angularaxis.type === "category") {
+ coerce("gridshape");
+ }
+ }
+ function handleAxisTypeDefaults(axIn, axOut, coerce, subplotData, dataAttr, options) {
+ var autotypenumbers = coerce("autotypenumbers", options.autotypenumbersDflt);
+ var axType = coerce("type");
+ if (axType === "-") {
+ var trace;
+ for (var i = 0; i < subplotData.length; i++) {
+ if (subplotData[i].visible) {
+ trace = subplotData[i];
+ break;
+ }
+ }
+ if (trace && trace[dataAttr]) {
+ axOut.type = autoType(trace[dataAttr], "gregorian", {
+ noMultiCategory: true,
+ autotypenumbers
+ });
+ }
+ if (axOut.type === "-") {
+ axOut.type = "linear";
+ } else {
+ axIn.type = axOut.type;
+ }
+ }
+ return axOut.type;
+ }
+ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
+ handleSubplotDefaults(layoutIn, layoutOut, fullData, {
+ type: constants.name,
+ attributes: layoutAttributes,
+ handleDefaults,
+ font: layoutOut.font,
+ autotypenumbersDflt: layoutOut.autotypenumbers,
+ paper_bgcolor: layoutOut.paper_bgcolor,
+ fullData,
+ layoutOut
+ });
+ };
+ }
+ });
+
+ // src/plots/polar/index.js
+ var require_polar2 = __commonJS({
+ "src/plots/polar/index.js"(exports, module) {
+ "use strict";
+ var getSubplotCalcData = require_get_data().getSubplotCalcData;
+ var counterRegex = require_lib().counterRegex;
+ var createPolar = require_polar();
+ var constants = require_constants33();
+ var attr = constants.attr;
+ var name2 = constants.name;
+ var counter = counterRegex(name2);
+ var attributes = {};
+ attributes[attr] = {
+ valType: "subplotid",
+ dflt: name2,
+ editType: "calc"
+ };
+ function plot(gd) {
+ var fullLayout = gd._fullLayout;
+ var calcData = gd.calcdata;
+ var subplotIds = fullLayout._subplots[name2];
+ for (var i = 0; i < subplotIds.length; i++) {
+ var id = subplotIds[i];
+ var subplotCalcData = getSubplotCalcData(calcData, name2, id);
+ var subplot = fullLayout[id]._subplot;
+ if (!subplot) {
+ subplot = createPolar(gd, id);
+ fullLayout[id]._subplot = subplot;
+ }
+ subplot.plot(subplotCalcData, fullLayout, gd._promises);
+ }
+ }
+ function clean(newFullData, newFullLayout, oldFullData, oldFullLayout) {
+ var oldIds = oldFullLayout._subplots[name2] || [];
+ var hadGl = oldFullLayout._has && oldFullLayout._has("gl");
+ var hasGl = newFullLayout._has && newFullLayout._has("gl");
+ var mustCleanScene = hadGl && !hasGl;
+ for (var i = 0; i < oldIds.length; i++) {
+ var id = oldIds[i];
+ var oldSubplot = oldFullLayout[id]._subplot;
+ if (!newFullLayout[id] && !!oldSubplot) {
+ oldSubplot.framework.remove();
+ oldSubplot.layers["radial-axis-title"].remove();
+ for (var k in oldSubplot.clipPaths) {
+ oldSubplot.clipPaths[k].remove();
+ }
+ }
+ if (mustCleanScene && oldSubplot._scene) {
+ oldSubplot._scene.destroy();
+ oldSubplot._scene = null;
+ }
+ }
+ }
+ module.exports = {
+ attr,
+ name: name2,
+ idRoot: name2,
+ idRegex: counter,
+ attrRegex: counter,
+ attributes,
+ layoutAttributes: require_layout_attributes21(),
+ supplyLayoutDefaults: require_layout_defaults19(),
+ plot,
+ clean,
+ toSVG: require_cartesian().toSVG
+ };
+ }
+ });
+
+ // src/traces/scatterpolar/attributes.js
+ var require_attributes68 = __commonJS({
+ "src/traces/scatterpolar/attributes.js"(exports, module) {
+ "use strict";
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var texttemplateAttrs = require_template_attributes().texttemplateAttrs;
+ var extendFlat = require_extend().extendFlat;
+ var makeFillcolorAttr = require_fillcolor_attribute();
+ var scatterAttrs = require_attributes12();
+ var baseAttrs = require_attributes2();
+ var lineAttrs = scatterAttrs.line;
+ module.exports = {
+ mode: scatterAttrs.mode,
+ r: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ theta: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ r0: {
+ valType: "any",
+ dflt: 0,
+ editType: "calc+clearAxisTypes"
+ },
+ dr: {
+ valType: "number",
+ dflt: 1,
+ editType: "calc"
+ },
+ theta0: {
+ valType: "any",
+ dflt: 0,
+ editType: "calc+clearAxisTypes"
+ },
+ dtheta: {
+ valType: "number",
+ editType: "calc"
+ },
+ thetaunit: {
+ valType: "enumerated",
+ values: ["radians", "degrees", "gradians"],
+ dflt: "degrees",
+ editType: "calc+clearAxisTypes"
+ },
+ text: scatterAttrs.text,
+ texttemplate: texttemplateAttrs({ editType: "plot" }, {
+ keys: ["r", "theta", "text"]
+ }),
+ hovertext: scatterAttrs.hovertext,
+ line: {
+ color: lineAttrs.color,
+ width: lineAttrs.width,
+ dash: lineAttrs.dash,
+ backoff: lineAttrs.backoff,
+ shape: extendFlat({}, lineAttrs.shape, {
+ values: ["linear", "spline"]
+ }),
+ smoothing: lineAttrs.smoothing,
+ editType: "calc"
+ },
+ connectgaps: scatterAttrs.connectgaps,
+ marker: scatterAttrs.marker,
+ cliponaxis: extendFlat({}, scatterAttrs.cliponaxis, { dflt: false }),
+ textposition: scatterAttrs.textposition,
+ textfont: scatterAttrs.textfont,
+ fill: extendFlat({}, scatterAttrs.fill, {
+ values: ["none", "toself", "tonext"],
+ dflt: "none"
+ }),
+ fillcolor: makeFillcolorAttr(),
+ // TODO error bars
+ // https://stackoverflow.com/a/26597487/4068492
+ // error_x (error_r, error_theta)
+ // error_y
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ flags: ["r", "theta", "text", "name"]
+ }),
+ hoveron: scatterAttrs.hoveron,
+ hovertemplate: hovertemplateAttrs(),
+ selected: scatterAttrs.selected,
+ unselected: scatterAttrs.unselected
+ };
+ }
+ });
+
+ // src/traces/scatterpolar/defaults.js
+ var require_defaults64 = __commonJS({
+ "src/traces/scatterpolar/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var subTypes = require_subtypes();
+ var handleMarkerDefaults = require_marker_defaults();
+ var handleLineDefaults = require_line_defaults();
+ var handleLineShapeDefaults = require_line_shape_defaults();
+ var handleTextDefaults = require_text_defaults();
+ var handleFillColorDefaults = require_fillcolor_defaults();
+ var PTS_LINESONLY = require_constants8().PTS_LINESONLY;
+ var attributes = require_attributes68();
+ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var len = handleRThetaDefaults(traceIn, traceOut, layout, coerce);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("thetaunit");
+ coerce("mode", len < PTS_LINESONLY ? "lines+markers" : "lines");
+ coerce("text");
+ coerce("hovertext");
+ if (traceOut.hoveron !== "fills") coerce("hovertemplate");
+ if (subTypes.hasMarkers(traceOut)) {
+ handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, { gradient: true });
+ }
+ if (subTypes.hasLines(traceOut)) {
+ handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce, { backoff: true });
+ handleLineShapeDefaults(traceIn, traceOut, coerce);
+ coerce("connectgaps");
+ }
+ if (subTypes.hasText(traceOut)) {
+ coerce("texttemplate");
+ handleTextDefaults(traceIn, traceOut, layout, coerce);
+ }
+ var dfltHoverOn = [];
+ if (subTypes.hasMarkers(traceOut) || subTypes.hasText(traceOut)) {
+ coerce("cliponaxis");
+ coerce("marker.maxdisplayed");
+ dfltHoverOn.push("points");
+ }
+ coerce("fill");
+ if (traceOut.fill !== "none") {
+ handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
+ if (!subTypes.hasLines(traceOut)) handleLineShapeDefaults(traceIn, traceOut, coerce);
+ }
+ if (traceOut.fill === "tonext" || traceOut.fill === "toself") {
+ dfltHoverOn.push("fills");
+ }
+ coerce("hoveron", dfltHoverOn.join("+") || "points");
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ }
+ function handleRThetaDefaults(traceIn, traceOut, layout, coerce) {
+ var r = coerce("r");
+ var theta = coerce("theta");
+ if (Lib.isTypedArray(r)) {
+ traceOut.r = r = Array.from(r);
+ }
+ if (Lib.isTypedArray(theta)) {
+ traceOut.theta = theta = Array.from(theta);
+ }
+ var len;
+ if (r) {
+ if (theta) {
+ len = Math.min(r.length, theta.length);
+ } else {
+ len = r.length;
+ coerce("theta0");
+ coerce("dtheta");
+ }
+ } else {
+ if (!theta) return 0;
+ len = traceOut.theta.length;
+ coerce("r0");
+ coerce("dr");
+ }
+ traceOut._length = len;
+ return len;
+ }
+ module.exports = {
+ handleRThetaDefaults,
+ supplyDefaults
+ };
+ }
+ });
+
+ // src/traces/scatterpolar/format_labels.js
+ var require_format_labels8 = __commonJS({
+ "src/traces/scatterpolar/format_labels.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var Axes = require_axes();
+ module.exports = function formatLabels(cdi, trace, fullLayout) {
+ var labels = {};
+ var subplot = fullLayout[trace.subplot]._subplot;
+ var radialAxis;
+ var angularAxis;
+ if (!subplot) {
+ subplot = fullLayout[trace.subplot];
+ radialAxis = subplot.radialaxis;
+ angularAxis = subplot.angularaxis;
+ } else {
+ radialAxis = subplot.radialAxis;
+ angularAxis = subplot.angularAxis;
+ }
+ var rVal = radialAxis.c2l(cdi.r);
+ labels.rLabel = Axes.tickText(radialAxis, rVal, true).text;
+ var thetaVal = angularAxis.thetaunit === "degrees" ? Lib.rad2deg(cdi.theta) : cdi.theta;
+ labels.thetaLabel = Axes.tickText(angularAxis, thetaVal, true).text;
+ return labels;
+ };
+ }
+ });
+
+ // src/traces/scatterpolar/calc.js
+ var require_calc43 = __commonJS({
+ "src/traces/scatterpolar/calc.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var BADNUM = require_numerical().BADNUM;
+ var Axes = require_axes();
+ var calcColorscale = require_colorscale_calc();
+ var arraysToCalcdata = require_arrays_to_calcdata();
+ var calcSelection = require_calc_selection();
+ var calcMarkerSize = require_calc3().calcMarkerSize;
+ module.exports = function calc(gd, trace) {
+ var fullLayout = gd._fullLayout;
+ var subplotId = trace.subplot;
+ var radialAxis = fullLayout[subplotId].radialaxis;
+ var angularAxis = fullLayout[subplotId].angularaxis;
+ var rArray = radialAxis.makeCalcdata(trace, "r");
+ var thetaArray = angularAxis.makeCalcdata(trace, "theta");
+ var len = trace._length;
+ var cd = new Array(len);
+ for (var i = 0; i < len; i++) {
+ var r = rArray[i];
+ var theta = thetaArray[i];
+ var cdi = cd[i] = {};
+ if (isNumeric(r) && isNumeric(theta)) {
+ cdi.r = r;
+ cdi.theta = theta;
+ } else {
+ cdi.r = BADNUM;
+ }
+ }
+ var ppad = calcMarkerSize(trace, len);
+ trace._extremes.x = Axes.findExtremes(radialAxis, rArray, { ppad });
+ calcColorscale(gd, trace);
+ arraysToCalcdata(cd, trace);
+ calcSelection(cd, trace);
+ return cd;
+ };
+ }
+ });
+
+ // src/traces/scatterpolar/plot.js
+ var require_plot36 = __commonJS({
+ "src/traces/scatterpolar/plot.js"(exports, module) {
+ "use strict";
+ var scatterPlot = require_plot();
+ var BADNUM = require_numerical().BADNUM;
+ module.exports = function plot(gd, subplot, moduleCalcData) {
+ var mlayer = subplot.layers.frontplot.select("g.scatterlayer");
+ var xa = subplot.xaxis;
+ var ya = subplot.yaxis;
+ var plotinfo = {
+ xaxis: xa,
+ yaxis: ya,
+ plot: subplot.framework,
+ layerClipId: subplot._hasClipOnAxisFalse ? subplot.clipIds.forTraces : null
+ };
+ var radialAxis = subplot.radialAxis;
+ var angularAxis = subplot.angularAxis;
+ for (var i = 0; i < moduleCalcData.length; i++) {
+ var cdi = moduleCalcData[i];
+ for (var j = 0; j < cdi.length; j++) {
+ if (j === 0) {
+ cdi[0].trace._xA = xa;
+ cdi[0].trace._yA = ya;
+ }
+ var cd = cdi[j];
+ var r = cd.r;
+ if (r === BADNUM) {
+ cd.x = cd.y = BADNUM;
+ } else {
+ var rg = radialAxis.c2g(r);
+ var thetag = angularAxis.c2g(cd.theta);
+ cd.x = rg * Math.cos(thetag);
+ cd.y = rg * Math.sin(thetag);
+ }
+ }
+ }
+ scatterPlot(gd, plotinfo, moduleCalcData, mlayer);
+ };
+ }
+ });
+
+ // src/traces/scatterpolar/hover.js
+ var require_hover24 = __commonJS({
+ "src/traces/scatterpolar/hover.js"(exports, module) {
+ "use strict";
+ var scatterHover = require_hover2();
+ function hoverPoints(pointData, xval, yval, hovermode) {
+ var scatterPointData = scatterHover(pointData, xval, yval, hovermode);
+ if (!scatterPointData || scatterPointData[0].index === false) return;
+ var newPointData = scatterPointData[0];
+ if (newPointData.index === void 0) {
+ return scatterPointData;
+ }
+ var subplot = pointData.subplot;
+ var cdi = newPointData.cd[newPointData.index];
+ var trace = newPointData.trace;
+ if (!subplot.isPtInside(cdi)) return;
+ newPointData.xLabelVal = void 0;
+ newPointData.yLabelVal = void 0;
+ makeHoverPointText(cdi, trace, subplot, newPointData);
+ newPointData.hovertemplate = trace.hovertemplate;
+ return scatterPointData;
+ }
+ function makeHoverPointText(cdi, trace, subplot, pointData) {
+ var radialAxis = subplot.radialAxis;
+ var angularAxis = subplot.angularAxis;
+ radialAxis._hovertitle = "r";
+ angularAxis._hovertitle = "\u03B8";
+ var fullLayout = {};
+ fullLayout[trace.subplot] = { _subplot: subplot };
+ var labels = trace._module.formatLabels(cdi, trace, fullLayout);
+ pointData.rLabel = labels.rLabel;
+ pointData.thetaLabel = labels.thetaLabel;
+ var hoverinfo = cdi.hi || trace.hoverinfo;
+ var text = [];
+ function textPart(ax, val) {
+ text.push(ax._hovertitle + ": " + val);
+ }
+ if (!trace.hovertemplate) {
+ var parts = hoverinfo.split("+");
+ if (parts.indexOf("all") !== -1) parts = ["r", "theta", "text"];
+ if (parts.indexOf("r") !== -1) textPart(radialAxis, pointData.rLabel);
+ if (parts.indexOf("theta") !== -1) textPart(angularAxis, pointData.thetaLabel);
+ if (parts.indexOf("text") !== -1 && pointData.text) {
+ text.push(pointData.text);
+ delete pointData.text;
+ }
+ pointData.extraText = text.join("
");
+ }
+ }
+ module.exports = {
+ hoverPoints,
+ makeHoverPointText
+ };
+ }
+ });
+
+ // src/traces/scatterpolar/index.js
+ var require_scatterpolar = __commonJS({
+ "src/traces/scatterpolar/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ moduleType: "trace",
+ name: "scatterpolar",
+ basePlotModule: require_polar2(),
+ categories: ["polar", "symbols", "showLegend", "scatter-like"],
+ attributes: require_attributes68(),
+ supplyDefaults: require_defaults64().supplyDefaults,
+ colorbar: require_marker_colorbar(),
+ formatLabels: require_format_labels8(),
+ calc: require_calc43(),
+ plot: require_plot36(),
+ style: require_style2().style,
+ styleOnSelect: require_style2().styleOnSelect,
+ hoverPoints: require_hover24().hoverPoints,
+ selectPoints: require_select2(),
+ meta: {}
+ };
+ }
+ });
+
+ // lib/scatterpolar.js
+ var require_scatterpolar2 = __commonJS({
+ "lib/scatterpolar.js"(exports, module) {
+ "use strict";
+ module.exports = require_scatterpolar();
+ }
+ });
+
+ // src/traces/scatterpolargl/attributes.js
+ var require_attributes69 = __commonJS({
+ "src/traces/scatterpolargl/attributes.js"(exports, module) {
+ "use strict";
+ var scatterPolarAttrs = require_attributes68();
+ var scatterGlAttrs = require_attributes50();
+ var texttemplateAttrs = require_template_attributes().texttemplateAttrs;
+ module.exports = {
+ mode: scatterPolarAttrs.mode,
+ r: scatterPolarAttrs.r,
+ theta: scatterPolarAttrs.theta,
+ r0: scatterPolarAttrs.r0,
+ dr: scatterPolarAttrs.dr,
+ theta0: scatterPolarAttrs.theta0,
+ dtheta: scatterPolarAttrs.dtheta,
+ thetaunit: scatterPolarAttrs.thetaunit,
+ text: scatterPolarAttrs.text,
+ texttemplate: texttemplateAttrs({ editType: "plot" }, {
+ keys: ["r", "theta", "text"]
+ }),
+ hovertext: scatterPolarAttrs.hovertext,
+ hovertemplate: scatterPolarAttrs.hovertemplate,
+ line: {
+ color: scatterGlAttrs.line.color,
+ width: scatterGlAttrs.line.width,
+ dash: scatterGlAttrs.line.dash,
+ editType: "calc"
+ },
+ connectgaps: scatterGlAttrs.connectgaps,
+ marker: scatterGlAttrs.marker,
+ // no cliponaxis
+ fill: scatterGlAttrs.fill,
+ fillcolor: scatterGlAttrs.fillcolor,
+ textposition: scatterGlAttrs.textposition,
+ textfont: scatterGlAttrs.textfont,
+ hoverinfo: scatterPolarAttrs.hoverinfo,
+ // no hoveron
+ selected: scatterPolarAttrs.selected,
+ unselected: scatterPolarAttrs.unselected
+ };
+ }
+ });
+
+ // src/traces/scatterpolargl/defaults.js
+ var require_defaults65 = __commonJS({
+ "src/traces/scatterpolargl/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var subTypes = require_subtypes();
+ var handleRThetaDefaults = require_defaults64().handleRThetaDefaults;
+ var handleMarkerDefaults = require_marker_defaults();
+ var handleLineDefaults = require_line_defaults();
+ var handleTextDefaults = require_text_defaults();
+ var handleFillColorDefaults = require_fillcolor_defaults();
+ var PTS_LINESONLY = require_constants8().PTS_LINESONLY;
+ var attributes = require_attributes69();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var len = handleRThetaDefaults(traceIn, traceOut, layout, coerce);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("thetaunit");
+ coerce("mode", len < PTS_LINESONLY ? "lines+markers" : "lines");
+ coerce("text");
+ coerce("hovertext");
+ if (traceOut.hoveron !== "fills") coerce("hovertemplate");
+ if (subTypes.hasMarkers(traceOut)) {
+ handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, { noAngleRef: true, noStandOff: true });
+ }
+ if (subTypes.hasLines(traceOut)) {
+ handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
+ coerce("connectgaps");
+ }
+ if (subTypes.hasText(traceOut)) {
+ coerce("texttemplate");
+ handleTextDefaults(traceIn, traceOut, layout, coerce, {
+ noFontShadow: true,
+ noFontLineposition: true,
+ noFontTextcase: true
+ });
+ }
+ coerce("fill");
+ if (traceOut.fill !== "none") {
+ handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
+ }
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ }
+ });
+
+ // src/traces/scatterpolargl/format_labels.js
+ var require_format_labels9 = __commonJS({
+ "src/traces/scatterpolargl/format_labels.js"(exports, module) {
+ "use strict";
+ var scatterPolarFormatLabels = require_format_labels8();
+ module.exports = function formatLabels(cdi, trace, fullLayout) {
+ var i = cdi.i;
+ if (!("r" in cdi)) cdi.r = trace._r[i];
+ if (!("theta" in cdi)) cdi.theta = trace._theta[i];
+ return scatterPolarFormatLabels(cdi, trace, fullLayout);
+ };
+ }
+ });
+
+ // src/traces/scatterpolargl/calc.js
+ var require_calc44 = __commonJS({
+ "src/traces/scatterpolargl/calc.js"(exports, module) {
+ "use strict";
+ var calcColorscale = require_colorscale_calc();
+ var calcMarkerSize = require_calc3().calcMarkerSize;
+ var convert = require_convert10();
+ var Axes = require_axes();
+ var TOO_MANY_POINTS = require_constants23().TOO_MANY_POINTS;
+ module.exports = function calc(gd, trace) {
+ var fullLayout = gd._fullLayout;
+ var subplotId = trace.subplot;
+ var radialAxis = fullLayout[subplotId].radialaxis;
+ var angularAxis = fullLayout[subplotId].angularaxis;
+ var rArray = trace._r = radialAxis.makeCalcdata(trace, "r");
+ var thetaArray = trace._theta = angularAxis.makeCalcdata(trace, "theta");
+ var len = trace._length;
+ var stash = {};
+ if (len < rArray.length) rArray = rArray.slice(0, len);
+ if (len < thetaArray.length) thetaArray = thetaArray.slice(0, len);
+ stash.r = rArray;
+ stash.theta = thetaArray;
+ calcColorscale(gd, trace);
+ var opts = stash.opts = convert.style(gd, trace);
+ var ppad;
+ if (len < TOO_MANY_POINTS) {
+ ppad = calcMarkerSize(trace, len);
+ } else if (opts.marker) {
+ ppad = 2 * (opts.marker.sizeAvg || Math.max(opts.marker.size, 3));
+ }
+ trace._extremes.x = Axes.findExtremes(radialAxis, rArray, { ppad });
+ return [{ x: false, y: false, t: stash, trace }];
+ };
+ }
+ });
+
+ // src/traces/scatterpolargl/hover.js
+ var require_hover25 = __commonJS({
+ "src/traces/scatterpolargl/hover.js"(exports, module) {
+ "use strict";
+ var hover = require_hover16();
+ var makeHoverPointText = require_hover24().makeHoverPointText;
+ function hoverPoints(pointData, xval, yval, hovermode) {
+ var cd = pointData.cd;
+ var stash = cd[0].t;
+ var rArray = stash.r;
+ var thetaArray = stash.theta;
+ var scatterPointData = hover.hoverPoints(pointData, xval, yval, hovermode);
+ if (!scatterPointData || scatterPointData[0].index === false) return;
+ var newPointData = scatterPointData[0];
+ if (newPointData.index === void 0) {
+ return scatterPointData;
+ }
+ var subplot = pointData.subplot;
+ var cdi = newPointData.cd[newPointData.index];
+ var trace = newPointData.trace;
+ cdi.r = rArray[newPointData.index];
+ cdi.theta = thetaArray[newPointData.index];
+ if (!subplot.isPtInside(cdi)) return;
+ newPointData.xLabelVal = void 0;
+ newPointData.yLabelVal = void 0;
+ makeHoverPointText(cdi, trace, subplot, newPointData);
+ return scatterPointData;
+ }
+ module.exports = {
+ hoverPoints
+ };
+ }
+ });
+
+ // src/traces/scatterpolargl/base_index.js
+ var require_base_index4 = __commonJS({
+ "src/traces/scatterpolargl/base_index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ moduleType: "trace",
+ name: "scatterpolargl",
+ basePlotModule: require_polar2(),
+ categories: ["gl", "regl", "polar", "symbols", "showLegend", "scatter-like"],
+ attributes: require_attributes69(),
+ supplyDefaults: require_defaults65(),
+ colorbar: require_marker_colorbar(),
+ formatLabels: require_format_labels9(),
+ calc: require_calc44(),
+ hoverPoints: require_hover25().hoverPoints,
+ selectPoints: require_select7(),
+ meta: {}
+ };
+ }
+ });
+
+ // src/traces/scatterpolargl/plot.js
+ var require_plot37 = __commonJS({
+ "src/traces/scatterpolargl/plot.js"(exports, module) {
+ "use strict";
+ var cluster = require_point_cluster();
+ var isNumeric = require_fast_isnumeric();
+ var scatterglPlot = require_plot19();
+ var sceneUpdate = require_scene_update();
+ var convert = require_convert10();
+ var Lib = require_lib();
+ var TOO_MANY_POINTS = require_constants23().TOO_MANY_POINTS;
+ var reglPrecompiled = {};
+ module.exports = function plot(gd, subplot, cdata) {
+ if (!cdata.length) return;
+ var radialAxis = subplot.radialAxis;
+ var angularAxis = subplot.angularAxis;
+ var scene = sceneUpdate(gd, subplot);
+ cdata.forEach(function(cdscatter) {
+ if (!cdscatter || !cdscatter[0] || !cdscatter[0].trace) return;
+ var cd = cdscatter[0];
+ var trace = cd.trace;
+ var stash = cd.t;
+ var len = trace._length;
+ var rArray = stash.r;
+ var thetaArray = stash.theta;
+ var opts = stash.opts;
+ var i;
+ var subRArray = rArray.slice();
+ var subThetaArray = thetaArray.slice();
+ for (i = 0; i < rArray.length; i++) {
+ if (!subplot.isPtInside({ r: rArray[i], theta: thetaArray[i] })) {
+ subRArray[i] = NaN;
+ subThetaArray[i] = NaN;
+ }
+ }
+ var positions = new Array(len * 2);
+ var x = Array(len);
+ var y = Array(len);
+ for (i = 0; i < len; i++) {
+ var r = subRArray[i];
+ var xx, yy;
+ if (isNumeric(r)) {
+ var rg = radialAxis.c2g(r);
+ var thetag = angularAxis.c2g(subThetaArray[i], trace.thetaunit);
+ xx = rg * Math.cos(thetag);
+ yy = rg * Math.sin(thetag);
+ } else {
+ xx = yy = NaN;
+ }
+ x[i] = positions[i * 2] = xx;
+ y[i] = positions[i * 2 + 1] = yy;
+ }
+ stash.tree = cluster(positions);
+ if (opts.marker && len >= TOO_MANY_POINTS) {
+ opts.marker.cluster = stash.tree;
+ }
+ if (opts.marker) {
+ opts.markerSel.positions = opts.markerUnsel.positions = opts.marker.positions = positions;
+ }
+ if (opts.line && positions.length > 1) {
+ Lib.extendFlat(
+ opts.line,
+ convert.linePositions(gd, trace, positions)
+ );
+ }
+ if (opts.text) {
+ Lib.extendFlat(
+ opts.text,
+ { positions },
+ convert.textPosition(gd, trace, opts.text, opts.marker)
+ );
+ Lib.extendFlat(
+ opts.textSel,
+ { positions },
+ convert.textPosition(gd, trace, opts.text, opts.markerSel)
+ );
+ Lib.extendFlat(
+ opts.textUnsel,
+ { positions },
+ convert.textPosition(gd, trace, opts.text, opts.markerUnsel)
+ );
+ }
+ if (opts.fill && !scene.fill2d) scene.fill2d = true;
+ if (opts.marker && !scene.scatter2d) scene.scatter2d = true;
+ if (opts.line && !scene.line2d) scene.line2d = true;
+ if (opts.text && !scene.glText) scene.glText = true;
+ scene.lineOptions.push(opts.line);
+ scene.fillOptions.push(opts.fill);
+ scene.markerOptions.push(opts.marker);
+ scene.markerSelectedOptions.push(opts.markerSel);
+ scene.markerUnselectedOptions.push(opts.markerUnsel);
+ scene.textOptions.push(opts.text);
+ scene.textSelectedOptions.push(opts.textSel);
+ scene.textUnselectedOptions.push(opts.textUnsel);
+ scene.selectBatch.push([]);
+ scene.unselectBatch.push([]);
+ stash.x = x;
+ stash.y = y;
+ stash.rawx = x;
+ stash.rawy = y;
+ stash.r = rArray;
+ stash.theta = thetaArray;
+ stash.positions = positions;
+ stash._scene = scene;
+ stash.index = scene.count;
+ scene.count++;
+ });
+ return scatterglPlot(gd, subplot, cdata);
+ };
+ module.exports.reglPrecompiled = reglPrecompiled;
+ }
+ });
+
+ // src/traces/scatterpolargl/index.js
+ var require_scatterpolargl = __commonJS({
+ "src/traces/scatterpolargl/index.js"(exports, module) {
+ "use strict";
+ var index = require_base_index4();
+ index.plot = require_plot37();
+ module.exports = index;
+ }
+ });
+
+ // lib/scatterpolargl.js
+ var require_scatterpolargl2 = __commonJS({
+ "lib/scatterpolargl.js"(exports, module) {
+ "use strict";
+ module.exports = require_scatterpolargl();
+ }
+ });
+
+ // src/traces/barpolar/attributes.js
+ var require_attributes70 = __commonJS({
+ "src/traces/barpolar/attributes.js"(exports, module) {
+ "use strict";
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var extendFlat = require_extend().extendFlat;
+ var scatterPolarAttrs = require_attributes68();
+ var barAttrs = require_attributes23();
+ module.exports = {
+ r: scatterPolarAttrs.r,
+ theta: scatterPolarAttrs.theta,
+ r0: scatterPolarAttrs.r0,
+ dr: scatterPolarAttrs.dr,
+ theta0: scatterPolarAttrs.theta0,
+ dtheta: scatterPolarAttrs.dtheta,
+ thetaunit: scatterPolarAttrs.thetaunit,
+ // orientation: {
+ // valType: 'enumerated',
+ // values: ['radial', 'angular'],
+ // editType: 'calc+clearAxisTypes',
+ //
+ // },
+ base: extendFlat({}, barAttrs.base, {}),
+ offset: extendFlat({}, barAttrs.offset, {}),
+ width: extendFlat({}, barAttrs.width, {}),
+ text: extendFlat({}, barAttrs.text, {}),
+ hovertext: extendFlat({}, barAttrs.hovertext, {}),
+ // textposition: {},
+ // textfont: {},
+ // insidetextfont: {},
+ // outsidetextfont: {},
+ // constraintext: {},
+ // cliponaxis: extendFlat({}, barAttrs.cliponaxis, {dflt: false}),
+ marker: barPolarMarker(),
+ hoverinfo: scatterPolarAttrs.hoverinfo,
+ hovertemplate: hovertemplateAttrs(),
+ selected: barAttrs.selected,
+ unselected: barAttrs.unselected
+ // error_x (error_r, error_theta)
+ // error_y
+ };
+ function barPolarMarker() {
+ var marker = extendFlat({}, barAttrs.marker);
+ delete marker.cornerradius;
+ return marker;
+ }
+ }
+ });
+
+ // src/traces/barpolar/layout_attributes.js
+ var require_layout_attributes22 = __commonJS({
+ "src/traces/barpolar/layout_attributes.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ barmode: {
+ valType: "enumerated",
+ values: ["stack", "overlay"],
+ dflt: "stack",
+ editType: "calc"
+ },
+ bargap: {
+ valType: "number",
+ dflt: 0.1,
+ min: 0,
+ max: 1,
+ editType: "calc"
+ }
+ };
+ }
+ });
+
+ // src/traces/barpolar/defaults.js
+ var require_defaults66 = __commonJS({
+ "src/traces/barpolar/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var handleRThetaDefaults = require_defaults64().handleRThetaDefaults;
+ var handleStyleDefaults = require_style_defaults();
+ var attributes = require_attributes70();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var len = handleRThetaDefaults(traceIn, traceOut, layout, coerce);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("thetaunit");
+ coerce("base");
+ coerce("offset");
+ coerce("width");
+ coerce("text");
+ coerce("hovertext");
+ coerce("hovertemplate");
+ handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout);
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ }
+ });
+
+ // src/traces/barpolar/layout_defaults.js
+ var require_layout_defaults20 = __commonJS({
+ "src/traces/barpolar/layout_defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var attrs = require_layout_attributes22();
+ module.exports = function(layoutIn, layoutOut, fullData) {
+ var subplotsDone = {};
+ var sp;
+ function coerce(attr, dflt) {
+ return Lib.coerce(layoutIn[sp] || {}, layoutOut[sp], attrs, attr, dflt);
+ }
+ for (var i = 0; i < fullData.length; i++) {
+ var trace = fullData[i];
+ if (trace.type === "barpolar" && trace.visible === true) {
+ sp = trace.subplot;
+ if (!subplotsDone[sp]) {
+ coerce("barmode");
+ coerce("bargap");
+ subplotsDone[sp] = 1;
+ }
+ }
+ }
+ };
+ }
+ });
+
+ // src/traces/barpolar/calc.js
+ var require_calc45 = __commonJS({
+ "src/traces/barpolar/calc.js"(exports, module) {
+ "use strict";
+ var hasColorscale = require_helpers().hasColorscale;
+ var colorscaleCalc = require_calc();
+ var isArrayOrTypedArray = require_lib().isArrayOrTypedArray;
+ var arraysToCalcdata = require_arrays_to_calcdata2();
+ var setGroupPositions = require_cross_trace_calc().setGroupPositions;
+ var calcSelection = require_calc_selection();
+ var traceIs = require_registry().traceIs;
+ var extendFlat = require_lib().extendFlat;
+ function calc(gd, trace) {
+ var fullLayout = gd._fullLayout;
+ var subplotId = trace.subplot;
+ var radialAxis = fullLayout[subplotId].radialaxis;
+ var angularAxis = fullLayout[subplotId].angularaxis;
+ var rArray = radialAxis.makeCalcdata(trace, "r");
+ var thetaArray = angularAxis.makeCalcdata(trace, "theta");
+ var len = trace._length;
+ var cd = new Array(len);
+ var sArray = rArray;
+ var pArray = thetaArray;
+ for (var i = 0; i < len; i++) {
+ cd[i] = { p: pArray[i], s: sArray[i] };
+ }
+ function d2c(attr) {
+ var val = trace[attr];
+ if (val !== void 0) {
+ trace["_" + attr] = isArrayOrTypedArray(val) ? angularAxis.makeCalcdata(trace, attr) : angularAxis.d2c(val, trace.thetaunit);
+ }
+ }
+ if (angularAxis.type === "linear") {
+ d2c("width");
+ d2c("offset");
+ }
+ if (hasColorscale(trace, "marker")) {
+ colorscaleCalc(gd, trace, {
+ vals: trace.marker.color,
+ containerStr: "marker",
+ cLetter: "c"
+ });
+ }
+ if (hasColorscale(trace, "marker.line")) {
+ colorscaleCalc(gd, trace, {
+ vals: trace.marker.line.color,
+ containerStr: "marker.line",
+ cLetter: "c"
+ });
+ }
+ arraysToCalcdata(cd, trace);
+ calcSelection(cd, trace);
+ return cd;
+ }
+ function crossTraceCalc(gd, polarLayout, subplotId) {
+ var calcdata = gd.calcdata;
+ var barPolarCd = [];
+ for (var i = 0; i < calcdata.length; i++) {
+ var cdi = calcdata[i];
+ var trace = cdi[0].trace;
+ if (trace.visible === true && traceIs(trace, "bar") && trace.subplot === subplotId) {
+ barPolarCd.push(cdi);
+ }
+ }
+ var rAxis = extendFlat({}, polarLayout.radialaxis, { _id: "x" });
+ var aAxis = polarLayout.angularaxis;
+ setGroupPositions(gd, aAxis, rAxis, barPolarCd, {
+ mode: polarLayout.barmode,
+ norm: polarLayout.barnorm,
+ gap: polarLayout.bargap,
+ groupgap: polarLayout.bargroupgap
+ });
+ }
+ module.exports = {
+ calc,
+ crossTraceCalc
+ };
+ }
+ });
+
+ // src/traces/barpolar/plot.js
+ var require_plot38 = __commonJS({
+ "src/traces/barpolar/plot.js"(exports, module) {
+ "use strict";
+ var d3 = require_d3();
+ var isNumeric = require_fast_isnumeric();
+ var Lib = require_lib();
+ var Drawing = require_drawing();
+ var helpers = require_helpers19();
+ module.exports = function plot(gd, subplot, cdbar) {
+ var isStatic = gd._context.staticPlot;
+ var xa = subplot.xaxis;
+ var ya = subplot.yaxis;
+ var radialAxis = subplot.radialAxis;
+ var angularAxis = subplot.angularAxis;
+ var pathFn = makePathFn(subplot);
+ var barLayer = subplot.layers.frontplot.select("g.barlayer");
+ Lib.makeTraceGroups(barLayer, cdbar, "trace bars").each(function() {
+ var plotGroup = d3.select(this);
+ var pointGroup = Lib.ensureSingle(plotGroup, "g", "points");
+ var bars = pointGroup.selectAll("g.point").data(Lib.identity);
+ bars.enter().append("g").style("vector-effect", isStatic ? "none" : "non-scaling-stroke").style("stroke-miterlimit", 2).classed("point", true);
+ bars.exit().remove();
+ bars.each(function(di) {
+ var bar = d3.select(this);
+ var rp0 = di.rp0 = radialAxis.c2p(di.s0);
+ var rp1 = di.rp1 = radialAxis.c2p(di.s1);
+ var thetag0 = di.thetag0 = angularAxis.c2g(di.p0);
+ var thetag1 = di.thetag1 = angularAxis.c2g(di.p1);
+ var dPath;
+ if (!isNumeric(rp0) || !isNumeric(rp1) || !isNumeric(thetag0) || !isNumeric(thetag1) || rp0 === rp1 || thetag0 === thetag1) {
+ dPath = "M0,0Z";
+ } else {
+ var rg1 = radialAxis.c2g(di.s1);
+ var thetagMid = (thetag0 + thetag1) / 2;
+ di.ct = [
+ xa.c2p(rg1 * Math.cos(thetagMid)),
+ ya.c2p(rg1 * Math.sin(thetagMid))
+ ];
+ dPath = pathFn(rp0, rp1, thetag0, thetag1);
+ }
+ Lib.ensureSingle(bar, "path").attr("d", dPath);
+ });
+ Drawing.setClipUrl(
+ plotGroup,
+ subplot._hasClipOnAxisFalse ? subplot.clipIds.forTraces : null,
+ gd
+ );
+ });
+ };
+ function makePathFn(subplot) {
+ var cxx = subplot.cxx;
+ var cyy = subplot.cyy;
+ if (subplot.vangles) {
+ return function(r0, r1, _a0, _a1) {
+ var a0, a1;
+ if (Lib.angleDelta(_a0, _a1) > 0) {
+ a0 = _a0;
+ a1 = _a1;
+ } else {
+ a0 = _a1;
+ a1 = _a0;
+ }
+ var va0 = helpers.findEnclosingVertexAngles(a0, subplot.vangles)[0];
+ var va1 = helpers.findEnclosingVertexAngles(a1, subplot.vangles)[1];
+ var vaBar = [va0, (a0 + a1) / 2, va1];
+ return helpers.pathPolygonAnnulus(r0, r1, a0, a1, vaBar, cxx, cyy);
+ };
+ }
+ return function(r0, r1, a0, a1) {
+ return Lib.pathAnnulus(r0, r1, a0, a1, cxx, cyy);
+ };
+ }
+ }
+ });
+
+ // src/traces/barpolar/hover.js
+ var require_hover26 = __commonJS({
+ "src/traces/barpolar/hover.js"(exports, module) {
+ "use strict";
+ var Fx = require_fx();
+ var Lib = require_lib();
+ var getTraceColor = require_hover3().getTraceColor;
+ var fillText = Lib.fillText;
+ var makeHoverPointText = require_hover24().makeHoverPointText;
+ var isPtInsidePolygon = require_helpers19().isPtInsidePolygon;
+ module.exports = function hoverPoints(pointData, xval, yval) {
+ var cd = pointData.cd;
+ var trace = cd[0].trace;
+ var subplot = pointData.subplot;
+ var radialAxis = subplot.radialAxis;
+ var angularAxis = subplot.angularAxis;
+ var vangles = subplot.vangles;
+ var inboxFn = vangles ? isPtInsidePolygon : Lib.isPtInsideSector;
+ var maxHoverDistance = pointData.maxHoverDistance;
+ var period = angularAxis._period || 2 * Math.PI;
+ var rVal = Math.abs(radialAxis.g2p(Math.sqrt(xval * xval + yval * yval)));
+ var thetaVal = Math.atan2(yval, xval);
+ if (radialAxis.range[0] > radialAxis.range[1]) {
+ thetaVal += Math.PI;
+ }
+ var distFn = function(di) {
+ if (inboxFn(rVal, thetaVal, [di.rp0, di.rp1], [di.thetag0, di.thetag1], vangles)) {
+ return maxHoverDistance + // add a little to the pseudo-distance for wider bars, so that like scatter,
+ // if you are over two overlapping bars, the narrower one wins.
+ Math.min(1, Math.abs(di.thetag1 - di.thetag0) / period) - 1 + // add a gradient so hovering near the end of a
+ // bar makes it a little closer match
+ (di.rp1 - rVal) / (di.rp1 - di.rp0) - 1;
+ } else {
+ return Infinity;
+ }
+ };
+ Fx.getClosest(cd, distFn, pointData);
+ if (pointData.index === false) return;
+ var index = pointData.index;
+ var cdi = cd[index];
+ pointData.x0 = pointData.x1 = cdi.ct[0];
+ pointData.y0 = pointData.y1 = cdi.ct[1];
+ var _cdi = Lib.extendFlat({}, cdi, { r: cdi.s, theta: cdi.p });
+ fillText(cdi, trace, pointData);
+ makeHoverPointText(_cdi, trace, subplot, pointData);
+ pointData.hovertemplate = trace.hovertemplate;
+ pointData.color = getTraceColor(trace, cdi);
+ pointData.xLabelVal = pointData.yLabelVal = void 0;
+ if (cdi.s < 0) {
+ pointData.idealAlign = "left";
+ }
+ return [pointData];
+ };
+ }
+ });
+
+ // src/traces/barpolar/index.js
+ var require_barpolar = __commonJS({
+ "src/traces/barpolar/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ moduleType: "trace",
+ name: "barpolar",
+ basePlotModule: require_polar2(),
+ categories: ["polar", "bar", "showLegend"],
+ attributes: require_attributes70(),
+ layoutAttributes: require_layout_attributes22(),
+ supplyDefaults: require_defaults66(),
+ supplyLayoutDefaults: require_layout_defaults20(),
+ calc: require_calc45().calc,
+ crossTraceCalc: require_calc45().crossTraceCalc,
+ plot: require_plot38(),
+ colorbar: require_marker_colorbar(),
+ formatLabels: require_format_labels8(),
+ style: require_style4().style,
+ styleOnSelect: require_style4().styleOnSelect,
+ hoverPoints: require_hover26(),
+ selectPoints: require_select3(),
+ meta: {}
+ };
+ }
+ });
+
+ // lib/barpolar.js
+ var require_barpolar2 = __commonJS({
+ "lib/barpolar.js"(exports, module) {
+ "use strict";
+ module.exports = require_barpolar();
+ }
+ });
+
+ // src/plots/smith/constants.js
+ var require_constants34 = __commonJS({
+ "src/plots/smith/constants.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ attr: "subplot",
+ name: "smith",
+ axisNames: [
+ "realaxis",
+ "imaginaryaxis"
+ // imaginary axis should be second here so that the `tickvals` defaults could be inherited from realaxis
+ ],
+ axisName2dataArray: { imaginaryaxis: "imag", realaxis: "real" }
+ };
+ }
+ });
+
+ // src/plots/smith/layout_attributes.js
+ var require_layout_attributes23 = __commonJS({
+ "src/plots/smith/layout_attributes.js"(exports, module) {
+ "use strict";
+ var colorAttrs = require_attributes3();
+ var axesAttrs = require_layout_attributes4();
+ var domainAttrs = require_domain().attributes;
+ var extendFlat = require_lib().extendFlat;
+ var overrideAll = require_edit_types().overrideAll;
+ var axisLineGridAttr = overrideAll({
+ color: axesAttrs.color,
+ showline: extendFlat({}, axesAttrs.showline, { dflt: true }),
+ linecolor: axesAttrs.linecolor,
+ linewidth: axesAttrs.linewidth,
+ showgrid: extendFlat({}, axesAttrs.showgrid, { dflt: true }),
+ gridcolor: axesAttrs.gridcolor,
+ gridwidth: axesAttrs.gridwidth,
+ griddash: axesAttrs.griddash
+ }, "plot", "from-root");
+ var axisTickAttrs = overrideAll({
+ ticklen: axesAttrs.ticklen,
+ tickwidth: extendFlat({}, axesAttrs.tickwidth, { dflt: 2 }),
+ tickcolor: axesAttrs.tickcolor,
+ showticklabels: axesAttrs.showticklabels,
+ labelalias: axesAttrs.labelalias,
+ showtickprefix: axesAttrs.showtickprefix,
+ tickprefix: axesAttrs.tickprefix,
+ showticksuffix: axesAttrs.showticksuffix,
+ ticksuffix: axesAttrs.ticksuffix,
+ tickfont: axesAttrs.tickfont,
+ tickformat: axesAttrs.tickformat,
+ hoverformat: axesAttrs.hoverformat,
+ layer: axesAttrs.layer
+ }, "plot", "from-root");
+ var realAxisAttrs = extendFlat({
+ visible: extendFlat({}, axesAttrs.visible, { dflt: true }),
+ tickvals: {
+ dflt: [0.2, 0.5, 1, 2, 5],
+ valType: "data_array",
+ editType: "plot"
+ },
+ tickangle: extendFlat({}, axesAttrs.tickangle, { dflt: 90 }),
+ ticks: {
+ valType: "enumerated",
+ values: ["top", "bottom", ""],
+ editType: "ticks"
+ },
+ side: {
+ valType: "enumerated",
+ values: ["top", "bottom"],
+ dflt: "top",
+ editType: "plot"
+ },
+ editType: "calc"
+ }, axisLineGridAttr, axisTickAttrs);
+ var imaginaryAxisAttrs = extendFlat({
+ visible: extendFlat({}, axesAttrs.visible, { dflt: true }),
+ tickvals: {
+ valType: "data_array",
+ editType: "plot"
+ },
+ ticks: axesAttrs.ticks,
+ editType: "calc"
+ }, axisLineGridAttr, axisTickAttrs);
+ module.exports = {
+ domain: domainAttrs({ name: "smith", editType: "plot" }),
+ bgcolor: {
+ valType: "color",
+ editType: "plot",
+ dflt: colorAttrs.background
+ },
+ realaxis: realAxisAttrs,
+ imaginaryaxis: imaginaryAxisAttrs,
+ editType: "calc"
+ };
+ }
+ });
+
+ // src/plots/smith/layout_defaults.js
+ var require_layout_defaults21 = __commonJS({
+ "src/plots/smith/layout_defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var Color2 = require_color();
+ var Template = require_plot_template();
+ var handleSubplotDefaults = require_subplot_defaults();
+ var getSubplotData = require_get_data().getSubplotData;
+ var handlePrefixSuffixDefaults = require_prefix_suffix_defaults();
+ var handleTickLabelDefaults = require_tick_label_defaults();
+ var handleLineGridDefaults = require_line_grid_defaults();
+ var setConvertCartesian = require_set_convert();
+ var layoutAttributes = require_layout_attributes23();
+ var constants = require_constants34();
+ var axisNames = constants.axisNames;
+ var makeImagDflt = memoize(function(realTickvals) {
+ if (Lib.isTypedArray(realTickvals)) realTickvals = Array.from(realTickvals);
+ return realTickvals.slice().reverse().map(function(x) {
+ return -x;
+ }).concat([0]).concat(realTickvals);
+ }, String);
+ function handleDefaults(contIn, contOut, coerce, opts) {
+ var bgColor = coerce("bgcolor");
+ opts.bgColor = Color2.combine(bgColor, opts.paper_bgcolor);
+ var subplotData = getSubplotData(opts.fullData, constants.name, opts.id);
+ var layoutOut = opts.layoutOut;
+ var axName;
+ function coerceAxis(attr, dflt) {
+ return coerce(axName + "." + attr, dflt);
+ }
+ for (var i = 0; i < axisNames.length; i++) {
+ axName = axisNames[i];
+ if (!Lib.isPlainObject(contIn[axName])) {
+ contIn[axName] = {};
+ }
+ var axIn = contIn[axName];
+ var axOut = Template.newContainer(contOut, axName);
+ axOut._id = axOut._name = axName;
+ axOut._attr = opts.id + "." + axName;
+ axOut._traceIndices = subplotData.map(function(t) {
+ return t.index;
+ });
+ var visible = coerceAxis("visible");
+ axOut.type = "linear";
+ setConvertCartesian(axOut, layoutOut);
+ handlePrefixSuffixDefaults(axIn, axOut, coerceAxis, axOut.type);
+ if (visible) {
+ var isRealAxis = axName === "realaxis";
+ if (isRealAxis) coerceAxis("side");
+ if (isRealAxis) {
+ coerceAxis("tickvals");
+ } else {
+ var imagTickvalsDflt = makeImagDflt(
+ contOut.realaxis.tickvals || layoutAttributes.realaxis.tickvals.dflt
+ );
+ coerceAxis("tickvals", imagTickvalsDflt);
+ }
+ if (Lib.isTypedArray(axOut.tickvals)) axOut.tickvals = Array.from(axOut.tickvals);
+ var dfltColor;
+ var dfltFontColor;
+ var dfltFontSize;
+ var dfltFontFamily;
+ var font = opts.font || {};
+ if (visible) {
+ dfltColor = coerceAxis("color");
+ dfltFontColor = dfltColor === axIn.color ? dfltColor : font.color;
+ dfltFontSize = font.size;
+ dfltFontFamily = font.family;
+ }
+ handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
+ noAutotickangles: true,
+ noTicklabelshift: true,
+ noTicklabelstandoff: true,
+ noTicklabelstep: true,
+ noAng: !isRealAxis,
+ noExp: true,
+ font: {
+ color: dfltFontColor,
+ size: dfltFontSize,
+ family: dfltFontFamily
+ }
+ });
+ Lib.coerce2(contIn, contOut, layoutAttributes, axName + ".ticklen");
+ Lib.coerce2(contIn, contOut, layoutAttributes, axName + ".tickwidth");
+ Lib.coerce2(contIn, contOut, layoutAttributes, axName + ".tickcolor", contOut.color);
+ var showTicks = coerceAxis("ticks");
+ if (!showTicks) {
+ delete contOut[axName].ticklen;
+ delete contOut[axName].tickwidth;
+ delete contOut[axName].tickcolor;
+ }
+ handleLineGridDefaults(axIn, axOut, coerceAxis, {
+ dfltColor,
+ bgColor: opts.bgColor,
+ // default grid color is darker here (60%, vs cartesian default ~91%)
+ // because the grid is not square so the eye needs heavier cues to follow
+ blend: 60,
+ showLine: true,
+ showGrid: true,
+ noZeroLine: true,
+ attributes: layoutAttributes[axName]
+ });
+ coerceAxis("layer");
+ }
+ coerceAxis("hoverformat");
+ delete axOut.type;
+ axOut._input = axIn;
+ }
+ }
+ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
+ handleSubplotDefaults(layoutIn, layoutOut, fullData, {
+ noUirevision: true,
+ type: constants.name,
+ attributes: layoutAttributes,
+ handleDefaults,
+ font: layoutOut.font,
+ paper_bgcolor: layoutOut.paper_bgcolor,
+ fullData,
+ layoutOut
+ });
+ };
+ function memoize(fn, keyFn) {
+ var cache = {};
+ return function(val) {
+ var newKey = keyFn ? keyFn(val) : val;
+ if (newKey in cache) {
+ return cache[newKey];
+ }
+ var out = fn(val);
+ cache[newKey] = out;
+ return out;
+ };
+ }
+ }
+ });
+
+ // src/plots/smith/index.js
+ var require_smith = __commonJS({
+ "src/plots/smith/index.js"(exports, module) {
+ "use strict";
+ var getSubplotCalcData = require_get_data().getSubplotCalcData;
+ var counterRegex = require_lib().counterRegex;
+ var createPolar = require_polar();
+ var constants = require_constants34();
+ var attr = constants.attr;
+ var name2 = constants.name;
+ var counter = counterRegex(name2);
+ var attributes = {};
+ attributes[attr] = {
+ valType: "subplotid",
+ dflt: name2,
+ editType: "calc"
+ };
+ function plot(gd) {
+ var fullLayout = gd._fullLayout;
+ var calcData = gd.calcdata;
+ var subplotIds = fullLayout._subplots[name2];
+ for (var i = 0; i < subplotIds.length; i++) {
+ var id = subplotIds[i];
+ var subplotCalcData = getSubplotCalcData(calcData, name2, id);
+ var subplot = fullLayout[id]._subplot;
+ if (!subplot) {
+ subplot = createPolar(gd, id, true);
+ fullLayout[id]._subplot = subplot;
+ }
+ subplot.plot(subplotCalcData, fullLayout, gd._promises);
+ }
+ }
+ function clean(newFullData, newFullLayout, oldFullData, oldFullLayout) {
+ var oldIds = oldFullLayout._subplots[name2] || [];
+ for (var i = 0; i < oldIds.length; i++) {
+ var id = oldIds[i];
+ var oldSubplot = oldFullLayout[id]._subplot;
+ if (!newFullLayout[id] && !!oldSubplot) {
+ oldSubplot.framework.remove();
+ for (var k in oldSubplot.clipPaths) {
+ oldSubplot.clipPaths[k].remove();
+ }
+ }
+ }
+ }
+ module.exports = {
+ attr,
+ name: name2,
+ idRoot: name2,
+ idRegex: counter,
+ attrRegex: counter,
+ attributes,
+ layoutAttributes: require_layout_attributes23(),
+ supplyLayoutDefaults: require_layout_defaults21(),
+ plot,
+ clean,
+ toSVG: require_cartesian().toSVG
+ };
+ }
+ });
+
+ // src/traces/scattersmith/attributes.js
+ var require_attributes71 = __commonJS({
+ "src/traces/scattersmith/attributes.js"(exports, module) {
+ "use strict";
+ var hovertemplateAttrs = require_template_attributes().hovertemplateAttrs;
+ var texttemplateAttrs = require_template_attributes().texttemplateAttrs;
+ var extendFlat = require_extend().extendFlat;
+ var makeFillcolorAttr = require_fillcolor_attribute();
+ var scatterAttrs = require_attributes12();
+ var baseAttrs = require_attributes2();
+ var lineAttrs = scatterAttrs.line;
+ module.exports = {
+ mode: scatterAttrs.mode,
+ real: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ imag: {
+ valType: "data_array",
+ editType: "calc+clearAxisTypes"
+ },
+ text: scatterAttrs.text,
+ texttemplate: texttemplateAttrs({ editType: "plot" }, {
+ keys: ["real", "imag", "text"]
+ }),
+ hovertext: scatterAttrs.hovertext,
+ line: {
+ color: lineAttrs.color,
+ width: lineAttrs.width,
+ dash: lineAttrs.dash,
+ backoff: lineAttrs.backoff,
+ shape: extendFlat({}, lineAttrs.shape, {
+ values: ["linear", "spline"]
+ }),
+ smoothing: lineAttrs.smoothing,
+ editType: "calc"
+ },
+ connectgaps: scatterAttrs.connectgaps,
+ marker: scatterAttrs.marker,
+ cliponaxis: extendFlat({}, scatterAttrs.cliponaxis, { dflt: false }),
+ textposition: scatterAttrs.textposition,
+ textfont: scatterAttrs.textfont,
+ fill: extendFlat({}, scatterAttrs.fill, {
+ values: ["none", "toself", "tonext"],
+ dflt: "none"
+ }),
+ fillcolor: makeFillcolorAttr(),
+ hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
+ flags: ["real", "imag", "text", "name"]
+ }),
+ hoveron: scatterAttrs.hoveron,
+ hovertemplate: hovertemplateAttrs(),
+ selected: scatterAttrs.selected,
+ unselected: scatterAttrs.unselected
+ };
+ }
+ });
+
+ // src/traces/scattersmith/defaults.js
+ var require_defaults67 = __commonJS({
+ "src/traces/scattersmith/defaults.js"(exports, module) {
+ "use strict";
+ var Lib = require_lib();
+ var subTypes = require_subtypes();
+ var handleMarkerDefaults = require_marker_defaults();
+ var handleLineDefaults = require_line_defaults();
+ var handleLineShapeDefaults = require_line_shape_defaults();
+ var handleTextDefaults = require_text_defaults();
+ var handleFillColorDefaults = require_fillcolor_defaults();
+ var PTS_LINESONLY = require_constants8().PTS_LINESONLY;
+ var attributes = require_attributes71();
+ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
+ function coerce(attr, dflt) {
+ return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
+ }
+ var len = handleRealImagDefaults(traceIn, traceOut, layout, coerce);
+ if (!len) {
+ traceOut.visible = false;
+ return;
+ }
+ coerce("mode", len < PTS_LINESONLY ? "lines+markers" : "lines");
+ coerce("text");
+ coerce("hovertext");
+ if (traceOut.hoveron !== "fills") coerce("hovertemplate");
+ if (subTypes.hasMarkers(traceOut)) {
+ handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, { gradient: true });
+ }
+ if (subTypes.hasLines(traceOut)) {
+ handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce, { backoff: true });
+ handleLineShapeDefaults(traceIn, traceOut, coerce);
+ coerce("connectgaps");
+ }
+ if (subTypes.hasText(traceOut)) {
+ coerce("texttemplate");
+ handleTextDefaults(traceIn, traceOut, layout, coerce);
+ }
+ var dfltHoverOn = [];
+ if (subTypes.hasMarkers(traceOut) || subTypes.hasText(traceOut)) {
+ coerce("cliponaxis");
+ coerce("marker.maxdisplayed");
+ dfltHoverOn.push("points");
+ }
+ coerce("fill");
+ if (traceOut.fill !== "none") {
+ handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
+ if (!subTypes.hasLines(traceOut)) handleLineShapeDefaults(traceIn, traceOut, coerce);
+ }
+ if (traceOut.fill === "tonext" || traceOut.fill === "toself") {
+ dfltHoverOn.push("fills");
+ }
+ coerce("hoveron", dfltHoverOn.join("+") || "points");
+ Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
+ };
+ function handleRealImagDefaults(traceIn, traceOut, layout, coerce) {
+ var real = coerce("real");
+ var imag = coerce("imag");
+ var len;
+ if (real && imag) {
+ len = Math.min(real.length, imag.length);
+ }
+ if (Lib.isTypedArray(real)) {
+ traceOut.real = real = Array.from(real);
+ }
+ if (Lib.isTypedArray(imag)) {
+ traceOut.imag = imag = Array.from(imag);
+ }
+ traceOut._length = len;
+ return len;
+ }
+ }
+ });
+
+ // src/traces/scattersmith/format_labels.js
+ var require_format_labels10 = __commonJS({
+ "src/traces/scattersmith/format_labels.js"(exports, module) {
+ "use strict";
+ var Axes = require_axes();
+ module.exports = function formatLabels(cdi, trace, fullLayout) {
+ var labels = {};
+ var subplot = fullLayout[trace.subplot]._subplot;
+ labels.realLabel = Axes.tickText(subplot.radialAxis, cdi.real, true).text;
+ labels.imagLabel = Axes.tickText(subplot.angularAxis, cdi.imag, true).text;
+ return labels;
+ };
+ }
+ });
+
+ // src/traces/scattersmith/calc.js
+ var require_calc46 = __commonJS({
+ "src/traces/scattersmith/calc.js"(exports, module) {
+ "use strict";
+ var isNumeric = require_fast_isnumeric();
+ var BADNUM = require_numerical().BADNUM;
+ var calcColorscale = require_colorscale_calc();
+ var arraysToCalcdata = require_arrays_to_calcdata();
+ var calcSelection = require_calc_selection();
+ var calcMarkerSize = require_calc3().calcMarkerSize;
+ module.exports = function calc(gd, trace) {
+ var fullLayout = gd._fullLayout;
+ var subplotId = trace.subplot;
+ var realAxis = fullLayout[subplotId].realaxis;
+ var imaginaryAxis = fullLayout[subplotId].imaginaryaxis;
+ var realArray = realAxis.makeCalcdata(trace, "real");
+ var imagArray = imaginaryAxis.makeCalcdata(trace, "imag");
+ var len = trace._length;
+ var cd = new Array(len);
+ for (var i = 0; i < len; i++) {
+ var real = realArray[i];
+ var imag = imagArray[i];
+ var cdi = cd[i] = {};
+ if (isNumeric(real) && isNumeric(imag)) {
+ cdi.real = real;
+ cdi.imag = imag;
+ } else {
+ cdi.real = BADNUM;
+ }
+ }
+ calcMarkerSize(trace, len);
+ calcColorscale(gd, trace);
+ arraysToCalcdata(cd, trace);
+ calcSelection(cd, trace);
+ return cd;
+ };
+ }
+ });
+
+ // src/traces/scattersmith/plot.js
+ var require_plot39 = __commonJS({
+ "src/traces/scattersmith/plot.js"(exports, module) {
+ "use strict";
+ var scatterPlot = require_plot();
+ var BADNUM = require_numerical().BADNUM;
+ var helpers = require_helpers20();
+ var smith = helpers.smith;
+ module.exports = function plot(gd, subplot, moduleCalcData) {
+ var mlayer = subplot.layers.frontplot.select("g.scatterlayer");
+ var xa = subplot.xaxis;
+ var ya = subplot.yaxis;
+ var plotinfo = {
+ xaxis: xa,
+ yaxis: ya,
+ plot: subplot.framework,
+ layerClipId: subplot._hasClipOnAxisFalse ? subplot.clipIds.forTraces : null
+ };
+ for (var i = 0; i < moduleCalcData.length; i++) {
+ var cdi = moduleCalcData[i];
+ for (var j = 0; j < cdi.length; j++) {
+ if (j === 0) {
+ cdi[0].trace._xA = xa;
+ cdi[0].trace._yA = ya;
+ }
+ var cd = cdi[j];
+ var real = cd.real;
+ if (real === BADNUM) {
+ cd.x = cd.y = BADNUM;
+ } else {
+ var t = smith([real, cd.imag]);
+ cd.x = t[0];
+ cd.y = t[1];
+ }
+ }
+ }
+ scatterPlot(gd, plotinfo, moduleCalcData, mlayer);
+ };
+ }
+ });
+
+ // src/traces/scattersmith/hover.js
+ var require_hover27 = __commonJS({
+ "src/traces/scattersmith/hover.js"(exports, module) {
+ "use strict";
+ var scatterHover = require_hover2();
+ function hoverPoints(pointData, xval, yval, hovermode) {
+ var scatterPointData = scatterHover(pointData, xval, yval, hovermode);
+ if (!scatterPointData || scatterPointData[0].index === false) return;
+ var newPointData = scatterPointData[0];
+ if (newPointData.index === void 0) {
+ return scatterPointData;
+ }
+ var subplot = pointData.subplot;
+ var cdi = newPointData.cd[newPointData.index];
+ var trace = newPointData.trace;
+ if (!subplot.isPtInside(cdi)) return;
+ newPointData.xLabelVal = void 0;
+ newPointData.yLabelVal = void 0;
+ makeHoverPointText(cdi, trace, subplot, newPointData);
+ newPointData.hovertemplate = trace.hovertemplate;
+ return scatterPointData;
+ }
+ function makeHoverPointText(cdi, trace, subplot, pointData) {
+ var realAxis = subplot.radialAxis;
+ var imaginaryAxis = subplot.angularAxis;
+ realAxis._hovertitle = "real";
+ imaginaryAxis._hovertitle = "imag";
+ var fullLayout = {};
+ fullLayout[trace.subplot] = { _subplot: subplot };
+ var labels = trace._module.formatLabels(cdi, trace, fullLayout);
+ pointData.realLabel = labels.realLabel;
+ pointData.imagLabel = labels.imagLabel;
+ var hoverinfo = cdi.hi || trace.hoverinfo;
+ var text = [];
+ function textPart(ax, val) {
+ text.push(ax._hovertitle + ": " + val);
+ }
+ if (!trace.hovertemplate) {
+ var parts = hoverinfo.split("+");
+ if (parts.indexOf("all") !== -1) parts = ["real", "imag", "text"];
+ if (parts.indexOf("real") !== -1) textPart(realAxis, pointData.realLabel);
+ if (parts.indexOf("imag") !== -1) textPart(imaginaryAxis, pointData.imagLabel);
+ if (parts.indexOf("text") !== -1 && pointData.text) {
+ text.push(pointData.text);
+ delete pointData.text;
+ }
+ pointData.extraText = text.join("
");
+ }
+ }
+ module.exports = {
+ hoverPoints,
+ makeHoverPointText
+ };
+ }
+ });
+
+ // src/traces/scattersmith/index.js
+ var require_scattersmith = __commonJS({
+ "src/traces/scattersmith/index.js"(exports, module) {
+ "use strict";
+ module.exports = {
+ moduleType: "trace",
+ name: "scattersmith",
+ basePlotModule: require_smith(),
+ categories: ["smith", "symbols", "showLegend", "scatter-like"],
+ attributes: require_attributes71(),
+ supplyDefaults: require_defaults67(),
+ colorbar: require_marker_colorbar(),
+ formatLabels: require_format_labels10(),
+ calc: require_calc46(),
+ plot: require_plot39(),
+ style: require_style2().style,
+ styleOnSelect: require_style2().styleOnSelect,
+ hoverPoints: require_hover27().hoverPoints,
+ selectPoints: require_select2(),
+ meta: {}
+ };
+ }
+ });
+
+ // lib/scattersmith.js
+ var require_scattersmith2 = __commonJS({
+ "lib/scattersmith.js"(exports, module) {
+ "use strict";
+ module.exports = require_scattersmith();
+ }
+ });
+
+ // node_modules/world-calendars/dist/main.js
+ var require_main = __commonJS({
+ "node_modules/world-calendars/dist/main.js"(exports, module) {
+ var assign = require_object_assign();
+ function Calendars() {
+ this.regionalOptions = [];
+ this.regionalOptions[""] = {
+ invalidCalendar: "Calendar {0} not found",
+ invalidDate: "Invalid {0} date",
+ invalidMonth: "Invalid {0} month",
+ invalidYear: "Invalid {0} year",
+ differentCalendars: "Cannot mix {0} and {1} dates"
+ };
+ this.local = this.regionalOptions[""];
+ this.calendars = {};
+ this._localCals = {};
+ }
+ assign(Calendars.prototype, {
+ /** Obtain a calendar implementation and localisation.
+ @memberof Calendars
+ @param [name='gregorian'] {string} The name of the calendar, e.g. 'gregorian', 'persian', 'islamic'.
+ @param [language=''] {string} The language code to use for localisation (default is English).
+ @return {Calendar} The calendar and localisation.
+ @throws Error if calendar not found. */
+ instance: function(name2, language) {
+ name2 = (name2 || "gregorian").toLowerCase();
+ language = language || "";
+ var cal = this._localCals[name2 + "-" + language];
+ if (!cal && this.calendars[name2]) {
+ cal = new this.calendars[name2](language);
+ this._localCals[name2 + "-" + language] = cal;
+ }
+ if (!cal) {
+ throw (this.local.invalidCalendar || this.regionalOptions[""].invalidCalendar).replace(/\{0\}/, name2);
+ }
+ return cal;
+ },
+ /** Create a new date - for today if no other parameters given.
+ @memberof Calendars
+ @param year {CDate|number} The date to copy or the year for the date.
+ @param [month] {number} The month for the date.
+ @param [day] {number} The day for the date.
+ @param [calendar='gregorian'] {BaseCalendar|string} The underlying calendar or the name of the calendar.
+ @param [language=''] {string} The language to use for localisation (default English).
+ @return {CDate} The new date.
+ @throws Error if an invalid date. */
+ newDate: function(year, month, day, calendar, language) {
+ calendar = (year != null && year.year ? year.calendar() : typeof calendar === "string" ? this.instance(calendar, language) : calendar) || this.instance();
+ return calendar.newDate(year, month, day);
+ },
+ /** A simple digit substitution function for localising numbers via the Calendar digits option.
+ @member Calendars
+ @param digits {string[]} The substitute digits, for 0 through 9.
+ @return {function} The substitution function. */
+ substituteDigits: function(digits) {
+ return function(value) {
+ return (value + "").replace(/[0-9]/g, function(digit) {
+ return digits[digit];
+ });
+ };
+ },
+ /** Digit substitution function for localising Chinese style numbers via the Calendar digits option.
+ @member Calendars
+ @param digits {string[]} The substitute digits, for 0 through 9.
+ @param powers {string[]} The characters denoting powers of 10, i.e. 1, 10, 100, 1000.
+ @return {function} The substitution function. */
+ substituteChineseDigits: function(digits, powers) {
+ return function(value) {
+ var localNumber = "";
+ var power = 0;
+ while (value > 0) {
+ var units = value % 10;
+ localNumber = (units === 0 ? "" : digits[units] + powers[power]) + localNumber;
+ power++;
+ value = Math.floor(value / 10);
+ }
+ if (localNumber.indexOf(digits[1] + powers[1]) === 0) {
+ localNumber = localNumber.substr(1);
+ }
+ return localNumber || digits[0];
+ };
+ }
+ });
+ function CDate(calendar, year, month, day) {
+ this._calendar = calendar;
+ this._year = year;
+ this._month = month;
+ this._day = day;
+ if (this._calendar._validateLevel === 0 && !this._calendar.isValid(this._year, this._month, this._day)) {
+ throw (_exports.local.invalidDate || _exports.regionalOptions[""].invalidDate).replace(/\{0\}/, this._calendar.local.name);
+ }
+ }
+ function pad(value, length) {
+ value = "" + value;
+ return "000000".substring(0, length - value.length) + value;
+ }
+ assign(CDate.prototype, {
+ /** Create a new date.
+ @memberof CDate
+ @param [year] {CDate|number} The date to copy or the year for the date (default this date).
+ @param [month] {number} The month for the date.
+ @param [day] {number} The day for the date.
+ @return {CDate} The new date.
+ @throws Error if an invalid date. */
+ newDate: function(year, month, day) {
+ return this._calendar.newDate(year == null ? this : year, month, day);
+ },
+ /** Set or retrieve the year for this date.
+ @memberof CDate
+ @param [year] {number} The year for the date.
+ @return {number|CDate} The date's year (if no parameter) or the updated date.
+ @throws Error if an invalid date. */
+ year: function(year) {
+ return arguments.length === 0 ? this._year : this.set(year, "y");
+ },
+ /** Set or retrieve the month for this date.
+ @memberof CDate
+ @param [month] {number} The month for the date.
+ @return {number|CDate} The date's month (if no parameter) or the updated date.
+ @throws Error if an invalid date. */
+ month: function(month) {
+ return arguments.length === 0 ? this._month : this.set(month, "m");
+ },
+ /** Set or retrieve the day for this date.
+ @memberof CDate
+ @param [day] {number} The day for the date.
+ @return {number|CData} The date's day (if no parameter) or the updated date.
+ @throws Error if an invalid date. */
+ day: function(day) {
+ return arguments.length === 0 ? this._day : this.set(day, "d");
+ },
+ /** Set new values for this date.
+ @memberof CDate
+ @param year {number} The year for the date.
+ @param month {number} The month for the date.
+ @param day {number} The day for the date.
+ @return {CDate} The updated date.
+ @throws Error if an invalid date. */
+ date: function(year, month, day) {
+ if (!this._calendar.isValid(year, month, day)) {
+ throw (_exports.local.invalidDate || _exports.regionalOptions[""].invalidDate).replace(/\{0\}/, this._calendar.local.name);
+ }
+ this._year = year;
+ this._month = month;
+ this._day = day;
+ return this;
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof CDate
+ @return {boolean} true
if this is a leap year, false
if not. */
+ leapYear: function() {
+ return this._calendar.leapYear(this);
+ },
+ /** Retrieve the epoch designator for this date, e.g. BCE or CE.
+ @memberof CDate
+ @return {string} The current epoch. */
+ epoch: function() {
+ return this._calendar.epoch(this);
+ },
+ /** Format the year, if not a simple sequential number.
+ @memberof CDate
+ @return {string} The formatted year. */
+ formatYear: function() {
+ return this._calendar.formatYear(this);
+ },
+ /** Retrieve the month of the year for this date,
+ i.e. the month's position within a numbered year.
+ @memberof CDate
+ @return {number} The month of the year: minMonth
to months per year. */
+ monthOfYear: function() {
+ return this._calendar.monthOfYear(this);
+ },
+ /** Retrieve the week of the year for this date.
+ @memberof CDate
+ @return {number} The week of the year: 1 to weeks per year. */
+ weekOfYear: function() {
+ return this._calendar.weekOfYear(this);
+ },
+ /** Retrieve the number of days in the year for this date.
+ @memberof CDate
+ @return {number} The number of days in this year. */
+ daysInYear: function() {
+ return this._calendar.daysInYear(this);
+ },
+ /** Retrieve the day of the year for this date.
+ @memberof CDate
+ @return {number} The day of the year: 1 to days per year. */
+ dayOfYear: function() {
+ return this._calendar.dayOfYear(this);
+ },
+ /** Retrieve the number of days in the month for this date.
+ @memberof CDate
+ @return {number} The number of days. */
+ daysInMonth: function() {
+ return this._calendar.daysInMonth(this);
+ },
+ /** Retrieve the day of the week for this date.
+ @memberof CDate
+ @return {number} The day of the week: 0 to number of days - 1. */
+ dayOfWeek: function() {
+ return this._calendar.dayOfWeek(this);
+ },
+ /** Determine whether this date is a week day.
+ @memberof CDate
+ @return {boolean} true
if a week day, false
if not. */
+ weekDay: function() {
+ return this._calendar.weekDay(this);
+ },
+ /** Retrieve additional information about this date.
+ @memberof CDate
+ @return {object} Additional information - contents depends on calendar. */
+ extraInfo: function() {
+ return this._calendar.extraInfo(this);
+ },
+ /** Add period(s) to a date.
+ @memberof CDate
+ @param offset {number} The number of periods to adjust by.
+ @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day.
+ @return {CDate} The updated date. */
+ add: function(offset, period) {
+ return this._calendar.add(this, offset, period);
+ },
+ /** Set a portion of the date.
+ @memberof CDate
+ @param value {number} The new value for the period.
+ @param period {string} One of 'y' for year, 'm' for month, 'd' for day.
+ @return {CDate} The updated date.
+ @throws Error if not a valid date. */
+ set: function(value, period) {
+ return this._calendar.set(this, value, period);
+ },
+ /** Compare this date to another date.
+ @memberof CDate
+ @param date {CDate} The other date.
+ @return {number} -1 if this date is before the other date,
+ 0 if they are equal, or +1 if this date is after the other date. */
+ compareTo: function(date) {
+ if (this._calendar.name !== date._calendar.name) {
+ throw (_exports.local.differentCalendars || _exports.regionalOptions[""].differentCalendars).replace(/\{0\}/, this._calendar.local.name).replace(/\{1\}/, date._calendar.local.name);
+ }
+ var c = this._year !== date._year ? this._year - date._year : this._month !== date._month ? this.monthOfYear() - date.monthOfYear() : this._day - date._day;
+ return c === 0 ? 0 : c < 0 ? -1 : 1;
+ },
+ /** Retrieve the calendar backing this date.
+ @memberof CDate
+ @return {BaseCalendar} The calendar implementation. */
+ calendar: function() {
+ return this._calendar;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof CDate
+ @return {number} The equivalent Julian date. */
+ toJD: function() {
+ return this._calendar.toJD(this);
+ },
+ /** Create a new date from a Julian date.
+ @memberof CDate
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ return this._calendar.fromJD(jd);
+ },
+ /** Convert this date to a standard (Gregorian) JavaScript Date.
+ @memberof CDate
+ @return {Date} The equivalent JavaScript date. */
+ toJSDate: function() {
+ return this._calendar.toJSDate(this);
+ },
+ /** Create a new date from a standard (Gregorian) JavaScript Date.
+ @memberof CDate
+ @param jsd {Date} The JavaScript date to convert.
+ @return {CDate} The equivalent date. */
+ fromJSDate: function(jsd) {
+ return this._calendar.fromJSDate(jsd);
+ },
+ /** Convert to a string for display.
+ @memberof CDate
+ @return {string} This date as a string. */
+ toString: function() {
+ return (this.year() < 0 ? "-" : "") + pad(Math.abs(this.year()), 4) + "-" + pad(this.month(), 2) + "-" + pad(this.day(), 2);
+ }
+ });
+ function BaseCalendar() {
+ this.shortYearCutoff = "+10";
+ }
+ assign(BaseCalendar.prototype, {
+ _validateLevel: 0,
+ // "Stack" to turn validation on/off
+ /** Create a new date within this calendar - today if no parameters given.
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to duplicate or the year for the date.
+ @param [month] {number} The month for the date.
+ @param [day] {number} The day for the date.
+ @return {CDate} The new date.
+ @throws Error if not a valid date or a different calendar used. */
+ newDate: function(year, month, day) {
+ if (year == null) {
+ return this.today();
+ }
+ if (year.year) {
+ this._validate(
+ year,
+ month,
+ day,
+ _exports.local.invalidDate || _exports.regionalOptions[""].invalidDate
+ );
+ day = year.day();
+ month = year.month();
+ year = year.year();
+ }
+ return new CDate(this, year, month, day);
+ },
+ /** Create a new date for today.
+ @memberof BaseCalendar
+ @return {CDate} Today's date. */
+ today: function() {
+ return this.fromJSDate(/* @__PURE__ */ new Date());
+ },
+ /** Retrieve the epoch designator for this date.
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {string} The current epoch.
+ @throws Error if an invalid year or a different calendar used. */
+ epoch: function(year) {
+ var date = this._validate(
+ year,
+ this.minMonth,
+ this.minDay,
+ _exports.local.invalidYear || _exports.regionalOptions[""].invalidYear
+ );
+ return date.year() < 0 ? this.local.epochs[0] : this.local.epochs[1];
+ },
+ /** Format the year, if not a simple sequential number
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to format or the year to format.
+ @return {string} The formatted year.
+ @throws Error if an invalid year or a different calendar used. */
+ formatYear: function(year) {
+ var date = this._validate(
+ year,
+ this.minMonth,
+ this.minDay,
+ _exports.local.invalidYear || _exports.regionalOptions[""].invalidYear
+ );
+ return (date.year() < 0 ? "-" : "") + pad(Math.abs(date.year()), 4);
+ },
+ /** Retrieve the number of months in a year.
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of months.
+ @throws Error if an invalid year or a different calendar used. */
+ monthsInYear: function(year) {
+ this._validate(
+ year,
+ this.minMonth,
+ this.minDay,
+ _exports.local.invalidYear || _exports.regionalOptions[""].invalidYear
+ );
+ return 12;
+ },
+ /** Calculate the month's ordinal position within the year -
+ for those calendars that don't start at month 1!
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param month {number} The month to examine.
+ @return {number} The ordinal position, starting from minMonth
.
+ @throws Error if an invalid year/month or a different calendar used. */
+ monthOfYear: function(year, month) {
+ var date = this._validate(
+ year,
+ month,
+ this.minDay,
+ _exports.local.invalidMonth || _exports.regionalOptions[""].invalidMonth
+ );
+ return (date.month() + this.monthsInYear(date) - this.firstMonth) % this.monthsInYear(date) + this.minMonth;
+ },
+ /** Calculate actual month from ordinal position, starting from minMonth.
+ @memberof BaseCalendar
+ @param year {number} The year to examine.
+ @param ord {number} The month's ordinal position.
+ @return {number} The month's number.
+ @throws Error if an invalid year/month. */
+ fromMonthOfYear: function(year, ord) {
+ var m = (ord + this.firstMonth - 2 * this.minMonth) % this.monthsInYear(year) + this.minMonth;
+ this._validate(
+ year,
+ m,
+ this.minDay,
+ _exports.local.invalidMonth || _exports.regionalOptions[""].invalidMonth
+ );
+ return m;
+ },
+ /** Retrieve the number of days in a year.
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of days.
+ @throws Error if an invalid year or a different calendar used. */
+ daysInYear: function(year) {
+ var date = this._validate(
+ year,
+ this.minMonth,
+ this.minDay,
+ _exports.local.invalidYear || _exports.regionalOptions[""].invalidYear
+ );
+ return this.leapYear(date) ? 366 : 365;
+ },
+ /** Retrieve the day of the year for a date.
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The day of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ dayOfYear: function(year, month, day) {
+ var date = this._validate(
+ year,
+ month,
+ day,
+ _exports.local.invalidDate || _exports.regionalOptions[""].invalidDate
+ );
+ return date.toJD() - this.newDate(
+ date.year(),
+ this.fromMonthOfYear(date.year(), this.minMonth),
+ this.minDay
+ ).toJD() + 1;
+ },
+ /** Retrieve the number of days in a week.
+ @memberof BaseCalendar
+ @return {number} The number of days. */
+ daysInWeek: function() {
+ return 7;
+ },
+ /** Retrieve the day of the week for a date.
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The day of the week: 0 to number of days - 1.
+ @throws Error if an invalid date or a different calendar used. */
+ dayOfWeek: function(year, month, day) {
+ var date = this._validate(
+ year,
+ month,
+ day,
+ _exports.local.invalidDate || _exports.regionalOptions[""].invalidDate
+ );
+ return (Math.floor(this.toJD(date)) + 2) % this.daysInWeek();
+ },
+ /** Retrieve additional information about a date.
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {object} Additional information - contents depends on calendar.
+ @throws Error if an invalid date or a different calendar used. */
+ extraInfo: function(year, month, day) {
+ this._validate(
+ year,
+ month,
+ day,
+ _exports.local.invalidDate || _exports.regionalOptions[""].invalidDate
+ );
+ return {};
+ },
+ /** Add period(s) to a date.
+ Cater for no year zero.
+ @memberof BaseCalendar
+ @param date {CDate} The starting date.
+ @param offset {number} The number of periods to adjust by.
+ @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day.
+ @return {CDate} The updated date.
+ @throws Error if a different calendar used. */
+ add: function(date, offset, period) {
+ this._validate(
+ date,
+ this.minMonth,
+ this.minDay,
+ _exports.local.invalidDate || _exports.regionalOptions[""].invalidDate
+ );
+ return this._correctAdd(date, this._add(date, offset, period), offset, period);
+ },
+ /** Add period(s) to a date.
+ @memberof BaseCalendar
+ @private
+ @param date {CDate} The starting date.
+ @param offset {number} The number of periods to adjust by.
+ @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day.
+ @return {CDate} The updated date. */
+ _add: function(date, offset, period) {
+ this._validateLevel++;
+ if (period === "d" || period === "w") {
+ var jd = date.toJD() + offset * (period === "w" ? this.daysInWeek() : 1);
+ var d = date.calendar().fromJD(jd);
+ this._validateLevel--;
+ return [d.year(), d.month(), d.day()];
+ }
+ try {
+ var y = date.year() + (period === "y" ? offset : 0);
+ var m = date.monthOfYear() + (period === "m" ? offset : 0);
+ var d = date.day();
+ var resyncYearMonth = function(calendar) {
+ while (m < calendar.minMonth) {
+ y--;
+ m += calendar.monthsInYear(y);
+ }
+ var yearMonths = calendar.monthsInYear(y);
+ while (m > yearMonths - 1 + calendar.minMonth) {
+ y++;
+ m -= yearMonths;
+ yearMonths = calendar.monthsInYear(y);
+ }
+ };
+ if (period === "y") {
+ if (date.month() !== this.fromMonthOfYear(y, m)) {
+ m = this.newDate(y, date.month(), this.minDay).monthOfYear();
+ }
+ m = Math.min(m, this.monthsInYear(y));
+ d = Math.min(d, this.daysInMonth(y, this.fromMonthOfYear(y, m)));
+ } else if (period === "m") {
+ resyncYearMonth(this);
+ d = Math.min(d, this.daysInMonth(y, this.fromMonthOfYear(y, m)));
+ }
+ var ymd = [y, this.fromMonthOfYear(y, m), d];
+ this._validateLevel--;
+ return ymd;
+ } catch (e) {
+ this._validateLevel--;
+ throw e;
+ }
+ },
+ /** Correct a candidate date after adding period(s) to a date.
+ Handle no year zero if necessary.
+ @memberof BaseCalendar
+ @private
+ @param date {CDate} The starting date.
+ @param ymd {number[]} The added date.
+ @param offset {number} The number of periods to adjust by.
+ @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day.
+ @return {CDate} The updated date. */
+ _correctAdd: function(date, ymd, offset, period) {
+ if (!this.hasYearZero && (period === "y" || period === "m")) {
+ if (ymd[0] === 0 || // In year zero
+ date.year() > 0 !== ymd[0] > 0) {
+ var adj = {
+ y: [1, 1, "y"],
+ m: [1, this.monthsInYear(-1), "m"],
+ w: [this.daysInWeek(), this.daysInYear(-1), "d"],
+ d: [1, this.daysInYear(-1), "d"]
+ }[period];
+ var dir = offset < 0 ? -1 : 1;
+ ymd = this._add(date, offset * adj[0] + dir * adj[1], adj[2]);
+ }
+ }
+ return date.date(ymd[0], ymd[1], ymd[2]);
+ },
+ /** Set a portion of the date.
+ @memberof BaseCalendar
+ @param date {CDate} The starting date.
+ @param value {number} The new value for the period.
+ @param period {string} One of 'y' for year, 'm' for month, 'd' for day.
+ @return {CDate} The updated date.
+ @throws Error if an invalid date or a different calendar used. */
+ set: function(date, value, period) {
+ this._validate(
+ date,
+ this.minMonth,
+ this.minDay,
+ _exports.local.invalidDate || _exports.regionalOptions[""].invalidDate
+ );
+ var y = period === "y" ? value : date.year();
+ var m = period === "m" ? value : date.month();
+ var d = period === "d" ? value : date.day();
+ if (period === "y" || period === "m") {
+ d = Math.min(d, this.daysInMonth(y, m));
+ }
+ return date.date(y, m, d);
+ },
+ /** Determine whether a date is valid for this calendar.
+ @memberof BaseCalendar
+ @param year {number} The year to examine.
+ @param month {number} The month to examine.
+ @param day {number} The day to examine.
+ @return {boolean} true
if a valid date, false
if not. */
+ isValid: function(year, month, day) {
+ this._validateLevel++;
+ var valid = this.hasYearZero || year !== 0;
+ if (valid) {
+ var date = this.newDate(year, month, this.minDay);
+ valid = month >= this.minMonth && month - this.minMonth < this.monthsInYear(date) && (day >= this.minDay && day - this.minDay < this.daysInMonth(date));
+ }
+ this._validateLevel--;
+ return valid;
+ },
+ /** Convert the date to a standard (Gregorian) JavaScript Date.
+ @memberof BaseCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {Date} The equivalent JavaScript date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJSDate: function(year, month, day) {
+ var date = this._validate(
+ year,
+ month,
+ day,
+ _exports.local.invalidDate || _exports.regionalOptions[""].invalidDate
+ );
+ return _exports.instance().fromJD(this.toJD(date)).toJSDate();
+ },
+ /** Convert the date from a standard (Gregorian) JavaScript Date.
+ @memberof BaseCalendar
+ @param jsd {Date} The JavaScript date.
+ @return {CDate} The equivalent calendar date. */
+ fromJSDate: function(jsd) {
+ return this.fromJD(_exports.instance().fromJSDate(jsd).toJD());
+ },
+ /** Check that a candidate date is from the same calendar and is valid.
+ @memberof BaseCalendar
+ @private
+ @param year {CDate|number} The date to validate or the year to validate.
+ @param [month] {number} The month to validate.
+ @param [day] {number} The day to validate.
+ @param error {string} Rrror message if invalid.
+ @throws Error if different calendars used or invalid date. */
+ _validate: function(year, month, day, error) {
+ if (year.year) {
+ if (this._validateLevel === 0 && this.name !== year.calendar().name) {
+ throw (_exports.local.differentCalendars || _exports.regionalOptions[""].differentCalendars).replace(/\{0\}/, this.local.name).replace(/\{1\}/, year.calendar().local.name);
+ }
+ return year;
+ }
+ try {
+ this._validateLevel++;
+ if (this._validateLevel === 1 && !this.isValid(year, month, day)) {
+ throw error.replace(/\{0\}/, this.local.name);
+ }
+ var date = this.newDate(year, month, day);
+ this._validateLevel--;
+ return date;
+ } catch (e) {
+ this._validateLevel--;
+ throw e;
+ }
+ }
+ });
+ function GregorianCalendar(language) {
+ this.local = this.regionalOptions[language] || this.regionalOptions[""];
+ }
+ GregorianCalendar.prototype = new BaseCalendar();
+ assign(GregorianCalendar.prototype, {
+ /** The calendar name.
+ @memberof GregorianCalendar */
+ name: "Gregorian",
+ /** Julian date of start of Gregorian epoch: 1 January 0001 CE.
+ @memberof GregorianCalendar */
+ jdEpoch: 17214255e-1,
+ /** Days per month in a common year.
+ @memberof GregorianCalendar */
+ daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
+ /** true
if has a year zero, false
if not.
+ @memberof GregorianCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof GregorianCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof GregorianCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof GregorianCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof GregorianCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Gregorian",
+ epochs: ["BCE", "CE"],
+ monthNames: [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+ ],
+ monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
+ dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
+ dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
+ digits: null,
+ dateFormat: "mm/dd/yyyy",
+ firstDay: 0,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof GregorianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(
+ year,
+ this.minMonth,
+ this.minDay,
+ _exports.local.invalidYear || _exports.regionalOptions[""].invalidYear
+ );
+ var year = date.year() + (date.year() < 0 ? 1 : 0);
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
+ },
+ /** Determine the week of the year for a date - ISO 8601.
+ @memberof GregorianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year, starting from 1.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(4 - (checkDate.dayOfWeek() || 7), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof GregorianCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(
+ year,
+ month,
+ this.minDay,
+ _exports.local.invalidMonth || _exports.regionalOptions[""].invalidMonth
+ );
+ return this.daysPerMonth[date.month() - 1] + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0);
+ },
+ /** Determine whether this date is a week day.
+ @memberof GregorianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return (this.dayOfWeek(year, month, day) || 7) < 6;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof GregorianCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(
+ year,
+ month,
+ day,
+ _exports.local.invalidDate || _exports.regionalOptions[""].invalidDate
+ );
+ year = date.year();
+ month = date.month();
+ day = date.day();
+ if (year < 0) {
+ year++;
+ }
+ if (month < 3) {
+ month += 12;
+ year--;
+ }
+ var a = Math.floor(year / 100);
+ var b = 2 - a + Math.floor(a / 4);
+ return Math.floor(365.25 * (year + 4716)) + Math.floor(30.6001 * (month + 1)) + day + b - 1524.5;
+ },
+ /** Create a new date from a Julian date.
+ @memberof GregorianCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ var z = Math.floor(jd + 0.5);
+ var a = Math.floor((z - 186721625e-2) / 36524.25);
+ a = z + 1 + a - Math.floor(a / 4);
+ var b = a + 1524;
+ var c = Math.floor((b - 122.1) / 365.25);
+ var d = Math.floor(365.25 * c);
+ var e = Math.floor((b - d) / 30.6001);
+ var day = b - d - Math.floor(e * 30.6001);
+ var month = e - (e > 13.5 ? 13 : 1);
+ var year = c - (month > 2.5 ? 4716 : 4715);
+ if (year <= 0) {
+ year--;
+ }
+ return this.newDate(year, month, day);
+ },
+ /** Convert this date to a standard (Gregorian) JavaScript Date.
+ @memberof GregorianCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {Date} The equivalent JavaScript date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJSDate: function(year, month, day) {
+ var date = this._validate(
+ year,
+ month,
+ day,
+ _exports.local.invalidDate || _exports.regionalOptions[""].invalidDate
+ );
+ var jsd = new Date(date.year(), date.month() - 1, date.day());
+ jsd.setHours(0);
+ jsd.setMinutes(0);
+ jsd.setSeconds(0);
+ jsd.setMilliseconds(0);
+ jsd.setHours(jsd.getHours() > 12 ? jsd.getHours() + 2 : 0);
+ return jsd;
+ },
+ /** Create a new date from a standard (Gregorian) JavaScript Date.
+ @memberof GregorianCalendar
+ @param jsd {Date} The JavaScript date to convert.
+ @return {CDate} The equivalent date. */
+ fromJSDate: function(jsd) {
+ return this.newDate(jsd.getFullYear(), jsd.getMonth() + 1, jsd.getDate());
+ }
+ });
+ var _exports = module.exports = new Calendars();
+ _exports.cdate = CDate;
+ _exports.baseCalendar = BaseCalendar;
+ _exports.calendars.gregorian = GregorianCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/plus.js
+ var require_plus = __commonJS({
+ "node_modules/world-calendars/dist/plus.js"() {
+ var assign = require_object_assign();
+ var main = require_main();
+ assign(main.regionalOptions[""], {
+ invalidArguments: "Invalid arguments",
+ invalidFormat: "Cannot format a date from another calendar",
+ missingNumberAt: "Missing number at position {0}",
+ unknownNameAt: "Unknown name at position {0}",
+ unexpectedLiteralAt: "Unexpected literal at position {0}",
+ unexpectedText: "Additional text found at end"
+ });
+ main.local = main.regionalOptions[""];
+ assign(main.cdate.prototype, {
+ /** Format this date.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof CDate
+ @param [format] {string} The date format to use (see formatDate
).
+ @param [settings] {object} Options for the formatDate
function.
+ @return {string} The formatted date. */
+ formatDate: function(format, settings) {
+ if (typeof format !== "string") {
+ settings = format;
+ format = "";
+ }
+ return this._calendar.formatDate(format || "", this, settings);
+ }
+ });
+ assign(main.baseCalendar.prototype, {
+ UNIX_EPOCH: main.instance().newDate(1970, 1, 1).toJD(),
+ SECS_PER_DAY: 24 * 60 * 60,
+ TICKS_EPOCH: main.instance().jdEpoch,
+ // 1 January 0001 CE
+ TICKS_PER_DAY: 24 * 60 * 60 * 1e7,
+ /** Date form for ATOM (RFC 3339/ISO 8601).
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ ATOM: "yyyy-mm-dd",
+ /** Date form for cookies.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ COOKIE: "D, dd M yyyy",
+ /** Date form for full date.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ FULL: "DD, MM d, yyyy",
+ /** Date form for ISO 8601.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ ISO_8601: "yyyy-mm-dd",
+ /** Date form for Julian date.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ JULIAN: "J",
+ /** Date form for RFC 822.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ RFC_822: "D, d M yy",
+ /** Date form for RFC 850.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ RFC_850: "DD, dd-M-yy",
+ /** Date form for RFC 1036.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ RFC_1036: "D, d M yy",
+ /** Date form for RFC 1123.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ RFC_1123: "D, d M yyyy",
+ /** Date form for RFC 2822.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ RFC_2822: "D, d M yyyy",
+ /** Date form for RSS (RFC 822).
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ RSS: "D, d M yy",
+ /** Date form for Windows ticks.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ TICKS: "!",
+ /** Date form for Unix timestamp.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ TIMESTAMP: "@",
+ /** Date form for W3c (ISO 8601).
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar */
+ W3C: "yyyy-mm-dd",
+ /** Format a date object into a string value.
+ The format can be combinations of the following:
+
+
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar
+ @param [format] {string} The desired format of the date (defaults to calendar format).
+ @param date {CDate} The date value to format.
+ @param [settings] {object} Addition options, whose attributes include:
+ @property [dayNamesShort] {string[]} Abbreviated names of the days from Sunday.
+ @property [dayNames] {string[]} Names of the days from Sunday.
+ @property [monthNamesShort] {string[]} Abbreviated names of the months.
+ @property [monthNames] {string[]} Names of the months.
+ @property [calculateWeek] {CalendarsPickerCalculateWeek} Function that determines week of the year.
+ @property [localNumbers=false] {boolean} true
to localise numbers (if available),
+ false
to use normal Arabic numerals.
+ @return {string} The date in the above format.
+ @throws Errors if the date is from a different calendar. */
+ formatDate: function(format, date, settings) {
+ if (typeof format !== "string") {
+ settings = date;
+ date = format;
+ format = "";
+ }
+ if (!date) {
+ return "";
+ }
+ if (date.calendar() !== this) {
+ throw main.local.invalidFormat || main.regionalOptions[""].invalidFormat;
+ }
+ format = format || this.local.dateFormat;
+ settings = settings || {};
+ var dayNamesShort = settings.dayNamesShort || this.local.dayNamesShort;
+ var dayNames = settings.dayNames || this.local.dayNames;
+ var monthNumbers = settings.monthNumbers || this.local.monthNumbers;
+ var monthNamesShort = settings.monthNamesShort || this.local.monthNamesShort;
+ var monthNames = settings.monthNames || this.local.monthNames;
+ var calculateWeek = settings.calculateWeek || this.local.calculateWeek;
+ var doubled = function(match, step) {
+ var matches = 1;
+ while (iFormat + matches < format.length && format.charAt(iFormat + matches) === match) {
+ matches++;
+ }
+ iFormat += matches - 1;
+ return Math.floor(matches / (step || 1)) > 1;
+ };
+ var formatNumber = function(match, value, len, step) {
+ var num = "" + value;
+ if (doubled(match, step)) {
+ while (num.length < len) {
+ num = "0" + num;
+ }
+ }
+ return num;
+ };
+ var formatName = function(match, value, shortNames, longNames) {
+ return doubled(match) ? longNames[value] : shortNames[value];
+ };
+ var calendar = this;
+ var formatMonth = function(date2) {
+ return typeof monthNumbers === "function" ? monthNumbers.call(calendar, date2, doubled("m")) : localiseNumbers(formatNumber("m", date2.month(), 2));
+ };
+ var formatMonthName = function(date2, useLongName) {
+ if (useLongName) {
+ return typeof monthNames === "function" ? monthNames.call(calendar, date2) : monthNames[date2.month() - calendar.minMonth];
+ } else {
+ return typeof monthNamesShort === "function" ? monthNamesShort.call(calendar, date2) : monthNamesShort[date2.month() - calendar.minMonth];
+ }
+ };
+ var digits = this.local.digits;
+ var localiseNumbers = function(value) {
+ return settings.localNumbers && digits ? digits(value) : value;
+ };
+ var output = "";
+ var literal = false;
+ for (var iFormat = 0; iFormat < format.length; iFormat++) {
+ if (literal) {
+ if (format.charAt(iFormat) === "'" && !doubled("'")) {
+ literal = false;
+ } else {
+ output += format.charAt(iFormat);
+ }
+ } else {
+ switch (format.charAt(iFormat)) {
+ case "d":
+ output += localiseNumbers(formatNumber("d", date.day(), 2));
+ break;
+ case "D":
+ output += formatName(
+ "D",
+ date.dayOfWeek(),
+ dayNamesShort,
+ dayNames
+ );
+ break;
+ case "o":
+ output += formatNumber("o", date.dayOfYear(), 3);
+ break;
+ case "w":
+ output += formatNumber("w", date.weekOfYear(), 2);
+ break;
+ case "m":
+ output += formatMonth(date);
+ break;
+ case "M":
+ output += formatMonthName(date, doubled("M"));
+ break;
+ case "y":
+ output += doubled("y", 2) ? date.year() : (date.year() % 100 < 10 ? "0" : "") + date.year() % 100;
+ break;
+ case "Y":
+ doubled("Y", 2);
+ output += date.formatYear();
+ break;
+ case "J":
+ output += date.toJD();
+ break;
+ case "@":
+ output += (date.toJD() - this.UNIX_EPOCH) * this.SECS_PER_DAY;
+ break;
+ case "!":
+ output += (date.toJD() - this.TICKS_EPOCH) * this.TICKS_PER_DAY;
+ break;
+ case "'":
+ if (doubled("'")) {
+ output += "'";
+ } else {
+ literal = true;
+ }
+ break;
+ default:
+ output += format.charAt(iFormat);
+ }
+ }
+ }
+ return output;
+ },
+ /** Parse a string value into a date object.
+ See formatDate
for the possible formats, plus:
+
+
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar
+ @param format {string} The expected format of the date ('' for default calendar format).
+ @param value {string} The date in the above format.
+ @param [settings] {object} Additional options whose attributes include:
+ @property [shortYearCutoff] {number} The cutoff year for determining the century.
+ @property [dayNamesShort] {string[]} Abbreviated names of the days from Sunday.
+ @property [dayNames] {string[]} Names of the days from Sunday.
+ @property [monthNamesShort] {string[]} Abbreviated names of the months.
+ @property [monthNames] {string[]} Names of the months.
+ @return {CDate} The extracted date value or null
if value is blank.
+ @throws Errors if the format and/or value are missing,
+ if the value doesn't match the format, or if the date is invalid. */
+ parseDate: function(format, value, settings) {
+ if (value == null) {
+ throw main.local.invalidArguments || main.regionalOptions[""].invalidArguments;
+ }
+ value = typeof value === "object" ? value.toString() : value + "";
+ if (value === "") {
+ return null;
+ }
+ format = format || this.local.dateFormat;
+ settings = settings || {};
+ var shortYearCutoff = settings.shortYearCutoff || this.shortYearCutoff;
+ shortYearCutoff = typeof shortYearCutoff !== "string" ? shortYearCutoff : this.today().year() % 100 + parseInt(shortYearCutoff, 10);
+ var dayNamesShort = settings.dayNamesShort || this.local.dayNamesShort;
+ var dayNames = settings.dayNames || this.local.dayNames;
+ var parseMonth = settings.parseMonth || this.local.parseMonth;
+ var monthNumbers = settings.monthNumbers || this.local.monthNumbers;
+ var monthNamesShort = settings.monthNamesShort || this.local.monthNamesShort;
+ var monthNames = settings.monthNames || this.local.monthNames;
+ var jd = -1;
+ var year = -1;
+ var month = -1;
+ var day = -1;
+ var doy = -1;
+ var shortYear = false;
+ var literal = false;
+ var doubled = function(match, step) {
+ var matches = 1;
+ while (iFormat + matches < format.length && format.charAt(iFormat + matches) === match) {
+ matches++;
+ }
+ iFormat += matches - 1;
+ return Math.floor(matches / (step || 1)) > 1;
+ };
+ var getNumber = function(match, step) {
+ var isDoubled = doubled(match, step);
+ var size = [2, 3, isDoubled ? 4 : 2, isDoubled ? 4 : 2, 10, 11, 20]["oyYJ@!".indexOf(match) + 1];
+ var digits = new RegExp("^-?\\d{1," + size + "}");
+ var num = value.substring(iValue).match(digits);
+ if (!num) {
+ throw (main.local.missingNumberAt || main.regionalOptions[""].missingNumberAt).replace(/\{0\}/, iValue);
+ }
+ iValue += num[0].length;
+ return parseInt(num[0], 10);
+ };
+ var calendar = this;
+ var getMonthNumber = function() {
+ if (typeof monthNumbers === "function") {
+ doubled("m");
+ var month2 = monthNumbers.call(calendar, value.substring(iValue));
+ iValue += month2.length;
+ return month2;
+ }
+ return getNumber("m");
+ };
+ var getName = function(match, shortNames, longNames, step) {
+ var names2 = doubled(match, step) ? longNames : shortNames;
+ for (var i = 0; i < names2.length; i++) {
+ if (value.substr(iValue, names2[i].length).toLowerCase() === names2[i].toLowerCase()) {
+ iValue += names2[i].length;
+ return i + calendar.minMonth;
+ }
+ }
+ throw (main.local.unknownNameAt || main.regionalOptions[""].unknownNameAt).replace(/\{0\}/, iValue);
+ };
+ var getMonthName = function() {
+ if (typeof monthNames === "function") {
+ var month2 = doubled("M") ? monthNames.call(calendar, value.substring(iValue)) : monthNamesShort.call(calendar, value.substring(iValue));
+ iValue += month2.length;
+ return month2;
+ }
+ return getName("M", monthNamesShort, monthNames);
+ };
+ var checkLiteral = function() {
+ if (value.charAt(iValue) !== format.charAt(iFormat)) {
+ throw (main.local.unexpectedLiteralAt || main.regionalOptions[""].unexpectedLiteralAt).replace(/\{0\}/, iValue);
+ }
+ iValue++;
+ };
+ var iValue = 0;
+ for (var iFormat = 0; iFormat < format.length; iFormat++) {
+ if (literal) {
+ if (format.charAt(iFormat) === "'" && !doubled("'")) {
+ literal = false;
+ } else {
+ checkLiteral();
+ }
+ } else {
+ switch (format.charAt(iFormat)) {
+ case "d":
+ day = getNumber("d");
+ break;
+ case "D":
+ getName("D", dayNamesShort, dayNames);
+ break;
+ case "o":
+ doy = getNumber("o");
+ break;
+ case "w":
+ getNumber("w");
+ break;
+ case "m":
+ month = getMonthNumber();
+ break;
+ case "M":
+ month = getMonthName();
+ break;
+ case "y":
+ var iSave = iFormat;
+ shortYear = !doubled("y", 2);
+ iFormat = iSave;
+ year = getNumber("y", 2);
+ break;
+ case "Y":
+ year = getNumber("Y", 2);
+ break;
+ case "J":
+ jd = getNumber("J") + 0.5;
+ if (value.charAt(iValue) === ".") {
+ iValue++;
+ getNumber("J");
+ }
+ break;
+ case "@":
+ jd = getNumber("@") / this.SECS_PER_DAY + this.UNIX_EPOCH;
+ break;
+ case "!":
+ jd = getNumber("!") / this.TICKS_PER_DAY + this.TICKS_EPOCH;
+ break;
+ case "*":
+ iValue = value.length;
+ break;
+ case "'":
+ if (doubled("'")) {
+ checkLiteral();
+ } else {
+ literal = true;
+ }
+ break;
+ default:
+ checkLiteral();
+ }
+ }
+ }
+ if (iValue < value.length) {
+ throw main.local.unexpectedText || main.regionalOptions[""].unexpectedText;
+ }
+ if (year === -1) {
+ year = this.today().year();
+ } else if (year < 100 && shortYear) {
+ year += shortYearCutoff === -1 ? 1900 : this.today().year() - this.today().year() % 100 - (year <= shortYearCutoff ? 0 : 100);
+ }
+ if (typeof month === "string") {
+ month = parseMonth.call(this, year, month);
+ }
+ if (doy > -1) {
+ month = 1;
+ day = doy;
+ for (var dim = this.daysInMonth(year, month); day > dim; dim = this.daysInMonth(year, month)) {
+ month++;
+ day -= dim;
+ }
+ }
+ return jd > -1 ? this.fromJD(jd) : this.newDate(year, month, day);
+ },
+ /** A date may be specified as an exact value or a relative one.
+ Found in the jquery.calendars.plus.js
module.
+ @memberof BaseCalendar
+ @param dateSpec {CDate|number|string} The date as an object or string in the given format or
+ an offset - numeric days from today, or string amounts and periods, e.g. '+1m +2w'.
+ @param defaultDate {CDate} The date to use if no other supplied, may be null
.
+ @param currentDate {CDate} The current date as a possible basis for relative dates,
+ if null
today is used (optional)
+ @param [dateFormat] {string} The expected date format - see formatDate
.
+ @param [settings] {object} Additional options whose attributes include:
+ @property [shortYearCutoff] {number} The cutoff year for determining the century.
+ @property [dayNamesShort] {string[]} Abbreviated names of the days from Sunday.
+ @property [dayNames] {string[]} Names of the days from Sunday.
+ @property [monthNamesShort] {string[]} Abbreviated names of the months.
+ @property [monthNames] {string[]} Names of the months.
+ @return {CDate} The decoded date. */
+ determineDate: function(dateSpec, defaultDate, currentDate, dateFormat, settings) {
+ if (currentDate && typeof currentDate !== "object") {
+ settings = dateFormat;
+ dateFormat = currentDate;
+ currentDate = null;
+ }
+ if (typeof dateFormat !== "string") {
+ settings = dateFormat;
+ dateFormat = "";
+ }
+ var calendar = this;
+ var offsetString = function(offset) {
+ try {
+ return calendar.parseDate(dateFormat, offset, settings);
+ } catch (e) {
+ }
+ offset = offset.toLowerCase();
+ var date = (offset.match(/^c/) && currentDate ? currentDate.newDate() : null) || calendar.today();
+ var pattern = /([+-]?[0-9]+)\s*(d|w|m|y)?/g;
+ var matches = pattern.exec(offset);
+ while (matches) {
+ date.add(parseInt(matches[1], 10), matches[2] || "d");
+ matches = pattern.exec(offset);
+ }
+ return date;
+ };
+ defaultDate = defaultDate ? defaultDate.newDate() : null;
+ dateSpec = dateSpec == null ? defaultDate : typeof dateSpec === "string" ? offsetString(dateSpec) : typeof dateSpec === "number" ? isNaN(dateSpec) || dateSpec === Infinity || dateSpec === -Infinity ? defaultDate : calendar.today().add(dateSpec, "d") : calendar.newDate(dateSpec);
+ return dateSpec;
+ }
+ });
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/chinese.js
+ var require_chinese = __commonJS({
+ "node_modules/world-calendars/dist/calendars/chinese.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ var gregorianCalendar = main.instance();
+ function ChineseCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ ChineseCalendar.prototype = new main.baseCalendar();
+ assign(ChineseCalendar.prototype, {
+ /** The calendar name.
+ @memberof ChineseCalendar */
+ name: "Chinese",
+ /** Julian date of start of Gregorian epoch: 1 January 0001 CE.
+ @memberof GregorianCalendar */
+ jdEpoch: 17214255e-1,
+ /** true
if has a year zero, false
if not.
+ @memberof ChineseCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ This calendar uses month indices to account for intercalary months.
+ @memberof ChineseCalendar */
+ minMonth: 0,
+ /** The first month in the year.
+ This calendar uses month indices to account for intercalary months.
+ @memberof ChineseCalendar */
+ firstMonth: 0,
+ /** The minimum day number.
+ @memberof ChineseCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof ChineseCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Chinese",
+ epochs: ["BEC", "EC"],
+ monthNumbers: function(date, padded) {
+ if (typeof date === "string") {
+ var match = date.match(MONTH_NUMBER_REGEXP);
+ return match ? match[0] : "";
+ }
+ var year = this._validateYear(date);
+ var monthIndex = date.month();
+ var month = "" + this.toChineseMonth(year, monthIndex);
+ if (padded && month.length < 2) {
+ month = "0" + month;
+ }
+ if (this.isIntercalaryMonth(year, monthIndex)) {
+ month += "i";
+ }
+ return month;
+ },
+ monthNames: function(date) {
+ if (typeof date === "string") {
+ var match = date.match(MONTH_NAME_REGEXP);
+ return match ? match[0] : "";
+ }
+ var year = this._validateYear(date);
+ var monthIndex = date.month();
+ var month = this.toChineseMonth(year, monthIndex);
+ var monthName = [
+ "\u4E00\u6708",
+ "\u4E8C\u6708",
+ "\u4E09\u6708",
+ "\u56DB\u6708",
+ "\u4E94\u6708",
+ "\u516D\u6708",
+ "\u4E03\u6708",
+ "\u516B\u6708",
+ "\u4E5D\u6708",
+ "\u5341\u6708",
+ "\u5341\u4E00\u6708",
+ "\u5341\u4E8C\u6708"
+ ][month - 1];
+ if (this.isIntercalaryMonth(year, monthIndex)) {
+ monthName = "\u95F0" + monthName;
+ }
+ return monthName;
+ },
+ monthNamesShort: function(date) {
+ if (typeof date === "string") {
+ var match = date.match(MONTH_SHORT_NAME_REGEXP);
+ return match ? match[0] : "";
+ }
+ var year = this._validateYear(date);
+ var monthIndex = date.month();
+ var month = this.toChineseMonth(year, monthIndex);
+ var monthName = [
+ "\u4E00",
+ "\u4E8C",
+ "\u4E09",
+ "\u56DB",
+ "\u4E94",
+ "\u516D",
+ "\u4E03",
+ "\u516B",
+ "\u4E5D",
+ "\u5341",
+ "\u5341\u4E00",
+ "\u5341\u4E8C"
+ ][month - 1];
+ if (this.isIntercalaryMonth(year, monthIndex)) {
+ monthName = "\u95F0" + monthName;
+ }
+ return monthName;
+ },
+ parseMonth: function(year, monthString) {
+ year = this._validateYear(year);
+ var month = parseInt(monthString);
+ var isIntercalary;
+ if (!isNaN(month)) {
+ var i = monthString[monthString.length - 1];
+ isIntercalary = i === "i" || i === "I";
+ } else {
+ if (monthString[0] === "\u95F0") {
+ isIntercalary = true;
+ monthString = monthString.substring(1);
+ }
+ if (monthString[monthString.length - 1] === "\u6708") {
+ monthString = monthString.substring(0, monthString.length - 1);
+ }
+ month = 1 + [
+ "\u4E00",
+ "\u4E8C",
+ "\u4E09",
+ "\u56DB",
+ "\u4E94",
+ "\u516D",
+ "\u4E03",
+ "\u516B",
+ "\u4E5D",
+ "\u5341",
+ "\u5341\u4E00",
+ "\u5341\u4E8C"
+ ].indexOf(monthString);
+ }
+ var monthIndex = this.toMonthIndex(year, month, isIntercalary);
+ return monthIndex;
+ },
+ dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
+ dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
+ digits: null,
+ dateFormat: "yyyy/mm/dd",
+ firstDay: 1,
+ isRTL: false
+ }
+ },
+ /** Check that a candidate date is from the same calendar and is valid.
+ @memberof BaseCalendar
+ @private
+ @param year {CDate|number} The date or the year to validate.
+ @param error {string} Error message if invalid.
+ @return {number} The year.
+ @throws Error if year out of range. */
+ _validateYear: function(year, error) {
+ if (year.year) {
+ year = year.year();
+ }
+ if (typeof year !== "number" || year < 1888 || year > 2111) {
+ throw error.replace(/\{0\}/, this.local.name);
+ }
+ return year;
+ },
+ /** Retrieve the month index (i.e. accounting for intercalary months).
+ @memberof ChineseCalendar
+ @param year {number} The year.
+ @param month {number} The month (1 for first month).
+ @param [isIntercalary=false] {boolean} If month is intercalary.
+ @return {number} The month index (0 for first month).
+ @throws Error if an invalid month/year or a different calendar used. */
+ toMonthIndex: function(year, month, isIntercalary) {
+ var intercalaryMonth = this.intercalaryMonth(year);
+ var invalidIntercalaryMonth = isIntercalary && month !== intercalaryMonth;
+ if (invalidIntercalaryMonth || month < 1 || month > 12) {
+ throw main.local.invalidMonth.replace(/\{0\}/, this.local.name);
+ }
+ var monthIndex;
+ if (!intercalaryMonth) {
+ monthIndex = month - 1;
+ } else if (!isIntercalary && month <= intercalaryMonth) {
+ monthIndex = month - 1;
+ } else {
+ monthIndex = month;
+ }
+ return monthIndex;
+ },
+ /** Retrieve the month (i.e. accounting for intercalary months).
+ @memberof ChineseCalendar
+ @param year {CDate|number} The date or the year to examine.
+ @param monthIndex {number} The month index (0 for first month).
+ @return {number} The month (1 for first month).
+ @throws Error if an invalid month/year or a different calendar used. */
+ toChineseMonth: function(year, monthIndex) {
+ if (year.year) {
+ year = year.year();
+ monthIndex = year.month();
+ }
+ var intercalaryMonth = this.intercalaryMonth(year);
+ var maxMonthIndex = intercalaryMonth ? 12 : 11;
+ if (monthIndex < 0 || monthIndex > maxMonthIndex) {
+ throw main.local.invalidMonth.replace(/\{0\}/, this.local.name);
+ }
+ var month;
+ if (!intercalaryMonth) {
+ month = monthIndex + 1;
+ } else if (monthIndex < intercalaryMonth) {
+ month = monthIndex + 1;
+ } else {
+ month = monthIndex;
+ }
+ return month;
+ },
+ /** Determine the intercalary month of a year (if any).
+ @memberof ChineseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The intercalary month number, or 0 if none.
+ @throws Error if an invalid year or a different calendar used. */
+ intercalaryMonth: function(year) {
+ year = this._validateYear(year);
+ var monthDaysTable = LUNAR_MONTH_DAYS[year - LUNAR_MONTH_DAYS[0]];
+ var intercalaryMonth = monthDaysTable >> 13;
+ return intercalaryMonth;
+ },
+ /** Determine whether this date is an intercalary month.
+ @memberof ChineseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [monthIndex] {number} The month index to examine.
+ @return {boolean} true
if this is an intercalary month, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ isIntercalaryMonth: function(year, monthIndex) {
+ if (year.year) {
+ year = year.year();
+ monthIndex = year.month();
+ }
+ var intercalaryMonth = this.intercalaryMonth(year);
+ return !!intercalaryMonth && intercalaryMonth === monthIndex;
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof ChineseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ return this.intercalaryMonth(year) !== 0;
+ },
+ /** Determine the week of the year for a date - ISO 8601.
+ @memberof ChineseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [monthIndex] {number} The month index to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, monthIndex, day) {
+ var validatedYear = this._validateYear(year, main.local.invalidyear);
+ var packedDate = CHINESE_NEW_YEAR[validatedYear - CHINESE_NEW_YEAR[0]];
+ var y = packedDate >> 9 & 4095;
+ var m = packedDate >> 5 & 15;
+ var d = packedDate & 31;
+ var firstThursday;
+ firstThursday = gregorianCalendar.newDate(y, m, d);
+ firstThursday.add(4 - (firstThursday.dayOfWeek() || 7), "d");
+ var offset = this.toJD(year, monthIndex, day) - firstThursday.toJD();
+ return 1 + Math.floor(offset / 7);
+ },
+ /** Retrieve the number of months in a year.
+ @memberof ChineseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of months.
+ @throws Error if an invalid year or a different calendar used. */
+ monthsInYear: function(year) {
+ return this.leapYear(year) ? 13 : 12;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof ChineseCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [monthIndex] {number} The month index.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, monthIndex) {
+ if (year.year) {
+ monthIndex = year.month();
+ year = year.year();
+ }
+ year = this._validateYear(year);
+ var monthDaysTable = LUNAR_MONTH_DAYS[year - LUNAR_MONTH_DAYS[0]];
+ var intercalaryMonth = monthDaysTable >> 13;
+ var maxMonthIndex = intercalaryMonth ? 12 : 11;
+ if (monthIndex > maxMonthIndex) {
+ throw main.local.invalidMonth.replace(/\{0\}/, this.local.name);
+ }
+ var daysInMonth = monthDaysTable & 1 << 12 - monthIndex ? 30 : 29;
+ return daysInMonth;
+ },
+ /** Determine whether this date is a week day.
+ @memberof ChineseCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [monthIndex] {number} The month index to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, monthIndex, day) {
+ return (this.dayOfWeek(year, monthIndex, day) || 7) < 6;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof ChineseCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [monthIndex] {number} The month index to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, monthIndex, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ year = this._validateYear(date.year());
+ monthIndex = date.month();
+ day = date.day();
+ var isIntercalary = this.isIntercalaryMonth(year, monthIndex);
+ var month = this.toChineseMonth(year, monthIndex);
+ var solar = toSolar(year, month, day, isIntercalary);
+ return gregorianCalendar.toJD(solar.year, solar.month, solar.day);
+ },
+ /** Create a new date from a Julian date.
+ @memberof ChineseCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ var date = gregorianCalendar.fromJD(jd);
+ var lunar = toLunar(date.year(), date.month(), date.day());
+ var monthIndex = this.toMonthIndex(
+ lunar.year,
+ lunar.month,
+ lunar.isIntercalary
+ );
+ return this.newDate(lunar.year, monthIndex, lunar.day);
+ },
+ /** Create a new date from a string.
+ @memberof ChineseCalendar
+ @param dateString {string} String representing a Chinese date
+ @return {CDate} The new date.
+ @throws Error if an invalid date. */
+ fromString: function(dateString) {
+ var match = dateString.match(DATE_REGEXP);
+ var year = this._validateYear(+match[1]);
+ var month = +match[2];
+ var isIntercalary = !!match[3];
+ var monthIndex = this.toMonthIndex(year, month, isIntercalary);
+ var day = +match[4];
+ return this.newDate(year, monthIndex, day);
+ },
+ /** Add period(s) to a date.
+ Cater for no year zero.
+ @memberof ChineseCalendar
+ @param date {CDate} The starting date.
+ @param offset {number} The number of periods to adjust by.
+ @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day.
+ @return {CDate} The updated date.
+ @throws Error if a different calendar used. */
+ add: function(date, offset, period) {
+ var year = date.year();
+ var monthIndex = date.month();
+ var isIntercalary = this.isIntercalaryMonth(year, monthIndex);
+ var month = this.toChineseMonth(year, monthIndex);
+ var cdate = Object.getPrototypeOf(ChineseCalendar.prototype).add.call(this, date, offset, period);
+ if (period === "y") {
+ var resultYear = cdate.year();
+ var resultMonthIndex = cdate.month();
+ var resultCanBeIntercalaryMonth = this.isIntercalaryMonth(resultYear, month);
+ var correctedMonthIndex = isIntercalary && resultCanBeIntercalaryMonth ? this.toMonthIndex(resultYear, month, true) : this.toMonthIndex(resultYear, month, false);
+ if (correctedMonthIndex !== resultMonthIndex) {
+ cdate.month(correctedMonthIndex);
+ }
+ }
+ return cdate;
+ }
+ });
+ var DATE_REGEXP = /^\s*(-?\d\d\d\d|\d\d)[-/](\d?\d)([iI]?)[-/](\d?\d)/m;
+ var MONTH_NUMBER_REGEXP = /^\d?\d[iI]?/m;
+ var MONTH_NAME_REGEXP = /^闰?十?[一二三四五六七八九]?月/m;
+ var MONTH_SHORT_NAME_REGEXP = /^闰?十?[一二三四五六七八九]?/m;
+ main.calendars.chinese = ChineseCalendar;
+ var LUNAR_MONTH_DAYS = [
+ 1887,
+ 5780,
+ 5802,
+ 19157,
+ 2742,
+ 50359,
+ 1198,
+ 2646,
+ 46378,
+ 7466,
+ 3412,
+ 30122,
+ 5482,
+ 67949,
+ 2396,
+ 5294,
+ 43597,
+ 6732,
+ 6954,
+ 36181,
+ 2772,
+ 4954,
+ 18781,
+ 2396,
+ 54427,
+ 5274,
+ 6730,
+ 47781,
+ 5800,
+ 6868,
+ 21210,
+ 4790,
+ 59703,
+ 2350,
+ 5270,
+ 46667,
+ 3402,
+ 3496,
+ 38325,
+ 1388,
+ 4782,
+ 18735,
+ 2350,
+ 52374,
+ 6804,
+ 7498,
+ 44457,
+ 2906,
+ 1388,
+ 29294,
+ 4700,
+ 63789,
+ 6442,
+ 6804,
+ 56138,
+ 5802,
+ 2772,
+ 38235,
+ 1210,
+ 4698,
+ 22827,
+ 5418,
+ 63125,
+ 3476,
+ 5802,
+ 43701,
+ 2484,
+ 5302,
+ 27223,
+ 2646,
+ 70954,
+ 7466,
+ 3412,
+ 54698,
+ 5482,
+ 2412,
+ 38062,
+ 5294,
+ 2636,
+ 32038,
+ 6954,
+ 60245,
+ 2772,
+ 4826,
+ 43357,
+ 2394,
+ 5274,
+ 39501,
+ 6730,
+ 72357,
+ 5800,
+ 5844,
+ 53978,
+ 4790,
+ 2358,
+ 38039,
+ 5270,
+ 87627,
+ 3402,
+ 3496,
+ 54708,
+ 5484,
+ 4782,
+ 43311,
+ 2350,
+ 3222,
+ 27978,
+ 7498,
+ 68965,
+ 2904,
+ 5484,
+ 45677,
+ 4700,
+ 6444,
+ 39573,
+ 6804,
+ 6986,
+ 19285,
+ 2772,
+ 62811,
+ 1210,
+ 4698,
+ 47403,
+ 5418,
+ 5780,
+ 38570,
+ 5546,
+ 76469,
+ 2420,
+ 5302,
+ 51799,
+ 2646,
+ 5414,
+ 36501,
+ 3412,
+ 5546,
+ 18869,
+ 2412,
+ 54446,
+ 5276,
+ 6732,
+ 48422,
+ 6822,
+ 2900,
+ 28010,
+ 4826,
+ 92509,
+ 2394,
+ 5274,
+ 55883,
+ 6730,
+ 6820,
+ 47956,
+ 5812,
+ 2778,
+ 18779,
+ 2358,
+ 62615,
+ 5270,
+ 5450,
+ 46757,
+ 3492,
+ 5556,
+ 27318,
+ 4718,
+ 67887,
+ 2350,
+ 3222,
+ 52554,
+ 7498,
+ 3428,
+ 38252,
+ 5468,
+ 4700,
+ 31022,
+ 6444,
+ 64149,
+ 6804,
+ 6986,
+ 43861,
+ 2772,
+ 5338,
+ 35421,
+ 2650,
+ 70955,
+ 5418,
+ 5780,
+ 54954,
+ 5546,
+ 2740,
+ 38074,
+ 5302,
+ 2646,
+ 29991,
+ 3366,
+ 61011,
+ 3412,
+ 5546,
+ 43445,
+ 2412,
+ 5294,
+ 35406,
+ 6732,
+ 72998,
+ 6820,
+ 6996,
+ 52586,
+ 2778,
+ 2396,
+ 38045,
+ 5274,
+ 6698,
+ 23333,
+ 6820,
+ 64338,
+ 5812,
+ 2746,
+ 43355,
+ 2358,
+ 5270,
+ 39499,
+ 5450,
+ 79525,
+ 3492,
+ 5548
+ ];
+ var CHINESE_NEW_YEAR = [
+ 1887,
+ 966732,
+ 967231,
+ 967733,
+ 968265,
+ 968766,
+ 969297,
+ 969798,
+ 970298,
+ 970829,
+ 971330,
+ 971830,
+ 972362,
+ 972863,
+ 973395,
+ 973896,
+ 974397,
+ 974928,
+ 975428,
+ 975929,
+ 976461,
+ 976962,
+ 977462,
+ 977994,
+ 978494,
+ 979026,
+ 979526,
+ 980026,
+ 980558,
+ 981059,
+ 981559,
+ 982091,
+ 982593,
+ 983124,
+ 983624,
+ 984124,
+ 984656,
+ 985157,
+ 985656,
+ 986189,
+ 986690,
+ 987191,
+ 987722,
+ 988222,
+ 988753,
+ 989254,
+ 989754,
+ 990286,
+ 990788,
+ 991288,
+ 991819,
+ 992319,
+ 992851,
+ 993352,
+ 993851,
+ 994383,
+ 994885,
+ 995385,
+ 995917,
+ 996418,
+ 996918,
+ 997450,
+ 997949,
+ 998481,
+ 998982,
+ 999483,
+ 1000014,
+ 1000515,
+ 1001016,
+ 1001548,
+ 1002047,
+ 1002578,
+ 1003080,
+ 1003580,
+ 1004111,
+ 1004613,
+ 1005113,
+ 1005645,
+ 1006146,
+ 1006645,
+ 1007177,
+ 1007678,
+ 1008209,
+ 1008710,
+ 1009211,
+ 1009743,
+ 1010243,
+ 1010743,
+ 1011275,
+ 1011775,
+ 1012306,
+ 1012807,
+ 1013308,
+ 1013840,
+ 1014341,
+ 1014841,
+ 1015373,
+ 1015874,
+ 1016404,
+ 1016905,
+ 1017405,
+ 1017937,
+ 1018438,
+ 1018939,
+ 1019471,
+ 1019972,
+ 1020471,
+ 1021002,
+ 1021503,
+ 1022035,
+ 1022535,
+ 1023036,
+ 1023568,
+ 1024069,
+ 1024568,
+ 1025100,
+ 1025601,
+ 1026102,
+ 1026633,
+ 1027133,
+ 1027666,
+ 1028167,
+ 1028666,
+ 1029198,
+ 1029699,
+ 1030199,
+ 1030730,
+ 1031231,
+ 1031763,
+ 1032264,
+ 1032764,
+ 1033296,
+ 1033797,
+ 1034297,
+ 1034828,
+ 1035329,
+ 1035830,
+ 1036362,
+ 1036861,
+ 1037393,
+ 1037894,
+ 1038394,
+ 1038925,
+ 1039427,
+ 1039927,
+ 1040459,
+ 1040959,
+ 1041491,
+ 1041992,
+ 1042492,
+ 1043023,
+ 1043524,
+ 1044024,
+ 1044556,
+ 1045057,
+ 1045558,
+ 1046090,
+ 1046590,
+ 1047121,
+ 1047622,
+ 1048122,
+ 1048654,
+ 1049154,
+ 1049655,
+ 1050187,
+ 1050689,
+ 1051219,
+ 1051720,
+ 1052220,
+ 1052751,
+ 1053252,
+ 1053752,
+ 1054284,
+ 1054786,
+ 1055285,
+ 1055817,
+ 1056317,
+ 1056849,
+ 1057349,
+ 1057850,
+ 1058382,
+ 1058883,
+ 1059383,
+ 1059915,
+ 1060415,
+ 1060947,
+ 1061447,
+ 1061947,
+ 1062479,
+ 1062981,
+ 1063480,
+ 1064012,
+ 1064514,
+ 1065014,
+ 1065545,
+ 1066045,
+ 1066577,
+ 1067078,
+ 1067578,
+ 1068110,
+ 1068611,
+ 1069112,
+ 1069642,
+ 1070142,
+ 1070674,
+ 1071175,
+ 1071675,
+ 1072207,
+ 1072709,
+ 1073209,
+ 1073740,
+ 1074241,
+ 1074741,
+ 1075273,
+ 1075773,
+ 1076305,
+ 1076807,
+ 1077308,
+ 1077839,
+ 1078340,
+ 1078840,
+ 1079372,
+ 1079871,
+ 1080403,
+ 1080904
+ ];
+ function toLunar(yearOrDate, monthOrResult, day, result) {
+ var solarDate;
+ var lunarDate;
+ if (typeof yearOrDate === "object") {
+ solarDate = yearOrDate;
+ lunarDate = monthOrResult || {};
+ } else {
+ var isValidYear = typeof yearOrDate === "number" && yearOrDate >= 1888 && yearOrDate <= 2111;
+ if (!isValidYear)
+ throw new Error("Solar year outside range 1888-2111");
+ var isValidMonth = typeof monthOrResult === "number" && monthOrResult >= 1 && monthOrResult <= 12;
+ if (!isValidMonth)
+ throw new Error("Solar month outside range 1 - 12");
+ var isValidDay = typeof day === "number" && day >= 1 && day <= 31;
+ if (!isValidDay)
+ throw new Error("Solar day outside range 1 - 31");
+ solarDate = {
+ year: yearOrDate,
+ month: monthOrResult,
+ day
+ };
+ lunarDate = result || {};
+ }
+ var chineseNewYearPackedDate = CHINESE_NEW_YEAR[solarDate.year - CHINESE_NEW_YEAR[0]];
+ var packedDate = solarDate.year << 9 | solarDate.month << 5 | solarDate.day;
+ lunarDate.year = packedDate >= chineseNewYearPackedDate ? solarDate.year : solarDate.year - 1;
+ chineseNewYearPackedDate = CHINESE_NEW_YEAR[lunarDate.year - CHINESE_NEW_YEAR[0]];
+ var y = chineseNewYearPackedDate >> 9 & 4095;
+ var m = chineseNewYearPackedDate >> 5 & 15;
+ var d = chineseNewYearPackedDate & 31;
+ var daysFromNewYear;
+ var chineseNewYearJSDate = new Date(y, m - 1, d);
+ var jsDate = new Date(solarDate.year, solarDate.month - 1, solarDate.day);
+ daysFromNewYear = Math.round(
+ (jsDate - chineseNewYearJSDate) / (24 * 3600 * 1e3)
+ );
+ var monthDaysTable = LUNAR_MONTH_DAYS[lunarDate.year - LUNAR_MONTH_DAYS[0]];
+ var i;
+ for (i = 0; i < 13; i++) {
+ var daysInMonth = monthDaysTable & 1 << 12 - i ? 30 : 29;
+ if (daysFromNewYear < daysInMonth) {
+ break;
+ }
+ daysFromNewYear -= daysInMonth;
+ }
+ var intercalaryMonth = monthDaysTable >> 13;
+ if (!intercalaryMonth || i < intercalaryMonth) {
+ lunarDate.isIntercalary = false;
+ lunarDate.month = 1 + i;
+ } else if (i === intercalaryMonth) {
+ lunarDate.isIntercalary = true;
+ lunarDate.month = i;
+ } else {
+ lunarDate.isIntercalary = false;
+ lunarDate.month = i;
+ }
+ lunarDate.day = 1 + daysFromNewYear;
+ return lunarDate;
+ }
+ function toSolar(yearOrDate, monthOrResult, day, isIntercalaryOrResult, result) {
+ var solarDate;
+ var lunarDate;
+ if (typeof yearOrDate === "object") {
+ lunarDate = yearOrDate;
+ solarDate = monthOrResult || {};
+ } else {
+ var isValidYear = typeof yearOrDate === "number" && yearOrDate >= 1888 && yearOrDate <= 2111;
+ if (!isValidYear)
+ throw new Error("Lunar year outside range 1888-2111");
+ var isValidMonth = typeof monthOrResult === "number" && monthOrResult >= 1 && monthOrResult <= 12;
+ if (!isValidMonth)
+ throw new Error("Lunar month outside range 1 - 12");
+ var isValidDay = typeof day === "number" && day >= 1 && day <= 30;
+ if (!isValidDay)
+ throw new Error("Lunar day outside range 1 - 30");
+ var isIntercalary;
+ if (typeof isIntercalaryOrResult === "object") {
+ isIntercalary = false;
+ solarDate = isIntercalaryOrResult;
+ } else {
+ isIntercalary = !!isIntercalaryOrResult;
+ solarDate = result || {};
+ }
+ lunarDate = {
+ year: yearOrDate,
+ month: monthOrResult,
+ day,
+ isIntercalary
+ };
+ }
+ var daysFromNewYear;
+ daysFromNewYear = lunarDate.day - 1;
+ var monthDaysTable = LUNAR_MONTH_DAYS[lunarDate.year - LUNAR_MONTH_DAYS[0]];
+ var intercalaryMonth = monthDaysTable >> 13;
+ var monthsFromNewYear;
+ if (!intercalaryMonth) {
+ monthsFromNewYear = lunarDate.month - 1;
+ } else if (lunarDate.month > intercalaryMonth) {
+ monthsFromNewYear = lunarDate.month;
+ } else if (lunarDate.isIntercalary) {
+ monthsFromNewYear = lunarDate.month;
+ } else {
+ monthsFromNewYear = lunarDate.month - 1;
+ }
+ for (var i = 0; i < monthsFromNewYear; i++) {
+ var daysInMonth = monthDaysTable & 1 << 12 - i ? 30 : 29;
+ daysFromNewYear += daysInMonth;
+ }
+ var packedDate = CHINESE_NEW_YEAR[lunarDate.year - CHINESE_NEW_YEAR[0]];
+ var y = packedDate >> 9 & 4095;
+ var m = packedDate >> 5 & 15;
+ var d = packedDate & 31;
+ var jsDate = new Date(y, m - 1, d + daysFromNewYear);
+ solarDate.year = jsDate.getFullYear();
+ solarDate.month = 1 + jsDate.getMonth();
+ solarDate.day = jsDate.getDate();
+ return solarDate;
+ }
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/coptic.js
+ var require_coptic = __commonJS({
+ "node_modules/world-calendars/dist/calendars/coptic.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function CopticCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ CopticCalendar.prototype = new main.baseCalendar();
+ assign(CopticCalendar.prototype, {
+ /** The calendar name.
+ @memberof CopticCalendar */
+ name: "Coptic",
+ /** Julian date of start of Coptic epoch: 29 August 284 CE (Gregorian).
+ @memberof CopticCalendar */
+ jdEpoch: 18250295e-1,
+ /** Days per month in a common year.
+ @memberof CopticCalendar */
+ daysPerMonth: [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 5],
+ /** true
if has a year zero, false
if not.
+ @memberof CopticCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof CopticCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof CopticCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof CopticCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof CopticCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Coptic",
+ epochs: ["BAM", "AM"],
+ monthNames: [
+ "Thout",
+ "Paopi",
+ "Hathor",
+ "Koiak",
+ "Tobi",
+ "Meshir",
+ "Paremhat",
+ "Paremoude",
+ "Pashons",
+ "Paoni",
+ "Epip",
+ "Mesori",
+ "Pi Kogi Enavot"
+ ],
+ monthNamesShort: [
+ "Tho",
+ "Pao",
+ "Hath",
+ "Koi",
+ "Tob",
+ "Mesh",
+ "Pat",
+ "Pad",
+ "Pash",
+ "Pao",
+ "Epi",
+ "Meso",
+ "PiK"
+ ],
+ dayNames: ["Tkyriaka", "Pesnau", "Pshoment", "Peftoou", "Ptiou", "Psoou", "Psabbaton"],
+ dayNamesShort: ["Tky", "Pes", "Psh", "Pef", "Pti", "Pso", "Psa"],
+ dayNamesMin: ["Tk", "Pes", "Psh", "Pef", "Pt", "Pso", "Psa"],
+ digits: null,
+ dateFormat: "dd/mm/yyyy",
+ firstDay: 0,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof CopticCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ var year = date.year() + (date.year() < 0 ? 1 : 0);
+ return year % 4 === 3 || year % 4 === -1;
+ },
+ /** Retrieve the number of months in a year.
+ @memberof CopticCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of months.
+ @throws Error if an invalid year or a different calendar used. */
+ monthsInYear: function(year) {
+ this._validate(
+ year,
+ this.minMonth,
+ this.minDay,
+ main.local.invalidYear || main.regionalOptions[""].invalidYear
+ );
+ return 13;
+ },
+ /** Determine the week of the year for a date.
+ @memberof CopticCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number) the month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(-checkDate.dayOfWeek(), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof CopticCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return this.daysPerMonth[date.month() - 1] + (date.month() === 13 && this.leapYear(date.year()) ? 1 : 0);
+ },
+ /** Determine whether this date is a week day.
+ @memberof CopticCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param month {number} The month to examine.
+ @param day {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return (this.dayOfWeek(year, month, day) || 7) < 6;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof CopticCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number) the month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ year = date.year();
+ if (year < 0) {
+ year++;
+ }
+ return date.day() + (date.month() - 1) * 30 + (year - 1) * 365 + Math.floor(year / 4) + this.jdEpoch - 1;
+ },
+ /** Create a new date from a Julian date.
+ @memberof CopticCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ var c = Math.floor(jd) + 0.5 - this.jdEpoch;
+ var year = Math.floor((c - Math.floor((c + 366) / 1461)) / 365) + 1;
+ if (year <= 0) {
+ year--;
+ }
+ c = Math.floor(jd) + 0.5 - this.newDate(year, 1, 1).toJD();
+ var month = Math.floor(c / 30) + 1;
+ var day = c - (month - 1) * 30 + 1;
+ return this.newDate(year, month, day);
+ }
+ });
+ main.calendars.coptic = CopticCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/discworld.js
+ var require_discworld = __commonJS({
+ "node_modules/world-calendars/dist/calendars/discworld.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function DiscworldCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ DiscworldCalendar.prototype = new main.baseCalendar();
+ assign(DiscworldCalendar.prototype, {
+ /** The calendar name.
+ @memberof DiscworldCalendar */
+ name: "Discworld",
+ /** Julian date of start of Discworld epoch: 1 January 0001 CE.
+ @memberof DiscworldCalendar */
+ jdEpoch: 17214255e-1,
+ /** Days per month in a common year.
+ @memberof DiscworldCalendar */
+ daysPerMonth: [16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32],
+ /** true
if has a year zero, false
if not.
+ @memberof DiscworldCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof DiscworldCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof DiscworldCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof DiscworldCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof DiscworldCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Discworld",
+ epochs: ["BUC", "UC"],
+ monthNames: [
+ "Ick",
+ "Offle",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "Grune",
+ "August",
+ "Spune",
+ "Sektober",
+ "Ember",
+ "December"
+ ],
+ monthNamesShort: ["Ick", "Off", "Feb", "Mar", "Apr", "May", "Jun", "Gru", "Aug", "Spu", "Sek", "Emb", "Dec"],
+ dayNames: ["Sunday", "Octeday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
+ dayNamesShort: ["Sun", "Oct", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ dayNamesMin: ["Su", "Oc", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
+ digits: null,
+ dateFormat: "yyyy/mm/dd",
+ firstDay: 2,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof DiscworldCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return false;
+ },
+ /** Retrieve the number of months in a year.
+ @memberof DiscworldCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of months.
+ @throws Error if an invalid year or a different calendar used. */
+ monthsInYear: function(year) {
+ this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return 13;
+ },
+ /** Retrieve the number of days in a year.
+ @memberof DiscworldCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of days.
+ @throws Error if an invalid year or a different calendar used. */
+ daysInYear: function(year) {
+ this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return 400;
+ },
+ /** Determine the week of the year for a date.
+ @memberof DiscworldCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(-checkDate.dayOfWeek(), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 8) + 1;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof DiscworldCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return this.daysPerMonth[date.month() - 1];
+ },
+ /** Retrieve the number of days in a week.
+ @memberof DiscworldCalendar
+ @return {number} The number of days. */
+ daysInWeek: function() {
+ return 8;
+ },
+ /** Retrieve the day of the week for a date.
+ @memberof DiscworldCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The day of the week: 0 to number of days - 1.
+ @throws Error if an invalid date or a different calendar used. */
+ dayOfWeek: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ return (date.day() + 1) % 8;
+ },
+ /** Determine whether this date is a week day.
+ @memberof DiscworldCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ var dow = this.dayOfWeek(year, month, day);
+ return dow >= 2 && dow <= 6;
+ },
+ /** Retrieve additional information about a date.
+ @memberof DiscworldCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {object} Additional information - contents depends on calendar.
+ @throws Error if an invalid date or a different calendar used. */
+ extraInfo: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ return { century: centuries[Math.floor((date.year() - 1) / 100) + 1] || "" };
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof DiscworldCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ year = date.year() + (date.year() < 0 ? 1 : 0);
+ month = date.month();
+ day = date.day();
+ return day + (month > 1 ? 16 : 0) + (month > 2 ? (month - 2) * 32 : 0) + (year - 1) * 400 + this.jdEpoch - 1;
+ },
+ /** Create a new date from a Julian date.
+ @memberof DiscworldCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ jd = Math.floor(jd + 0.5) - Math.floor(this.jdEpoch) - 1;
+ var year = Math.floor(jd / 400) + 1;
+ jd -= (year - 1) * 400;
+ jd += jd > 15 ? 16 : 0;
+ var month = Math.floor(jd / 32) + 1;
+ var day = jd - (month - 1) * 32 + 1;
+ return this.newDate(year <= 0 ? year - 1 : year, month, day);
+ }
+ });
+ var centuries = {
+ 20: "Fruitbat",
+ 21: "Anchovy"
+ };
+ main.calendars.discworld = DiscworldCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/ethiopian.js
+ var require_ethiopian = __commonJS({
+ "node_modules/world-calendars/dist/calendars/ethiopian.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function EthiopianCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ EthiopianCalendar.prototype = new main.baseCalendar();
+ assign(EthiopianCalendar.prototype, {
+ /** The calendar name.
+ @memberof EthiopianCalendar */
+ name: "Ethiopian",
+ /** Julian date of start of Ethiopian epoch: 27 August 8 CE (Gregorian).
+ @memberof EthiopianCalendar */
+ jdEpoch: 17242205e-1,
+ /** Days per month in a common year.
+ @memberof EthiopianCalendar */
+ daysPerMonth: [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 5],
+ /** true
if has a year zero, false
if not.
+ @memberof EthiopianCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof EthiopianCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof EthiopianCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof EthiopianCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof EthiopianCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Ethiopian",
+ epochs: ["BEE", "EE"],
+ monthNames: [
+ "Meskerem",
+ "Tikemet",
+ "Hidar",
+ "Tahesas",
+ "Tir",
+ "Yekatit",
+ "Megabit",
+ "Miazia",
+ "Genbot",
+ "Sene",
+ "Hamle",
+ "Nehase",
+ "Pagume"
+ ],
+ monthNamesShort: [
+ "Mes",
+ "Tik",
+ "Hid",
+ "Tah",
+ "Tir",
+ "Yek",
+ "Meg",
+ "Mia",
+ "Gen",
+ "Sen",
+ "Ham",
+ "Neh",
+ "Pag"
+ ],
+ dayNames: ["Ehud", "Segno", "Maksegno", "Irob", "Hamus", "Arb", "Kidame"],
+ dayNamesShort: ["Ehu", "Seg", "Mak", "Iro", "Ham", "Arb", "Kid"],
+ dayNamesMin: ["Eh", "Se", "Ma", "Ir", "Ha", "Ar", "Ki"],
+ digits: null,
+ dateFormat: "dd/mm/yyyy",
+ firstDay: 0,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof EthiopianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ var year = date.year() + (date.year() < 0 ? 1 : 0);
+ return year % 4 === 3 || year % 4 === -1;
+ },
+ /** Retrieve the number of months in a year.
+ @memberof EthiopianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of months.
+ @throws Error if an invalid year or a different calendar used. */
+ monthsInYear: function(year) {
+ this._validate(
+ year,
+ this.minMonth,
+ this.minDay,
+ main.local.invalidYear || main.regionalOptions[""].invalidYear
+ );
+ return 13;
+ },
+ /** Determine the week of the year for a date.
+ @memberof EthiopianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(-checkDate.dayOfWeek(), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof EthiopianCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return this.daysPerMonth[date.month() - 1] + (date.month() === 13 && this.leapYear(date.year()) ? 1 : 0);
+ },
+ /** Determine whether this date is a week day.
+ @memberof EthiopianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return (this.dayOfWeek(year, month, day) || 7) < 6;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof EthiopianCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ year = date.year();
+ if (year < 0) {
+ year++;
+ }
+ return date.day() + (date.month() - 1) * 30 + (year - 1) * 365 + Math.floor(year / 4) + this.jdEpoch - 1;
+ },
+ /** Create a new date from a Julian date.
+ @memberof EthiopianCalendar
+ @param jd {number} the Julian date to convert.
+ @return {CDate} the equivalent date. */
+ fromJD: function(jd) {
+ var c = Math.floor(jd) + 0.5 - this.jdEpoch;
+ var year = Math.floor((c - Math.floor((c + 366) / 1461)) / 365) + 1;
+ if (year <= 0) {
+ year--;
+ }
+ c = Math.floor(jd) + 0.5 - this.newDate(year, 1, 1).toJD();
+ var month = Math.floor(c / 30) + 1;
+ var day = c - (month - 1) * 30 + 1;
+ return this.newDate(year, month, day);
+ }
+ });
+ main.calendars.ethiopian = EthiopianCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/hebrew.js
+ var require_hebrew = __commonJS({
+ "node_modules/world-calendars/dist/calendars/hebrew.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function HebrewCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ HebrewCalendar.prototype = new main.baseCalendar();
+ assign(HebrewCalendar.prototype, {
+ /** The calendar name.
+ @memberof HebrewCalendar */
+ name: "Hebrew",
+ /** Julian date of start of Hebrew epoch: 7 October 3761 BCE.
+ @memberof HebrewCalendar */
+ jdEpoch: 347995.5,
+ /** Days per month in a common year.
+ @memberof HebrewCalendar */
+ daysPerMonth: [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 29],
+ /** true
if has a year zero, false
if not.
+ @memberof HebrewCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof HebrewCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof HebrewCalendar */
+ firstMonth: 7,
+ /** The minimum day number.
+ @memberof HebrewCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof HebrewCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Hebrew",
+ epochs: ["BAM", "AM"],
+ monthNames: [
+ "Nisan",
+ "Iyar",
+ "Sivan",
+ "Tammuz",
+ "Av",
+ "Elul",
+ "Tishrei",
+ "Cheshvan",
+ "Kislev",
+ "Tevet",
+ "Shevat",
+ "Adar",
+ "Adar II"
+ ],
+ monthNamesShort: ["Nis", "Iya", "Siv", "Tam", "Av", "Elu", "Tis", "Che", "Kis", "Tev", "She", "Ada", "Ad2"],
+ dayNames: ["Yom Rishon", "Yom Sheni", "Yom Shlishi", "Yom Revi'i", "Yom Chamishi", "Yom Shishi", "Yom Shabbat"],
+ dayNamesShort: ["Ris", "She", "Shl", "Rev", "Cha", "Shi", "Sha"],
+ dayNamesMin: ["Ri", "She", "Shl", "Re", "Ch", "Shi", "Sha"],
+ digits: null,
+ dateFormat: "dd/mm/yyyy",
+ firstDay: 0,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof HebrewCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return this._leapYear(date.year());
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof HebrewCalendar
+ @private
+ @param year {number} The year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ _leapYear: function(year) {
+ year = year < 0 ? year + 1 : year;
+ return mod(year * 7 + 1, 19) < 7;
+ },
+ /** Retrieve the number of months in a year.
+ @memberof HebrewCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of months.
+ @throws Error if an invalid year or a different calendar used. */
+ monthsInYear: function(year) {
+ this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return this._leapYear(year.year ? year.year() : year) ? 13 : 12;
+ },
+ /** Determine the week of the year for a date.
+ @memberof HebrewCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(-checkDate.dayOfWeek(), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a year.
+ @memberof HebrewCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of days.
+ @throws Error if an invalid year or a different calendar used. */
+ daysInYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ year = date.year();
+ return this.toJD(year === -1 ? 1 : year + 1, 7, 1) - this.toJD(year, 7, 1);
+ },
+ /** Retrieve the number of days in a month.
+ @memberof HebrewCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ if (year.year) {
+ month = year.month();
+ year = year.year();
+ }
+ this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return month === 12 && this.leapYear(year) ? 30 : (
+ // Adar I
+ month === 8 && mod(this.daysInYear(year), 10) === 5 ? 30 : (
+ // Cheshvan in shlemah year
+ month === 9 && mod(this.daysInYear(year), 10) === 3 ? 29 : (
+ // Kislev in chaserah year
+ this.daysPerMonth[month - 1]
+ )
+ )
+ );
+ },
+ /** Determine whether this date is a week day.
+ @memberof HebrewCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return this.dayOfWeek(year, month, day) !== 6;
+ },
+ /** Retrieve additional information about a date - year type.
+ @memberof HebrewCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {object} Additional information - contents depends on calendar.
+ @throws Error if an invalid date or a different calendar used. */
+ extraInfo: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ return { yearType: (this.leapYear(date) ? "embolismic" : "common") + " " + ["deficient", "regular", "complete"][this.daysInYear(date) % 10 - 3] };
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof HebrewCalendar
+ @param year {CDate)|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ year = date.year();
+ month = date.month();
+ day = date.day();
+ var adjYear = year <= 0 ? year + 1 : year;
+ var jd = this.jdEpoch + this._delay1(adjYear) + this._delay2(adjYear) + day + 1;
+ if (month < 7) {
+ for (var m = 7; m <= this.monthsInYear(year); m++) {
+ jd += this.daysInMonth(year, m);
+ }
+ for (var m = 1; m < month; m++) {
+ jd += this.daysInMonth(year, m);
+ }
+ } else {
+ for (var m = 7; m < month; m++) {
+ jd += this.daysInMonth(year, m);
+ }
+ }
+ return jd;
+ },
+ /** Test for delay of start of new year and to avoid
+ Sunday, Wednesday, or Friday as start of the new year.
+ @memberof HebrewCalendar
+ @private
+ @param year {number} The year to examine.
+ @return {number} The days to offset by. */
+ _delay1: function(year) {
+ var months = Math.floor((235 * year - 234) / 19);
+ var parts = 12084 + 13753 * months;
+ var day = months * 29 + Math.floor(parts / 25920);
+ if (mod(3 * (day + 1), 7) < 3) {
+ day++;
+ }
+ return day;
+ },
+ /** Check for delay in start of new year due to length of adjacent years.
+ @memberof HebrewCalendar
+ @private
+ @param year {number} The year to examine.
+ @return {number} The days to offset by. */
+ _delay2: function(year) {
+ var last = this._delay1(year - 1);
+ var present = this._delay1(year);
+ var next = this._delay1(year + 1);
+ return next - present === 356 ? 2 : present - last === 382 ? 1 : 0;
+ },
+ /** Create a new date from a Julian date.
+ @memberof HebrewCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ jd = Math.floor(jd) + 0.5;
+ var year = Math.floor((jd - this.jdEpoch) * 98496 / 35975351) - 1;
+ while (jd >= this.toJD(year === -1 ? 1 : year + 1, 7, 1)) {
+ year++;
+ }
+ var month = jd < this.toJD(year, 1, 1) ? 7 : 1;
+ while (jd > this.toJD(year, month, this.daysInMonth(year, month))) {
+ month++;
+ }
+ var day = jd - this.toJD(year, month, 1) + 1;
+ return this.newDate(year, month, day);
+ }
+ });
+ function mod(a, b) {
+ return a - b * Math.floor(a / b);
+ }
+ main.calendars.hebrew = HebrewCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/islamic.js
+ var require_islamic = __commonJS({
+ "node_modules/world-calendars/dist/calendars/islamic.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function IslamicCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ IslamicCalendar.prototype = new main.baseCalendar();
+ assign(IslamicCalendar.prototype, {
+ /** The calendar name.
+ @memberof IslamicCalendar */
+ name: "Islamic",
+ /** Julian date of start of Islamic epoch: 16 July 622 CE.
+ @memberof IslamicCalendar */
+ jdEpoch: 19484395e-1,
+ /** Days per month in a common year.
+ @memberof IslamicCalendar */
+ daysPerMonth: [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29],
+ /** true
if has a year zero, false
if not.
+ @memberof IslamicCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof IslamicCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof IslamicCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof IslamicCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof IslamicCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Islamic",
+ epochs: ["BH", "AH"],
+ monthNames: [
+ "Muharram",
+ "Safar",
+ "Rabi' al-awwal",
+ "Rabi' al-thani",
+ "Jumada al-awwal",
+ "Jumada al-thani",
+ "Rajab",
+ "Sha'aban",
+ "Ramadan",
+ "Shawwal",
+ "Dhu al-Qi'dah",
+ "Dhu al-Hijjah"
+ ],
+ monthNamesShort: ["Muh", "Saf", "Rab1", "Rab2", "Jum1", "Jum2", "Raj", "Sha'", "Ram", "Shaw", "DhuQ", "DhuH"],
+ dayNames: [
+ "Yawm al-ahad",
+ "Yawm al-ithnayn",
+ "Yawm ath-thulaathaa'",
+ "Yawm al-arbi'aa'",
+ "Yawm al-kham\u012Bs",
+ "Yawm al-jum'a",
+ "Yawm as-sabt"
+ ],
+ dayNamesShort: ["Aha", "Ith", "Thu", "Arb", "Kha", "Jum", "Sab"],
+ dayNamesMin: ["Ah", "It", "Th", "Ar", "Kh", "Ju", "Sa"],
+ digits: null,
+ dateFormat: "yyyy/mm/dd",
+ firstDay: 6,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof IslamicCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return (date.year() * 11 + 14) % 30 < 11;
+ },
+ /** Determine the week of the year for a date.
+ @memberof IslamicCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(-checkDate.dayOfWeek(), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a year.
+ @memberof IslamicCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of days.
+ @throws Error if an invalid year or a different calendar used. */
+ daysInYear: function(year) {
+ return this.leapYear(year) ? 355 : 354;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof IslamicCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return this.daysPerMonth[date.month() - 1] + (date.month() === 12 && this.leapYear(date.year()) ? 1 : 0);
+ },
+ /** Determine whether this date is a week day.
+ @memberof IslamicCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return this.dayOfWeek(year, month, day) !== 5;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof IslamicCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ year = date.year();
+ month = date.month();
+ day = date.day();
+ year = year <= 0 ? year + 1 : year;
+ return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + Math.floor((3 + 11 * year) / 30) + this.jdEpoch - 1;
+ },
+ /** Create a new date from a Julian date.
+ @memberof IslamicCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ jd = Math.floor(jd) + 0.5;
+ var year = Math.floor((30 * (jd - this.jdEpoch) + 10646) / 10631);
+ year = year <= 0 ? year - 1 : year;
+ var month = Math.min(12, Math.ceil((jd - 29 - this.toJD(year, 1, 1)) / 29.5) + 1);
+ var day = jd - this.toJD(year, month, 1) + 1;
+ return this.newDate(year, month, day);
+ }
+ });
+ main.calendars.islamic = IslamicCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/julian.js
+ var require_julian = __commonJS({
+ "node_modules/world-calendars/dist/calendars/julian.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function JulianCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ JulianCalendar.prototype = new main.baseCalendar();
+ assign(JulianCalendar.prototype, {
+ /** The calendar name.
+ @memberof JulianCalendar */
+ name: "Julian",
+ /** Julian date of start of Julian epoch: 1 January 0001 AD = 30 December 0001 BCE.
+ @memberof JulianCalendar */
+ jdEpoch: 17214235e-1,
+ /** Days per month in a common year.
+ @memberof JulianCalendar */
+ daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
+ /** true
if has a year zero, false
if not.
+ @memberof JulianCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof JulianCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof JulianCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof JulianCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof JulianCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Julian",
+ epochs: ["BC", "AD"],
+ monthNames: [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+ ],
+ monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
+ dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
+ dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
+ digits: null,
+ dateFormat: "mm/dd/yyyy",
+ firstDay: 0,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof JulianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ var year = date.year() < 0 ? date.year() + 1 : date.year();
+ return year % 4 === 0;
+ },
+ /** Determine the week of the year for a date - ISO 8601.
+ @memberof JulianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(4 - (checkDate.dayOfWeek() || 7), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof JulianCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return this.daysPerMonth[date.month() - 1] + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0);
+ },
+ /** Determine whether this date is a week day.
+ @memberof JulianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} True if a week day, false if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return (this.dayOfWeek(year, month, day) || 7) < 6;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof JulianCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ year = date.year();
+ month = date.month();
+ day = date.day();
+ if (year < 0) {
+ year++;
+ }
+ if (month <= 2) {
+ year--;
+ month += 12;
+ }
+ return Math.floor(365.25 * (year + 4716)) + Math.floor(30.6001 * (month + 1)) + day - 1524.5;
+ },
+ /** Create a new date from a Julian date.
+ @memberof JulianCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ var a = Math.floor(jd + 0.5);
+ var b = a + 1524;
+ var c = Math.floor((b - 122.1) / 365.25);
+ var d = Math.floor(365.25 * c);
+ var e = Math.floor((b - d) / 30.6001);
+ var month = e - Math.floor(e < 14 ? 1 : 13);
+ var year = c - Math.floor(month > 2 ? 4716 : 4715);
+ var day = b - d - Math.floor(30.6001 * e);
+ if (year <= 0) {
+ year--;
+ }
+ return this.newDate(year, month, day);
+ }
+ });
+ main.calendars.julian = JulianCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/mayan.js
+ var require_mayan = __commonJS({
+ "node_modules/world-calendars/dist/calendars/mayan.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function MayanCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ MayanCalendar.prototype = new main.baseCalendar();
+ assign(MayanCalendar.prototype, {
+ /** The calendar name.
+ @memberof MayanCalendar */
+ name: "Mayan",
+ /** Julian date of start of Mayan epoch: 11 August 3114 BCE.
+ @memberof MayanCalendar */
+ jdEpoch: 584282.5,
+ /** true
if has a year zero, false
if not.
+ @memberof MayanCalendar */
+ hasYearZero: true,
+ /** The minimum month number.
+ @memberof MayanCalendar */
+ minMonth: 0,
+ /** The first month in the year.
+ @memberof MayanCalendar */
+ firstMonth: 0,
+ /** The minimum day number.
+ @memberof MayanCalendar */
+ minDay: 0,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof MayanCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left.
+ @property haabMonths {string[]} The names of the Haab months.
+ @property tzolkinMonths {string[]} The names of the Tzolkin months. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Mayan",
+ epochs: ["", ""],
+ monthNames: [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17"
+ ],
+ monthNamesShort: [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17"
+ ],
+ dayNames: [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "19"
+ ],
+ dayNamesShort: [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "19"
+ ],
+ dayNamesMin: [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "19"
+ ],
+ digits: null,
+ dateFormat: "YYYY.m.d",
+ firstDay: 0,
+ isRTL: false,
+ haabMonths: [
+ "Pop",
+ "Uo",
+ "Zip",
+ "Zotz",
+ "Tzec",
+ "Xul",
+ "Yaxkin",
+ "Mol",
+ "Chen",
+ "Yax",
+ "Zac",
+ "Ceh",
+ "Mac",
+ "Kankin",
+ "Muan",
+ "Pax",
+ "Kayab",
+ "Cumku",
+ "Uayeb"
+ ],
+ tzolkinMonths: [
+ "Imix",
+ "Ik",
+ "Akbal",
+ "Kan",
+ "Chicchan",
+ "Cimi",
+ "Manik",
+ "Lamat",
+ "Muluc",
+ "Oc",
+ "Chuen",
+ "Eb",
+ "Ben",
+ "Ix",
+ "Men",
+ "Cib",
+ "Caban",
+ "Etznab",
+ "Cauac",
+ "Ahau"
+ ]
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return false;
+ },
+ /** Format the year, if not a simple sequential number.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to format or the year to format.
+ @return {string} The formatted year.
+ @throws Error if an invalid year or a different calendar used. */
+ formatYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ year = date.year();
+ var baktun = Math.floor(year / 400);
+ year = year % 400;
+ year += year < 0 ? 400 : 0;
+ var katun = Math.floor(year / 20);
+ return baktun + "." + katun + "." + year % 20;
+ },
+ /** Convert from the formatted year back to a single number.
+ @memberof MayanCalendar
+ @param years {string} The year as n.n.n.
+ @return {number} The sequential year.
+ @throws Error if an invalid value is supplied. */
+ forYear: function(years) {
+ years = years.split(".");
+ if (years.length < 3) {
+ throw "Invalid Mayan year";
+ }
+ var year = 0;
+ for (var i = 0; i < years.length; i++) {
+ var y = parseInt(years[i], 10);
+ if (Math.abs(y) > 19 || i > 0 && y < 0) {
+ throw "Invalid Mayan year";
+ }
+ year = year * 20 + y;
+ }
+ return year;
+ },
+ /** Retrieve the number of months in a year.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of months.
+ @throws Error if an invalid year or a different calendar used. */
+ monthsInYear: function(year) {
+ this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return 18;
+ },
+ /** Determine the week of the year for a date.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ this._validate(year, month, day, main.local.invalidDate);
+ return 0;
+ },
+ /** Retrieve the number of days in a year.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of days.
+ @throws Error if an invalid year or a different calendar used. */
+ daysInYear: function(year) {
+ this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return 360;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return 20;
+ },
+ /** Retrieve the number of days in a week.
+ @memberof MayanCalendar
+ @return {number} The number of days. */
+ daysInWeek: function() {
+ return 5;
+ },
+ /** Retrieve the day of the week for a date.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The day of the week: 0 to number of days - 1.
+ @throws Error if an invalid date or a different calendar used. */
+ dayOfWeek: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ return date.day();
+ },
+ /** Determine whether this date is a week day.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ this._validate(year, month, day, main.local.invalidDate);
+ return true;
+ },
+ /** Retrieve additional information about a date - Haab and Tzolkin equivalents.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {object} Additional information - contents depends on calendar.
+ @throws Error if an invalid date or a different calendar used. */
+ extraInfo: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ var jd = date.toJD();
+ var haab = this._toHaab(jd);
+ var tzolkin = this._toTzolkin(jd);
+ return {
+ haabMonthName: this.local.haabMonths[haab[0] - 1],
+ haabMonth: haab[0],
+ haabDay: haab[1],
+ tzolkinDayName: this.local.tzolkinMonths[tzolkin[0] - 1],
+ tzolkinDay: tzolkin[0],
+ tzolkinTrecena: tzolkin[1]
+ };
+ },
+ /** Retrieve Haab date from a Julian date.
+ @memberof MayanCalendar
+ @private
+ @param jd {number} The Julian date.
+ @return {number[]} Corresponding Haab month and day. */
+ _toHaab: function(jd) {
+ jd -= this.jdEpoch;
+ var day = mod(jd + 8 + (18 - 1) * 20, 365);
+ return [Math.floor(day / 20) + 1, mod(day, 20)];
+ },
+ /** Retrieve Tzolkin date from a Julian date.
+ @memberof MayanCalendar
+ @private
+ @param jd {number} The Julian date.
+ @return {number[]} Corresponding Tzolkin day and trecena. */
+ _toTzolkin: function(jd) {
+ jd -= this.jdEpoch;
+ return [amod(jd + 20, 20), amod(jd + 4, 13)];
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof MayanCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ return date.day() + date.month() * 20 + date.year() * 360 + this.jdEpoch;
+ },
+ /** Create a new date from a Julian date.
+ @memberof MayanCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ jd = Math.floor(jd) + 0.5 - this.jdEpoch;
+ var year = Math.floor(jd / 360);
+ jd = jd % 360;
+ jd += jd < 0 ? 360 : 0;
+ var month = Math.floor(jd / 20);
+ var day = jd % 20;
+ return this.newDate(year, month, day);
+ }
+ });
+ function mod(a, b) {
+ return a - b * Math.floor(a / b);
+ }
+ function amod(a, b) {
+ return mod(a - 1, b) + 1;
+ }
+ main.calendars.mayan = MayanCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/nanakshahi.js
+ var require_nanakshahi = __commonJS({
+ "node_modules/world-calendars/dist/calendars/nanakshahi.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function NanakshahiCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ NanakshahiCalendar.prototype = new main.baseCalendar();
+ var gregorian = main.instance("gregorian");
+ assign(NanakshahiCalendar.prototype, {
+ /** The calendar name.
+ @memberof NanakshahiCalendar */
+ name: "Nanakshahi",
+ /** Julian date of start of Nanakshahi epoch: 14 March 1469 CE.
+ @memberof NanakshahiCalendar */
+ jdEpoch: 22576735e-1,
+ /** Days per month in a common year.
+ @memberof NanakshahiCalendar */
+ daysPerMonth: [31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30],
+ /** true
if has a year zero, false
if not.
+ @memberof NanakshahiCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof NanakshahiCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof NanakshahiCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof NanakshahiCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof NanakshahiCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Nanakshahi",
+ epochs: ["BN", "AN"],
+ monthNames: [
+ "Chet",
+ "Vaisakh",
+ "Jeth",
+ "Harh",
+ "Sawan",
+ "Bhadon",
+ "Assu",
+ "Katak",
+ "Maghar",
+ "Poh",
+ "Magh",
+ "Phagun"
+ ],
+ monthNamesShort: ["Che", "Vai", "Jet", "Har", "Saw", "Bha", "Ass", "Kat", "Mgr", "Poh", "Mgh", "Pha"],
+ dayNames: ["Somvaar", "Mangalvar", "Budhvaar", "Veervaar", "Shukarvaar", "Sanicharvaar", "Etvaar"],
+ dayNamesShort: ["Som", "Mangal", "Budh", "Veer", "Shukar", "Sanichar", "Et"],
+ dayNamesMin: ["So", "Ma", "Bu", "Ve", "Sh", "Sa", "Et"],
+ digits: null,
+ dateFormat: "dd-mm-yyyy",
+ firstDay: 0,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof NanakshahiCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(
+ year,
+ this.minMonth,
+ this.minDay,
+ main.local.invalidYear || main.regionalOptions[""].invalidYear
+ );
+ return gregorian.leapYear(date.year() + (date.year() < 1 ? 1 : 0) + 1469);
+ },
+ /** Determine the week of the year for a date.
+ @memberof NanakshahiCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(1 - (checkDate.dayOfWeek() || 7), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof NanakshahiCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return this.daysPerMonth[date.month() - 1] + (date.month() === 12 && this.leapYear(date.year()) ? 1 : 0);
+ },
+ /** Determine whether this date is a week day.
+ @memberof NanakshahiCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return (this.dayOfWeek(year, month, day) || 7) < 6;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof NanakshahiCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidMonth);
+ var year = date.year();
+ if (year < 0) {
+ year++;
+ }
+ var doy = date.day();
+ for (var m = 1; m < date.month(); m++) {
+ doy += this.daysPerMonth[m - 1];
+ }
+ return doy + gregorian.toJD(year + 1468, 3, 13);
+ },
+ /** Create a new date from a Julian date.
+ @memberof NanakshahiCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ jd = Math.floor(jd + 0.5);
+ var year = Math.floor((jd - (this.jdEpoch - 1)) / 366);
+ while (jd >= this.toJD(year + 1, 1, 1)) {
+ year++;
+ }
+ var day = jd - Math.floor(this.toJD(year, 1, 1) + 0.5) + 1;
+ var month = 1;
+ while (day > this.daysInMonth(year, month)) {
+ day -= this.daysInMonth(year, month);
+ month++;
+ }
+ return this.newDate(year, month, day);
+ }
+ });
+ main.calendars.nanakshahi = NanakshahiCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/nepali.js
+ var require_nepali = __commonJS({
+ "node_modules/world-calendars/dist/calendars/nepali.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function NepaliCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ NepaliCalendar.prototype = new main.baseCalendar();
+ assign(NepaliCalendar.prototype, {
+ /** The calendar name.
+ @memberof NepaliCalendar */
+ name: "Nepali",
+ /** Julian date of start of Nepali epoch: 14 April 57 BCE.
+ @memberof NepaliCalendar */
+ jdEpoch: 17007095e-1,
+ /** Days per month in a common year.
+ @memberof NepaliCalendar */
+ daysPerMonth: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ /** true
if has a year zero, false
if not.
+ @memberof NepaliCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof NepaliCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof NepaliCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof NepaliCalendar */
+ minDay: 1,
+ /** The number of days in the year.
+ @memberof NepaliCalendar */
+ daysPerYear: 365,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof NepaliCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Nepali",
+ epochs: ["BBS", "ABS"],
+ monthNames: [
+ "Baisakh",
+ "Jestha",
+ "Ashadh",
+ "Shrawan",
+ "Bhadra",
+ "Ashwin",
+ "Kartik",
+ "Mangsir",
+ "Paush",
+ "Mangh",
+ "Falgun",
+ "Chaitra"
+ ],
+ monthNamesShort: ["Bai", "Je", "As", "Shra", "Bha", "Ash", "Kar", "Mang", "Pau", "Ma", "Fal", "Chai"],
+ dayNames: ["Aaitabaar", "Sombaar", "Manglbaar", "Budhabaar", "Bihibaar", "Shukrabaar", "Shanibaar"],
+ dayNamesShort: ["Aaita", "Som", "Mangl", "Budha", "Bihi", "Shukra", "Shani"],
+ dayNamesMin: ["Aai", "So", "Man", "Bu", "Bi", "Shu", "Sha"],
+ digits: null,
+ dateFormat: "dd/mm/yyyy",
+ firstDay: 1,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof NepaliCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ return this.daysInYear(year) !== this.daysPerYear;
+ },
+ /** Determine the week of the year for a date.
+ @memberof NepaliCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(-checkDate.dayOfWeek(), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a year.
+ @memberof NepaliCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of days.
+ @throws Error if an invalid year or a different calendar used. */
+ daysInYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ year = date.year();
+ if (typeof this.NEPALI_CALENDAR_DATA[year] === "undefined") {
+ return this.daysPerYear;
+ }
+ var daysPerYear = 0;
+ for (var month_number = this.minMonth; month_number <= 12; month_number++) {
+ daysPerYear += this.NEPALI_CALENDAR_DATA[year][month_number];
+ }
+ return daysPerYear;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof NepaliCalendar
+ @param year {CDate|number| The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ if (year.year) {
+ month = year.month();
+ year = year.year();
+ }
+ this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return typeof this.NEPALI_CALENDAR_DATA[year] === "undefined" ? this.daysPerMonth[month - 1] : this.NEPALI_CALENDAR_DATA[year][month];
+ },
+ /** Determine whether this date is a week day.
+ @memberof NepaliCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return this.dayOfWeek(year, month, day) !== 6;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof NepaliCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(nepaliYear, nepaliMonth, nepaliDay) {
+ var date = this._validate(nepaliYear, nepaliMonth, nepaliDay, main.local.invalidDate);
+ nepaliYear = date.year();
+ nepaliMonth = date.month();
+ nepaliDay = date.day();
+ var gregorianCalendar = main.instance();
+ var gregorianDayOfYear = 0;
+ var nepaliMonthToCheck = nepaliMonth;
+ var nepaliYearToCheck = nepaliYear;
+ this._createMissingCalendarData(nepaliYear);
+ var gregorianYear = nepaliYear - (nepaliMonthToCheck > 9 || nepaliMonthToCheck === 9 && nepaliDay >= this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][0] ? 56 : 57);
+ if (nepaliMonth !== 9) {
+ gregorianDayOfYear = nepaliDay;
+ nepaliMonthToCheck--;
+ }
+ while (nepaliMonthToCheck !== 9) {
+ if (nepaliMonthToCheck <= 0) {
+ nepaliMonthToCheck = 12;
+ nepaliYearToCheck--;
+ }
+ gregorianDayOfYear += this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][nepaliMonthToCheck];
+ nepaliMonthToCheck--;
+ }
+ if (nepaliMonth === 9) {
+ gregorianDayOfYear += nepaliDay - this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][0];
+ if (gregorianDayOfYear < 0) {
+ gregorianDayOfYear += gregorianCalendar.daysInYear(gregorianYear);
+ }
+ } else {
+ gregorianDayOfYear += this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][9] - this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][0];
+ }
+ return gregorianCalendar.newDate(gregorianYear, 1, 1).add(gregorianDayOfYear, "d").toJD();
+ },
+ /** Create a new date from a Julian date.
+ @memberof NepaliCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ var gregorianCalendar = main.instance();
+ var gregorianDate = gregorianCalendar.fromJD(jd);
+ var gregorianYear = gregorianDate.year();
+ var gregorianDayOfYear = gregorianDate.dayOfYear();
+ var nepaliYear = gregorianYear + 56;
+ this._createMissingCalendarData(nepaliYear);
+ var nepaliMonth = 9;
+ var dayOfFirstJanInPaush = this.NEPALI_CALENDAR_DATA[nepaliYear][0];
+ var daysSinceJanFirstToEndOfNepaliMonth = this.NEPALI_CALENDAR_DATA[nepaliYear][nepaliMonth] - dayOfFirstJanInPaush + 1;
+ while (gregorianDayOfYear > daysSinceJanFirstToEndOfNepaliMonth) {
+ nepaliMonth++;
+ if (nepaliMonth > 12) {
+ nepaliMonth = 1;
+ nepaliYear++;
+ }
+ daysSinceJanFirstToEndOfNepaliMonth += this.NEPALI_CALENDAR_DATA[nepaliYear][nepaliMonth];
+ }
+ var nepaliDayOfMonth = this.NEPALI_CALENDAR_DATA[nepaliYear][nepaliMonth] - (daysSinceJanFirstToEndOfNepaliMonth - gregorianDayOfYear);
+ return this.newDate(nepaliYear, nepaliMonth, nepaliDayOfMonth);
+ },
+ /** Creates missing data in the NEPALI_CALENDAR_DATA table.
+ This data will not be correct but just give an estimated result. Mostly -/+ 1 day
+ @private
+ @param nepaliYear {number} The missing year number. */
+ _createMissingCalendarData: function(nepaliYear) {
+ var tmp_calendar_data = this.daysPerMonth.slice(0);
+ tmp_calendar_data.unshift(17);
+ for (var nepaliYearToCreate = nepaliYear - 1; nepaliYearToCreate < nepaliYear + 2; nepaliYearToCreate++) {
+ if (typeof this.NEPALI_CALENDAR_DATA[nepaliYearToCreate] === "undefined") {
+ this.NEPALI_CALENDAR_DATA[nepaliYearToCreate] = tmp_calendar_data;
+ }
+ }
+ },
+ NEPALI_CALENDAR_DATA: {
+ // These data are from http://www.ashesh.com.np
+ 1970: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1971: [18, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
+ 1972: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
+ 1973: [19, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 1974: [19, 31, 31, 32, 30, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1975: [18, 31, 31, 32, 32, 30, 31, 30, 29, 30, 29, 30, 30],
+ 1976: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 1977: [18, 31, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
+ 1978: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1979: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 1980: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 1981: [18, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
+ 1982: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1983: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 1984: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 1985: [18, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
+ 1986: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1987: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 1988: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 1989: [18, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1990: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1991: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ // These data are from http://nepalicalendar.rat32.com/index.php
+ 1992: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 1993: [18, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1994: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1995: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
+ 1996: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 1997: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1998: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 1999: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2e3: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 2001: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2002: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2003: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2004: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 2005: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2006: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2007: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2008: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
+ 2009: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2010: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2011: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2012: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
+ 2013: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2014: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2015: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2016: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
+ 2017: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2018: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2019: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 2020: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2021: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2022: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
+ 2023: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 2024: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2025: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2026: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2027: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 2028: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2029: [18, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
+ 2030: [17, 31, 32, 31, 32, 31, 30, 30, 30, 30, 30, 30, 31],
+ 2031: [17, 31, 32, 31, 32, 31, 31, 31, 31, 31, 31, 31, 31],
+ 2032: [17, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32],
+ 2033: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2034: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2035: [17, 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
+ 2036: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2037: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2038: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2039: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
+ 2040: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2041: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2042: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2043: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
+ 2044: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2045: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2046: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2047: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2048: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2049: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
+ 2050: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 2051: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2052: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2053: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
+ 2054: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 2055: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 29, 30],
+ 2056: [17, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
+ 2057: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2058: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 2059: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2060: [17, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2061: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2062: [17, 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
+ 2063: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2064: [17, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2065: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2066: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
+ 2067: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2068: [17, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2069: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2070: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
+ 2071: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2072: [17, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2073: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
+ 2074: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2075: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2076: [16, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
+ 2077: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
+ 2078: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2079: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
+ 2080: [16, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
+ // These data are from http://www.ashesh.com.np/nepali-calendar/
+ 2081: [17, 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2082: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2083: [17, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2084: [17, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2085: [17, 31, 32, 31, 32, 31, 31, 30, 30, 29, 30, 30, 30],
+ 2086: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2087: [16, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
+ 2088: [16, 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30],
+ 2089: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2090: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2091: [16, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
+ 2092: [16, 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2093: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2094: [17, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2095: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30],
+ 2096: [17, 30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
+ 2097: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
+ 2098: [17, 31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 30, 31],
+ 2099: [17, 31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30],
+ 2100: [17, 31, 32, 31, 32, 30, 31, 30, 29, 30, 29, 30, 30]
+ }
+ });
+ main.calendars.nepali = NepaliCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/persian.js
+ var require_persian = __commonJS({
+ "node_modules/world-calendars/dist/calendars/persian.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function PersianCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ PersianCalendar.prototype = new main.baseCalendar();
+ assign(PersianCalendar.prototype, {
+ /** The calendar name.
+ @memberof PersianCalendar */
+ name: "Persian",
+ /** Julian date of start of Persian epoch: 19 March 622 CE.
+ @memberof PersianCalendar */
+ jdEpoch: 19483205e-1,
+ /** Days per month in a common year.
+ @memberof PersianCalendar */
+ daysPerMonth: [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29],
+ /** true
if has a year zero, false
if not.
+ @memberof PersianCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof PersianCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof PersianCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof PersianCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof PersianCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Persian",
+ epochs: ["BP", "AP"],
+ monthNames: [
+ "Farvardin",
+ "Ordibehesht",
+ "Khordad",
+ "Tir",
+ "Mordad",
+ "Shahrivar",
+ "Mehr",
+ "Aban",
+ "Azar",
+ "Day",
+ "Bahman",
+ "Esfand"
+ ],
+ monthNamesShort: ["Far", "Ord", "Kho", "Tir", "Mor", "Sha", "Meh", "Aba", "Aza", "Day", "Bah", "Esf"],
+ dayNames: ["Yekshambe", "Doshambe", "Seshambe", "Ch\xE6harshambe", "Panjshambe", "Jom'e", "Shambe"],
+ dayNamesShort: ["Yek", "Do", "Se", "Ch\xE6", "Panj", "Jom", "Sha"],
+ dayNamesMin: ["Ye", "Do", "Se", "Ch", "Pa", "Jo", "Sh"],
+ digits: null,
+ dateFormat: "yyyy/mm/dd",
+ firstDay: 6,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof PersianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return ((date.year() - (date.year() > 0 ? 474 : 473)) % 2820 + 474 + 38) * 682 % 2816 < 682;
+ },
+ /** Determine the week of the year for a date.
+ @memberof PersianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(-((checkDate.dayOfWeek() + 1) % 7), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof PersianCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return this.daysPerMonth[date.month() - 1] + (date.month() === 12 && this.leapYear(date.year()) ? 1 : 0);
+ },
+ /** Determine whether this date is a week day.
+ @memberof PersianCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return this.dayOfWeek(year, month, day) !== 5;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof PersianCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ year = date.year();
+ month = date.month();
+ day = date.day();
+ var epBase = year - (year >= 0 ? 474 : 473);
+ var epYear = 474 + mod(epBase, 2820);
+ return day + (month <= 7 ? (month - 1) * 31 : (month - 1) * 30 + 6) + Math.floor((epYear * 682 - 110) / 2816) + (epYear - 1) * 365 + Math.floor(epBase / 2820) * 1029983 + this.jdEpoch - 1;
+ },
+ /** Create a new date from a Julian date.
+ @memberof PersianCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ jd = Math.floor(jd) + 0.5;
+ var depoch = jd - this.toJD(475, 1, 1);
+ var cycle = Math.floor(depoch / 1029983);
+ var cyear = mod(depoch, 1029983);
+ var ycycle = 2820;
+ if (cyear !== 1029982) {
+ var aux1 = Math.floor(cyear / 366);
+ var aux2 = mod(cyear, 366);
+ ycycle = Math.floor((2134 * aux1 + 2816 * aux2 + 2815) / 1028522) + aux1 + 1;
+ }
+ var year = ycycle + 2820 * cycle + 474;
+ year = year <= 0 ? year - 1 : year;
+ var yday = jd - this.toJD(year, 1, 1) + 1;
+ var month = yday <= 186 ? Math.ceil(yday / 31) : Math.ceil((yday - 6) / 30);
+ var day = jd - this.toJD(year, month, 1) + 1;
+ return this.newDate(year, month, day);
+ }
+ });
+ function mod(a, b) {
+ return a - b * Math.floor(a / b);
+ }
+ main.calendars.persian = PersianCalendar;
+ main.calendars.jalali = PersianCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/taiwan.js
+ var require_taiwan = __commonJS({
+ "node_modules/world-calendars/dist/calendars/taiwan.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ var gregorianCalendar = main.instance();
+ function TaiwanCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ TaiwanCalendar.prototype = new main.baseCalendar();
+ assign(TaiwanCalendar.prototype, {
+ /** The calendar name.
+ @memberof TaiwanCalendar */
+ name: "Taiwan",
+ /** Julian date of start of Taiwan epoch: 1 January 1912 CE (Gregorian).
+ @memberof TaiwanCalendar */
+ jdEpoch: 24194025e-1,
+ /** Difference in years between Taiwan and Gregorian calendars.
+ @memberof TaiwanCalendar */
+ yearsOffset: 1911,
+ /** Days per month in a common year.
+ @memberof TaiwanCalendar */
+ daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
+ /** true
if has a year zero, false
if not.
+ @memberof TaiwanCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof TaiwanCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof TaiwanCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof TaiwanCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof TaiwanCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Taiwan",
+ epochs: ["BROC", "ROC"],
+ monthNames: [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+ ],
+ monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
+ dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
+ dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
+ digits: null,
+ dateFormat: "yyyy/mm/dd",
+ firstDay: 1,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof TaiwanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ var year = this._t2gYear(date.year());
+ return gregorianCalendar.leapYear(year);
+ },
+ /** Determine the week of the year for a date - ISO 8601.
+ @memberof TaiwanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ var year = this._t2gYear(date.year());
+ return gregorianCalendar.weekOfYear(year, date.month(), date.day());
+ },
+ /** Retrieve the number of days in a month.
+ @memberof TaiwanCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return this.daysPerMonth[date.month() - 1] + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0);
+ },
+ /** Determine whether this date is a week day.
+ @memberof TaiwanCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return (this.dayOfWeek(year, month, day) || 7) < 6;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof TaiwanCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ var year = this._t2gYear(date.year());
+ return gregorianCalendar.toJD(year, date.month(), date.day());
+ },
+ /** Create a new date from a Julian date.
+ @memberof TaiwanCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ var date = gregorianCalendar.fromJD(jd);
+ var year = this._g2tYear(date.year());
+ return this.newDate(year, date.month(), date.day());
+ },
+ /** Convert Taiwanese to Gregorian year.
+ @memberof TaiwanCalendar
+ @private
+ @param year {number} The Taiwanese year.
+ @return {number} The corresponding Gregorian year. */
+ _t2gYear: function(year) {
+ return year + this.yearsOffset + (year >= -this.yearsOffset && year <= -1 ? 1 : 0);
+ },
+ /** Convert Gregorian to Taiwanese year.
+ @memberof TaiwanCalendar
+ @private
+ @param year {number} The Gregorian year.
+ @return {number} The corresponding Taiwanese year. */
+ _g2tYear: function(year) {
+ return year - this.yearsOffset - (year >= 1 && year <= this.yearsOffset ? 1 : 0);
+ }
+ });
+ main.calendars.taiwan = TaiwanCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/thai.js
+ var require_thai = __commonJS({
+ "node_modules/world-calendars/dist/calendars/thai.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ var gregorianCalendar = main.instance();
+ function ThaiCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ ThaiCalendar.prototype = new main.baseCalendar();
+ assign(ThaiCalendar.prototype, {
+ /** The calendar name.
+ @memberof ThaiCalendar */
+ name: "Thai",
+ /** Julian date of start of Thai epoch: 1 January 543 BCE (Gregorian).
+ @memberof ThaiCalendar */
+ jdEpoch: 15230985e-1,
+ /** Difference in years between Thai and Gregorian calendars.
+ @memberof ThaiCalendar */
+ yearsOffset: 543,
+ /** Days per month in a common year.
+ @memberof ThaiCalendar */
+ daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
+ /** true
if has a year zero, false
if not.
+ @memberof ThaiCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof ThaiCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof ThaiCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof ThaiCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof ThaiCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Thai",
+ epochs: ["BBE", "BE"],
+ monthNames: [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+ ],
+ monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
+ dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
+ dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
+ digits: null,
+ dateFormat: "dd/mm/yyyy",
+ firstDay: 0,
+ isRTL: false
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof ThaiCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ var year = this._t2gYear(date.year());
+ return gregorianCalendar.leapYear(year);
+ },
+ /** Determine the week of the year for a date - ISO 8601.
+ @memberof ThaiCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ var year = this._t2gYear(date.year());
+ return gregorianCalendar.weekOfYear(year, date.month(), date.day());
+ },
+ /** Retrieve the number of days in a month.
+ @memberof ThaiCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ return this.daysPerMonth[date.month() - 1] + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0);
+ },
+ /** Determine whether this date is a week day.
+ @memberof ThaiCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return (this.dayOfWeek(year, month, day) || 7) < 6;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof ThaiCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ var year = this._t2gYear(date.year());
+ return gregorianCalendar.toJD(year, date.month(), date.day());
+ },
+ /** Create a new date from a Julian date.
+ @memberof ThaiCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ var date = gregorianCalendar.fromJD(jd);
+ var year = this._g2tYear(date.year());
+ return this.newDate(year, date.month(), date.day());
+ },
+ /** Convert Thai to Gregorian year.
+ @memberof ThaiCalendar
+ @private
+ @param year {number} The Thai year.
+ @return {number} The corresponding Gregorian year. */
+ _t2gYear: function(year) {
+ return year - this.yearsOffset - (year >= 1 && year <= this.yearsOffset ? 1 : 0);
+ },
+ /** Convert Gregorian to Thai year.
+ @memberof ThaiCalendar
+ @private
+ @param year {number} The Gregorian year.
+ @return {number} The corresponding Thai year. */
+ _g2tYear: function(year) {
+ return year + this.yearsOffset + (year >= -this.yearsOffset && year <= -1 ? 1 : 0);
+ }
+ });
+ main.calendars.thai = ThaiCalendar;
+ }
+ });
+
+ // node_modules/world-calendars/dist/calendars/ummalqura.js
+ var require_ummalqura = __commonJS({
+ "node_modules/world-calendars/dist/calendars/ummalqura.js"() {
+ var main = require_main();
+ var assign = require_object_assign();
+ function UmmAlQuraCalendar(language) {
+ this.local = this.regionalOptions[language || ""] || this.regionalOptions[""];
+ }
+ UmmAlQuraCalendar.prototype = new main.baseCalendar();
+ assign(UmmAlQuraCalendar.prototype, {
+ /** The calendar name.
+ @memberof UmmAlQuraCalendar */
+ name: "UmmAlQura",
+ //jdEpoch: 1948440, // Julian date of start of UmmAlQura epoch: 14 March 1937 CE
+ //daysPerMonth: // Days per month in a common year, replaced by a method.
+ /** true
if has a year zero, false
if not.
+ @memberof UmmAlQuraCalendar */
+ hasYearZero: false,
+ /** The minimum month number.
+ @memberof UmmAlQuraCalendar */
+ minMonth: 1,
+ /** The first month in the year.
+ @memberof UmmAlQuraCalendar */
+ firstMonth: 1,
+ /** The minimum day number.
+ @memberof UmmAlQuraCalendar */
+ minDay: 1,
+ /** Localisations for the plugin.
+ Entries are objects indexed by the language code ('' being the default US/English).
+ Each object has the following attributes.
+ @memberof UmmAlQuraCalendar
+ @property name {string} The calendar name.
+ @property epochs {string[]} The epoch names.
+ @property monthNames {string[]} The long names of the months of the year.
+ @property monthNamesShort {string[]} The short names of the months of the year.
+ @property dayNames {string[]} The long names of the days of the week.
+ @property dayNamesShort {string[]} The short names of the days of the week.
+ @property dayNamesMin {string[]} The minimal names of the days of the week.
+ @property dateFormat {string} The date format for this calendar.
+ See the options on formatDate
for details.
+ @property firstDay {number} The number of the first day of the week, starting at 0.
+ @property isRTL {number} true
if this localisation reads right-to-left. */
+ regionalOptions: {
+ // Localisations
+ "": {
+ name: "Umm al-Qura",
+ epochs: ["BH", "AH"],
+ monthNames: [
+ "Al-Muharram",
+ "Safar",
+ "Rabi' al-awwal",
+ "Rabi' Al-Thani",
+ "Jumada Al-Awwal",
+ "Jumada Al-Thani",
+ "Rajab",
+ "Sha'aban",
+ "Ramadan",
+ "Shawwal",
+ "Dhu al-Qi'dah",
+ "Dhu al-Hijjah"
+ ],
+ monthNamesShort: ["Muh", "Saf", "Rab1", "Rab2", "Jum1", "Jum2", "Raj", "Sha'", "Ram", "Shaw", "DhuQ", "DhuH"],
+ dayNames: ["Yawm al-Ahad", "Yawm al-Ithnain", "Yawm al-Thal\u0101th\u0101\u2019", "Yawm al-Arba\u2018\u0101\u2019", "Yawm al-Kham\u012Bs", "Yawm al-Jum\u2018a", "Yawm al-Sabt"],
+ dayNamesMin: ["Ah", "Ith", "Th", "Ar", "Kh", "Ju", "Sa"],
+ digits: null,
+ dateFormat: "yyyy/mm/dd",
+ firstDay: 6,
+ isRTL: true
+ }
+ },
+ /** Determine whether this date is in a leap year.
+ @memberof UmmAlQuraCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {boolean} true
if this is a leap year, false
if not.
+ @throws Error if an invalid year or a different calendar used. */
+ leapYear: function(year) {
+ var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear);
+ return this.daysInYear(date.year()) === 355;
+ },
+ /** Determine the week of the year for a date.
+ @memberof UmmAlQuraCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {number} The week of the year.
+ @throws Error if an invalid date or a different calendar used. */
+ weekOfYear: function(year, month, day) {
+ var checkDate = this.newDate(year, month, day);
+ checkDate.add(-checkDate.dayOfWeek(), "d");
+ return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1;
+ },
+ /** Retrieve the number of days in a year.
+ @memberof UmmAlQuraCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @return {number} The number of days.
+ @throws Error if an invalid year or a different calendar used. */
+ daysInYear: function(year) {
+ var daysCount = 0;
+ for (var i = 1; i <= 12; i++) {
+ daysCount += this.daysInMonth(year, i);
+ }
+ return daysCount;
+ },
+ /** Retrieve the number of days in a month.
+ @memberof UmmAlQuraCalendar
+ @param year {CDate|number} The date to examine or the year of the month.
+ @param [month] {number} The month.
+ @return {number} The number of days in this month.
+ @throws Error if an invalid month/year or a different calendar used. */
+ daysInMonth: function(year, month) {
+ var date = this._validate(year, month, this.minDay, main.local.invalidMonth);
+ var mcjdn = date.toJD() - 24e5 + 0.5;
+ var index = 0;
+ for (var i = 0; i < ummalqura_dat.length; i++) {
+ if (ummalqura_dat[i] > mcjdn) {
+ return ummalqura_dat[index] - ummalqura_dat[index - 1];
+ }
+ index++;
+ }
+ return 30;
+ },
+ /** Determine whether this date is a week day.
+ @memberof UmmAlQuraCalendar
+ @param year {CDate|number} The date to examine or the year to examine.
+ @param [month] {number} The month to examine.
+ @param [day] {number} The day to examine.
+ @return {boolean} true
if a week day, false
if not.
+ @throws Error if an invalid date or a different calendar used. */
+ weekDay: function(year, month, day) {
+ return this.dayOfWeek(year, month, day) !== 5;
+ },
+ /** Retrieve the Julian date equivalent for this date,
+ i.e. days since January 1, 4713 BCE Greenwich noon.
+ @memberof UmmAlQuraCalendar
+ @param year {CDate|number} The date to convert or the year to convert.
+ @param [month] {number} The month to convert.
+ @param [day] {number} The day to convert.
+ @return {number} The equivalent Julian date.
+ @throws Error if an invalid date or a different calendar used. */
+ toJD: function(year, month, day) {
+ var date = this._validate(year, month, day, main.local.invalidDate);
+ var index = 12 * (date.year() - 1) + date.month() - 15292;
+ var mcjdn = date.day() + ummalqura_dat[index - 1] - 1;
+ return mcjdn + 24e5 - 0.5;
+ },
+ /** Create a new date from a Julian date.
+ @memberof UmmAlQuraCalendar
+ @param jd {number} The Julian date to convert.
+ @return {CDate} The equivalent date. */
+ fromJD: function(jd) {
+ var mcjdn = jd - 24e5 + 0.5;
+ var index = 0;
+ for (var i = 0; i < ummalqura_dat.length; i++) {
+ if (ummalqura_dat[i] > mcjdn) break;
+ index++;
+ }
+ var lunation = index + 15292;
+ var ii = Math.floor((lunation - 1) / 12);
+ var year = ii + 1;
+ var month = lunation - 12 * ii;
+ var day = mcjdn - ummalqura_dat[index - 1] + 1;
+ return this.newDate(year, month, day);
+ },
+ /** Determine whether a date is valid for this calendar.
+ @memberof UmmAlQuraCalendar
+ @param year {number} The year to examine.
+ @param month {number} The month to examine.
+ @param day {number} The day to examine.
+ @return {boolean} true
if a valid date, false
if not. */
+ isValid: function(year, month, day) {
+ var valid = main.baseCalendar.prototype.isValid.apply(this, arguments);
+ if (valid) {
+ year = year.year != null ? year.year : year;
+ valid = year >= 1276 && year <= 1500;
+ }
+ return valid;
+ },
+ /** Check that a candidate date is from the same calendar and is valid.
+ @memberof UmmAlQuraCalendar
+ @private
+ @param year {CDate|number} The date to validate or the year to validate.
+ @param month {number} The month to validate.
+ @param day {number} The day to validate.
+ @param error {string} Error message if invalid.
+ @throws Error if different calendars used or invalid date. */
+ _validate: function(year, month, day, error) {
+ var date = main.baseCalendar.prototype._validate.apply(this, arguments);
+ if (date.year < 1276 || date.year > 1500) {
+ throw error.replace(/\{0\}/, this.local.name);
+ }
+ return date;
+ }
+ });
+ main.calendars.ummalqura = UmmAlQuraCalendar;
+ var ummalqura_dat = [
+ 20,
+ 50,
+ 79,
+ 109,
+ 138,
+ 168,
+ 197,
+ 227,
+ 256,
+ 286,
+ 315,
+ 345,
+ 374,
+ 404,
+ 433,
+ 463,
+ 492,
+ 522,
+ 551,
+ 581,
+ 611,
+ 641,
+ 670,
+ 700,
+ 729,
+ 759,
+ 788,
+ 818,
+ 847,
+ 877,
+ 906,
+ 936,
+ 965,
+ 995,
+ 1024,
+ 1054,
+ 1083,
+ 1113,
+ 1142,
+ 1172,
+ 1201,
+ 1231,
+ 1260,
+ 1290,
+ 1320,
+ 1350,
+ 1379,
+ 1409,
+ 1438,
+ 1468,
+ 1497,
+ 1527,
+ 1556,
+ 1586,
+ 1615,
+ 1645,
+ 1674,
+ 1704,
+ 1733,
+ 1763,
+ 1792,
+ 1822,
+ 1851,
+ 1881,
+ 1910,
+ 1940,
+ 1969,
+ 1999,
+ 2028,
+ 2058,
+ 2087,
+ 2117,
+ 2146,
+ 2176,
+ 2205,
+ 2235,
+ 2264,
+ 2294,
+ 2323,
+ 2353,
+ 2383,
+ 2413,
+ 2442,
+ 2472,
+ 2501,
+ 2531,
+ 2560,
+ 2590,
+ 2619,
+ 2649,
+ 2678,
+ 2708,
+ 2737,
+ 2767,
+ 2796,
+ 2826,
+ 2855,
+ 2885,
+ 2914,
+ 2944,
+ 2973,
+ 3003,
+ 3032,
+ 3062,
+ 3091,
+ 3121,
+ 3150,
+ 3180,
+ 3209,
+ 3239,
+ 3268,
+ 3298,
+ 3327,
+ 3357,
+ 3386,
+ 3416,
+ 3446,
+ 3476,
+ 3505,
+ 3535,
+ 3564,
+ 3594,
+ 3623,
+ 3653,
+ 3682,
+ 3712,
+ 3741,
+ 3771,
+ 3800,
+ 3830,
+ 3859,
+ 3889,
+ 3918,
+ 3948,
+ 3977,
+ 4007,
+ 4036,
+ 4066,
+ 4095,
+ 4125,
+ 4155,
+ 4185,
+ 4214,
+ 4244,
+ 4273,
+ 4303,
+ 4332,
+ 4362,
+ 4391,
+ 4421,
+ 4450,
+ 4480,
+ 4509,
+ 4539,
+ 4568,
+ 4598,
+ 4627,
+ 4657,
+ 4686,
+ 4716,
+ 4745,
+ 4775,
+ 4804,
+ 4834,
+ 4863,
+ 4893,
+ 4922,
+ 4952,
+ 4981,
+ 5011,
+ 5040,
+ 5070,
+ 5099,
+ 5129,
+ 5158,
+ 5188,
+ 5218,
+ 5248,
+ 5277,
+ 5307,
+ 5336,
+ 5366,
+ 5395,
+ 5425,
+ 5454,
+ 5484,
+ 5513,
+ 5543,
+ 5572,
+ 5602,
+ 5631,
+ 5661,
+ 5690,
+ 5720,
+ 5749,
+ 5779,
+ 5808,
+ 5838,
+ 5867,
+ 5897,
+ 5926,
+ 5956,
+ 5985,
+ 6015,
+ 6044,
+ 6074,
+ 6103,
+ 6133,
+ 6162,
+ 6192,
+ 6221,
+ 6251,
+ 6281,
+ 6311,
+ 6340,
+ 6370,
+ 6399,
+ 6429,
+ 6458,
+ 6488,
+ 6517,
+ 6547,
+ 6576,
+ 6606,
+ 6635,
+ 6665,
+ 6694,
+ 6724,
+ 6753,
+ 6783,
+ 6812,
+ 6842,
+ 6871,
+ 6901,
+ 6930,
+ 6960,
+ 6989,
+ 7019,
+ 7048,
+ 7078,
+ 7107,
+ 7137,
+ 7166,
+ 7196,
+ 7225,
+ 7255,
+ 7284,
+ 7314,
+ 7344,
+ 7374,
+ 7403,
+ 7433,
+ 7462,
+ 7492,
+ 7521,
+ 7551,
+ 7580,
+ 7610,
+ 7639,
+ 7669,
+ 7698,
+ 7728,
+ 7757,
+ 7787,
+ 7816,
+ 7846,
+ 7875,
+ 7905,
+ 7934,
+ 7964,
+ 7993,
+ 8023,
+ 8053,
+ 8083,
+ 8112,
+ 8142,
+ 8171,
+ 8201,
+ 8230,
+ 8260,
+ 8289,
+ 8319,
+ 8348,
+ 8378,
+ 8407,
+ 8437,
+ 8466,
+ 8496,
+ 8525,
+ 8555,
+ 8584,
+ 8614,
+ 8643,
+ 8673,
+ 8702,
+ 8732,
+ 8761,
+ 8791,
+ 8821,
+ 8850,
+ 8880,
+ 8909,
+ 8938,
+ 8968,
+ 8997,
+ 9027,
+ 9056,
+ 9086,
+ 9115,
+ 9145,
+ 9175,
+ 9205,
+ 9234,
+ 9264,
+ 9293,
+ 9322,
+ 9352,
+ 9381,
+ 9410,
+ 9440,
+ 9470,
+ 9499,
+ 9529,
+ 9559,
+ 9589,
+ 9618,
+ 9648,
+ 9677,
+ 9706,
+ 9736,
+ 9765,
+ 9794,
+ 9824,
+ 9853,
+ 9883,
+ 9913,
+ 9943,
+ 9972,
+ 10002,
+ 10032,
+ 10061,
+ 10090,
+ 10120,
+ 10149,
+ 10178,
+ 10208,
+ 10237,
+ 10267,
+ 10297,
+ 10326,
+ 10356,
+ 10386,
+ 10415,
+ 10445,
+ 10474,
+ 10504,
+ 10533,
+ 10562,
+ 10592,
+ 10621,
+ 10651,
+ 10680,
+ 10710,
+ 10740,
+ 10770,
+ 10799,
+ 10829,
+ 10858,
+ 10888,
+ 10917,
+ 10947,
+ 10976,
+ 11005,
+ 11035,
+ 11064,
+ 11094,
+ 11124,
+ 11153,
+ 11183,
+ 11213,
+ 11242,
+ 11272,
+ 11301,
+ 11331,
+ 11360,
+ 11389,
+ 11419,
+ 11448,
+ 11478,
+ 11507,
+ 11537,
+ 11567,
+ 11596,
+ 11626,
+ 11655,
+ 11685,
+ 11715,
+ 11744,
+ 11774,
+ 11803,
+ 11832,
+ 11862,
+ 11891,
+ 11921,
+ 11950,
+ 11980,
+ 12010,
+ 12039,
+ 12069,
+ 12099,
+ 12128,
+ 12158,
+ 12187,
+ 12216,
+ 12246,
+ 12275,
+ 12304,
+ 12334,
+ 12364,
+ 12393,
+ 12423,
+ 12453,
+ 12483,
+ 12512,
+ 12542,
+ 12571,
+ 12600,
+ 12630,
+ 12659,
+ 12688,
+ 12718,
+ 12747,
+ 12777,
+ 12807,
+ 12837,
+ 12866,
+ 12896,
+ 12926,
+ 12955,
+ 12984,
+ 13014,
+ 13043,
+ 13072,
+ 13102,
+ 13131,
+ 13161,
+ 13191,
+ 13220,
+ 13250,
+ 13280,
+ 13310,
+ 13339,
+ 13368,
+ 13398,
+ 13427,
+ 13456,
+ 13486,
+ 13515,
+ 13545,
+ 13574,
+ 13604,
+ 13634,
+ 13664,
+ 13693,
+ 13723,
+ 13752,
+ 13782,
+ 13811,
+ 13840,
+ 13870,
+ 13899,
+ 13929,
+ 13958,
+ 13988,
+ 14018,
+ 14047,
+ 14077,
+ 14107,
+ 14136,
+ 14166,
+ 14195,
+ 14224,
+ 14254,
+ 14283,
+ 14313,
+ 14342,
+ 14372,
+ 14401,
+ 14431,
+ 14461,
+ 14490,
+ 14520,
+ 14550,
+ 14579,
+ 14609,
+ 14638,
+ 14667,
+ 14697,
+ 14726,
+ 14756,
+ 14785,
+ 14815,
+ 14844,
+ 14874,
+ 14904,
+ 14933,
+ 14963,
+ 14993,
+ 15021,
+ 15051,
+ 15081,
+ 15110,
+ 15140,
+ 15169,
+ 15199,
+ 15228,
+ 15258,
+ 15287,
+ 15317,
+ 15347,
+ 15377,
+ 15406,
+ 15436,
+ 15465,
+ 15494,
+ 15524,
+ 15553,
+ 15582,
+ 15612,
+ 15641,
+ 15671,
+ 15701,
+ 15731,
+ 15760,
+ 15790,
+ 15820,
+ 15849,
+ 15878,
+ 15908,
+ 15937,
+ 15966,
+ 15996,
+ 16025,
+ 16055,
+ 16085,
+ 16114,
+ 16144,
+ 16174,
+ 16204,
+ 16233,
+ 16262,
+ 16292,
+ 16321,
+ 16350,
+ 16380,
+ 16409,
+ 16439,
+ 16468,
+ 16498,
+ 16528,
+ 16558,
+ 16587,
+ 16617,
+ 16646,
+ 16676,
+ 16705,
+ 16734,
+ 16764,
+ 16793,
+ 16823,
+ 16852,
+ 16882,
+ 16912,
+ 16941,
+ 16971,
+ 17001,
+ 17030,
+ 17060,
+ 17089,
+ 17118,
+ 17148,
+ 17177,
+ 17207,
+ 17236,
+ 17266,
+ 17295,
+ 17325,
+ 17355,
+ 17384,
+ 17414,
+ 17444,
+ 17473,
+ 17502,
+ 17532,
+ 17561,
+ 17591,
+ 17620,
+ 17650,
+ 17679,
+ 17709,
+ 17738,
+ 17768,
+ 17798,
+ 17827,
+ 17857,
+ 17886,
+ 17916,
+ 17945,
+ 17975,
+ 18004,
+ 18034,
+ 18063,
+ 18093,
+ 18122,
+ 18152,
+ 18181,
+ 18211,
+ 18241,
+ 18270,
+ 18300,
+ 18330,
+ 18359,
+ 18388,
+ 18418,
+ 18447,
+ 18476,
+ 18506,
+ 18535,
+ 18565,
+ 18595,
+ 18625,
+ 18654,
+ 18684,
+ 18714,
+ 18743,
+ 18772,
+ 18802,
+ 18831,
+ 18860,
+ 18890,
+ 18919,
+ 18949,
+ 18979,
+ 19008,
+ 19038,
+ 19068,
+ 19098,
+ 19127,
+ 19156,
+ 19186,
+ 19215,
+ 19244,
+ 19274,
+ 19303,
+ 19333,
+ 19362,
+ 19392,
+ 19422,
+ 19452,
+ 19481,
+ 19511,
+ 19540,
+ 19570,
+ 19599,
+ 19628,
+ 19658,
+ 19687,
+ 19717,
+ 19746,
+ 19776,
+ 19806,
+ 19836,
+ 19865,
+ 19895,
+ 19924,
+ 19954,
+ 19983,
+ 20012,
+ 20042,
+ 20071,
+ 20101,
+ 20130,
+ 20160,
+ 20190,
+ 20219,
+ 20249,
+ 20279,
+ 20308,
+ 20338,
+ 20367,
+ 20396,
+ 20426,
+ 20455,
+ 20485,
+ 20514,
+ 20544,
+ 20573,
+ 20603,
+ 20633,
+ 20662,
+ 20692,
+ 20721,
+ 20751,
+ 20780,
+ 20810,
+ 20839,
+ 20869,
+ 20898,
+ 20928,
+ 20957,
+ 20987,
+ 21016,
+ 21046,
+ 21076,
+ 21105,
+ 21135,
+ 21164,
+ 21194,
+ 21223,
+ 21253,
+ 21282,
+ 21312,
+ 21341,
+ 21371,
+ 21400,
+ 21430,
+ 21459,
+ 21489,
+ 21519,
+ 21548,
+ 21578,
+ 21607,
+ 21637,
+ 21666,
+ 21696,
+ 21725,
+ 21754,
+ 21784,
+ 21813,
+ 21843,
+ 21873,
+ 21902,
+ 21932,
+ 21962,
+ 21991,
+ 22021,
+ 22050,
+ 22080,
+ 22109,
+ 22138,
+ 22168,
+ 22197,
+ 22227,
+ 22256,
+ 22286,
+ 22316,
+ 22346,
+ 22375,
+ 22405,
+ 22434,
+ 22464,
+ 22493,
+ 22522,
+ 22552,
+ 22581,
+ 22611,
+ 22640,
+ 22670,
+ 22700,
+ 22730,
+ 22759,
+ 22789,
+ 22818,
+ 22848,
+ 22877,
+ 22906,
+ 22936,
+ 22965,
+ 22994,
+ 23024,
+ 23054,
+ 23083,
+ 23113,
+ 23143,
+ 23173,
+ 23202,
+ 23232,
+ 23261,
+ 23290,
+ 23320,
+ 23349,
+ 23379,
+ 23408,
+ 23438,
+ 23467,
+ 23497,
+ 23527,
+ 23556,
+ 23586,
+ 23616,
+ 23645,
+ 23674,
+ 23704,
+ 23733,
+ 23763,
+ 23792,
+ 23822,
+ 23851,
+ 23881,
+ 23910,
+ 23940,
+ 23970,
+ 23999,
+ 24029,
+ 24058,
+ 24088,
+ 24117,
+ 24147,
+ 24176,
+ 24206,
+ 24235,
+ 24265,
+ 24294,
+ 24324,
+ 24353,
+ 24383,
+ 24413,
+ 24442,
+ 24472,
+ 24501,
+ 24531,
+ 24560,
+ 24590,
+ 24619,
+ 24648,
+ 24678,
+ 24707,
+ 24737,
+ 24767,
+ 24796,
+ 24826,
+ 24856,
+ 24885,
+ 24915,
+ 24944,
+ 24974,
+ 25003,
+ 25032,
+ 25062,
+ 25091,
+ 25121,
+ 25150,
+ 25180,
+ 25210,
+ 25240,
+ 25269,
+ 25299,
+ 25328,
+ 25358,
+ 25387,
+ 25416,
+ 25446,
+ 25475,
+ 25505,
+ 25534,
+ 25564,
+ 25594,
+ 25624,
+ 25653,
+ 25683,
+ 25712,
+ 25742,
+ 25771,
+ 25800,
+ 25830,
+ 25859,
+ 25888,
+ 25918,
+ 25948,
+ 25977,
+ 26007,
+ 26037,
+ 26067,
+ 26096,
+ 26126,
+ 26155,
+ 26184,
+ 26214,
+ 26243,
+ 26272,
+ 26302,
+ 26332,
+ 26361,
+ 26391,
+ 26421,
+ 26451,
+ 26480,
+ 26510,
+ 26539,
+ 26568,
+ 26598,
+ 26627,
+ 26656,
+ 26686,
+ 26715,
+ 26745,
+ 26775,
+ 26805,
+ 26834,
+ 26864,
+ 26893,
+ 26923,
+ 26952,
+ 26982,
+ 27011,
+ 27041,
+ 27070,
+ 27099,
+ 27129,
+ 27159,
+ 27188,
+ 27218,
+ 27248,
+ 27277,
+ 27307,
+ 27336,
+ 27366,
+ 27395,
+ 27425,
+ 27454,
+ 27484,
+ 27513,
+ 27542,
+ 27572,
+ 27602,
+ 27631,
+ 27661,
+ 27691,
+ 27720,
+ 27750,
+ 27779,
+ 27809,
+ 27838,
+ 27868,
+ 27897,
+ 27926,
+ 27956,
+ 27985,
+ 28015,
+ 28045,
+ 28074,
+ 28104,
+ 28134,
+ 28163,
+ 28193,
+ 28222,
+ 28252,
+ 28281,
+ 28310,
+ 28340,
+ 28369,
+ 28399,
+ 28428,
+ 28458,
+ 28488,
+ 28517,
+ 28547,
+ 28577,
+ // From 1356
+ 28607,
+ 28636,
+ 28665,
+ 28695,
+ 28724,
+ 28754,
+ 28783,
+ 28813,
+ 28843,
+ 28872,
+ 28901,
+ 28931,
+ 28960,
+ 28990,
+ 29019,
+ 29049,
+ 29078,
+ 29108,
+ 29137,
+ 29167,
+ 29196,
+ 29226,
+ 29255,
+ 29285,
+ 29315,
+ 29345,
+ 29375,
+ 29404,
+ 29434,
+ 29463,
+ 29492,
+ 29522,
+ 29551,
+ 29580,
+ 29610,
+ 29640,
+ 29669,
+ 29699,
+ 29729,
+ 29759,
+ 29788,
+ 29818,
+ 29847,
+ 29876,
+ 29906,
+ 29935,
+ 29964,
+ 29994,
+ 30023,
+ 30053,
+ 30082,
+ 30112,
+ 30141,
+ 30171,
+ 30200,
+ 30230,
+ 30259,
+ 30289,
+ 30318,
+ 30348,
+ 30378,
+ 30408,
+ 30437,
+ 30467,
+ 30496,
+ 30526,
+ 30555,
+ 30585,
+ 30614,
+ 30644,
+ 30673,
+ 30703,
+ 30732,
+ 30762,
+ 30791,
+ 30821,
+ 30850,
+ 30880,
+ 30909,
+ 30939,
+ 30968,
+ 30998,
+ 31027,
+ 31057,
+ 31086,
+ 31116,
+ 31145,
+ 31175,
+ 31204,
+ 31234,
+ 31263,
+ 31293,
+ 31322,
+ 31352,
+ 31381,
+ 31411,
+ 31441,
+ 31471,
+ 31500,
+ 31530,
+ 31559,
+ 31589,
+ 31618,
+ 31648,
+ 31676,
+ 31706,
+ 31736,
+ 31766,
+ 31795,
+ 31825,
+ 31854,
+ 31884,
+ 31913,
+ 31943,
+ 31972,
+ 32002,
+ 32031,
+ 32061,
+ 32090,
+ 32120,
+ 32150,
+ 32180,
+ 32209,
+ 32239,
+ 32268,
+ 32298,
+ 32327,
+ 32357,
+ 32386,
+ 32416,
+ 32445,
+ 32475,
+ 32504,
+ 32534,
+ 32563,
+ 32593,
+ 32622,
+ 32652,
+ 32681,
+ 32711,
+ 32740,
+ 32770,
+ 32799,
+ 32829,
+ 32858,
+ 32888,
+ 32917,
+ 32947,
+ 32976,
+ 33006,
+ 33035,
+ 33065,
+ 33094,
+ 33124,
+ 33153,
+ 33183,
+ 33213,
+ 33243,
+ 33272,
+ 33302,
+ 33331,
+ 33361,
+ 33390,
+ 33420,
+ 33450,
+ 33479,
+ 33509,
+ 33539,
+ 33568,
+ 33598,
+ 33627,
+ 33657,
+ 33686,
+ 33716,
+ 33745,
+ 33775,
+ 33804,
+ 33834,
+ 33863,
+ 33893,
+ 33922,
+ 33952,
+ 33981,
+ 34011,
+ 34040,
+ 34069,
+ 34099,
+ 34128,
+ 34158,
+ 34187,
+ 34217,
+ 34247,
+ 34277,
+ 34306,
+ 34336,
+ 34365,
+ 34395,
+ 34424,
+ 34454,
+ 34483,
+ 34512,
+ 34542,
+ 34571,
+ 34601,
+ 34631,
+ 34660,
+ 34690,
+ 34719,
+ 34749,
+ 34778,
+ 34808,
+ 34837,
+ 34867,
+ 34896,
+ 34926,
+ 34955,
+ 34985,
+ 35015,
+ 35044,
+ 35074,
+ 35103,
+ 35133,
+ 35162,
+ 35192,
+ 35222,
+ 35251,
+ 35280,
+ 35310,
+ 35340,
+ 35370,
+ 35399,
+ 35429,
+ 35458,
+ 35488,
+ 35517,
+ 35547,
+ 35576,
+ 35605,
+ 35635,
+ 35665,
+ 35694,
+ 35723,
+ 35753,
+ 35782,
+ 35811,
+ 35841,
+ 35871,
+ 35901,
+ 35930,
+ 35960,
+ 35989,
+ 36019,
+ 36048,
+ 36078,
+ 36107,
+ 36136,
+ 36166,
+ 36195,
+ 36225,
+ 36254,
+ 36284,
+ 36314,
+ 36343,
+ 36373,
+ 36403,
+ 36433,
+ 36462,
+ 36492,
+ 36521,
+ 36551,
+ 36580,
+ 36610,
+ 36639,
+ 36669,
+ 36698,
+ 36728,
+ 36757,
+ 36786,
+ 36816,
+ 36845,
+ 36875,
+ 36904,
+ 36934,
+ 36963,
+ 36993,
+ 37022,
+ 37052,
+ 37081,
+ 37111,
+ 37141,
+ 37170,
+ 37200,
+ 37229,
+ 37259,
+ 37288,
+ 37318,
+ 37347,
+ 37377,
+ 37406,
+ 37436,
+ 37465,
+ 37495,
+ 37524,
+ 37554,
+ 37584,
+ 37613,
+ 37643,
+ 37672,
+ 37701,
+ 37731,
+ 37760,
+ 37790,
+ 37819,
+ 37849,
+ 37878,
+ 37908,
+ 37938,
+ 37967,
+ 37997,
+ 38027,
+ 38056,
+ 38085,
+ 38115,
+ 38144,
+ 38174,
+ 38203,
+ 38233,
+ 38262,
+ 38292,
+ 38322,
+ 38351,
+ 38381,
+ 38410,
+ 38440,
+ 38469,
+ 38499,
+ 38528,
+ 38558,
+ 38587,
+ 38617,
+ 38646,
+ 38676,
+ 38705,
+ 38735,
+ 38764,
+ 38794,
+ 38823,
+ 38853,
+ 38882,
+ 38912,
+ 38941,
+ 38971,
+ 39001,
+ 39030,
+ 39059,
+ 39089,
+ 39118,
+ 39148,
+ 39178,
+ 39208,
+ 39237,
+ 39267,
+ 39297,
+ 39326,
+ 39355,
+ 39385,
+ 39414,
+ 39444,
+ 39473,
+ 39503,
+ 39532,
+ 39562,
+ 39592,
+ 39621,
+ 39650,
+ 39680,
+ 39709,
+ 39739,
+ 39768,
+ 39798,
+ 39827,
+ 39857,
+ 39886,
+ 39916,
+ 39946,
+ 39975,
+ 40005,
+ 40035,
+ 40064,
+ 40094,
+ 40123,
+ 40153,
+ 40182,
+ 40212,
+ 40241,
+ 40271,
+ 40300,
+ 40330,
+ 40359,
+ 40389,
+ 40418,
+ 40448,
+ 40477,
+ 40507,
+ 40536,
+ 40566,
+ 40595,
+ 40625,
+ 40655,
+ 40685,
+ 40714,
+ 40744,
+ 40773,
+ 40803,
+ 40832,
+ 40862,
+ 40892,
+ 40921,
+ 40951,
+ 40980,
+ 41009,
+ 41039,
+ 41068,
+ 41098,
+ 41127,
+ 41157,
+ 41186,
+ 41216,
+ 41245,
+ 41275,
+ 41304,
+ 41334,
+ 41364,
+ 41393,
+ 41422,
+ 41452,
+ 41481,
+ 41511,
+ 41540,
+ 41570,
+ 41599,
+ 41629,
+ 41658,
+ 41688,
+ 41718,
+ 41748,
+ 41777,
+ 41807,
+ 41836,
+ 41865,
+ 41894,
+ 41924,
+ 41953,
+ 41983,
+ 42012,
+ 42042,
+ 42072,
+ 42102,
+ 42131,
+ 42161,
+ 42190,
+ 42220,
+ 42249,
+ 42279,
+ 42308,
+ 42337,
+ 42367,
+ 42397,
+ 42426,
+ 42456,
+ 42485,
+ 42515,
+ 42545,
+ 42574,
+ 42604,
+ 42633,
+ 42662,
+ 42692,
+ 42721,
+ 42751,
+ 42780,
+ 42810,
+ 42839,
+ 42869,
+ 42899,
+ 42929,
+ 42958,
+ 42988,
+ 43017,
+ 43046,
+ 43076,
+ 43105,
+ 43135,
+ 43164,
+ 43194,
+ 43223,
+ 43253,
+ 43283,
+ 43312,
+ 43342,
+ 43371,
+ 43401,
+ 43430,
+ 43460,
+ 43489,
+ 43519,
+ 43548,
+ 43578,
+ 43607,
+ 43637,
+ 43666,
+ 43696,
+ 43726,
+ 43755,
+ 43785,
+ 43814,
+ 43844,
+ 43873,
+ 43903,
+ 43932,
+ 43962,
+ 43991,
+ 44021,
+ 44050,
+ 44080,
+ 44109,
+ 44139,
+ 44169,
+ 44198,
+ 44228,
+ 44258,
+ 44287,
+ 44317,
+ 44346,
+ 44375,
+ 44405,
+ 44434,
+ 44464,
+ 44493,
+ 44523,
+ 44553,
+ 44582,
+ 44612,
+ 44641,
+ 44671,
+ 44700,
+ 44730,
+ 44759,
+ 44788,
+ 44818,
+ 44847,
+ 44877,
+ 44906,
+ 44936,
+ 44966,
+ 44996,
+ 45025,
+ 45055,
+ 45084,
+ 45114,
+ 45143,
+ 45172,
+ 45202,
+ 45231,
+ 45261,
+ 45290,
+ 45320,
+ 45350,
+ 45380,
+ 45409,
+ 45439,
+ 45468,
+ 45498,
+ 45527,
+ 45556,
+ 45586,
+ 45615,
+ 45644,
+ 45674,
+ 45704,
+ 45733,
+ 45763,
+ 45793,
+ 45823,
+ 45852,
+ 45882,
+ 45911,
+ 45940,
+ 45970,
+ 45999,
+ 46028,
+ 46058,
+ 46088,
+ 46117,
+ 46147,
+ 46177,
+ 46206,
+ 46236,
+ 46265,
+ 46295,
+ 46324,
+ 46354,
+ 46383,
+ 46413,
+ 46442,
+ 46472,
+ 46501,
+ 46531,
+ 46560,
+ 46590,
+ 46620,
+ 46649,
+ 46679,
+ 46708,
+ 46738,
+ 46767,
+ 46797,
+ 46826,
+ 46856,
+ 46885,
+ 46915,
+ 46944,
+ 46974,
+ 47003,
+ 47033,
+ 47063,
+ 47092,
+ 47122,
+ 47151,
+ 47181,
+ 47210,
+ 47240,
+ 47269,
+ 47298,
+ 47328,
+ 47357,
+ 47387,
+ 47417,
+ 47446,
+ 47476,
+ 47506,
+ 47535,
+ 47565,
+ 47594,
+ 47624,
+ 47653,
+ 47682,
+ 47712,
+ 47741,
+ 47771,
+ 47800,
+ 47830,
+ 47860,
+ 47890,
+ 47919,
+ 47949,
+ 47978,
+ 48008,
+ 48037,
+ 48066,
+ 48096,
+ 48125,
+ 48155,
+ 48184,
+ 48214,
+ 48244,
+ 48273,
+ 48303,
+ 48333,
+ 48362,
+ 48392,
+ 48421,
+ 48450,
+ 48480,
+ 48509,
+ 48538,
+ 48568,
+ 48598,
+ 48627,
+ 48657,
+ 48687,
+ 48717,
+ 48746,
+ 48776,
+ 48805,
+ 48834,
+ 48864,
+ 48893,
+ 48922,
+ 48952,
+ 48982,
+ 49011,
+ 49041,
+ 49071,
+ 49100,
+ 49130,
+ 49160,
+ 49189,
+ 49218,
+ 49248,
+ 49277,
+ 49306,
+ 49336,
+ 49365,
+ 49395,
+ 49425,
+ 49455,
+ 49484,
+ 49514,
+ 49543,
+ 49573,
+ 49602,
+ 49632,
+ 49661,
+ 49690,
+ 49720,
+ 49749,
+ 49779,
+ 49809,
+ 49838,
+ 49868,
+ 49898,
+ 49927,
+ 49957,
+ 49986,
+ 50016,
+ 50045,
+ 50075,
+ 50104,
+ 50133,
+ 50163,
+ 50192,
+ 50222,
+ 50252,
+ 50281,
+ 50311,
+ 50340,
+ 50370,
+ 50400,
+ 50429,
+ 50459,
+ 50488,
+ 50518,
+ 50547,
+ 50576,
+ 50606,
+ 50635,
+ 50665,
+ 50694,
+ 50724,
+ 50754,
+ 50784,
+ 50813,
+ 50843,
+ 50872,
+ 50902,
+ 50931,
+ 50960,
+ 50990,
+ 51019,
+ 51049,
+ 51078,
+ 51108,
+ 51138,
+ 51167,
+ 51197,
+ 51227,
+ 51256,
+ 51286,
+ 51315,
+ 51345,
+ 51374,
+ 51403,
+ 51433,
+ 51462,
+ 51492,
+ 51522,
+ 51552,
+ 51582,
+ 51611,
+ 51641,
+ 51670,
+ 51699,
+ 51729,
+ 51758,
+ 51787,
+ 51816,
+ 51846,
+ 51876,
+ 51906,
+ 51936,
+ 51965,
+ 51995,
+ 52025,
+ 52054,
+ 52083,
+ 52113,
+ 52142,
+ 52171,
+ 52200,
+ 52230,
+ 52260,
+ 52290,
+ 52319,
+ 52349,
+ 52379,
+ 52408,
+ 52438,
+ 52467,
+ 52497,
+ 52526,
+ 52555,
+ 52585,
+ 52614,
+ 52644,
+ 52673,
+ 52703,
+ 52733,
+ 52762,
+ 52792,
+ 52822,
+ 52851,
+ 52881,
+ 52910,
+ 52939,
+ 52969,
+ 52998,
+ 53028,
+ 53057,
+ 53087,
+ 53116,
+ 53146,
+ 53176,
+ 53205,
+ 53235,
+ 53264,
+ 53294,
+ 53324,
+ 53353,
+ 53383,
+ 53412,
+ 53441,
+ 53471,
+ 53500,
+ 53530,
+ 53559,
+ 53589,
+ 53619,
+ 53648,
+ 53678,
+ 53708,
+ 53737,
+ 53767,
+ 53796,
+ 53825,
+ 53855,
+ 53884,
+ 53913,
+ 53943,
+ 53973,
+ 54003,
+ 54032,
+ 54062,
+ 54092,
+ 54121,
+ 54151,
+ 54180,
+ 54209,
+ 54239,
+ 54268,
+ 54297,
+ 54327,
+ 54357,
+ 54387,
+ 54416,
+ 54446,
+ 54476,
+ 54505,
+ 54535,
+ 54564,
+ 54593,
+ 54623,
+ 54652,
+ 54681,
+ 54711,
+ 54741,
+ 54770,
+ 54800,
+ 54830,
+ 54859,
+ 54889,
+ 54919,
+ 54948,
+ 54977,
+ 55007,
+ 55036,
+ 55066,
+ 55095,
+ 55125,
+ 55154,
+ 55184,
+ 55213,
+ 55243,
+ 55273,
+ 55302,
+ 55332,
+ 55361,
+ 55391,
+ 55420,
+ 55450,
+ 55479,
+ 55508,
+ 55538,
+ 55567,
+ 55597,
+ 55627,
+ 55657,
+ 55686,
+ 55716,
+ 55745,
+ 55775,
+ 55804,
+ 55834,
+ 55863,
+ 55892,
+ 55922,
+ 55951,
+ 55981,
+ 56011,
+ 56040,
+ 56070,
+ 56100,
+ 56129,
+ 56159,
+ 56188,
+ 56218,
+ 56247,
+ 56276,
+ 56306,
+ 56335,
+ 56365,
+ 56394,
+ 56424,
+ 56454,
+ 56483,
+ 56513,
+ 56543,
+ 56572,
+ 56601,
+ 56631,
+ 56660,
+ 56690,
+ 56719,
+ 56749,
+ 56778,
+ 56808,
+ 56837,
+ 56867,
+ 56897,
+ 56926,
+ 56956,
+ 56985,
+ 57015,
+ 57044,
+ 57074,
+ 57103,
+ 57133,
+ 57162,
+ 57192,
+ 57221,
+ 57251,
+ 57280,
+ 57310,
+ 57340,
+ 57369,
+ 57399,
+ 57429,
+ 57458,
+ 57487,
+ 57517,
+ 57546,
+ 57576,
+ 57605,
+ 57634,
+ 57664,
+ 57694,
+ 57723,
+ 57753,
+ 57783,
+ 57813,
+ 57842,
+ 57871,
+ 57901,
+ 57930,
+ 57959,
+ 57989,
+ 58018,
+ 58048,
+ 58077,
+ 58107,
+ 58137,
+ 58167,
+ 58196,
+ 58226,
+ 58255,
+ 58285,
+ 58314,
+ 58343,
+ 58373,
+ 58402,
+ 58432,
+ 58461,
+ 58491,
+ 58521,
+ 58551,
+ 58580,
+ 58610,
+ 58639,
+ 58669,
+ 58698,
+ 58727,
+ 58757,
+ 58786,
+ 58816,
+ 58845,
+ 58875,
+ 58905,
+ 58934,
+ 58964,
+ 58994,
+ 59023,
+ 59053,
+ 59082,
+ 59111,
+ 59141,
+ 59170,
+ 59200,
+ 59229,
+ 59259,
+ 59288,
+ 59318,
+ 59348,
+ 59377,
+ 59407,
+ 59436,
+ 59466,
+ 59495,
+ 59525,
+ 59554,
+ 59584,
+ 59613,
+ 59643,
+ 59672,
+ 59702,
+ 59731,
+ 59761,
+ 59791,
+ 59820,
+ 59850,
+ 59879,
+ 59909,
+ 59939,
+ 59968,
+ 59997,
+ 60027,
+ 60056,
+ 60086,
+ 60115,
+ 60145,
+ 60174,
+ 60204,
+ 60234,
+ 60264,
+ 60293,
+ 60323,
+ 60352,
+ 60381,
+ 60411,
+ 60440,
+ 60469,
+ 60499,
+ 60528,
+ 60558,
+ 60588,
+ 60618,
+ 60648,
+ 60677,
+ 60707,
+ 60736,
+ 60765,
+ 60795,
+ 60824,
+ 60853,
+ 60883,
+ 60912,
+ 60942,
+ 60972,
+ 61002,
+ 61031,
+ 61061,
+ 61090,
+ 61120,
+ 61149,
+ 61179,
+ 61208,
+ 61237,
+ 61267,
+ 61296,
+ 61326,
+ 61356,
+ 61385,
+ 61415,
+ 61445,
+ 61474,
+ 61504,
+ 61533,
+ 61563,
+ 61592,
+ 61621,
+ 61651,
+ 61680,
+ 61710,
+ 61739,
+ 61769,
+ 61799,
+ 61828,
+ 61858,
+ 61888,
+ 61917,
+ 61947,
+ 61976,
+ 62006,
+ 62035,
+ 62064,
+ 62094,
+ 62123,
+ 62153,
+ 62182,
+ 62212,
+ 62242,
+ 62271,
+ 62301,
+ 62331,
+ 62360,
+ 62390,
+ 62419,
+ 62448,
+ 62478,
+ 62507,
+ 62537,
+ 62566,
+ 62596,
+ 62625,
+ 62655,
+ 62685,
+ 62715,
+ 62744,
+ 62774,
+ 62803,
+ 62832,
+ 62862,
+ 62891,
+ 62921,
+ 62950,
+ 62980,
+ 63009,
+ 63039,
+ 63069,
+ 63099,
+ 63128,
+ 63157,
+ 63187,
+ 63216,
+ 63246,
+ 63275,
+ 63305,
+ 63334,
+ 63363,
+ 63393,
+ 63423,
+ 63453,
+ 63482,
+ 63512,
+ 63541,
+ 63571,
+ 63600,
+ 63630,
+ 63659,
+ 63689,
+ 63718,
+ 63747,
+ 63777,
+ 63807,
+ 63836,
+ 63866,
+ 63895,
+ 63925,
+ 63955,
+ 63984,
+ 64014,
+ 64043,
+ 64073,
+ 64102,
+ 64131,
+ 64161,
+ 64190,
+ 64220,
+ 64249,
+ 64279,
+ 64309,
+ 64339,
+ 64368,
+ 64398,
+ 64427,
+ 64457,
+ 64486,
+ 64515,
+ 64545,
+ 64574,
+ 64603,
+ 64633,
+ 64663,
+ 64692,
+ 64722,
+ 64752,
+ 64782,
+ 64811,
+ 64841,
+ 64870,
+ 64899,
+ 64929,
+ 64958,
+ 64987,
+ 65017,
+ 65047,
+ 65076,
+ 65106,
+ 65136,
+ 65166,
+ 65195,
+ 65225,
+ 65254,
+ 65283,
+ 65313,
+ 65342,
+ 65371,
+ 65401,
+ 65431,
+ 65460,
+ 65490,
+ 65520,
+ 65549,
+ 65579,
+ 65608,
+ 65638,
+ 65667,
+ 65697,
+ 65726,
+ 65755,
+ 65785,
+ 65815,
+ 65844,
+ 65874,
+ 65903,
+ 65933,
+ 65963,
+ 65992,
+ 66022,
+ 66051,
+ 66081,
+ 66110,
+ 66140,
+ 66169,
+ 66199,
+ 66228,
+ 66258,
+ 66287,
+ 66317,
+ 66346,
+ 66376,
+ 66405,
+ 66435,
+ 66465,
+ 66494,
+ 66524,
+ 66553,
+ 66583,
+ 66612,
+ 66641,
+ 66671,
+ 66700,
+ 66730,
+ 66760,
+ 66789,
+ 66819,
+ 66849,
+ 66878,
+ 66908,
+ 66937,
+ 66967,
+ 66996,
+ 67025,
+ 67055,
+ 67084,
+ 67114,
+ 67143,
+ 67173,
+ 67203,
+ 67233,
+ 67262,
+ 67292,
+ 67321,
+ 67351,
+ 67380,
+ 67409,
+ 67439,
+ 67468,
+ 67497,
+ 67527,
+ 67557,
+ 67587,
+ 67617,
+ 67646,
+ 67676,
+ 67705,
+ 67735,
+ 67764,
+ 67793,
+ 67823,
+ 67852,
+ 67882,
+ 67911,
+ 67941,
+ 67971,
+ 68e3,
+ 68030,
+ 68060,
+ 68089,
+ 68119,
+ 68148,
+ 68177,
+ 68207,
+ 68236,
+ 68266,
+ 68295,
+ 68325,
+ 68354,
+ 68384,
+ 68414,
+ 68443,
+ 68473,
+ 68502,
+ 68532,
+ 68561,
+ 68591,
+ 68620,
+ 68650,
+ 68679,
+ 68708,
+ 68738,
+ 68768,
+ 68797,
+ 68827,
+ 68857,
+ 68886,
+ 68916,
+ 68946,
+ 68975,
+ 69004,
+ 69034,
+ 69063,
+ 69092,
+ 69122,
+ 69152,
+ 69181,
+ 69211,
+ 69240,
+ 69270,
+ 69300,
+ 69330,
+ 69359,
+ 69388,
+ 69418,
+ 69447,
+ 69476,
+ 69506,
+ 69535,
+ 69565,
+ 69595,
+ 69624,
+ 69654,
+ 69684,
+ 69713,
+ 69743,
+ 69772,
+ 69802,
+ 69831,
+ 69861,
+ 69890,
+ 69919,
+ 69949,
+ 69978,
+ 70008,
+ 70038,
+ 70067,
+ 70097,
+ 70126,
+ 70156,
+ 70186,
+ 70215,
+ 70245,
+ 70274,
+ 70303,
+ 70333,
+ 70362,
+ 70392,
+ 70421,
+ 70451,
+ 70481,
+ 70510,
+ 70540,
+ 70570,
+ 70599,
+ 70629,
+ 70658,
+ 70687,
+ 70717,
+ 70746,
+ 70776,
+ 70805,
+ 70835,
+ 70864,
+ 70894,
+ 70924,
+ 70954,
+ 70983,
+ 71013,
+ 71042,
+ 71071,
+ 71101,
+ 71130,
+ 71159,
+ 71189,
+ 71218,
+ 71248,
+ 71278,
+ 71308,
+ 71337,
+ 71367,
+ 71397,
+ 71426,
+ 71455,
+ 71485,
+ 71514,
+ 71543,
+ 71573,
+ 71602,
+ 71632,
+ 71662,
+ 71691,
+ 71721,
+ 71751,
+ 71781,
+ 71810,
+ 71839,
+ 71869,
+ 71898,
+ 71927,
+ 71957,
+ 71986,
+ 72016,
+ 72046,
+ 72075,
+ 72105,
+ 72135,
+ 72164,
+ 72194,
+ 72223,
+ 72253,
+ 72282,
+ 72311,
+ 72341,
+ 72370,
+ 72400,
+ 72429,
+ 72459,
+ 72489,
+ 72518,
+ 72548,
+ 72577,
+ 72607,
+ 72637,
+ 72666,
+ 72695,
+ 72725,
+ 72754,
+ 72784,
+ 72813,
+ 72843,
+ 72872,
+ 72902,
+ 72931,
+ 72961,
+ 72991,
+ 73020,
+ 73050,
+ 73080,
+ 73109,
+ 73139,
+ 73168,
+ 73197,
+ 73227,
+ 73256,
+ 73286,
+ 73315,
+ 73345,
+ 73375,
+ 73404,
+ 73434,
+ 73464,
+ 73493,
+ 73523,
+ 73552,
+ 73581,
+ 73611,
+ 73640,
+ 73669,
+ 73699,
+ 73729,
+ 73758,
+ 73788,
+ 73818,
+ 73848,
+ 73877,
+ 73907,
+ 73936,
+ 73965,
+ 73995,
+ 74024,
+ 74053,
+ 74083,
+ 74113,
+ 74142,
+ 74172,
+ 74202,
+ 74231,
+ 74261,
+ 74291,
+ 74320,
+ 74349,
+ 74379,
+ 74408,
+ 74437,
+ 74467,
+ 74497,
+ 74526,
+ 74556,
+ 74586,
+ 74615,
+ 74645,
+ 74675,
+ 74704,
+ 74733,
+ 74763,
+ 74792,
+ 74822,
+ 74851,
+ 74881,
+ 74910,
+ 74940,
+ 74969,
+ 74999,
+ 75029,
+ 75058,
+ 75088,
+ 75117,
+ 75147,
+ 75176,
+ 75206,
+ 75235,
+ 75264,
+ 75294,
+ 75323,
+ 75353,
+ 75383,
+ 75412,
+ 75442,
+ 75472,
+ 75501,
+ 75531,
+ 75560,
+ 75590,
+ 75619,
+ 75648,
+ 75678,
+ 75707,
+ 75737,
+ 75766,
+ 75796,
+ 75826,
+ 75856,
+ 75885,
+ 75915,
+ 75944,
+ 75974,
+ 76003,
+ 76032,
+ 76062,
+ 76091,
+ 76121,
+ 76150,
+ 76180,
+ 76210,
+ 76239,
+ 76269,
+ 76299,
+ 76328,
+ 76358,
+ 76387,
+ 76416,
+ 76446,
+ 76475,
+ 76505,
+ 76534,
+ 76564,
+ 76593,
+ 76623,
+ 76653,
+ 76682,
+ 76712,
+ 76741,
+ 76771,
+ 76801,
+ 76830,
+ 76859,
+ 76889,
+ 76918,
+ 76948,
+ 76977,
+ 77007,
+ 77036,
+ 77066,
+ 77096,
+ 77125,
+ 77155,
+ 77185,
+ 77214,
+ 77243,
+ 77273,
+ 77302,
+ 77332,
+ 77361,
+ 77390,
+ 77420,
+ 77450,
+ 77479,
+ 77509,
+ 77539,
+ 77569,
+ 77598,
+ 77627,
+ 77657,
+ 77686,
+ 77715,
+ 77745,
+ 77774,
+ 77804,
+ 77833,
+ 77863,
+ 77893,
+ 77923,
+ 77952,
+ 77982,
+ 78011,
+ 78041,
+ 78070,
+ 78099,
+ 78129,
+ 78158,
+ 78188,
+ 78217,
+ 78247,
+ 78277,
+ 78307,
+ 78336,
+ 78366,
+ 78395,
+ 78425,
+ 78454,
+ 78483,
+ 78513,
+ 78542,
+ 78572,
+ 78601,
+ 78631,
+ 78661,
+ 78690,
+ 78720,
+ 78750,
+ 78779,
+ 78808,
+ 78838,
+ 78867,
+ 78897,
+ 78926,
+ 78956,
+ 78985,
+ 79015,
+ 79044,
+ 79074,
+ 79104,
+ 79133,
+ 79163,
+ 79192,
+ 79222,
+ 79251,
+ 79281,
+ 79310,
+ 79340,
+ 79369,
+ 79399,
+ 79428,
+ 79458,
+ 79487,
+ 79517,
+ 79546,
+ 79576,
+ 79606,
+ 79635,
+ 79665,
+ 79695,
+ 79724,
+ 79753,
+ 79783,
+ 79812,
+ 79841,
+ 79871,
+ 79900,
+ 79930,
+ 79960,
+ 79990
+ ];
+ }
+ });
+
+ // src/components/calendars/calendars.js
+ var require_calendars = __commonJS({
+ "src/components/calendars/calendars.js"(exports, module) {
+ "use strict";
+ module.exports = require_main();
+ require_plus();
+ require_chinese();
+ require_coptic();
+ require_discworld();
+ require_ethiopian();
+ require_hebrew();
+ require_islamic();
+ require_julian();
+ require_mayan();
+ require_nanakshahi();
+ require_nepali();
+ require_persian();
+ require_taiwan();
+ require_thai();
+ require_ummalqura();
+ }
+ });
+
+ // src/components/calendars/index.js
+ var require_calendars2 = __commonJS({
+ "src/components/calendars/index.js"(exports, module) {
+ "use strict";
+ var calendars = require_calendars();
+ var Lib = require_lib();
+ var constants = require_numerical();
+ var EPOCHJD = constants.EPOCHJD;
+ var ONEDAY = constants.ONEDAY;
+ var attributes = {
+ valType: "enumerated",
+ values: Lib.sortObjectKeys(calendars.calendars),
+ editType: "calc",
+ dflt: "gregorian"
+ };
+ var handleDefaults = function(contIn, contOut, attr, dflt) {
+ var attrs = {};
+ attrs[attr] = attributes;
+ return Lib.coerce(contIn, contOut, attrs, attr, dflt);
+ };
+ var handleTraceDefaults = function(traceIn, traceOut, coords, layout) {
+ for (var i = 0; i < coords.length; i++) {
+ handleDefaults(traceIn, traceOut, coords[i] + "calendar", layout.calendar);
+ }
+ };
+ var CANONICAL_TICK = {
+ chinese: "2000-01-01",
+ coptic: "2000-01-01",
+ discworld: "2000-01-01",
+ ethiopian: "2000-01-01",
+ hebrew: "5000-01-01",
+ islamic: "1000-01-01",
+ julian: "2000-01-01",
+ mayan: "5000-01-01",
+ nanakshahi: "1000-01-01",
+ nepali: "2000-01-01",
+ persian: "1000-01-01",
+ jalali: "1000-01-01",
+ taiwan: "1000-01-01",
+ thai: "2000-01-01",
+ ummalqura: "1400-01-01"
+ };
+ var CANONICAL_SUNDAY = {
+ chinese: "2000-01-02",
+ coptic: "2000-01-03",
+ discworld: "2000-01-03",
+ ethiopian: "2000-01-05",
+ hebrew: "5000-01-01",
+ islamic: "1000-01-02",
+ julian: "2000-01-03",
+ mayan: "5000-01-01",
+ nanakshahi: "1000-01-05",
+ nepali: "2000-01-05",
+ persian: "1000-01-01",
+ jalali: "1000-01-01",
+ taiwan: "1000-01-04",
+ thai: "2000-01-04",
+ ummalqura: "1400-01-06"
+ };
+ var DFLTRANGE = {
+ chinese: ["2000-01-01", "2001-01-01"],
+ coptic: ["1700-01-01", "1701-01-01"],
+ discworld: ["1800-01-01", "1801-01-01"],
+ ethiopian: ["2000-01-01", "2001-01-01"],
+ hebrew: ["5700-01-01", "5701-01-01"],
+ islamic: ["1400-01-01", "1401-01-01"],
+ julian: ["2000-01-01", "2001-01-01"],
+ mayan: ["5200-01-01", "5201-01-01"],
+ nanakshahi: ["0500-01-01", "0501-01-01"],
+ nepali: ["2000-01-01", "2001-01-01"],
+ persian: ["1400-01-01", "1401-01-01"],
+ jalali: ["1400-01-01", "1401-01-01"],
+ taiwan: ["0100-01-01", "0101-01-01"],
+ thai: ["2500-01-01", "2501-01-01"],
+ ummalqura: ["1400-01-01", "1401-01-01"]
+ };
+ var UNKNOWN = "##";
+ var d3ToWorldCalendars = {
+ d: { 0: "dd", "-": "d" },
+ // 2-digit or unpadded day of month
+ e: { 0: "d", "-": "d" },
+ // alternate, always unpadded day of month
+ a: { 0: "D", "-": "D" },
+ // short weekday name
+ A: { 0: "DD", "-": "DD" },
+ // full weekday name
+ j: { 0: "oo", "-": "o" },
+ // 3-digit or unpadded day of the year
+ W: { 0: "ww", "-": "w" },
+ // 2-digit or unpadded week of the year (Monday first)
+ m: { 0: "mm", "-": "m" },
+ // 2-digit or unpadded month number
+ b: { 0: "M", "-": "M" },
+ // short month name
+ B: { 0: "MM", "-": "MM" },
+ // full month name
+ y: { 0: "yy", "-": "yy" },
+ // 2-digit year (map unpadded to zero-padded)
+ Y: { 0: "yyyy", "-": "yyyy" },
+ // 4-digit year (map unpadded to zero-padded)
+ U: UNKNOWN,
+ // Sunday-first week of the year
+ w: UNKNOWN,
+ // day of the week [0(sunday),6]
+ // combined format, we replace the date part with the world-calendar version
+ // and the %X stays there for d3 to handle with time parts
+ c: { 0: "D M d %X yyyy", "-": "D M d %X yyyy" },
+ x: { 0: "mm/dd/yyyy", "-": "mm/dd/yyyy" }
+ };
+ function worldCalFmt(fmt, x, calendar) {
+ var dateJD = Math.floor((x + 0.05) / ONEDAY) + EPOCHJD;
+ var cDate = getCal(calendar).fromJD(dateJD);
+ var i = 0;
+ var modifier, directive, directiveLen, directiveObj, replacementPart;
+ while ((i = fmt.indexOf("%", i)) !== -1) {
+ modifier = fmt.charAt(i + 1);
+ if (modifier === "0" || modifier === "-" || modifier === "_") {
+ directiveLen = 3;
+ directive = fmt.charAt(i + 2);
+ if (modifier === "_") modifier = "-";
+ } else {
+ directive = modifier;
+ modifier = "0";
+ directiveLen = 2;
+ }
+ directiveObj = d3ToWorldCalendars[directive];
+ if (!directiveObj) {
+ i += directiveLen;
+ } else {
+ if (directiveObj === UNKNOWN) replacementPart = UNKNOWN;
+ else replacementPart = cDate.formatDate(directiveObj[modifier]);
+ fmt = fmt.substr(0, i) + replacementPart + fmt.substr(i + directiveLen);
+ i += replacementPart.length;
+ }
+ }
+ return fmt;
+ }
+ var allCals = {};
+ function getCal(calendar) {
+ var calendarObj = allCals[calendar];
+ if (calendarObj) return calendarObj;
+ calendarObj = allCals[calendar] = calendars.instance(calendar);
+ return calendarObj;
+ }
+ function makeAttrs(description) {
+ return Lib.extendFlat({}, attributes, { description });
+ }
+ function makeTraceAttrsDescription(coord) {
+ return "Sets the calendar system to use with `" + coord + "` date data.";
+ }
+ var xAttrs = {
+ xcalendar: makeAttrs(makeTraceAttrsDescription("x"))
+ };
+ var xyAttrs = Lib.extendFlat({}, xAttrs, {
+ ycalendar: makeAttrs(makeTraceAttrsDescription("y"))
+ });
+ var xyzAttrs = Lib.extendFlat({}, xyAttrs, {
+ zcalendar: makeAttrs(makeTraceAttrsDescription("z"))
+ });
+ var axisAttrs = makeAttrs([
+ "Sets the calendar system to use for `range` and `tick0`",
+ "if this is a date axis. This does not set the calendar for",
+ "interpreting data on this axis, that's specified in the trace",
+ "or via the global `layout.calendar`"
+ ].join(" "));
+ module.exports = {
+ moduleType: "component",
+ name: "calendars",
+ schema: {
+ traces: {
+ scatter: xyAttrs,
+ bar: xyAttrs,
+ box: xyAttrs,
+ heatmap: xyAttrs,
+ contour: xyAttrs,
+ histogram: xyAttrs,
+ histogram2d: xyAttrs,
+ histogram2dcontour: xyAttrs,
+ scatter3d: xyzAttrs,
+ surface: xyzAttrs,
+ mesh3d: xyzAttrs,
+ scattergl: xyAttrs,
+ ohlc: xAttrs,
+ candlestick: xAttrs
+ },
+ layout: {
+ calendar: makeAttrs([
+ "Sets the default calendar system to use for interpreting and",
+ "displaying dates throughout the plot."
+ ].join(" "))
+ },
+ subplots: {
+ xaxis: { calendar: axisAttrs },
+ yaxis: { calendar: axisAttrs },
+ scene: {
+ xaxis: { calendar: axisAttrs },
+ // TODO: it's actually redundant to include yaxis and zaxis here
+ // because in the scene attributes these are the same object so merging
+ // into one merges into them all. However, I left them in for parity with
+ // cartesian, where yaxis is unused until we Plotschema.get() when we
+ // use its presence or absence to determine whether to delete attributes
+ // from yaxis if they only apply to x (rangeselector/rangeslider)
+ yaxis: { calendar: axisAttrs },
+ zaxis: { calendar: axisAttrs }
+ },
+ polar: {
+ radialaxis: { calendar: axisAttrs }
+ }
+ }
+ },
+ layoutAttributes: attributes,
+ handleDefaults,
+ handleTraceDefaults,
+ CANONICAL_SUNDAY,
+ CANONICAL_TICK,
+ DFLTRANGE,
+ getCal,
+ worldCalFmt
+ };
+ }
+ });
+
+ // lib/calendars.js
+ var require_calendars3 = __commonJS({
+ "lib/calendars.js"(exports, module) {
+ "use strict";
+ module.exports = require_calendars2();
+ }
+ });
+
+ // lib/index.js
+ var require_lib2 = __commonJS({
+ "lib/index.js"(exports, module) {
+ var Plotly = require_core2();
+ Plotly.register([
+ // traces
+ require_bar2(),
+ require_box2(),
+ require_heatmap2(),
+ require_histogram2(),
+ require_histogram2d2(),
+ require_histogram2dcontour2(),
+ require_contour2(),
+ require_scatterternary2(),
+ require_violin2(),
+ require_funnel2(),
+ require_waterfall2(),
+ require_image2(),
+ require_pie2(),
+ require_sunburst2(),
+ require_treemap2(),
+ require_icicle2(),
+ require_funnelarea2(),
+ require_scatter3d2(),
+ require_surface2(),
+ require_isosurface2(),
+ require_volume2(),
+ require_mesh3d2(),
+ require_cone2(),
+ require_streamtube2(),
+ require_scattergeo2(),
+ require_choropleth2(),
+ require_scattergl2(),
+ require_splom2(),
+ require_parcoords3(),
+ require_parcats3(),
+ require_scattermapbox2(),
+ require_choroplethmapbox2(),
+ require_densitymapbox2(),
+ require_scattermap2(),
+ require_choroplethmap2(),
+ require_densitymap2(),
+ require_sankey2(),
+ require_indicator2(),
+ require_table2(),
+ require_carpet2(),
+ require_scattercarpet2(),
+ require_contourcarpet2(),
+ require_ohlc2(),
+ require_candlestick2(),
+ require_scatterpolar2(),
+ require_scatterpolargl2(),
+ require_barpolar2(),
+ require_scattersmith2(),
+ // components
+ require_calendars3()
+ ]);
+ module.exports = Plotly;
+ }
+ });
+ return require_lib2();
+})();
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh