/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{makeHandle as e}from"../../../core/handleUtils.js";import{nextTick as n}from"../../../core/nextTick.js";import{makeAllLayerSnappingOptions as r}from"./allLayerSnapping.js";import{SnappingManager as o}from"./SnappingManager.js";const t=new Map;function a(n){if(!t.has(n)){const e=r(n,{distance:10}),a=new o({view:n,options:e.options});t.set(n,{referenceCount:0,snappingManager:a,remove:()=>{e.remove(),a.destroy()}})}const a=t.get(n);a.referenceCount++;const p=e(()=>i(n,a));return{snappingManager:a.snappingManager,...p}}function i(e,r){r.referenceCount--,r.referenceCount>0||n(()=>{0===r.referenceCount&&(r.remove(),t.delete(e))})}export{a as acquire};
