/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/Accessor","../../../core/Logger","../../../core/maybe","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../../geometry/projection","../../../geometry/support/contains","../../../geometry/support/near"],(function(e,t,r,o,n,s,i,a,c,l,y,p,u,m){"use strict";var g;const d=n.getLogger("esri.views.MapView");e.GeometryConstraint=g=function(e){function r(t){var r;return(r=e.call(this,t)||this).geometry=null,r.spatialReference=null,r}t._inheritsLoose(r,e);var o=r.prototype;return o.constrain=function(e,t){if(s.isNone(this.normalizedGeometry))return e;const r=e.targetGeometry;if("extent"===this.normalizedGeometry.type?u.extentContainsPoint(this.normalizedGeometry,r):u.polygonContainsPoint(this.normalizedGeometry,r))return e;const{coordinate:o}=m.nearestCoordinate(this.normalizedGeometry,r);return o?(e.targetGeometry=o,e):e},o.clone=function(){var e,t;return new g({geometry:null==(e=this.geometry)?void 0:e.clone(),spatialReference:null==(t=this.spatialReference)?void 0:t.clone()})},t._createClass(r,[{key:"normalizedGeometry",get:function(){if(s.isNone(this.geometry)||!this.spatialReference)return null;if(!this.spatialReference.equals(this.geometry.spatialReference))try{return p.project(this.geometry,this.spatialReference)}catch(e){return d.error("#constraints.geometry","could not project the geometry to the view's spatial reference",{geometry:this.geometry,spatialReference:this.spatialReference,error:e}),null}return this.geometry}}]),r}(o),r.__decorate([i.property({constructOnly:!0})],e.GeometryConstraint.prototype,"geometry",void 0),r.__decorate([i.property({readOnly:!0})],e.GeometryConstraint.prototype,"normalizedGeometry",null),r.__decorate([i.property({constructOnly:!0})],e.GeometryConstraint.prototype,"spatialReference",void 0),e.GeometryConstraint=g=r.__decorate([y.subclass("esri.views.2d.constraints.GeometryConstraint")],e.GeometryConstraint),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
