/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","../chunks/_rollupPluginBabelHelpers","../chunks/tslib.es6","../core/Logger","../core/maybe","../core/promiseUtils","../core/accessorSupport/decorators/property","../core/arrayUtils","../core/has","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/enumeration","../core/accessorSupport/decorators/subclass","../portal/Portal","../chunks/persistableUrlUtils","./Symbol","./support/Thumbnail"],(function(e,t,r,o,l,s,n,c,i,a,p,y,u,h,m,b){"use strict";var d;const f=o.getLogger("esri.symbols.WebStyleSymbol");let S=d=function(e){function r(t){var r;return(r=e.call(this,t)||this).styleName=null,r.portal=null,r.styleUrl=null,r.thumbnail=null,r.name=null,r.type="web-style",r}t._inheritsLoose(r,e);var o=r.prototype;return o.read=function(t,r){this.portal=r?r.portal:void 0,e.prototype.read.call(this,t,r)},o.clone=function(){return new d({name:this.name,styleUrl:this.styleUrl,styleName:this.styleName,portal:this.portal})},o.fetchSymbol=function(e){return this._fetchSymbol("webRef",e)},o.fetchCIMSymbol=function(e){return this._fetchSymbol("cimRef",e)},o._fetchSymbol=function(){var e=t._asyncToGenerator((function*(e,t){const r=l.isSome(t)?t.cache:null,o=r?this.fetchCacheKey:null;if(l.isSome(r)){const e=r.get(o);if(e)return e.clone()}const n=yield _();s.throwIfAborted(t);const c=n.resolveWebStyleSymbol(this,{portal:this.portal},e,t);c.catch((e=>{f.error("#fetchSymbol()","Failed to create symbol from style",e)}));const i=yield c;return"webRef"===e&&"point-3d"===i.type||"cimRef"===e&&"cim"===i.type?(l.isSome(r)&&r.set(o,i.clone()),i):null}));function r(t,r){return e.apply(this,arguments)}return r}(),t._createClass(r,[{key:"fetchCacheKey",get:function(){const e=l.isSome(this.portal)?this.portal:u.getDefault(),t=e.user?e.user.username:null;return`${this.styleName}:${this.styleUrl}:${this.name}:${t}:${e.url}`}}]),r}(m);function _(){return new Promise(((t,r)=>e(["./support/webStyleSymbolUtils"],t,r)))}r.__decorate([n.property({json:{write:!1}})],S.prototype,"color",void 0),r.__decorate([n.property({type:String,json:{write:!0}})],S.prototype,"styleName",void 0),r.__decorate([n.property({type:u,json:{write:!1}})],S.prototype,"portal",void 0),r.__decorate([n.property({type:String,json:{read:h.read,write:h.write}})],S.prototype,"styleUrl",void 0),r.__decorate([n.property({type:b.Thumbnail,json:{read:!1}})],S.prototype,"thumbnail",void 0),r.__decorate([n.property({type:String,json:{write:!0}})],S.prototype,"name",void 0),r.__decorate([p.enumeration({styleSymbolReference:"web-style"},{readOnly:!0})],S.prototype,"type",void 0),r.__decorate([n.property()],S.prototype,"fetchCacheKey",null),S=d=r.__decorate([y.subclass("esri.symbols.WebStyleSymbol")],S);return S}));
