(self.webpackChunkRemoteClient = self.webpackChunkRemoteClient || []).push([
  [9231],
  {
    89231: (e, t, a) => {
      'use strict';
      a.r(t), a.d(t, { applyEdits: () => o });
      var r = a(23761),
        s = a(15324),
        i = a(60991),
        d = a(76506),
        n = a(32101),
        l = a(95533);
      async function o(e, t, a, r = {}) {
        let n, l;
        const o = {
          edits: a,
          result: new Promise((e, t) => {
            (n = e), (l = t);
          }),
        };
        e.emit('apply-edits', o);
        try {
          var y;
          const { results: l, edits: o } = await (async function (e, t, a, r) {
              if (
                (await e.load(),
                !(function (e) {
                  return e && null != e.applyEdits;
                })(t))
              )
                return Promise.reject(
                  new i.Z(
                    `${e.type}-layer:no-editing-support`,
                    'Layer source does not support applyEdits capability',
                    { layer: e },
                  ),
                );
              if (!e.editingEnabled)
                throw new i.Z(`${e.type}-layer:editing-disabled`, 'Editing is disabled for layer', {
                  layer: e,
                });
              const { edits: n, options: l } = await (async function (e, t, a) {
                const r = t && (t.addFeatures || t.updateFeatures || t.deleteFeatures),
                  n = t && (t.addAttachments || t.updateAttachments || t.deleteAttachments);
                if (!t || (!r && !n))
                  throw new i.Z(
                    `${e.type}-layer:missing-parameters`,
                    "'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required",
                  );
                if (!e.capabilities.data.isVersioned && a && a.gdbVersion)
                  throw new i.Z(
                    `${e.type}-layer:invalid-parameter`,
                    "'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'",
                  );
                if (
                  !e.capabilities.editing.supportsRollbackOnFailure &&
                  a &&
                  a.rollbackOnFailureEnabled
                )
                  throw new i.Z(
                    `${e.type}-layer:invalid-parameter`,
                    "This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'",
                  );
                if (!e.capabilities.editing.supportsGlobalId && a && a.globalIdUsed)
                  throw new i.Z(
                    `${e.type}-layer:invalid-parameter`,
                    "This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'",
                  );
                if (!e.capabilities.editing.supportsGlobalId && n)
                  throw new i.Z(
                    `${e.type}-layer:invalid-parameter`,
                    "'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'",
                  );
                if ((!a || !a.globalIdUsed) && n)
                  throw new i.Z(
                    `${e.type}-layer:invalid-parameter`,
                    "When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true",
                  );
                const l = { ...a };
                if (
                  (null != l.rollbackOnFailureEnabled ||
                    e.capabilities.editing.supportsRollbackOnFailure ||
                    (l.rollbackOnFailureEnabled = !0),
                  !1 === l.rollbackOnFailureEnabled &&
                    'original-and-current-features' === l.returnServiceEditsOption)
                )
                  throw new i.Z(
                    `${e.type}-layer:invalid-parameter`,
                    "'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true.",
                  );
                if (
                  !e.capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference &&
                  l.returnServiceEditsInSourceSR
                )
                  throw new i.Z(
                    `${e.type}-layer:invalid-parameter`,
                    "This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'",
                  );
                if (
                  l.returnServiceEditsInSourceSR &&
                  'original-and-current-features' !== l.returnServiceEditsOption
                )
                  throw new i.Z(
                    `${e.type}-layer:invalid-parameter`,
                    "'returnServiceEditsOption' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'",
                  );
                const o = { ...t };
                if (
                  ((o.addFeatures =
                    t && s.Z.isCollection(t.addFeatures)
                      ? t.addFeatures.toArray()
                      : o.addFeatures || []),
                  (o.updateFeatures =
                    t && s.Z.isCollection(t.updateFeatures)
                      ? t.updateFeatures.toArray()
                      : o.updateFeatures || []),
                  (o.deleteFeatures =
                    t && s.Z.isCollection(t.deleteFeatures)
                      ? t.deleteFeatures.toArray()
                      : o.deleteFeatures || []),
                  o.addFeatures.length && !e.capabilities.operations.supportsAdd)
                )
                  throw new i.Z(
                    `${e.type}-layer:unsupported-operation`,
                    'Layer does not support adding features.',
                  );
                if (o.updateFeatures.length && !e.capabilities.operations.supportsUpdate)
                  throw new i.Z(
                    `${e.type}-layer:unsupported-operation`,
                    'Layer does not support updating features.',
                  );
                if (o.deleteFeatures.length && !e.capabilities.operations.supportsDelete)
                  throw new i.Z(
                    `${e.type}-layer:unsupported-operation`,
                    'Layer does not support deleting features.',
                  );
                (o.addAttachments = o.addAttachments || []),
                  (o.updateAttachments = o.updateAttachments || []),
                  (o.deleteAttachments = o.deleteAttachments || []),
                  (o.addFeatures = o.addFeatures.map(h)),
                  (o.updateFeatures = o.updateFeatures.map(h));
                const y = a && a.globalIdUsed;
                return (
                  o.addFeatures.forEach((t) =>
                    (function (e, t, a) {
                      u(e, t, a);
                    })(t, e, y),
                  ),
                  o.updateFeatures.forEach((t) =>
                    (function (e, t, a) {
                      if (
                        (u(e, t, a),
                        'geometry' in e &&
                          (0, d.i)(e.geometry) &&
                          !t.capabilities.editing.supportsGeometryUpdate)
                      )
                        throw new i.Z(
                          `${t.type}-layer:unsupported-operation`,
                          'Layer does not support geometry updates.',
                        );
                    })(t, e, y),
                  ),
                  o.deleteFeatures.forEach((t) =>
                    (function (e, t, a) {
                      u(e, t, a);
                    })(t, e, y),
                  ),
                  o.addAttachments.forEach((t) => p(t, e)),
                  o.updateAttachments.forEach((t) => p(t, e)),
                  { edits: await c(o), options: l }
                );
              })(e, a, r);
              return n.addFeatures.length ||
                n.updateFeatures.length ||
                n.deleteFeatures.length ||
                n.addAttachments.length ||
                n.updateAttachments.length ||
                n.deleteAttachments.length
                ? { edits: n, results: await t.applyEdits(n, l) }
                : {
                    edits: n,
                    results: {
                      addFeatureResults: [],
                      updateFeatureResults: [],
                      deleteFeatureResults: [],
                      addAttachmentResults: [],
                      updateAttachmentResults: [],
                      deleteAttachmentResults: [],
                    },
                  };
            })(e, t, a, r),
            m = (e) => e.filter((e) => !e.error).map(d.d9),
            b = {
              edits: o,
              addedFeatures: m(l.addFeatureResults),
              updatedFeatures: m(l.updateFeatureResults),
              deletedFeatures: m(l.deleteFeatureResults),
              addedAttachments: m(l.addAttachmentResults),
              updatedAttachments: m(l.updateAttachmentResults),
              deletedAttachments: m(l.deleteAttachmentResults),
            };
          return (
            null != (y = l.editedFeatureResults) &&
              y.length &&
              (b.editedFeatures = l.editedFeatureResults),
            (b.addedFeatures.length ||
              b.updatedFeatures.length ||
              b.deletedFeatures.length ||
              b.addedAttachments.length ||
              b.updatedAttachments.length ||
              b.deletedAttachments.length) &&
              e.emit('edits', b),
            n(b),
            l
          );
        } catch (e) {
          throw (l(e), e);
        }
      }
      function u(e, t, a) {
        if (a) {
          if ('attributes' in e && !e.attributes[t.globalIdField])
            throw new i.Z(
              `${t.type}-layer:invalid-parameter`,
              "Feature should have 'globalId' when 'globalIdUsed' is true",
            );
          if (!('attributes' in e) && !e.globalId)
            throw new i.Z(
              `${t.type}-layer:invalid-parameter`,
              "'globalId' of the feature should be passed when 'globalIdUsed' is true",
            );
        }
        if ('geometry' in e && (0, d.i)(e.geometry)) {
          if (e.geometry.hasZ && !1 === t.capabilities.data.supportsZ)
            throw new i.Z(
              `${t.type}-layer:z-unsupported`,
              'Layer does not support z values while feature has z values.',
            );
          if (e.geometry.hasM && !1 === t.capabilities.data.supportsM)
            throw new i.Z(
              `${t.type}-layer:m-unsupported`,
              'Layer does not support m values while feature has m values.',
            );
        }
      }
      function p(e, t) {
        const { feature: a, attachment: r } = e;
        if (!a || ('attributes' in a && !a.attributes[t.globalIdField]))
          throw new i.Z(
            `${t.type}-layer:invalid-parameter`,
            "Attachment should have reference to a feature with 'globalId'",
          );
        if (!('attributes' in a) && !a.globalId)
          throw new i.Z(
            `${t.type}-layer:invalid-parameter`,
            "Attachment should have reference to 'globalId' of the parent feature",
          );
        if (!r.globalId)
          throw new i.Z(`${t.type}-layer:invalid-parameter`, "Attachment should have 'globalId'");
        if (!r.data && !r.uploadId)
          throw new i.Z(
            `${t.type}-layer:invalid-parameter`,
            "Attachment should have 'data' or 'uploadId'",
          );
        if (!((r.data instanceof File && r.data.name) || r.name))
          throw new i.Z(
            `${t.type}-layer:invalid-parameter`,
            "'name' is required when attachment is specified as Base64 encoded string using 'data'",
          );
        if (!t.capabilities.editing.supportsUploadWithItemId && r.uploadId)
          throw new i.Z(
            `${t.type}-layer:invalid-parameter`,
            "This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'",
          );
        if ('string' == typeof r.data) {
          const e = (0, n.sJ)(r.data);
          if (e && !e.isBase64)
            throw new i.Z(
              `${t.type}-layer:invalid-parameter`,
              "Attachment 'data' should be a Blob, File or Base64 encoded string",
            );
        }
      }
      async function c(e) {
        const t = e.addFeatures,
          a = e.updateFeatures,
          r = t.concat(a).map((e) => e.geometry),
          s = await (0, l.aX)(r),
          i = t.length,
          d = a.length;
        return (
          s.slice(0, i).forEach((t, a) => (e.addFeatures[a].geometry = t)),
          s.slice(i, i + d).forEach((t, a) => (e.updateFeatures[a].geometry = t)),
          e
        );
      }
      function h(e) {
        const t = new r.Z();
        return (
          e.attributes || (e.attributes = {}),
          (t.geometry = e.geometry),
          (t.attributes = e.attributes),
          t
        );
      }
      a(74569),
        a(91306),
        a(92143),
        a(31450),
        a(71552),
        a(40642),
        a(21801),
        a(34250),
        a(86656),
        a(22723),
        a(17533),
        a(81172),
        a(73796),
        a(74673),
        a(21972),
        a(23639),
        a(91055),
        a(27794),
        a(6906),
        a(50406),
        a(26341),
        a(97714),
        a(60947),
        a(2906),
        a(91597),
        a(86787),
        a(35132),
        a(89623),
        a(84069),
        a(44567),
        a(98380),
        a(92896),
        a(22781),
        a(57251),
        a(32422),
        a(86748),
        a(14249),
        a(9801),
        a(53523),
        a(59465),
        a(42911),
        a(46826),
        a(45433),
        a(60217),
        a(29107),
        a(30574),
        a(2157),
        a(25977),
        a(7471),
        a(54414),
        a(1648),
        a(8925),
        a(33921),
        a(3482),
        a(45154),
        a(16769),
        a(55531),
        a(30582),
        a(593),
        a(85699),
        a(63136),
        a(96055),
        a(47776),
        a(18033),
        a(6331),
        a(62048),
        a(4292),
        a(75626),
        a(72652),
        a(29641),
        a(30493),
        a(70821),
        a(82673),
        a(34229),
        a(37029),
        a(76996),
        a(96467),
        a(63571),
        a(30776),
        a(48027),
        a(54174),
        a(82426),
        a(63130),
        a(25696),
        a(66396),
        a(42775),
        a(95834),
        a(34394),
        a(57150),
        a(76726),
        a(20444),
        a(76393),
        a(78548),
        a(2497),
        a(49906),
        a(46527),
        a(48649),
        a(9960),
        a(3101),
        a(5853),
        a(39141),
        a(38742),
        a(48243),
        a(34635),
        a(10401),
        a(49900),
        a(66284),
        a(82058),
        a(88762),
        a(73173),
        a(22739),
        a(20543),
        a(67477),
        a(78533),
        a(74653),
        a(91091),
        a(58943),
        a(70737),
        a(8487),
        a(17817),
        a(90814),
        a(15459),
        a(61847),
        a(16796),
        a(16955),
        a(22401),
        a(77894),
        a(55187),
        a(8586),
        a(44509),
        a(69814),
        a(11305),
        a(62259),
        a(44790),
        a(5909),
        a(60669),
        a(48208),
        a(51589),
        a(94751);
    },
  },
]);
