/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as e}from"tslib";import{Loadable as r}from"../../core/Loadable.js";import o from"../../core/Logger.js";import{MultiOriginJSONSupportMixin as t}from"../../core/MultiOriginJSONSupport.js";import{NumericIdentifiableMixin as n}from"../../core/NumericIdentifiable.js";import{property as i,subclass as s}from"../../core/accessorSupport/decorators.js";import c from"./ControlPointsGeoreference.js";import{toControlPointsGeoreference as p,mediaGeoreferenceProperty as l}from"./mediaUtils.js";import{addPropertyUnsupportedError as f}from"../../webdoc/support/unsupportedErrors.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{writer as u}from"../../core/accessorSupport/decorators/writer.js";let d=class extends(n(t(r))){constructor(e){super(e),this.georeference=null,this.opacity=1}readGeoreference(e){return c.fromJSON(e)}writeGeoreference(e,r,t,n){const i=n?.resources?.pendingOperations,s=()=>{const i=p(this.georeference,this.contentWidth,this.contentHeight);if(i){if("control-points"!==e.type&&o.getLogger(this).warn(`only georeference of type 'control-points' may be persisted. The georeference of type '${e.type}' has been automatically converted.`),4!==i.controlPoints?.length)return void f(n,"ControlPointsGeoreference.controlPoints","only 'control-points' georeference with 4 control points may be persisted.");r[t]=i.write({},n)}};if("control-points"!==e.type&&!this.loaded&&i)return r[t]={},void i.push(this.load().then(s));s()}get contentWidth(){return 0}get contentHeight(){return 0}toSource(e){const{georeference:r,contentWidth:o,contentHeight:t}=this;if(null==e||null==r||0===o||0===t)return null;const n=r.toSourceNormalized(e);return null==n?null:(n.x*=o,n.y*=t,n)}};e([i(l)],d.prototype,"georeference",void 0),e([a("georeference")],d.prototype,"readGeoreference",null),e([u("georeference")],d.prototype,"writeGeoreference",null),e([i({json:{read:!1,write:!1}})],d.prototype,"opacity",void 0),d=e([s("esri.layers.support.MediaElementBase")],d);export{d as default};
