import{scheduler as e,updateCount as r}from"./utils/scheduler.js";import{ResizeObservation as t}from"./ResizeObservation.js";import{ResizeObserverDetail as s}from"./ResizeObserverDetail.js";import{resizeObservers as o}from"./utils/resizeObservers.js";var n=new WeakMap,getObservationIndex=function(e,r){for(var t=0;t<e.length;t+=1)if(e[t].target===r)return t;return-1},i=function(){function ResizeObserverController(){}return ResizeObserverController.connect=function(e,r){var t=new s(e,r);n.set(e,t)},ResizeObserverController.observe=function(s,i,a){var v=n.get(s),l=0===v.observationTargets.length;getObservationIndex(v.observationTargets,i)<0&&(l&&o.push(v),v.observationTargets.push(new t(i,a&&a.box)),r(1),e.schedule())},ResizeObserverController.unobserve=function(e,t){var s=n.get(e),i=getObservationIndex(s.observationTargets,t),a=1===s.observationTargets.length;i>=0&&(a&&o.splice(o.indexOf(s),1),s.observationTargets.splice(i,1),r(-1))},ResizeObserverController.disconnect=function(e){var r=this,t=n.get(e);t.observationTargets.slice().forEach((function(t){return r.unobserve(e,t.target)})),t.activeTargets.splice(0,t.activeTargets.length)},ResizeObserverController}();export{i as ResizeObserverController};