chunk-KNUJIMME.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import {
  2. e
  3. } from "./chunk-MYF5A5DJ.js";
  4. import {
  5. s as s2
  6. } from "./chunk-2HUEYG7P.js";
  7. import {
  8. t
  9. } from "./chunk-5GYJGY4C.js";
  10. import {
  11. d
  12. } from "./chunk-SZFMKPVM.js";
  13. import {
  14. x
  15. } from "./chunk-YUA3AHKR.js";
  16. import {
  17. j
  18. } from "./chunk-LU5IJZB4.js";
  19. import {
  20. b
  21. } from "./chunk-DXVOOCG4.js";
  22. import {
  23. U
  24. } from "./chunk-DVUG3KID.js";
  25. import {
  26. s3 as s
  27. } from "./chunk-E5O6P5I2.js";
  28. // node_modules/@arcgis/core/support/requestPresets.js
  29. async function n(n2) {
  30. const { data: o } = await U(n2, { responseType: "json", query: { f: "json" } });
  31. return o;
  32. }
  33. // node_modules/@arcgis/core/portal/support/layersLoader.js
  34. async function p(e2, t2) {
  35. const r = e2.instance.portalItem;
  36. if (r && r.id)
  37. return await r.load(t2), u(e2), y(e2, t2);
  38. }
  39. function u(t2) {
  40. const r = t2.instance.portalItem;
  41. if (!t2.supportedTypes.includes(r.type))
  42. throw new s("portal:invalid-layer-item-type", "Invalid layer item type '${type}', expected '${expectedType}'", { type: r.type, expectedType: t2.supportedTypes.join(", ") });
  43. }
  44. async function y(e2, t2) {
  45. const r = e2.instance, a = r.portalItem, { url: n2, title: l } = a, i = e(a);
  46. if ("group" === r.type)
  47. return r.read({ title: l }, i), c(r, e2);
  48. n2 && r.read({ url: n2 }, i);
  49. const p2 = await h(e2, t2);
  50. return p2 && r.read(p2, i), r.resourceReferences = { portalItem: a, paths: i.readResourcePaths }, "subtype-group" !== r.type && r.read({ title: l }, i), t(r, i);
  51. }
  52. function c(t2, r) {
  53. var _a;
  54. let a;
  55. const n2 = t2.portalItem.type, o = r.layerModuleTypeMap, s3 = (_a = s2(t2.portalItem, "Oriented Imagery Layer")) != null ? _a : false;
  56. switch (n2) {
  57. case "Feature Service":
  58. a = s3 ? o.OrientedImageryLayer : o.FeatureLayer;
  59. break;
  60. case "Stream Service":
  61. a = o.StreamLayer;
  62. break;
  63. case "Scene Service":
  64. a = o.SceneLayer;
  65. break;
  66. case "Feature Collection":
  67. a = o.FeatureLayer;
  68. break;
  69. default:
  70. throw new s("portal:unsupported-item-type-as-group", `The item type '${n2}' is not supported as a 'IGroupLayer'`);
  71. }
  72. let i;
  73. return a().then((e2) => (i = e2, h(r))).then(async (e2) => {
  74. let r2 = () => i;
  75. if ("Feature Service" === n2) {
  76. if (T(e2 = await b2(e2, t2.portalItem.url)).length) {
  77. const e3 = o.SubtypeGroupLayer, t3 = await e3();
  78. r2 = (e4) => "SubtypeGroupLayer" === e4.layerType ? t3 : i;
  79. }
  80. return m(t2, r2, e2);
  81. }
  82. return w(e2) > 0 ? m(t2, r2, e2) : d2(t2, r2);
  83. });
  84. }
  85. function d2(e2, t2) {
  86. return e2.portalItem.url ? n(e2.portalItem.url).then((r) => {
  87. var _a, _b;
  88. function a(e3) {
  89. return { id: e3.id, name: e3.name };
  90. }
  91. r && m(e2, t2, { layers: (_a = r.layers) == null ? void 0 : _a.map(a), tables: (_b = r.tables) == null ? void 0 : _b.map(a) });
  92. }) : Promise.resolve();
  93. }
  94. function m(e2, t2, r) {
  95. let a = r.layers || [];
  96. const n2 = r.tables || [];
  97. if ("Feature Collection" === e2.portalItem.type && (a.forEach((e3) => {
  98. var _a;
  99. "Table" === ((_a = e3 == null ? void 0 : e3.layerDefinition) == null ? void 0 : _a.type) && n2.push(e3);
  100. }), a = a.filter((e3) => {
  101. var _a;
  102. return "Table" !== ((_a = e3 == null ? void 0 : e3.layerDefinition) == null ? void 0 : _a.type);
  103. })), "coverage" in r) {
  104. const t3 = L(r);
  105. e2.add(t3);
  106. }
  107. a.reverse().forEach((a2) => {
  108. const n3 = f(e2, t2(a2), r, a2);
  109. e2.add(n3);
  110. }), n2.reverse().forEach((a2) => {
  111. const n3 = f(e2, t2(a2), r, a2);
  112. e2.tables.add(n3);
  113. });
  114. }
  115. function f(e2, t2, r, n2) {
  116. const o = new t2({ portalItem: e2.portalItem.clone(), layerId: n2.id });
  117. if ("subtype-group" !== o.type && (o.sublayerTitleMode = "service-name"), "Feature Collection" === e2.portalItem.type) {
  118. const t3 = { origin: "portal-item", portal: e2.portalItem.portal || j.getDefault() };
  119. o.read(n2, t3);
  120. const l = r.showLegend;
  121. null != l && o.read({ showLegend: l }, t3);
  122. }
  123. return o;
  124. }
  125. function h(e2, t2) {
  126. if (false === e2.supportsData)
  127. return Promise.resolve(void 0);
  128. const r = e2.instance;
  129. return r.portalItem.fetchData("json", t2).catch(() => null).then((e3) => {
  130. if (v(r)) {
  131. let t3, a = true;
  132. if (e3 && w(e3) > 0) {
  133. if (null == r.layerId) {
  134. const t4 = T(e3);
  135. r.layerId = "subtype-group" === r.type ? t4 == null ? void 0 : t4[0] : g(e3);
  136. }
  137. t3 = I(e3, r), t3 && (1 === w(e3) && (a = false), null != e3.showLegend && (t3.showLegend = e3.showLegend));
  138. }
  139. return a && "service-name" !== r.sublayerTitleMode && (r.sublayerTitleMode = "item-title-and-service-name"), t3;
  140. }
  141. return e3;
  142. });
  143. }
  144. async function b2(e2, t2) {
  145. if (null == (e2 == null ? void 0 : e2.layers) || null == (e2 == null ? void 0 : e2.tables)) {
  146. const r = await n(t2);
  147. (e2 = e2 || {}).layers = e2.layers || (r == null ? void 0 : r.layers), e2.tables = e2.tables || (r == null ? void 0 : r.tables);
  148. }
  149. return e2;
  150. }
  151. function g(e2) {
  152. const t2 = e2.layers;
  153. if (t2 && t2.length)
  154. return t2[0].id;
  155. const r = e2.tables;
  156. return r && r.length ? r[0].id : null;
  157. }
  158. function I(e2, t2) {
  159. var _a, _b;
  160. const { layerId: r } = t2, a = ((_a = e2.layers) == null ? void 0 : _a.find((e3) => e3.id === r)) || ((_b = e2.tables) == null ? void 0 : _b.find((e3) => e3.id === r));
  161. return a && S(a, t2) ? a : null;
  162. }
  163. function w(e2) {
  164. var _a, _b, _c, _d;
  165. return ((_b = (_a = e2 == null ? void 0 : e2.layers) == null ? void 0 : _a.length) != null ? _b : 0) + ((_d = (_c = e2 == null ? void 0 : e2.tables) == null ? void 0 : _c.length) != null ? _d : 0);
  166. }
  167. function v(e2) {
  168. return "stream" !== e2.type && "oriented-imagery" !== e2.type && "layerId" in e2;
  169. }
  170. function L(a) {
  171. const { coverage: o } = a;
  172. if (!o)
  173. return null;
  174. const l = new URL(o);
  175. if (o.toLowerCase().includes("item.html")) {
  176. const e2 = l.searchParams.get("id"), r = l.origin;
  177. return b.fromPortalItem({ portalItem: new x({ id: e2, url: r }) });
  178. }
  179. if (d(o))
  180. return b.fromArcGISServerUrl({ url: o });
  181. throw new s("portal:oriented-imagery-layer-coverage", "the provided coverage url couldn't be loaded as a layer");
  182. }
  183. function T(e2) {
  184. var _a;
  185. const t2 = [];
  186. return (_a = e2 == null ? void 0 : e2.layers) == null ? void 0 : _a.forEach((e3) => {
  187. "SubtypeGroupLayer" === e3.layerType && t2.push(e3.id);
  188. }), t2;
  189. }
  190. function S(e2, t2) {
  191. return !("feature" === t2.type && "layerType" in e2 && "SubtypeGroupLayer" === e2.layerType || "subtype-group" === t2.type && !("layerType" in e2));
  192. }
  193. export {
  194. n,
  195. p,
  196. b2 as b,
  197. g,
  198. w,
  199. T
  200. };
  201. //# sourceMappingURL=chunk-KNUJIMME.js.map