{"version":3,"file":"cluster.mjs","sources":["../../../../packages/utils/cluster.ts"],"sourcesContent":["export const cluster = `!(function (t, e) {\n  typeof exports == 'object' && typeof module != 'undefined'\n    ? (module.exports = e())\n    : typeof define == 'function' && define.amd\n      ? define(e)\n      : ((t = typeof globalThis != 'undefined' ? globalThis : t || self).Cluster = e())\n})(this, function () {\n  'use strict'\n  class t {\n    constructor(e) {\n      this._hashCode = e != null ? e : t.guid()\n    }\n    getHandlers(t) {\n      const e = this._events || (this._events = new Map())\n      return e.has(t) || e.set(t, new Map()), e.get(t)\n    }\n    on(e, s) {\n      if (typeof s != 'function') return\n      this.getHandlers(e).set(s, t.guid())\n    }\n    addEventListener(t, e) {\n      this.on(t, e)\n    }\n    off(t, e) {\n      let s\n      const i = this.getHandlers(t)\n      e ? i.has(e) && i.delete(e) : (s = this._events) === null || void 0 === s || s.clear()\n    }\n    removeEventListener(t, e) {\n      this.off(t, e)\n    }\n    fire(t, e) {\n      const s = Array.from(this.getHandlers(t).entries())\n      for (const [t] of s) t.call(this, e)\n    }\n    dispatchEvent(t, e) {\n      this.fire(t, e)\n    }\n    destroy() {\n      let t\n      ;(t = this._events) === null || void 0 === t || t.clear(), (this._events = null)\n    }\n    get hashCode() {\n      return this._hashCode\n    }\n    static guid() {\n      return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (t) {\n        const e = (16 * Math.random()) | 0\n        return (t == 'x' ? e : (3 & e) | 8).toString(16)\n      })\n    }\n  }\n  let e, s, i, r\n  !(function (t) {\n    ;(t.CLICK = 'click'), (t.MOUSE_OVER = 'mouseover'), (t.MOUSE_OUT = 'mouseout'), (t.CHANGE = 'change'), (t.DESTROY = 'destroy')\n  })(e || (e = {})),\n    (function (t) {\n      ;(t.DIS_PIXEL = 'dis-pixel'), (t.ATTR_REF = 'attribute'), (t.GEO_FENCE = 'geo-fence')\n    })(s || (s = {})),\n    (function (t) {\n      ;(t.DOM = 'dom'), (t.WEBGL = 'webgl')\n    })(i || (i = {})),\n    (function (t) {\n      ;(t.MULTI = 'multi'), (t.SINGLE = 'single')\n    })(r || (r = {}))\n  const o = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]\n  class n {\n    static from(t) {\n      if (!(t instanceof ArrayBuffer)) throw new Error('Data must be an instance of ArrayBuffer.')\n      const [e, s] = new Uint8Array(t, 0, 2)\n      if (e !== 219) throw new Error('Data does not appear to be in a KDBush format.')\n      const i = s >> 4\n      if (i !== 1) throw new Error('Got v'+i+' data when expected v1.')\n      const r = o[15 & s]\n      if (!r) throw new Error('Unrecognized array type.')\n      const [l] = new Uint16Array(t, 2, 1)\n      const [h] = new Uint32Array(t, 4, 1)\n      return new n(h, l, r, t)\n    }\n    constructor(t, e = 64, s = Float64Array, i) {\n      if (isNaN(t) || t < 0) throw new Error('Unpexpected numItems value: '+t)\n      ;(this.numItems = +t),\n        (this.nodeSize = Math.min(Math.max(+e, 2), 65535)),\n        (this.ArrayType = s),\n        (this.IndexArrayType = t < 65536 ? Uint16Array : Uint32Array)\n      const r = o.indexOf(this.ArrayType)\n      const n = 2 * t * this.ArrayType.BYTES_PER_ELEMENT\n      const l = t * this.IndexArrayType.BYTES_PER_ELEMENT\n      const h = (8 - (l % 8)) % 8\n      if (r < 0) throw new Error('Unexpected typed array class:'+s)\n      i && i instanceof ArrayBuffer\n        ? ((this.data = i),\n          (this.ids = new this.IndexArrayType(this.data, 8, t)),\n          (this.coords = new this.ArrayType(this.data, 8 + l + h, 2 * t)),\n          (this._pos = 2 * t),\n          (this._finished = !0))\n        : ((this.data = new ArrayBuffer(8 + n + l + h)),\n          (this.ids = new this.IndexArrayType(this.data, 8, t)),\n          (this.coords = new this.ArrayType(this.data, 8 + l + h, 2 * t)),\n          (this._pos = 0),\n          (this._finished = !1),\n          new Uint8Array(this.data, 0, 2).set([219, 16 + r]),\n          (new Uint16Array(this.data, 2, 1)[0] = e),\n          (new Uint32Array(this.data, 4, 1)[0] = t))\n    }\n    add(t, e) {\n      const s = this._pos >> 1\n      return (this.ids[s] = s), (this.coords[this._pos++] = t), (this.coords[this._pos++] = e), s\n    }\n    finish() {\n      const t = this._pos >> 1\n      if (t !== this.numItems) throw new Error('Added '+t+' items when expected '+this.numItems)\n      return l(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0), (this._finished = !0), this\n    }\n    range(t, e, s, i) {\n      if (!this._finished) throw new Error('Data not yet indexed - call index.finish().')\n      const { ids: r, coords: o, nodeSize: n } = this\n      const l = [0, r.length - 1, 0]\n      const h = []\n      for (; l.length; ) {\n        const a = l.pop() || 0\n        const u = l.pop() || 0\n        const c = l.pop() || 0\n        if (u - c <= n) {\n          for (let n = c; n <= u; n++) {\n            const l = o[2 * n]\n            const a = o[2 * n + 1]\n            l >= t && l <= s && a >= e && a <= i && h.push(r[n])\n          }\n          continue\n        }\n        const p = (c + u) >> 1\n        const g = o[2 * p]\n        const d = o[2 * p + 1]\n        g >= t && g <= s && d >= e && d <= i && h.push(r[p]),\n          (a === 0 ? t <= g : e <= d) && (l.push(c), l.push(p - 1), l.push(1 - a)),\n          (a === 0 ? s >= g : i >= d) && (l.push(p + 1), l.push(u), l.push(1 - a))\n      }\n      return h\n    }\n    within(t, e, s) {\n      if (!this._finished) throw new Error('Data not yet indexed - call index.finish().')\n      const { ids: i, coords: r, nodeSize: o } = this\n      const n = [0, i.length - 1, 0]\n      const l = []\n      const h = s * s\n      for (; n.length; ) {\n        const a = n.pop() || 0\n        const u = n.pop() || 0\n        const p = n.pop() || 0\n        if (u - p <= o) {\n          for (let s = p; s <= u; s++) c(r[2 * s], r[2 * s + 1], t, e) <= h && l.push(i[s])\n          continue\n        }\n        const g = (p + u) >> 1\n        const d = r[2 * g]\n        const y = r[2 * g + 1]\n        c(d, y, t, e) <= h && l.push(i[g]),\n          (a === 0 ? t - s <= d : e - s <= y) && (n.push(p), n.push(g - 1), n.push(1 - a)),\n          (a === 0 ? t + s >= d : e + s >= y) && (n.push(g + 1), n.push(u), n.push(1 - a))\n      }\n      return l\n    }\n  }\n  function l(t, e, s, i, r, o) {\n    if (r - i <= s) return\n    const n = (i + r) >> 1\n    h(t, e, n, i, r, o), l(t, e, s, i, n - 1, 1 - o), l(t, e, s, n + 1, r, 1 - o)\n  }\n  function h(t, e, s, i, r, o) {\n    for (; r > i; ) {\n      if (r - i > 600) {\n        const n = r - i + 1\n        const l = s - i + 1\n        const a = Math.log(n)\n        const u = 0.5 * Math.exp((2 * a) / 3)\n        const c = 0.5 * Math.sqrt((a * u * (n - u)) / n) * (l - n / 2 < 0 ? -1 : 1)\n        h(t, e, s, Math.max(i, Math.floor(s - (l * u) / n + c)), Math.min(r, Math.floor(s + ((n - l) * u) / n + c)), o)\n      }\n      const n = e[2 * s + o]\n      let l = i\n      let u = r\n      for (a(t, e, i, s), e[2 * r + o] > n && a(t, e, i, r); l < u; ) {\n        for (a(t, e, l, u), l++, u--; e[2 * l + o] < n; ) l++\n        for (; e[2 * u + o] > n; ) u--\n      }\n      e[2 * i + o] === n ? a(t, e, i, u) : (u++, a(t, e, u, r)), u <= s && (i = u + 1), s <= u && (r = u - 1)\n    }\n  }\n  function a(t, e, s, i) {\n    u(t, s, i), u(e, 2 * s, 2 * i), u(e, 2 * s + 1, 2 * i + 1)\n  }\n  function u(t, e, s) {\n    const i = t[e]\n    ;(t[e] = t[s]), (t[s] = i)\n  }\n  function c(t, e, s, i) {\n    const r = t - s\n    const o = e - i\n    return r * r + o * o\n  }\n  function p(t) {\n    return !isNaN(t) && t !== null && !Array.isArray(t)\n  }\n  function g(t, e, s) {\n    if (t !== null) {\n      for (\n        var i, r, o, n, l, h, a, u, c = 0, p = 0, d = t.type, y = d === 'FeatureCollection', m = d === 'Feature', f = y ? t.features.length : 1, w = 0;\n        w < f;\n        w++\n      ) {\n        l = (u = !!(a = y ? t.features[w].geometry : m ? t.geometry : t) && a.type === 'GeometryCollection') ? a.geometries.length : 1\n        for (let _ = 0; _ < l; _++) {\n          let E = 0\n          let O = 0\n          if ((n = u ? a.geometries[_] : a) !== null) {\n            h = n.coordinates\n            let M = n.type\n            switch (((c = !s || (M !== 'Polygon' && M !== 'MultiPolygon') ? 0 : 1), M)) {\n              case null:\n                break\n              case 'Point':\n                if (!1 === e(h, p, w, E, O)) return !1\n                p++, E++\n                break\n              case 'LineString':\n              case 'MultiPoint':\n                for (i = 0; i < h.length; i++) {\n                  if (!1 === e(h[i], p, w, E, O)) return !1\n                  p++, M === 'MultiPoint' && E++\n                }\n                M === 'LineString' && E++\n                break\n              case 'Polygon':\n              case 'MultiLineString':\n                for (i = 0; i < h.length; i++) {\n                  for (r = 0; r < h[i].length - c; r++) {\n                    if (!1 === e(h[i][r], p, w, E, O)) return !1\n                    p++\n                  }\n                  M === 'MultiLineString' && E++, M === 'Polygon' && O++\n                }\n                M === 'Polygon' && E++\n                break\n              case 'MultiPolygon':\n                for (i = 0; i < h.length; i++) {\n                  for (O = 0, r = 0; r < h[i].length; r++) {\n                    for (o = 0; o < h[i][r].length - c; o++) {\n                      if (!1 === e(h[i][r][o], p, w, E, O)) return !1\n                      p++\n                    }\n                    O++\n                  }\n                  E++\n                }\n                break\n              case 'GeometryCollection':\n                for (i = 0; i < n.geometries.length; i++) {\n                  if (!1 === g(n.geometries[i], e, s)) return !1\n                }\n                break\n              default:\n                throw new Error('Unknown Geometry Type')\n            }\n          }\n        }\n      }\n    }\n  }\n  function d(t) {\n    let e = [1 / 0, 1 / 0, -1 / 0, -1 / 0]\n    return (\n      g(t, function (t) {\n        e[0] > t[0] && (e[0] = t[0]), e[1] > t[1] && (e[1] = t[1]), e[2] < t[0] && (e[2] = t[0]), e[3] < t[1] && (e[3] = t[1])\n      }),\n      e\n    )\n  }\n  function y(t, e, s) {\n    if ((void 0 === s && (s = {}), !t)) throw new Error('point is required')\n    if (!e) throw new Error('polygon is required')\n    let i\n    let r = (function (t) {\n      if (!t) throw new Error('coord is required')\n      if (!Array.isArray(t)) {\n        if (t.type === 'Feature' && t.geometry !== null && t.geometry.type === 'Point') {\n          return t.geometry.coordinates\n        }\n        if (t.type === 'Point') return t.coordinates\n      }\n      if (Array.isArray(t) && t.length >= 2 && !Array.isArray(t[0]) && !Array.isArray(t[1])) return t\n      throw new Error('coord must be GeoJSON Point or an Array of numbers')\n    })(t)\n    let o = (i = e).type === 'Feature' ? i.geometry : i\n    let n = o.type\n    let l = e.bbox\n    let h = o.coordinates\n    if (\n      l &&\n      !1 ===\n        (function (t, e) {\n          return e[0] <= t[0] && e[1] <= t[1] && e[2] >= t[0] && e[3] >= t[1]\n        })(r, l)\n    )\n      return !1\n    n === 'Polygon' && (h = [h])\n    for (var a = !1, u = 0; u < h.length && !a; u++) {\n      if (m(r, h[u][0], s.ignoreBoundary)) {\n        for (var c = !1, p = 1; p < h[u].length && !c; ) m(r, h[u][p], !s.ignoreBoundary) && (c = !0), p++\n        c || (a = !0)\n      }\n    }\n    return a\n  }\n  function m(t, e, s) {\n    let i = !1\n    e[0][0] === e[e.length - 1][0] && e[0][1] === e[e.length - 1][1] && (e = e.slice(0, e.length - 1))\n    for (let r = 0, o = e.length - 1; r < e.length; o = r++) {\n      let n = e[r][0]\n      let l = e[r][1]\n      let h = e[o][0]\n      let a = e[o][1]\n      if (t[1] * (n - h) + l * (h - t[0]) + a * (t[0] - n) == 0 && (n - t[0]) * (h - t[0]) <= 0 && (l - t[1]) * (a - t[1]) <= 0) return !s\n      l > t[1] != a > t[1] && t[0] < ((h - n) * (t[1] - l)) / (a - l) + n && (i = !i)\n    }\n    return i\n  }\n  function f(t, e) {\n    void 0 === e && (e = {})\n    let s = 0\n    let i = 0\n    let r = 0\n    return (\n      g(\n        t,\n        function (t) {\n          ;(s += t[0]), (i += t[1]), r++\n        },\n        !0\n      ),\n      (function (t, e, s) {\n        if ((void 0 === s && (s = {}), !t)) throw new Error('coordinates is required')\n        if (!Array.isArray(t)) throw new Error('coordinates must be an Array')\n        if (t.length < 2) throw new Error('coordinates must be at least 2 numbers long')\n        if (!p(t[0]) || !p(t[1])) throw new Error('coordinates must contain numbers')\n        return (function (t, e, s) {\n          void 0 === s && (s = {})\n          let i = {\n            type: 'Feature'\n          }\n          return (s.id === 0 || s.id) && (i.id = s.id), s.bbox && (i.bbox = s.bbox), (i.properties = e || {}), (i.geometry = t), i\n        })(\n          {\n            type: 'Point',\n            coordinates: t\n          },\n          e,\n          s\n        )\n      })([s / r, i / r], e.properties)\n    )\n  }\n  d.default = d\n  const w = (t, e, s) => {\n    let i\n    let r\n    let o\n    let n = null\n    let l = 0\n    s || (s = {})\n    const h = function () {\n      ;(l = !1 === s.leading ? 0 : Date.now()), (n = null), (o = t.apply(r, i)), n || (r = i = null)\n    }\n    return function () {\n      const a = Date.now()\n      l || !1 !== s.leading || (l = a)\n      const u = e - (a - l)\n      return (\n        (r = this),\n        (i = arguments),\n        u <= 0 || u > e\n          ? (n && (clearTimeout(n), (n = null)), (l = a), (o = t.apply(r, i)), n || (r = i = null))\n          : n || !1 === s.trailing || (n = setTimeout(h, u)),\n        o\n      )\n    }\n  }\n  const _ = Math.fround || ((E = new Float32Array(1)), (t) => ((E[0] = +t), E[0]))\n  let E\n  const O = (t, e) =>\n    t.reduce((t, s, i) => {\n      let r = e(s)\n      ;(r = r == null || r === '' ? 'undefined' : r), t[r] || (t[r] = [])\n      const o = Object.assign({}, s)\n      return (o.id = i), t[r].push(o), t\n    }, {})\n  const M = (t) => ({\n    fence: !0,\n    bbox: d(t),\n    center: L(t)\n  })\n  const T = (t, e) => {\n    if (e) {\n      return d({\n        type: 'FeatureCollection',\n        features: [\n          {\n            type: 'Feature',\n            properties: {},\n            geometry: {\n              type: 'Polygon',\n              coordinates: [t]\n            }\n          }\n        ]\n      })\n    }\n    return d({\n      type: 'FeatureCollection',\n      features: t\n    })\n  }\n  const L = (t) => f(t).geometry.coordinates\n  const v = (t) => {\n    if (!t || !Array.isArray(t) || t.length < 2) return []\n    const e = [t[0], t[1]]\n    for (let s = 2; s < t.length - 1; s += 2) {\n      t[s] !== e[s - 2] && t[s + 1] !== e[s - 1] && e.push(t[s], t[s + 1])\n    }\n    return e\n  }\n  const x = (t) => t / 360 + 0.5\n  const b = (t) => {\n    const e = Math.sin((t * Math.PI) / 180)\n    const s = 0.5 - (0.25 * Math.log((1 + e) / (1 - e))) / Math.PI\n    return s < 0 ? 0 : s > 1 ? 1 : s\n  }\n  class F {\n    constructor() {}\n  }\n  let C\n  !(function (t) {\n    ;(t[(t.NONE = 0)] = 'NONE'), (t[(t.INNER = 1)] = 'INNER'), (t[(t.OUT = 2)] = 'OUT'), (t[(t.ALL = 3)] = 'ALL')\n  })(C || (C = {}))\n  class S {\n    constructor(t, s = !1) {\n      ;(this.trees = {}),\n        (this.nodeSize = 64),\n        (this.isSort = !0),\n        (this.splitChar = '*.*'),\n        (this.isWeight = !1),\n        (this.OFFSET_ZOOM = 2),\n        (this.OFFSET_ID = 3),\n        (this.OFFSET_PARENT = 4),\n        (this.OFFSET_NUM = 5),\n        (this.OFFSET_PROP = 6),\n        (this.mapping = new Map()),\n        (this.geo_refs = new Map()),\n        (this.key_refs = new Map()),\n        (this.cluster_geo_refs = new Map()),\n        (this.own = t),\n        (this.showLog = s),\n        (this.reduceType = this.isClusterReduce()),\n        (this.stride = this.reduceType !== C.NONE ? 7 : 6),\n        this.isWeight &&\n          ((this.innerReduce = (t, e) => {\n            let s\n            t.weight += (s = e == null ? void 0 : e.weight) !== null && void 0 !== s ? s : 1\n          }),\n          (this.innerMap = (t) => {\n            let e\n            return {\n              weight: t ? ((e = t[this.weightKey]) !== null && void 0 !== e ? e : 1) : null\n            }\n          })),\n        this.createZoomMapping(),\n        this.own.on(e.DESTROY, () => {\n          this.reset(), this.mapping.clear()\n        })\n    }\n    isClusterReduce() {\n      const t = this.own.getOptions().clusterPointWeight\n      return t\n        ? ((this.isWeight = !0), (this.weightKey = t), this.own.getOptions().clusterReduce ? C.ALL : C.INNER)\n        : this.own.getOptions().clusterReduce\n          ? C.OUT\n          : C.NONE\n    }\n    createZoomMapping() {\n      const t = this.own.getOptions().clusterType\n      t &&\n        t.length !== 0 &&\n        (t.forEach((t) => {\n          let [e, i, r, o, n] = t\n          if (((i = i != null ? i : this.own.getOptions().clusterMaxZoom), r === s.GEO_FENCE || r === s.ATTR_REF))\n            this.mapping.set(e, [n != null ? n : i, r, o])\n          else if (n) this.mapping.set(e, [n, s.DIS_PIXEL, o])\n          else {\n            for (let l = e; l <= i; l++) this.mapping.set(l, [l, s.DIS_PIXEL, o])\n          }\n        }),\n        this.showLog && console.log('this.mapping', this.mapping))\n    }\n    getClusterType(t) {\n      let e\n      let i = s.DIS_PIXEL\n      for (const [r, o] of [...this.mapping.entries()].reverse()) {\n        if (r <= t) {\n          ;(i = o[1]), (e = i === s.ATTR_REF && o[2] instanceof Array ? o[2][o[2].length - 1] : o[2])\n          break\n        }\n      }\n      return {\n        type: i,\n        name: e\n      }\n    }\n    getClusterZoom(t) {\n      let e = this._limitZoom(t)\n      for (const [s] of [...this.mapping.entries()].reverse()) {\n        if (s <= t) {\n          e = s\n          break\n        }\n      }\n      return e\n    }\n    getClusterTree(t) {\n      const e = this.getClusterZoom(t)\n      return this.trees[e]\n    }\n    createClusters(t) {\n      this.reset(), (this.points = t)\n      const { clusterMinZoom: e = 3, clusterMaxZoom: i = 21 } = this.own.getOptions()\n      const r = 'prepare ' + t.length + ' points'\n      this.showLog && console.time(r)\n      const o = []\n      for (let t = 0; t < this.points.length; t++) {\n        const e = this.points[t]\n        if (!e.geometry) continue\n        const [s, i] = e.geometry.coordinates\n        const r = _(s)\n        const n = _(i)\n        o.push(r, n, 1 / 0, t, -1, 1), this.reduceType !== C.NONE && o.push(-1)\n      }\n      let n = (this.trees[i + 1] = this._createTree(new Float32Array(o)))\n      for (let t = i; t >= e; t--) {\n        const e = +Date.now()\n        const i = this.getClusterZoom(t)\n        if (this.mapping.has(i)) {\n          if (this.trees[i]) continue\n          let t\n          const [e, r, o] = this.mapping.get(i)\n          switch (r) {\n            case s.GEO_FENCE:\n              t = this._fence_cluster(e, o)\n              break\n            case s.ATTR_REF:\n              t = this._attribute_cluster(e, o)\n              break\n            default:\n              t = this._distance_cluster(n, e)\n          }\n          n = this.trees[i] = this._createTree(t)\n        } else n = this.trees[i] = this._createTree(this._distance_cluster(n, i))\n        this.showLog && console.log('z%d: %d clusters in %dms', t, n.numItems, +Date.now() - e)\n      }\n      this.showLog && console.timeEnd(r)\n    }\n    _createTree(t) {\n      const e = new n((t.length / this.stride) | 0, this.nodeSize, Float32Array)\n      for (let s = 0; s < t.length; s += this.stride) e.add(x(t[s]), b(t[s + 1]))\n      return e.finish(), (e.data = t), e\n    }\n    _attribute_cluster(t, e) {\n      const i = O(this.points, (t) => {\n        if (!t.properties) return null\n        let i = null\n        if (\n          (e instanceof Array\n            ? e.forEach((e) => {\n                let s\n                ;((s = t.properties) === null || void 0 === s ? void 0 : s.hasOwnProperty(e)) &&\n                  (i === null ? (i = t.properties[e]) : (i += this.splitChar + t.properties[e]))\n              })\n            : (i = t.properties[e]),\n          this.own.getOptions().clusterDictionary && i && !this.geo_refs.has(i))\n        ) {\n          const t = this.own.getOptions().clusterDictionary(s.ATTR_REF, i)\n          t && t.point && this.geo_refs.set(i, t)\n        }\n        return i\n      })\n      this.showLog && console.log('attribute_cluster', t, i)\n      return this._match_cluster(s.ATTR_REF, i, t)\n    }\n    _fence_cluster(t, e) {\n      const i = new Map()\n      if (this.own.getOptions().clusterDictionary) {\n        let t = e\n        t instanceof Array || (t = [t]),\n          t.forEach((t) => {\n            if (this.geo_refs.has(t)) i.set(t, this.geo_refs.get(t))\n            else {\n              this.showLog && console.log('fence_cluster_key', t)\n              const e = this.own.getOptions().clusterDictionary(s.GEO_FENCE, t)\n              e && e.region && (e.point || (e.point = L(e.region)), this.geo_refs.set(t, e), i.set(t, e))\n            }\n          })\n      }\n      const r = O(this.points, (t) =>\n        ((t, e, s) => {\n          let i = null\n          for (const [r, o] of t) {\n            const t = s(o)\n            const n = y(e, t)\n            if ((console.log(n, e, t), n)) {\n              i = r\n              break\n            }\n          }\n          return i\n        })(i, t, (t) => ({\n          type: 'Feature',\n          geometry: {\n            type: 'Polygon',\n            coordinates: [t.region]\n          }\n        }))\n      )\n      this.showLog && console.log('fence_cluster', r)\n      return this._match_cluster(s.GEO_FENCE, r, t)\n    }\n    _match_cluster(t, e, i) {\n      const r = []\n      const { clusterMinPoints: o = 3, clusterReduce: n } = this.own.getOptions()\n      for (const l in e) {\n        if (e.hasOwnProperty(l)) {\n          const h = e[l]\n          if (l === 'undefined' || h.length < o) {\n            h.forEach((t) => {\n              let e\n              const [s, i] = t.geometry.coordinates\n              const o = s\n              const n = i\n              r.push(o, n, 1 / 0, +((e = t.id) !== null && void 0 !== e ? e : 0), -1, 1), this.reduceType !== C.NONE && r.push(-1)\n            })\n          } else {\n            let e\n            let a = -1\n            h.forEach((t) => {\n              if (this.reduceType !== C.NONE) {\n                let s = {}\n                if ((this.isWeight && (s = this.innerMap(t.properties)), n)) {\n                  const e = this.own.getOptions().clusterMap(t.properties)\n                  Object.assign(s, e)\n                }\n                e\n                  ? (this.isWeight && this.innerReduce(e, Object.assign({}, s)), n && n(e, Object.assign({}, s)))\n                  : ((e = Object.assign({}, s)), (a = this.clusterProps.length), this.clusterProps.push(e))\n              }\n            })\n            let u = (h[0].id << 5) + (i + 1) + this.points.length\n            const c = l.split(this.splitChar)\n            if ((this.key_refs.set(u, c[c.length - 1]), this.geo_refs.has(l))) {\n              const e = this.geo_refs.get(l)\n              const i = e.point\n              r.push(i[0], i[1], 1 / 0, u, -1, h.length),\n                t === s.GEO_FENCE\n                  ? this.cluster_geo_refs.set(u, {\n                      bbox: T(e.region, !0)\n                    })\n                  : this.cluster_geo_refs.set(u, {\n                      bbox: T(h, !1)\n                    })\n            } else {\n              const {\n                fence: t,\n                bbox: e,\n                center: s\n              } = M({\n                type: 'FeatureCollection',\n                features: h\n              })\n              v(e).length <= 2 || e[0] === 1 / 0 || !t\n                ? (o > 1 && (u = h[0].id), r.push(s[0], s[1], 1 / 0, u, -1, 1))\n                : r.push(s[0], s[1], 1 / 0, u, -1, h.length),\n                this.cluster_geo_refs.set(u, {\n                  bbox: e\n                })\n            }\n            this.reduceType !== C.NONE && r.push(a)\n          }\n        }\n      }\n      return r\n    }\n    _distance_cluster(t, e) {\n      let s, i, r, o, n, l\n      const { clusterRadius: h = 60, tileSize: a = 256, clusterMinPoints: u = 3, clusterReduce: c } = this.own.getOptions()\n      const p = h / (a * Math.pow(2, e - 1))\n      const g = t.data\n      const d = []\n      const y = this.stride\n      for (let h = 0; h < g.length; h += y) {\n        if (g[h + this.OFFSET_ZOOM] <= e) continue\n        g[h + this.OFFSET_ZOOM] = e\n        const a = g[h]\n        const m = g[h + 1]\n        const f = t.within(x(g[h]), b(g[h + 1]), p)\n        const w = g[h + this.OFFSET_NUM]\n        let _ = w\n        const E =\n          this.isWeight && (i = (s = this.clusterProps[g[h + this.OFFSET_PROP]]) === null || void 0 === s ? void 0 : s.weight) !== null && void 0 !== i ? i : 1\n        let O = E\n        for (const t of f) {\n          const s = t * y\n          g[s + this.OFFSET_ZOOM] > e &&\n            ((_ += g[s + this.OFFSET_NUM]),\n            (O +=\n              this.isWeight && (o = (r = this.clusterProps[g[s + this.OFFSET_PROP]]) === null || void 0 === r ? void 0 : r.weight) !== null && void 0 !== o\n                ? o\n                : 1))\n        }\n        if (_ > w && _ >= u) {\n          let t\n          let s = a * (this.isWeight ? E : w)\n          let i = m * (this.isWeight ? E : w)\n          let r = -1\n          const o = [[a, m]]\n          const u = ((h / y) << 5) + (e + 1) + this.points.length\n          for (const a of f) {\n            const p = a * y\n            if (g[p + this.OFFSET_ZOOM] <= e) continue\n            g[p + this.OFFSET_ZOOM] = e\n            const d = g[p + this.OFFSET_NUM]\n            const m =\n              this.isWeight && (l = (n = this.clusterProps[g[p + this.OFFSET_PROP]]) === null || void 0 === n ? void 0 : n.weight) !== null && void 0 !== l\n                ? l\n                : 1\n            if (\n              ((s += g[p] * (this.isWeight ? m : d)),\n              (i += g[p + 1] * (this.isWeight ? m : d)),\n              o.push([g[p], g[p + 1]]),\n              (g[p + this.OFFSET_PARENT] = u),\n              this.reduceType !== C.NONE)\n            ) {\n              t || ((t = this._map(g, h, !0)), (r = this.clusterProps.length), this.clusterProps.push(t))\n              const e = this._map(g, p)\n              this.isWeight && this.innerReduce(t, e), c && c(t, e)\n            }\n          }\n          ;(g[h + this.OFFSET_PARENT] = u),\n            this.cluster_geo_refs.set(u, {\n              bbox: T(o, !0)\n            }),\n            this.isWeight ? d.push(s / O, i / O, 1 / 0, u, -1, _) : d.push(s / _, i / _, 1 / 0, u, -1, _),\n            this.reduceType !== C.NONE && d.push(r)\n        } else {\n          for (let t = 0; t < y; t++) d.push(g[h + t])\n          if (_ > 1) {\n            for (const t of f) {\n              const s = t * y\n              if (!(g[s + this.OFFSET_ZOOM] <= e)) {\n                g[s + this.OFFSET_ZOOM] = e\n                for (let t = 0; t < y; t++) d.push(g[s + t])\n              }\n            }\n          }\n        }\n      }\n      return d\n    }\n    _getOriginId(t) {\n      return (t - this.points.length) >> 5\n    }\n    _getOriginZoom(t) {\n      return (t - this.points.length) % 32\n    }\n    _map(t, e, s) {\n      if (t[e + this.OFFSET_NUM] > 1) {\n        const i = this.clusterProps[t[e + this.OFFSET_PROP]]\n        return s ? Object.assign({}, i) : i\n      }\n      const i = this.points[t[e + this.OFFSET_ID]].properties\n      let r = {}\n      if ((this.isWeight && (r = this.innerMap(i)), this.own.getOptions().clusterReduce)) {\n        const t = this.own.getOptions().clusterMap(i)\n        Object.assign(r, t)\n      }\n      return s && r === i ? Object.assign({}, r) : r\n    }\n    _limitZoom(t) {\n      let e, s\n      const i = this.own.getOptions()\n      return Math.max(\n        (e = i.clusterMinZoom) !== null && void 0 !== e ? e : 3,\n        Math.min(Math.floor(+t), ((s = i.clusterMaxZoom) !== null && void 0 !== s ? s : 21) + 1)\n      )\n    }\n    getClusters(t, e) {\n      if (this.isIllegal(t)) return [[], []]\n      let i = ((((e[0] + 180) % 360) + 360) % 360) - 180\n      const r = Math.max(-90, Math.min(90, e[1]))\n      let o = e[2] === 180 ? 180 : ((((e[2] + 180) % 360) + 360) % 360) - 180\n      const n = Math.max(-90, Math.min(90, e[3]))\n      if (e[2] - e[0] >= 360) (i = -180), (o = 180)\n      else if (i > o) {\n        const e = this.getClusters(t, [i, r, 180, n])\n        const s = this.getClusters(t, [-180, r, o, n])\n        return [\n          [...e[0], ...s[0]],\n          [...e[1], ...s[1]]\n        ]\n      }\n      const l = this.getClusterTree(t)\n      if (!l) return [[], []]\n      const { type: h, name: a } = this.getClusterType(t)\n      const u = l.range(x(i), b(n), x(o), b(r))\n      const c = l.data\n      const p = []\n      const g = []\n      this.showLog && console.log('getClusters', u)\n      for (const t of u) {\n        const e = this.stride * t\n        if (c[e + this.OFFSET_NUM] >= this.own.getOptions().clusterMinPoints) {\n          const i = this.getClusterJSON(c, e, this.clusterProps)\n          i.properties || (i.properties = {}),\n            (i.properties.clusterIndex = t),\n            (i.properties.allCount = this.points.length),\n            (i.properties.type = h),\n            (h !== s.GEO_FENCE && h !== s.ATTR_REF) ||\n              (this.key_refs.has(c[e + this.OFFSET_ID]) &&\n                ((i.properties.belongKey = a), (i.properties.belongValue = this.key_refs.get(c[e + this.OFFSET_ID])))),\n            p.push(i)\n        } else {\n          const t = c[e + this.OFFSET_ID]\n          const s = this.points[t]\n          ;(s.id = t),\n            s.properties\n              ? (s.properties.clusterId = t)\n              : (s.properties = {\n                  clusterId: t\n                }),\n            s.properties\n              ? (s.properties.allCount = this.points.length)\n              : (s.properties = {\n                  allCount: this.points.length\n                }),\n            g.push(s)\n        }\n      }\n      return (\n        this.isSort &&\n          p.sort((t, e) => {\n            let s, i\n            return ((s = t.properties) === null || void 0 === s ? void 0 : s.pointCount) - ((i = e.properties) === null || void 0 === i ? void 0 : i.pointCount)\n          }),\n        [g, p]\n      )\n    }\n    getElementById(t, e) {\n      const i = new F()\n      i.id = t\n      const r = this._getOriginZoom(t) - 1\n      const { type: o, name: n } = this.getClusterType(r)\n      if (((i.type = o), t <= this.points.length)) {\n        ;(i.isCluster = !1), (i.properties = this.points[t].properties), (i.latLng = this.points[t].geometry.coordinates)\n      } else {\n        i.isCluster = !0\n        const l = this.getClusterTree(r)\n        const h = l.data\n        if (l) {\n          const r = e * this.stride\n          this.showLog && console.log('getElementById', h.slice(r, r + this.stride)),\n            (i.latLng = [h[r], h[r + 1]]),\n            (i.pointCount = h[r + this.OFFSET_NUM]),\n            (o !== s.GEO_FENCE && o !== s.ATTR_REF) || (this.key_refs.has(t) && ((i.belongKey = n), (i.belongValue = this.key_refs.get(t)))),\n            this.reduceType !== C.NONE && (i.reduces = this.clusterProps[h[r + this.OFFSET_PROP]])\n        }\n      }\n      return this.cluster_geo_refs.has(t) && (i.bbox = this.cluster_geo_refs.get(t).bbox), this.showLog && console.log('getElementById', i), i\n    }\n    getChildren(t) {\n      const e = this._getOriginId(t)\n      const s = this._getOriginZoom(t)\n      const i = 'No cluster with the specified id.'\n      const r = this.trees[s]\n      if (!r) throw new Error(i)\n      const o = r.data\n      if (e * this.stride >= o.length) throw new Error(i)\n      const n = []\n      if (n.length === 0) throw new Error(i)\n      return n\n    }\n    getLeaves(t) {\n      return []\n    }\n    getClusterJSON(t, e, s) {\n      return {\n        type: 'Feature',\n        id: t[e + this.OFFSET_ID],\n        properties: this.getClusterProperties(t, e, s),\n        geometry: {\n          type: 'Point',\n          coordinates: [t[e], t[e + 1]]\n        }\n      }\n    }\n    getClusterProperties(t, e, s) {\n      const i = t[e + this.OFFSET_NUM]\n      const r = i >= 1e4 ? '+' + Math.round(i / 1e3) + 'k' : i >= 1e3 ? Math.round(i / 100) / 10 + 'k' : i\n      let o = {}\n      if (this.reduceType !== C.NONE) {\n        const i = t[e + this.OFFSET_PROP]\n        o =\n          i === -1\n            ? {}\n            : Object.assign(\n                {},\n                {\n                  reduces: s[i]\n                }\n              )\n      }\n      return Object.assign(o, {\n        isCluster: !0,\n        clusterId: t[e + this.OFFSET_ID],\n        point: [t[e], t[e + 1]],\n        pointCount: i,\n        pointCountAbbrev: r\n      })\n    }\n    isIllegal(t) {\n      let e, s\n      const i = (e = this.own.getOptions().minZoom) !== null && void 0 !== e ? e : 3\n      const r = (s = this.own.getOptions().maxZoom) !== null && void 0 !== s ? s : 23\n      return t < i || t > r\n    }\n    reset() {\n      ;(this.points = []), (this.clusterProps = []), (this.trees = {}), this.geo_refs.clear(), this.key_refs.clear(), this.cluster_geo_refs.clear()\n    }\n  }\n  class I {\n    constructor(t, e, s, i) {\n      ;(this._wait = 600),\n        (this._fitViewMargin = [12, 12, 12, 12]),\n        (this.own = t),\n        (this.engine = e),\n        (this.map = s),\n        (this.showLog = i),\n        this.register(),\n        this.createLayers()\n    }\n    register() {\n      this.own.getOptions().updateRealTime\n        ? ((this._wait = this.own.getOptions().waitTime || 300),\n          this.map.addEventListener(\n            'update',\n            (this._onMapStatusChange = w(this.mapStatusChange.bind(this), this._wait, {\n              leading: !0,\n              trailing: !1\n            }))\n          ))\n        : this.map.addEventListener('mapstatusidle_inner', (this._onMapStatusChange = this.mapStatusChange.bind(this))),\n        this.map.addEventListener('destroy', () => {\n          this.own.destroy()\n        }),\n        this.own.on(e.DESTROY, () => {\n          this.destroy()\n        })\n    }\n    unregister() {\n      this.own.getOptions().updateRealTime\n        ? this.map.removeEventListener('update', this._onMapStatusChange)\n        : this.map.removeEventListener('mapstatusidle_inner', this._onMapStatusChange),\n        (this._onMapStatusChange = () => {})\n    }\n    mapStatusChange(t) {\n      const s = this.map.getZoom()\n      const i = this.map.getBounds()\n      const r = i.getSouthWest()\n      const o = i.getNorthEast()\n      this.showLog && console.log('地图状态变化', s, [r.lng, r.lat, o.lng, o.lat])\n      const n = this.engine.getClusters(s, [r.lng, r.lat, o.lng, o.lat])\n      this.own.fire(e.CHANGE, n), this.own.isRender && this.update(n)\n    }\n    update(t) {\n      this.showLog && console.log('更新数据', t), this.render(t[0], r.SINGLE), this.render(t[1], r.MULTI)\n    }\n    render(t, e) {\n      this.showLog && console.log('渲染type', e), this.showLog && console.log('渲染data', t)\n      const s = {\n        type: 'FeatureCollection',\n        features: t\n      }\n      const i = e === r.MULTI ? this.multi_layer : this.single_layer\n      i && (t.length > 0 && (i == null || i.setData(s)), t.length === 0 && (i == null || i.clearData()))\n    }\n    createLayers() {\n      let t, e\n      ;((t = this.own.getOptions().renderSingleStyle) === null || void 0 === t ? void 0 : t.type) === i.DOM\n        ? (this.single_layer = this.createLayer(r.SINGLE, i.DOM))\n        : (this.single_layer = this.createLayer(r.SINGLE, i.WEBGL)),\n        ((e = this.own.getOptions().renderClusterStyle) === null || void 0 === e ? void 0 : e.type) === i.DOM\n          ? (this.multi_layer = this.createLayer(r.MULTI, i.DOM))\n          : (this.multi_layer = this.createLayer(r.MULTI, i.WEBGL))\n    }\n    createLayer(t, s) {\n      this.showLog && console.log('创建图层', s)\n      let o\n      const n = this.own.getOptions()\n      const l = t === r.MULTI ? n.renderClusterStyle : n.renderSingleStyle\n      if (!l) return\n      if (s === i.DOM) {\n        const e = {\n          sliceRepeat: !0,\n          minZoom: this.own.getOptions().minZoom,\n          maxZoom: this.own.getOptions().maxZoom,\n          zIndex: t === r.MULTI ? 10 : 9,\n          nextTick: !0,\n          fixBottom: !0,\n          anchors: [0.5, 0.5],\n          enableDraggingMap: !0\n        }\n        Object.assign(e, l.style)\n        const s = new BMapGL.CustomHtmlLayer(l.inject, e)\n        this.map.addCustomHtmlLayer(s), (o = s)\n      } else {\n        const e = 1.2 * (n.clusterRadius || 32)\n        const s = {\n          iconObj: (t, e) => ({\n            canvas: (l == null ? void 0 : l.inject)(e),\n            id: e.clusterId\n          }),\n          sizes: [e, e / 2],\n          scale: 1,\n          userSizes: !1,\n          anchors: [0, 0],\n          width: e,\n          height: e / 2\n        }\n        Object.assign(s, l.style)\n        const i = {\n          icon: 'https://webmap0.bdimg.com/image/api/marker_red.png',\n          sizes: [8, 8],\n          anchors: [0, -1],\n          userSizes: !1,\n          width: ['match', ['get', 'type'], 0, 16, 8],\n          height: ['match', ['get', 'type'], 0, 16, 8]\n        }\n        Object.assign(i, l.style)\n        const h = new BMapGL.PointIconLayer({\n          minZoom: this.own.getOptions().minZoom,\n          maxZoom: this.own.getOptions().maxZoom,\n          zIndex: t === r.MULTI ? 10 : 9,\n          isTop: true,\n          enablePicked: !0,\n          autoSelect: !1,\n          pickWidth: 30,\n          pickHeight: 30,\n          opacity: 1,\n          isFlat: !1,\n          isFixed: !0,\n          style: t === r.MULTI ? s : i\n        })\n        this.map.addNormalLayer(h), (o = h)\n      }\n      o.addEventListener('click', (t) => {\n        if ((this.showLog && console.log('鼠标点击事件', t), t.target instanceof BMapGL.PointIconLayer && !t.value.dataItem)) return\n        const s = this.getElementByEvent(t)\n        s.bbox && Array.isArray(s.bbox) && s.bbox[0] !== 1 / 0 && this.fitView(s.bbox), this.own.fire(e.CLICK, s)\n      })\n      const h = s === i.DOM ? 'mouseover' : 'mousemove'\n      return (\n        o.addEventListener(h, (t) => {\n          if ((this.showLog && console.log('鼠标悬浮事件', t), t.target instanceof BMapGL.PointIconLayer && !t.value.dataItem)) {\n            return void (this._preMouseMove && (this.own.fire(e.MOUSE_OUT, this._preMouseMove), (this._preMouseMove = null)))\n          }\n          const s = this.getElementByEvent(t)\n          if (t.target instanceof BMapGL.PointIconLayer) {\n            return (this._preMouseMove && this._preMouseMove.id === s.id) || this.own.fire(e.MOUSE_OVER, s), void (this._preMouseMove = s)\n          }\n          this.own.fire(e.MOUSE_OVER, s)\n        }),\n        o.addEventListener('mouseout', (t) => {\n          if ((this.showLog && console.log('鼠标移开事件', t), t.target instanceof BMapGL.PointIconLayer)) {\n            return\n          }\n          const s = this.getElementByEvent(t)\n          this.own.fire(e.MOUSE_OUT, s)\n        }),\n        o\n      )\n    }\n    getElementByEvent(t) {\n      let e, s\n      if (t.target instanceof BMapGL.CustomOverlay) {\n        const i = t.target.properties || {}\n        ;(e = i.clusterId), (s = i.clusterIndex)\n      } else {\n        const i = t.value.dataItem.properties || {}\n        ;(e = i.clusterId), (s = i.clusterIndex)\n      }\n      const i = this.engine.getElementById(e, s)\n      return (i.pixel = [t.pixel.x, t.pixel.y]), (i.target = t.target), i\n    }\n    clearRender() {\n      this.showLog && console.log('清除图层'), this.update([[], []])\n    }\n    unrender() {\n      this.showLog && console.log('销毁图层'),\n        this.multi_layer instanceof BMapGL.PointIconLayer ? this.map.removeNormalLayer(this.multi_layer) : this.map.removeCustomHtmlLayer(this.multi_layer),\n        this.single_layer instanceof BMapGL.PointIconLayer ? this.map.removeNormalLayer(this.single_layer) : this.map.removeCustomHtmlLayer(this.single_layer),\n        (this.multi_layer = void 0),\n        (this.single_layer = void 0)\n    }\n    fitView(t) {\n      if ((this.showLog && console.log('fitView', t), this.own.getOptions().fitViewOnClick)) {\n        const e = this.map.getZoom()\n        const s = [new BMapGL.Point(t[0], t[1]), new BMapGL.Point(t[2], t[3])]\n        const i = {\n          margins: this._fitViewMargin,\n          enableAnimation: !0\n        }\n        this.map.setViewport(s, i),\n          setTimeout(() => {\n            e === this.map.getZoom() && this.map.setZoom(e + 1), this.mapStatusChange()\n          }, 300)\n      }\n    }\n    show() {\n      try {\n        this.single_layer &&\n          (this.single_layer instanceof BMapGL.CustomHtmlLayer && this.single_layer.show?.(),\n          this.single_layer instanceof BMapGL.PointIconLayer && this.single_layer.setVisible?.(!0))\n      } catch (e) {\n        console.log(e)\n      }\n      // this.single_layer && (this.single_layer instanceof BMapGL.CustomHtmlLayer && this.single_layer.show?.(),\n      //         this.single_layer instanceof BMapGL.PointIconLayer && this.single_layer.setVisible?.(!0)),\n      try {\n        this.multi_layer &&\n          (this.multi_layer instanceof BMapGL.CustomHtmlLayer && this.multi_layer.show(),\n          this.multi_layer instanceof BMapGL.PointIconLayer && this.multi_layer.setVisible(!0))\n      } catch (e) {\n        console.log(e)\n      }\n    }\n    hide() {\n      try {\n        this.single_layer &&\n          (this.single_layer instanceof BMapGL.CustomHtmlLayer && this.single_layer.hide?.(),\n          this.single_layer instanceof BMapGL.PointIconLayer && this.single_layer.setVisible?.(!1))\n      } catch (e) {\n        console.log(e)\n      }\n      // this.single_layer && (this.single_layer instanceof BMapGL.CustomHtmlLayer && this.single_layer.hide?.(),\n      //         this.single_layer instanceof BMapGL.PointIconLayer && this.single_layer.setVisible?.(!1)),\n      try {\n        this.multi_layer &&\n          (this.multi_layer instanceof BMapGL.CustomHtmlLayer && this.multi_layer.hide(),\n          this.multi_layer instanceof BMapGL.PointIconLayer && this.multi_layer.setVisible(!1))\n      } catch (e) {\n        console.log(e)\n      }\n    }\n    getSingleLayer() {\n      return this.single_layer\n    }\n    getClusterLayer() {\n      return this.multi_layer\n    }\n    drawMarker(t) {\n      this.map.addOverlay(new BMapGL.Marker(new BMapGL.Point(t[0], t[1])))\n    }\n    destroy() {\n      this.map && (this.unregister(), this.unrender())\n    }\n  }\n  let P = Object.freeze({\n    __proto__: null,\n    get ClusterData() {\n      return r\n    },\n    ClusterElement: F,\n    get ClusterEvent() {\n      return e\n    },\n    get ClusterRender() {\n      return i\n    },\n    get ClusterType() {\n      return s\n    },\n    View: class extends t {\n      constructor(t, e) {\n        if ((super(), (this._showLog = !1), !t)) throw new Error('map is required')\n        e && this.verifyOptions(e)\n        const s = {\n          tileSize: 256,\n          minZoom: 3,\n          maxZoom: 21,\n          clusterRadius: 30,\n          clusterMinZoom: 3,\n          clusterMaxZoom: 16,\n          clusterMinPoints: 3,\n          clusterPointWeight: void 0,\n          clusterMap: (t) => ({}),\n          clusterReduce: void 0,\n          clusterType: void 0,\n          clusterDictionary: void 0,\n          isRender: !0,\n          renderClusterStyle: {\n            type: i.DOM,\n            style: {},\n            inject: (t) => {\n              let e = Math.pow(t.pointCount / t.allCount, 0.1)\n              let s = document.createElement('div')\n              let i = 180 - 180 * e\n              let r = 'hsla(' + i + ',100%,30%,0.7)'\n              let o = 'hsla(' + i + ',100%,90%,1)'\n              let n = 'hsla(' + i + ',100%,30%,1)'\n              let l = 'hsla(' + i + ',100%,90%,1)'\n              s.style.backgroundColor = r\n              let h = Math.round(25 + 30 * Math.pow(t.pointCount / t.allCount, 1 / 6))\n              return (\n                (s.style.width = s.style.height = h + 'px'),\n                (s.style.border = 'solid 1px ' + n),\n                (s.style.borderRadius = h / 2 + 'px'),\n                (s.style.boxShadow = '0 0 5px ' + l),\n                (s.innerHTML = t.pointCount),\n                (s.style.lineHeight = h + 'px'),\n                (s.style.color = o),\n                (s.style.fontSize = '14px'),\n                (s.style.textAlign = 'center'),\n                (s.style.cursor = 'pointer'),\n                s\n              )\n            }\n          },\n          renderSingleStyle: {\n            type: i.WEBGL,\n            style: {},\n            inject: (t) => document.createElement('canvas')\n          },\n          fitViewOnClick: !0,\n          updateRealTime: !1,\n          waitTime: 300\n        }\n        ;(this.options = Object.assign(s, e)),\n          (this.engine = new S(this, this._showLog)),\n          (this.render = new I(this, this.engine, t, this._showLog)),\n          (this.isRender = this.options.isRender || !1)\n      }\n      setData(t) {\n        this._showLog && console.log('cluster options', this.options), this.engine.createClusters(t), this.redraw()\n      }\n      getSingleLayer() {\n        return this.render.getSingleLayer()\n      }\n      getClusterLayer() {\n        return this.render.getClusterLayer()\n      }\n      redraw() {\n        this.render.mapStatusChange()\n      }\n      show() {\n        this.render.show()\n      }\n      hide() {\n        this.render.hide()\n      }\n      destroy() {\n        this.fire(e.DESTROY)\n      }\n      get isRender() {\n        return this._isRender\n      }\n      set isRender(t) {\n        ;(this._isRender = t), !t && this.render.clearRender()\n      }\n      getOptions() {\n        return this.options\n      }\n      verifyOptions(t) {\n        let e, s\n        if (t.minZoom && t.minZoom < 3) {\n          throw new Error('minZoom must be greater than 3')\n        }\n        if (t.maxZoom && t.maxZoom > 23) throw new Error('maxZoom must be less than 23')\n        if (Math.max((e = t.minZoom) !== null && void 0 !== e ? e : 3, 3) > Math.min((s = t.maxZoom) !== null && void 0 !== s ? s : 23, 23)) {\n          throw new Error('minZoom must be less than maxZoom')\n        }\n        if (t.clusterMinZoom && t.clusterMinZoom < 3) {\n          throw new Error('clusterMinZoom must be greater than 3')\n        }\n        if (t.clusterMaxZoom && t.clusterMaxZoom > 23) {\n          throw new Error('clusterMaxZoom must be less than 23')\n        }\n        if (t.clusterMinZoom && t.clusterMaxZoom && t.clusterMinZoom > t.clusterMaxZoom) {\n          throw new Error('clusterMinZoom must be less than clusterMaxZoom')\n        }\n        if (t.clusterType) {\n          if (!(t.clusterType instanceof Array)) {\n            throw new Error('clusterType must be an array')\n          }\n          if (t.clusterType.length < 1) {\n            throw new Error('clusterType must be greater than 0')\n          }\n          for (let e = 0; e < t.clusterType.length; e++) {\n            if (t.clusterType[e].length < 4) {\n              throw new Error('clusterType must be greater than 4')\n            }\n            if (!t.clusterType[e][0]) {\n              throw new Error('clusterType item startZoom must not be null')\n            }\n            if (t.clusterType[e][1] && t.clusterType[e][0] > t.clusterType[e][1]) {\n              throw new Error('clusterType item endZoom must be less than starZoom')\n            }\n            if (t.clusterType[e][1] === null && e < t.clusterType.length - 1) {\n              throw new Error('clusterType item endZoom must not be null,excluding the last item endZoom')\n            }\n            if (e < t.clusterType.length - 1 && t.clusterType[e][1] !== null && t.clusterType[e][1] > t.clusterType[e + 1][0]) {\n              throw new Error('clusterType item endZoom must be less than the next startZoom')\n            }\n          }\n        }\n      }\n    },\n    pointTransformer: (t, e) => {\n      const s = []\n      return (\n        t.forEach((t) => {\n          const { point: i = null, properties: r = {} } = e(t)\n          i &&\n            s.push({\n              type: 'Feature',\n              geometry: {\n                type: 'Point',\n                coordinates: i\n              },\n              properties: r\n            })\n        }),\n        s\n      )\n    }\n  })\n  return P\n})`\n"],"names":[],"mappings":"AAAO,MAAM,OAAU,GAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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