/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../core/Accessor","../../core/reactiveUtils","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","../../chunks/vec2","../../chunks/vec2f64","./viewpointUtils","./ViewState"],(function(t,e,o,i,r,n,s,p,a,c,d,l,u){"use strict";var h,_;let y=h=function(e){function o(){var t;return(t=e.apply(this,arguments)||this).left=0,t.top=0,t.right=0,t.bottom=0,t}return t._inheritsLoose(o,e),o.prototype.clone=function(){return new h({left:this.left,top:this.top,right:this.right,bottom:this.bottom})},o}(o);e.__decorate([r.property()],y.prototype,"left",void 0),e.__decorate([r.property()],y.prototype,"top",void 0),e.__decorate([r.property()],y.prototype,"right",void 0),e.__decorate([r.property()],y.prototype,"bottom",void 0),y=h=e.__decorate([a.subclass("esri.views.2d.PaddedViewState.Padding")],y);let w=_=function(e){function o(...t){var o;return(o=e.call(this,...t)||this).paddedViewState=new u,o._updateContent=(()=>{const t=d.create();return()=>{const e=o._get("size"),i=o._get("padding");if(!e||!i)return;const r=o.paddedViewState;c.set(t,i.left+i.right,i.top+i.bottom),c.subtract(t,e,t),c.copy(r.size,t);const n=r.viewpoint;n&&(o.viewpoint=n)}})(),o.own(i.watch((()=>[o.size,o.padding]),(()=>o._updateContent()),i.sync)),o.padding=new y,o.size=[0,0],o}return t._inheritsLoose(o,e),o.prototype.clone=function(){return new _({padding:this.padding.clone(),size:this.size.slice(),viewpoint:this.paddedViewState.viewpoint.clone(),pixelRatio:this.pixelRatio})},t._createClass(o,[{key:"padding",set:function(t){this._set("padding",t||new y)}},{key:"viewpoint",set:function(t){if(t){const e=t.clone();this.paddedViewState.viewpoint=t,l.addPadding(e,t,this._get("size"),this._get("padding"));const o=this._viewpoint2D,i=e.targetGeometry;o.center[0]=i.x,o.center[1]=i.y,o.rotation=e.rotation,o.scale=e.scale,o.spatialReference=i.spatialReference,this._update()}}}]),o}(u);e.__decorate([r.property()],w.prototype,"paddedViewState",void 0),e.__decorate([r.property({type:y})],w.prototype,"padding",null),e.__decorate([r.property()],w.prototype,"viewpoint",null),w=_=e.__decorate([a.subclass("esri.views.2d.PaddedViewState")],w);return w}));
