/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as o}from"tslib";import{clone as t}from"../core/lang.js";import e from"../core/Logger.js";import{makeData as i}from"../core/urlUtils.js";import{property as r,subclass as s}from"../core/accessorSupport/decorators.js";import l from"./Symbol3DLayer.js";import{white as n,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{occludedVisibilityProperty as m}from"./support/occludedVisibilityUtils.js";import h from"./support/Symbol3DAnchorPosition2D.js";import d from"./support/Symbol3DIconOutline.js";import y from"./support/Symbol3DMaterial.js";import{enumeration as f}from"../core/accessorSupport/decorators/enumeration.js";var b;let g=class extends l{static{b=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=new u({mode:"adaptive"})}get size(){return this._get("size")??12}set size(o){this._set("size",o)}clone(){return new b({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||n,i=j(o),r=o.outline&&o.outline.width>0?{size:o.outline.width,color:(o.outline.color||n).clone()}:null;return new b({size:o.size,angle:o.angle,resource:{primitive:z(()=>e.getLogger(this.prototype),o.style)},material:{color:t},outline:r,anchor:i?"relative":void 0,anchorPosition:i,occludedVisibility:null})}static fromPictureMarkerSymbol(o){const t=!o.color||c(o.color)?n:o.color,e=j(o);return new b({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,occludedVisibility:null})}static fromCIMSymbol(o){return new b({resource:{href:i({mediaType:"application/json",data:JSON.stringify(o.data)})},occludedVisibility:null})}};function j(o){const t="width"in o?o.width:o.size,e="height"in o?o.height:o.size,i=w(o.xoffset),r=w(o.yoffset);return(i||r)&&t&&e?{x:-i/t,y:r/e}:null}function w(o){return isFinite(o)?o:0}o([r({type:y,json:{write:!0}})],g.prototype,"material",void 0),o([r({type:a,json:{write:!0}})],g.prototype,"resource",void 0),o([f({Icon:"icon"},{readOnly:!0})],g.prototype,"type",void 0),o([r({...p,json:{write:{isRequired:!0}}})],g.prototype,"size",null),o([f({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"})],g.prototype,"anchor",void 0),o([r({type:h,json:{type:[Number],read:{reader:o=>new h({x:o[0],y:o[1]})},write:{writer:(o,t)=>{t.anchorPosition=[o.x,o.y]},overridePolicy(){return{enabled:"relative"===this.anchor}}}}})],g.prototype,"anchorPosition",void 0),o([r({type:d,json:{write:!0}})],g.prototype,"outline",void 0),o([r({type:Number,json:{write:!0,default:0}})],g.prototype,"angle",void 0),o([r(m)],g.prototype,"occludedVisibility",void 0),g=b=o([s("esri.symbols.IconSymbol3DLayer")],g);const v={circle:"circle",cross:"cross",diamond:"kite",square:"square",x:"x",triangle:"triangle",path:null};function z(o,t){const e=v[t];return e||(o().warn(`${t} cannot be mapped to Icon symbol. Fallback to "circle"`),"circle")}export{g as default};
