/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as o}from"tslib";import{clone as t}from"../core/lang.js";import e from"../core/Logger.js";import{makeData as r}from"../core/urlUtils.js";import{property as i,subclass as s}from"../core/accessorSupport/decorators.js";import n from"./Symbol3DLayer.js";import{white as l,isBlack as c}from"./support/colors.js";import a from"./support/IconSymbol3DLayerResource.js";import{screenSizeProperty as p}from"./support/materialUtils.js";import u from"./support/OccludedVisibility.js";import m from"./support/Symbol3DAnchorPosition2D.js";import h from"./support/Symbol3DIconOutline.js";import y from"./support/Symbol3DMaterial.js";import{enumeration as d}from"../core/accessorSupport/decorators/enumeration.js";var f;let b=class extends n{static{f=this}constructor(o){super(o),this.material=null,this.resource=null,this.type="icon",this.anchor="center",this.anchorPosition=null,this.outline=null,this.angle=0,this.occludedVisibility=null}get size(){return this._get("size")??12}set size(o){this._set("size",o)}clone(){return new f({anchor:this.anchor,anchorPosition:t(this.anchorPosition),enabled:this.enabled,material:t(this.material),outline:t(this.outline),resource:t(this.resource),angle:this.angle,size:this.size,occludedVisibility:t(this.occludedVisibility)})}static fromSimpleMarkerSymbol(o){const t=o.color||l,r=g(o),i=o.outline&&o.outline.width>0?{size:o.outline.width,color:(o.outline.color||l).clone()}:null;return new f({size:o.size,angle:o.angle,resource:{primitive:v(()=>e.getLogger(this.prototype),o.style)},material:{color:t},outline:i,anchor:r?"relative":void 0,anchorPosition:r})}static fromPictureMarkerSymbol(o){const t=!o.color||c(o.color)?l:o.color,e=g(o);return new f({size:o.width<=o.height?o.height:o.width,angle:o.angle,resource:{href:o.url},material:{color:t.clone()},anchor:e?"relative":void 0,anchorPosition:e})}static fromCIMSymbol(o){return new f({resource:{href:r({mediaType:"application/json",data:JSON.stringify(o.data)})}})}};function g(o){const t="width"in o?o.width:o.size,e="height"in o?o.height:o.size,r=j(o.xoffset),i=j(o.yoffset);return(r||i)&&t&&e?{x:-r/t,y:i/e}:null}function j(o){return isFinite(o)?o:0}o([i({type:y,json:{write:!0}})],b.prototype,"material",void 0),o([i({type:a,json:{write:!0}})],b.prototype,"resource",void 0),o([d({Icon:"icon"},{readOnly:!0})],b.prototype,"type",void 0),o([i({...p,json:{write:{isRequired:!0}}})],b.prototype,"size",null),o([d({center:"center",left:"left",right:"right",top:"top",bottom:"bottom",topLeft:"top-left",topRight:"top-right",bottomLeft:"bottom-left",bottomRight:"bottom-right",relative:"relative"},{default:"center"})],b.prototype,"anchor",void 0),o([i({type:m,json:{type:[Number],read:{reader:o=>new m({x:o[0],y:o[1]})},write:{writer:(o,t)=>{t.anchorPosition=[o.x,o.y]},overridePolicy(){return{enabled:"relative"===this.anchor}}}}})],b.prototype,"anchorPosition",void 0),o([i({type:h,json:{write:!0}})],b.prototype,"outline",void 0),o([i({type:Number,json:{write:!0,default:0}})],b.prototype,"angle",void 0),o([i({type:u,json:{write:!0}})],b.prototype,"occludedVisibility",void 0),b=f=o([s("esri.symbols.IconSymbol3DLayer")],b);const w={circle:"circle",cross:"cross",diamond:"kite",square:"square",x:"x",triangle:"triangle",path:null};function v(o,t){const e=w[t];return e||(o().warn(`${t} cannot be mapped to Icon symbol. Fallback to "circle"`),"circle")}export{b as default};
