chunk-JUWKPBLS.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import {
  2. b
  3. } from "./chunk-2ZSOO377.js";
  4. import {
  5. x
  6. } from "./chunk-YUA3AHKR.js";
  7. import {
  8. j as j2
  9. } from "./chunk-LU5IJZB4.js";
  10. import {
  11. p
  12. } from "./chunk-7IBV2TRE.js";
  13. import {
  14. U
  15. } from "./chunk-DVUG3KID.js";
  16. import {
  17. s as s4
  18. } from "./chunk-FWSQEIAR.js";
  19. import {
  20. F,
  21. N
  22. } from "./chunk-VEGAOVMY.js";
  23. import {
  24. o
  25. } from "./chunk-6T6G6LCQ.js";
  26. import {
  27. r as r2
  28. } from "./chunk-PQFTYGF5.js";
  29. import {
  30. e,
  31. n5 as n,
  32. y3 as y
  33. } from "./chunk-2Z2TG5CU.js";
  34. import {
  35. f,
  36. j,
  37. w
  38. } from "./chunk-V6P2MAQQ.js";
  39. import {
  40. s2,
  41. s3
  42. } from "./chunk-E5O6P5I2.js";
  43. import {
  44. r,
  45. s,
  46. t
  47. } from "./chunk-YXWMMD76.js";
  48. // node_modules/@arcgis/core/layers/mixins/PortalLayer.js
  49. var v = (v2) => {
  50. let U2 = class extends v2 {
  51. constructor() {
  52. super(...arguments), this.resourceReferences = { portalItem: null, paths: [] }, this.userHasEditingPrivileges = true;
  53. }
  54. destroy() {
  55. this.portalItem = s(this.portalItem);
  56. }
  57. set portalItem(t2) {
  58. t2 !== this._get("portalItem") && (this.removeOrigin("portal-item"), this._set("portalItem", t2));
  59. }
  60. readPortalItem(t2, e2, r3) {
  61. if (e2.itemId)
  62. return new x({ id: e2.itemId, portal: r3 && r3.portal });
  63. }
  64. writePortalItem(t2, e2) {
  65. t2 && t2.id && (e2.itemId = t2.id);
  66. }
  67. async loadFromPortal(t2, e2) {
  68. if (this.portalItem && this.portalItem.id)
  69. try {
  70. const r3 = await import("./layersLoader-OZVG5BNX.js");
  71. return f(e2), await r3.load({ instance: this, supportedTypes: t2.supportedTypes, validateItem: t2.validateItem, supportsData: t2.supportsData, layerModuleTypeMap: t2.layerModuleTypeMap }, e2);
  72. } catch (r3) {
  73. throw j(r3) || s2.getLogger(this.declaredClass).warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})
  74. ${r3}`), r3;
  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. var _a;
  82. const r3 = this.url ? (_a = s4) == null ? void 0 : _a.findCredential(this.url) : null;
  83. if (!r3)
  84. return true;
  85. const s5 = P.credential === r3 ? P.user : await this._fetchEditingUser(t2);
  86. return P.credential = r3, P.user = s5, t(s5) || null == s5.privileges || s5.privileges.includes("features:user:edit");
  87. }
  88. async _fetchEditingUser(t2) {
  89. var _a, _b, _c;
  90. const o2 = (_b = (_a = this.portalItem) == null ? void 0 : _a.portal) == null ? void 0 : _b.user;
  91. if (o2)
  92. return o2;
  93. const i = s4.findServerInfo((_c = this.url) != null ? _c : "");
  94. if (!(i == null ? void 0 : i.owningSystemUrl))
  95. return null;
  96. const a = `${i.owningSystemUrl}/sharing/rest`, l = j2.getDefault();
  97. if (l && l.loaded && F(l.restUrl) === F(a))
  98. return l.user;
  99. const n2 = `${a}/community/self`, m = r(t2) ? t2.signal : null, c = await b(U(n2, { authMode: "no-prompt", query: { f: "json" }, signal: m }));
  100. return c.ok ? p.fromJSON(c.value.data) : null;
  101. }
  102. read(t2, e2) {
  103. e2 && (e2.layer = this), super.read(t2, e2);
  104. }
  105. write(t2, e2) {
  106. const r3 = e2 && e2.portal, s5 = this.portalItem && this.portalItem.id && (this.portalItem.portal || j2.getDefault());
  107. return r3 && s5 && !N(s5.restUrl, r3.restUrl) ? (e2.messages && e2.messages.push(new s3("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, { ...e2, layer: this });
  108. }
  109. };
  110. return e([y({ type: x })], U2.prototype, "portalItem", null), e([o("web-document", "portalItem", ["itemId"])], U2.prototype, "readPortalItem", null), e([r2("web-document", "portalItem", { itemId: { type: String } })], U2.prototype, "writePortalItem", null), e([y({ clonable: false })], U2.prototype, "resourceReferences", void 0), e([y({ readOnly: true })], U2.prototype, "userHasEditingPrivileges", void 0), U2 = e([n("esri.layers.mixins.PortalLayer")], U2), U2;
  111. };
  112. var P = { credential: null, user: null };
  113. export {
  114. v
  115. };
  116. //# sourceMappingURL=chunk-JUWKPBLS.js.map