import{disposables as u}from'../../utils/disposables.js';import*as i from'../../utils/dom.js';import{isIOS as p}from'../../utils/platform.js';function w(){return p()?{before({doc:o,d:r,meta:m}){function a(s){for(let l of m().containers)for(let c of l())if(c.contains(s))return!0;return!1}r.microTask(()=>{var c;if(window.getComputedStyle(o.documentElement).scrollBehavior!=="auto"){let t=u();t.style(o.documentElement,"scrollBehavior","auto"),r.add(()=>r.microTask(()=>t.dispose()))}let s=(c=window.scrollY)!=null?c:window.pageYOffset,l=null;r.addEventListener(o,"click",t=>{if(i.isHTMLorSVGElement(t.target))try{let e=t.target.closest("a");if(!e)return;let{hash:n}=new URL(e.href),f=o.querySelector(n);i.isHTMLorSVGElement(f)&&!a(f)&&(l=f)}catch{}},!0),r.group(t=>{r.addEventListener(o,"touchstart",e=>{if(t.dispose(),i.isHTMLorSVGElement(e.target)&&i.hasInlineStyle(e.target))if(a(e.target)){let n=e.target;for(;n.parentElement&&a(n.parentElement);)n=n.parentElement;t.style(n,"overscrollBehavior","contain")}else t.style(e.target,"touchAction","none")})}),r.addEventListener(o,"touchmove",t=>{if(i.isHTMLorSVGElement(t.target)){if(i.isHTMLInputElement(t.target))return;if(a(t.target)){let e=t.target;for(;e.parentElement&&e.dataset.headlessuiPortal!==""&&!(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth);)e=e.parentElement;e.dataset.headlessuiPortal===""&&t.preventDefault()}else t.preventDefault()}},{passive:!1}),r.add(()=>{var e;let t=(e=window.scrollY)!=null?e:window.pageYOffset;s!==t&&window.scrollTo(0,s),l&&l.isConnected&&(l.scrollIntoView({block:"nearest"}),l=null)})})}}:{}}export{w as handleIOSLocking};
