// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.6/esri/copyright.txt for details.
//>>built
define("require exports ../../core/tsSupport/declareExtendsHelper ../../core/tsSupport/decorateHelper ../../core/accessorSupport/decorators ./viewpointUtils ./ViewState ./libs/gl-matrix/vec2 ./libs/gl-matrix/mat2d ./libs/gl-matrix/common ../../core/Accessor".split(" "),function(r,t,k,c,d,l,m,e,g,p,q){var h=function(e){function a(){var b=null!==e&&e.apply(this,arguments)||this;b.left=0;b.top=0;b.right=0;b.bottom=0;return b}k(a,e);c([d.property()],a.prototype,"left",void 0);c([d.property()],a.prototype,
"top",void 0);c([d.property()],a.prototype,"right",void 0);c([d.property()],a.prototype,"bottom",void 0);return a=c([d.subclass("esri.views.2d.PaddedViewState.Padding")],a)}(d.declared(q));return function(n){function a(){for(var b=[],a=0;a<arguments.length;a++)b[a]=arguments[a];b=n.apply(this,b)||this;b.content=new m;b.padding=new h;b.size=e.fromValues(0,0);return b}k(a,n);Object.defineProperty(a.prototype,"clipRect",{get:function(){var b=this.worldScreenWidth;if(!b)return null;var a=p.toRadian(this.rotation),
d=this.width*Math.abs(Math.cos(a))+this.height*Math.abs(Math.sin(a));if(b>d)return null;var c=e.clone(this.screenCenter),f=g.fromTranslation(g.create(),c);g.rotate(f,f,a);e.negate(c,c);g.translate(f,f,c);e.transformMat2d(c,this.paddedScreenCenter,f);return{top:-Math.round(d),left:Math.round(c[0]-.5*b),right:Math.round(c[0]+.5*b),bottom:+Math.round(d)}},enumerable:!0,configurable:!0});Object.defineProperty(a.prototype,"padding",{set:function(b){this._set("padding",b||new h);this._updateContent()},
enumerable:!0,configurable:!0});Object.defineProperty(a.prototype,"size",{set:function(b){this._set("size",b);this._updateContent()},enumerable:!0,configurable:!0});Object.defineProperty(a.prototype,"paddedScreenCenter",{get:function(){var b=this.content.size,a=this.padding,b=e.scale(e.create(),b,.5);b[0]+=a.left;b[1]+=a.top;return b},enumerable:!0,configurable:!0});Object.defineProperty(a.prototype,"viewpoint",{set:function(b){var a=b.clone();this.content.viewpoint=b;l.addPadding(a,b,this._get("size"),
this._get("padding"));this._set("viewpoint",l.addPadding(a.clone(),b,this._get("size"),this._get("padding")))},enumerable:!0,configurable:!0});a.prototype._updateContent=function(){var b=e.create(),a=this._get("size"),c=this._get("padding");if(a&&c){var d=this.content;e.set(b,c.left+c.right,c.top+c.bottom);e.subtract(b,a,b);d.size=b;if(b=d.viewpoint)this.viewpoint=b}};c([d.shared({transform:{dependsOn:["padding"]}})],a.prototype,"properties",void 0);c([d.property({dependsOn:["worldScreenWidth","rotation",
"paddedScreenCenter","screenCenter"],readOnly:!0})],a.prototype,"clipRect",null);c([d.property()],a.prototype,"content",void 0);c([d.property({type:h})],a.prototype,"padding",null);c([d.property()],a.prototype,"size",null);c([d.property({dependsOn:["size","padding"],readOnly:!0})],a.prototype,"paddedScreenCenter",null);c([d.property()],a.prototype,"viewpoint",null);return a=c([d.subclass("esri.views.2d.PaddedViewState")],a)}(d.declared(m))});