{"version":3,"sources":["node_modules/@arcgis/core/versionManagement/support/versionManagementUtils.js","node_modules/@arcgis/core/layers/mixins/EditBusLayer.js"],"sourcesContent":["/*\nAll material copyright ESRI, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/4.31/esri/copyright.txt for details.\n*/\nimport e from \"../../request.js\";\nimport { generateLowercaseBracedUUID as r } from \"../../core/uuid.js\";\nconst t = r(),\n n = new Map(),\n s = new Map(),\n a = new Map();\nasync function o(r, t, s) {\n if (!r || !s) return !1;\n if (!t) return !0;\n const a = new URL(r).host;\n let o = n.get(a);\n if (!o) {\n const t = r.replace(/\\/FeatureServer/i, \"/VersionManagementServer\").replace(/\\/\\d*$/, \"\");\n o = (await e(t, {\n responseType: \"json\",\n query: {\n f: \"json\"\n }\n })).data.defaultVersionName;\n }\n return o === t;\n}\nasync function i(e, r, n = !1) {\n if (!e || !r) return !0;\n const a = e.replace(/\\/FeatureServer/i, \"/VersionManagementServer\").replace(/\\/\\d*$/, \"\"),\n o = s.get(a)?.entries();\n if (o) for (const [s, i] of o) if (i.name === r) {\n const e = !i.stack?.hasForwardEdits();\n if (!e && n) {\n const [{\n deleteForwardEdits: e\n }, {\n default: r\n }] = await Promise.all([import(\"../../rest/versionManagement/gdbVersion/deleteForwardEdits.js\"), import(\"../../rest/versionManagement/gdbVersion/support/DeleteForwardEditsParameters.js\")]),\n n = await e(a, s, new r({\n sessionId: t,\n moment: i.moment\n }));\n return n.success && i.stack?.clearForwardEdits(), n.success;\n }\n return e;\n }\n return !0;\n}\nfunction c(e, r) {\n if (!e) return !1;\n const t = e.replace(/\\/FeatureServer/i, \"/VersionManagementServer\").replace(/\\/\\d*$/, \"\"),\n n = s.get(t)?.entries();\n if (n) for (const [s, a] of n) if (a.name === r) {\n return \"edit\" === a.lockType;\n }\n return !1;\n}\nexport { t as currentSessionId, n as defaultVersionNameLookup, o as isHistoricVersion, i as isSafeToEditVersion, c as isVersionInEditSession, s as versionCollection, a as versionCollectionCount };","/*\nAll material copyright ESRI, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/4.31/esri/copyright.txt for details.\n*/\nimport { _ as t } from \"../../chunks/tslib.es6.js\";\nimport e from \"../../core/Evented.js\";\nimport { clone as i } from \"../../core/lang.js\";\nimport { createResolver as s } from \"../../core/promiseUtils.js\";\nimport { property as r } from \"../../core/accessorSupport/decorators/property.js\";\nimport \"../../core/has.js\";\nimport \"../../core/Logger.js\";\nimport { subclass as d } from \"../../core/accessorSupport/decorators/subclass.js\";\nimport { defaultVersionNameLookup as o, isVersionInEditSession as n } from \"../../versionManagement/support/versionManagementUtils.js\";\nconst a = new e.EventEmitter();\nfunction l(t) {\n return a.on(\"apply-edits\", new WeakRef(t));\n}\nfunction h(t) {\n return a.on(\"update-moment\", new WeakRef(t));\n}\nfunction c(t, e, i = null, r = !1) {\n const d = s();\n return r = null == e || r, a.emit(\"apply-edits\", {\n serviceUrl: t,\n layerId: e,\n gdbVersion: i,\n mayReceiveServiceEdits: r,\n result: d.promise\n }), d;\n}\nfunction u(t, e, i = null, s) {\n a.emit(\"update-moment\", {\n serviceUrl: t,\n layerId: e,\n gdbVersion: i,\n moment: s\n });\n}\nconst m = Symbol();\nfunction p(t) {\n return null != t && \"object\" == typeof t && m in t;\n}\nfunction b(t) {\n return null != t && \"object\" == typeof t && \"gdbVersion\" in t;\n}\nfunction g(t, e, i) {\n const s = new URL(t).host,\n r = o.get(s),\n d = t => !t || t === r;\n return d(e) && d(i) || e === i;\n}\nconst F = e => {\n var s;\n let o = class extends e {\n constructor(...t) {\n super(...t), this[s] = !0, this._applyEditsHandler = t => {\n const {\n serviceUrl: e,\n layerId: s,\n gdbVersion: r,\n mayReceiveServiceEdits: d,\n result: o\n } = t,\n n = e === this.url,\n a = null != s && null != this.layerId && s === this.layerId,\n l = b(this),\n h = b(this) && g(e, r, this.gdbVersion);\n if (!n || l && !h || !a && !d) return;\n const c = o.then(t => {\n if (this.lastEditsEventDate = new Date(), a && (t.addedFeatures.length || t.updatedFeatures.length || t.deletedFeatures.length || t.addedAttachments.length || t.updatedAttachments.length || t.deletedAttachments.length)) return this.emit(\"edits\", i(t)), t;\n const s = t.editedFeatures?.find(({\n layerId: t\n }) => t === this.layerId);\n if (s) {\n const {\n adds: e,\n updates: r,\n deletes: d\n } = s.editedFeatures,\n o = {\n edits: null,\n addedAttachments: [],\n deletedAttachments: [],\n updatedAttachments: [],\n addedFeatures: e ? e.map(({\n attributes: t\n }) => ({\n objectId: this.objectIdField && t[this.objectIdField],\n globalId: this.globalIdField && t[this.globalIdField]\n })) : [],\n deletedFeatures: d ? d.map(({\n attributes: t\n }) => ({\n objectId: this.objectIdField && t[this.objectIdField],\n globalId: this.globalIdField && t[this.globalIdField]\n })) : [],\n updatedFeatures: r ? r.map(({\n current: {\n attributes: t\n }\n }) => ({\n objectId: this.objectIdField && t[this.objectIdField],\n globalId: this.globalIdField && t[this.globalIdField]\n })) : [],\n editedFeatures: i(t.editedFeatures),\n exceededTransferLimit: !1,\n historicMoment: i(t.historicMoment)\n };\n return this.emit(\"edits\", o), o;\n }\n const d = {\n edits: null,\n addedAttachments: [],\n deletedAttachments: [],\n updatedAttachments: [],\n addedFeatures: [],\n deletedFeatures: [],\n updatedFeatures: [],\n editedFeatures: i(t.editedFeatures),\n exceededTransferLimit: !1,\n historicMoment: i(t.historicMoment)\n };\n return \"historicMoment\" in this && this._shouldUpdateHistoricMoment(e, r, d.historicMoment) && this.emit(\"edits\", d), d;\n }).then(t => (\"historicMoment\" in this && this._shouldUpdateHistoricMoment(e, r, t.historicMoment) && (this.historicMoment = t.historicMoment), t));\n this.emit(\"apply-edits\", {\n result: c\n });\n }, this._updateMomentHandler = t => {\n const {\n serviceUrl: e,\n gdbVersion: i,\n moment: s\n } = t,\n r = e === this.url,\n d = b(this),\n o = b(this) && g(e, i, this.gdbVersion),\n n = b(this) && !g(e, this.gdbVersion, null);\n r && d && o && n && \"historicMoment\" in this && this.historicMoment !== s && (this.historicMoment = s);\n }, this.when().then(() => {\n this.addHandles(l(this._applyEditsHandler)), \"historicMoment\" in this && this.addHandles(h(this._updateMomentHandler));\n }, () => {});\n }\n _shouldUpdateHistoricMoment(t, e, i) {\n return \"historicMoment\" in this && this.historicMoment !== i && n(t, e);\n }\n };\n return s = m, t([r()], o.prototype, \"lastEditsEventDate\", void 0), o = t([d(\"esri.layers.mixins.EditBusLayer\")], o), o;\n};\nexport { F as EditBusLayer, c as emitApplyEditsEvent, u as emitUpdateMomentEvent, p as isEditBusLayer, b as isLayerWithGDBVersion, l as onApplyEditsEvent, h as onUpdateMomentEvent, g as versionMatches };"],"mappings":"wWAMA,IAAMA,EAAIC,EAAE,EACVC,EAAI,IAAI,IACRC,EAAI,IAAI,IAEV,SAAeC,EAAEC,EAAGC,EAAGC,EAAG,QAAAC,EAAA,sBACxB,GAAI,CAACH,GAAK,CAACE,EAAG,MAAO,GACrB,GAAI,CAACD,EAAG,MAAO,GACf,IAAMG,EAAI,IAAI,IAAIJ,CAAC,EAAE,KACjBD,EAAIM,EAAE,IAAID,CAAC,EACf,GAAI,CAACL,EAAG,CACN,IAAM,EAAIC,EAAE,QAAQ,mBAAoB,0BAA0B,EAAE,QAAQ,SAAU,EAAE,EACxFD,GAAK,MAAMO,EAAE,EAAG,CACd,aAAc,OACd,MAAO,CACL,EAAG,MACL,CACF,CAAC,GAAG,KAAK,kBACX,CACA,OAAOP,IAAME,CACf,GACA,SAAeM,EAAE,EAAGP,EAAGK,EAAI,GAAI,QAAAF,EAAA,sBAC7B,GAAI,CAAC,GAAK,CAACH,EAAG,MAAO,GACrB,IAAMI,EAAI,EAAE,QAAQ,mBAAoB,0BAA0B,EAAE,QAAQ,SAAU,EAAE,EACtFL,EAAIG,EAAE,IAAIE,CAAC,GAAG,QAAQ,EACxB,GAAIL,GAAG,OAAW,CAACG,EAAGK,CAAC,IAAKR,EAAG,GAAIQ,EAAE,OAASP,EAAG,CAC/C,IAAMQ,EAAI,CAACD,EAAE,OAAO,gBAAgB,EACpC,GAAI,C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,gBAAiBA,EAAE,EAClJ,KAAK,KAAK,cAAe,CACvB,OAAQc,CACV,CAAC,CACH,EAAG,KAAK,qBAAuBd,GAAK,CAClC,GAAM,CACF,WAAYG,EACZ,WAAYC,EACZ,OAAQC,CACV,EAAIL,EACJM,EAAIH,IAAM,KAAK,IACfK,EAAIP,EAAE,IAAI,EACVS,EAAIT,EAAE,IAAI,GAAKC,EAAEC,EAAGC,EAAG,KAAK,UAAU,EACtCG,EAAIN,EAAE,IAAI,GAAK,CAACC,EAAEC,EAAG,KAAK,WAAY,IAAI,EAC5CG,GAAKE,GAAKE,GAAKH,GAAK,mBAAoB,MAAQ,KAAK,iBAAmBF,IAAM,KAAK,eAAiBA,EACtG,EAAG,KAAK,KAAK,EAAE,KAAK,IAAM,CACxB,KAAK,WAAWO,EAAE,KAAK,kBAAkB,CAAC,EAAG,mBAAoB,MAAQ,KAAK,WAAWC,EAAE,KAAK,oBAAoB,CAAC,CACvH,EAAG,IAAM,CAAC,CAAC,CACb,CACA,4BAA4Bb,EAAGG,EAAGC,EAAG,CACnC,MAAO,mBAAoB,MAAQ,KAAK,iBAAmBA,GAAKU,EAAEd,EAAGG,CAAC,CACxE,CACF,EACA,OAAOE,EAAIP,EAAGQ,EAAE,CAACR,EAAE,CAAC,EAAG,EAAE,UAAW,qBAAsB,MAAM,EAAG,EAAIQ,EAAE,CAACK,EAAE,iCAAiC,CAAC,EAAG,CAAC,EAAG,CACvH","names":["t","o","n","s","o","r","t","s","__async","a","n","U","i","e","c","a","o","l","t","h","c","e","i","r","d","L","m","p","t","b","g","e","i","s","r","n","d","F","o","a","l","h","c"],"x_google_ignoreList":[0,1]}