@plainsheet/react 0.4.11 → 0.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,14 +1,15 @@
1
1
  <p align="center">
2
- <a href="https://https://www.plainsheet.org/">
3
- <img src="https://github.com/plainsheet/plainsheet/raw/main/documents/assets/readme-header.png" width="328" height="167">
2
+ <a href="https://www.plainsheet.org/">
3
+ <img src="https://github.com/plainsheet/plainsheet/raw/main/documents/assets/readme-header-mascot.png" width="328" height="167">
4
4
  </a>
5
5
  </p>
6
6
 
7
- ![Core Bundle Size](https://deno.bundlejs.com/badge?q=@plainsheet/core@latest&badge=detailed)
8
- ![Core NPM Downloads](https://img.shields.io/npm/dt/@plainsheet/react)
9
-
10
- ![React Bundle Size](https://deno.bundlejs.com/badge?q=@plainsheet/react@latest&badge=detailed)
11
- ![React NPM Downloads](https://img.shields.io/npm/dt/@plainsheet/core)
7
+ **Plainsheet/Core**
8
+ ![Core Bundle Size](https://img.shields.io/bundlephobia/minzip/@plainsheet/core)
9
+ ![Core NPM Downloads](https://img.shields.io/npm/dt/@plainsheet/core)
10
+ **Plainsheet/React**
11
+ ![React Bundle Size](https://img.shields.io/bundlephobia/minzip/@plainsheet/react)
12
+ ![React NPM Downloads](https://img.shields.io/npm/dt/@plainsheet/react)
12
13
 
13
14
  <a href="https://codecov.io/gh/PeterByun/plain-bottom-sheet" >
14
15
  <img src="https://codecov.io/gh/PeterByun/plain-bottom-sheet/graph/badge.svg?token=WFHGUAI3GC"/>
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export * from './BottomSheet';
2
- export * from './hooks';
1
+ export { BottomSheet, createPlaceholderBottomSheet } from './BottomSheet';
2
+ export type { BottomSheetCore, BottomSheetProps } from './BottomSheet';
3
+ export { useBottomSheet } from './hooks';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),xt=require("react-dom");function Bt(t){return t!=null}(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var At=Object.defineProperty,Dt=(t,e,n)=>e in t?At(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,K=(t,e,n)=>Dt(t,typeof e!="symbol"?e+"":e,n);function x(t){return typeof t=="string"}function Mt(t,e){return t.classList.contains(et(e))}function V(t,e){t.classList.add(et(e))}function ot(t,e){t.classList.remove(et(e))}function X(t,e,n){x(n)&&(x(e)&&ot(t,e),V(t,n))}function et(t){return x(t)?t.trim().replace(/\./g,""):""}function W(t){return t.map(e=>et(e)).filter(Boolean).join(" ")}function Pt(t){return t.map(e=>e==null?void 0:e.trim()).filter(Boolean).map(e=>`.${e}`).join(" ")}const ut="open",dt="hidden";function nt(t,e){const n=e;if(Array.isArray(t)){t.forEach(o=>{Q(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Q(t,n),t.setAttribute("aria-modal",n?"true":"false")}function Q(t,e){e?(V(t,ut),ot(t,dt)):(V(t,dt),ot(t,ut))}function St(t){return t instanceof HTMLElement}function A(t){return typeof t=="number"&&!Number.isNaN(t)}function Yt(t){St(t)&&t.focus()}function Ft(t){if(!St(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),n=A(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),r=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||r||n>-1}var T=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(T||{}),rt=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(rt||{}),J=(t=>(t.Hidden="hidden",t))(J||{});function P(t,e,n){const o=document.createElement(t);return e.split(" ").forEach(r=>{V(o,r)}),x(n)&&o.setAttribute("data-testid",n),o}Pt([T.Root,T.ContentWrapper]);function pt(t,e,n,o){switch(o){case"content-height":return e>=t?Et(t,e,n):0;case"middle":return-(t/2-e);case"top":return-(t-e)+n;default:return 0}}function yt(t,e){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function Ct(t,e){return e<t?-(t-e):e-t}function z(t,e){return t>e?t-e:e-t}function It(t,e){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function ht(t,e,n){const o=t==="above";return n.filter(r=>{const i=r*e.viewportHeight;return o?e.visibleHeight<i:e.visibleHeight>i})}function Et(t,e,n){return-(t-e)+n}function mt(t){return Number(t.replace("px",""))}function Z(t,...e){return Number(t.toFixed(...e))}function wt(t){const e=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=e.exec(t))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function Rt(t){const e=t.style.transform,n=wt(e);return{transform:e,transformValues:n}}function kt(t,e){return t.find(o=>o.type.startsWith(e))||null}const at="translate";function M(t){const e=t.style.transform,n=wt(e),o=kt(n,at);return Tt(o??{type:at,values:[]})}function tt(t,{x:e,y:n}){const{transform:o,transformValues:r}=Rt(t),i=kt(r,at);if(i){const a=Tt(i);t.style.transform=`translate(${e??a.x??0}px,${n??a.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${e??0}px,${n??0}px)`;return}t.style.transform=`translate(${e??0}px,${n??0}px)`}function Tt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const e=t.values[0],n=t.values[1];return{x:mt(e)??0,y:mt(n)??0}}function it(t){return t!=null}function ft(t,{min:e,max:n}){return it(n)&&t>=n?n:it(e)&&t<=e?e:t}const Wt=(t,e,n)=>{e instanceof HTMLElement&&!Mt(e,T.Handle)&&n.scrollTop>=1||(t.isDragging=!0)},Nt=(t,e,n,o)=>r=>{o.startY=t.getCoordinates(r).y,o.containerStartTranslate=M(e),n.onDragStart()},jt=(t,e,n,o,r)=>i=>{Gt(i,t,n,o,r,e,n.marginTop)};function Gt(t,e,n,o,r,i,a){if(!o.isDragging||!A(o.startY))return;const l=e.getCoordinates(t).y,u=Ct(o.startY,l),h=window.innerHeight,s=i.clientHeight,f=s-(o.containerStartTranslate.y+u);if(f>=h)return;const y=yt(o.startY,l);if(y.isUp&&!n.expandable&&f>=s||n.preventClosing&&f<=s)return;r.start(()=>{tt(i,{y:o.containerStartTranslate.y+u})},0);const c=h-a,C=s-o.containerStartTranslate.y;if(y.isUp){const v=c-C,S=c-f,E=ft(1-Z(S/v,2),{min:0,max:1});n.onDragMove(y,E)}else if(y.isDown){const v=ft(Z(1-f/C,2),{min:0,max:1});n.onDragMove(y,v)}}const Ut=(t,e,n,o,r,i,a)=>l=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const u=o.startY,h=t.getCoordinates(l).y,s=M(e).y,f=yt(u,h),y=window.innerHeight,c=e.clientHeight;if(f.isUp){if(!n.expandable)return;const C=[...n.snapPoints].sort((E,B)=>E-B),v=c+-s;for(const E of C){const B=E*window.innerHeight;if(v<=B){const k=z(v,B);a.translateContainer({startY:s,endY:s-k,animationFrame:r,bottomSheetContainer:e});return}}const S=Et(y,c,n.marginTop);a.translateContainer({startY:s,endY:S,animationFrame:r,bottomSheetContainer:e})}else if(f.isDown){const C=[...n.snapPoints].sort((v,S)=>S-v);for(const v of C){const S=v*window.innerHeight,E=c+-s;if(E>=S){const B=z(E,S);a.translateContainer({startY:s,endY:s+B,animationFrame:r,bottomSheetContainer:e});return}}if(n.preventClosing){const v=c+-s;if(v>=c){const S=z(v,c);a.translateContainer({startY:s,endY:s+S,animationFrame:r,bottomSheetContainer:e})}return}i()}};var G=(t=>(t[t.All=-1]="All",t[t.None=0]="None",t[t.Capture=1]="Capture",t[t.Target=2]="Target",t[t.Bubble=3]="Bubble",t))(G||{});function bt(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const $t={eventPhase:G.All};class q{constructor(e){K(this,"currentTarget"),this.currentTarget=e}addEventListeners({onStart:e,onStartOptions:n=$t,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===G.All){e(i);return}bt(i.eventPhase)===n.eventPhase&&e(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:e,onStartOptions:n,onMove:o,onEnd:r}){e&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===G.All){e(i);return}bt(i.eventPhase)===n.eventPhase&&e(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:e,onMove:n,onEnd:o}){e&&this.currentTarget.removeEventListener("touchstart",e),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),e&&this.currentTarget.removeEventListener("mousedown",e),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(e){if(e.type==="touchstart"||e.type==="mousedown"){if("touches"in e)return{x:e.touches[0].clientX,y:e.touches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}if(e.type==="touchend"||e.type==="mouseup"||e.type==="mousemove"||e.type==="touchmove"){if("touches"in e)return{x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY};if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY}}return{x:0,y:0}}}function Ht(t){const e=t;return`${e} ${e} 0px 0px`}function _t(t,e){const n=Xt(t);qt(n),n.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=zt({bottomSheetElements:n,bottomSheetProps:t,options:e});return t.rootStyle&&Object.assign(n.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,t.backdropStyle),t.containerGapFillerStyle&&Object.assign(n.bottomSheetContainer.style,t.containerStyle),t.containerStyle&&Object.assign(n.bottomSheetContainerGapFiller.style,t.containerGapFillerStyle),t.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:n,eventHandlers:i}}function Xt(t){const e=P("dialog",W([T.Root,rt.Dialog,t.rootClass]),T.Root);e.ariaLabel=t.ariaLabel;const n=P("section",W([T.Container,t.containerClass]),T.Container);t.containerBorderRadius&&(n.style.borderRadius=Ht(t.containerBorderRadius));const o=P("div",T.GapFiller,T.GapFiller);t.containerBackgroundColor&&(n.style.backgroundColor=t.containerBackgroundColor,o.style.backgroundColor=t.containerBackgroundColor);const r=P("button",W([T.Handle,rt.Button,t.shouldShowHandle?null:J.Hidden,t.handleClass]),T.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=P("span",W([T.HandleBar,t.shouldShowHandle?null:J.Hidden]),T.HandleBar),a=P("article",W([T.ContentWrapper,t.contentWrapperClass]),T.ContentWrapper),l=P("div",W([T.Backdrop,t.backdropClass,J.Hidden]),T.Backdrop);return t.backdropColor&&(l.style.backgroundColor=t.backdropColor),t.backDropTransition&&(l.style.transition=t.backDropTransition),{bottomSheetRoot:e,bottomSheetBackdrop:l,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function qt({bottomSheetRoot:t,bottomSheetContainer:e,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){t.appendChild(e),n.appendChild(o),e.appendChild(n),e.appendChild(r),e.appendChild(i)}function zt({bottomSheetElements:t,bottomSheetProps:e,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:l,bottomSheetBackdrop:u}=t,{animationFrame:h}=n,s=new q(i),f=new q(l),y=new q(a);let c=[];const C=new q(window),v=Nt(C,r,e,n.draggingState),S=jt(C,r,e,n.draggingState,h),E=Ut(C,r,e,n.draggingState,h,n.onClose,n.bottomSheetState);function B(H){H.target instanceof Element&&!o.contains(H.target)&&n.onClose()}function k(H){Wt(n.draggingState,H.target,t.bottomSheetContentWrapper)}function Y(H){const L=H??e;L.draggable&&L.backgroundDraggable&&(f.addEventListeners({onStart:k,onStartOptions:{eventPhase:G.Target}}),y.addEventListeners({onStart:k})),L.draggable&&C.addEventListeners({onStart:v,onMove:S,onEnd:E}),L.draggable&&window.document.addEventListener("keyup",b=>{b.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",b=>{if(b.key==="ArrowUp"){n.moveUp();return}if(b.key==="ArrowDown"){n.moveDown();return}if(b.shiftKey&&b.key==="Tab"){const d=F(t.bottomSheetContentWrapper);Yt(d)}})}function $(H){const L=H??e;e.shouldCloseOnOutsideClick&&!e.preventClosing?u.addEventListener("click",B):u.style.pointerEvents="none",L.draggable&&(s.addEventListeners({onStart:k}),c.forEach(b=>{b.removeEventListeners({onStart:k})}),c=e.dragTriggers.reduce((b,d)=>{const p=o.querySelectorAll(d);if(!p.length)return b;const g=Array.from(p).map(m=>m instanceof HTMLElement?new q(m):null).filter(m=>!!m);return[...b,...g]},[]),c.forEach(b=>{b.addEventListeners({onStart:k,onStartOptions:{eventPhase:G.Target}})}))}function _(){u.removeEventListener("click",B)}function F(H){let L=[...Array.from(H.childNodes).reverse()];for(;L.length;){const b=L.shift();if(Ft(b))return b;b&&(L=[...L,...Array.from(b.childNodes).reverse()])}return null}function I(){s.removeEventListeners({onStart:k}),f.removeEventListeners({onStart:k}),y.removeEventListeners({onStart:k}),c.forEach(H=>{H.removeEventListeners({onStart:k})}),C.removeEventListeners({onStart:v,onMove:S,onEnd:E})}return{attachEventListeners:Y,clearEventListeners:I,attacheOnOpenEventListeners:$,clearOnOpenEventListeners:_}}class Vt{constructor(){K(this,"animationId"),K(this,"isInProgress"),K(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(e,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,l=n===0?1:Z(a/n,2),u=l>=1&&!o;e(l),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Kt(t){const{startY:e,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:l}=t,u=Ct(e,n);r.stop();let h=!1;r.start(s=>{tt(o,{y:e+u*a(s)}),!h&&s>=1&&(i==null||i(),h=!0)},l)}const st=(t,e)=>n=>{Kt({...n,animationTimingFunction:t,animationDuration:e})},j={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!A(t)||t>1||t<0)}function Qt(t,e){const n={set(o,r,i,a){return e(r,i),Reflect.set(o,r,i,a)}};return new Proxy(t,n)}function Zt(...t){console.error(t)}const N={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function te(t){for(const e of Object.values(N))if(e===t)return!0;return!1}function Ot(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&A(t.p1x)&&A(t.p1y)&&A(t.p2x)&&A(t.p2y))}function U(t,e,n,o){return function(l){return a(r(l))};function r(l){let u=0,h=1,s=l,f;if(l===0||l===1)return l;for(;u<h;){if(f=i(s),Math.abs(f-l)<.001)return s;l>f?u=s:h=s,s=(h+u)/2}return s}function i(l){return 3*t*l*Math.pow(1-l,2)+3*n*Math.pow(l,2)*(1-l)+Math.pow(l,3)}function a(l){return 3*e*l*Math.pow(1-l,2)+3*o*Math.pow(l,2)*(1-l)+Math.pow(l,3)}}const gt=U(.25,.1,.25,1),ee=U(.42,0,1,1),Lt=U(.42,0,.58,1),ne=U(.4,.1,.6,1),oe=U(.45,1.5,.55,1);function re(t){switch(t){case N.EASE:return gt;case N.EASE_IN:return ee;case N.EASE_OUT:return Lt;case N.EASE_IN_OUT:return ne;case N.SPRING:return oe;default:return gt}}function vt(t){return typeof t=="boolean"}const ae={ariaLabel:"Bottom sheet",content:"",defaultPosition:j.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBackgroundColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{},containerGapFillerStyle:{}};function ie(t){const e={...ae},n=Object.entries(t).reduce((o,r)=>{const[i,a]=r;return it(a)&&(o[i]=a),o},{});return{...e,...n}}function ct(t){if(Ot(t)){const{p1x:e,p1y:n,p2x:o,p2y:r}=t;return U(e,n,o,r)}return te(t)?re(t):Lt}function se(t,e,n,o){function r(i,a){switch(i){case"content":x(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":x(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":vt(a)||Q(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":vt(a)||Q(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":x(a)&&(t.bottomSheetContainer.style.borderRadius=Ht(a));break;case"containerBackgroundColor":x(a)&&(t.bottomSheetContainer.style.backgroundColor=a,t.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":x(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":x(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!x(a))return;X(t.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!x(a))return;X(t.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!x(a))return;X(t.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!x(a))return;X(t.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!x(a))return;X(t.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"dragTriggers":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(Ot(a)){const l=ct(a),u=st(l,n.draggingAnimationDuration);e.translateContainer=u}break;case"draggingAnimationDuration":if(A(a)){const l=ct(n.draggingAnimationTimings),u=st(l,a);e.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(t.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(t.bottomSheetContainer.style,n.containerStyle);break;case"containerGapFillerStyle":n.containerGapFillerStyle&&Object.assign(t.bottomSheetContainerGapFiller.style,n.containerGapFillerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function ce(t){const e=ie(t),n=ct(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:st(n,e.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new Vt,l={animationFrame:a,onClose:E,bottomSheetState:o,draggingState:r,snapTo:b,moveUp:H,moveDown:L},{elements:u,eventHandlers:h}=_t(e,l),s=Qt(e,se(u,o,e,h)),{bottomSheetBackdrop:f,bottomSheetRoot:y,bottomSheetContainer:c}=u,C=d=>{const p=d??window.document.body;p.appendChild(y),p.appendChild(f);const g=window.innerHeight;tt(c,{y:g}),h.attachEventListeners(),o.isMounted=!0},v=()=>{h.clearEventListeners(),Object.values(u).forEach(d=>{d.remove()}),i(),o.isMounted=!1},S=()=>{var d;if(B()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(d=t.beforeOpen)==null||d.call(t),k())return;nt(f,!0),s.shouldShowBackdrop||V(f,"transparent"),nt([c],!0),tt(c,{y:c.clientHeight});const p=window.innerHeight,g=pt(p,c.clientHeight,s.marginTop,s.defaultPosition),m=M(c).y;o.translateContainer({startY:m,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:t.afterOpen});const O=document.body.style.overflowY;r.originalDocumentOverflowY=O||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function E(){var d;if(Y())return;(d=t.beforeClose)==null||d.call(t);const p=M(c).y,g=c.clientHeight;o.translateContainer({startY:p,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),nt([f,c],!1),h.clearOnOpenEventListeners()}}),i()}function B(){return o.isMounted}function k(){const d=M(c).y,p=window.innerHeight,g=c.clientHeight>=p?p:c.clientHeight;return d<=g}function Y(){return!k()}function $(){const d=M(c).y,p=c.clientHeight,g=window.innerHeight;if(d<=5&&d>=-5)return j.CONTENT_HEIGHT;const m=p-d;if(m===g/2)return j.MIDDLE;const O=g-s.marginTop,D=10;return m<=O+D&&m>=O-D?j.TOP:j.CLOSED}function _(){return c.clientHeight}function F(d){if(!k())return;const p=M(c).y,g=c.clientHeight-p,m=window.innerHeight-d,O=It(g,m),D=z(g,m);o.translateContainer({startY:p,endY:p+(O.isUp?-D:D),animationFrame:a,bottomSheetContainer:c})}function I(d,{viewportHeight:p,visibleHeight:g}){let m=null;for(const O of d){const D=O*p,R=z(g,D);(m===null||R<m)&&(m=R)}return{minOffset:m}}function H(){const d=[...s.snapPoints].reverse(),p=M(c).y,g=c.clientHeight,m=g-p;if(!s.expandable&&m>=g)return;const O=window.innerHeight,D=ht("above",{visibleHeight:m,viewportHeight:O},d),{minOffset:R}=I(D,{visibleHeight:m,viewportHeight:O});if(R===null&&m<O-s.marginTop){o.translateContainer({startY:p,endY:pt(O,g,s.marginTop,"top"),animationFrame:a,bottomSheetContainer:c});return}A(R)&&o.translateContainer({startY:p,endY:p-R,animationFrame:a,bottomSheetContainer:c})}function L(){const d=M(c).y,p=c.clientHeight-d;if(p<1)return;const g=window.innerHeight,m=ht("below",{visibleHeight:p,viewportHeight:g},s.snapPoints),{minOffset:O}=I(m,{visibleHeight:p,viewportHeight:g});A(O)&&o.translateContainer({startY:d,endY:d+O,animationFrame:a,bottomSheetContainer:c})}function b(d){const p=window.innerHeight;if(!Jt(d))return;const g=Z(p*d,2);F(g)}return{props:s,elements:u,mount:C,unmount:v,open:S,close:E,getIsMounted:B,getIsOpen:k,getIsClosed:Y,getPosition:$,getHeight:_,moveTo:F,snapTo:b}}function lt(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>j.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const le=lt(),ue=w.forwardRef(function(e,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:l,...u}=e,h=w.useRef(le),[s,f]=w.useState(h.current);w.useImperativeHandle(n,()=>s,[s]);const y=w.useCallback(()=>{i(!1),a==null||a()},[a]);w.useEffect(()=>{r?s.open():s.close()},[r]);const c=w.useRef(null);return w.useEffect(function(){var E;if(l&&!l.current)return;const v=Bt((E=e.mountingPointRef)==null?void 0:E.current)?e.mountingPointRef.current:window.document.body;if(!v||s.getIsMounted())return;const S=ce({content:"",...u,afterClose:y});return S.mount(v),c.current=S.elements.bottomSheetContentWrapper??null,h.current=S,f(S),()=>{s.unmount()}},[e.mountingPointRef,u,y]),w.useEffect(function(){Object.assign(h.current.props,{...u}),f(h.current)},[u]),w.useEffect(function(){return()=>{h.current.unmount()}},[]),c.current?xt.createPortal(e.children,c.current):null}),de=lt();function pe(t={}){const e=w.useRef(de),[n,o]=w.useState(!1),r=!n,[i,a]=w.useState(e.current);w.useEffect(()=>{a(e.current)},[e.current]);const{beforeOpen:l,afterOpen:u,beforeClose:h,afterClose:s,onDragStart:f,onDragMove:y,onDragEnd:c,...C}=t,v=()=>{l==null||l()},S=()=>{u==null||u(),o(!0)},E=()=>{h==null||h()},B=()=>{s==null||s(),o(!1)},k=()=>{f==null||f()},Y=(b,d)=>{y==null||y(b,d)},$=()=>{c==null||c()},_=w.useMemo(()=>({ref:e,isOpen:n,setIsOpen:o,beforeOpen:v,afterOpen:S,beforeClose:E,afterClose:B,onDragStart:k,onDragMove:Y,onDragEnd:$,...C}),[e.current,n,o,t]),F=w.useCallback(()=>{o(!0)},[o]),I=w.useCallback(()=>{o(!1)},[o]),H=w.useCallback((...b)=>{i.moveTo(...b)},[i]),L=w.useCallback((...b)=>{i.snapTo(...b)},[i]);return{props:_,instance:i,isOpen:n,isClosed:r,setIsOpen:o,open:F,close:I,moveTo:H,snapTo:L}}exports.BottomSheet=ue;exports.createPlaceholderBottomSheet=lt;exports.useBottomSheet=pe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),xe=require("react-dom");function Be(e){return e!=null}(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;flex-shrink:0;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var Ae=Object.defineProperty,De=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t,n)=>De(e,typeof t!="symbol"?t+"":t,n);function x(e){return typeof e=="string"}function Me(e,t){return e.classList.contains(te(t))}function V(e,t){e.classList.add(te(t))}function oe(e,t){e.classList.remove(te(t))}function X(e,t,n){x(n)&&(x(t)&&oe(e,t),V(e,n))}function te(e){return x(e)?e.trim().replace(/\./g,""):""}function W(e){return e.map(t=>te(t)).filter(Boolean).join(" ")}const ue="open",de="hidden";function ne(e,t){const n=t;if(Array.isArray(e)){e.forEach(o=>{Q(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Q(e,n),e.setAttribute("aria-modal",n?"true":"false")}function Q(e,t){t?(V(e,ue),oe(e,de)):(V(e,de),oe(e,ue))}function ve(e){return e instanceof HTMLElement}function A(e){return typeof e=="number"&&!Number.isNaN(e)}function Ye(e){ve(e)&&e.focus()}function Pe(e){if(!ve(e)||e.offsetParent===null||"disabled"in e&&e.disabled)return!1;const t=e.getAttribute("tabindex"),n=A(t)?parseInt(t,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(e.tagName),r=e instanceof HTMLAnchorElement&&e.href!==""||e instanceof HTMLAreaElement&&e.href!=="";return o||r||n>-1}var O=(e=>(e.Backdrop="pbs-backdrop",e.Root="pbs-root",e.Container="pbs-container",e.GapFiller="pbs-gap-filler",e.Handle="pbs-handle",e.HandleBar="pbs-handle-bar",e.ContentWrapper="pbs-content-wrapper",e))(O||{}),re=(e=>(e.Button="pbs-button-reset",e.Dialog="pbs-dialog-reset",e))(re||{}),J=(e=>(e.Hidden="hidden",e))(J||{});function Y(e,t,n){const o=document.createElement(e);return t.split(" ").forEach(r=>{V(o,r)}),x(n)&&o.setAttribute("data-testid",n),o}function pe(e,t,n,o){switch(o){case"content-height":return t>=e?Ee(e,t,n):0;case"middle":return-(e/2-t);case"top":return-(e-t)+n;default:return 0}}function ye(e,t){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function Ce(e,t){return t<e?-(e-t):t-e}function z(e,t){return e>t?e-t:t-e}function Fe(e,t){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function he(e,t,n){const o=e==="above";return n.filter(r=>{const i=r*t.viewportHeight;return o?t.visibleHeight<i:t.visibleHeight>i})}function Ee(e,t,n){return-(e-t)+n}function me(e){return Number(e.replace("px",""))}function Z(e,...t){return Number(e.toFixed(...t))}function we(e){const t=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=t.exec(e))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function Ie(e){const t=e.style.transform,n=we(t);return{transform:t,transformValues:n}}function ke(e,t){return e.find(o=>o.type.startsWith(t))||null}const ae="translate";function M(e){const t=e.style.transform,n=we(t),o=ke(n,ae);return Te(o??{type:ae,values:[]})}function ee(e,{x:t,y:n}){const{transform:o,transformValues:r}=Ie(e),i=ke(r,ae);if(i){const a=Te(i);e.style.transform=`translate(${t??a.x??0}px,${n??a.y??0}px)`;return}if(o){e.style.transform=`${o}, translate(${t??0}px,${n??0}px)`;return}e.style.transform=`translate(${t??0}px,${n??0}px)`}function Te(e){if(e.type!=="translate")throw new Error(`Could not get coordinates from ${e.type}, since is not translate.`);const t=e.values[0],n=e.values[1];return{x:me(t)??0,y:me(n)??0}}function ie(e){return e!=null}function fe(e,{min:t,max:n}){return ie(n)&&e>=n?n:ie(t)&&e<=t?t:e}const Re=(e,t,n)=>{t instanceof HTMLElement&&!Me(t,O.Handle)&&n.scrollTop>=1||(e.isDragging=!0)},We=(e,t,n,o)=>r=>{o.startY=e.getCoordinates(r).y,o.containerStartTranslate=M(t),n.onDragStart()},je=(e,t,n,o,r)=>i=>{Ne(i,e,n,o,r,t,n.marginTop)};function Ne(e,t,n,o,r,i,a){if(!o.isDragging||!A(o.startY))return;const l=t.getCoordinates(e).y,u=Ce(o.startY,l),h=window.innerHeight,s=i.clientHeight,f=s-(o.containerStartTranslate.y+u);if(f>=h)return;const y=ye(o.startY,l);if(y.isUp&&!n.expandable&&f>=s||n.preventClosing&&f<=s)return;r.start(()=>{ee(i,{y:o.containerStartTranslate.y+u})},0);const c=h-a,C=s-o.containerStartTranslate.y;if(y.isUp){const S=c-C,v=c-f,E=fe(1-Z(v/S,2),{min:0,max:1});n.onDragMove(y,E)}else if(y.isDown){const S=fe(Z(1-f/C,2),{min:0,max:1});n.onDragMove(y,S)}}const Ge=(e,t,n,o,r,i,a)=>l=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const u=o.startY,h=e.getCoordinates(l).y,s=M(t).y,f=ye(u,h),y=window.innerHeight,c=t.clientHeight;if(f.isUp){if(!n.expandable)return;const C=[...n.snapPoints].sort((E,B)=>E-B),S=c+-s;for(const E of C){const B=E*window.innerHeight;if(S<=B){const k=z(S,B);a.translateContainer({startY:s,endY:s-k,animationFrame:r,bottomSheetContainer:t});return}}const v=Ee(y,c,n.marginTop);a.translateContainer({startY:s,endY:v,animationFrame:r,bottomSheetContainer:t})}else if(f.isDown){const C=[...n.snapPoints].sort((S,v)=>v-S);for(const S of C){const v=S*window.innerHeight,E=c+-s;if(E>=v){const B=z(E,v);a.translateContainer({startY:s,endY:s+B,animationFrame:r,bottomSheetContainer:t});return}}if(n.preventClosing){const S=c+-s;if(S>=c){const v=z(S,c);a.translateContainer({startY:s,endY:s+v,animationFrame:r,bottomSheetContainer:t})}return}i()}};var G=(e=>(e[e.All=-1]="All",e[e.None=0]="None",e[e.Capture=1]="Capture",e[e.Target=2]="Target",e[e.Bubble=3]="Bubble",e))(G||{});function be(e){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const Ue={eventPhase:G.All};class q{constructor(t){K(this,"currentTarget"),this.currentTarget=t}addEventListeners({onStart:t,onStartOptions:n=Ue,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===G.All){t(i);return}be(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===G.All){t(i);return}be(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:t,onMove:n,onEnd:o}){t&&this.currentTarget.removeEventListener("touchstart",t),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),t&&this.currentTarget.removeEventListener("mousedown",t),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(t){if(t.type==="touchstart"||t.type==="mousedown"){if("touches"in t)return{x:t.touches[0].clientX,y:t.touches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}if(t.type==="touchend"||t.type==="mouseup"||t.type==="mousemove"||t.type==="touchmove"){if("touches"in t)return{x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}return{x:0,y:0}}}function He(e){const t=e;return`${t} ${t} 0px 0px`}function $e(e,t){const n=_e(e);Xe(n),n.bottomSheetContainer.style.width=e.width;const o=document.createElement("div");o.innerHTML=e.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=qe({bottomSheetElements:n,bottomSheetProps:e,options:t});return e.rootStyle&&Object.assign(n.bottomSheetRoot.style,e.rootStyle),e.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,e.backdropStyle),e.containerGapFillerStyle&&Object.assign(n.bottomSheetContainer.style,e.containerStyle),e.containerStyle&&Object.assign(n.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle),e.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,e.handleStyle),e.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,e.contentWrapperStyle),{elements:n,eventHandlers:i}}function _e(e){const t=Y("dialog",W([O.Root,re.Dialog,e.rootClass]),O.Root);t.ariaLabel=e.ariaLabel;const n=Y("section",W([O.Container,e.containerClass]),O.Container);e.containerBorderRadius&&(n.style.borderRadius=He(e.containerBorderRadius));const o=Y("div",O.GapFiller,O.GapFiller);e.containerBackgroundColor&&(n.style.backgroundColor=e.containerBackgroundColor,o.style.backgroundColor=e.containerBackgroundColor);const r=Y("button",W([O.Handle,re.Button,e.shouldShowHandle?null:J.Hidden,e.handleClass]),O.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=Y("span",W([O.HandleBar,e.shouldShowHandle?null:J.Hidden]),O.HandleBar),a=Y("article",W([O.ContentWrapper,e.contentWrapperClass]),O.ContentWrapper),l=Y("div",W([O.Backdrop,e.backdropClass,J.Hidden]),O.Backdrop);return e.backdropColor&&(l.style.backgroundColor=e.backdropColor),e.backDropTransition&&(l.style.transition=e.backDropTransition),{bottomSheetRoot:t,bottomSheetBackdrop:l,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function Xe({bottomSheetRoot:e,bottomSheetContainer:t,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){e.appendChild(t),n.appendChild(o),t.appendChild(n),t.appendChild(r),t.appendChild(i)}function qe({bottomSheetElements:e,bottomSheetProps:t,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:l,bottomSheetBackdrop:u}=e,{animationFrame:h}=n,s=new q(i),f=new q(l),y=new q(a);let c=[];const C=new q(window),S=We(C,r,t,n.draggingState),v=je(C,r,t,n.draggingState,h),E=Ge(C,r,t,n.draggingState,h,n.onClose,n.bottomSheetState);function B(T){T.target instanceof Element&&!o.contains(T.target)&&n.onClose()}function k(T){Re(n.draggingState,T.target,e.bottomSheetContentWrapper)}function P(T){const L=T??t;L.draggable&&L.backgroundDraggable&&(f.addEventListeners({onStart:k,onStartOptions:{eventPhase:G.Target}}),y.addEventListeners({onStart:k})),L.draggable&&C.addEventListeners({onStart:S,onMove:v,onEnd:E}),L.draggable&&window.document.addEventListener("keyup",b=>{b.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",b=>{if(b.key==="ArrowUp"){n.moveUp();return}if(b.key==="ArrowDown"){n.moveDown();return}if(b.shiftKey&&b.key==="Tab"){const d=F(e.bottomSheetContentWrapper);Ye(d)}})}function $(T){const L=T??t;t.shouldCloseOnOutsideClick&&!t.preventClosing?u.addEventListener("click",B):u.style.pointerEvents="none",L.draggable&&(s.addEventListeners({onStart:k}),c.forEach(b=>{b.removeEventListeners({onStart:k})}),c=t.dragTriggers.reduce((b,d)=>{const p=o.querySelectorAll(d);if(!p.length)return b;const g=Array.from(p).map(m=>m instanceof HTMLElement?new q(m):null).filter(m=>!!m);return[...b,...g]},[]),c.forEach(b=>{b.addEventListeners({onStart:k,onStartOptions:{eventPhase:G.Target}})}))}function _(){u.removeEventListener("click",B)}function F(T){let L=[...Array.from(T.childNodes).reverse()];for(;L.length;){const b=L.shift();if(Pe(b))return b;b&&(L=[...L,...Array.from(b.childNodes).reverse()])}return null}function I(){s.removeEventListeners({onStart:k}),f.removeEventListeners({onStart:k}),y.removeEventListeners({onStart:k}),c.forEach(T=>{T.removeEventListeners({onStart:k})}),C.removeEventListeners({onStart:S,onMove:v,onEnd:E})}return{attachEventListeners:P,clearEventListeners:I,attacheOnOpenEventListeners:$,clearOnOpenEventListeners:_}}class ze{constructor(){K(this,"animationId"),K(this,"isInProgress"),K(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(t,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,l=n===0?1:Z(a/n,2),u=l>=1&&!o;t(l),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Ve(e){const{startY:t,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:l}=e,u=Ce(t,n);r.stop();let h=!1;r.start(s=>{ee(o,{y:t+u*a(s)}),!h&&s>=1&&(i==null||i(),h=!0)},l)}const se=(e,t)=>n=>{Ve({...n,animationTimingFunction:e,animationDuration:t})},N={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Ke(e){return!(!A(e)||e>1||e<0)}function Je(e,t){const n={set(o,r,i,a){return t(r,i),Reflect.set(o,r,i,a)}};return new Proxy(e,n)}function Qe(...e){console.error(e)}const j={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Ze(e){for(const t of Object.values(j))if(t===e)return!0;return!1}function Oe(e){return!!(e instanceof Object&&"p1x"in e&&"p1y"in e&&"p2x"in e&&"p2y"in e&&A(e.p1x)&&A(e.p1y)&&A(e.p2x)&&A(e.p2y))}function U(e,t,n,o){return function(l){return a(r(l))};function r(l){let u=0,h=1,s=l,f;if(l===0||l===1)return l;for(;u<h;){if(f=i(s),Math.abs(f-l)<.001)return s;l>f?u=s:h=s,s=(h+u)/2}return s}function i(l){return 3*e*l*Math.pow(1-l,2)+3*n*Math.pow(l,2)*(1-l)+Math.pow(l,3)}function a(l){return 3*t*l*Math.pow(1-l,2)+3*o*Math.pow(l,2)*(1-l)+Math.pow(l,3)}}const ge=U(.25,.1,.25,1),et=U(.42,0,1,1),Le=U(.42,0,.58,1),tt=U(.4,.1,.6,1),nt=U(.45,1.5,.55,1);function ot(e){switch(e){case j.EASE:return ge;case j.EASE_IN:return et;case j.EASE_OUT:return Le;case j.EASE_IN_OUT:return tt;case j.SPRING:return nt;default:return ge}}function Se(e){return typeof e=="boolean"}const rt={ariaLabel:"Bottom sheet",content:"",defaultPosition:N.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBackgroundColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{},containerGapFillerStyle:{}};function at(e){const t={...rt},n=Object.entries(e).reduce((o,r)=>{const[i,a]=r;return ie(a)&&(o[i]=a),o},{});return{...t,...n}}function ce(e){if(Oe(e)){const{p1x:t,p1y:n,p2x:o,p2y:r}=e;return U(t,n,o,r)}return Ze(e)?ot(e):Le}function it(e,t,n,o){function r(i,a){switch(i){case"content":x(a)&&(e.bottomSheetContentWrapper.innerHTML=a);break;case"width":x(a)&&(e.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Se(a)||Q(e.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Se(a)||Q(e.bottomSheetBackdrop,!1);break;case"containerBorderRadius":x(a)&&(e.bottomSheetContainer.style.borderRadius=He(a));break;case"containerBackgroundColor":x(a)&&(e.bottomSheetContainer.style.backgroundColor=a,e.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":x(a)&&(e.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":x(a)&&(e.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!x(a))return;X(e.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!x(a))return;X(e.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!x(a))return;X(e.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!x(a))return;X(e.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!x(a))return;X(e.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"dragTriggers":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(Oe(a)){const l=ce(a),u=se(l,n.draggingAnimationDuration);t.translateContainer=u}break;case"draggingAnimationDuration":if(A(a)){const l=ce(n.draggingAnimationTimings),u=se(l,a);t.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(e.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(e.bottomSheetContainer.style,n.containerStyle);break;case"containerGapFillerStyle":n.containerGapFillerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,n.containerGapFillerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function st(e){const t=at(e),n=ce(e.draggingAnimationTimings),o={isMounted:!1,translateContainer:se(n,t.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new ze,l={animationFrame:a,onClose:E,bottomSheetState:o,draggingState:r,snapTo:b,moveUp:T,moveDown:L},{elements:u,eventHandlers:h}=$e(t,l),s=Je(t,it(u,o,t,h)),{bottomSheetBackdrop:f,bottomSheetRoot:y,bottomSheetContainer:c}=u,C=d=>{const p=d??window.document.body;p.appendChild(y),p.appendChild(f);const g=window.innerHeight;ee(c,{y:g}),h.attachEventListeners(),o.isMounted=!0},S=()=>{h.clearEventListeners(),Object.values(u).forEach(d=>{d.remove()}),i(),o.isMounted=!1},v=()=>{var d;if(B()||Qe('Bottom Sheet is not mounted yet. call the "mount" method first.'),(d=e.beforeOpen)==null||d.call(e),k())return;ne(f,!0),s.shouldShowBackdrop||V(f,"transparent"),ne([c],!0),ee(c,{y:c.clientHeight});const p=window.innerHeight,g=pe(p,c.clientHeight,s.marginTop,s.defaultPosition),m=M(c).y;o.translateContainer({startY:m,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:e.afterOpen});const H=document.body.style.overflowY;r.originalDocumentOverflowY=H||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function E(){var d;if(P())return;(d=e.beforeClose)==null||d.call(e);const p=M(c).y,g=c.clientHeight;o.translateContainer({startY:p,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:()=>{var m;(m=e.afterClose)==null||m.call(e),ne([f,c],!1),h.clearOnOpenEventListeners()}}),i()}function B(){return o.isMounted}function k(){const d=M(c).y,p=window.innerHeight,g=c.clientHeight>=p?p:c.clientHeight;return d<=g}function P(){return!k()}function $(){const d=M(c).y,p=c.clientHeight,g=window.innerHeight;if(d<=5&&d>=-5)return N.CONTENT_HEIGHT;const m=p-d;if(m===g/2)return N.MIDDLE;const H=g-s.marginTop,D=10;return m<=H+D&&m>=H-D?N.TOP:N.CLOSED}function _(){return c.clientHeight}function F(d){if(!k())return;const p=M(c).y,g=c.clientHeight-p,m=window.innerHeight-d,H=Fe(g,m),D=z(g,m);o.translateContainer({startY:p,endY:p+(H.isUp?-D:D),animationFrame:a,bottomSheetContainer:c})}function I(d,{viewportHeight:p,visibleHeight:g}){let m=null;for(const H of d){const D=H*p,R=z(g,D);(m===null||R<m)&&(m=R)}return{minOffset:m}}function T(){const d=[...s.snapPoints].reverse(),p=M(c).y,g=c.clientHeight,m=g-p;if(!s.expandable&&m>=g)return;const H=window.innerHeight,D=he("above",{visibleHeight:m,viewportHeight:H},d),{minOffset:R}=I(D,{visibleHeight:m,viewportHeight:H});if(R===null&&m<H-s.marginTop){o.translateContainer({startY:p,endY:pe(H,g,s.marginTop,"top"),animationFrame:a,bottomSheetContainer:c});return}A(R)&&o.translateContainer({startY:p,endY:p-R,animationFrame:a,bottomSheetContainer:c})}function L(){const d=M(c).y,p=c.clientHeight-d;if(p<1)return;const g=window.innerHeight,m=he("below",{visibleHeight:p,viewportHeight:g},s.snapPoints),{minOffset:H}=I(m,{visibleHeight:p,viewportHeight:g});A(H)&&o.translateContainer({startY:d,endY:d+H,animationFrame:a,bottomSheetContainer:c})}function b(d){const p=window.innerHeight;if(!Ke(d))return;const g=Z(p*d,2);F(g)}return{props:s,elements:u,mount:C,unmount:S,open:v,close:E,getIsMounted:B,getIsOpen:k,getIsClosed:P,getPosition:$,getHeight:_,moveTo:F,snapTo:b}}function le(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>N.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const ct=le(),lt=w.forwardRef(function(t,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:l,...u}=t,h=w.useRef(ct),[s,f]=w.useState(h.current);w.useImperativeHandle(n,()=>s,[s]);const y=w.useCallback(()=>{i(!1),a==null||a()},[a]);w.useEffect(()=>{r?s.open():s.close()},[r]);const c=w.useRef(null);return w.useEffect(function(){var E;if(l&&!l.current)return;const S=Be((E=t.mountingPointRef)==null?void 0:E.current)?t.mountingPointRef.current:window.document.body;if(!S||s.getIsMounted())return;const v=st({content:"",...u,afterClose:y});return v.mount(S),c.current=v.elements.bottomSheetContentWrapper??null,h.current=v,f(v),()=>{s.unmount()}},[t.mountingPointRef,u,y]),w.useEffect(function(){Object.assign(h.current.props,{...u}),f(h.current)},[u]),w.useEffect(function(){return()=>{h.current.unmount()}},[]),c.current?xe.createPortal(t.children,c.current):null}),ut=le();function dt(e={}){const t=w.useRef(ut),[n,o]=w.useState(!1),r=!n,[i,a]=w.useState(t.current);w.useEffect(()=>{a(t.current)},[t.current]);const{beforeOpen:l,afterOpen:u,beforeClose:h,afterClose:s,onDragStart:f,onDragMove:y,onDragEnd:c,...C}=e,S=()=>{l==null||l()},v=()=>{u==null||u(),o(!0)},E=()=>{h==null||h()},B=()=>{s==null||s(),o(!1)},k=()=>{f==null||f()},P=(b,d)=>{y==null||y(b,d)},$=()=>{c==null||c()},_=w.useMemo(()=>({ref:t,isOpen:n,setIsOpen:o,beforeOpen:S,afterOpen:v,beforeClose:E,afterClose:B,onDragStart:k,onDragMove:P,onDragEnd:$,...C}),[t.current,n,o,e]),F=w.useCallback(()=>{o(!0)},[o]),I=w.useCallback(()=>{o(!1)},[o]),T=w.useCallback((...b)=>{i.moveTo(...b)},[i]),L=w.useCallback((...b)=>{i.snapTo(...b)},[i]);return{props:_,instance:i,isOpen:n,isClosed:r,setIsOpen:o,open:F,close:I,moveTo:T,snapTo:L}}exports.BottomSheet=lt;exports.createPlaceholderBottomSheet=le;exports.useBottomSheet=dt;
@@ -1,19 +1,19 @@
1
1
  import { forwardRef as Dt, useRef as rt, useState as at, useImperativeHandle as Mt, useCallback as z, useEffect as q, useMemo as Yt } from "react";
2
- import { createPortal as Pt } from "react-dom";
3
- function Ft(t) {
2
+ import { createPortal as Ft } from "react-dom";
3
+ function It(t) {
4
4
  return t != null;
5
5
  }
6
6
  (function() {
7
7
  try {
8
8
  if (typeof document < "u") {
9
9
  var t = document.createElement("style");
10
- t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')), document.head.appendChild(t);
10
+ t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;flex-shrink:0;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')), document.head.appendChild(t);
11
11
  }
12
12
  } catch (e) {
13
13
  console.error("vite-plugin-css-injected-by-js", e);
14
14
  }
15
15
  })();
16
- var It = Object.defineProperty, Rt = (t, e, n) => e in t ? It(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, J = (t, e, n) => Rt(t, typeof e != "symbol" ? e + "" : e, n);
16
+ var Pt = Object.defineProperty, Rt = (t, e, n) => e in t ? Pt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, J = (t, e, n) => Rt(t, typeof e != "symbol" ? e + "" : e, n);
17
17
  function L(t) {
18
18
  return typeof t == "string";
19
19
  }
@@ -35,9 +35,6 @@ function nt(t) {
35
35
  function R(t) {
36
36
  return t.map((e) => nt(e)).filter(Boolean).join(" ");
37
37
  }
38
- function Nt(t) {
39
- return t.map((e) => e == null ? void 0 : e.trim()).filter(Boolean).map((e) => `.${e}`).join(" ");
40
- }
41
38
  const pt = "open", ht = "hidden";
42
39
  function ot(t, e) {
43
40
  const n = e;
@@ -58,10 +55,10 @@ function Ct(t) {
58
55
  function A(t) {
59
56
  return typeof t == "number" && !Number.isNaN(t);
60
57
  }
61
- function jt(t) {
58
+ function Nt(t) {
62
59
  Ct(t) && t.focus();
63
60
  }
64
- function Gt(t) {
61
+ function jt(t) {
65
62
  if (!Ct(t) || t.offsetParent === null || "disabled" in t && t.disabled)
66
63
  return !1;
67
64
  const e = t.getAttribute("tabindex"), n = A(e) ? parseInt(e, 10) : -1, o = [
@@ -75,17 +72,13 @@ function Gt(t) {
75
72
  ].includes(t.tagName), r = t instanceof HTMLAnchorElement && t.href !== "" || t instanceof HTMLAreaElement && t.href !== "";
76
73
  return o || r || n > -1;
77
74
  }
78
- var k = /* @__PURE__ */ ((t) => (t.Backdrop = "pbs-backdrop", t.Root = "pbs-root", t.Container = "pbs-container", t.GapFiller = "pbs-gap-filler", t.Handle = "pbs-handle", t.HandleBar = "pbs-handle-bar", t.ContentWrapper = "pbs-content-wrapper", t))(k || {}), st = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(st || {}), Q = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(Q || {});
75
+ var H = /* @__PURE__ */ ((t) => (t.Backdrop = "pbs-backdrop", t.Root = "pbs-root", t.Container = "pbs-container", t.GapFiller = "pbs-gap-filler", t.Handle = "pbs-handle", t.HandleBar = "pbs-handle-bar", t.ContentWrapper = "pbs-content-wrapper", t))(H || {}), st = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(st || {}), Q = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(Q || {});
79
76
  function M(t, e, n) {
80
77
  const o = document.createElement(t);
81
78
  return e.split(" ").forEach((r) => {
82
79
  K(o, r);
83
80
  }), L(n) && o.setAttribute("data-testid", n), o;
84
81
  }
85
- Nt([
86
- k.Root,
87
- k.ContentWrapper
88
- ]);
89
82
  function mt(t, e, n, o) {
90
83
  switch (o) {
91
84
  case "content-height":
@@ -112,7 +105,7 @@ function wt(t, e) {
112
105
  function V(t, e) {
113
106
  return t > e ? t - e : e - t;
114
107
  }
115
- function Ut(t, e) {
108
+ function Gt(t, e) {
116
109
  const n = t < e, o = t > e;
117
110
  return {
118
111
  isUp: n,
@@ -120,7 +113,7 @@ function Ut(t, e) {
120
113
  stayedSame: t === e
121
114
  };
122
115
  }
123
- function ft(t, e, n) {
116
+ function bt(t, e, n) {
124
117
  const o = t === "above";
125
118
  return n.filter((r) => {
126
119
  const i = r * e.viewportHeight;
@@ -130,7 +123,7 @@ function ft(t, e, n) {
130
123
  function kt(t, e, n) {
131
124
  return -(t - e) + n;
132
125
  }
133
- function bt(t) {
126
+ function ft(t) {
134
127
  return Number(t.replace("px", ""));
135
128
  }
136
129
  function tt(t, ...e) {
@@ -145,7 +138,7 @@ function Tt(t) {
145
138
  }
146
139
  return n;
147
140
  }
148
- function $t(t) {
141
+ function Ut(t) {
149
142
  const e = t.style.transform, n = Tt(e);
150
143
  return { transform: e, transformValues: n };
151
144
  }
@@ -169,7 +162,7 @@ function et(t, { x: e, y: n }) {
169
162
  const {
170
163
  transform: o,
171
164
  transformValues: r
172
- } = $t(t), i = Ht(
165
+ } = Ut(t), i = Ht(
173
166
  r,
174
167
  ct
175
168
  );
@@ -191,8 +184,8 @@ function Ot(t) {
191
184
  );
192
185
  const e = t.values[0], n = t.values[1];
193
186
  return {
194
- x: bt(e) ?? 0,
195
- y: bt(n) ?? 0
187
+ x: ft(e) ?? 0,
188
+ y: ft(n) ?? 0
196
189
  };
197
190
  }
198
191
  function lt(t) {
@@ -204,12 +197,12 @@ function gt(t, {
204
197
  }) {
205
198
  return lt(n) && t >= n ? n : lt(e) && t <= e ? e : t;
206
199
  }
207
- const _t = (t, e, n) => {
208
- e instanceof HTMLElement && !Wt(e, k.Handle) && n.scrollTop >= 1 || (t.isDragging = !0);
209
- }, Xt = (t, e, n, o) => (r) => {
200
+ const $t = (t, e, n) => {
201
+ e instanceof HTMLElement && !Wt(e, H.Handle) && n.scrollTop >= 1 || (t.isDragging = !0);
202
+ }, _t = (t, e, n, o) => (r) => {
210
203
  o.startY = t.getCoordinates(r).y, o.containerStartTranslate = D(e), n.onDragStart();
211
- }, zt = (t, e, n, o, r) => (i) => {
212
- qt(
204
+ }, Xt = (t, e, n, o, r) => (i) => {
205
+ zt(
213
206
  i,
214
207
  t,
215
208
  n,
@@ -219,14 +212,14 @@ const _t = (t, e, n) => {
219
212
  n.marginTop
220
213
  );
221
214
  };
222
- function qt(t, e, n, o, r, i, a) {
215
+ function zt(t, e, n, o, r, i, a) {
223
216
  if (!o.isDragging || !A(o.startY))
224
217
  return;
225
- const l = e.getCoordinates(t).y, u = wt(o.startY, l), h = window.innerHeight, s = i.clientHeight, f = s - (o.containerStartTranslate.y + u);
226
- if (f >= h)
218
+ const l = e.getCoordinates(t).y, u = wt(o.startY, l), h = window.innerHeight, s = i.clientHeight, b = s - (o.containerStartTranslate.y + u);
219
+ if (b >= h)
227
220
  return;
228
221
  const y = Et(o.startY, l);
229
- if (y.isUp && !n.expandable && f >= s || n.preventClosing && f <= s)
222
+ if (y.isUp && !n.expandable && b >= s || n.preventClosing && b <= s)
230
223
  return;
231
224
  r.start(() => {
232
225
  et(i, {
@@ -235,7 +228,7 @@ function qt(t, e, n, o, r, i, a) {
235
228
  }, 0);
236
229
  const c = h - a, C = s - o.containerStartTranslate.y;
237
230
  if (y.isUp) {
238
- const v = c - C, S = c - f, E = gt(
231
+ const v = c - C, S = c - b, E = gt(
239
232
  1 - tt(S / v, 2),
240
233
  {
241
234
  min: 0,
@@ -246,7 +239,7 @@ function qt(t, e, n, o, r, i, a) {
246
239
  } else if (y.isDown) {
247
240
  const v = gt(
248
241
  tt(
249
- 1 - f / C,
242
+ 1 - b / C,
250
243
  2
251
244
  ),
252
245
  {
@@ -257,12 +250,12 @@ function qt(t, e, n, o, r, i, a) {
257
250
  n.onDragMove(y, v);
258
251
  }
259
252
  }
260
- const Vt = (t, e, n, o, r, i, a) => (l) => {
253
+ const qt = (t, e, n, o, r, i, a) => (l) => {
261
254
  if (!o.isDragging || (o.isDragging = !1, !A(o.startY)))
262
255
  return;
263
256
  n.onDragEnd();
264
- const u = o.startY, h = t.getCoordinates(l).y, s = D(e).y, f = Et(u, h), y = window.innerHeight, c = e.clientHeight;
265
- if (f.isUp) {
257
+ const u = o.startY, h = t.getCoordinates(l).y, s = D(e).y, b = Et(u, h), y = window.innerHeight, c = e.clientHeight;
258
+ if (b.isUp) {
266
259
  if (!n.expandable)
267
260
  return;
268
261
  const C = [...n.snapPoints].sort(
@@ -295,7 +288,7 @@ const Vt = (t, e, n, o, r, i, a) => (l) => {
295
288
  animationFrame: r,
296
289
  bottomSheetContainer: e
297
290
  });
298
- } else if (f.isDown) {
291
+ } else if (b.isDown) {
299
292
  const C = [...n.snapPoints].sort(
300
293
  (v, S) => S - v
301
294
  );
@@ -346,7 +339,7 @@ function vt(t) {
346
339
  return -1;
347
340
  }
348
341
  }
349
- const Kt = {
342
+ const Vt = {
350
343
  eventPhase: j.All
351
344
  };
352
345
  class X {
@@ -355,7 +348,7 @@ class X {
355
348
  }
356
349
  addEventListeners({
357
350
  onStart: e,
358
- onStartOptions: n = Kt,
351
+ onStartOptions: n = Vt,
359
352
  onMove: o,
360
353
  onEnd: r
361
354
  }) {
@@ -445,14 +438,14 @@ function Lt(t) {
445
438
  const e = t;
446
439
  return `${e} ${e} 0px 0px`;
447
440
  }
448
- function Jt(t, e) {
449
- const n = Qt(t);
450
- Zt(n), n.bottomSheetContainer.style.width = t.width;
441
+ function Kt(t, e) {
442
+ const n = Jt(t);
443
+ Qt(n), n.bottomSheetContainer.style.width = t.width;
451
444
  const o = document.createElement("div");
452
445
  o.innerHTML = t.content ?? "";
453
446
  const r = window.innerHeight;
454
447
  n.bottomSheetContainer.style.maxHeight = `${r}px`, n.bottomSheetContentWrapper.appendChild(o);
455
- const i = te({
448
+ const i = Zt({
456
449
  bottomSheetElements: n,
457
450
  bottomSheetProps: t,
458
451
  options: e
@@ -465,64 +458,64 @@ function Jt(t, e) {
465
458
  t.contentWrapperStyle
466
459
  ), { elements: n, eventHandlers: i };
467
460
  }
468
- function Qt(t) {
461
+ function Jt(t) {
469
462
  const e = M(
470
463
  "dialog",
471
464
  R([
472
- k.Root,
465
+ H.Root,
473
466
  st.Dialog,
474
467
  t.rootClass
475
468
  ]),
476
- k.Root
469
+ H.Root
477
470
  );
478
471
  e.ariaLabel = t.ariaLabel;
479
472
  const n = M(
480
473
  "section",
481
- R([k.Container, t.containerClass]),
482
- k.Container
474
+ R([H.Container, t.containerClass]),
475
+ H.Container
483
476
  );
484
477
  t.containerBorderRadius && (n.style.borderRadius = Lt(
485
478
  t.containerBorderRadius
486
479
  ));
487
480
  const o = M(
488
481
  "div",
489
- k.GapFiller,
490
- k.GapFiller
482
+ H.GapFiller,
483
+ H.GapFiller
491
484
  );
492
485
  t.containerBackgroundColor && (n.style.backgroundColor = t.containerBackgroundColor, o.style.backgroundColor = t.containerBackgroundColor);
493
486
  const r = M(
494
487
  "button",
495
488
  R([
496
- k.Handle,
489
+ H.Handle,
497
490
  st.Button,
498
491
  t.shouldShowHandle ? null : Q.Hidden,
499
492
  t.handleClass
500
493
  ]),
501
- k.Handle
494
+ H.Handle
502
495
  );
503
496
  r.setAttribute("type", "button"), r.ariaLabel = "bottom sheet close button";
504
497
  const i = M(
505
498
  "span",
506
499
  R([
507
- k.HandleBar,
500
+ H.HandleBar,
508
501
  t.shouldShowHandle ? null : Q.Hidden
509
502
  ]),
510
- k.HandleBar
503
+ H.HandleBar
511
504
  ), a = M(
512
505
  "article",
513
506
  R([
514
- k.ContentWrapper,
507
+ H.ContentWrapper,
515
508
  t.contentWrapperClass
516
509
  ]),
517
- k.ContentWrapper
510
+ H.ContentWrapper
518
511
  ), l = M(
519
512
  "div",
520
513
  R([
521
- k.Backdrop,
514
+ H.Backdrop,
522
515
  t.backdropClass,
523
516
  Q.Hidden
524
517
  ]),
525
- k.Backdrop
518
+ H.Backdrop
526
519
  );
527
520
  return t.backdropColor && (l.style.backgroundColor = t.backdropColor), t.backDropTransition && (l.style.transition = t.backDropTransition), {
528
521
  bottomSheetRoot: e,
@@ -534,7 +527,7 @@ function Qt(t) {
534
527
  bottomSheetContainerGapFiller: o
535
528
  };
536
529
  }
537
- function Zt({
530
+ function Qt({
538
531
  bottomSheetRoot: t,
539
532
  bottomSheetContainer: e,
540
533
  bottomSheetHandle: n,
@@ -544,7 +537,7 @@ function Zt({
544
537
  }) {
545
538
  t.appendChild(e), n.appendChild(o), e.appendChild(n), e.appendChild(r), e.appendChild(i);
546
539
  }
547
- function te({
540
+ function Zt({
548
541
  bottomSheetElements: t,
549
542
  bottomSheetProps: e,
550
543
  options: n
@@ -556,7 +549,7 @@ function te({
556
549
  bottomSheetContainerGapFiller: a,
557
550
  bottomSheetContentWrapper: l,
558
551
  bottomSheetBackdrop: u
559
- } = t, { animationFrame: h } = n, s = new X(i), f = new X(
552
+ } = t, { animationFrame: h } = n, s = new X(i), b = new X(
560
553
  l
561
554
  ), y = new X(
562
555
  a
@@ -564,18 +557,18 @@ function te({
564
557
  let c = [];
565
558
  const C = new X(
566
559
  window
567
- ), v = Xt(
560
+ ), v = _t(
568
561
  C,
569
562
  r,
570
563
  e,
571
564
  n.draggingState
572
- ), S = zt(
565
+ ), S = Xt(
573
566
  C,
574
567
  r,
575
568
  e,
576
569
  n.draggingState,
577
570
  h
578
- ), E = Vt(
571
+ ), E = qt(
579
572
  C,
580
573
  r,
581
574
  e,
@@ -584,19 +577,19 @@ function te({
584
577
  n.onClose,
585
578
  n.bottomSheetState
586
579
  );
587
- function x(T) {
588
- T.target instanceof Element && !o.contains(T.target) && n.onClose();
580
+ function x(k) {
581
+ k.target instanceof Element && !o.contains(k.target) && n.onClose();
589
582
  }
590
- function w(T) {
591
- _t(
583
+ function w(k) {
584
+ $t(
592
585
  n.draggingState,
593
- T.target,
586
+ k.target,
594
587
  t.bottomSheetContentWrapper
595
588
  );
596
589
  }
597
- function Y(T) {
598
- const O = T ?? e;
599
- O.draggable && O.backgroundDraggable && (f.addEventListeners({
590
+ function Y(k) {
591
+ const O = k ?? e;
592
+ O.draggable && O.backgroundDraggable && (b.addEventListeners({
600
593
  onStart: w,
601
594
  onStartOptions: {
602
595
  eventPhase: j.Target
@@ -607,41 +600,41 @@ function te({
607
600
  onStart: v,
608
601
  onMove: S,
609
602
  onEnd: E
610
- }), O.draggable && window.document.addEventListener("keyup", (b) => {
611
- b.key === "Escape" && n.onClose();
612
- }), i.addEventListener("keyup", (b) => {
613
- if (b.key === "ArrowUp") {
603
+ }), O.draggable && window.document.addEventListener("keyup", (f) => {
604
+ f.key === "Escape" && n.onClose();
605
+ }), i.addEventListener("keyup", (f) => {
606
+ if (f.key === "ArrowUp") {
614
607
  n.moveUp();
615
608
  return;
616
609
  }
617
- if (b.key === "ArrowDown") {
610
+ if (f.key === "ArrowDown") {
618
611
  n.moveDown();
619
612
  return;
620
613
  }
621
- if (b.shiftKey && b.key === "Tab") {
622
- const d = P(
614
+ if (f.shiftKey && f.key === "Tab") {
615
+ const d = F(
623
616
  t.bottomSheetContentWrapper
624
617
  );
625
- jt(d);
618
+ Nt(d);
626
619
  }
627
620
  });
628
621
  }
629
- function U(T) {
630
- const O = T ?? e;
622
+ function U(k) {
623
+ const O = k ?? e;
631
624
  e.shouldCloseOnOutsideClick && !e.preventClosing ? u.addEventListener("click", x) : u.style.pointerEvents = "none", O.draggable && (s.addEventListeners({
632
625
  onStart: w
633
- }), c.forEach((b) => {
634
- b.removeEventListeners({
626
+ }), c.forEach((f) => {
627
+ f.removeEventListeners({
635
628
  onStart: w
636
629
  });
637
- }), c = e.dragTriggers.reduce((b, d) => {
630
+ }), c = e.dragTriggers.reduce((f, d) => {
638
631
  const p = o.querySelectorAll(d);
639
632
  if (!p.length)
640
- return b;
633
+ return f;
641
634
  const g = Array.from(p).map((m) => m instanceof HTMLElement ? new X(m) : null).filter((m) => !!m);
642
- return [...b, ...g];
643
- }, []), c.forEach((b) => {
644
- b.addEventListeners({
635
+ return [...f, ...g];
636
+ }, []), c.forEach((f) => {
637
+ f.addEventListeners({
645
638
  onStart: w,
646
639
  onStartOptions: {
647
640
  eventPhase: j.Target
@@ -652,28 +645,28 @@ function te({
652
645
  function $() {
653
646
  u.removeEventListener("click", x);
654
647
  }
655
- function P(T) {
656
- let O = [...Array.from(T.childNodes).reverse()];
648
+ function F(k) {
649
+ let O = [...Array.from(k.childNodes).reverse()];
657
650
  for (; O.length; ) {
658
- const b = O.shift();
659
- if (Gt(b))
660
- return b;
661
- b && (O = [
651
+ const f = O.shift();
652
+ if (jt(f))
653
+ return f;
654
+ f && (O = [
662
655
  ...O,
663
- ...Array.from(b.childNodes).reverse()
656
+ ...Array.from(f.childNodes).reverse()
664
657
  ]);
665
658
  }
666
659
  return null;
667
660
  }
668
- function F() {
661
+ function I() {
669
662
  s.removeEventListeners({
670
663
  onStart: w
671
- }), f.removeEventListeners({
664
+ }), b.removeEventListeners({
672
665
  onStart: w
673
666
  }), y.removeEventListeners({
674
667
  onStart: w
675
- }), c.forEach((T) => {
676
- T.removeEventListeners({
668
+ }), c.forEach((k) => {
669
+ k.removeEventListeners({
677
670
  onStart: w
678
671
  });
679
672
  }), C.removeEventListeners({
@@ -684,12 +677,12 @@ function te({
684
677
  }
685
678
  return {
686
679
  attachEventListeners: Y,
687
- clearEventListeners: F,
680
+ clearEventListeners: I,
688
681
  attacheOnOpenEventListeners: U,
689
682
  clearOnOpenEventListeners: $
690
683
  };
691
684
  }
692
- class ee {
685
+ class te {
693
686
  constructor() {
694
687
  J(this, "animationId"), J(this, "isInProgress"), J(this, "startedAt"), this.animationId = null, this.isInProgress = !1, this.startedAt = null;
695
688
  }
@@ -711,7 +704,7 @@ class ee {
711
704
  this.isInProgress = !1, this.startedAt = null, A(this.animationId) && cancelAnimationFrame(this.animationId);
712
705
  }
713
706
  }
714
- function ne(t) {
707
+ function ee(t) {
715
708
  const {
716
709
  startY: e,
717
710
  endY: n,
@@ -730,7 +723,7 @@ function ne(t) {
730
723
  }, l);
731
724
  }
732
725
  const ut = (t, e) => (n) => {
733
- ne({
726
+ ee({
734
727
  ...n,
735
728
  animationTimingFunction: t,
736
729
  animationDuration: e
@@ -741,10 +734,10 @@ const ut = (t, e) => (n) => {
741
734
  CONTENT_HEIGHT: "content-height",
742
735
  CLOSED: "closed"
743
736
  };
744
- function oe(t) {
737
+ function ne(t) {
745
738
  return !(!A(t) || t > 1 || t < 0);
746
739
  }
747
- function re(t, e) {
740
+ function oe(t, e) {
748
741
  const n = {
749
742
  set(o, r, i, a) {
750
743
  return e(r, i), Reflect.set(o, r, i, a);
@@ -752,7 +745,7 @@ function re(t, e) {
752
745
  };
753
746
  return new Proxy(t, n);
754
747
  }
755
- function ae(...t) {
748
+ function re(...t) {
756
749
  console.error(t);
757
750
  }
758
751
  const W = {
@@ -762,7 +755,7 @@ const W = {
762
755
  EASE_IN_OUT: "ease-in-out",
763
756
  SPRING: "spring"
764
757
  };
765
- function ie(t) {
758
+ function ae(t) {
766
759
  for (const e of Object.values(W))
767
760
  if (e === t)
768
761
  return !0;
@@ -776,13 +769,13 @@ function G(t, e, n, o) {
776
769
  return a(r(l));
777
770
  };
778
771
  function r(l) {
779
- let u = 0, h = 1, s = l, f;
772
+ let u = 0, h = 1, s = l, b;
780
773
  if (l === 0 || l === 1)
781
774
  return l;
782
775
  for (; u < h; ) {
783
- if (f = i(s), Math.abs(f - l) < 1e-3)
776
+ if (b = i(s), Math.abs(b - l) < 1e-3)
784
777
  return s;
785
- l > f ? u = s : h = s, s = (h + u) / 2;
778
+ l > b ? u = s : h = s, s = (h + u) / 2;
786
779
  }
787
780
  return s;
788
781
  }
@@ -793,19 +786,19 @@ function G(t, e, n, o) {
793
786
  return 3 * e * l * Math.pow(1 - l, 2) + 3 * o * Math.pow(l, 2) * (1 - l) + Math.pow(l, 3);
794
787
  }
795
788
  }
796
- const St = G(0.25, 0.1, 0.25, 1), se = G(0.42, 0, 1, 1), At = G(0.42, 0, 0.58, 1), ce = G(0.4, 0.1, 0.6, 1), le = G(0.45, 1.5, 0.55, 1);
797
- function ue(t) {
789
+ const St = G(0.25, 0.1, 0.25, 1), ie = G(0.42, 0, 1, 1), At = G(0.42, 0, 0.58, 1), se = G(0.4, 0.1, 0.6, 1), ce = G(0.45, 1.5, 0.55, 1);
790
+ function le(t) {
798
791
  switch (t) {
799
792
  case W.EASE:
800
793
  return St;
801
794
  case W.EASE_IN:
802
- return se;
795
+ return ie;
803
796
  case W.EASE_OUT:
804
797
  return At;
805
798
  case W.EASE_IN_OUT:
806
- return ce;
799
+ return se;
807
800
  case W.SPRING:
808
- return le;
801
+ return ce;
809
802
  default:
810
803
  return St;
811
804
  }
@@ -813,7 +806,7 @@ function ue(t) {
813
806
  function yt(t) {
814
807
  return typeof t == "boolean";
815
808
  }
816
- const de = {
809
+ const ue = {
817
810
  ariaLabel: "Bottom sheet",
818
811
  content: "",
819
812
  defaultPosition: N.CONTENT_HEIGHT,
@@ -860,9 +853,9 @@ const de = {
860
853
  backdropStyle: {},
861
854
  containerGapFillerStyle: {}
862
855
  };
863
- function pe(t) {
856
+ function de(t) {
864
857
  const e = {
865
- ...de
858
+ ...ue
866
859
  }, n = Object.entries(t).reduce(
867
860
  (o, r) => {
868
861
  const [i, a] = r;
@@ -880,9 +873,9 @@ function dt(t) {
880
873
  const { p1x: e, p1y: n, p2x: o, p2y: r } = t;
881
874
  return G(e, n, o, r);
882
875
  }
883
- return ie(t) ? ue(t) : At;
876
+ return ae(t) ? le(t) : At;
884
877
  }
885
- function he(t, e, n, o) {
878
+ function pe(t, e, n, o) {
886
879
  function r(i, a) {
887
880
  switch (i) {
888
881
  case "content":
@@ -1026,8 +1019,8 @@ function he(t, e, n, o) {
1026
1019
  }
1027
1020
  return r;
1028
1021
  }
1029
- function me(t) {
1030
- const e = pe(t), n = dt(
1022
+ function he(t) {
1023
+ const e = de(t), n = dt(
1031
1024
  t.draggingAnimationTimings
1032
1025
  ), o = {
1033
1026
  isMounted: !1,
@@ -1048,28 +1041,28 @@ function me(t) {
1048
1041
  function i() {
1049
1042
  r.originalDocumentOverflowY && r.originalDocumentOverflowY !== "hidden" && (document.body.style.overflowY = r.originalDocumentOverflowY), r.originalDocumentOverscrollBehavior && (document.body.style.position = r.originalDocumentOverscrollBehavior);
1050
1043
  }
1051
- const a = new ee(), l = {
1044
+ const a = new te(), l = {
1052
1045
  animationFrame: a,
1053
1046
  onClose: E,
1054
1047
  bottomSheetState: o,
1055
1048
  draggingState: r,
1056
- snapTo: b,
1057
- moveUp: T,
1049
+ snapTo: f,
1050
+ moveUp: k,
1058
1051
  moveDown: O
1059
- }, { elements: u, eventHandlers: h } = Jt(
1052
+ }, { elements: u, eventHandlers: h } = Kt(
1060
1053
  e,
1061
1054
  l
1062
- ), s = re(
1055
+ ), s = oe(
1063
1056
  e,
1064
- he(
1057
+ pe(
1065
1058
  u,
1066
1059
  o,
1067
1060
  e,
1068
1061
  h
1069
1062
  )
1070
- ), { bottomSheetBackdrop: f, bottomSheetRoot: y, bottomSheetContainer: c } = u, C = (d) => {
1063
+ ), { bottomSheetBackdrop: b, bottomSheetRoot: y, bottomSheetContainer: c } = u, C = (d) => {
1071
1064
  const p = d ?? window.document.body;
1072
- p.appendChild(y), p.appendChild(f);
1065
+ p.appendChild(y), p.appendChild(b);
1073
1066
  const g = window.innerHeight;
1074
1067
  et(c, {
1075
1068
  y: g
@@ -1080,11 +1073,11 @@ function me(t) {
1080
1073
  }), i(), o.isMounted = !1;
1081
1074
  }, S = () => {
1082
1075
  var d;
1083
- if (x() || ae(
1076
+ if (x() || re(
1084
1077
  'Bottom Sheet is not mounted yet. call the "mount" method first.'
1085
1078
  ), (d = t.beforeOpen) == null || d.call(t), w())
1086
1079
  return;
1087
- ot(f, !0), s.shouldShowBackdrop || K(f, "transparent"), ot([c], !0), et(c, {
1080
+ ot(b, !0), s.shouldShowBackdrop || K(b, "transparent"), ot([c], !0), et(c, {
1088
1081
  y: c.clientHeight
1089
1082
  });
1090
1083
  const p = window.innerHeight, g = mt(
@@ -1100,8 +1093,8 @@ function me(t) {
1100
1093
  bottomSheetContainer: c,
1101
1094
  onEnd: t.afterOpen
1102
1095
  });
1103
- const H = document.body.style.overflowY;
1104
- r.originalDocumentOverflowY = H || "initial";
1096
+ const T = document.body.style.overflowY;
1097
+ r.originalDocumentOverflowY = T || "initial";
1105
1098
  const B = document.body.style.overscrollBehavior;
1106
1099
  r.originalDocumentOverscrollBehavior = B || "initial", document.body.style.overflow = "hidden", document.body.style.overscrollBehavior = "contain", u.bottomSheetHandle.focus(), h.attacheOnOpenEventListeners();
1107
1100
  };
@@ -1118,7 +1111,7 @@ function me(t) {
1118
1111
  bottomSheetContainer: c,
1119
1112
  onEnd: () => {
1120
1113
  var m;
1121
- (m = t.afterClose) == null || m.call(t), ot([f, c], !1), h.clearOnOpenEventListeners();
1114
+ (m = t.afterClose) == null || m.call(t), ot([b, c], !1), h.clearOnOpenEventListeners();
1122
1115
  }
1123
1116
  }), i();
1124
1117
  }
@@ -1139,56 +1132,56 @@ function me(t) {
1139
1132
  const m = p - d;
1140
1133
  if (m === g / 2)
1141
1134
  return N.MIDDLE;
1142
- const H = g - s.marginTop, B = 10;
1143
- return m <= H + B && m >= H - B ? N.TOP : N.CLOSED;
1135
+ const T = g - s.marginTop, B = 10;
1136
+ return m <= T + B && m >= T - B ? N.TOP : N.CLOSED;
1144
1137
  }
1145
1138
  function $() {
1146
1139
  return c.clientHeight;
1147
1140
  }
1148
- function P(d) {
1141
+ function F(d) {
1149
1142
  if (!w())
1150
1143
  return;
1151
- const p = D(c).y, g = c.clientHeight - p, m = window.innerHeight - d, H = Ut(g, m), B = V(g, m);
1144
+ const p = D(c).y, g = c.clientHeight - p, m = window.innerHeight - d, T = Gt(g, m), B = V(g, m);
1152
1145
  o.translateContainer({
1153
1146
  startY: p,
1154
- endY: p + (H.isUp ? -B : B),
1147
+ endY: p + (T.isUp ? -B : B),
1155
1148
  animationFrame: a,
1156
1149
  bottomSheetContainer: c
1157
1150
  });
1158
1151
  }
1159
- function F(d, {
1152
+ function I(d, {
1160
1153
  viewportHeight: p,
1161
1154
  visibleHeight: g
1162
1155
  }) {
1163
1156
  let m = null;
1164
- for (const H of d) {
1165
- const B = H * p, I = V(
1157
+ for (const T of d) {
1158
+ const B = T * p, P = V(
1166
1159
  g,
1167
1160
  B
1168
1161
  );
1169
- (m === null || I < m) && (m = I);
1162
+ (m === null || P < m) && (m = P);
1170
1163
  }
1171
1164
  return {
1172
1165
  minOffset: m
1173
1166
  };
1174
1167
  }
1175
- function T() {
1168
+ function k() {
1176
1169
  const d = [...s.snapPoints].reverse(), p = D(c).y, g = c.clientHeight, m = g - p;
1177
1170
  if (!s.expandable && m >= g)
1178
1171
  return;
1179
- const H = window.innerHeight, B = ft(
1172
+ const T = window.innerHeight, B = bt(
1180
1173
  "above",
1181
- { visibleHeight: m, viewportHeight: H },
1174
+ { visibleHeight: m, viewportHeight: T },
1182
1175
  d
1183
- ), { minOffset: I } = F(B, {
1176
+ ), { minOffset: P } = I(B, {
1184
1177
  visibleHeight: m,
1185
- viewportHeight: H
1178
+ viewportHeight: T
1186
1179
  });
1187
- if (I === null && m < H - s.marginTop) {
1180
+ if (P === null && m < T - s.marginTop) {
1188
1181
  o.translateContainer({
1189
1182
  startY: p,
1190
1183
  endY: mt(
1191
- H,
1184
+ T,
1192
1185
  g,
1193
1186
  s.marginTop,
1194
1187
  "top"
@@ -1198,9 +1191,9 @@ function me(t) {
1198
1191
  });
1199
1192
  return;
1200
1193
  }
1201
- A(I) && o.translateContainer({
1194
+ A(P) && o.translateContainer({
1202
1195
  startY: p,
1203
- endY: p - I,
1196
+ endY: p - P,
1204
1197
  animationFrame: a,
1205
1198
  bottomSheetContainer: c
1206
1199
  });
@@ -1209,27 +1202,27 @@ function me(t) {
1209
1202
  const d = D(c).y, p = c.clientHeight - d;
1210
1203
  if (p < 1)
1211
1204
  return;
1212
- const g = window.innerHeight, m = ft(
1205
+ const g = window.innerHeight, m = bt(
1213
1206
  "below",
1214
1207
  { visibleHeight: p, viewportHeight: g },
1215
1208
  s.snapPoints
1216
- ), { minOffset: H } = F(m, {
1209
+ ), { minOffset: T } = I(m, {
1217
1210
  visibleHeight: p,
1218
1211
  viewportHeight: g
1219
1212
  });
1220
- A(H) && o.translateContainer({
1213
+ A(T) && o.translateContainer({
1221
1214
  startY: d,
1222
- endY: d + H,
1215
+ endY: d + T,
1223
1216
  animationFrame: a,
1224
1217
  bottomSheetContainer: c
1225
1218
  });
1226
1219
  }
1227
- function b(d) {
1220
+ function f(d) {
1228
1221
  const p = window.innerHeight;
1229
- if (!oe(d))
1222
+ if (!ne(d))
1230
1223
  return;
1231
1224
  const g = tt(p * d, 2);
1232
- P(g);
1225
+ F(g);
1233
1226
  }
1234
1227
  return {
1235
1228
  props: s,
@@ -1243,8 +1236,8 @@ function me(t) {
1243
1236
  getIsClosed: Y,
1244
1237
  getPosition: U,
1245
1238
  getHeight: $,
1246
- moveTo: P,
1247
- snapTo: b
1239
+ moveTo: F,
1240
+ snapTo: f
1248
1241
  };
1249
1242
  }
1250
1243
  function Bt() {
@@ -1280,7 +1273,7 @@ function Bt() {
1280
1273
  }
1281
1274
  };
1282
1275
  }
1283
- const fe = Bt(), Se = Dt(
1276
+ const me = Bt(), ve = Dt(
1284
1277
  function(e, n) {
1285
1278
  const {
1286
1279
  children: o,
@@ -1289,7 +1282,7 @@ const fe = Bt(), Se = Dt(
1289
1282
  afterClose: a,
1290
1283
  mountingPointRef: l,
1291
1284
  ...u
1292
- } = e, h = rt(fe), [s, f] = at(
1285
+ } = e, h = rt(me), [s, b] = at(
1293
1286
  h.current
1294
1287
  );
1295
1288
  Mt(
@@ -1309,15 +1302,15 @@ const fe = Bt(), Se = Dt(
1309
1302
  var E;
1310
1303
  if (l && !l.current)
1311
1304
  return;
1312
- const v = Ft((E = e.mountingPointRef) == null ? void 0 : E.current) ? e.mountingPointRef.current : window.document.body;
1305
+ const v = It((E = e.mountingPointRef) == null ? void 0 : E.current) ? e.mountingPointRef.current : window.document.body;
1313
1306
  if (!v || s.getIsMounted())
1314
1307
  return;
1315
- const S = me({
1308
+ const S = he({
1316
1309
  content: "",
1317
1310
  ...u,
1318
1311
  afterClose: y
1319
1312
  });
1320
- return S.mount(v), c.current = S.elements.bottomSheetContentWrapper ?? null, h.current = S, f(S), () => {
1313
+ return S.mount(v), c.current = S.elements.bottomSheetContentWrapper ?? null, h.current = S, b(S), () => {
1321
1314
  s.unmount();
1322
1315
  };
1323
1316
  },
@@ -1326,20 +1319,20 @@ const fe = Bt(), Se = Dt(
1326
1319
  function() {
1327
1320
  Object.assign(h.current.props, {
1328
1321
  ...u
1329
- }), f(h.current);
1322
+ }), b(h.current);
1330
1323
  },
1331
1324
  [u]
1332
1325
  ), q(function() {
1333
1326
  return () => {
1334
1327
  h.current.unmount();
1335
1328
  };
1336
- }, []), c.current ? Pt(
1329
+ }, []), c.current ? Ft(
1337
1330
  e.children,
1338
1331
  c.current
1339
1332
  ) : null;
1340
1333
  }
1341
1334
  ), be = Bt();
1342
- function ye(t = {}) {
1335
+ function Se(t = {}) {
1343
1336
  const e = rt(be), [n, o] = at(!1), r = !n, [i, a] = at(e.current);
1344
1337
  q(() => {
1345
1338
  a(e.current);
@@ -1349,7 +1342,7 @@ function ye(t = {}) {
1349
1342
  afterOpen: u,
1350
1343
  beforeClose: h,
1351
1344
  afterClose: s,
1352
- onDragStart: f,
1345
+ onDragStart: b,
1353
1346
  onDragMove: y,
1354
1347
  onDragEnd: c,
1355
1348
  ...C
@@ -1362,9 +1355,9 @@ function ye(t = {}) {
1362
1355
  }, x = () => {
1363
1356
  s == null || s(), o(!1);
1364
1357
  }, w = () => {
1365
- f == null || f();
1366
- }, Y = (b, d) => {
1367
- y == null || y(b, d);
1358
+ b == null || b();
1359
+ }, Y = (f, d) => {
1360
+ y == null || y(f, d);
1368
1361
  }, U = () => {
1369
1362
  c == null || c();
1370
1363
  }, $ = Yt(() => ({
@@ -1379,18 +1372,18 @@ function ye(t = {}) {
1379
1372
  onDragMove: Y,
1380
1373
  onDragEnd: U,
1381
1374
  ...C
1382
- }), [e.current, n, o, t]), P = z(() => {
1375
+ }), [e.current, n, o, t]), F = z(() => {
1383
1376
  o(!0);
1384
- }, [o]), F = z(() => {
1377
+ }, [o]), I = z(() => {
1385
1378
  o(!1);
1386
- }, [o]), T = z(
1387
- (...b) => {
1388
- i.moveTo(...b);
1379
+ }, [o]), k = z(
1380
+ (...f) => {
1381
+ i.moveTo(...f);
1389
1382
  },
1390
1383
  [i]
1391
1384
  ), O = z(
1392
- (...b) => {
1393
- i.snapTo(...b);
1385
+ (...f) => {
1386
+ i.snapTo(...f);
1394
1387
  },
1395
1388
  [i]
1396
1389
  );
@@ -1400,14 +1393,14 @@ function ye(t = {}) {
1400
1393
  isOpen: n,
1401
1394
  isClosed: r,
1402
1395
  setIsOpen: o,
1403
- open: P,
1404
- close: F,
1405
- moveTo: T,
1396
+ open: F,
1397
+ close: I,
1398
+ moveTo: k,
1406
1399
  snapTo: O
1407
1400
  };
1408
1401
  }
1409
1402
  export {
1410
- Se as BottomSheet,
1403
+ ve as BottomSheet,
1411
1404
  Bt as createPlaceholderBottomSheet,
1412
- ye as useBottomSheet
1405
+ Se as useBottomSheet
1413
1406
  };
@@ -1 +1 @@
1
- (function(M,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],v):(M=typeof globalThis<"u"?globalThis:M||self,v(M.BottomSheet={},M.React,M.ReactDOM))})(this,function(M,v,xe){"use strict";function Ae(e){return e!=null}(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var De=Object.defineProperty,Me=(e,t,n)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,J=(e,t,n)=>Me(e,typeof t!="symbol"?t+"":t,n);function L(e){return typeof e=="string"}function Pe(e,t){return e.classList.contains(Q(t))}function _(e,t){e.classList.add(Q(t))}function oe(e,t){e.classList.remove(Q(t))}function X(e,t,n){L(n)&&(L(t)&&oe(e,t),_(e,n))}function Q(e){return L(e)?e.trim().replace(/\./g,""):""}function R(e){return e.map(t=>Q(t)).filter(Boolean).join(" ")}function Ye(e){return e.map(t=>t==null?void 0:t.trim()).filter(Boolean).map(t=>`.${t}`).join(" ")}const de="open",pe="hidden";function re(e,t){const n=t;if(Array.isArray(e)){e.forEach(o=>{Z(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Z(e,n),e.setAttribute("aria-modal",n?"true":"false")}function Z(e,t){t?(_(e,de),oe(e,pe)):(_(e,pe),oe(e,de))}function he(e){return e instanceof HTMLElement}function A(e){return typeof e=="number"&&!Number.isNaN(e)}function Re(e){he(e)&&e.focus()}function Fe(e){if(!he(e)||e.offsetParent===null||"disabled"in e&&e.disabled)return!1;const t=e.getAttribute("tabindex"),n=A(t)?parseInt(t,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(e.tagName),r=e instanceof HTMLAnchorElement&&e.href!==""||e instanceof HTMLAreaElement&&e.href!=="";return o||r||n>-1}var k=(e=>(e.Backdrop="pbs-backdrop",e.Root="pbs-root",e.Container="pbs-container",e.GapFiller="pbs-gap-filler",e.Handle="pbs-handle",e.HandleBar="pbs-handle-bar",e.ContentWrapper="pbs-content-wrapper",e))(k||{}),ae=(e=>(e.Button="pbs-button-reset",e.Dialog="pbs-dialog-reset",e))(ae||{}),ee=(e=>(e.Hidden="hidden",e))(ee||{});function Y(e,t,n){const o=document.createElement(e);return t.split(" ").forEach(r=>{_(o,r)}),L(n)&&o.setAttribute("data-testid",n),o}Ye([k.Root,k.ContentWrapper]);function me(e,t,n,o){switch(o){case"content-height":return t>=e?ve(e,t,n):0;case"middle":return-(e/2-t);case"top":return-(e-t)+n;default:return 0}}function fe(e,t){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function be(e,t){return t<e?-(e-t):t-e}function q(e,t){return e>t?e-t:t-e}function Ie(e,t){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function ge(e,t,n){const o=e==="above";return n.filter(r=>{const i=r*t.viewportHeight;return o?t.visibleHeight<i:t.visibleHeight>i})}function ve(e,t,n){return-(e-t)+n}function Se(e){return Number(e.replace("px",""))}function te(e,...t){return Number(e.toFixed(...t))}function ye(e){const t=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=t.exec(e))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function We(e){const t=e.style.transform,n=ye(t);return{transform:t,transformValues:n}}function Ce(e,t){return e.find(o=>o.type.startsWith(t))||null}const ie="translate";function P(e){const t=e.style.transform,n=ye(t),o=Ce(n,ie);return Ee(o??{type:ie,values:[]})}function ne(e,{x:t,y:n}){const{transform:o,transformValues:r}=We(e),i=Ce(r,ie);if(i){const a=Ee(i);e.style.transform=`translate(${t??a.x??0}px,${n??a.y??0}px)`;return}if(o){e.style.transform=`${o}, translate(${t??0}px,${n??0}px)`;return}e.style.transform=`translate(${t??0}px,${n??0}px)`}function Ee(e){if(e.type!=="translate")throw new Error(`Could not get coordinates from ${e.type}, since is not translate.`);const t=e.values[0],n=e.values[1];return{x:Se(t)??0,y:Se(n)??0}}function se(e){return e!=null}function we(e,{min:t,max:n}){return se(n)&&e>=n?n:se(t)&&e<=t?t:e}const Ne=(e,t,n)=>{t instanceof HTMLElement&&!Pe(t,k.Handle)&&n.scrollTop>=1||(e.isDragging=!0)},je=(e,t,n,o)=>r=>{o.startY=e.getCoordinates(r).y,o.containerStartTranslate=P(t),n.onDragStart()},Ge=(e,t,n,o,r)=>i=>{Ue(i,e,n,o,r,t,n.marginTop)};function Ue(e,t,n,o,r,i,a){if(!o.isDragging||!A(o.startY))return;const l=t.getCoordinates(e).y,u=be(o.startY,l),h=window.innerHeight,s=i.clientHeight,f=s-(o.containerStartTranslate.y+u);if(f>=h)return;const C=fe(o.startY,l);if(C.isUp&&!n.expandable&&f>=s||n.preventClosing&&f<=s)return;r.start(()=>{ne(i,{y:o.containerStartTranslate.y+u})},0);const c=h-a,E=s-o.containerStartTranslate.y;if(C.isUp){const S=c-E,y=c-f,w=we(1-te(y/S,2),{min:0,max:1});n.onDragMove(C,w)}else if(C.isDown){const S=we(te(1-f/E,2),{min:0,max:1});n.onDragMove(C,S)}}const $e=(e,t,n,o,r,i,a)=>l=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const u=o.startY,h=e.getCoordinates(l).y,s=P(t).y,f=fe(u,h),C=window.innerHeight,c=t.clientHeight;if(f.isUp){if(!n.expandable)return;const E=[...n.snapPoints].sort((w,x)=>w-x),S=c+-s;for(const w of E){const x=w*window.innerHeight;if(S<=x){const T=q(S,x);a.translateContainer({startY:s,endY:s-T,animationFrame:r,bottomSheetContainer:t});return}}const y=ve(C,c,n.marginTop);a.translateContainer({startY:s,endY:y,animationFrame:r,bottomSheetContainer:t})}else if(f.isDown){const E=[...n.snapPoints].sort((S,y)=>y-S);for(const S of E){const y=S*window.innerHeight,w=c+-s;if(w>=y){const x=q(w,y);a.translateContainer({startY:s,endY:s+x,animationFrame:r,bottomSheetContainer:t});return}}if(n.preventClosing){const S=c+-s;if(S>=c){const y=q(S,c);a.translateContainer({startY:s,endY:s+y,animationFrame:r,bottomSheetContainer:t})}return}i()}};var F=(e=>(e[e.All=-1]="All",e[e.None=0]="None",e[e.Capture=1]="Capture",e[e.Target=2]="Target",e[e.Bubble=3]="Bubble",e))(F||{});function ke(e){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const _e={eventPhase:F.All};class z{constructor(t){J(this,"currentTarget"),this.currentTarget=t}addEventListeners({onStart:t,onStartOptions:n=_e,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===F.All){t(i);return}ke(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===F.All){t(i);return}ke(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:t,onMove:n,onEnd:o}){t&&this.currentTarget.removeEventListener("touchstart",t),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),t&&this.currentTarget.removeEventListener("mousedown",t),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(t){if(t.type==="touchstart"||t.type==="mousedown"){if("touches"in t)return{x:t.touches[0].clientX,y:t.touches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}if(t.type==="touchend"||t.type==="mouseup"||t.type==="mousemove"||t.type==="touchmove"){if("touches"in t)return{x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}return{x:0,y:0}}}function Te(e){const t=e;return`${t} ${t} 0px 0px`}function Xe(e,t){const n=qe(e);ze(n),n.bottomSheetContainer.style.width=e.width;const o=document.createElement("div");o.innerHTML=e.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=Ve({bottomSheetElements:n,bottomSheetProps:e,options:t});return e.rootStyle&&Object.assign(n.bottomSheetRoot.style,e.rootStyle),e.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,e.backdropStyle),e.containerGapFillerStyle&&Object.assign(n.bottomSheetContainer.style,e.containerStyle),e.containerStyle&&Object.assign(n.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle),e.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,e.handleStyle),e.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,e.contentWrapperStyle),{elements:n,eventHandlers:i}}function qe(e){const t=Y("dialog",R([k.Root,ae.Dialog,e.rootClass]),k.Root);t.ariaLabel=e.ariaLabel;const n=Y("section",R([k.Container,e.containerClass]),k.Container);e.containerBorderRadius&&(n.style.borderRadius=Te(e.containerBorderRadius));const o=Y("div",k.GapFiller,k.GapFiller);e.containerBackgroundColor&&(n.style.backgroundColor=e.containerBackgroundColor,o.style.backgroundColor=e.containerBackgroundColor);const r=Y("button",R([k.Handle,ae.Button,e.shouldShowHandle?null:ee.Hidden,e.handleClass]),k.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=Y("span",R([k.HandleBar,e.shouldShowHandle?null:ee.Hidden]),k.HandleBar),a=Y("article",R([k.ContentWrapper,e.contentWrapperClass]),k.ContentWrapper),l=Y("div",R([k.Backdrop,e.backdropClass,ee.Hidden]),k.Backdrop);return e.backdropColor&&(l.style.backgroundColor=e.backdropColor),e.backDropTransition&&(l.style.transition=e.backDropTransition),{bottomSheetRoot:t,bottomSheetBackdrop:l,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function ze({bottomSheetRoot:e,bottomSheetContainer:t,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){e.appendChild(t),n.appendChild(o),t.appendChild(n),t.appendChild(r),t.appendChild(i)}function Ve({bottomSheetElements:e,bottomSheetProps:t,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:l,bottomSheetBackdrop:u}=e,{animationFrame:h}=n,s=new z(i),f=new z(l),C=new z(a);let c=[];const E=new z(window),S=je(E,r,t,n.draggingState),y=Ge(E,r,t,n.draggingState,h),w=$e(E,r,t,n.draggingState,h,n.onClose,n.bottomSheetState);function x(H){H.target instanceof Element&&!o.contains(H.target)&&n.onClose()}function T(H){Ne(n.draggingState,H.target,e.bottomSheetContentWrapper)}function j(H){const B=H??t;B.draggable&&B.backgroundDraggable&&(f.addEventListeners({onStart:T,onStartOptions:{eventPhase:F.Target}}),C.addEventListeners({onStart:T})),B.draggable&&E.addEventListeners({onStart:S,onMove:y,onEnd:w}),B.draggable&&window.document.addEventListener("keyup",b=>{b.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",b=>{if(b.key==="ArrowUp"){n.moveUp();return}if(b.key==="ArrowDown"){n.moveDown();return}if(b.shiftKey&&b.key==="Tab"){const d=G(e.bottomSheetContentWrapper);Re(d)}})}function V(H){const B=H??t;t.shouldCloseOnOutsideClick&&!t.preventClosing?u.addEventListener("click",x):u.style.pointerEvents="none",B.draggable&&(s.addEventListeners({onStart:T}),c.forEach(b=>{b.removeEventListeners({onStart:T})}),c=t.dragTriggers.reduce((b,d)=>{const p=o.querySelectorAll(d);if(!p.length)return b;const g=Array.from(p).map(m=>m instanceof HTMLElement?new z(m):null).filter(m=>!!m);return[...b,...g]},[]),c.forEach(b=>{b.addEventListeners({onStart:T,onStartOptions:{eventPhase:F.Target}})}))}function K(){u.removeEventListener("click",x)}function G(H){let B=[...Array.from(H.childNodes).reverse()];for(;B.length;){const b=B.shift();if(Fe(b))return b;b&&(B=[...B,...Array.from(b.childNodes).reverse()])}return null}function U(){s.removeEventListeners({onStart:T}),f.removeEventListeners({onStart:T}),C.removeEventListeners({onStart:T}),c.forEach(H=>{H.removeEventListeners({onStart:T})}),E.removeEventListeners({onStart:S,onMove:y,onEnd:w})}return{attachEventListeners:j,clearEventListeners:U,attacheOnOpenEventListeners:V,clearOnOpenEventListeners:K}}class Ke{constructor(){J(this,"animationId"),J(this,"isInProgress"),J(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(t,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,l=n===0?1:te(a/n,2),u=l>=1&&!o;t(l),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Je(e){const{startY:t,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:l}=e,u=be(t,n);r.stop();let h=!1;r.start(s=>{ne(o,{y:t+u*a(s)}),!h&&s>=1&&(i==null||i(),h=!0)},l)}const ce=(e,t)=>n=>{Je({...n,animationTimingFunction:e,animationDuration:t})},I={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Qe(e){return!(!A(e)||e>1||e<0)}function Ze(e,t){const n={set(o,r,i,a){return t(r,i),Reflect.set(o,r,i,a)}};return new Proxy(e,n)}function et(...e){console.error(e)}const W={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function tt(e){for(const t of Object.values(W))if(t===e)return!0;return!1}function He(e){return!!(e instanceof Object&&"p1x"in e&&"p1y"in e&&"p2x"in e&&"p2y"in e&&A(e.p1x)&&A(e.p1y)&&A(e.p2x)&&A(e.p2y))}function N(e,t,n,o){return function(l){return a(r(l))};function r(l){let u=0,h=1,s=l,f;if(l===0||l===1)return l;for(;u<h;){if(f=i(s),Math.abs(f-l)<.001)return s;l>f?u=s:h=s,s=(h+u)/2}return s}function i(l){return 3*e*l*Math.pow(1-l,2)+3*n*Math.pow(l,2)*(1-l)+Math.pow(l,3)}function a(l){return 3*t*l*Math.pow(1-l,2)+3*o*Math.pow(l,2)*(1-l)+Math.pow(l,3)}}const Oe=N(.25,.1,.25,1),nt=N(.42,0,1,1),Le=N(.42,0,.58,1),ot=N(.4,.1,.6,1),rt=N(.45,1.5,.55,1);function at(e){switch(e){case W.EASE:return Oe;case W.EASE_IN:return nt;case W.EASE_OUT:return Le;case W.EASE_IN_OUT:return ot;case W.SPRING:return rt;default:return Oe}}function Be(e){return typeof e=="boolean"}const it={ariaLabel:"Bottom sheet",content:"",defaultPosition:I.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBackgroundColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{},containerGapFillerStyle:{}};function st(e){const t={...it},n=Object.entries(e).reduce((o,r)=>{const[i,a]=r;return se(a)&&(o[i]=a),o},{});return{...t,...n}}function le(e){if(He(e)){const{p1x:t,p1y:n,p2x:o,p2y:r}=e;return N(t,n,o,r)}return tt(e)?at(e):Le}function ct(e,t,n,o){function r(i,a){switch(i){case"content":L(a)&&(e.bottomSheetContentWrapper.innerHTML=a);break;case"width":L(a)&&(e.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Be(a)||Z(e.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Be(a)||Z(e.bottomSheetBackdrop,!1);break;case"containerBorderRadius":L(a)&&(e.bottomSheetContainer.style.borderRadius=Te(a));break;case"containerBackgroundColor":L(a)&&(e.bottomSheetContainer.style.backgroundColor=a,e.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":L(a)&&(e.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":L(a)&&(e.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!L(a))return;X(e.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!L(a))return;X(e.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!L(a))return;X(e.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!L(a))return;X(e.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!L(a))return;X(e.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"dragTriggers":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(He(a)){const l=le(a),u=ce(l,n.draggingAnimationDuration);t.translateContainer=u}break;case"draggingAnimationDuration":if(A(a)){const l=le(n.draggingAnimationTimings),u=ce(l,a);t.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(e.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(e.bottomSheetContainer.style,n.containerStyle);break;case"containerGapFillerStyle":n.containerGapFillerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,n.containerGapFillerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function lt(e){const t=st(e),n=le(e.draggingAnimationTimings),o={isMounted:!1,translateContainer:ce(n,t.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new Ke,l={animationFrame:a,onClose:w,bottomSheetState:o,draggingState:r,snapTo:b,moveUp:H,moveDown:B},{elements:u,eventHandlers:h}=Xe(t,l),s=Ze(t,ct(u,o,t,h)),{bottomSheetBackdrop:f,bottomSheetRoot:C,bottomSheetContainer:c}=u,E=d=>{const p=d??window.document.body;p.appendChild(C),p.appendChild(f);const g=window.innerHeight;ne(c,{y:g}),h.attachEventListeners(),o.isMounted=!0},S=()=>{h.clearEventListeners(),Object.values(u).forEach(d=>{d.remove()}),i(),o.isMounted=!1},y=()=>{var d;if(x()||et('Bottom Sheet is not mounted yet. call the "mount" method first.'),(d=e.beforeOpen)==null||d.call(e),T())return;re(f,!0),s.shouldShowBackdrop||_(f,"transparent"),re([c],!0),ne(c,{y:c.clientHeight});const p=window.innerHeight,g=me(p,c.clientHeight,s.marginTop,s.defaultPosition),m=P(c).y;o.translateContainer({startY:m,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:e.afterOpen});const O=document.body.style.overflowY;r.originalDocumentOverflowY=O||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function w(){var d;if(j())return;(d=e.beforeClose)==null||d.call(e);const p=P(c).y,g=c.clientHeight;o.translateContainer({startY:p,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:()=>{var m;(m=e.afterClose)==null||m.call(e),re([f,c],!1),h.clearOnOpenEventListeners()}}),i()}function x(){return o.isMounted}function T(){const d=P(c).y,p=window.innerHeight,g=c.clientHeight>=p?p:c.clientHeight;return d<=g}function j(){return!T()}function V(){const d=P(c).y,p=c.clientHeight,g=window.innerHeight;if(d<=5&&d>=-5)return I.CONTENT_HEIGHT;const m=p-d;if(m===g/2)return I.MIDDLE;const O=g-s.marginTop,D=10;return m<=O+D&&m>=O-D?I.TOP:I.CLOSED}function K(){return c.clientHeight}function G(d){if(!T())return;const p=P(c).y,g=c.clientHeight-p,m=window.innerHeight-d,O=Ie(g,m),D=q(g,m);o.translateContainer({startY:p,endY:p+(O.isUp?-D:D),animationFrame:a,bottomSheetContainer:c})}function U(d,{viewportHeight:p,visibleHeight:g}){let m=null;for(const O of d){const D=O*p,$=q(g,D);(m===null||$<m)&&(m=$)}return{minOffset:m}}function H(){const d=[...s.snapPoints].reverse(),p=P(c).y,g=c.clientHeight,m=g-p;if(!s.expandable&&m>=g)return;const O=window.innerHeight,D=ge("above",{visibleHeight:m,viewportHeight:O},d),{minOffset:$}=U(D,{visibleHeight:m,viewportHeight:O});if($===null&&m<O-s.marginTop){o.translateContainer({startY:p,endY:me(O,g,s.marginTop,"top"),animationFrame:a,bottomSheetContainer:c});return}A($)&&o.translateContainer({startY:p,endY:p-$,animationFrame:a,bottomSheetContainer:c})}function B(){const d=P(c).y,p=c.clientHeight-d;if(p<1)return;const g=window.innerHeight,m=ge("below",{visibleHeight:p,viewportHeight:g},s.snapPoints),{minOffset:O}=U(m,{visibleHeight:p,viewportHeight:g});A(O)&&o.translateContainer({startY:d,endY:d+O,animationFrame:a,bottomSheetContainer:c})}function b(d){const p=window.innerHeight;if(!Qe(d))return;const g=te(p*d,2);G(g)}return{props:s,elements:u,mount:E,unmount:S,open:y,close:w,getIsMounted:x,getIsOpen:T,getIsClosed:j,getPosition:V,getHeight:K,moveTo:G,snapTo:b}}function ue(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>I.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const ut=ue(),dt=v.forwardRef(function(t,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:l,...u}=t,h=v.useRef(ut),[s,f]=v.useState(h.current);v.useImperativeHandle(n,()=>s,[s]);const C=v.useCallback(()=>{i(!1),a==null||a()},[a]);v.useEffect(()=>{r?s.open():s.close()},[r]);const c=v.useRef(null);return v.useEffect(function(){var w;if(l&&!l.current)return;const S=Ae((w=t.mountingPointRef)==null?void 0:w.current)?t.mountingPointRef.current:window.document.body;if(!S||s.getIsMounted())return;const y=lt({content:"",...u,afterClose:C});return y.mount(S),c.current=y.elements.bottomSheetContentWrapper??null,h.current=y,f(y),()=>{s.unmount()}},[t.mountingPointRef,u,C]),v.useEffect(function(){Object.assign(h.current.props,{...u}),f(h.current)},[u]),v.useEffect(function(){return()=>{h.current.unmount()}},[]),c.current?xe.createPortal(t.children,c.current):null}),pt=ue();function ht(e={}){const t=v.useRef(pt),[n,o]=v.useState(!1),r=!n,[i,a]=v.useState(t.current);v.useEffect(()=>{a(t.current)},[t.current]);const{beforeOpen:l,afterOpen:u,beforeClose:h,afterClose:s,onDragStart:f,onDragMove:C,onDragEnd:c,...E}=e,S=()=>{l==null||l()},y=()=>{u==null||u(),o(!0)},w=()=>{h==null||h()},x=()=>{s==null||s(),o(!1)},T=()=>{f==null||f()},j=(b,d)=>{C==null||C(b,d)},V=()=>{c==null||c()},K=v.useMemo(()=>({ref:t,isOpen:n,setIsOpen:o,beforeOpen:S,afterOpen:y,beforeClose:w,afterClose:x,onDragStart:T,onDragMove:j,onDragEnd:V,...E}),[t.current,n,o,e]),G=v.useCallback(()=>{o(!0)},[o]),U=v.useCallback(()=>{o(!1)},[o]),H=v.useCallback((...b)=>{i.moveTo(...b)},[i]),B=v.useCallback((...b)=>{i.snapTo(...b)},[i]);return{props:K,instance:i,isOpen:n,isClosed:r,setIsOpen:o,open:G,close:U,moveTo:H,snapTo:B}}M.BottomSheet=dt,M.createPlaceholderBottomSheet=ue,M.useBottomSheet=ht,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
1
+ (function(M,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],S):(M=typeof globalThis<"u"?globalThis:M||self,S(M.BottomSheet={},M.React,M.ReactDOM))})(this,function(M,S,Be){"use strict";function Ae(e){return e!=null}(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;flex-shrink:0;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var De=Object.defineProperty,Me=(e,t,n)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,J=(e,t,n)=>Me(e,typeof t!="symbol"?t+"":t,n);function L(e){return typeof e=="string"}function Ye(e,t){return e.classList.contains(Q(t))}function _(e,t){e.classList.add(Q(t))}function oe(e,t){e.classList.remove(Q(t))}function X(e,t,n){L(n)&&(L(t)&&oe(e,t),_(e,n))}function Q(e){return L(e)?e.trim().replace(/\./g,""):""}function F(e){return e.map(t=>Q(t)).filter(Boolean).join(" ")}const de="open",pe="hidden";function re(e,t){const n=t;if(Array.isArray(e)){e.forEach(o=>{Z(o,n),o.setAttribute("aria-modal",n?"true":"false")});return}Z(e,n),e.setAttribute("aria-modal",n?"true":"false")}function Z(e,t){t?(_(e,de),oe(e,pe)):(_(e,pe),oe(e,de))}function he(e){return e instanceof HTMLElement}function A(e){return typeof e=="number"&&!Number.isNaN(e)}function Pe(e){he(e)&&e.focus()}function Fe(e){if(!he(e)||e.offsetParent===null||"disabled"in e&&e.disabled)return!1;const t=e.getAttribute("tabindex"),n=A(t)?parseInt(t,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(e.tagName),r=e instanceof HTMLAnchorElement&&e.href!==""||e instanceof HTMLAreaElement&&e.href!=="";return o||r||n>-1}var T=(e=>(e.Backdrop="pbs-backdrop",e.Root="pbs-root",e.Container="pbs-container",e.GapFiller="pbs-gap-filler",e.Handle="pbs-handle",e.HandleBar="pbs-handle-bar",e.ContentWrapper="pbs-content-wrapper",e))(T||{}),ae=(e=>(e.Button="pbs-button-reset",e.Dialog="pbs-dialog-reset",e))(ae||{}),ee=(e=>(e.Hidden="hidden",e))(ee||{});function P(e,t,n){const o=document.createElement(e);return t.split(" ").forEach(r=>{_(o,r)}),L(n)&&o.setAttribute("data-testid",n),o}function me(e,t,n,o){switch(o){case"content-height":return t>=e?Se(e,t,n):0;case"middle":return-(e/2-t);case"top":return-(e-t)+n;default:return 0}}function fe(e,t){const n=t<e,o=t>e;return{isUp:n,isDown:o,stayedSame:t===e}}function be(e,t){return t<e?-(e-t):t-e}function q(e,t){return e>t?e-t:t-e}function Ie(e,t){const n=e<t,o=e>t;return{isUp:n,isDown:o,stayedSame:e===t}}function ge(e,t,n){const o=e==="above";return n.filter(r=>{const i=r*t.viewportHeight;return o?t.visibleHeight<i:t.visibleHeight>i})}function Se(e,t,n){return-(e-t)+n}function ve(e){return Number(e.replace("px",""))}function te(e,...t){return Number(e.toFixed(...t))}function ye(e){const t=/(?<type>\w+)\((?<values>[^)]+)\)/g,n=[];let o;for(;(o=t.exec(e))!==null;){const r=o[1],i=o[2].split(",").map(a=>a.trim());n.push({type:r,values:i})}return n}function Re(e){const t=e.style.transform,n=ye(t);return{transform:t,transformValues:n}}function Ce(e,t){return e.find(o=>o.type.startsWith(t))||null}const ie="translate";function Y(e){const t=e.style.transform,n=ye(t),o=Ce(n,ie);return Ee(o??{type:ie,values:[]})}function ne(e,{x:t,y:n}){const{transform:o,transformValues:r}=Re(e),i=Ce(r,ie);if(i){const a=Ee(i);e.style.transform=`translate(${t??a.x??0}px,${n??a.y??0}px)`;return}if(o){e.style.transform=`${o}, translate(${t??0}px,${n??0}px)`;return}e.style.transform=`translate(${t??0}px,${n??0}px)`}function Ee(e){if(e.type!=="translate")throw new Error(`Could not get coordinates from ${e.type}, since is not translate.`);const t=e.values[0],n=e.values[1];return{x:ve(t)??0,y:ve(n)??0}}function se(e){return e!=null}function we(e,{min:t,max:n}){return se(n)&&e>=n?n:se(t)&&e<=t?t:e}const We=(e,t,n)=>{t instanceof HTMLElement&&!Ye(t,T.Handle)&&n.scrollTop>=1||(e.isDragging=!0)},je=(e,t,n,o)=>r=>{o.startY=e.getCoordinates(r).y,o.containerStartTranslate=Y(t),n.onDragStart()},Ne=(e,t,n,o,r)=>i=>{Ge(i,e,n,o,r,t,n.marginTop)};function Ge(e,t,n,o,r,i,a){if(!o.isDragging||!A(o.startY))return;const l=t.getCoordinates(e).y,u=be(o.startY,l),h=window.innerHeight,s=i.clientHeight,f=s-(o.containerStartTranslate.y+u);if(f>=h)return;const C=fe(o.startY,l);if(C.isUp&&!n.expandable&&f>=s||n.preventClosing&&f<=s)return;r.start(()=>{ne(i,{y:o.containerStartTranslate.y+u})},0);const c=h-a,E=s-o.containerStartTranslate.y;if(C.isUp){const v=c-E,y=c-f,w=we(1-te(y/v,2),{min:0,max:1});n.onDragMove(C,w)}else if(C.isDown){const v=we(te(1-f/E,2),{min:0,max:1});n.onDragMove(C,v)}}const Ue=(e,t,n,o,r,i,a)=>l=>{if(!o.isDragging||(o.isDragging=!1,!A(o.startY)))return;n.onDragEnd();const u=o.startY,h=e.getCoordinates(l).y,s=Y(t).y,f=fe(u,h),C=window.innerHeight,c=t.clientHeight;if(f.isUp){if(!n.expandable)return;const E=[...n.snapPoints].sort((w,B)=>w-B),v=c+-s;for(const w of E){const B=w*window.innerHeight;if(v<=B){const k=q(v,B);a.translateContainer({startY:s,endY:s-k,animationFrame:r,bottomSheetContainer:t});return}}const y=Se(C,c,n.marginTop);a.translateContainer({startY:s,endY:y,animationFrame:r,bottomSheetContainer:t})}else if(f.isDown){const E=[...n.snapPoints].sort((v,y)=>y-v);for(const v of E){const y=v*window.innerHeight,w=c+-s;if(w>=y){const B=q(w,y);a.translateContainer({startY:s,endY:s+B,animationFrame:r,bottomSheetContainer:t});return}}if(n.preventClosing){const v=c+-s;if(v>=c){const y=q(v,c);a.translateContainer({startY:s,endY:s+y,animationFrame:r,bottomSheetContainer:t})}return}i()}};var I=(e=>(e[e.All=-1]="All",e[e.None=0]="None",e[e.Capture=1]="Capture",e[e.Target=2]="Target",e[e.Bubble=3]="Bubble",e))(I||{});function ke(e){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const $e={eventPhase:I.All};class z{constructor(t){J(this,"currentTarget"),this.currentTarget=t}addEventListeners({onStart:t,onStartOptions:n=$e,onMove:o,onEnd:r}){this.addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}),this.addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r})}addTouchEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("touchstart",i=>{if(n.eventPhase===I.All){t(i);return}ke(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),r&&this.currentTarget.addEventListener("touchend",r)}addMouseEventListeners({onStart:t,onStartOptions:n,onMove:o,onEnd:r}){t&&this.currentTarget.addEventListener("mousedown",i=>{if(n.eventPhase===I.All){t(i);return}ke(i.eventPhase)===n.eventPhase&&t(i)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),r&&this.currentTarget.addEventListener("mouseup",i=>{r(i)})}removeEventListeners({onStart:t,onMove:n,onEnd:o}){t&&this.currentTarget.removeEventListener("touchstart",t),o&&this.currentTarget.removeEventListener("touchend",o),n&&this.currentTarget.removeEventListener("touchmove",n),t&&this.currentTarget.removeEventListener("mousedown",t),n&&this.currentTarget.removeEventListener("mousemove",n),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(t){if(t.type==="touchstart"||t.type==="mousedown"){if("touches"in t)return{x:t.touches[0].clientX,y:t.touches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}if(t.type==="touchend"||t.type==="mouseup"||t.type==="mousemove"||t.type==="touchmove"){if("touches"in t)return{x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(t instanceof MouseEvent)return{x:t.clientX,y:t.clientY}}return{x:0,y:0}}}function Te(e){const t=e;return`${t} ${t} 0px 0px`}function _e(e,t){const n=Xe(e);qe(n),n.bottomSheetContainer.style.width=e.width;const o=document.createElement("div");o.innerHTML=e.content??"";const r=window.innerHeight;n.bottomSheetContainer.style.maxHeight=`${r}px`,n.bottomSheetContentWrapper.appendChild(o);const i=ze({bottomSheetElements:n,bottomSheetProps:e,options:t});return e.rootStyle&&Object.assign(n.bottomSheetRoot.style,e.rootStyle),e.backdropStyle&&Object.assign(n.bottomSheetBackdrop.style,e.backdropStyle),e.containerGapFillerStyle&&Object.assign(n.bottomSheetContainer.style,e.containerStyle),e.containerStyle&&Object.assign(n.bottomSheetContainerGapFiller.style,e.containerGapFillerStyle),e.handleStyle&&Object.assign(n.bottomSheetHandleBar.style,e.handleStyle),e.contentWrapperStyle&&Object.assign(n.bottomSheetContentWrapper.style,e.contentWrapperStyle),{elements:n,eventHandlers:i}}function Xe(e){const t=P("dialog",F([T.Root,ae.Dialog,e.rootClass]),T.Root);t.ariaLabel=e.ariaLabel;const n=P("section",F([T.Container,e.containerClass]),T.Container);e.containerBorderRadius&&(n.style.borderRadius=Te(e.containerBorderRadius));const o=P("div",T.GapFiller,T.GapFiller);e.containerBackgroundColor&&(n.style.backgroundColor=e.containerBackgroundColor,o.style.backgroundColor=e.containerBackgroundColor);const r=P("button",F([T.Handle,ae.Button,e.shouldShowHandle?null:ee.Hidden,e.handleClass]),T.Handle);r.setAttribute("type","button"),r.ariaLabel="bottom sheet close button";const i=P("span",F([T.HandleBar,e.shouldShowHandle?null:ee.Hidden]),T.HandleBar),a=P("article",F([T.ContentWrapper,e.contentWrapperClass]),T.ContentWrapper),l=P("div",F([T.Backdrop,e.backdropClass,ee.Hidden]),T.Backdrop);return e.backdropColor&&(l.style.backgroundColor=e.backdropColor),e.backDropTransition&&(l.style.transition=e.backDropTransition),{bottomSheetRoot:t,bottomSheetBackdrop:l,bottomSheetContainer:n,bottomSheetHandle:r,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:o}}function qe({bottomSheetRoot:e,bottomSheetContainer:t,bottomSheetHandle:n,bottomSheetHandleBar:o,bottomSheetContentWrapper:r,bottomSheetContainerGapFiller:i}){e.appendChild(t),n.appendChild(o),t.appendChild(n),t.appendChild(r),t.appendChild(i)}function ze({bottomSheetElements:e,bottomSheetProps:t,options:n}){const{bottomSheetRoot:o,bottomSheetContainer:r,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:l,bottomSheetBackdrop:u}=e,{animationFrame:h}=n,s=new z(i),f=new z(l),C=new z(a);let c=[];const E=new z(window),v=je(E,r,t,n.draggingState),y=Ne(E,r,t,n.draggingState,h),w=Ue(E,r,t,n.draggingState,h,n.onClose,n.bottomSheetState);function B(H){H.target instanceof Element&&!o.contains(H.target)&&n.onClose()}function k(H){We(n.draggingState,H.target,e.bottomSheetContentWrapper)}function N(H){const x=H??t;x.draggable&&x.backgroundDraggable&&(f.addEventListeners({onStart:k,onStartOptions:{eventPhase:I.Target}}),C.addEventListeners({onStart:k})),x.draggable&&E.addEventListeners({onStart:v,onMove:y,onEnd:w}),x.draggable&&window.document.addEventListener("keyup",b=>{b.key==="Escape"&&n.onClose()}),i.addEventListener("keyup",b=>{if(b.key==="ArrowUp"){n.moveUp();return}if(b.key==="ArrowDown"){n.moveDown();return}if(b.shiftKey&&b.key==="Tab"){const d=G(e.bottomSheetContentWrapper);Pe(d)}})}function V(H){const x=H??t;t.shouldCloseOnOutsideClick&&!t.preventClosing?u.addEventListener("click",B):u.style.pointerEvents="none",x.draggable&&(s.addEventListeners({onStart:k}),c.forEach(b=>{b.removeEventListeners({onStart:k})}),c=t.dragTriggers.reduce((b,d)=>{const p=o.querySelectorAll(d);if(!p.length)return b;const g=Array.from(p).map(m=>m instanceof HTMLElement?new z(m):null).filter(m=>!!m);return[...b,...g]},[]),c.forEach(b=>{b.addEventListeners({onStart:k,onStartOptions:{eventPhase:I.Target}})}))}function K(){u.removeEventListener("click",B)}function G(H){let x=[...Array.from(H.childNodes).reverse()];for(;x.length;){const b=x.shift();if(Fe(b))return b;b&&(x=[...x,...Array.from(b.childNodes).reverse()])}return null}function U(){s.removeEventListeners({onStart:k}),f.removeEventListeners({onStart:k}),C.removeEventListeners({onStart:k}),c.forEach(H=>{H.removeEventListeners({onStart:k})}),E.removeEventListeners({onStart:v,onMove:y,onEnd:w})}return{attachEventListeners:N,clearEventListeners:U,attacheOnOpenEventListeners:V,clearOnOpenEventListeners:K}}class Ve{constructor(){J(this,"animationId"),J(this,"isInProgress"),J(this,"startedAt"),this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(t,n,o=!1){this.isInProgress=!0;const r=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,l=n===0?1:te(a/n,2),u=l>=1&&!o;t(l),u?this.stop():this.animationId=requestAnimationFrame(r)};this.animationId=requestAnimationFrame(r)}stop(){this.isInProgress=!1,this.startedAt=null,A(this.animationId)&&cancelAnimationFrame(this.animationId)}}function Ke(e){const{startY:t,endY:n,bottomSheetContainer:o,animationFrame:r,onEnd:i,animationTimingFunction:a,animationDuration:l}=e,u=be(t,n);r.stop();let h=!1;r.start(s=>{ne(o,{y:t+u*a(s)}),!h&&s>=1&&(i==null||i(),h=!0)},l)}const ce=(e,t)=>n=>{Ke({...n,animationTimingFunction:e,animationDuration:t})},R={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Je(e){return!(!A(e)||e>1||e<0)}function Qe(e,t){const n={set(o,r,i,a){return t(r,i),Reflect.set(o,r,i,a)}};return new Proxy(e,n)}function Ze(...e){console.error(e)}const W={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function et(e){for(const t of Object.values(W))if(t===e)return!0;return!1}function He(e){return!!(e instanceof Object&&"p1x"in e&&"p1y"in e&&"p2x"in e&&"p2y"in e&&A(e.p1x)&&A(e.p1y)&&A(e.p2x)&&A(e.p2y))}function j(e,t,n,o){return function(l){return a(r(l))};function r(l){let u=0,h=1,s=l,f;if(l===0||l===1)return l;for(;u<h;){if(f=i(s),Math.abs(f-l)<.001)return s;l>f?u=s:h=s,s=(h+u)/2}return s}function i(l){return 3*e*l*Math.pow(1-l,2)+3*n*Math.pow(l,2)*(1-l)+Math.pow(l,3)}function a(l){return 3*t*l*Math.pow(1-l,2)+3*o*Math.pow(l,2)*(1-l)+Math.pow(l,3)}}const Oe=j(.25,.1,.25,1),tt=j(.42,0,1,1),Le=j(.42,0,.58,1),nt=j(.4,.1,.6,1),ot=j(.45,1.5,.55,1);function rt(e){switch(e){case W.EASE:return Oe;case W.EASE_IN:return tt;case W.EASE_OUT:return Le;case W.EASE_IN_OUT:return nt;case W.SPRING:return ot;default:return Oe}}function xe(e){return typeof e=="boolean"}const at={ariaLabel:"Bottom sheet",content:"",defaultPosition:R.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBackgroundColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{},containerGapFillerStyle:{}};function it(e){const t={...at},n=Object.entries(e).reduce((o,r)=>{const[i,a]=r;return se(a)&&(o[i]=a),o},{});return{...t,...n}}function le(e){if(He(e)){const{p1x:t,p1y:n,p2x:o,p2y:r}=e;return j(t,n,o,r)}return et(e)?rt(e):Le}function st(e,t,n,o){function r(i,a){switch(i){case"content":L(a)&&(e.bottomSheetContentWrapper.innerHTML=a);break;case"width":L(a)&&(e.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":xe(a)||Z(e.bottomSheetHandle,!1);break;case"shouldShowBackdrop":xe(a)||Z(e.bottomSheetBackdrop,!1);break;case"containerBorderRadius":L(a)&&(e.bottomSheetContainer.style.borderRadius=Te(a));break;case"containerBackgroundColor":L(a)&&(e.bottomSheetContainer.style.backgroundColor=a,e.bottomSheetContainerGapFiller.style.backgroundColor=a);break;case"backdropColor":L(a)&&(e.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":L(a)&&(e.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!L(a))return;X(e.bottomSheetRoot,n.rootClass,a);break;case"containerClass":if(!L(a))return;X(e.bottomSheetContainer,n.containerClass,a);break;case"handleClass":if(!L(a))return;X(e.bottomSheetHandle,n.handleClass,a);break;case"contentWrapperClass":if(!L(a))return;X(e.bottomSheetContentWrapper,n.contentWrapperClass,a);break;case"backdropClass":if(!L(a))return;X(e.bottomSheetBackdrop,n.backdropClass,a);break;case"expandable":o.clearEventListeners(),o.attachEventListeners(n);break;case"preventClosing":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggable":o.clearEventListeners(),o.attachEventListeners(n);break;case"dragTriggers":o.clearEventListeners(),o.attachEventListeners(n);break;case"draggingAnimationTimings":if(He(a)){const l=le(a),u=ce(l,n.draggingAnimationDuration);t.translateContainer=u}break;case"draggingAnimationDuration":if(A(a)){const l=le(n.draggingAnimationTimings),u=ce(l,a);t.translateContainer=u}break;case"rootStyle":n.rootStyle&&Object.assign(e.bottomSheetRoot.style,n.rootStyle);break;case"backdropStyle":n.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,n.backdropStyle);break;case"containerStyle":n.containerStyle&&Object.assign(e.bottomSheetContainer.style,n.containerStyle);break;case"containerGapFillerStyle":n.containerGapFillerStyle&&Object.assign(e.bottomSheetContainerGapFiller.style,n.containerGapFillerStyle);break;case"handleStyle":n.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,n.handleStyle);break;case"contentWrapperStyle":n.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,n.contentWrapperStyle);break}}return r}function ct(e){const t=it(e),n=le(e.draggingAnimationTimings),o={isMounted:!1,translateContainer:ce(n,t.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function i(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const a=new Ve,l={animationFrame:a,onClose:w,bottomSheetState:o,draggingState:r,snapTo:b,moveUp:H,moveDown:x},{elements:u,eventHandlers:h}=_e(t,l),s=Qe(t,st(u,o,t,h)),{bottomSheetBackdrop:f,bottomSheetRoot:C,bottomSheetContainer:c}=u,E=d=>{const p=d??window.document.body;p.appendChild(C),p.appendChild(f);const g=window.innerHeight;ne(c,{y:g}),h.attachEventListeners(),o.isMounted=!0},v=()=>{h.clearEventListeners(),Object.values(u).forEach(d=>{d.remove()}),i(),o.isMounted=!1},y=()=>{var d;if(B()||Ze('Bottom Sheet is not mounted yet. call the "mount" method first.'),(d=e.beforeOpen)==null||d.call(e),k())return;re(f,!0),s.shouldShowBackdrop||_(f,"transparent"),re([c],!0),ne(c,{y:c.clientHeight});const p=window.innerHeight,g=me(p,c.clientHeight,s.marginTop,s.defaultPosition),m=Y(c).y;o.translateContainer({startY:m,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:e.afterOpen});const O=document.body.style.overflowY;r.originalDocumentOverflowY=O||"initial";const D=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=D||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",u.bottomSheetHandle.focus(),h.attacheOnOpenEventListeners()};function w(){var d;if(N())return;(d=e.beforeClose)==null||d.call(e);const p=Y(c).y,g=c.clientHeight;o.translateContainer({startY:p,endY:g,animationFrame:a,bottomSheetContainer:c,onEnd:()=>{var m;(m=e.afterClose)==null||m.call(e),re([f,c],!1),h.clearOnOpenEventListeners()}}),i()}function B(){return o.isMounted}function k(){const d=Y(c).y,p=window.innerHeight,g=c.clientHeight>=p?p:c.clientHeight;return d<=g}function N(){return!k()}function V(){const d=Y(c).y,p=c.clientHeight,g=window.innerHeight;if(d<=5&&d>=-5)return R.CONTENT_HEIGHT;const m=p-d;if(m===g/2)return R.MIDDLE;const O=g-s.marginTop,D=10;return m<=O+D&&m>=O-D?R.TOP:R.CLOSED}function K(){return c.clientHeight}function G(d){if(!k())return;const p=Y(c).y,g=c.clientHeight-p,m=window.innerHeight-d,O=Ie(g,m),D=q(g,m);o.translateContainer({startY:p,endY:p+(O.isUp?-D:D),animationFrame:a,bottomSheetContainer:c})}function U(d,{viewportHeight:p,visibleHeight:g}){let m=null;for(const O of d){const D=O*p,$=q(g,D);(m===null||$<m)&&(m=$)}return{minOffset:m}}function H(){const d=[...s.snapPoints].reverse(),p=Y(c).y,g=c.clientHeight,m=g-p;if(!s.expandable&&m>=g)return;const O=window.innerHeight,D=ge("above",{visibleHeight:m,viewportHeight:O},d),{minOffset:$}=U(D,{visibleHeight:m,viewportHeight:O});if($===null&&m<O-s.marginTop){o.translateContainer({startY:p,endY:me(O,g,s.marginTop,"top"),animationFrame:a,bottomSheetContainer:c});return}A($)&&o.translateContainer({startY:p,endY:p-$,animationFrame:a,bottomSheetContainer:c})}function x(){const d=Y(c).y,p=c.clientHeight-d;if(p<1)return;const g=window.innerHeight,m=ge("below",{visibleHeight:p,viewportHeight:g},s.snapPoints),{minOffset:O}=U(m,{visibleHeight:p,viewportHeight:g});A(O)&&o.translateContainer({startY:d,endY:d+O,animationFrame:a,bottomSheetContainer:c})}function b(d){const p=window.innerHeight;if(!Je(d))return;const g=te(p*d,2);G(g)}return{props:s,elements:u,mount:E,unmount:v,open:y,close:w,getIsMounted:B,getIsOpen:k,getIsClosed:N,getPosition:V,getHeight:K,moveTo:G,snapTo:b}}function ue(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>R.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}const lt=ue(),ut=S.forwardRef(function(t,n){const{children:o,isOpen:r,setIsOpen:i,afterClose:a,mountingPointRef:l,...u}=t,h=S.useRef(lt),[s,f]=S.useState(h.current);S.useImperativeHandle(n,()=>s,[s]);const C=S.useCallback(()=>{i(!1),a==null||a()},[a]);S.useEffect(()=>{r?s.open():s.close()},[r]);const c=S.useRef(null);return S.useEffect(function(){var w;if(l&&!l.current)return;const v=Ae((w=t.mountingPointRef)==null?void 0:w.current)?t.mountingPointRef.current:window.document.body;if(!v||s.getIsMounted())return;const y=ct({content:"",...u,afterClose:C});return y.mount(v),c.current=y.elements.bottomSheetContentWrapper??null,h.current=y,f(y),()=>{s.unmount()}},[t.mountingPointRef,u,C]),S.useEffect(function(){Object.assign(h.current.props,{...u}),f(h.current)},[u]),S.useEffect(function(){return()=>{h.current.unmount()}},[]),c.current?Be.createPortal(t.children,c.current):null}),dt=ue();function pt(e={}){const t=S.useRef(dt),[n,o]=S.useState(!1),r=!n,[i,a]=S.useState(t.current);S.useEffect(()=>{a(t.current)},[t.current]);const{beforeOpen:l,afterOpen:u,beforeClose:h,afterClose:s,onDragStart:f,onDragMove:C,onDragEnd:c,...E}=e,v=()=>{l==null||l()},y=()=>{u==null||u(),o(!0)},w=()=>{h==null||h()},B=()=>{s==null||s(),o(!1)},k=()=>{f==null||f()},N=(b,d)=>{C==null||C(b,d)},V=()=>{c==null||c()},K=S.useMemo(()=>({ref:t,isOpen:n,setIsOpen:o,beforeOpen:v,afterOpen:y,beforeClose:w,afterClose:B,onDragStart:k,onDragMove:N,onDragEnd:V,...E}),[t.current,n,o,e]),G=S.useCallback(()=>{o(!0)},[o]),U=S.useCallback(()=>{o(!1)},[o]),H=S.useCallback((...b)=>{i.moveTo(...b)},[i]),x=S.useCallback((...b)=>{i.snapTo(...b)},[i]);return{props:K,instance:i,isOpen:n,isClosed:r,setIsOpen:o,open:G,close:U,moveTo:H,snapTo:x}}M.BottomSheet=ut,M.createPlaceholderBottomSheet=ue,M.useBottomSheet=pt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plainsheet/react",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@plainsheet/core": "0.7.11",
34
+ "@plainsheet/core": "0.7.12",
35
35
  "@plainsheet/utility": "0.0.3"
36
36
  },
37
37
  "devDependencies": {
@@ -49,7 +49,7 @@
49
49
  "typescript-eslint": "^8.0.0",
50
50
  "vite": "^5.4.0",
51
51
  "vite-plugin-dts": "^3.8.1",
52
- "vitest": "^1.6.0"
52
+ "vitest": "^1.6.1"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "react": ">=17.0.0 <20.0.0",