/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{a as e,b as t,c as r}from"../chunks/vec32.js";import{create as n}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as l,fromPoints as o}from"../geometry/support/ray.js";import{toGraphic as u,hasLod as i,getIntersectedFeatureBSRadius as a}from"../views/3d/webgl-engine/lib/intersectorUtilsConversions.js";function c(e,t){return s(e)===s(t)}function s(e){if(null==e)return null;const t=null!=e.layer?e.layer.id:"";let r=null;return r=null!=e.objectId?e.objectId:null!=e.layer&&"objectIdField"in e.layer&&null!=e.layer.objectIdField&&null!=e.attributes?e.attributes[e.layer.objectIdField]:e.uid,null==r?null:`o-${t}-${r}`}const d={json:{write:{writer:b,target:{"feature.layerId":{type:[Number,String],isRequired:!0},"feature.objectId":{type:[Number,String],isRequired:!0}}},origins:{"web-scene":{read:f}}},clonable:"reference"};function b(e,t){null!=e?.layer?.objectIdField&&null!=e.attributes&&(t.feature={layerId:e.layer.id,objectId:e.attributes[e.layer.objectIdField]})}function f(e){if(null!=e.layerId&&null!=e.objectId)return{uid:null,layer:{id:e.layerId,objectIdField:"ObjectId"},attributes:{ObjectId:e.objectId}}}function I(l,i,a,c){const{sceneIntersectionHelper:d}=l,{observer:b,observerFeatureId:f,targetFeatureId:I,target:m}=a;if(null==f&&null==I)return;c||(c=e=>e),e(g,b,m);const p=t(g),S=1;r(g,b,g,S/p);const v=o(g,m,y);i.options.store=2,d.intersectToolIntersectorRay(v,i);let F=null,N=null,R=null,w=null;for(const e of i.results.all){const t=u(e,l);if(null==t||null==e.distanceInRenderSpace)continue;const r=s(t);null!=r&&(null!=f&&r===f&&(F??=c(j(e,l,p)),e.distanceInRenderSpace-S<F&&(R=e)),null!=I&&r===I&&(N??=c(j(e,l,p)),null==w&&e.distanceInRenderSpace-S<p&&p-e.distanceInRenderSpace+S<N&&(w=e)))}const{observerAdjusted:T,targetAdjusted:h}=a;R?.getIntersectionPoint(T)?a.observerSurfaceNormal=R.getTransformedNormal(n()):a.observerSurfaceNormal=null,w?.getIntersectionPoint(h)?a.targetSurfaceNormal=w.getTransformedNormal(n()):a.targetSurfaceNormal=null}function j(e,t,r){if(i(e)){const n=a(e,t);if(null!=n)return Math.min(n*m,r)}return 1e-5*r}const m=.05,y=l(),g=n();export{c as featureReferenceEquals,d as featureReferenceProperty,s as getFeatureId,I as updatePointsFromFeatureReference};
