/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import i from"../../../core/Logger.js";import{clamp as o,deg2rad as s}from"../../../core/mathUtils.js";import{property as r,subclass as n}from"../../../core/accessorSupport/decorators.js";import{earth as a}from"../../../geometry/support/Ellipsoid.js";import{makePiecewiseLinearFunction as l}from"../support/mathUtils.js";let m=class extends e{constructor(t){super(t),this.collision=new h,this.distance=1/0,this.minimumPoiDistance=4,this.tilt=null}get altitude(){return 2===this.mode?null:this._get("altitude")||null}set altitude(t){2!==this.mode?this._set("altitude",t):i.getLogger(this).warn("Altitude constraint is ignored in local scenes")}get mode(){return this.state.viewingMode}clampAltitude(t){return this.altitude?o(t,this.altitude.min,this.altitude.max):t}clampTilt(t,e){if(!this.tilt)return e;const i=this.tilt(t);return o(e,i.min,i.max)}clampDistance(t){return Math.min(t,this.distance)}createDefaultTilt(){return 2===this.mode?this._createDefaultTiltLocal():this._createDefaultTiltGlobal()}createConstantMaxTilt(t){return(e,i=p)=>(i.min=d.min,i.max=t,i)}_createDefaultTiltLocal(){const t=this.collision.enabled?l([[4e3,d.max],[1e4,s(88)],[6e6,s(88)]]):()=>d.max;return(e,i=p)=>(i.min=d.min,i.max=t(e),i)}_createDefaultTiltGlobal(){const t=this.collision.enabled?l([[4e3,d.max],[5e4,s(88)],[6e6,s(88)],[2e7,d.min]]):l([[3e5,d.max],[3e6,s(88)],[6e6,s(88)],[2e7,d.min]]);return(e,i=p)=>(i.min=d.min,i.max=t(e),i)}};function c(t){return{min:-2e5,max:4*t.radius}}t([r()],m.prototype,"altitude",null),t([r({readOnly:!0})],m.prototype,"collision",void 0),t([r()],m.prototype,"distance",void 0),t([r({readOnly:!0})],m.prototype,"minimumPoiDistance",void 0),t([r()],m.prototype,"tilt",void 0),t([r({constructOnly:!0})],m.prototype,"state",void 0),m=t([n("esri.views.3d.state.Constraints")],m);const u=c(a),d={min:s(.5),max:s(179.5)},p={min:0,max:0};let h=class extends e{constructor(){super(...arguments),this.enabled=!0,this.elevationMargin=5}};t([r({type:Boolean})],h.prototype,"enabled",void 0),t([r({type:Number})],h.prototype,"elevationMargin",void 0),h=t([n("esri.views.3d.state.Constraints.CollisionConstraint")],h);export{m as Constraints,d as TiltRange,u as earthAltitudeConstraint};
