12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import r from"../../core/Accessor.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import s from"../../core/Logger.js";import{isSome as i,isNone as l}from"../../core/maybe.js";import{watch as a,initial as n}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import{renderPreviewHTML as u}from"../../symbols/support/symbolUtils.js";var c;const y=s.getLogger("esri.widgets.FeatureTemplates.TemplateItem");let h=c=class extends(o(r)){constructor(t){super(t),this._activeFetchInfo={id:null,request:null},this.description=null,this.label=null,this.layer=null,this.template=null,this.thumbnail=null}initialize(){this.handles.add(a((()=>{const{layer:t}=this;return[t&&"renderer"in t?t.renderer:null,this.template]}),(()=>{this._activeFetchInfo.id=null,this._activeFetchInfo.request=null,this._set("thumbnail",null)}),n))}clone(){const t=i(this.thumbnail)?this.thumbnail.cloneNode(!0):null,e=new c({layer:this.layer,template:this.template});return e._set("thumbnail",t),e}static async fetchThumbnail(t,e){if(b(t))return y.warn("Thumbnails for sublayers of a SubtypeGroupLayer are not yet supported."),null;const r=await d(t,e);if(l(r))return null;const o={maxSize:36};"dictionary"===t.renderer?.type&&(o.fieldMap=t.renderer.fieldMap,o.feature={attributes:e.prototype.attributes});return await u(r,o)}};async function d(t,r){const{renderer:o}=t;if(o){const t=new e({attributes:r.prototype.attributes}),s=await o.getSymbolAsync(t);if(s)return s}return f(t)}async function f(t){const{geometryType:e}=t,r="point"===e||"multipoint"===e?await import("../../symbols/SimpleMarkerSymbol.js"):"polyline"===e?await import("../../symbols/SimpleLineSymbol.js"):"polygon"===e||"mesh"===e||"multipatch"===e?await import("../../symbols/SimpleFillSymbol.js"):null;return r?new r.default:null}function b(t){return"subtype-group"===t.type}t([p({aliasOf:"template.description"})],h.prototype,"description",void 0),t([p({aliasOf:"template.name"})],h.prototype,"label",void 0),t([p()],h.prototype,"layer",void 0),t([p()],h.prototype,"template",void 0),t([p({readOnly:!0})],h.prototype,"thumbnail",void 0),h=c=t([m("esri.widgets.FeatureTemplates.TemplateItem")],h);const j=h;export{j as default};
|