chunk-C62PEMUB.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. import {
  2. i
  3. } from "./chunk-5ZZSM3DU.js";
  4. import {
  5. w
  6. } from "./chunk-UILPRJKY.js";
  7. import {
  8. v as v2
  9. } from "./chunk-524XACB7.js";
  10. import {
  11. t
  12. } from "./chunk-QY775BFA.js";
  13. import {
  14. L,
  15. b,
  16. h,
  17. m,
  18. y
  19. } from "./chunk-X7DBH4KK.js";
  20. import {
  21. f as f2,
  22. v
  23. } from "./chunk-PSV473TI.js";
  24. import {
  25. b as b2
  26. } from "./chunk-EGZW6HC3.js";
  27. import {
  28. B
  29. } from "./chunk-4NKD334K.js";
  30. import {
  31. a
  32. } from "./chunk-WJ3OEUD3.js";
  33. import {
  34. U
  35. } from "./chunk-VNFRAYHO.js";
  36. import {
  37. j
  38. } from "./chunk-VBRY5KJM.js";
  39. import {
  40. M2 as M,
  41. o
  42. } from "./chunk-ECW2QABR.js";
  43. import {
  44. k2 as k,
  45. r as r2
  46. } from "./chunk-MRJEICT6.js";
  47. import {
  48. d,
  49. e,
  50. n2 as n
  51. } from "./chunk-Y3WMVFTW.js";
  52. import {
  53. E,
  54. f,
  55. x
  56. } from "./chunk-ULGDPLM2.js";
  57. import {
  58. s,
  59. s3 as s2
  60. } from "./chunk-EMJ4ZSM2.js";
  61. import {
  62. r
  63. } from "./chunk-GZT4BVFP.js";
  64. // node_modules/@arcgis/core/layers/support/I3SIndexInfo.js
  65. async function n2(n4, t2, s3, a3, i2, d2) {
  66. let l = null;
  67. if (r(s3)) {
  68. const o2 = `${n4}/nodepages/`, t3 = o2 + Math.floor(s3.rootIndex / s3.nodesPerPage);
  69. try {
  70. return { type: "page", rootPage: (await U(t3, { query: { f: "json", token: a3 }, responseType: "json", signal: d2 })).data, rootIndex: s3.rootIndex, pageSize: s3.nodesPerPage, lodMetric: s3.lodSelectionMetricType, urlPrefix: o2 };
  71. } catch (f3) {
  72. r(i2) && i2.warn("#fetchIndexInfo()", "Failed to load root node page. Falling back to node documents.", t3, f3), l = f3;
  73. }
  74. }
  75. if (!t2)
  76. return null;
  77. const p2 = `${n4}/nodes/`, c = p2 + (t2 && t2.split("/").pop());
  78. try {
  79. return { type: "node", rootNode: (await U(c, { query: { f: "json", token: a3 }, responseType: "json", signal: d2 })).data, urlPrefix: p2 };
  80. } catch (f3) {
  81. throw new s2("sceneservice:root-node-missing", "Root node missing.", { pageError: l, nodeError: f3, url: c });
  82. }
  83. }
  84. // node_modules/@arcgis/core/webdoc/support/saveUtils.js
  85. async function a2(r3, a3, u) {
  86. if (!a3 || !a3.resources)
  87. return;
  88. const h2 = a3.portalItem === r3.portalItem ? new Set(r3.paths) : new Set();
  89. r3.paths.length = 0, r3.portalItem = a3.portalItem;
  90. const i2 = new Set(a3.resources.toKeep.map((r4) => r4.resource.path)), f3 = new Set(), m2 = [];
  91. i2.forEach((e2) => {
  92. h2.delete(e2), r3.paths.push(e2);
  93. });
  94. for (const e2 of a3.resources.toUpdate)
  95. if (h2.delete(e2.resource.path), i2.has(e2.resource.path) || f3.has(e2.resource.path)) {
  96. const { resource: o2, content: t2, finish: a4, error: p2 } = e2, h3 = w(o2, t());
  97. r3.paths.push(h3.path), m2.push(n3({ resource: h3, content: t2, finish: a4, error: p2 }, u));
  98. } else
  99. r3.paths.push(e2.resource.path), m2.push(p(e2, u)), f3.add(e2.resource.path);
  100. for (const e2 of a3.resources.toAdd)
  101. m2.push(n3(e2, u)), r3.paths.push(e2.resource.path);
  102. if (h2.forEach((r4) => {
  103. const e2 = a3.portalItem.resourceFromPath(r4);
  104. m2.push(e2.portalItem.removeResource(e2).catch(() => {
  105. }));
  106. }), m2.length === 0)
  107. return;
  108. const l = await E(m2);
  109. f(u);
  110. const d2 = l.filter((r4) => "error" in r4).map((r4) => r4.error);
  111. if (d2.length > 0)
  112. throw new s2("save:resources", "Failed to save one or more resources", { errors: d2 });
  113. }
  114. async function n3(e2, o2) {
  115. const t2 = await a(e2.resource.portalItem.addResource(e2.resource, e2.content, o2));
  116. if (t2.ok !== true)
  117. throw e2.error && e2.error(t2.error), t2.error;
  118. e2.finish && e2.finish(e2.resource);
  119. }
  120. async function p(e2, o2) {
  121. const t2 = await a(e2.resource.update(e2.content, o2));
  122. if (t2.ok !== true)
  123. throw e2.error(t2.error), t2.error;
  124. e2.finish(e2.resource);
  125. }
  126. // node_modules/@arcgis/core/layers/mixins/SceneService.js
  127. var R = s.getLogger("esri.layers.mixins.SceneService");
  128. var A = (i2) => {
  129. let A2 = class extends i2 {
  130. constructor() {
  131. super(...arguments), this.spatialReference = null, this.fullExtent = null, this.heightModelInfo = null, this.minScale = 0, this.maxScale = 0, this.version = { major: Number.NaN, minor: Number.NaN, versionString: "" }, this.copyright = null, this.sublayerTitleMode = "item-title", this.title = null, this.layerId = null, this.indexInfo = null, this._debouncedSaveOperations = x(async (e2, t2, r3) => {
  132. switch (e2) {
  133. case K.SAVE:
  134. return this._save(t2);
  135. case K.SAVE_AS:
  136. return this._saveAs(r3, t2);
  137. }
  138. });
  139. }
  140. readSpatialReference(e2, t2) {
  141. return this._readSpatialReference(t2);
  142. }
  143. _readSpatialReference(e2) {
  144. if (e2.spatialReference != null)
  145. return k.fromJSON(e2.spatialReference);
  146. {
  147. const t2 = e2.store, r3 = t2.indexCRS || t2.geographicCRS, i3 = r3 && parseInt(r3.substring(r3.lastIndexOf("/") + 1, r3.length), 10);
  148. return i3 != null ? new k(i3) : null;
  149. }
  150. }
  151. readFullExtent(e2, t2, r3) {
  152. if (e2 != null && typeof e2 == "object") {
  153. const i4 = e2.spatialReference == null ? { ...e2, spatialReference: this._readSpatialReference(t2) } : e2;
  154. return M.fromJSON(i4, r3);
  155. }
  156. const i3 = t2.store, o2 = this._readSpatialReference(t2);
  157. return o2 == null || i3 == null || i3.extent == null || !Array.isArray(i3.extent) || i3.extent.some((e3) => e3 < N) ? null : new M({ xmin: i3.extent[0], ymin: i3.extent[1], xmax: i3.extent[2], ymax: i3.extent[3], spatialReference: o2 });
  158. }
  159. parseVersionString(e2) {
  160. const t2 = { major: Number.NaN, minor: Number.NaN, versionString: e2 }, r3 = e2.split(".");
  161. return r3.length >= 2 && (t2.major = parseInt(r3[0], 10), t2.minor = parseInt(r3[1], 10)), t2;
  162. }
  163. readVersion(e2, t2) {
  164. const r3 = t2.store, i3 = r3.version != null ? r3.version.toString() : "";
  165. return this.parseVersionString(i3);
  166. }
  167. readTitlePortalItem(e2) {
  168. return this.sublayerTitleMode !== "item-title" ? void 0 : e2;
  169. }
  170. readTitleService(e2, t2) {
  171. const r3 = this.portalItem && this.portalItem.title;
  172. if (this.sublayerTitleMode === "item-title")
  173. return y(this.url, t2.name);
  174. let i3 = t2.name;
  175. if (!i3 && this.url) {
  176. const e3 = m(this.url);
  177. r(e3) && (i3 = e3.title);
  178. }
  179. return this.sublayerTitleMode === "item-title-and-service-name" && r3 && (i3 = r3 + " - " + i3), h(i3);
  180. }
  181. set url(e2) {
  182. const t2 = L({ layer: this, url: e2, nonStandardUrlAllowed: false, logger: R });
  183. this._set("url", t2.url), t2.layerId != null && this._set("layerId", t2.layerId);
  184. }
  185. writeUrl(e2, t2, r3, i3) {
  186. b(this, e2, "layers", t2, i3);
  187. }
  188. get parsedUrl() {
  189. const e2 = this._get("url");
  190. if (!e2)
  191. return null;
  192. const t2 = j(e2);
  193. return this.layerId != null && (t2.path = `${t2.path}/layers/${this.layerId}`), t2;
  194. }
  195. async _fetchIndexAndUpdateExtent(e2, t2) {
  196. this.indexInfo = n2(this.parsedUrl.path, this.rootNode, e2, this.apiKey, R, t2), this.fullExtent == null || this.fullExtent.hasZ || this._updateExtent(await this.indexInfo);
  197. }
  198. _updateExtent(e2) {
  199. if (e2?.type === "page") {
  200. const t2 = e2.rootIndex % e2.pageSize, i3 = e2.rootPage?.nodes?.[t2];
  201. if (i3 == null || i3.obb == null || i3.obb.center == null || i3.obb.halfSize == null)
  202. throw new s2("sceneservice:invalid-node-page", "Invalid node page.");
  203. if (i3.obb.center[0] < N || this.fullExtent == null || this.fullExtent.hasZ)
  204. return;
  205. const o2 = i3.obb.halfSize, s3 = i3.obb.center[2], a3 = Math.sqrt(o2[0] * o2[0] + o2[1] * o2[1] + o2[2] * o2[2]);
  206. this.fullExtent.zmin = s3 - a3, this.fullExtent.zmax = s3 + a3;
  207. } else if (e2?.type === "node") {
  208. const t2 = e2.rootNode?.mbs;
  209. if (!Array.isArray(t2) || t2.length !== 4 || t2[0] < N)
  210. return;
  211. const r3 = t2[2], i3 = t2[3];
  212. this.fullExtent.zmin = r3 - i3, this.fullExtent.zmax = r3 + i3;
  213. }
  214. }
  215. async _fetchService(e2) {
  216. if (this.url == null)
  217. throw new s2("sceneservice:url-not-set", "Scene service can not be loaded without valid portal item or url");
  218. if (this.layerId == null && /SceneServer\/*$/i.test(this.url)) {
  219. const t2 = await this._fetchFirstLayerId(e2);
  220. t2 != null && (this.layerId = t2);
  221. }
  222. return this._fetchServiceLayer(e2);
  223. }
  224. async _fetchFirstLayerId(e2) {
  225. const r3 = await U(this.url, { query: { f: "json", token: this.apiKey }, responseType: "json", signal: e2 });
  226. if (r3.data && Array.isArray(r3.data.layers) && r3.data.layers.length > 0)
  227. return r3.data.layers[0].id;
  228. }
  229. async _fetchServiceLayer(e2) {
  230. const r3 = await U(this.parsedUrl.path, { query: { f: "json", token: this.apiKey }, responseType: "json", signal: e2 });
  231. r3.ssl && (this.url = this.url.replace(/^http:/i, "https:"));
  232. let i3 = false;
  233. if (r3.data.layerType && r3.data.layerType === "Voxel" && (i3 = true), i3)
  234. return this._fetchVoxelServiceLayer();
  235. const o2 = r3.data;
  236. this.read(o2, { origin: "service", url: this.parsedUrl }), this.validateLayer(o2);
  237. }
  238. async _fetchVoxelServiceLayer(e2) {
  239. const r3 = (await U(this.parsedUrl.path + "/layer", { query: { f: "json", token: this.apiKey }, responseType: "json", signal: e2 })).data;
  240. this.read(r3, { origin: "service", url: this.parsedUrl }), this.validateLayer(r3);
  241. }
  242. async _ensureLoadBeforeSave() {
  243. await this.load(), "beforeSave" in this && typeof this.beforeSave == "function" && await this.beforeSave();
  244. }
  245. validateLayer(e2) {
  246. }
  247. _updateTypeKeywords(e2, t2, r3) {
  248. e2.typeKeywords || (e2.typeKeywords = []);
  249. const i3 = t2.getTypeKeywords();
  250. for (const o2 of i3)
  251. e2.typeKeywords.push(o2);
  252. e2.typeKeywords && (e2.typeKeywords = e2.typeKeywords.filter((e3, t3, r4) => r4.indexOf(e3) === t3), r3 === U2.newItem && (e2.typeKeywords = e2.typeKeywords.filter((e3) => e3 !== "Hosted Service")));
  253. }
  254. async _saveAs(e2, t2) {
  255. const i3 = { ...O, ...t2 };
  256. let o2 = b2.from(e2);
  257. o2 || (R.error("_saveAs(): requires a portal item parameter"), await Promise.reject(new s2("sceneservice:portal-item-required", "_saveAs() requires a portal item to save to"))), o2.id && (o2 = o2.clone(), o2.id = null);
  258. const s3 = o2.portal || B.getDefault();
  259. await this._ensureLoadBeforeSave(), o2.type = T, o2.portal = s3;
  260. const a3 = { origin: "portal-item", url: null, messages: [], portal: s3, portalItem: o2, writtenProperties: [], blockedRelativeUrls: [], resources: { toAdd: [], toUpdate: [], toKeep: [], pendingOperations: [] } }, n4 = { layers: [this.write({}, a3)] };
  261. return await Promise.all(a3.resources.pendingOperations), await this._validateAgainstJSONSchema(n4, a3, i3), o2.url = this.url, o2.title || (o2.title = this.title), this._updateTypeKeywords(o2, i3, U2.newItem), await s3._signIn(), await s3.user.addItem({ item: o2, folder: i3 && i3.folder, data: n4 }), await a2(this.resourceReferences, a3, null), this.portalItem = o2, i(a3), a3.portalItem = o2, o2;
  262. }
  263. async _save(e2) {
  264. const t2 = { ...O, ...e2 };
  265. this.portalItem || (R.error("_save(): requires the .portalItem property to be set"), await Promise.reject(new s2("sceneservice:portal-item-not-set", "Portal item to save to has not been set on this SceneService"))), this.portalItem.type !== T && (R.error("_save(): Non-matching portal item type. Got " + this.portalItem.type + ", expected " + T), await Promise.reject(new s2("sceneservice:portal-item-wrong-type", `Portal item needs to have type "${T}"`))), await this._ensureLoadBeforeSave();
  266. const i3 = { origin: "portal-item", url: this.portalItem.itemUrl && j(this.portalItem.itemUrl), messages: [], portal: this.portalItem.portal || B.getDefault(), portalItem: this.portalItem, writtenProperties: [], blockedRelativeUrls: [], resources: { toAdd: [], toUpdate: [], toKeep: [], pendingOperations: [] } }, o2 = { layers: [this.write({}, i3)] };
  267. return await Promise.all(i3.resources.pendingOperations), await this._validateAgainstJSONSchema(o2, i3, t2), this.portalItem.url = this.url, this.portalItem.title || (this.portalItem.title = this.title), this._updateTypeKeywords(this.portalItem, t2, U2.existingItem), await this.portalItem.update({ data: o2 }), await a2(this.resourceReferences, i3, null), i(i3), this.portalItem;
  268. }
  269. async _validateAgainstJSONSchema(e2, t2, i3) {
  270. let o2 = t2.messages.filter((e3) => e3.type === "error").map((e3) => new s2(e3.name, e3.message, e3.details));
  271. if (i3 && i3.validationOptions.ignoreUnsupported && (o2 = o2.filter((e3) => e3.name !== "layer:unsupported" && e3.name !== "symbol:unsupported" && e3.name !== "symbol-layer:unsupported" && e3.name !== "property:unsupported" && e3.name !== "url:unsupported" && e3.name !== "scenemodification:unsupported")), i3.validationOptions.enabled || E2) {
  272. const t3 = (await import("./schemaValidator-K3QIB4AY.js")).validate(e2, i3.portalItemLayerType);
  273. if (t3.length > 0) {
  274. const e3 = `Layer item did not validate:
  275. ${t3.join("\n")}`;
  276. if (R.error(`_validateAgainstJSONSchema(): ${e3}`), i3.validationOptions.failPolicy === "throw") {
  277. const e4 = t3.map((e5) => new s2("sceneservice:schema-validation", e5)).concat(o2);
  278. throw new s2("sceneservice-validate:error", "Failed to save layer item due to schema validation, see `details.errors`.", { combined: e4 });
  279. }
  280. }
  281. }
  282. if (o2.length > 0)
  283. throw new s2("sceneservice:save", "Failed to save SceneService due to unsupported or invalid content. See 'details.errors' for more detailed information", { errors: o2 });
  284. }
  285. };
  286. return e([d(v)], A2.prototype, "id", void 0), e([d({ type: k })], A2.prototype, "spatialReference", void 0), e([o("spatialReference", ["spatialReference", "store.indexCRS", "store.geographicCRS"])], A2.prototype, "readSpatialReference", null), e([d({ type: M })], A2.prototype, "fullExtent", void 0), e([o("fullExtent", ["fullExtent", "store.extent", "spatialReference", "store.indexCRS", "store.geographicCRS"])], A2.prototype, "readFullExtent", null), e([d({ readOnly: true, type: v2 })], A2.prototype, "heightModelInfo", void 0), e([d({ type: Number, json: { name: "layerDefinition.minScale", write: true, origins: { service: { read: { source: "minScale" }, write: false } } } })], A2.prototype, "minScale", void 0), e([d({ type: Number, json: { name: "layerDefinition.maxScale", write: true, origins: { service: { read: { source: "maxScale" }, write: false } } } })], A2.prototype, "maxScale", void 0), e([d({ readOnly: true })], A2.prototype, "version", void 0), e([o("version", ["store.version"])], A2.prototype, "readVersion", null), e([d({ type: String, json: { read: { source: "copyrightText" } } })], A2.prototype, "copyright", void 0), e([d({ type: String, json: { read: false } })], A2.prototype, "sublayerTitleMode", void 0), e([d({ type: String })], A2.prototype, "title", void 0), e([o("portal-item", "title")], A2.prototype, "readTitlePortalItem", null), e([o("service", "title", ["name"])], A2.prototype, "readTitleService", null), e([d({ type: Number, json: { origins: { service: { read: { source: "id" } }, "portal-item": { write: { target: "id", isRequired: true, ignoreOrigin: true }, read: false } } } })], A2.prototype, "layerId", void 0), e([d(f2)], A2.prototype, "url", null), e([r2("url")], A2.prototype, "writeUrl", null), e([d()], A2.prototype, "parsedUrl", null), e([d({ readOnly: true })], A2.prototype, "store", void 0), e([d({ type: String, readOnly: true, json: { read: { source: "store.rootNode" } } })], A2.prototype, "rootNode", void 0), A2 = e([n("esri.layers.mixins.SceneService")], A2), A2;
  287. };
  288. var N = -1e38;
  289. var E2 = false;
  290. var U2;
  291. !function(e2) {
  292. e2[e2.existingItem = 0] = "existingItem", e2[e2.newItem = 1] = "newItem";
  293. }(U2 || (U2 = {}));
  294. var T = "Scene Service";
  295. var O = { getTypeKeywords: () => [], portalItemLayerType: "unknown", validationOptions: { enabled: true, ignoreUnsupported: false, failPolicy: "throw" } };
  296. var K;
  297. !function(e2) {
  298. e2[e2.SAVE = 0] = "SAVE", e2[e2.SAVE_AS = 1] = "SAVE_AS";
  299. }(K || (K = {}));
  300. export {
  301. n2 as n,
  302. A,
  303. K
  304. };
  305. //# sourceMappingURL=chunk-C62PEMUB.js.map