// @bun
var{defineProperty:I,getOwnPropertyNames:R,getOwnPropertyDescriptor:T}=Object,U=Object.prototype.hasOwnProperty;function V(b){return this[b]}var k=(b)=>{var j=(N??=new WeakMap).get(b),A;if(j)return j;if(j=I({},"__esModule",{value:!0}),b&&typeof b==="object"||typeof b==="function"){for(var w of R(b))if(!U.call(j,w))I(j,w,{get:V.bind(b,w),enumerable:!(A=T(b,w))||A.enumerable})}return N.set(b,j),j},N;var W=(b)=>b;function X(b,j){this[b]=W.bind(null,j)}var q=(b,j)=>{for(var A in j)I(b,A,{get:j[A],enumerable:!0,configurable:!0,set:X.bind(j,A)})};var C=(b,j)=>()=>(b&&(j=b(b=0)),j);var L=import.meta.require;function J(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null}function Y(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}async function Z(b,j){let A=j?.navigationUI?{navigationUI:j.navigationUI}:void 0;if(b.requestFullscreen)await b.requestFullscreen(A);else if(b.webkitRequestFullscreen)await b.webkitRequestFullscreen();else if(b.mozRequestFullScreen)await b.mozRequestFullScreen();else if(b.msRequestFullscreen)await b.msRequestFullscreen()}async function _(){if(document.exitFullscreen)await document.exitFullscreen();else if(document.webkitExitFullscreen)await document.webkitExitFullscreen();else if(document.mozCancelFullScreen)await document.mozCancelFullScreen();else if(document.msExitFullscreen)await document.msExitFullscreen()}function $(b,j={}){let A=typeof document<"u"&&Y(),w={isFullscreen:!1,isSupported:A,element:null},B=[],G=null,O=()=>{if(!b)return document.documentElement;if(typeof b==="function")return b()||document.documentElement;return b},P=()=>{B.forEach((z)=>z(w))},H=()=>{let z=J();w={...w,isFullscreen:!!z,element:z},P()},Q=()=>{if(typeof document>"u")return;let z=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];for(let D of z)document.addEventListener(D,H);G=()=>{for(let D of z)document.removeEventListener(D,H)},H()},K=async()=>{if(!A)return;let z=O();await Z(z,j)},M=async()=>{if(!A)return;if(J())await _()};return{get:()=>w,subscribe:(z)=>{if(B.length===0)Q();return B.push(z),z(w),()=>{if(B=B.filter((D)=>D!==z),B.length===0&&G)G(),G=null}},isFullscreen:()=>w.isFullscreen,isSupported:()=>w.isSupported,enter:K,exit:M,toggle:async()=>{if(w.isFullscreen)await M();else await K()}}}function x(){return $().toggle()}function v(){return!!J()}export{$ as useFullscreen,x as toggleFullscreen,v as isInFullscreen};
