/*
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","../../request","../../core/Error","../../core/Logger","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","./MediaElementBase"],(function(e,t,s,o,r,n,i,a,c,l,d){"use strict";let p=function(t){function n(e){var s;return(s=t.call(this,e)||this).content=null,s.type="image",s.image=null,s}return e._inheritsLoose(n,t),n.prototype.load=function(){const e=this.image;if("string"==typeof e){const t=s(e,{responseType:"image"}).then((({data:e})=>{this._set("content",e)}));this.addResolvingPromise(t)}else if(e instanceof HTMLImageElement){const t=e.decode().then((()=>{this._set("content",e)}));this.addResolvingPromise(t)}else e?this._set("content",e):this.addResolvingPromise(Promise.reject(new o("image-element:invalid-image-type","Invalid image type",{image:e})));return Promise.resolve(this)},e._createClass(n,[{key:"image",set:function(e){"not-loaded"===this.loadStatus?this._set("image",e):r.getLogger(this.declaredClass).error("#image","image cannot be changed after the element is loaded.")}}]),n}(d);t.__decorate([n.property({readOnly:!0})],p.prototype,"content",void 0),t.__decorate([n.property()],p.prototype,"image",null),p=t.__decorate([l.subclass("esri.layers.support.ImageElement")],p);return p}));
