chunk-KHA63LLS.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import {
  2. b
  3. } from "./chunk-EGZW6HC3.js";
  4. import {
  5. B
  6. } from "./chunk-4NKD334K.js";
  7. import {
  8. p
  9. } from "./chunk-65K7LC56.js";
  10. import {
  11. a
  12. } from "./chunk-WJ3OEUD3.js";
  13. import {
  14. U
  15. } from "./chunk-VNFRAYHO.js";
  16. import {
  17. n as n2
  18. } from "./chunk-R5IG2D6H.js";
  19. import {
  20. F,
  21. N
  22. } from "./chunk-VBRY5KJM.js";
  23. import {
  24. o
  25. } from "./chunk-ECW2QABR.js";
  26. import {
  27. r as r2
  28. } from "./chunk-MRJEICT6.js";
  29. import {
  30. d,
  31. e,
  32. n2 as n
  33. } from "./chunk-Y3WMVFTW.js";
  34. import {
  35. f,
  36. g,
  37. w
  38. } from "./chunk-ULGDPLM2.js";
  39. import {
  40. s,
  41. s3 as s2
  42. } from "./chunk-EMJ4ZSM2.js";
  43. import {
  44. r,
  45. t
  46. } from "./chunk-GZT4BVFP.js";
  47. // node_modules/@arcgis/core/layers/mixins/PortalLayer.js
  48. var w2 = s.getLogger("esri.layers.mixins.PortalLayer");
  49. var v = (i) => {
  50. let v2 = class extends i {
  51. constructor() {
  52. super(...arguments), this.resourceReferences = { portalItem: null, paths: [] }, this.userHasEditingPrivileges = true;
  53. }
  54. destroy() {
  55. this.portalItem?.destroy(), this.portalItem = null;
  56. }
  57. set portalItem(t2) {
  58. t2 !== this._get("portalItem") && (this.removeOrigin("portal-item"), this._set("portalItem", t2));
  59. }
  60. readPortalItem(t2, r3, e2) {
  61. if (r3.itemId)
  62. return new b({ id: r3.itemId, portal: e2 && e2.portal });
  63. }
  64. writePortalItem(t2, r3) {
  65. t2 && t2.id && (r3.itemId = t2.id);
  66. }
  67. async loadFromPortal(t2, r3) {
  68. if (this.portalItem && this.portalItem.id)
  69. try {
  70. const e2 = await import("./layersLoader-YJ5XBY7K.js");
  71. return f(r3), await e2.load({ instance: this, supportedTypes: t2.supportedTypes, validateItem: t2.validateItem, supportsData: t2.supportsData }, r3);
  72. } catch (e2) {
  73. throw g(e2) || w2.warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})
  74. ${e2}`), e2;
  75. }
  76. }
  77. async finishLoadEditablePortalLayer(t2) {
  78. this._set("userHasEditingPrivileges", await this._fetchUserHasEditingPrivileges(t2).catch((t3) => (w(t3), true)));
  79. }
  80. async _fetchUserHasEditingPrivileges(t2) {
  81. const e2 = this.url ? n2?.findCredential(this.url) : null;
  82. if (!e2)
  83. return true;
  84. const s3 = P.credential === e2 ? P.user : await this._fetchEditingUser(t2);
  85. return P.credential = e2, P.user = s3, t(s3) || s3.privileges == null || s3.privileges.includes("features:user:edit");
  86. }
  87. async _fetchEditingUser(t2) {
  88. const o2 = this.portalItem?.portal?.user;
  89. if (o2)
  90. return o2;
  91. const i2 = n2.findServerInfo(this.url);
  92. if (!i2?.owningSystemUrl)
  93. return null;
  94. const a2 = `${i2.owningSystemUrl}/sharing/rest`, p2 = B.getDefault();
  95. if (p2 && p2.loaded && F(p2.restUrl) === F(a2))
  96. return p2.user;
  97. const n3 = `${a2}/community/self`, m = r(t2) ? t2.signal : null, u = await a(U(n3, { authMode: "no-prompt", query: { f: "json" }, signal: m }));
  98. return u.ok ? p.fromJSON(u.value.data) : null;
  99. }
  100. read(t2, r3) {
  101. r3 && (r3.layer = this), super.read(t2, r3);
  102. }
  103. write(t2, r3) {
  104. const e2 = r3 && r3.portal, s3 = this.portalItem && this.portalItem.id && (this.portalItem.portal || B.getDefault());
  105. return e2 && s3 && !N(s3.restUrl, e2.restUrl) ? (r3.messages && r3.messages.push(new s2("layer:cross-portal", `The layer '${this.title} (${this.id})' cannot be persisted because it refers to an item on a different portal than the one being saved to. To save, set layer.portalItem to null or save to the same portal as the item associated with the layer`, { layer: this })), null) : super.write(t2, { ...r3, layer: this });
  106. }
  107. };
  108. return e([d({ type: b })], v2.prototype, "portalItem", null), e([o("web-document", "portalItem", ["itemId"])], v2.prototype, "readPortalItem", null), e([r2("web-document", "portalItem", { itemId: { type: String } })], v2.prototype, "writePortalItem", null), e([d({ clonable: false })], v2.prototype, "resourceReferences", void 0), e([d({ readOnly: true })], v2.prototype, "userHasEditingPrivileges", void 0), v2 = e([n("esri.layers.mixins.PortalLayer")], v2), v2;
  109. };
  110. var P = { credential: null, user: null };
  111. export {
  112. v
  113. };
  114. //# sourceMappingURL=chunk-KHA63LLS.js.map