/*
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","../TimeExtent","../Viewpoint","../core/Error","../core/Identifiable","../core/JSONSupport","../core/lang","../core/Logger","../core/maybe","../core/accessorSupport/decorators/property","../core/accessorSupport/decorators/cast","../core/accessorSupport/decorators/reader","../core/accessorSupport/decorators/subclass","../core/accessorSupport/decorators/writer","../core/accessorSupport/ensureType","../webdoc/support/SlideThumbnail"],(function(e,t,o,r,n,i,s,p,a,c,l,u,m,d,w,y,h){"use strict";var b;const S="esri.webmap.Bookmark",_=a.getLogger(S);let v=b=function(t){function o(e){var o;return(o=t.call(this,e)||this).name=null,o.thumbnail=new h.SlideThumbnail,o.timeExtent=null,o}e._inheritsLoose(o,t);var i=o.prototype;return i.castThumbnail=function(e){return"string"==typeof e?new h.SlideThumbnail({url:e}):y.ensureType(h.SlideThumbnail,e)},i.readViewpoint=function(e,t){const{extent:o,viewpoint:n}=t;return r.fromJSON(n||{targetGeometry:o})},i.writeViewpoint=function(e,t,o,r){if(!e)return;const{targetGeometry:i}=e;if(c.isSome(i)&&"extent"!==i.type){const e="Bookmark.viewpoint cannot be written to JSON when the viewpoint's targetGeometry is not an extent.";null!=r&&r.messages?r.messages.push(new n("property:unsupported",e)):_.error(e)}else c.isSome(i)&&(t.extent=i.toJSON()),t[o]=e.toJSON()},i.clone=function(){return new b(p.clone({name:this.name,thumbnail:this.thumbnail,timeExtent:this.timeExtent,viewpoint:this.viewpoint}))},e._createClass(o,[{key:"viewpoint",set:function(e){const{targetGeometry:t,scale:o}=e;c.isSome(t)&&"point"===t.type&&c.isNone(o)&&_.warn("Bookmark.viewpoint should include 'scale' when its targetGeometry is a point.",e),this._set("viewpoint",e)}}]),o}(i.IdentifiableMixin(s.JSONSupport));t.__decorate([l.property({type:String,nonNullable:!0,json:{write:{isRequired:!0}}})],v.prototype,"name",void 0),t.__decorate([l.property({type:h.SlideThumbnail,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.url)})}}})],v.prototype,"thumbnail",void 0),t.__decorate([u.cast("thumbnail")],v.prototype,"castThumbnail",null),t.__decorate([l.property({type:o,json:{write:!0}})],v.prototype,"timeExtent",void 0),t.__decorate([l.property({type:r,nonNullable:!0,json:{write:!0}})],v.prototype,"viewpoint",null),t.__decorate([m.reader("viewpoint",["extent","viewpoint"])],v.prototype,"readViewpoint",null),t.__decorate([w.writer("viewpoint")],v.prototype,"writeViewpoint",null),v=b=t.__decorate([d.subclass(S)],v);return v}));
