Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vaul

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vaul - npm Package Compare versions

Comparing version 0.6.2 to 0.6.3

4

dist/index.js
"use client"
"use client";var Tt=Object.create;var se=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var Rt=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty;var Mt=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},Be=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of St(n))!Dt.call(e,i)&&i!==t&&se(e,i,{get:()=>n[i],enumerable:!(o=wt(n,i))||o.enumerable});return e};var j=(e,n,t)=>(t=e!=null?Tt(Rt(e)):{},Be(n||!e||!e.__esModule?se(t,"default",{value:e,enumerable:!0}):t,e)),Ct=e=>Be(se({},"__esModule",{value:!0}),e);var nn={};Mt(nn,{Drawer:()=>tn});module.exports=Ct(nn);var H=j(require("@radix-ui/react-dialog")),h=j(require("react"));var we=j(require("react")),Se=we.default.createContext({drawerRef:{current:null},overlayRef:{current:null},scaleBackground:()=>{},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},dismissible:!1,isOpen:!1,keyboardIsOpen:{current:!1},experimentalSafariThemeAnimation:!1,snapPointsOffset:null,snapPoints:null,modal:!1,shouldFade:!1,activeSnapPoint:null,setActiveSnapPoint:()=>{},visible:!1,closeDrawer:()=>{},setVisible:()=>{}}),ce=()=>we.default.useContext(Se);function Re(e,{insertAt:n}={}){if(!e||typeof document=="undefined")return;let t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",n==="top"&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}Re(`[vaul-drawer]{touch-action:none;transform:translate3d(0,100%,0);transition:transform .5s cubic-bezier(.32,.72,0,1)}[vaul-drawer][vaul-drawer-visible=true]{transform:translate3d(0,var(--snap-point-height, 0),0)}[vaul-overlay]{opacity:0;transition:opacity .5s cubic-bezier(.32,.72,0,1)}[vaul-overlay][vaul-drawer-visible=true]{opacity:1}[vaul-drawer]:after{content:"";position:absolute;top:100%;background:inherit;background-color:inherit;left:0;right:0;height:200%}[vaul-overlay][vaul-snap-points=true]:not([vaul-snap-points-overlay="true"]):not([data-state="closed"]){opacity:0}[vaul-overlay][vaul-snap-points-overlay=true]:not([vaul-drawer-visible="false"]){opacity:1}@keyframes fake-animation{}@keyframes show-theme-overlay{0%{background:var(--vaul-overlay-background-start)}to{background:var(--vaul-overlay-background-end)}}@keyframes hide-theme-overlay{0%{background:var(--vaul-overlay-background-end)}to{background:var(--vaul-overlay-background-start)}}@media (hover: hover) and (pointer: fine){[vaul-drawer]{user-select:none}}
`);var me=require("react"),xt=typeof window!="undefined"?me.useLayoutEffect:me.useEffect;function Ce(...e){return(...n)=>{for(let t of e)typeof t=="function"&&t(...n)}}function Ot(){return xe(/^Mac/)}function It(){return xe(/^iPhone/)}function ze(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Ht(){return xe(/^iPad/)||Ot()&&navigator.maxTouchPoints>1}function X(){return It()||Ht()}function xe(e){return typeof window!="undefined"&&window.navigator!=null?e.test(window.navigator.platform):void 0}var De=typeof document!="undefined"&&window.visualViewport;function Ve(e){let n=window.getComputedStyle(e);return/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY)}function Ue(e){for(Ve(e)&&(e=e.parentElement);e&&!Ve(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}var At=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),fe=0,Me;function We(e={}){let{isDisabled:n}=e;xt(()=>{if(!n)return fe++,fe===1&&(X()?Me=Nt():Me=Lt()),()=>{fe--,fe===0&&Me()}},[n])}function Lt(){return Ce(de(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),de(document.documentElement,"overflow","hidden"))}function Nt(){let e,n=0,t=l=>{e=Ue(l.target),!(e===document.documentElement&&e===document.body)&&(n=l.changedTouches[0].pageY)},o=l=>{if(!e||e===document.documentElement||e===document.body){l.preventDefault();return}let s=l.changedTouches[0].pageY,x=e.scrollTop,O=e.scrollHeight-e.clientHeight;O!==0&&((x<=0&&s>n||x>=O&&s<n)&&l.preventDefault(),n=s)},i=l=>{let s=l.target;Z(s)&&s!==document.activeElement&&(l.preventDefault(),s.style.transform="translateY(-2000px)",s.focus(),requestAnimationFrame(()=>{s.style.transform=""}))},r=l=>{let s=l.target;Z(s)&&(s.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{s.style.transform="",De&&(De.height<window.innerHeight?requestAnimationFrame(()=>{je(s)}):De.addEventListener("resize",()=>je(s),{once:!0}))}))},a=()=>{window.scrollTo(0,0)},u=window.pageXOffset,E=window.pageYOffset,T=Ce(de(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),de(document.documentElement,"overflow","hidden"));window.scrollTo(0,0);let p=Ce(Q(document,"touchstart",t,{passive:!1,capture:!0}),Q(document,"touchmove",o,{passive:!1,capture:!0}),Q(document,"touchend",i,{passive:!1,capture:!0}),Q(document,"focus",r,!0),Q(window,"scroll",a));return()=>{T(),p(),window.scrollTo(u,E)}}function de(e,n,t){let o=e.style[n];return e.style[n]=t,()=>{e.style[n]=o}}function Q(e,n,t,o){return e.addEventListener(n,t,o),()=>{e.removeEventListener(n,t,o)}}function je(e){let n=document.scrollingElement||document.documentElement;for(;e&&e!==n;){let t=Ue(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let o=t.getBoundingClientRect().top,i=e.getBoundingClientRect().top,r=e.getBoundingClientRect().bottom,a=t.getBoundingClientRect().bottom;r>a&&(t.scrollTop+=i-o)}e=t.parentElement}}function Z(e){return e instanceof HTMLInputElement&&!At.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var Ye=j(require("react"));function $t(e,n){typeof e=="function"?e(n):e!=null&&(e.current=n)}function Pt(...e){return n=>e.forEach(t=>$t(t,n))}function Oe(...e){return Ye.useCallback(Pt(...e),e)}var A=j(require("react"));var Ft=4,kt=.001,Bt=1e-7,Vt=10,ee=11,be=1/(ee-1),jt=typeof Float32Array=="function";function _e(e,n){return 1-3*n+3*e}function qe(e,n){return 3*n-6*e}function Ge(e){return 3*e}function ge(e,n,t){return((_e(n,t)*e+qe(n,t))*e+Ge(n))*e}function Ke(e,n,t){return 3*_e(n,t)*e*e+2*qe(n,t)*e+Ge(n)}function zt(e,n,t,o,i){var r,a,u=0;do a=n+(t-n)/2,r=ge(a,o,i)-e,r>0?t=a:n=a;while(Math.abs(r)>Bt&&++u<Vt);return a}function Ut(e,n,t,o){for(var i=0;i<Ft;++i){var r=Ke(n,t,o);if(r===0)return n;var a=ge(n,t,o)-e;n-=a/r}return n}function Wt(e){return e}function Je(e,n,t,o){if(!(0<=e&&e<=1&&0<=t&&t<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===n&&t===o)return Wt;for(var i=jt?new Float32Array(ee):new Array(ee),r=0;r<ee;++r)i[r]=ge(r*be,e,t);function a(u){for(var E=0,T=1,p=ee-1;T!==p&&i[T]<=u;++T)E+=be;--T;var l=(u-i[T])/(i[T+1]-i[T]),s=E+l*be,x=Ke(s,e,t);return x>=kt?Ut(u,s,e,t):x===0?s:zt(u,E,E+be,e,t)}return function(E){return E===0||E===1?E:ge(a(E),n,o)}}var Yt=Je(.32,.72,0,1);function _t(e){let n=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+),\s*(\d*(?:\.\d+)?)\)/);if(!n)throw new Error("Invalid color string");return[Number(n[1]),Number(n[2]),Number(n[3]),Number(n[4])]}function qt(e,n){let[t,o,i,r]=_t(e);return[Math.round(r*t+(1-r)*Number(n[0])),Math.round(r*o+(1-r)*Number(n[1])),Math.round(r*i+(1-r)*Number(n[2]))]}function Gt(e){return Yt(e)}function Kt(e,n,t,o){arguments.length<3&&(t=.5);let i=e.slice();for(let r=0;r<3;r++){let a=n[r]-e[r],u=o?e[r]+t*a:e[r]+Gt(t)*a;i[r]=Math.round(u),i[r]<0&&(i[r]=0),i[r]>255&&(i[r]=255)}return i}function te(e,n,t,o){let i=1/(t-1),r=[];for(let a=0;a<t;a++)r.push(Kt(e,n,i*a,!!o));return r}function Qe(e,n,t,o){let[i,r]=A.default.useState([255,255,255]),[a,u]=A.default.useState([153,153,153]),[E,T]=A.default.useState(!1),[p,l]=A.default.useState(null),[s,x]=A.default.useState(null),O=A.default.useMemo(()=>X()&&ze()&&o,[o]),$=A.default.useMemo(()=>i&&a?te(i,a,50):null,[a,i]),F=A.default.useMemo(()=>i&&a?te(a,i,50):null,[a,i]),c=A.default.useMemo(()=>i&&a?te(a,i,50,!0):null,[a,i]);A.default.useEffect(()=>{if(!O)return;let g=getComputedStyle(document.documentElement),R=g.getPropertyValue("--vaul-overlay-background").split(",").map(k=>Number(k)),D=g.getPropertyValue("--vaul-overlay-background-end"),M=qt(D,R);r(R),u(M)},[O]),A.default.useEffect(()=>{if(O&&!p){let g=document.querySelector('meta[name="theme-color"]');g?l(g.getAttribute("content")):(g=document.createElement("meta"),g.name="theme-color",document.getElementsByTagName("head")[0].appendChild(g)),x(g)}},[p,O]);let b=(0,A.useCallback)(g=>{let R,D;function M(k){R||(R=k);let re=k-R,P=Math.floor(re/10);if(n.current&&g&&!E&&e.current){if(e.current.style.transform==="translateY(0px)"&&e.current.getAttribute("vaul-clicked-outside")!=="true")return;if(P<g.length){let G=g[P];s==null||s.setAttribute("content",`rgb(${G.join(",")})`),P===g.length-1&&p&&!t&&(s==null||s.setAttribute("content",p)),D=requestAnimationFrame(M)}}}return D=requestAnimationFrame(M),D},[e,t,s,E,p,n]);A.default.useEffect(()=>{if(!O||!$||!F)return;let g=b(t?$:F);return t&&T(!1),()=>{g&&cancelAnimationFrame(g)}},[t,O,b,$,F]);function v(g){let R=document.querySelector('meta[name="theme-color"]');if(!O||!R||!c)return;let D=Math.floor(g*c.length);D=Math.max(0,Math.min(c.length-1,D));let M=c[D];R.setAttribute("content",`rgb(${M.join(",")})`)}function N(g){let R=document.querySelector('meta[name="theme-color"]');if(!R||!O)return;T(!0);let D=R.getAttribute("content").match(/\d+/g).map(Number),M=te(D,a,50);!g&&i&&(M=te(D,i,50)),b(M)}return{onDrag:v,onRelease:N}}var pe=j(require("react")),z=null;function Ze({isOpen:e,modal:n,nested:t}){let o=pe.default.useRef(0);function i(){if(z===null){z={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height};let{scrollX:a,innerHeight:u}=window;document.body.style.setProperty("position","fixed","important"),document.body.style.top=`${-o.current}px`,document.body.style.left=`${-a}px`,document.body.style.right="0px",document.body.style.height="auto",setTimeout(()=>requestAnimationFrame(()=>{let E=u-window.innerHeight;E&&o.current>=u&&(document.body.style.top=`${-(o.current+E)}px`)}),300)}}function r(){if(z!==null){let a=-parseInt(document.body.style.top,10),u=-parseInt(document.body.style.left,10);document.body.style.position=z.position,document.body.style.top=z.top,document.body.style.left=z.left,document.body.style.height=z.height,document.body.style.right="unset",requestAnimationFrame(()=>{window.scrollTo(u,a)}),z=null}}pe.default.useEffect(()=>{function a(){o.current=window.scrollY}return a(),window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a)}},[]),pe.default.useEffect(()=>{t||(e?(i(),n||setTimeout(()=>{r()},500)):r())},[e])}var W=j(require("react"));var Xe=new WeakMap;function w(e,n,t=!1){if(!e||!(e instanceof HTMLElement)||!n)return;let o={};Object.entries(n).forEach(([i,r])=>{if(i.startsWith("--")){e.style.setProperty(i,r);return}o[i]=e.style[i],e.style[i]=r}),!t&&Xe.set(e,o)}function ve(e,n){if(!e||!(e instanceof HTMLElement))return;let t=Xe.get(e);t&&(n?e.style[n]=t[n]:Object.entries(t).forEach(([o,i])=>{e.style[o]=i}))}function ne(e){let n=window.getComputedStyle(e),t=n.transform||n.webkitTransform||n.mozTransform,o=t.match(/^matrix3d\((.+)\)$/);return o?parseFloat(o[1].split(", ")[13]):(o=t.match(/^matrix\((.+)\)$/),o?parseFloat(o[1].split(", ")[5]):null)}function et(e){return 8*(Math.log(e+1)-2)}var y={DURATION:.5,EASE:[.32,.72,0,1]},he=.4;var U=j(require("react"));function tt(e){let n=U.default.useRef(e);return U.default.useEffect(()=>{n.current=e}),U.default.useMemo(()=>(...t)=>{var o;return(o=n.current)==null?void 0:o.call(n,...t)},[])}function Jt({defaultProp:e,onChange:n}){let t=U.default.useState(e),[o]=t,i=U.default.useRef(o),r=tt(n);return U.default.useEffect(()=>{i.current!==o&&(r(o),i.current=o)},[o,i,r]),t}function nt({prop:e,defaultProp:n,onChange:t=()=>{}}){let[o,i]=Jt({defaultProp:n,onChange:t}),r=e!==void 0,a=r?e:o,u=tt(t),E=U.default.useCallback(T=>{if(r){let l=typeof T=="function"?T(e):T;l!==e&&u(l)}else i(T)},[r,e,i,u]);return[a,E]}function rt({activeSnapPointProp:e,setActiveSnapPointProp:n,snapPoints:t,drawerRef:o,overlayRef:i,fadeFromIndex:r}){let[a,u]=nt({prop:e,defaultProp:t==null?void 0:t[0],onChange:n}),E=W.default.useMemo(()=>a===(t==null?void 0:t[t.length-1]),[t,a]),T=t&&t.length>0&&r&&t[r]===a||!t,p=W.default.useMemo(()=>{var c;return(c=t==null?void 0:t.findIndex(b=>b===a))!=null?c:null},[t,a]),l=W.default.useMemo(()=>{var c;return(c=t==null?void 0:t.map(b=>{let v=typeof window!="undefined",N=typeof b=="string",g=0;N&&(g=parseInt(b,10));let R=N?g:v?b*window.innerHeight:0;return v?window.innerHeight-R:R}))!=null?c:[]},[t]),s=W.default.useMemo(()=>p!==null?l==null?void 0:l[p]:null,[l,p]),x=W.default.useCallback(c=>{var v;let b=(v=l==null?void 0:l.findIndex(N=>N===c))!=null?v:null;w(o.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`translate3d(0, ${c}px, 0)`}),l&&b!==l.length-1&&b!==r?w(i.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"0"}):w(i.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"1"}),u(b!==null?t==null?void 0:t[b]:null)},[o,t,l,r,i,u]);W.default.useEffect(()=>{var c;if(e){let b=(c=t==null?void 0:t.findIndex(v=>v===e))!=null?c:null;l&&b&&typeof l[b]=="number"&&x(l[b])}},[e,t,l,x]);function O({draggedDistance:c,closeDrawer:b,velocity:v}){if(typeof s!="number"||r===void 0)return;let N=s-c,g=p===r-1,R=p===0;if(g&&w(i.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),v>2&&c<0){b();return}if(v>2&&c>0&&l&&t){x(l[t.length-1]);return}let D=l==null?void 0:l.reduce((M,k)=>typeof M!="number"||typeof k!="number"?M:Math.abs(k-N)<Math.abs(M-N)?k:M);if(v>he&&Math.abs(c)<window.innerHeight*.4){let M=c>0?1:-1;if(M>0&&E||(R&&M<0&&b(),p===null))return;x(l[p+M]);return}x(D)}function $({draggedDistance:c}){var v;if(s===null)return;let b=s-c;if(b<l[l.length-1]){u((v=t==null?void 0:t[t.length-1])!=null?v:null),w(o.current,{transform:"translate3d(0, 0px, 0)"});return}w(o.current,{transform:`translate3d(0, ${b}px, 0)`})}function F(c,b){if(!t||!p||!l||r===void 0)return null;let v=p===r-1;if(p>=r&&b)return 0;if(v&&!b)return 1;if(!T&&!v)return null;let g=v?p+1:p-1,R=v?l[g]-l[g-1]:l[g+1]-l[g],D=c/Math.abs(R);return v?1-D:D}return{isLastSnapPoint:E,activeSnapPoint:a,shouldFade:T,getPercentageDragged:F,setActiveSnapPoint:u,activeSnapPointIndex:p,onRelease:O,onDrag:$,snapPointsOffset:l}}var Qt=.25,Zt=500,Xt=501,ot=8,Y=16,it=26;function at({open:e,onOpenChange:n,children:t,shouldScaleBackground:o,onDrag:i,onRelease:r,experimentalSafariThemeAnimation:a,snapPoints:u,nested:E,closeThreshold:T=Qt,scrollLockTimeout:p=Zt,dismissible:l=!0,fadeFromIndex:s=u&&u.length-1,activeSnapPoint:x,setActiveSnapPoint:O,modal:$=!0,onClose:F}){var ke;let[c=!1,b]=h.default.useState(!1),[v,N]=h.default.useState(!1),[g,R]=h.default.useState(!1),[D,M]=h.default.useState(!1),[k,re]=h.default.useState(!1),P=h.default.useRef(null),G=h.default.useRef(null),Ie=h.default.useRef(null),K=h.default.useRef(null),J=h.default.useRef(!1),Ee=h.default.useRef(null),ye=h.default.useRef(0),_=h.default.useRef(!1),He=h.default.useRef(0),m=h.default.useRef(null),Ae=h.default.useRef(((ke=m.current)==null?void 0:ke.getBoundingClientRect().height)||0),{onDrag:st,onRelease:oe}=Qe(m,P,c,a),{activeSnapPoint:ct,activeSnapPointIndex:ie,setActiveSnapPoint:Le,onRelease:ft,snapPointsOffset:ae,onDrag:dt,shouldFade:Ne,getPercentageDragged:mt}=rt({snapPoints:u,activeSnapPointProp:x,setActiveSnapPointProp:O,drawerRef:m,fadeFromIndex:s,overlayRef:P});We({isDisabled:!c||D||!$||k}),Ze({isOpen:c,modal:$,nested:E});function le(){return(window.innerWidth-it)/window.innerWidth}function bt(f){var d;l&&(m.current&&!m.current.contains(f.target)||(Ae.current=((d=m.current)==null?void 0:d.getBoundingClientRect().height)||0,M(!0),G.current=new Date,X()&&window.addEventListener("touchend",()=>J.current=!1,{once:!0}),f.target.setPointerCapture(f.pointerId),ye.current=f.clientY))}function $e(f,d){var B;let S=f,L=new Date,I=(B=window.getSelection())==null?void 0:B.toString(),C=m.current?ne(m.current):null;if(C>0)return!0;if(I&&I.length>0)return!1;if(K.current&&L.getTime()-K.current.getTime()<p&&C===0)return K.current=new Date,!1;for(;S;){if(S.scrollHeight>S.clientHeight){if(S.getAttribute("role")==="dialog")return!0;if(d&&S!==document.body&&!C&&C>=0)return K.current=new Date,!1;if(S.scrollTop!==0)return K.current=new Date,!1}S=S.parentNode}return!0}function gt(f){if(D){let d=ye.current-f.clientY,S=d>0;if(!J.current&&!$e(f.target,S))return;if(J.current=!0,w(m.current,{transition:"none"}),w(P.current,{transition:"none"}),u&&dt({draggedDistance:d}),d>0&&!u){let V=et(d);w(m.current,{transform:`translate3d(0, ${Math.min(V*-1,0)}px, 0)`});return}let L=Math.abs(d),I=document.querySelector("[vaul-drawer-wrapper]"),C=L/Ae.current,B=mt(L,S);B!==null&&(C=B);let Te=1-C;if((Ne||s&&ie===s-1)&&(st(C),i==null||i(f,C),w(P.current,{opacity:`${Te}`,transition:"none"},!0)),I&&P.current&&o){let V=Math.min(le()+C*(1-le()),1),ue=8-C*8,yt=Math.max(0,14-C*14);w(I,{borderRadius:`${ue}px`,transform:`scale(${V}) translate3d(0, ${yt}px, 0)`,transition:"none"},!0)}u||w(m.current,{transform:`translate3d(0, ${L}px, 0)`})}}h.default.useEffect(()=>{var d;function f(){var L;if(!m.current)return;let S=document.activeElement;if(Z(S)||_.current){let I=((L=window.visualViewport)==null?void 0:L.height)||0,C=window.innerHeight-I,B=m.current.getBoundingClientRect().height||0,Te=m.current.getBoundingClientRect().top;if(Math.abs(He.current-C)>60&&(_.current=!_.current),u&&u.length>0&&ae&&ie){let V=ae[ie]||0;C+=V}if(He.current=C,B>I||_.current){let V=m.current.getBoundingClientRect().height,ue=V;V>I&&(ue=I-it),m.current.style.height=`${Math.max(ue,I-Te)}px`}else m.current.style.height="initial";u&&u.length>0&&!_.current?m.current.style.bottom="0px":m.current.style.bottom=`${Math.max(C,0)}px`}}return(d=window.visualViewport)==null||d.addEventListener("resize",f),()=>{var S;return(S=window.visualViewport)==null?void 0:S.removeEventListener("resize",f)}},[ie,u,ae]);function q(){m.current&&(F==null||F(),m.current&&(w(m.current,{transform:"translate3d(0, 100%, 0)",transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),w(P.current,{opacity:"0",transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),Fe(!1)),setTimeout(()=>{b(!1),N(!1),u&&Le(u[0])},Xt))}h.default.useEffect(()=>{if(!c&&o){let f=setTimeout(()=>{ve(document.body)},200);return()=>clearTimeout(f)}},[c,o]),h.default.useEffect(()=>{e?b(!0):q()},[e]),h.default.useEffect(()=>{g&&(n==null||n(c))},[c]),h.default.useEffect(()=>{R(!0)},[]);function Pe(){if(!m.current)return;let f=document.querySelector("[vaul-drawer-wrapper]"),d=ne(m.current);w(m.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),w(P.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"1"}),o&&d&&d>0&&c&&w(f,{borderRadius:`${ot}px`,overflow:"hidden",transform:`scale(${le()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`},!0)}function pt(f){if(!D||!m.current)return;J.current&&Z(f.target)&&f.target.blur(),J.current=!1,M(!1),Ie.current=new Date;let d=ne(m.current);if(!$e(f.target,!1)||!d||Number.isNaN(d)||G.current===null)return;let S=f.clientY,L=Ie.current.getTime()-G.current.getTime(),I=ye.current-S,C=Math.abs(I)/L;if(C>.05&&(re(!0),setTimeout(()=>{re(!1)},200)),u){ft({draggedDistance:I,closeDrawer:q,velocity:C});return}if(I>0){Pe(),r==null||r(f,!0),oe(!0);return}if(C>he){q(),r==null||r(f,!1),oe(!1);return}let B=Math.min(m.current.getBoundingClientRect().height||0,window.innerHeight);if(d>=B*T){q(),r==null||r(f,!1),oe(!1);return}r==null||r(f,!0),oe(!0),Pe()}function Fe(f){let d=document.querySelector("[vaul-drawer-wrapper]");!d||!o||(f?(w(document.body,{background:"black"},!0),w(d,{borderRadius:`${ot}px`,overflow:"hidden",transform:`scale(${le()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`})):(ve(d,"transform"),ve(d,"borderRadius"),w(d,{transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`})))}function vt(f){let d=f?(window.innerWidth-Y)/window.innerWidth:1,S=f?-Y:0;Ee.current&&window.clearTimeout(Ee.current),w(m.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`scale(${d}) translate3d(0, ${S}px, 0)`}),!f&&m.current&&(Ee.current=setTimeout(()=>{w(m.current,{transition:"none",transform:`translate3d(0, ${ne(m.current)}px, 0)`})},500))}function ht(f,d){if(d<0)return;let S=(window.innerWidth-Y)/window.innerWidth,L=S+d*(1-S),I=-Y+d*Y;w(m.current,{transform:`scale(${L}) translate3d(0, ${I}px, 0)`,transition:"none"})}function Et(f,d){let S=d?(window.innerWidth-Y)/window.innerWidth:1,L=d?-Y:0;d&&w(m.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`scale(${S}) translate3d(0, ${L}px, 0)`})}return h.default.createElement(H.Root,{modal:$,onOpenChange:f=>{f?b(f):q()},open:c},h.default.createElement(Se.Provider,{value:{visible:v,activeSnapPoint:ct,snapPoints:u,setActiveSnapPoint:Le,drawerRef:m,overlayRef:P,scaleBackground:Fe,onPress:bt,setVisible:N,onRelease:pt,onDrag:gt,dismissible:l,isOpen:c,shouldFade:Ne,closeDrawer:q,onNestedDrag:ht,onNestedOpenChange:vt,onNestedRelease:Et,keyboardIsOpen:_,modal:$,snapPointsOffset:ae,experimentalSafariThemeAnimation:a}},t))}var lt=h.default.forwardRef(function({children:e,style:n,...t},o){let{overlayRef:i,snapPoints:r,onRelease:a,experimentalSafariThemeAnimation:u,shouldFade:E,isOpen:T,visible:p}=ce(),l=Oe(o,i),s=r&&r.length>0;return h.default.createElement(H.Overlay,{onMouseUp:a,ref:l,"vaul-drawer-visible":p?"true":"false","vaul-overlay":"","vaul-snap-points":T&&s?"true":"false","vaul-snap-points-overlay":T&&E?"true":"false","vaul-theme-transition":u?"true":"false",...t})});lt.displayName="Drawer.Overlay";var ut=h.default.forwardRef(function({children:e,onOpenAutoFocus:n,onPointerDownOutside:t,onAnimationEnd:o,style:i,...r},a){let{drawerRef:u,onPress:E,onRelease:T,onDrag:p,dismissible:l,keyboardIsOpen:s,snapPointsOffset:x,visible:O,setVisible:$,closeDrawer:F,scaleBackground:c}=ce(),b=Oe(a,u);return h.default.useEffect(()=>{$(!0),c(!0)},[]),h.default.createElement(H.Content,{onOpenAutoFocus:v=>{n?n(v):v.preventDefault()},onPointerDown:E,onPointerDownOutside:v=>{s.current&&(s.current=!1),v.preventDefault(),l&&(F(),t==null||t(v))},onPointerMove:p,onPointerUp:T,ref:b,style:x?{"--snap-point-height":`${x[0]}px`,...i}:i,...r,"vaul-drawer":"","vaul-drawer-visible":O?"true":"false"},e)});ut.displayName="Drawer.Content";function en({children:e,onDrag:n,onOpenChange:t}){let{onNestedDrag:o,onNestedOpenChange:i,onNestedRelease:r}=ce();if(!o)throw new Error("Drawer.NestedRoot must be placed in another drawer");return h.default.createElement(at,{nested:!0,onClose:()=>{i(!1)},onDrag:(a,u)=>{o(a,u),n==null||n(a,u)},onOpenChange:a=>{a&&i(a),t==null||t(a)},onRelease:r},e)}var tn={Root:at,NestedRoot:en,Content:ut,Overlay:lt,Trigger:H.Trigger,Portal:H.Portal,Close:H.Close,Title:H.Title,Description:H.Description};0&&(module.exports={Drawer});
"use client";var Tt=Object.create;var se=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var Rt=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty;var Mt=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},Be=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of St(n))!Dt.call(e,i)&&i!==t&&se(e,i,{get:()=>n[i],enumerable:!(o=wt(n,i))||o.enumerable});return e};var j=(e,n,t)=>(t=e!=null?Tt(Rt(e)):{},Be(n||!e||!e.__esModule?se(t,"default",{value:e,enumerable:!0}):t,e)),Ct=e=>Be(se({},"__esModule",{value:!0}),e);var tn={};Mt(tn,{Drawer:()=>en});module.exports=Ct(tn);var H=j(require("@radix-ui/react-dialog")),h=j(require("react"));var we=j(require("react")),Se=we.default.createContext({drawerRef:{current:null},overlayRef:{current:null},scaleBackground:()=>{},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},dismissible:!1,isOpen:!1,keyboardIsOpen:{current:!1},experimentalSafariThemeAnimation:!1,snapPointsOffset:null,snapPoints:null,modal:!1,shouldFade:!1,activeSnapPoint:null,setActiveSnapPoint:()=>{},visible:!1,closeDrawer:()=>{},setVisible:()=>{}}),ce=()=>we.default.useContext(Se);function Re(e,{insertAt:n}={}){if(!e||typeof document=="undefined")return;let t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",n==="top"&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}Re(`[vaul-drawer]{touch-action:none;transform:translate3d(0,100%,0);transition:transform .5s cubic-bezier(.32,.72,0,1)}[vaul-drawer][vaul-drawer-visible=true]{transform:translate3d(0,var(--snap-point-height, 0),0)}[vaul-overlay]{opacity:0;transition:opacity .5s cubic-bezier(.32,.72,0,1)}[vaul-overlay][vaul-drawer-visible=true]{opacity:1}[vaul-drawer]:after{content:"";position:absolute;top:100%;background:inherit;background-color:inherit;left:0;right:0;height:200%}[vaul-overlay][vaul-snap-points=true]:not([vaul-snap-points-overlay="true"]):not([data-state="closed"]){opacity:0}[vaul-overlay][vaul-snap-points-overlay=true]:not([vaul-drawer-visible="false"]){opacity:1}@keyframes fake-animation{}@keyframes show-theme-overlay{0%{background:var(--vaul-overlay-background-start)}to{background:var(--vaul-overlay-background-end)}}@keyframes hide-theme-overlay{0%{background:var(--vaul-overlay-background-end)}to{background:var(--vaul-overlay-background-start)}}@media (hover: hover) and (pointer: fine){[vaul-drawer]{user-select:none}}
`);var me=require("react"),xt=typeof window!="undefined"?me.useLayoutEffect:me.useEffect;function Ce(...e){return(...n)=>{for(let t of e)typeof t=="function"&&t(...n)}}function Ot(){return xe(/^Mac/)}function It(){return xe(/^iPhone/)}function ze(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Ht(){return xe(/^iPad/)||Ot()&&navigator.maxTouchPoints>1}function X(){return It()||Ht()}function xe(e){return typeof window!="undefined"&&window.navigator!=null?e.test(window.navigator.platform):void 0}var De=typeof document!="undefined"&&window.visualViewport;function Ve(e){let n=window.getComputedStyle(e);return/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY)}function Ue(e){for(Ve(e)&&(e=e.parentElement);e&&!Ve(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}var At=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),fe=0,Me;function We(e={}){let{isDisabled:n}=e;xt(()=>{if(!n)return fe++,fe===1&&(X()?Me=Nt():Me=Lt()),()=>{fe--,fe===0&&Me()}},[n])}function Lt(){return Ce(de(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),de(document.documentElement,"overflow","hidden"))}function Nt(){let e,n=0,t=l=>{e=Ue(l.target),!(e===document.documentElement&&e===document.body)&&(n=l.changedTouches[0].pageY)},o=l=>{if(!e||e===document.documentElement||e===document.body){l.preventDefault();return}let s=l.changedTouches[0].pageY,x=e.scrollTop,O=e.scrollHeight-e.clientHeight;O!==0&&((x<=0&&s>n||x>=O&&s<n)&&l.preventDefault(),n=s)},i=l=>{let s=l.target;Z(s)&&s!==document.activeElement&&(l.preventDefault(),s.style.transform="translateY(-2000px)",s.focus(),requestAnimationFrame(()=>{s.style.transform=""}))},r=l=>{let s=l.target;Z(s)&&(s.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{s.style.transform="",De&&(De.height<window.innerHeight?requestAnimationFrame(()=>{je(s)}):De.addEventListener("resize",()=>je(s),{once:!0}))}))},a=()=>{window.scrollTo(0,0)},u=window.pageXOffset,E=window.pageYOffset,T=Ce(de(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),de(document.documentElement,"overflow","hidden"));window.scrollTo(0,0);let p=Ce(Q(document,"touchstart",t,{passive:!1,capture:!0}),Q(document,"touchmove",o,{passive:!1,capture:!0}),Q(document,"touchend",i,{passive:!1,capture:!0}),Q(document,"focus",r,!0),Q(window,"scroll",a));return()=>{T(),p(),window.scrollTo(u,E)}}function de(e,n,t){let o=e.style[n];return e.style[n]=t,()=>{e.style[n]=o}}function Q(e,n,t,o){return e.addEventListener(n,t,o),()=>{e.removeEventListener(n,t,o)}}function je(e){let n=document.scrollingElement||document.documentElement;for(;e&&e!==n;){let t=Ue(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let o=t.getBoundingClientRect().top,i=e.getBoundingClientRect().top,r=e.getBoundingClientRect().bottom,a=t.getBoundingClientRect().bottom;r>a&&(t.scrollTop+=i-o)}e=t.parentElement}}function Z(e){return e instanceof HTMLInputElement&&!At.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var Ye=j(require("react"));function $t(e,n){typeof e=="function"?e(n):e!=null&&(e.current=n)}function Pt(...e){return n=>e.forEach(t=>$t(t,n))}function Oe(...e){return Ye.useCallback(Pt(...e),e)}var A=j(require("react"));var Ft=4,kt=.001,Bt=1e-7,Vt=10,ee=11,be=1/(ee-1),jt=typeof Float32Array=="function";function _e(e,n){return 1-3*n+3*e}function qe(e,n){return 3*n-6*e}function Ge(e){return 3*e}function ge(e,n,t){return((_e(n,t)*e+qe(n,t))*e+Ge(n))*e}function Ke(e,n,t){return 3*_e(n,t)*e*e+2*qe(n,t)*e+Ge(n)}function zt(e,n,t,o,i){var r,a,u=0;do a=n+(t-n)/2,r=ge(a,o,i)-e,r>0?t=a:n=a;while(Math.abs(r)>Bt&&++u<Vt);return a}function Ut(e,n,t,o){for(var i=0;i<Ft;++i){var r=Ke(n,t,o);if(r===0)return n;var a=ge(n,t,o)-e;n-=a/r}return n}function Wt(e){return e}function Je(e,n,t,o){if(!(0<=e&&e<=1&&0<=t&&t<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===n&&t===o)return Wt;for(var i=jt?new Float32Array(ee):new Array(ee),r=0;r<ee;++r)i[r]=ge(r*be,e,t);function a(u){for(var E=0,T=1,p=ee-1;T!==p&&i[T]<=u;++T)E+=be;--T;var l=(u-i[T])/(i[T+1]-i[T]),s=E+l*be,x=Ke(s,e,t);return x>=kt?Ut(u,s,e,t):x===0?s:zt(u,E,E+be,e,t)}return function(E){return E===0||E===1?E:ge(a(E),n,o)}}var Yt=Je(.32,.72,0,1);function _t(e){let n=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+),\s*(\d*(?:\.\d+)?)\)/);if(!n)throw new Error("Invalid color string");return[Number(n[1]),Number(n[2]),Number(n[3]),Number(n[4])]}function qt(e,n){let[t,o,i,r]=_t(e);return[Math.round(r*t+(1-r)*Number(n[0])),Math.round(r*o+(1-r)*Number(n[1])),Math.round(r*i+(1-r)*Number(n[2]))]}function Gt(e){return Yt(e)}function Kt(e,n,t,o){arguments.length<3&&(t=.5);let i=e.slice();for(let r=0;r<3;r++){let a=n[r]-e[r],u=o?e[r]+t*a:e[r]+Gt(t)*a;i[r]=Math.round(u),i[r]<0&&(i[r]=0),i[r]>255&&(i[r]=255)}return i}function te(e,n,t,o){let i=1/(t-1),r=[];for(let a=0;a<t;a++)r.push(Kt(e,n,i*a,!!o));return r}function Qe(e,n,t,o){let[i,r]=A.default.useState([255,255,255]),[a,u]=A.default.useState([153,153,153]),[E,T]=A.default.useState(!1),[p,l]=A.default.useState(null),[s,x]=A.default.useState(null),O=A.default.useMemo(()=>X()&&ze()&&o,[o]),$=A.default.useMemo(()=>i&&a?te(i,a,50):null,[a,i]),F=A.default.useMemo(()=>i&&a?te(a,i,50):null,[a,i]),c=A.default.useMemo(()=>i&&a?te(a,i,50,!0):null,[a,i]);A.default.useEffect(()=>{if(!O)return;let g=getComputedStyle(document.documentElement),R=g.getPropertyValue("--vaul-overlay-background").split(",").map(k=>Number(k)),D=g.getPropertyValue("--vaul-overlay-background-end"),M=qt(D,R);r(R),u(M)},[O]),A.default.useEffect(()=>{if(O&&!p){let g=document.querySelector('meta[name="theme-color"]');g?l(g.getAttribute("content")):(g=document.createElement("meta"),g.name="theme-color",document.getElementsByTagName("head")[0].appendChild(g)),x(g)}},[p,O]);let b=(0,A.useCallback)(g=>{let R,D;function M(k){R||(R=k);let re=k-R,P=Math.floor(re/10);if(n.current&&g&&!E&&e.current){if(e.current.style.transform==="translateY(0px)"&&e.current.getAttribute("vaul-clicked-outside")!=="true")return;if(P<g.length){let G=g[P];s==null||s.setAttribute("content",`rgb(${G.join(",")})`),P===g.length-1&&p&&!t&&(s==null||s.setAttribute("content",p)),D=requestAnimationFrame(M)}}}return D=requestAnimationFrame(M),D},[e,t,s,E,p,n]);A.default.useEffect(()=>{if(!O||!$||!F)return;let g=b(t?$:F);return t&&T(!1),()=>{g&&cancelAnimationFrame(g)}},[t,O,b,$,F]);function v(g){let R=document.querySelector('meta[name="theme-color"]');if(!O||!R||!c)return;let D=Math.floor(g*c.length);D=Math.max(0,Math.min(c.length-1,D));let M=c[D];R.setAttribute("content",`rgb(${M.join(",")})`)}function N(g){let R=document.querySelector('meta[name="theme-color"]');if(!R||!O)return;T(!0);let D=R.getAttribute("content").match(/\d+/g).map(Number),M=te(D,a,50);!g&&i&&(M=te(D,i,50)),b(M)}return{onDrag:v,onRelease:N}}var pe=j(require("react")),z=null;function Ze({isOpen:e,modal:n,nested:t}){let o=pe.default.useRef(0);function i(){if(z===null){z={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height};let{scrollX:a,innerHeight:u}=window;document.body.style.setProperty("position","fixed","important"),document.body.style.top=`${-o.current}px`,document.body.style.left=`${-a}px`,document.body.style.right="0px",document.body.style.height="auto",setTimeout(()=>requestAnimationFrame(()=>{let E=u-window.innerHeight;E&&o.current>=u&&(document.body.style.top=`${-(o.current+E)}px`)}),300)}}function r(){if(z!==null){let a=-parseInt(document.body.style.top,10),u=-parseInt(document.body.style.left,10);document.body.style.position=z.position,document.body.style.top=z.top,document.body.style.left=z.left,document.body.style.height=z.height,document.body.style.right="unset",requestAnimationFrame(()=>{window.scrollTo(u,a)}),z=null}}pe.default.useEffect(()=>{function a(){o.current=window.scrollY}return a(),window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a)}},[]),pe.default.useEffect(()=>{t||(e?(i(),n||setTimeout(()=>{r()},500)):r())},[e])}var W=j(require("react"));var Xe=new WeakMap;function w(e,n,t=!1){if(!e||!(e instanceof HTMLElement)||!n)return;let o={};Object.entries(n).forEach(([i,r])=>{if(i.startsWith("--")){e.style.setProperty(i,r);return}o[i]=e.style[i],e.style[i]=r}),!t&&Xe.set(e,o)}function ve(e,n){if(!e||!(e instanceof HTMLElement))return;let t=Xe.get(e);t&&(n?e.style[n]=t[n]:Object.entries(t).forEach(([o,i])=>{e.style[o]=i}))}function ne(e){let n=window.getComputedStyle(e),t=n.transform||n.webkitTransform||n.mozTransform,o=t.match(/^matrix3d\((.+)\)$/);return o?parseFloat(o[1].split(", ")[13]):(o=t.match(/^matrix\((.+)\)$/),o?parseFloat(o[1].split(", ")[5]):null)}function et(e){return 8*(Math.log(e+1)-2)}var y={DURATION:.5,EASE:[.32,.72,0,1]},he=.4;var U=j(require("react"));function tt(e){let n=U.default.useRef(e);return U.default.useEffect(()=>{n.current=e}),U.default.useMemo(()=>(...t)=>{var o;return(o=n.current)==null?void 0:o.call(n,...t)},[])}function Jt({defaultProp:e,onChange:n}){let t=U.default.useState(e),[o]=t,i=U.default.useRef(o),r=tt(n);return U.default.useEffect(()=>{i.current!==o&&(r(o),i.current=o)},[o,i,r]),t}function nt({prop:e,defaultProp:n,onChange:t=()=>{}}){let[o,i]=Jt({defaultProp:n,onChange:t}),r=e!==void 0,a=r?e:o,u=tt(t),E=U.default.useCallback(T=>{if(r){let l=typeof T=="function"?T(e):T;l!==e&&u(l)}else i(T)},[r,e,i,u]);return[a,E]}function rt({activeSnapPointProp:e,setActiveSnapPointProp:n,snapPoints:t,drawerRef:o,overlayRef:i,fadeFromIndex:r}){let[a,u]=nt({prop:e,defaultProp:t==null?void 0:t[0],onChange:n}),E=W.default.useMemo(()=>a===(t==null?void 0:t[t.length-1]),[t,a]),T=t&&t.length>0&&r&&t[r]===a||!t,p=W.default.useMemo(()=>{var c;return(c=t==null?void 0:t.findIndex(b=>b===a))!=null?c:null},[t,a]),l=W.default.useMemo(()=>{var c;return(c=t==null?void 0:t.map(b=>{let v=typeof window!="undefined",N=typeof b=="string",g=0;N&&(g=parseInt(b,10));let R=N?g:v?b*window.innerHeight:0;return v?window.innerHeight-R:R}))!=null?c:[]},[t]),s=W.default.useMemo(()=>p!==null?l==null?void 0:l[p]:null,[l,p]),x=W.default.useCallback(c=>{var v;let b=(v=l==null?void 0:l.findIndex(N=>N===c))!=null?v:null;w(o.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`translate3d(0, ${c}px, 0)`}),l&&b!==l.length-1&&b!==r?w(i.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"0"}):w(i.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"1"}),u(b!==null?t==null?void 0:t[b]:null)},[o,t,l,r,i,u]);W.default.useEffect(()=>{var c;if(e){let b=(c=t==null?void 0:t.findIndex(v=>v===e))!=null?c:null;l&&b&&typeof l[b]=="number"&&x(l[b])}},[e,t,l,x]);function O({draggedDistance:c,closeDrawer:b,velocity:v}){if(typeof s!="number"||r===void 0)return;let N=s-c,g=p===r-1,R=p===0;if(g&&w(i.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),v>2&&c<0){b();return}if(v>2&&c>0&&l&&t){x(l[t.length-1]);return}let D=l==null?void 0:l.reduce((M,k)=>typeof M!="number"||typeof k!="number"?M:Math.abs(k-N)<Math.abs(M-N)?k:M);if(v>he&&Math.abs(c)<window.innerHeight*.4){let M=c>0?1:-1;if(M>0&&E||(R&&M<0&&b(),p===null))return;x(l[p+M]);return}x(D)}function $({draggedDistance:c}){var v;if(s===null)return;let b=s-c;if(b<l[l.length-1]){u((v=t==null?void 0:t[t.length-1])!=null?v:null),w(o.current,{transform:"translate3d(0, 0px, 0)"});return}w(o.current,{transform:`translate3d(0, ${b}px, 0)`})}function F(c,b){if(!t||!p||!l||r===void 0)return null;let v=p===r-1;if(p>=r&&b)return 0;if(v&&!b)return 1;if(!T&&!v)return null;let g=v?p+1:p-1,R=v?l[g]-l[g-1]:l[g+1]-l[g],D=c/Math.abs(R);return v?1-D:D}return{isLastSnapPoint:E,activeSnapPoint:a,shouldFade:T,getPercentageDragged:F,setActiveSnapPoint:u,activeSnapPointIndex:p,onRelease:O,onDrag:$,snapPointsOffset:l}}var Qt=.25,Zt=500;var ot=8,Y=16,it=26;function at({open:e,onOpenChange:n,children:t,shouldScaleBackground:o,onDrag:i,onRelease:r,experimentalSafariThemeAnimation:a,snapPoints:u,nested:E,closeThreshold:T=Qt,scrollLockTimeout:p=Zt,dismissible:l=!0,fadeFromIndex:s=u&&u.length-1,activeSnapPoint:x,setActiveSnapPoint:O,modal:$=!0,onClose:F}){var ke;let[c=!1,b]=h.default.useState(!1),[v,N]=h.default.useState(!1),[g,R]=h.default.useState(!1),[D,M]=h.default.useState(!1),[k,re]=h.default.useState(!1),P=h.default.useRef(null),G=h.default.useRef(null),Ie=h.default.useRef(null),K=h.default.useRef(null),J=h.default.useRef(!1),Ee=h.default.useRef(null),ye=h.default.useRef(0),_=h.default.useRef(!1),He=h.default.useRef(0),m=h.default.useRef(null),Ae=h.default.useRef(((ke=m.current)==null?void 0:ke.getBoundingClientRect().height)||0),{onDrag:st,onRelease:oe}=Qe(m,P,c,a),{activeSnapPoint:ct,activeSnapPointIndex:ie,setActiveSnapPoint:Le,onRelease:ft,snapPointsOffset:ae,onDrag:dt,shouldFade:Ne,getPercentageDragged:mt}=rt({snapPoints:u,activeSnapPointProp:x,setActiveSnapPointProp:O,drawerRef:m,fadeFromIndex:s,overlayRef:P});We({isDisabled:!c||D||!$||k}),Ze({isOpen:c,modal:$,nested:E});function le(){return(window.innerWidth-it)/window.innerWidth}function bt(f){var d;l&&(m.current&&!m.current.contains(f.target)||(Ae.current=((d=m.current)==null?void 0:d.getBoundingClientRect().height)||0,M(!0),G.current=new Date,X()&&window.addEventListener("touchend",()=>J.current=!1,{once:!0}),f.target.setPointerCapture(f.pointerId),ye.current=f.clientY))}function $e(f,d){var B;let S=f,L=new Date,I=(B=window.getSelection())==null?void 0:B.toString(),C=m.current?ne(m.current):null;if(C>0)return!0;if(I&&I.length>0)return!1;if(K.current&&L.getTime()-K.current.getTime()<p&&C===0)return K.current=new Date,!1;for(;S;){if(S.scrollHeight>S.clientHeight){if(S.getAttribute("role")==="dialog")return!0;if(d&&S!==document.body&&!C&&C>=0)return K.current=new Date,!1;if(S.scrollTop!==0)return K.current=new Date,!1}S=S.parentNode}return!0}function gt(f){if(D){let d=ye.current-f.clientY,S=d>0;if(!J.current&&!$e(f.target,S))return;if(J.current=!0,w(m.current,{transition:"none"}),w(P.current,{transition:"none"}),u&&dt({draggedDistance:d}),d>0&&!u){let V=et(d);w(m.current,{transform:`translate3d(0, ${Math.min(V*-1,0)}px, 0)`});return}let L=Math.abs(d),I=document.querySelector("[vaul-drawer-wrapper]"),C=L/Ae.current,B=mt(L,S);B!==null&&(C=B);let Te=1-C;if((Ne||s&&ie===s-1)&&(st(C),i==null||i(f,C),w(P.current,{opacity:`${Te}`,transition:"none"},!0)),I&&P.current&&o){let V=Math.min(le()+C*(1-le()),1),ue=8-C*8,yt=Math.max(0,14-C*14);w(I,{borderRadius:`${ue}px`,transform:`scale(${V}) translate3d(0, ${yt}px, 0)`,transition:"none"},!0)}u||w(m.current,{transform:`translate3d(0, ${L}px, 0)`})}}h.default.useEffect(()=>{var d;function f(){var L;if(!m.current)return;let S=document.activeElement;if(Z(S)||_.current){let I=((L=window.visualViewport)==null?void 0:L.height)||0,C=window.innerHeight-I,B=m.current.getBoundingClientRect().height||0,Te=m.current.getBoundingClientRect().top;if(Math.abs(He.current-C)>60&&(_.current=!_.current),u&&u.length>0&&ae&&ie){let V=ae[ie]||0;C+=V}if(He.current=C,B>I||_.current){let V=m.current.getBoundingClientRect().height,ue=V;V>I&&(ue=I-it),m.current.style.height=`${Math.max(ue,I-Te)}px`}else m.current.style.height="initial";u&&u.length>0&&!_.current?m.current.style.bottom="0px":m.current.style.bottom=`${Math.max(C,0)}px`}}return(d=window.visualViewport)==null||d.addEventListener("resize",f),()=>{var S;return(S=window.visualViewport)==null?void 0:S.removeEventListener("resize",f)}},[ie,u,ae]);function q(){m.current&&(F==null||F(),m.current&&(w(m.current,{transform:"translate3d(0, 100%, 0)",transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),w(P.current,{opacity:"0",transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),Fe(!1)),setTimeout(()=>{b(!1),N(!1)},300),setTimeout(()=>{u&&Le(u[0])},500))}h.default.useEffect(()=>{if(!c&&o){let f=setTimeout(()=>{ve(document.body)},200);return()=>clearTimeout(f)}},[c,o]),h.default.useEffect(()=>{e?b(!0):q()},[e]),h.default.useEffect(()=>{g&&(n==null||n(c))},[c]),h.default.useEffect(()=>{R(!0)},[]);function Pe(){if(!m.current)return;let f=document.querySelector("[vaul-drawer-wrapper]"),d=ne(m.current);w(m.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`}),w(P.current,{transition:`opacity ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,opacity:"1"}),o&&d&&d>0&&c&&w(f,{borderRadius:`${ot}px`,overflow:"hidden",transform:`scale(${le()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`},!0)}function pt(f){if(!D||!m.current)return;J.current&&Z(f.target)&&f.target.blur(),J.current=!1,M(!1),Ie.current=new Date;let d=ne(m.current);if(!$e(f.target,!1)||!d||Number.isNaN(d)||G.current===null)return;let S=f.clientY,L=Ie.current.getTime()-G.current.getTime(),I=ye.current-S,C=Math.abs(I)/L;if(C>.05&&(re(!0),setTimeout(()=>{re(!1)},200)),u){ft({draggedDistance:I,closeDrawer:q,velocity:C});return}if(I>0){Pe(),r==null||r(f,!0),oe(!0);return}if(C>he){q(),r==null||r(f,!1),oe(!1);return}let B=Math.min(m.current.getBoundingClientRect().height||0,window.innerHeight);if(d>=B*T){q(),r==null||r(f,!1),oe(!1);return}r==null||r(f,!0),oe(!0),Pe()}function Fe(f){let d=document.querySelector("[vaul-drawer-wrapper]");!d||!o||(f?(w(document.body,{background:"black"},!0),w(d,{borderRadius:`${ot}px`,overflow:"hidden",transform:`scale(${le()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top",transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`})):(ve(d,"transform"),ve(d,"borderRadius"),w(d,{transitionProperty:"transform, border-radius",transitionDuration:`${y.DURATION}s`,transitionTimingFunction:`cubic-bezier(${y.EASE.join(",")})`})))}function vt(f){let d=f?(window.innerWidth-Y)/window.innerWidth:1,S=f?-Y:0;Ee.current&&window.clearTimeout(Ee.current),w(m.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`scale(${d}) translate3d(0, ${S}px, 0)`}),!f&&m.current&&(Ee.current=setTimeout(()=>{w(m.current,{transition:"none",transform:`translate3d(0, ${ne(m.current)}px, 0)`})},500))}function ht(f,d){if(d<0)return;let S=(window.innerWidth-Y)/window.innerWidth,L=S+d*(1-S),I=-Y+d*Y;w(m.current,{transform:`scale(${L}) translate3d(0, ${I}px, 0)`,transition:"none"})}function Et(f,d){let S=d?(window.innerWidth-Y)/window.innerWidth:1,L=d?-Y:0;d&&w(m.current,{transition:`transform ${y.DURATION}s cubic-bezier(${y.EASE.join(",")})`,transform:`scale(${S}) translate3d(0, ${L}px, 0)`})}return h.default.createElement(H.Root,{modal:$,onOpenChange:f=>{f?b(f):q()},open:c},h.default.createElement(Se.Provider,{value:{visible:v,activeSnapPoint:ct,snapPoints:u,setActiveSnapPoint:Le,drawerRef:m,overlayRef:P,scaleBackground:Fe,onPress:bt,setVisible:N,onRelease:pt,onDrag:gt,dismissible:l,isOpen:c,shouldFade:Ne,closeDrawer:q,onNestedDrag:ht,onNestedOpenChange:vt,onNestedRelease:Et,keyboardIsOpen:_,modal:$,snapPointsOffset:ae,experimentalSafariThemeAnimation:a}},t))}var lt=h.default.forwardRef(function({children:e,style:n,...t},o){let{overlayRef:i,snapPoints:r,onRelease:a,experimentalSafariThemeAnimation:u,shouldFade:E,isOpen:T,visible:p}=ce(),l=Oe(o,i),s=r&&r.length>0;return h.default.createElement(H.Overlay,{onMouseUp:a,ref:l,"vaul-drawer-visible":p?"true":"false","vaul-overlay":"","vaul-snap-points":T&&s?"true":"false","vaul-snap-points-overlay":T&&E?"true":"false","vaul-theme-transition":u?"true":"false",...t})});lt.displayName="Drawer.Overlay";var ut=h.default.forwardRef(function({children:e,onOpenAutoFocus:n,onPointerDownOutside:t,onAnimationEnd:o,style:i,...r},a){let{drawerRef:u,onPress:E,onRelease:T,onDrag:p,dismissible:l,keyboardIsOpen:s,snapPointsOffset:x,visible:O,setVisible:$,closeDrawer:F,scaleBackground:c}=ce(),b=Oe(a,u);return h.default.useEffect(()=>{$(!0),c(!0)},[]),h.default.createElement(H.Content,{onOpenAutoFocus:v=>{n?n(v):v.preventDefault()},onPointerDown:E,onPointerDownOutside:v=>{s.current&&(s.current=!1),v.preventDefault(),l&&(F(),t==null||t(v))},onPointerMove:p,onPointerUp:T,ref:b,style:x?{"--snap-point-height":`${x[0]}px`,...i}:i,...r,"vaul-drawer":"","vaul-drawer-visible":O?"true":"false"},e)});ut.displayName="Drawer.Content";function Xt({children:e,onDrag:n,onOpenChange:t}){let{onNestedDrag:o,onNestedOpenChange:i,onNestedRelease:r}=ce();if(!o)throw new Error("Drawer.NestedRoot must be placed in another drawer");return h.default.createElement(at,{nested:!0,onClose:()=>{i(!1)},onDrag:(a,u)=>{o(a,u),n==null||n(a,u)},onOpenChange:a=>{a&&i(a),t==null||t(a)},onRelease:r},e)}var en={Root:at,NestedRoot:Xt,Content:ut,Overlay:lt,Trigger:H.Trigger,Portal:H.Portal,Close:H.Close,Title:H.Title,Description:H.Description};0&&(module.exports={Drawer});
//# sourceMappingURL=index.js.map
{
"name": "vaul",
"version": "0.6.2",
"version": "0.6.3",
"description": "Drawer component for React.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc