/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{pt2px as t,screenPointObjectToArray 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(o){let e=0,s=0,r=0;return o?("cim"===o.type&&o.data.symbol&&"symbolLayers"in o.data.symbol&&o.data.symbol.symbolLayers&&o.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=t(e),s=t(s),r=t(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:t,offsetY:r,size:n}=a(u),i=o(f,m),l=n/2,y=e.toScreen(c),b=y.x+t,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 o=c,s=e.spatialReference;if(r(o.spatialReference,s)){const e=n(o,s);y={originalPoint:o.clone(),mapPoint:e,radiusPx:t(u.size)}}}if(null!=y){const r=o(f,m),n=e.toScreen?.(y.mapPoint);if(!n)return{result:null,cache:y};const i=y.radiusPx,l=n.x+t(u.xoffset),a=n.y-t(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};
