123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import {
- b
- } from "./chunk-2ZSOO377.js";
- import {
- x
- } from "./chunk-YUA3AHKR.js";
- import {
- j as j2
- } from "./chunk-LU5IJZB4.js";
- import {
- p
- } from "./chunk-7IBV2TRE.js";
- import {
- U
- } from "./chunk-DVUG3KID.js";
- import {
- s as s4
- } from "./chunk-FWSQEIAR.js";
- import {
- F,
- N
- } from "./chunk-VEGAOVMY.js";
- import {
- o
- } from "./chunk-6T6G6LCQ.js";
- import {
- r as r2
- } from "./chunk-PQFTYGF5.js";
- import {
- e,
- n5 as n,
- y3 as y
- } from "./chunk-2Z2TG5CU.js";
- import {
- f,
- j,
- w
- } from "./chunk-V6P2MAQQ.js";
- import {
- s2,
- s3
- } from "./chunk-E5O6P5I2.js";
- import {
- r,
- s,
- t
- } from "./chunk-YXWMMD76.js";
- // node_modules/@arcgis/core/layers/mixins/PortalLayer.js
- var v = (v2) => {
- let U2 = class extends v2 {
- constructor() {
- super(...arguments), this.resourceReferences = { portalItem: null, paths: [] }, this.userHasEditingPrivileges = true;
- }
- destroy() {
- this.portalItem = s(this.portalItem);
- }
- set portalItem(t2) {
- t2 !== this._get("portalItem") && (this.removeOrigin("portal-item"), this._set("portalItem", t2));
- }
- readPortalItem(t2, e2, r3) {
- if (e2.itemId)
- return new x({ id: e2.itemId, portal: r3 && r3.portal });
- }
- writePortalItem(t2, e2) {
- t2 && t2.id && (e2.itemId = t2.id);
- }
- async loadFromPortal(t2, e2) {
- if (this.portalItem && this.portalItem.id)
- try {
- const r3 = await import("./layersLoader-OZVG5BNX.js");
- return f(e2), await r3.load({ instance: this, supportedTypes: t2.supportedTypes, validateItem: t2.validateItem, supportsData: t2.supportsData, layerModuleTypeMap: t2.layerModuleTypeMap }, e2);
- } catch (r3) {
- throw j(r3) || s2.getLogger(this.declaredClass).warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})
- ${r3}`), r3;
- }
- }
- async finishLoadEditablePortalLayer(t2) {
- this._set("userHasEditingPrivileges", await this._fetchUserHasEditingPrivileges(t2).catch((t3) => (w(t3), true)));
- }
- async _fetchUserHasEditingPrivileges(t2) {
- var _a;
- const r3 = this.url ? (_a = s4) == null ? void 0 : _a.findCredential(this.url) : null;
- if (!r3)
- return true;
- const s5 = P.credential === r3 ? P.user : await this._fetchEditingUser(t2);
- return P.credential = r3, P.user = s5, t(s5) || null == s5.privileges || s5.privileges.includes("features:user:edit");
- }
- async _fetchEditingUser(t2) {
- var _a, _b, _c;
- const o2 = (_b = (_a = this.portalItem) == null ? void 0 : _a.portal) == null ? void 0 : _b.user;
- if (o2)
- return o2;
- const i = s4.findServerInfo((_c = this.url) != null ? _c : "");
- if (!(i == null ? void 0 : i.owningSystemUrl))
- return null;
- const a = `${i.owningSystemUrl}/sharing/rest`, l = j2.getDefault();
- if (l && l.loaded && F(l.restUrl) === F(a))
- return l.user;
- const n2 = `${a}/community/self`, m = r(t2) ? t2.signal : null, c = await b(U(n2, { authMode: "no-prompt", query: { f: "json" }, signal: m }));
- return c.ok ? p.fromJSON(c.value.data) : null;
- }
- read(t2, e2) {
- e2 && (e2.layer = this), super.read(t2, e2);
- }
- write(t2, e2) {
- const r3 = e2 && e2.portal, s5 = this.portalItem && this.portalItem.id && (this.portalItem.portal || j2.getDefault());
- 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 });
- }
- };
- 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;
- };
- var P = { credential: null, user: null };
- export {
- v
- };
- //# sourceMappingURL=chunk-JUWKPBLS.js.map
|