/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import e from"../../../core/Logger.js";import{equals as t,isGeographic as r,isWebMercator as i,isWGS84 as s}from"../../../geometry/support/spatialReferenceUtils.js";import{getGlbFormatId as o}from"../../../layers/support/infoFor3D.js";const n="esri.views.layers.support.editableLayerViews";function a(a,d){const{associatedLayer:c}=a,l=c?.infoFor3D;if(!!!l)return!1;const g=o(l);if(!(null!=g&&l.queryFormats.includes(g)))return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because it does not support GLB queries.`),!1;const p=a.spatialReference,u=c.spatialReference;if(!t(p,u))return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because its spatial reference (wkid:${p.wkid}) is different from its associated FeatureLayer's spatial reference (wkid:${u.wkid}).`),!1;const f=c.sourceJSON?.sourceSpatialReference;if(!(null==f||t(f,u)))return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because the spatial reference of its associated FeatureLayer's service (wkid:${u.wkid}) is different from its source spatial reference (wkid:${f.wkid}).`),!1;const{view:w}=d;if(d.destroyed||null==w)return!1;const y=w.spatialReference,{viewingMode:m}=w.state,$=r(p),L=1===m;if($&&!L)return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits in local viewing mode because its spatial reference (wkid:${p.wkid}) is geographic. Please consider changing the viewing mode to global.`),!1;if(!$&&L)return e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits in global viewing mode because its spatial reference (wkid:${p.wkid}) is projected. Please consider changing the viewing mode to local.`),!1;return!!(t(p,y)||L&&i(y)&&s(p))||(e.getLogger(n).warnOnce(`SceneLayer (${a.title??"Untitled layer"}, ${a.id}) does not support geometry edits because its spatial reference (wkid:${p.wkid}) does not match the view spatial reference (wkid:${y.wkid}).`),!1)}export{a as isGeometryEditableSceneLayer};
