/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as e}from"tslib";import{EventedMixin as t}from"../../../core/Evented.js";import{property as o,subclass as n}from"../../../core/accessorSupport/decorators.js";import i from"../../../webscene/SunLighting.js";var s;let a=s=class extends(t(i)){static calculateTimezoneOffset({hours:e,minutes:t,seconds:o}){return Math.round(e+t/60+o/3600)}constructor(e){super(e),this.cameraTrackingEnabled=!0,this.positionTimezoneInfo={hours:0,minutes:0,seconds:0,autoUpdated:!0},this.type="sun";const t=(new Date).getFullYear(),o=new Date("March 15, "+t+" 12:00:00 UTC");this._set("defaultDate",o),this._set("date",o)}get defaultDate(){return new Date(this._get("defaultDate"))}static fromWebsceneLighting(e){return new s(e.cloneConstructProperties())}set defaultDate(e){const t=this._get("date")===this._get("defaultDate");e=new Date(e),this._set("defaultDate",e),t&&this._set("date",e)}set date(e){null!=e&&(this.positionTimezoneInfo.autoUpdated=!1,this._set("date",new Date(e)))}autoUpdate(e,t){const o=s.calculateTimezoneOffset(this.positionTimezoneInfo);this.positionTimezoneInfo.hours=t.hours,this.positionTimezoneInfo.minutes=t.minutes,this.positionTimezoneInfo.seconds=t.seconds;let n=null;null!=e&&(this.positionTimezoneInfo.autoUpdated=!0,isNaN(e.getTime())?(n=this.defaultDate.getTime(),this._set("date",this.defaultDate)):(n=this.date&&this.date.getTime(),this._set("date",new Date(e))));const i=s.calculateTimezoneOffset(this.positionTimezoneInfo);if(o!==i&&(r.target=this,r.timezoneOffset=i,this.emit("timezone-will-change",r),r.target=null),null!=e)return isNaN(e.getTime())||n!==e.getTime()}clone(){const e=this._get("date")===this._get("defaultDate"),t=new s({...this.cloneConstructProperties(),defaultDate:this.defaultDate,cameraTrackingEnabled:this.cameraTrackingEnabled});return e&&t._set("date",t._get("defaultDate")),t.positionTimezoneInfo.autoUpdated=this.positionTimezoneInfo.autoUpdated,t.positionTimezoneInfo.hours=this.positionTimezoneInfo.hours,t.positionTimezoneInfo.minutes=this.positionTimezoneInfo.minutes,t.positionTimezoneInfo.seconds=this.positionTimezoneInfo.seconds,t}cloneWithWebsceneLighting(e){const t=this.clone();return null!=e.date&&(t.date=e.date),t.directShadowsEnabled=e.directShadowsEnabled,t.glow=e.glow?.clone(),t.displayUTCOffset=e.displayUTCOffset,t}cloneNonPersistentConstructProperties(){return{cameraTrackingEnabled:this.cameraTrackingEnabled}}};e([o({type:Boolean})],a.prototype,"cameraTrackingEnabled",void 0),e([o({type:Date})],a.prototype,"defaultDate",null),e([o({type:Date})],a.prototype,"date",null),e([o({readOnly:!0,type:["sun"],json:{write:!0}})],a.prototype,"type",void 0),a=s=e([n("esri.views.3d.environment.SunLighting")],a);const r={target:null,timezoneOffset:0},d=a;export{d as default};
