/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{screenPointObjectToArray as t,pt2px as o,createScreenPointArray as e}from"../../../core/screenUtils.js";import{squaredDistance as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{canProjectWithoutEngine as r,project as n}from"../../../geometry/projectionUtils.js";import{getDefaultSymbol2D as i}from"../../../symbols/support/defaults.js";import{intersectsDrapedGeometry as l}from"../../support/drapedUtils.js";function a(t){let e=0,s=0,r=0;return t?("cim"===t.type&&t.data.symbol&&"symbolLayers"in t.data.symbol&&t.data.symbol.symbolLayers&&t.data.symbol.symbolLayers.map(t=>{"CIMVectorMarker"===t.type&&t.anchorPoint&&(Math.abs(t.anchorPoint.x)>e&&(e=t.anchorPoint.x),Math.abs(t.anchorPoint.y)>s&&(s=t.anchorPoint.y),null!=t.size&&t.size>r&&(r=t.size))}),e=o(e),s=o(s),r=o(r),{offsetX:e,offsetY:s,size:r}):{offsetX:e,offsetY:s,size:r}}function f(e,f,c,u,y){if(null==(u=u||i(c)))return null;const p=1;if("point"===c.type&&"cim"===u.type&&"CIMPointSymbol"===u.data.symbol?.type&&u.data.symbol.symbolLayers){const{offsetX:o,offsetY:r,size:n}=a(u),i=t(f,m),l=n/2,y=e.toScreen(c),b=y.x+o,P=y.y+r;return s(i,[b,P])<l*l?{result:p}:null}if("point"!==c.type||"simple-marker"!==u.type)return l(f,c,e)?{result:p}:null;if(null==y||!y.originalPoint.equals(c)){const t=c,s=e.spatialReference;if(r(t.spatialReference,s)){const e=n(t,s);y={originalPoint:t.clone(),mapPoint:e,radiusPx:o(u.size)}}}if(null!=y){const r=t(f,m),n=e.toScreen?.(y.mapPoint);if(!n)return{result:null,cache:y};const i=y.radiusPx,l=n.x+o(u.xoffset),a=n.y-o(u.yoffset);return s(r,[l,a])<i*i?{result:p,cache:y}:null}return null}const m=e();export{a as getSymbolInfo,f as intersectionDistance2D};
