(self.webpackChunkRemoteClient = self.webpackChunkRemoteClient || []).push([
  [2790],
  {
    82933: (e, t, r) => {
      'use strict';
      r.d(t, { Z: () => c });
      var i = r(29768),
        s = r(21972),
        o = r(15324),
        l = r(76506),
        a = r(34250),
        n = r(17533);
      r(23639),
        r(92143),
        r(31450),
        r(71552),
        r(40642),
        r(86656),
        r(22723),
        r(91055),
        r(27794),
        r(6906),
        r(50406),
        r(60991),
        r(81172),
        r(91306),
        r(76996);
      let u = class extends s.Z {
        constructor(e) {
          super(e), (this._groups = new Map());
        }
        destroy() {
          this.removeAll();
        }
        get size() {
          let e = 0;
          return (
            this._groups.forEach((t) => {
              e += t.length;
            }),
            e
          );
        }
        add(e, t) {
          if (!this._isHandle(e) && !Array.isArray(e) && !o.Z.isCollection(e)) return this;
          const r = this._getOrCreateGroup(t);
          return (
            Array.isArray(e) || o.Z.isCollection(e)
              ? e.forEach((e) => this._isHandle(e) && r.push(e))
              : r.push(e),
            this.notifyChange('size'),
            this
          );
        }
        forEach(e, t) {
          if ('function' == typeof e) this._groups.forEach((t) => t.forEach(e));
          else {
            const r = this._getGroup(e);
            r && t && r.forEach(t);
          }
        }
        has(e) {
          return this._groups.has(this._ensureGroupKey(e));
        }
        remove(e) {
          if (Array.isArray(e) || o.Z.isCollection(e)) return e.forEach(this.remove, this), this;
          if (!this.has(e)) return this;
          const t = this._getGroup(e);
          for (let e = 0; e < t.length; e++) t[e].remove();
          return this._deleteGroup(e), this.notifyChange('size'), this;
        }
        removeAll() {
          return (
            this._groups.forEach((e) => {
              for (let t = 0; t < e.length; t++) e[t].remove();
            }),
            this._groups.clear(),
            this.notifyChange('size'),
            this
          );
        }
        _isHandle(e) {
          return e && !!e.remove;
        }
        _getOrCreateGroup(e) {
          if (this.has(e)) return this._getGroup(e);
          const t = [];
          return this._groups.set(this._ensureGroupKey(e), t), t;
        }
        _getGroup(e) {
          return (0, l.a)(this._groups.get(this._ensureGroupKey(e)));
        }
        _deleteGroup(e) {
          return this._groups.delete(this._ensureGroupKey(e));
        }
        _ensureGroupKey(e) {
          return e || '_default_';
        }
      };
      (0, i._)([(0, a.Cb)({ readOnly: !0 })], u.prototype, 'size', null),
        (u = (0, i._)([(0, n.j)('esri.core.Handles')], u));
      const c = u;
    },
    82790: (e, t, r) => {
      'use strict';
      r.r(t), r.d(t, { default: () => Q });
      var i,
        s = r(29768),
        o = r(82058),
        l = r(15324),
        a = r(60991),
        n = r(82933),
        u = r(76506),
        c = r(54179),
        p = r(71552),
        d = r(50406),
        h = r(32101),
        m = r(34250),
        y = (r(91306), r(92143), r(97714)),
        f = r(17533),
        g = r(2906),
        v = r(21801),
        w = r(41617),
        x = r(3799),
        _ = r(11118),
        S = r(89440),
        M = r(62162),
        I = r(16647),
        b = r(58912),
        C = r(43352),
        L = r(74673),
        T =
          (r(21972),
          r(23639),
          r(86656),
          r(22723),
          r(91055),
          r(27794),
          r(6906),
          r(81172),
          r(31450),
          r(40642),
          r(26341),
          r(73796),
          r(60947)),
        E = r(91597),
        P = (r(86787), r(35132), r(89623), r(57251), r(53785), r(95587));
      r(92482), r(92817);
      let O = (i = class extends L.a {
        constructor(e) {
          super(e), (this.fullExtent = null), (this.id = null), (this.tileInfo = null);
        }
        clone() {
          const e = new i();
          return (
            this.hasOwnProperty('fullExtent') &&
              (e.fullExtent = this.fullExtent && this.fullExtent.clone()),
            this.hasOwnProperty('id') && (e.id = this.id),
            this.hasOwnProperty('tileInfo') &&
              (e.tileInfo = this.tileInfo && this.tileInfo.clone()),
            e
          );
        }
      });
      (0, s._)(
        [(0, m.Cb)({ type: v.Z, json: { read: { source: 'fullExtent' } } })],
        O.prototype,
        'fullExtent',
        void 0,
      ),
        (0, s._)(
          [(0, m.Cb)({ type: String, json: { read: { source: 'id' } } })],
          O.prototype,
          'id',
          void 0,
        ),
        (0, s._)(
          [(0, m.Cb)({ type: C.Z, json: { read: { source: 'tileInfo' } } })],
          O.prototype,
          'tileInfo',
          void 0,
        ),
        (O = i = (0, s._)([(0, f.j)('esri.layer.support.TileMatrixSet')], O));
      const F = O;
      var R;
      let A = (R = class extends L.a {
        constructor(e) {
          super(e),
            (this.id = null),
            (this.title = null),
            (this.description = null),
            (this.legendUrl = null);
        }
        clone() {
          const e = new R();
          return (
            this.hasOwnProperty('description') && (e.description = this.description),
            this.hasOwnProperty('id') && (e.id = this.id),
            this.hasOwnProperty('isDefault') && (e.isDefault = this.isDefault),
            this.hasOwnProperty('keywords') &&
              (e.keywords = this.keywords && this.keywords.slice()),
            this.hasOwnProperty('legendUrl') && (e.legendUrl = this.legendUrl),
            this.hasOwnProperty('title') && (e.title = this.title),
            e
          );
        }
      });
      (0, s._)([(0, m.Cb)({ json: { read: { source: 'id' } } })], A.prototype, 'id', void 0),
        (0, s._)(
          [(0, m.Cb)({ json: { read: { source: 'title' } } })],
          A.prototype,
          'title',
          void 0,
        ),
        (0, s._)(
          [(0, m.Cb)({ json: { read: { source: 'abstract' } } })],
          A.prototype,
          'description',
          void 0,
        ),
        (0, s._)(
          [(0, m.Cb)({ json: { read: { source: 'legendUrl' } } })],
          A.prototype,
          'legendUrl',
          void 0,
        ),
        (0, s._)(
          [(0, m.Cb)({ json: { read: { source: 'isDefault' } } })],
          A.prototype,
          'isDefault',
          void 0,
        ),
        (0, s._)(
          [(0, m.Cb)({ json: { read: { source: 'keywords' } } })],
          A.prototype,
          'keywords',
          void 0,
        ),
        (A = R = (0, s._)([(0, f.j)('esri.layer.support.WMTSStyle')], A));
      const V = A;
      var j;
      r(76996);
      let U = (j = class extends L.a {
        constructor(e) {
          super(e),
            (this.fullExtent = null),
            (this.imageFormats = null),
            (this.id = null),
            (this.layer = null),
            (this.styles = null),
            (this.tileMatrixSetId = null),
            (this.tileMatrixSets = null);
        }
        get description() {
          return this._get('description');
        }
        set description(e) {
          this._set('description', e);
        }
        readFullExtent(e, t) {
          return (e = t.fullExtent) ? v.Z.fromJSON(e) : null;
        }
        get imageFormat() {
          let e = this._get('imageFormat');
          return (
            e || (e = this.imageFormats && this.imageFormats.length ? this.imageFormats[0] : ''), e
          );
        }
        set imageFormat(e) {
          const t = this.imageFormats;
          e &&
          (e.indexOf('image/') > -1 || (t && -1 === t.indexOf(e))) &&
          (-1 === e.indexOf('image/') && (e = 'image/' + e), t && -1 === t.indexOf(e))
            ? console.error("The layer doesn't support the format of " + e)
            : this._set('imageFormat', e);
        }
        get styleId() {
          let e = this._get('styleId');
          return e || (e = this.styles && this.styles.length ? this.styles.getItemAt(0).id : ''), e;
        }
        set styleId(e) {
          this._set('styleId', e);
        }
        get title() {
          return this._get('title');
        }
        set title(e) {
          this._set('title', e);
        }
        get tileMatrixSet() {
          return this.tileMatrixSets
            ? this.tileMatrixSets.find((e) => e.id === this.tileMatrixSetId)
            : null;
        }
        clone() {
          const e = new j();
          return (
            this.hasOwnProperty('description') && (e.description = this.description),
            this.hasOwnProperty('imageFormats') &&
              (e.imageFormats = this.imageFormats && this.imageFormats.slice()),
            this.hasOwnProperty('imageFormat') && (e.imageFormat = this.imageFormat),
            this.hasOwnProperty('fullExtent') &&
              (e.fullExtent = this.fullExtent && this.fullExtent.clone()),
            this.hasOwnProperty('id') && (e.id = this.id),
            this.hasOwnProperty('layer') && (e.layer = this.layer),
            this.hasOwnProperty('styleId') && (e.styleId = this.styleId),
            this.hasOwnProperty('styles') && (e.styles = this.styles && this.styles.clone()),
            this.hasOwnProperty('tileMatrixSetId') && (e.tileMatrixSetId = this.tileMatrixSetId),
            this.hasOwnProperty('tileMatrixSets') &&
              (e.tileMatrixSets = this.tileMatrixSets.clone()),
            this.hasOwnProperty('title') && (e.title = this.title),
            e
          );
        }
      });
      (0, s._)([(0, m.Cb)()], U.prototype, 'description', null),
        (0, s._)([(0, m.Cb)()], U.prototype, 'fullExtent', void 0),
        (0, s._)([(0, y.r)('fullExtent', ['fullExtent'])], U.prototype, 'readFullExtent', null),
        (0, s._)([(0, m.Cb)()], U.prototype, 'imageFormat', null),
        (0, s._)(
          [(0, m.Cb)({ json: { read: { source: 'formats' } } })],
          U.prototype,
          'imageFormats',
          void 0,
        ),
        (0, s._)([(0, m.Cb)()], U.prototype, 'id', void 0),
        (0, s._)([(0, m.Cb)()], U.prototype, 'layer', void 0),
        (0, s._)([(0, m.Cb)()], U.prototype, 'styleId', null),
        (0, s._)(
          [(0, m.Cb)({ type: l.Z.ofType(V), json: { read: { source: 'styles' } } })],
          U.prototype,
          'styles',
          void 0,
        ),
        (0, s._)(
          [(0, m.Cb)({ value: null, json: { write: { ignoreOrigin: !0 } } })],
          U.prototype,
          'title',
          null,
        ),
        (0, s._)([(0, m.Cb)()], U.prototype, 'tileMatrixSetId', void 0),
        (0, s._)([(0, m.Cb)({ readOnly: !0 })], U.prototype, 'tileMatrixSet', null),
        (0, s._)(
          [(0, m.Cb)({ type: l.Z.ofType(F), json: { read: { source: 'tileMatrixSets' } } })],
          U.prototype,
          'tileMatrixSets',
          void 0,
        ),
        (U = j = (0, s._)([(0, f.j)('esri.layers.support.WMTSSublayer')], U));
      const Z = U;
      r(88762),
        r(50161),
        r(74569),
        r(84069),
        r(44567),
        r(98380),
        r(92896),
        r(22781),
        r(32422),
        r(82673),
        r(22739),
        r(20543),
        r(43022),
        r(93314),
        r(35197),
        r(38742),
        r(47842),
        r(14249),
        r(9801),
        r(53523),
        r(59465),
        r(42911),
        r(46826),
        r(45433),
        r(60217),
        r(17298),
        r(85557),
        r(34394),
        r(41864),
        r(49900),
        r(66284),
        r(33921),
        r(3482),
        r(73173),
        r(67477),
        r(78533),
        r(74653),
        r(91091),
        r(58943),
        r(56420),
        r(74742),
        r(28239);
      const N = [
        [3819, 3819],
        [3821, 3824],
        [3889, 3889],
        [3906, 3906],
        [4001, 4025],
        [4027, 4036],
        [4039, 4047],
        [4052, 4055],
        [4074, 4075],
        [4080, 4081],
        [4120, 4176],
        [4178, 4185],
        [4188, 4216],
        [4218, 4289],
        [4291, 4304],
        [4306, 4319],
        [4322, 4326],
        [4463, 4463],
        [4470, 4470],
        [4475, 4475],
        [4483, 4483],
        [4490, 4490],
        [4555, 4558],
        [4600, 4646],
        [4657, 4765],
        [4801, 4811],
        [4813, 4821],
        [4823, 4824],
        [4901, 4904],
        [5013, 5013],
        [5132, 5132],
        [5228, 5229],
        [5233, 5233],
        [5246, 5246],
        [5252, 5252],
        [5264, 5264],
        [5324, 5340],
        [5354, 5354],
        [5360, 5360],
        [5365, 5365],
        [5370, 5373],
        [5381, 5381],
        [5393, 5393],
        [5451, 5451],
        [5464, 5464],
        [5467, 5467],
        [5489, 5489],
        [5524, 5524],
        [5527, 5527],
        [5546, 5546],
        [2044, 2045],
        [2081, 2083],
        [2085, 2086],
        [2093, 2093],
        [2096, 2098],
        [2105, 2132],
        [2169, 2170],
        [2176, 2180],
        [2193, 2193],
        [2200, 2200],
        [2206, 2212],
        [2319, 2319],
        [2320, 2462],
        [2523, 2549],
        [2551, 2735],
        [2738, 2758],
        [2935, 2941],
        [2953, 2953],
        [3006, 3030],
        [3034, 3035],
        [3038, 3051],
        [3058, 3059],
        [3068, 3068],
        [3114, 3118],
        [3126, 3138],
        [3150, 3151],
        [3300, 3301],
        [3328, 3335],
        [3346, 3346],
        [3350, 3352],
        [3366, 3366],
        [3389, 3390],
        [3416, 3417],
        [3833, 3841],
        [3844, 3850],
        [3854, 3854],
        [3873, 3885],
        [3907, 3910],
        [4026, 4026],
        [4037, 4038],
        [4417, 4417],
        [4434, 4434],
        [4491, 4554],
        [4839, 4839],
        [5048, 5048],
        [5105, 5130],
        [5253, 5259],
        [5269, 5275],
        [5343, 5349],
        [5479, 5482],
        [5518, 5519],
        [5520, 5520],
        [20004, 20032],
        [20064, 20092],
        [21413, 21423],
        [21473, 21483],
        [21896, 21899],
        [22171, 22177],
        [22181, 22187],
        [22191, 22197],
        [25884, 25884],
        [27205, 27232],
        [27391, 27398],
        [27492, 27492],
        [28402, 28432],
        [28462, 28492],
        [30161, 30179],
        [30800, 30800],
        [31251, 31259],
        [31275, 31279],
        [31281, 31290],
        [31466, 31700],
      ];
      function k(e) {
        return e.nodeType === Node.ELEMENT_NODE;
      }
      function K(e, t) {
        for (let r = 0; r < t.childNodes.length; r++) {
          const i = t.childNodes[r];
          if (k(i) && i.nodeName === e) return i;
        }
        return null;
      }
      function W(e, t) {
        const r = [];
        for (let i = 0; i < t.childNodes.length; i++) {
          const s = t.childNodes[i];
          k(s) && s.nodeName === e && r.push(s);
        }
        return r;
      }
      function G(e, t) {
        const r = [];
        for (let i = 0; i < t.childNodes.length; i++) {
          const s = t.childNodes[i];
          k(s) && s.nodeName === e && r.push(s);
        }
        return r.map((e) => e.textContent);
      }
      function D(e, t) {
        return (
          e.split('>').forEach((e) => {
            t && (t = K(e, t));
          }),
          t && t.textContent
        );
      }
      function H(e, t, r, i) {
        let s;
        return (
          Array.prototype.slice.call(i.childNodes).some((i) => {
            if (i.nodeName.indexOf(e) > -1) {
              const e = K(t, i),
                o = e && e.textContent;
              if (o === r || (r.split(':') && r.split(':')[1] === o)) return (s = i), !0;
            }
            return !1;
          }),
          s
        );
      }
      function B(e, t) {
        var r;
        const i = [],
          s = null == (r = e.layerMap) ? void 0 : r.get(t);
        if (!s) return;
        const o = W('ResourceURL', s),
          l = W('Dimension', s);
        let a, n, u, c;
        return (
          l.length && ((a = D('Identifier', l[0])), (n = G('Default', l[0]) || G('Value', l[0]))),
          l.length > 1 &&
            ((u = D('Identifier', l[1])), (c = G('Default', l[1]) || G('Value', l[1]))),
          e.dimensionMap.set(t, { dimensions: n, dimensions2: c }),
          o.forEach((e) => {
            let t = e.getAttribute('template');
            if ('tile' === e.getAttribute('resourceType')) {
              if (a && n.length)
                if (t.indexOf('{' + a + '}') > -1) t = t.replace('{' + a + '}', '{dimensionValue}');
                else {
                  const e = t.toLowerCase().indexOf('{' + a.toLowerCase() + '}');
                  e > -1 &&
                    (t = t.substring(0, e) + '{dimensionValue}' + t.substring(e + a.length + 2));
                }
              if (u && c.length)
                if (t.indexOf('{' + u + '}') > -1)
                  t = t.replace('{' + u + '}', '{dimensionValue2}');
                else {
                  const e = t.toLowerCase().indexOf('{' + u.toLowerCase() + '}');
                  e > -1 &&
                    (t = t.substring(0, e) + '{dimensionValue2}' + t.substring(e + u.length + 2));
                }
              i.push({ template: t, format: e.getAttribute('format'), resourceType: 'tile' });
            }
          }),
          i
        );
      }
      function z(e) {
        return N.some(([t, r]) => e >= t && e <= r);
      }
      function q(e, t, r, i) {
        const s = D('Identifier', e),
          o = D('ScaleDenominator', e)
            .split('E')
            .map((e) => Number(e));
        let l;
        l = o.length > 1 ? o[0] * 10 ** o[1] : o[0];
        const a = J(t, l, i);
        return (l *= 1.058267716535433), { level: r, levelValue: s, scale: l, resolution: a };
      }
      function J(e, t, r) {
        let i;
        return (
          (i = T.o.hasOwnProperty(String(e))
            ? T.o.values[T.o[e]]
            : 'default028mm' === r
            ? (6370997 * Math.PI) / 180
            : (0, P.e)(e).metersPerDegree),
          (7 * t) / 25e3 / i
        );
      }
      const $ = {
          'image/png': '.png',
          'image/png8': '.png',
          'image/png24': '.png',
          'image/png32': '.png',
          'image/jpg': '.jpg',
          'image/jpeg': '.jpeg',
          'image/gif': '.gif',
          'image/bmp': '.bmp',
          'image/tiff': '.tif',
          'image/jpgpng': '',
          'image/jpegpng': '',
          'image/unknown': '',
        },
        X = new Set([
          'version',
          'service',
          'request',
          'layer',
          'style',
          'format',
          'tilematrixset',
          'tilematrix',
          'tilerow',
          'tilecol',
        ]);
      let Y = class extends (0, _.B)((0, I.R)((0, b.S)((0, S.O)((0, M.P)((0, c.M)(w.Z)))))) {
        constructor(...e) {
          super(...e),
            (this._sublayersHandles = new n.Z()),
            (this.copyright = ''),
            (this.customParameters = null),
            (this.customLayerParameters = null),
            (this.fullExtent = null),
            (this.operationalLayerType = 'WebTiledLayer'),
            (this.resourceInfo = null),
            (this.serviceMode = 'RESTful'),
            (this.sublayers = null),
            (this.type = 'wmts'),
            (this.version = '1.0.0'),
            this.watch(
              'activeLayer',
              (e, t) => {
                t && (t.layer = null), e && (e.layer = this);
              },
              !0,
            ),
            this.watch(
              'sublayers',
              (e, t) => {
                t &&
                  (t.forEach((e) => {
                    e.layer = null;
                  }),
                  this._sublayersHandles.removeAll(),
                  (this._sublayersHandles = null)),
                  e &&
                    (e.forEach((e) => {
                      e.layer = this;
                    }),
                    this._sublayersHandles || (this._sublayersHandles = new n.Z()),
                    this._sublayersHandles.add([
                      e.on('after-add', ({ item: e }) => {
                        e.layer = this;
                      }),
                      e.on('after-remove', ({ item: e }) => {
                        e.layer = null;
                      }),
                    ]));
              },
              !0,
            );
        }
        normalizeCtorArgs(e, t) {
          return 'string' == typeof e ? { url: e, ...t } : e;
        }
        load(e) {
          if ('KVP' === this.serviceMode || 'RESTful' === this.serviceMode)
            return (
              this.addResolvingPromise(
                this.loadFromPortal({ supportedTypes: ['WMTS'] }, e)
                  .catch(d.r9)
                  .then(() => this._fetchService(e))
                  .catch((e) => {
                    throw (
                      ((0, d.r9)(e),
                      new a.Z(
                        'wmtslayer:unsupported-service-data',
                        'Invalid response from the WMTS service.',
                        { error: e },
                      ))
                    );
                  }),
              ),
              Promise.resolve(this)
            );
          console.error("WMTS mode could only be 'KVP' or 'RESTful'");
        }
        get activeLayer() {
          return this._get('activeLayer');
        }
        set activeLayer(e) {
          this._set('activeLayer', e);
        }
        readActiveLayerFromService(e, t, r) {
          let i;
          return (
            this.activeLayer
              ? t.layers.some((e) => e.id === this.activeLayer.id && ((i = e), !0))
              : ((this.activeLayer = new Z()), (i = t.layers[0])),
            this.activeLayer.read(i, r),
            this.activeLayer
          );
        }
        readActiveLayerFromItemOrWebDoc(e, t) {
          const { templateUrl: r, wmtsInfo: i } = t,
            s = r ? this._getLowerCasedUrlParams(r) : null,
            o = i && i.layerIdentifier;
          let l = null;
          const a = i && i.tileMatrixSet;
          a && (Array.isArray(a) ? a.length && (l = a[0]) : (l = a));
          const n = s && s.format,
            u = s && s.style;
          return new Z({ id: o, imageFormat: n, styleId: u, tileMatrixSetId: l });
        }
        writeActiveLayer(e, t, r, i) {
          const s = this.activeLayer;
          t.templateUrl = this.getUrlTemplate(s.id, s.tileMatrixSetId, s.imageFormat, s.styleId);
          const o = (0, p.g)('tileMatrixSet.tileInfo', s);
          (t.tileInfo = o ? o.toJSON(i) : null),
            (t.wmtsInfo = {
              ...t.wmtsInfo,
              layerIdentifier: s.id,
              tileMatrixSet: s.tileMatrixSetId,
            });
        }
        readCustomParameters(e, t) {
          const r = t.wmtsInfo;
          return r ? this._mergeParams(r.customParameters, r.url) : null;
        }
        get fullExtents() {
          const e = [];
          return (
            this.activeLayer.tileMatrixSets.forEach((t) => {
              t.fullExtent && e.push(t.fullExtent);
            }),
            e
          );
        }
        readServiceMode(e, t) {
          return t.templateUrl.indexOf('?') > -1 ? 'KVP' : 'RESTful';
        }
        readSublayersFromService(e, t, r) {
          return (function (e, t) {
            return e.map((e) => {
              const r = new Z();
              return r.read(e, t), r;
            });
          })(t.layers, r);
        }
        get supportedSpatialReferences() {
          return this.activeLayer.tileMatrixSets.map((e) => e.tileInfo.spatialReference).toArray();
        }
        get title() {
          var e, t;
          return null != (e = null == (t = this.activeLayer) ? void 0 : t.title) ? e : 'Layer';
        }
        set title(e) {
          e ? this._override('title', e) : this._clearOverride('title');
        }
        get url() {
          return this._get('url');
        }
        set url(e) {
          e && '/' === e.substr(-1) ? this._set('url', e.slice(0, -1)) : this._set('url', e);
        }
        createWebTileLayer(e) {
          const t = this.getUrlTemplate(
              this.activeLayer.id,
              this.activeLayer.tileMatrixSetId,
              this.activeLayer.imageFormat,
              this.activeLayer.styleId,
            ),
            r = this._getTileMatrixSetById(e.tileMatrixSetId).tileInfo,
            i = e.fullExtent,
            s = new x.W({ layerIdentifier: e.id, tileMatrixSet: e.tileMatrixSetId, url: this.url });
          return (
            this.customLayerParameters && (s.customLayerParameters = this.customLayerParameters),
            this.customParameters && (s.customParameters = this.customParameters),
            new x.default({ fullExtent: i, urlTemplate: t, tileInfo: r, wmtsInfo: s })
          );
        }
        fetchTile(e, t, r) {
          const i = this.getTileUrl(e, t, r);
          return (0, o.default)(i, { responseType: 'image' }).then((e) => e.data);
        }
        findSublayerById(e) {
          return this.sublayers.find((t) => t.id === e);
        }
        getTileUrl(e, t, r) {
          const i = this._getTileMatrixSetById(this.activeLayer.tileMatrixSetId).tileInfo.lods[e],
            s = i ? (i.levelValue ? i.levelValue : `${i.level}`) : `${e}`;
          let o = this.resourceInfo
            ? ''
            : (function (e, t, r, i, s, o, l, a) {
                const { dimensionMap: n } = e,
                  u = B(e, t),
                  c = n.get(t).dimensions && n.get(t).dimensions[0],
                  p = n.get(t).dimensions2 && n.get(t).dimensions2[0];
                let d = '';
                if (u && u.length > 0) {
                  let e = null;
                  u.some((t) => t.format === i && ((e = t), !0)),
                    e || (e = u[l % u.length]),
                    (d = e.template
                      .replace(/\{Style\}/gi, s)
                      .replace(/\{TileMatrixSet\}/gi, r)
                      .replace(/\{TileMatrix\}/gi, o)
                      .replace(/\{TileRow\}/gi, '' + l)
                      .replace(/\{TileCol\}/gi, '' + a)
                      .replace(/\{dimensionValue\}/gi, c)
                      .replace(/\{dimensionValue2\}/gi, p));
                }
                return d;
              })(
                { dimensionMap: this.dimensionMap, layerMap: this.layerMap },
                this.activeLayer.id,
                this.activeLayer.tileMatrixSetId,
                this.activeLayer.imageFormat,
                this.activeLayer.styleId,
                s,
                t,
                r,
              );
          return (
            o ||
              (o = this.getUrlTemplate(
                this.activeLayer.id,
                this.activeLayer.tileMatrixSetId,
                this.activeLayer.imageFormat,
                this.activeLayer.styleId,
              )
                .replace(/\{level\}/gi, s)
                .replace(/\{row\}/gi, `${t}`)
                .replace(/\{col\}/gi, `${r}`)),
            (o = this._appendCustomLayerParameters(o)),
            o
          );
        }
        getUrlTemplate(e, t, r, i) {
          if (!this.resourceInfo) {
            const r = (function (e, t, r, i) {
              const { dimensionMap: s } = e,
                o = B(e, t);
              let l = '';
              if (o && o.length > 0) {
                const e = s.get(t).dimensions && s.get(t).dimensions[0],
                  a = s.get(t).dimensions2 && s.get(t).dimensions2[0];
                (l = o[0].template),
                  l.indexOf('.xxx') === l.length - 4 && (l = l.slice(0, l.length - 4)),
                  (l = l.replace(/\{Style\}/gi, i)),
                  (l = l.replace(/\{TileMatrixSet\}/gi, r)),
                  (l = l.replace(/\{TileMatrix\}/gi, '{level}')),
                  (l = l.replace(/\{TileRow\}/gi, '{row}')),
                  (l = l.replace(/\{TileCol\}/gi, '{col}')),
                  (l = l.replace(/\{dimensionValue\}/gi, e)),
                  (l = l.replace(/\{dimensionValue2\}/gi, a));
              }
              return l;
            })({ dimensionMap: this.dimensionMap, layerMap: this.layerMap }, e, t, i);
            if (r) return r;
          }
          if ('KVP' === this.serviceMode)
            return (
              this.url +
              '?SERVICE=WMTS&VERSION=' +
              this.version +
              '&REQUEST=GetTile&LAYER=' +
              e +
              '&STYLE=' +
              i +
              '&FORMAT=' +
              r +
              '&TILEMATRIXSET=' +
              t +
              '&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}'
            );
          if ('RESTful' === this.serviceMode) {
            let s = '';
            return (
              $[r.toLowerCase()] && (s = $[r.toLowerCase()]),
              this.url + e + '/' + i + '/' + t + '/{level}/{row}/{col}' + s
            );
          }
          return '';
        }
        async _fetchService(e) {
          let t;
          if (this.resourceInfo)
            'KVP' === this.resourceInfo.serviceMode &&
              (this.url += this.url.indexOf('?') > -1 ? '' : '?'),
              (t = { ssl: !1, data: this.resourceInfo });
          else
            try {
              t = await this._getCapabilities(this.serviceMode, e);
            } catch {
              const r = 'KVP' === this.serviceMode ? 'RESTful' : 'KVP';
              try {
                (t = await this._getCapabilities(r, e)), (this.serviceMode = r);
              } catch (e) {
                throw new a.Z(
                  'wmtslayer:unsupported-service-data',
                  'Services does not support RESTful or KVP service modes.',
                  { error: e },
                );
              }
            }
          var r;
          this.resourceInfo
            ? (t.data =
                ((r = t.data).layers.forEach((e) => {
                  e.tileMatrixSets.forEach((e) => {
                    const t = e.tileInfo;
                    96 !== t.dpi &&
                      (t.lods.forEach((r) => {
                        (r.scale = (96 * r.scale) / t.dpi),
                          (r.resolution = J(
                            t.spatialReference.wkid,
                            (90.71428571428571 * r.scale) / 96,
                            e.id,
                          ));
                      }),
                      (t.dpi = 96));
                  });
                }),
                r))
            : (t.data = (function (e, t) {
                var r, i;
                e = e.replace(/ows:/gi, '');
                const s = new DOMParser().parseFromString(e, 'text/xml').documentElement,
                  o = new Map(),
                  l = new Map(),
                  n = K('Contents', s);
                if (!n) throw new a.Z('wmtslayer:wmts-capabilities-xml-is-not-valid');
                const c = K('OperationsMetadata', s),
                  p = null == c ? void 0 : c.querySelector("[name='GetTile']"),
                  d = null == p ? void 0 : p.getElementsByTagName('Get'),
                  h = d && Array.prototype.slice.call(d),
                  m =
                    null !=
                      (r = (null == t || null == (i = t.url) ? void 0 : i.indexOf('https')) > -1) &&
                    r;
                let y,
                  f,
                  g = t.serviceMode,
                  w = t && t.url;
                if (
                  (h &&
                    h.length &&
                    h.some((e) => {
                      const t = K('Constraint', e);
                      return !t || H('AllowedValues', 'Value', g, t)
                        ? ((w = e.attributes[0].nodeValue), !0)
                        : (!t ||
                          H('AllowedValues', 'Value', 'RESTful', t) ||
                          H('AllowedValues', 'Value', 'REST', t)
                            ? (f = e.attributes[0].nodeValue)
                            : (t && !H('AllowedValues', 'Value', 'KVP', t)) ||
                              (y = e.attributes[0].nodeValue),
                          !1);
                    }),
                  !w)
                )
                  if (f) (w = f), (g = 'RESTful');
                  else if (y) (w = y), (g = 'KVP');
                  else {
                    const e = K('ServiceMetadataURL', s);
                    w = e && e.getAttribute('xlink:href');
                  }
                const x = w.indexOf('1.0.0/');
                -1 === x && 'RESTful' === g ? (w += '/') : x > -1 && (w = w.substring(0, x)),
                  'KVP' === g && (w += x > -1 ? '' : '?'),
                  m && (w = w.replace(/^http:/i, 'https:'));
                const _ = D('ServiceIdentification>ServiceTypeVersion', s),
                  S = D('ServiceIdentification>AccessConstraints', s),
                  M = W('Layer', n),
                  I = W('TileMatrixSet', n);
                return {
                  copyright: S,
                  layers: M.map((e) => {
                    const t = D('Identifier', e);
                    return (
                      o.set(t, e),
                      (function (e, t, r, i, s) {
                        const o = D('Abstract', t),
                          l = G('Format', t),
                          a = (function (e) {
                            const t = K('WGS84BoundingBox', e),
                              r = t ? D('LowerCorner', t).split(' ') : ['-180', '-90'],
                              i = t ? D('UpperCorner', t).split(' ') : ['180', '90'];
                            return {
                              xmin: parseFloat(r[0]),
                              ymin: parseFloat(r[1]),
                              xmax: parseFloat(i[0]),
                              ymax: parseFloat(i[1]),
                              spatialReference: { wkid: 4326 },
                            };
                          })(t),
                          n = (function (e, t) {
                            return W('Style', e).map((e) => {
                              const r = K('LegendURL', e),
                                i = K('Keywords', e),
                                s = i && G('Keyword', i);
                              let o = r && r.getAttribute('xlink:href');
                              return (
                                t && (o = o && o.replace(/^http:/i, 'https:')),
                                {
                                  abstract: D('Abstract', e),
                                  id: D('Identifier', e),
                                  isDefault: 'true' === e.getAttribute('isDefault'),
                                  keywords: s,
                                  legendUrl: o,
                                  title: D('Title', e),
                                }
                              );
                            });
                          })(t, i),
                          c = D('Title', t),
                          p = (function (e, t, r) {
                            return W('TileMatrixSetLink', t)
                              .map((e) => K('TileMatrixSet', e).textContent)
                              .map((i) =>
                                (function (e, t, r, i) {
                                  const s = G(
                                      'TileMatrix',
                                      H('TileMatrixSetLink', 'TileMatrixSet', t, r),
                                    ),
                                    o = i.find((e) => {
                                      const r = K('Identifier', e),
                                        i = r && r.textContent;
                                      return !!(i === t || (t.split(':') && t.split(':')[1] === i));
                                    }),
                                    l = (function (e) {
                                      let t = D('SupportedCRS', e);
                                      t && (t = t.toLowerCase());
                                      let r = parseInt(t.split(':').pop(), 10);
                                      (900913 !== r && 3857 !== r) || (r = 102100);
                                      const i = (function (e) {
                                        return e.includes('crs84') || e.includes('crs:84')
                                          ? 4326
                                          : e.includes('crs83') || e.includes('crs:83')
                                          ? 4269
                                          : e.includes('crs27') || e.includes('crs:27')
                                          ? 4267
                                          : null;
                                      })(t);
                                      (0, u.i)(i) && (r = i);
                                      const s = new T.Z({ wkid: r }),
                                        o = D('TopLeftCorner', K('TileMatrix', e)).split(' '),
                                        l = o[0].split('E').map((e) => Number(e)),
                                        a = o[1].split('E').map((e) => Number(e)),
                                        n = l.length > 1 ? l[0] * 10 ** l[1] : l[0],
                                        c = a.length > 1 ? a[0] * 10 ** a[1] : a[0];
                                      return t.includes('epsg') && z(r)
                                        ? new E.Z(c, n, s)
                                        : new E.Z(n, c, s);
                                    })(o),
                                    a = l.spatialReference,
                                    n = a.wkid,
                                    c = K('TileMatrix', o),
                                    p = [
                                      parseInt(D('TileWidth', c), 10),
                                      parseInt(D('TileHeight', c), 10),
                                    ],
                                    d = [];
                                  s.length
                                    ? s.forEach((e, r) => {
                                        const i = H('TileMatrix', 'Identifier', e, o);
                                        d.push(q(i, n, r, t));
                                      })
                                    : W('TileMatrix', o).forEach((e, r) => {
                                        d.push(q(e, n, r, t));
                                      });
                                  const h = (function (e, t, r, i, s) {
                                    const o = K('BoundingBox', t);
                                    let l, a, n, u, c, p;
                                    if (
                                      (o &&
                                        ((l = D('LowerCorner', o).split(' ')),
                                        (a = D('UpperCorner', o).split(' '))),
                                      l && l.length > 1 && a && a.length > 1)
                                    )
                                      (n = parseFloat(l[0])),
                                        (c = parseFloat(l[1])),
                                        (u = parseFloat(a[0])),
                                        (p = parseFloat(a[1]));
                                    else {
                                      const e = K('TileMatrix', t),
                                        o = parseFloat(D('MatrixWidth', e)),
                                        l = parseFloat(D('MatrixHeight', e));
                                      (n = r.x),
                                        (p = r.y),
                                        (u = n + o * i[0] * s.resolution),
                                        (c = p - l * i[1] * s.resolution);
                                    }
                                    return (
                                      (d = e),
                                      (h = r.spatialReference),
                                      '1.0.0' === d && z(h.wkid)
                                        ? new v.Z(c, n, p, u, r.spatialReference)
                                        : new v.Z(n, c, u, p, r.spatialReference)
                                    );
                                    var d, h;
                                  })(e, o, l, p, d[0]);
                                  return {
                                    id: t,
                                    fullExtent: h.toJSON(),
                                    tileInfo: new C.Z({
                                      dpi: 96,
                                      spatialReference: a,
                                      size: p,
                                      origin: l,
                                      lods: d,
                                    }).toJSON(),
                                  };
                                })(e, i, t, r),
                              );
                          })(s, t, r);
                        return {
                          id: e,
                          fullExtent: a,
                          description: o,
                          formats: l,
                          styles: n,
                          title: c,
                          tileMatrixSets: p,
                        };
                      })(t, e, I, m, _)
                    );
                  }),
                  tileUrl: w,
                  serviceMode: g,
                  layerMap: o,
                  dimensionMap: l,
                };
              })(t.data, { serviceMode: this.serviceMode, url: this.url })),
            t.data && this.read(t.data, { origin: 'service' });
        }
        async _getCapabilities(e, t) {
          const r = this._getCapabilitiesUrl(e);
          return await (0, o.default)(r, { ...t, responseType: 'text' });
        }
        _getTileMatrixSetById(e) {
          return this.findSublayerById(this.activeLayer.id).tileMatrixSets.find((t) => t.id === e);
        }
        _appendCustomParameters(e) {
          if (this.customParameters)
            for (const t in this.customParameters)
              e +=
                (-1 === e.indexOf('?') ? '?' : '&') +
                t +
                '=' +
                encodeURIComponent(this.customParameters[t]);
          return e;
        }
        _appendCustomLayerParameters(e) {
          if (this.customLayerParameters || this.customParameters) {
            const t = { ...(0, u.d9)(this.customParameters), ...this.customLayerParameters };
            for (const r in t)
              e += (-1 === e.indexOf('?') ? '?' : '&') + r + '=' + encodeURIComponent(t[r]);
          }
          return e;
        }
        _getCapabilitiesUrl(e) {
          let t;
          return (
            (this.url = this.url.split('?')[0]),
            'KVP' === e
              ? (t = this.url + '?request=GetCapabilities&service=WMTS&version=' + this.version)
              : 'RESTful' === e && (t = this.url + '/' + this.version + '/WMTSCapabilities.xml'),
            (t = this._appendCustomParameters(t)),
            t
          );
        }
        _getLowerCasedUrlParams(e) {
          if (!e) return null;
          const t = (0, h.mN)(e).query;
          if (!t) return null;
          const r = {};
          return (
            Object.keys(t).forEach((e) => {
              r[e.toLowerCase()] = t[e];
            }),
            r
          );
        }
        _mergeParams(e, t) {
          const r = this._getLowerCasedUrlParams(t);
          if (r) {
            const t = Object.keys(r);
            t.length &&
              ((e = e ? (0, u.d9)(e) : {}),
              t.forEach((t) => {
                e.hasOwnProperty(t) || X.has(t) || (e[t] = r[t]);
              }));
          }
          return e;
        }
      };
      (0, s._)([(0, m.Cb)()], Y.prototype, 'dimensionMap', void 0),
        (0, s._)([(0, m.Cb)()], Y.prototype, 'layerMap', void 0),
        (0, s._)(
          [
            (0, m.Cb)({
              type: Z,
              json: { origins: { 'web-document': { write: { ignoreOrigin: !0 } } } },
            }),
          ],
          Y.prototype,
          'activeLayer',
          null,
        ),
        (0, s._)(
          [(0, y.r)('service', 'activeLayer', ['layers'])],
          Y.prototype,
          'readActiveLayerFromService',
          null,
        ),
        (0, s._)(
          [(0, y.r)(['web-document', 'portal-item'], 'activeLayer', ['wmtsInfo'])],
          Y.prototype,
          'readActiveLayerFromItemOrWebDoc',
          null,
        ),
        (0, s._)(
          [
            (0, g.w)(['web-document', 'portal-item'], 'activeLayer', {
              templateUrl: { type: String },
              tileInfo: { type: C.Z },
              'wmtsInfo.layerIdentifier': { type: String },
              'wmtsInfo.tileMatrixSet': { type: String },
            }),
          ],
          Y.prototype,
          'writeActiveLayer',
          null,
        ),
        (0, s._)(
          [(0, m.Cb)({ type: String, value: '', json: { write: !0 } })],
          Y.prototype,
          'copyright',
          void 0,
        ),
        (0, s._)([(0, m.Cb)({ type: ['show', 'hide'] })], Y.prototype, 'listMode', void 0),
        (0, s._)(
          [
            (0, m.Cb)({
              json: {
                origins: {
                  'web-document': {
                    read: { source: ['wmtsInfo.customParameters', 'wmtsInfo.url'] },
                    write: { target: 'wmtsInfo.customParameters' },
                  },
                  'portal-item': {
                    read: { source: ['wmtsInfo.customParameters', 'wmtsInfo.url'] },
                    write: { target: 'wmtsInfo.customParameters' },
                  },
                },
              },
            }),
          ],
          Y.prototype,
          'customParameters',
          void 0,
        ),
        (0, s._)(
          [
            (0, y.r)('web-document', 'customParameters'),
            (0, y.r)('portal-item', 'customParameters'),
          ],
          Y.prototype,
          'readCustomParameters',
          null,
        ),
        (0, s._)(
          [
            (0, m.Cb)({
              json: {
                origins: {
                  'web-document': {
                    read: { source: 'wmtsInfo.customLayerParameters' },
                    write: { target: 'wmtsInfo.customLayerParameters' },
                  },
                  'portal-item': {
                    read: { source: 'wmtsInfo.customLayerParameters' },
                    write: { target: 'wmtsInfo.customLayerParameters' },
                  },
                },
              },
            }),
          ],
          Y.prototype,
          'customLayerParameters',
          void 0,
        ),
        (0, s._)(
          [
            (0, m.Cb)({
              type: v.Z,
              json: {
                write: { ignoreOrigin: !0 },
                origins: {
                  'web-document': { read: { source: 'fullExtent' } },
                  'portal-item': { read: { source: 'fullExtent' } },
                },
              },
            }),
          ],
          Y.prototype,
          'fullExtent',
          void 0,
        ),
        (0, s._)([(0, m.Cb)({ readOnly: !0 })], Y.prototype, 'fullExtents', null),
        (0, s._)(
          [(0, m.Cb)({ type: ['WebTiledLayer'] })],
          Y.prototype,
          'operationalLayerType',
          void 0,
        ),
        (0, s._)([(0, m.Cb)()], Y.prototype, 'resourceInfo', void 0),
        (0, s._)([(0, m.Cb)()], Y.prototype, 'serviceMode', void 0),
        (0, s._)(
          [(0, y.r)(['portal-item', 'web-document'], 'serviceMode', ['templateUrl'])],
          Y.prototype,
          'readServiceMode',
          null,
        ),
        (0, s._)([(0, m.Cb)({ type: l.Z.ofType(Z) })], Y.prototype, 'sublayers', void 0),
        (0, s._)(
          [(0, y.r)('service', 'sublayers', ['layers'])],
          Y.prototype,
          'readSublayersFromService',
          null,
        ),
        (0, s._)([(0, m.Cb)({ readOnly: !0 })], Y.prototype, 'supportedSpatialReferences', null),
        (0, s._)([(0, m.Cb)({ json: { read: { source: 'title' } } })], Y.prototype, 'title', null),
        (0, s._)(
          [(0, m.Cb)({ json: { read: !1 }, readOnly: !0, value: 'wmts' })],
          Y.prototype,
          'type',
          void 0,
        ),
        (0, s._)(
          [
            (0, m.Cb)({
              json: {
                origins: {
                  service: { read: { source: 'tileUrl' } },
                  'web-document': {
                    read: { source: 'wmtsInfo.url' },
                    write: { target: 'wmtsInfo.url' },
                  },
                  'portal-item': {
                    read: { source: 'wmtsInfo.url' },
                    write: { target: 'wmtsInfo.url' },
                  },
                },
              },
            }),
          ],
          Y.prototype,
          'url',
          null,
        ),
        (0, s._)([(0, m.Cb)()], Y.prototype, 'version', void 0),
        (Y = (0, s._)([(0, f.j)('esri.layers.WMTSLayer')], Y));
      const Q = Y;
    },
  },
]);
