import{useRef as n,useState as e,useCallback as t,useEffect as o}from"react";import{throttle as r}from"lodash";import{ISOLATED_PAGE_APP_CONTAINER_ID as i}from"../components/DevCenter/IsolatedDevCenterAppContainer/constants.js";var u=function(){var n;return null===(n=document.getElementById(i))||void 0===n?void 0:n.firstElementChild},l=function(l){var m=void 0===l?{}:l,a=m.width,d=m.height,c=n(u()),v=function(){var n,e=null===(n=c.current)||void 0===n?void 0:n.getBoundingClientRect();if(!e)return console.error("#".concat(i,' component is not available. Check if you are not using "useMatchAppContainerSize" hook outside of DC app')),null;var t="number"!=typeof(null==a?void 0:a.min)||a.min<e.width,o="number"!=typeof(null==a?void 0:a.max)||a.max>e.width,r="number"!=typeof(null==d?void 0:d.min)||d.min<e.height,u="number"!=typeof(null==d?void 0:d.max)||d.max>e.height;return t&&o&&r&&u},f=e(c.current?v():null),p=f[0],s=f[1],h=t(r((function(){return s(v())}),200),[a,d]);return o((function(){c.current||(c.current=u(),s(v()))}),[]),o((function(){return window.addEventListener("resize",h),function(){window.removeEventListener("resize",h)}}),[]),p};export{l as useMatchAppContainerSize};
