{"version":3,"sources":["node_modules/@arcgis/core/support/basemapUtils.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 \"../Basemap.js\";\nimport r from \"../config.js\";\nimport t from \"../core/Collection.js\";\nimport n from \"../core/Logger.js\";\nimport { destroyMaybe as a, mappedFind as i } from \"../core/maybe.js\";\nimport { Url as l, makeAbsolute as s, normalize as u } from \"../core/urlUtils.js\";\nimport { ensureType as o } from \"../core/accessorSupport/ensureType.js\";\nimport { effectEquals as c } from \"../layers/effects/utils.js\";\nimport { esriBasemapDefinitions as f } from \"./basemapDefinitions.js\";\nconst p = () => n.getLogger(\"esri.support.basemapUtils\");\nfunction y() {\n return {};\n}\nfunction m(e) {\n for (const r in e) {\n const t = e[r];\n a(t), delete e[r];\n }\n}\nfunction b(t, n) {\n let a;\n if (\"string\" == typeof t) {\n const i = (t in f),\n l = !i && t.includes(\"/\");\n if (!i && !l) {\n if (r.apiKey) p().warn(`Unable to find basemap definition for: ${t}. See available styles at https://developers.arcgis.com/rest/basemap-styles/`);else {\n const e = Object.entries(f).filter(([e, r]) => r.classic || r.is3d).map(([e]) => `\"${e}\"`).sort().join(\", \");\n p().warn(`Unable to find basemap definition for: ${t}. Try one of these: ${e}`);\n }\n return null;\n }\n n && (a = n[t]), a || (a = i ? e.fromId(t) : new e({\n style: {\n id: t\n }\n }), n && (n[t] = a));\n } else a = o(e, t);\n return a?.destroyed && (p().warn(\"The provided basemap is already destroyed\", {\n basemap: a\n }), a = null), a;\n}\nfunction d(e) {\n return \"Web Scene\" === e.portalItem?.type || e.referenceLayers.some(e => \"scene\" === e.type);\n}\nfunction L(e) {\n return !!e?.portalItem?.tags?.some(e => \"beta\" === e.toLowerCase());\n}\nfunction v(e, r) {\n return e.basemap?.referenceLayers?.some(e => e.uid === r) || e.basemap?.baseLayers?.some(e => e.uid === r);\n}\nfunction S(e, r = null) {\n const t = b(e);\n if (!t) return null;\n const n = t.clone();\n return r && (n.baseLayers = w(n.baseLayers, r.baseLayers), n.referenceLayers = w(n.referenceLayers, r.referenceLayers)), n;\n}\nlet g;\nfunction h(e) {\n if (g) return g(e);\n let r = null;\n const t = M(e),\n n = !t?.baseLayers.length;\n for (const a in f) {\n const e = N(t, C(f[a]), {\n mustMatchReferences: n\n });\n if (\"equal\" === e) {\n r = a;\n break;\n }\n \"base-layers-equal\" === e && (r = a);\n }\n return r;\n}\nfunction I(e) {\n g = e;\n}\nfunction R(e, r) {\n if (e === r) return !0;\n if (null != e?.portalItem?.id && e.portalItem.id === r?.portalItem?.id) return !0;\n return \"equal\" === N(M(e), M(r), {\n mustMatchReferences: !0\n });\n}\nfunction w(e, r) {\n const n = new t();\n return e.forEach(e => {\n const t = r.find(r => \"scene\" !== r.type && E($(e), $(r))) || e;\n n.includes(t) ? n.push(e) : n.push(t);\n }), n;\n}\nfunction T(e) {\n return !!e?.baseLayers.concat(e.referenceLayers).some(U);\n}\nfunction U(e) {\n if (x(e.url)) return !0;\n if (\"vector-tile\" === e.type) for (const r in e.sourceNameToSource) {\n const t = e.sourceNameToSource[r];\n if (x(t?.sourceUrl)) return !0;\n }\n return !1;\n}\nfunction j(e, r) {\n if (null == r || null == e) return {\n spatialReference: null,\n updating: !1\n };\n if (\"not-loaded\" === r.loadStatus) return r.load(), {\n spatialReference: null,\n updating: !0\n };\n if (r.spatialReference) return {\n spatialReference: r.spatialReference,\n updating: !1\n };\n if (0 === r.baseLayers.length) return {\n spatialReference: null,\n updating: !1\n };\n const t = r.baseLayers.at(0);\n switch (t.loadStatus) {\n case \"not-loaded\":\n t.load();\n case \"loading\":\n return {\n spatialReference: null,\n updating: !0\n };\n case \"failed\":\n return {\n spatialReference: null,\n updating: !1\n };\n }\n const n = ((\"supportedSpatialReferences\" in t ? t.supportedSpatialReferences : null) || [\"tileInfo\" in t ? t.tileInfo?.spatialReference : t.spatialReference]).filter(Boolean),\n a = e.spatialReference;\n return a ? {\n spatialReference: n.find(e => a.equals(e)) ?? n[0] ?? null,\n updating: !1\n } : {\n spatialReference: n[0],\n updating: !1\n };\n}\nconst q = /^(basemaps|ibasemaps).*-api\\.arcgis\\.com$/i;\nfunction x(e) {\n if (!e) return !1;\n const r = new l(s(e));\n return !!r.authority && q.test(r.authority);\n}\nfunction M(e) {\n return e ? !e.loaded && e.resourceInfo ? C(e.resourceInfo.data) : {\n baseLayers: k(e.baseLayers),\n referenceLayers: k(e.referenceLayers)\n } : null;\n}\nfunction k(e) {\n return (t.isCollection(e) ? e.toArray() : e).map($);\n}\nfunction $(e) {\n return {\n type: e.type,\n effect: \"effect\" in e ? e.effect : void 0,\n url: K(\"urlTemplate\" in e && e.urlTemplate || e.url || \"styleUrl\" in e && e.styleUrl || \"\"),\n minScale: \"minScale\" in e && null != e.minScale ? e.minScale : 0,\n maxScale: \"maxScale\" in e && null != e.maxScale ? e.maxScale : 0,\n opacity: null != e.opacity ? e.opacity : 1,\n visible: null == e.visible || !!e.visible,\n sublayers: \"map-image\" !== e.type && \"wms\" !== e.type || null == e.sublayers ? void 0 : e.sublayers?.map(e => ({\n id: e.id,\n visible: e.visible\n })),\n activeLayerId: \"wmts\" === e.type ? e.activeLayer?.id : void 0\n };\n}\nfunction A(e) {\n return e.isReference || \"ArcGISSceneServiceLayer\" === e.layerType;\n}\nfunction C(e) {\n return e ? {\n baseLayers: G((e.baseMapLayers ?? []).filter(e => !A(e))),\n referenceLayers: G((e.baseMapLayers ?? []).filter(e => A(e)))\n } : null;\n}\nfunction G(e) {\n return e.map(e => B(e));\n}\nfunction B(e) {\n let r;\n switch (e.layerType) {\n case \"VectorTileLayer\":\n r = \"vector-tile\";\n break;\n case \"ArcGISTiledMapServiceLayer\":\n r = \"tile\";\n break;\n case \"ArcGISSceneServiceLayer\":\n r = \"scene\";\n break;\n default:\n r = \"unknown\";\n }\n return {\n type: r,\n effect: e.effect,\n url: K(e.templateUrl || e.urlTemplate || e.styleUrl || e.url),\n minScale: e.minScale ?? 0,\n maxScale: e.maxScale ?? 0,\n opacity: e.opacity ?? 1,\n visible: null == e.visibility || !!e.visibility,\n sublayers: void 0,\n activeLayerId: void 0\n };\n}\nfunction N(e, r, t) {\n if (null != e != (null != r)) return \"not-equal\";\n if (!e || !r) return \"equal\";\n if (!D(e.baseLayers, r.baseLayers)) return \"not-equal\";\n return D(e.referenceLayers, r.referenceLayers) ? \"equal\" : t.mustMatchReferences ? \"not-equal\" : \"base-layers-equal\";\n}\nfunction D(e, r) {\n if (e.length !== r.length) return !1;\n for (let t = 0; t < e.length; t++) if (!E(e[t], r[t])) return !1;\n return !0;\n}\nfunction E(e, r) {\n if (e.type !== r.type || e.url !== r.url || e.minScale !== r.minScale || e.maxScale !== r.maxScale || e.visible !== r.visible || e.opacity !== r.opacity) return !1;\n if (!c(e.effect, r.effect)) return !1;\n if (null != e.activeLayerId || null != r.activeLayerId) return e.activeLayerId === r.activeLayerId;\n if (null != e.sublayers || null != r.sublayers) {\n if (null == e.sublayers || null == r.sublayers || e.sublayers.length !== r.sublayers.length) return !1;\n for (let t = 0; t < e.sublayers.length; t++) {\n const n = e.sublayers.at(t),\n a = r.sublayers.at(t);\n if (n?.id !== a?.id || n?.visible !== a?.visible) return !1;\n }\n }\n return !0;\n}\nfunction K(e) {\n return e ? u(e).replace(/^\\s*https?:/i, \"\").toLowerCase() : \"\";\n}\nfunction O(e) {\n if (!e) return null;\n const {\n thumbnailUrl: r\n } = e;\n if (r) return r;\n const t = h(e);\n return t ? f[t].thumbnailUrl : i(e.baseLayers, V);\n}\nfunction V(e) {\n return \"portalItem\" in e ? e.portalItem?.thumbnailUrl : void 0;\n}\nexport { S as clonePreservingTiledLayers, R as contentEquals, y as createCache, m as destroyCache, b as ensureType, j as findSpatialReference, O as getBasemapThumbnailUrl, h as getWellKnownBasemapId, T as hasDeveloperBasemapLayer, d as isBasemap3D, L as isBasemapInBeta, v as isBasemapLayer, U as isDeveloperBasemapLayer, I as overrideGetWellKnownBasemapId };"],"mappings":"8KAaA,IAAMA,EAAI,IAAMC,EAAE,UAAU,2BAA2B,EACvD,SAASC,GAAI,CACX,MAAO,CAAC,CACV,CACA,SAASC,EAAE,EAAG,CACZ,QAAW,KAAK,EAAG,CACjB,IAAMC,EAAI,EAAE,CAAC,EACbC,EAAED,CAAC,EAAG,OAAO,EAAE,CAAC,CAClB,CACF,CACA,SAASE,EAAEF,EAAGH,EAAG,CACf,IAAI,EACJ,GAAgB,OAAOG,GAAnB,SAAsB,CACxB,IAAMG,EAAKH,KAAK,EACdI,EAAI,CAACD,GAAKH,EAAE,SAAS,GAAG,EAC1B,GAAI,CAACG,GAAK,CAACC,EAAG,CACZ,GAAIC,EAAE,OAAQT,EAAE,EAAE,KAAK,0CAA0CI,CAAC,8EAA8E,MAAO,CACrJ,IAAMM,EAAI,OAAO,QAAQ,CAAC,EAAE,OAAO,CAAC,CAACA,EAAGC,CAAC,IAAMA,EAAE,SAAWA,EAAE,IAAI,EAAE,IAAI,CAAC,CAACD,CAAC,IAAM,IAAIA,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,IAAI,EAC3GV,EAAE,EAAE,KAAK,0CAA0CI,CAAC,uBAAuBM,CAAC,EAAE,CAChF,CACA,OAAO,IACT,CACAT,IAAM,EAAIA,EAAEG,CAAC,GAAI,IAAM,EAAIG,EAAIK,EAAE,OAAOR,CAAC,EAAI,IAAIQ,EAAE,CACjD,MAAO,CACL,GAAIR,CACN,CACF,CAAC,EAAGH,IAAMA,EAAEG,CAAC,EAAI,GACnB,MAAO,EAAIS,EAAED,EAAGR,CAAC,EACjB,OAAO,GAAG,YAAcJ,EAAE,EAAE,KAAK,4CAA6C,CAC5E,QAAS,CACX,CAAC,EAAG,EAAI,MAAO,CACjB","names":["p","n","y","m","t","u","b","i","l","s","e","r","F","w"],"x_google_ignoreList":[0]}