@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.61 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Error.js";import o from"../core/Logger.js";import{throwIfAborted as r}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{enumeration as l}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import a from"../portal/Portal.js";import{r as p,w as c}from"../chunks/persistableUrlUtils.js";import m from"./Symbol.js";import{Thumbnail as n}from"./support/Thumbnail.js";var y;let h=y=class extends m{constructor(t){super(t),this.color=null,this.styleName=null,this.portal=null,this.styleUrl=null,this.thumbnail=null,this.name=null,this.type="web-style"}get _fetchCacheKey(){const t=null!=this.portal?this.portal:a.getDefault(),e=t.user?t.user.username:null;return`${this.styleName}:${this.styleUrl}:${this.name}:${e}:${t.url}`}read(t,e){this.portal=e?.portal,super.read(t,e)}clone(){return new y({name:this.name,styleUrl:this.styleUrl,styleName:this.styleName,portal:this.portal})}fetchSymbol(t){const e=t&&"acceptedFormats"in t?t.acceptedFormats:["web"];return this._fetchSymbol({...t,acceptedFormats:e})}async fetchCIMSymbol(t){const o=await this.fetchSymbol({...t,acceptedFormats:["cim"]});if("cim"!==o?.type)throw new e("webstylesymbol:fetchCIMSymbol","Resolved web style symbol is not of type 'cim'");return o}async _fetchSymbol(t){const e=null!=t?t.cache:null,s=e?this._fetchCacheKey:null;if(null!=e){const t=s&&e.get(s);if(t)return t.clone()}const{resolveWebStyleSymbol:l}=await import("./support/webStyleSymbolUtils.js");r(t);const i=l(this,{portal:this.portal},t);i.catch((t=>{o.getLogger(this).error("#fetchSymbol()","Failed to create symbol from style",t)}));const a=await i;return null!=e&&e.set(s,a.clone()),a}};t([s({json:{write:!1}})],h.prototype,"color",void 0),t([s({type:String,json:{write:!0}})],h.prototype,"styleName",void 0),t([s({type:a,json:{write:!1}})],h.prototype,"portal",void 0),t([s({type:String,json:{read:p,write:c}})],h.prototype,"styleUrl",void 0),t([s({type:n,json:{read:!1}})],h.prototype,"thumbnail",void 0),t([s({type:String,json:{write:!0}})],h.prototype,"name",void 0),t([l({styleSymbolReference:"web-style"},{readOnly:!0})],h.prototype,"type",void 0),t([s()],h.prototype,"_fetchCacheKey",null),h=y=t([i("esri.symbols.WebStyleSymbol")],h);const u=h;export{u as default};