"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../utils/disposables.js"),t=require("../../utils/dom.js"),r=require("../../utils/platform.js");exports.handleIOSLocking=function(){return r.isIOS()?{before(r){let{doc:l,d:o,meta:n}=r;function s(e){for(let t of n().containers)for(let r of t())if(r.contains(e))return!0;return!1}o.microTask((()=>{var r;if("auto"!==window.getComputedStyle(l.documentElement).scrollBehavior){let t=e.disposables();t.style(l.documentElement,"scrollBehavior","auto"),o.add((()=>o.microTask((()=>t.dispose()))))}let n=null!=(r=window.scrollY)?r:window.pageYOffset,i=null;o.addEventListener(l,"click",(e=>{if(t.isHTMLorSVGElement(e.target))try{let r=e.target.closest("a");if(!r)return;let{hash:o}=new URL(r.href),n=l.querySelector(o);t.isHTMLorSVGElement(n)&&!s(n)&&(i=n)}catch{}}),!0),o.group((e=>{o.addEventListener(l,"touchstart",(r=>{if(e.dispose(),t.isHTMLorSVGElement(r.target)&&t.hasInlineStyle(r.target))if(s(r.target)){let t=r.target;for(;t.parentElement&&s(t.parentElement);)t=t.parentElement;e.style(t,"overscrollBehavior","contain")}else e.style(r.target,"touchAction","none")}))})),o.addEventListener(l,"touchmove",(e=>{if(t.isHTMLorSVGElement(e.target)){if(t.isHTMLInputElement(e.target))return;if(s(e.target)){let t=e.target;for(;t.parentElement&&""!==t.dataset.headlessuiPortal&&!(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth);)t=t.parentElement;""===t.dataset.headlessuiPortal&&e.preventDefault()}else e.preventDefault()}}),{passive:!1}),o.add((()=>{var e;let t=null!=(e=window.scrollY)?e:window.pageYOffset;n!==t&&window.scrollTo(0,n),i&&i.isConnected&&(i.scrollIntoView({block:"nearest"}),i=null)}))}))}}:{}};
//# sourceMappingURL=handle-ios-locking.js.map
