// @bun
var{defineProperty:J,getOwnPropertyNames:Q,getOwnPropertyDescriptor:R}=Object,T=Object.prototype.hasOwnProperty;function U(j){return this[j]}var N=(j)=>{var w=(K??=new WeakMap).get(j),A;if(w)return w;if(w=J({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var B of Q(j))if(!T.call(w,B))J(w,B,{get:U.bind(j,B),enumerable:!(A=R(j,B))||A.enumerable})}return K.set(j,w),w},K;var V=(j)=>j;function W(j,w){this[j]=V.bind(null,w)}var $=(j,w)=>{for(var A in w)J(j,A,{get:w[A],enumerable:!0,configurable:!0,set:W.bind(w,A)})};var S=(j,w)=>()=>(j&&(w=j(j=0)),w);var h=import.meta.require;function X(){return typeof window<"u"&&"DeviceOrientationEvent"in window}function Y(){return typeof window<"u"&&"DeviceMotionEvent"in window}async function Z(){if(typeof window>"u")return!1;let j=window.DeviceOrientationEvent;if(typeof j?.requestPermission==="function")try{return await j.requestPermission()==="granted"}catch{return!1}return!0}async function _(){if(typeof window>"u")return!1;let j=window.DeviceMotionEvent;if(typeof j?.requestPermission==="function")try{return await j.requestPermission()==="granted"}catch{return!1}return!0}function z(){let j=X(),w=new Set,A={isSupported:j,isAbsolute:!1,alpha:null,beta:null,gamma:null},B=null;function C(){w.forEach((k)=>k(A))}function F(k){A={...A,isAbsolute:k.absolute,alpha:k.alpha,beta:k.beta,gamma:k.gamma},C()}function G(){if(!j||B)return;window.addEventListener("deviceorientation",F,!0),B=()=>{window.removeEventListener("deviceorientation",F,!0)}}function H(){B?.(),B=null}async function I(){let k=await Z();if(k)G();return k}if(j)G();return{get:()=>A,subscribe:(k)=>{return w.add(k),k(A),()=>{if(w.delete(k),w.size===0)H()}},isSupported:()=>j,requestPermission:I}}function E(){let j=Y(),w=new Set,A={isSupported:j,acceleration:{x:null,y:null,z:null},accelerationIncludingGravity:{x:null,y:null,z:null},rotationRate:{alpha:null,beta:null,gamma:null},interval:0},B=null;function C(){w.forEach((k)=>k(A))}function F(k){A={...A,acceleration:{x:k.acceleration?.x??null,y:k.acceleration?.y??null,z:k.acceleration?.z??null},accelerationIncludingGravity:{x:k.accelerationIncludingGravity?.x??null,y:k.accelerationIncludingGravity?.y??null,z:k.accelerationIncludingGravity?.z??null},rotationRate:{alpha:k.rotationRate?.alpha??null,beta:k.rotationRate?.beta??null,gamma:k.rotationRate?.gamma??null},interval:k.interval},C()}function G(){if(!j||B)return;window.addEventListener("devicemotion",F,!0),B=()=>{window.removeEventListener("devicemotion",F,!0)}}function H(){B?.(),B=null}async function I(){let k=await _();if(k)G();return k}if(j)G();return{get:()=>A,subscribe:(k)=>{return w.add(k),k(A),()=>{if(w.delete(k),w.size===0)H()}},isSupported:()=>j,requestPermission:I}}function y(){let j=z(),w=new Set,A={x:0,y:0};return j.subscribe((B)=>{if(B.gamma!==null&&B.beta!==null)A={x:Math.max(-1,Math.min(1,(B.gamma||0)/45)),y:Math.max(-1,Math.min(1,(B.beta||0)/45))},w.forEach((C)=>C(A))}),{get:()=>A,subscribe:(B)=>{return w.add(B),B(A),()=>{w.delete(B)}},isSupported:j.isSupported,requestPermission:j.requestPermission}}export{y as useParallax,z as useDeviceOrientation,E as useDeviceMotion,Z as requestOrientationPermission,_ as requestMotionPermission,X as isDeviceOrientationSupported,Y as isDeviceMotionSupported};
