123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- import {
- b
- } from "./chunk-EGZW6HC3.js";
- import {
- B
- } from "./chunk-4NKD334K.js";
- import {
- p
- } from "./chunk-65K7LC56.js";
- import {
- a
- } from "./chunk-WJ3OEUD3.js";
- import {
- U
- } from "./chunk-VNFRAYHO.js";
- import {
- n as n2
- } from "./chunk-R5IG2D6H.js";
- import {
- F,
- N
- } from "./chunk-VBRY5KJM.js";
- import {
- o
- } from "./chunk-ECW2QABR.js";
- import {
- r as r2
- } from "./chunk-MRJEICT6.js";
- import {
- d,
- e,
- n2 as n
- } from "./chunk-Y3WMVFTW.js";
- import {
- f,
- g,
- w
- } from "./chunk-ULGDPLM2.js";
- import {
- s,
- s3 as s2
- } from "./chunk-EMJ4ZSM2.js";
- import {
- r,
- t
- } from "./chunk-GZT4BVFP.js";
- // node_modules/@arcgis/core/layers/mixins/PortalLayer.js
- var w2 = s.getLogger("esri.layers.mixins.PortalLayer");
- var v = (i) => {
- let v2 = class extends i {
- constructor() {
- super(...arguments), this.resourceReferences = { portalItem: null, paths: [] }, this.userHasEditingPrivileges = true;
- }
- destroy() {
- this.portalItem?.destroy(), this.portalItem = null;
- }
- set portalItem(t2) {
- t2 !== this._get("portalItem") && (this.removeOrigin("portal-item"), this._set("portalItem", t2));
- }
- readPortalItem(t2, r3, e2) {
- if (r3.itemId)
- return new b({ id: r3.itemId, portal: e2 && e2.portal });
- }
- writePortalItem(t2, r3) {
- t2 && t2.id && (r3.itemId = t2.id);
- }
- async loadFromPortal(t2, r3) {
- if (this.portalItem && this.portalItem.id)
- try {
- const e2 = await import("./layersLoader-YJ5XBY7K.js");
- return f(r3), await e2.load({ instance: this, supportedTypes: t2.supportedTypes, validateItem: t2.validateItem, supportsData: t2.supportsData }, r3);
- } catch (e2) {
- throw g(e2) || w2.warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})
- ${e2}`), e2;
- }
- }
- async finishLoadEditablePortalLayer(t2) {
- this._set("userHasEditingPrivileges", await this._fetchUserHasEditingPrivileges(t2).catch((t3) => (w(t3), true)));
- }
- async _fetchUserHasEditingPrivileges(t2) {
- const e2 = this.url ? n2?.findCredential(this.url) : null;
- if (!e2)
- return true;
- const s3 = P.credential === e2 ? P.user : await this._fetchEditingUser(t2);
- return P.credential = e2, P.user = s3, t(s3) || s3.privileges == null || s3.privileges.includes("features:user:edit");
- }
- async _fetchEditingUser(t2) {
- const o2 = this.portalItem?.portal?.user;
- if (o2)
- return o2;
- const i2 = n2.findServerInfo(this.url);
- if (!i2?.owningSystemUrl)
- return null;
- const a2 = `${i2.owningSystemUrl}/sharing/rest`, p2 = B.getDefault();
- if (p2 && p2.loaded && F(p2.restUrl) === F(a2))
- return p2.user;
- const n3 = `${a2}/community/self`, m = r(t2) ? t2.signal : null, u = await a(U(n3, { authMode: "no-prompt", query: { f: "json" }, signal: m }));
- return u.ok ? p.fromJSON(u.value.data) : null;
- }
- read(t2, r3) {
- r3 && (r3.layer = this), super.read(t2, r3);
- }
- write(t2, r3) {
- const e2 = r3 && r3.portal, s3 = this.portalItem && this.portalItem.id && (this.portalItem.portal || B.getDefault());
- 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 });
- }
- };
- 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;
- };
- var P = { credential: null, user: null };
- export {
- v
- };
- //# sourceMappingURL=chunk-KHA63LLS.js.map
|