@sps-woodland/modal 8.7.4 → 8.7.6

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/lib/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@sps-woodland/core"),he=require("@sps-woodland/buttons"),m=require("react"),tt=require("react-dom"),v=require("@spscommerce/utils"),Fe=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function ot(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const w=Fe(m),u=ot(m),rt=Fe(tt);function nt(e,t,o){let[r,n]=m.useState(e||t),l=m.useRef(e!==void 0),a=e!==void 0;m.useEffect(()=>{let d=l.current;d!==a&&console.warn(`WARN: A component changed from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}.`),l.current=a},[a]);let s=a?e:r,c=m.useCallback((d,...i)=>{let p=(f,...b)=>{o&&(Object.is(s,f)||o(f,...b)),a||(s=f)};typeof d=="function"?(console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),n((b,...g)=>{let T=d(a?s:b,...g);return p(T,...i),a?b:T})):(a||n(d),p(d,...i))},[a,s,o]);return[s,c]}const V={prefix:String(Math.round(Math.random()*1e10)),current:0},Le=w.default.createContext(V),at=w.default.createContext(!1);let lt=Boolean(typeof window<"u"&&window.document&&window.document.createElement),oe=new WeakMap;function it(e=!1){let t=m.useContext(Le),o=m.useRef(null);if(o.current===null&&!e){var r,n;let l=(n=w.default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)===null||n===void 0||(r=n.ReactCurrentOwner)===null||r===void 0?void 0:r.current;if(l){let a=oe.get(l);a==null?oe.set(l,{id:t.current,state:l.memoizedState}):l.memoizedState!==a.state&&(t.current=a.id,oe.delete(l))}o.current=++t.current}return o.current}function st(e){let t=m.useContext(Le);t===V&&!lt&&console.warn("When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.");let o=it(!!e),r=t===V&&process.env.NODE_ENV==="test"?"react-aria":`react-aria${t.prefix}`;return e||`${r}-${o}`}function dt(e){let t=w.default.useId(),[o]=m.useState(Ce()),r=o||process.env.NODE_ENV==="test"?"react-aria":`react-aria${V.prefix}`;return e||`${r}-${t}`}const ut=typeof w.default.useId=="function"?dt:st;function ct(){return!1}function mt(){return!0}function ft(e){return()=>{}}function Ce(){return typeof w.default.useSyncExternalStore=="function"?w.default.useSyncExternalStore(ft,ct,mt):m.useContext(at)}function Be(e){var t,o,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(o=Be(e[t]))&&(r&&(r+=" "),r+=o)}else for(o in e)e[o]&&(r&&(r+=" "),r+=o);return r}function pt(){for(var e,t,o=0,r="",n=arguments.length;o<n;o++)(e=arguments[o])&&(t=Be(e))&&(r&&(r+=" "),r+=t);return r}const E=typeof document<"u"?w.default.useLayoutEffect:()=>{};function I(e){const t=m.useRef(null);return E(()=>{t.current=e},[e]),m.useCallback((...o)=>{const r=t.current;return r==null?void 0:r(...o)},[])}function gt(e){let[t,o]=m.useState(e),r=m.useRef(null),n=I(()=>{if(!r.current)return;let a=r.current.next();if(a.done){r.current=null;return}t===a.value?n():o(a.value)});E(()=>{r.current&&n()});let l=I(a=>{r.current=a(t),n()});return[t,l]}let bt=Boolean(typeof window<"u"&&window.document&&window.document.createElement),j=new Map;function Ne(e){let[t,o]=m.useState(e),r=m.useRef(null),n=ut(t),l=m.useCallback(a=>{r.current=a},[]);return bt&&j.set(n,l),E(()=>{let a=n;return()=>{j.delete(a)}},[n]),m.useEffect(()=>{let a=r.current;a&&(r.current=null,o(a))}),n}function vt(e,t){if(e===t)return e;let o=j.get(e);if(o)return o(t),t;let r=j.get(t);return r?(r(e),e):t}function $t(e=[]){let t=Ne(),[o,r]=gt(t),n=m.useCallback(()=>{r(function*(){yield t,yield document.getElementById(t)?t:void 0})},[t,r]);return E(n,[t,n,...e]),o}function K(...e){return(...t)=>{for(let o of e)typeof o=="function"&&o(...t)}}const M=e=>{var t;return(t=e==null?void 0:e.ownerDocument)!==null&&t!==void 0?t:document},U=e=>e&&"window"in e&&e.window===e?e:M(e).defaultView||window;function ht(...e){let t={...e[0]};for(let o=1;o<e.length;o++){let r=e[o];for(let n in r){let l=t[n],a=r[n];typeof l=="function"&&typeof a=="function"&&n[0]==="o"&&n[1]==="n"&&n.charCodeAt(2)>=65&&n.charCodeAt(2)<=90?t[n]=K(l,a):(n==="className"||n==="UNSAFE_className")&&typeof l=="string"&&typeof a=="string"?t[n]=pt(l,a):n==="id"&&l&&a?t.id=vt(l,a):t[n]=a!==void 0?a:l}}return t}const wt=new Set(["id"]),Et=new Set(["aria-label","aria-labelledby","aria-describedby","aria-details"]),Mt=new Set(["href","target","rel","download","ping","referrerPolicy"]),yt=/^(data-.*)$/;function Pt(e,t={}){let{labelable:o,isLink:r,propNames:n}=t,l={};for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(wt.has(a)||o&&Et.has(a)||r&&Mt.has(a)||(n==null?void 0:n.has(a))||yt.test(a))&&(l[a]=e[a]);return l}function we(e){if(kt())e.focus({preventScroll:!0});else{let t=xt(e);e.focus(),Tt(t)}}let q=null;function kt(){if(q==null){q=!1;try{document.createElement("div").focus({get preventScroll(){return q=!0,!0}})}catch{}}return q}function xt(e){let t=e.parentNode,o=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&o.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&o.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),o}function Tt(e){for(let{element:t,scrollTop:o,scrollLeft:r}of e)t.scrollTop=o,t.scrollLeft=r}function St(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(o=>e.test(o.brand)))||e.test(window.navigator.userAgent)}function ue(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function Oe(){return ue(/^Mac/i)}function Ft(){return ue(/^iPhone/i)}function Lt(){return ue(/^iPad/i)||Oe()&&navigator.maxTouchPoints>1}function Ct(){return Ft()||Lt()}function Bt(){return St(/Android/i)}let N=new Map,ae=new Set;function Ee(){if(typeof window>"u")return;function e(r){return"propertyName"in r}let t=r=>{if(!e(r)||!r.target)return;let n=N.get(r.target);n||(n=new Set,N.set(r.target,n),r.target.addEventListener("transitioncancel",o,{once:!0})),n.add(r.propertyName)},o=r=>{if(!e(r)||!r.target)return;let n=N.get(r.target);if(!!n&&(n.delete(r.propertyName),n.size===0&&(r.target.removeEventListener("transitioncancel",o),N.delete(r.target)),N.size===0)){for(let l of ae)l();ae.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",o)}typeof document<"u"&&(document.readyState!=="loading"?Ee():document.addEventListener("DOMContentLoaded",Ee));function Nt(e){requestAnimationFrame(()=>{N.size===0?e():ae.add(e)})}function De(e,t){let o=e;for(Me(o,t)&&(o=o.parentElement);o&&!Me(o,t);)o=o.parentElement;return o||document.scrollingElement||document.documentElement}function Me(e,t){let o=window.getComputedStyle(e),r=/(auto|scroll)/.test(o.overflow+o.overflowX+o.overflowY);return r&&t&&(r=e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth),r}function Ot(e){return e.mozInputSource===0&&e.isTrusted?!0:Bt()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}const Re=w.default.createContext({register:()=>{}});Re.displayName="PressResponderContext";function Dt({children:e}){let t=m.useMemo(()=>({register:()=>{}}),[]);return w.default.createElement(Re.Provider,{value:t},e)}class Rt{isDefaultPrevented(){return this.nativeEvent.defaultPrevented}preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPropagationStopped=()=>!0}isPropagationStopped(){return!1}persist(){}constructor(t,o){this.nativeEvent=o,this.target=o.target,this.currentTarget=o.currentTarget,this.relatedTarget=o.relatedTarget,this.bubbles=o.bubbles,this.cancelable=o.cancelable,this.defaultPrevented=o.defaultPrevented,this.eventPhase=o.eventPhase,this.isTrusted=o.isTrusted,this.timeStamp=o.timeStamp,this.type=t}}function Wt(e){let t=m.useRef({isFocused:!1,observer:null});E(()=>{const r=t.current;return()=>{r.observer&&(r.observer.disconnect(),r.observer=null)}},[]);let o=I(r=>{e==null||e(r)});return m.useCallback(r=>{if(r.target instanceof HTMLButtonElement||r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||r.target instanceof HTMLSelectElement){t.current.isFocused=!0;let n=r.target,l=a=>{t.current.isFocused=!1,n.disabled&&o(new Rt("blur",a)),t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};n.addEventListener("focusout",l,{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&n.disabled){var a;(a=t.current.observer)===null||a===void 0||a.disconnect();let s=n===document.activeElement?null:document.activeElement;n.dispatchEvent(new FocusEvent("blur",{relatedTarget:s})),n.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:s}))}}),t.current.observer.observe(n,{attributes:!0,attributeFilter:["disabled"]})}},[o])}let z=null,At=new Set,A=new Map,B=!1,le=!1;function ce(e,t){for(let o of At)o(e,t)}function It(e){return!(e.metaKey||!Oe()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function G(e){B=!0,It(e)&&(z="keyboard",ce("keyboard",e))}function x(e){z="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(B=!0,ce("pointer",e))}function We(e){Ot(e)&&(B=!0,z="virtual")}function Ae(e){e.target===window||e.target===document||(!B&&!le&&(z="virtual",ce("virtual",e)),B=!1,le=!1)}function Ie(){B=!1,le=!0}function ye(e){if(typeof window>"u"||A.get(U(e)))return;const t=U(e),o=M(e);let r=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){B=!0,r.apply(this,arguments)},o.addEventListener("keydown",G,!0),o.addEventListener("keyup",G,!0),o.addEventListener("click",We,!0),t.addEventListener("focus",Ae,!0),t.addEventListener("blur",Ie,!1),typeof PointerEvent<"u"?(o.addEventListener("pointerdown",x,!0),o.addEventListener("pointermove",x,!0),o.addEventListener("pointerup",x,!0)):(o.addEventListener("mousedown",x,!0),o.addEventListener("mousemove",x,!0),o.addEventListener("mouseup",x,!0)),t.addEventListener("beforeunload",()=>{ze(e)},{once:!0}),A.set(t,{focus:r})}const ze=(e,t)=>{const o=U(e),r=M(e);t&&r.removeEventListener("DOMContentLoaded",t),A.has(o)&&(o.HTMLElement.prototype.focus=A.get(o).focus,r.removeEventListener("keydown",G,!0),r.removeEventListener("keyup",G,!0),r.removeEventListener("click",We,!0),o.removeEventListener("focus",Ae,!0),o.removeEventListener("blur",Ie,!1),typeof PointerEvent<"u"?(r.removeEventListener("pointerdown",x,!0),r.removeEventListener("pointermove",x,!0),r.removeEventListener("pointerup",x,!0)):(r.removeEventListener("mousedown",x,!0),r.removeEventListener("mousemove",x,!0),r.removeEventListener("mouseup",x,!0)),A.delete(o))};function zt(e){const t=M(e);let o;return t.readyState!=="loading"?ye(e):(o=()=>{ye(e)},t.addEventListener("DOMContentLoaded",o)),()=>ze(e,o)}typeof document<"u"&&zt();function qt(){return z}function _t(e){let{isDisabled:t,onBlurWithin:o,onFocusWithin:r,onFocusWithinChange:n}=e,l=m.useRef({isFocusWithin:!1}),a=m.useCallback(d=>{l.current.isFocusWithin&&!d.currentTarget.contains(d.relatedTarget)&&(l.current.isFocusWithin=!1,o&&o(d),n&&n(!1))},[o,n,l]),s=Wt(a),c=m.useCallback(d=>{!l.current.isFocusWithin&&document.activeElement===d.target&&(r&&r(d),n&&n(!0),l.current.isFocusWithin=!0,s(d))},[r,n,s]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:c,onBlur:a}}}function Ht(e){let{ref:t,onInteractOutside:o,isDisabled:r,onInteractOutsideStart:n}=e,l=m.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}),a=I(c=>{o&&_(c,t)&&(n&&n(c),l.current.isPointerDown=!0)}),s=I(c=>{o&&o(c)});m.useEffect(()=>{let c=l.current;if(r)return;const d=t.current,i=M(d);if(typeof PointerEvent<"u"){let p=f=>{c.isPointerDown&&_(f,t)&&s(f),c.isPointerDown=!1};return i.addEventListener("pointerdown",a,!0),i.addEventListener("pointerup",p,!0),()=>{i.removeEventListener("pointerdown",a,!0),i.removeEventListener("pointerup",p,!0)}}else{let p=b=>{c.ignoreEmulatedMouseEvents?c.ignoreEmulatedMouseEvents=!1:c.isPointerDown&&_(b,t)&&s(b),c.isPointerDown=!1},f=b=>{c.ignoreEmulatedMouseEvents=!0,c.isPointerDown&&_(b,t)&&s(b),c.isPointerDown=!1};return i.addEventListener("mousedown",a,!0),i.addEventListener("mouseup",p,!0),i.addEventListener("touchstart",a,!0),i.addEventListener("touchend",f,!0),()=>{i.removeEventListener("mousedown",a,!0),i.removeEventListener("mouseup",p,!0),i.removeEventListener("touchstart",a,!0),i.removeEventListener("touchend",f,!0)}}},[t,r,a,s])}function _(e,t){if(e.button>0)return!1;if(e.target){const o=e.target.ownerDocument;if(!o||!o.documentElement.contains(e.target)||e.target.closest("[data-react-aria-top-layer]"))return!1}return t.current&&!t.current.contains(e.target)}function ie(e){const t=M(e);if(qt()==="virtual"){let o=t.activeElement;Nt(()=>{t.activeElement===o&&e.isConnected&&we(e)})}else we(e)}function Vt(e){const t=U(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:o,visibility:r}=e.style,n=o!=="none"&&r!=="hidden"&&r!=="collapse";if(n){const{getComputedStyle:l}=e.ownerDocument.defaultView;let{display:a,visibility:s}=l(e);n=a!=="none"&&s!=="hidden"&&s!=="collapse"}return n}function jt(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function qe(e,t){return e.nodeName!=="#comment"&&Vt(e)&&jt(e,t)&&(!e.parentElement||qe(e.parentElement,e))}const Pe=w.default.createContext(null);let $=null;function Kt(e){let{children:t,contain:o,restoreFocus:r,autoFocus:n}=e,l=m.useRef(null),a=m.useRef(null),s=m.useRef([]),{parentNode:c}=m.useContext(Pe)||{},d=m.useMemo(()=>new se({scopeRef:s}),[s]);E(()=>{let f=c||h.root;if(h.getTreeNode(f.scopeRef)&&$&&!J($,f.scopeRef)){let b=h.getTreeNode($);b&&(f=b)}f.addChild(d),h.addNode(d)},[d,c]),E(()=>{let f=h.getTreeNode(s);f&&(f.contain=!!o)},[o]),E(()=>{var f;let b=(f=l.current)===null||f===void 0?void 0:f.nextSibling,g=[];for(;b&&b!==a.current;)g.push(b),b=b.nextSibling;s.current=g},[t]),Zt(s,r,o),Jt(s,o),to(s,r,o),Qt(s,n),m.useEffect(()=>{const f=M(s.current?s.current[0]:void 0).activeElement;let b=null;if(y(f,s.current)){for(let g of h.traverse())g.scopeRef&&y(f,g.scopeRef.current)&&(b=g);b===h.getTreeNode(s)&&($=b.scopeRef)}},[s]),E(()=>()=>{var f,b,g;let T=(g=(b=h.getTreeNode(s))===null||b===void 0||(f=b.parent)===null||f===void 0?void 0:f.scopeRef)!==null&&g!==void 0?g:null;(s===$||J(s,$))&&(!T||h.getTreeNode(T))&&($=T),h.removeTreeNode(s)},[s]);let i=m.useMemo(()=>Ut(s),[]),p=m.useMemo(()=>({focusManager:i,parentNode:d}),[d,i]);return w.default.createElement(Pe.Provider,{value:p},w.default.createElement("span",{"data-focus-scope-start":!0,hidden:!0,ref:l}),t,w.default.createElement("span",{"data-focus-scope-end":!0,hidden:!0,ref:a}))}function Ut(e){return{focusNext(t={}){let o=e.current,{from:r,tabbable:n,wrap:l,accept:a}=t,s=r||M(o[0]).activeElement,c=o[0].previousElementSibling,d=C(o),i=L(d,{tabbable:n,accept:a},o);i.currentNode=y(s,o)?s:c;let p=i.nextNode();return!p&&l&&(i.currentNode=c,p=i.nextNode()),p&&F(p,!0),p},focusPrevious(t={}){let o=e.current,{from:r,tabbable:n,wrap:l,accept:a}=t,s=r||M(o[0]).activeElement,c=o[o.length-1].nextElementSibling,d=C(o),i=L(d,{tabbable:n,accept:a},o);i.currentNode=y(s,o)?s:c;let p=i.previousNode();return!p&&l&&(i.currentNode=c,p=i.previousNode()),p&&F(p,!0),p},focusFirst(t={}){let o=e.current,{tabbable:r,accept:n}=t,l=C(o),a=L(l,{tabbable:r,accept:n},o);a.currentNode=o[0].previousElementSibling;let s=a.nextNode();return s&&F(s,!0),s},focusLast(t={}){let o=e.current,{tabbable:r,accept:n}=t,l=C(o),a=L(l,{tabbable:r,accept:n},o);a.currentNode=o[o.length-1].nextElementSibling;let s=a.previousNode();return s&&F(s,!0),s}}}const me=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]"],Gt=me.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";me.push('[tabindex]:not([tabindex="-1"]):not([disabled])');const Xt=me.join(':not([hidden]):not([tabindex="-1"]),');function C(e){return e[0].parentElement}function W(e){let t=h.getTreeNode($);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function Jt(e,t){let o=m.useRef(),r=m.useRef();E(()=>{let n=e.current;if(!t){r.current&&(cancelAnimationFrame(r.current),r.current=void 0);return}const l=M(n?n[0]:void 0);let a=d=>{if(d.key!=="Tab"||d.altKey||d.ctrlKey||d.metaKey||!W(e))return;let i=l.activeElement,p=e.current;if(!p||!y(i,p))return;let f=C(p),b=L(f,{tabbable:!0},p);if(!i)return;b.currentNode=i;let g=d.shiftKey?b.previousNode():b.nextNode();g||(b.currentNode=d.shiftKey?p[p.length-1].nextElementSibling:p[0].previousElementSibling,g=d.shiftKey?b.previousNode():b.nextNode()),d.preventDefault(),g&&F(g,!0)},s=d=>{(!$||J($,e))&&y(d.target,e.current)?($=e,o.current=d.target):W(e)&&!X(d.target,e)?o.current?o.current.focus():$&&$.current&&Y($.current):W(e)&&(o.current=d.target)},c=d=>{r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{if(l.activeElement&&W(e)&&!X(l.activeElement,e))if($=e,l.body.contains(d.target)){var i;o.current=d.target,(i=o.current)===null||i===void 0||i.focus()}else $.current&&Y($.current)})};return l.addEventListener("keydown",a,!1),l.addEventListener("focusin",s,!1),n==null||n.forEach(d=>d.addEventListener("focusin",s,!1)),n==null||n.forEach(d=>d.addEventListener("focusout",c,!1)),()=>{l.removeEventListener("keydown",a,!1),l.removeEventListener("focusin",s,!1),n==null||n.forEach(d=>d.removeEventListener("focusin",s,!1)),n==null||n.forEach(d=>d.removeEventListener("focusout",c,!1))}},[e,t]),E(()=>()=>{r.current&&cancelAnimationFrame(r.current)},[r])}function _e(e){return X(e)}function y(e,t){return!e||!t?!1:t.some(o=>o.contains(e))}function X(e,t=null){if(e instanceof Element&&e.closest("[data-react-aria-top-layer]"))return!0;for(let{scopeRef:o}of h.traverse(h.getTreeNode(t)))if(o&&y(e,o.current))return!0;return!1}function Yt(e){return X(e,$)}function J(e,t){var o;let r=(o=h.getTreeNode(t))===null||o===void 0?void 0:o.parent;for(;r;){if(r.scopeRef===e)return!0;r=r.parent}return!1}function F(e,t=!1){if(e!=null&&!t)try{ie(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function Y(e,t=!0){let o=e[0].previousElementSibling,r=C(e),n=L(r,{tabbable:t},e);n.currentNode=o;let l=n.nextNode();t&&!l&&(r=C(e),n=L(r,{tabbable:!1},e),n.currentNode=o,l=n.nextNode()),F(l)}function Qt(e,t){const o=w.default.useRef(t);m.useEffect(()=>{if(o.current){$=e;const r=M(e.current?e.current[0]:void 0);!y(r.activeElement,$.current)&&e.current&&Y(e.current)}o.current=!1},[e])}function Zt(e,t,o){E(()=>{if(t||o)return;let r=e.current;const n=M(r?r[0]:void 0);let l=a=>{let s=a.target;y(s,e.current)?$=e:_e(s)||($=null)};return n.addEventListener("focusin",l,!1),r==null||r.forEach(a=>a.addEventListener("focusin",l,!1)),()=>{n.removeEventListener("focusin",l,!1),r==null||r.forEach(a=>a.removeEventListener("focusin",l,!1))}},[e,t,o])}function eo(e){let t=h.getTreeNode($);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return(t==null?void 0:t.scopeRef)===e}function to(e,t,o){const r=m.useRef(typeof document<"u"?M(e.current?e.current[0]:void 0).activeElement:null);E(()=>{let n=e.current;const l=M(n?n[0]:void 0);if(!t||o)return;let a=()=>{(!$||J($,e))&&y(l.activeElement,e.current)&&($=e)};return l.addEventListener("focusin",a,!1),n==null||n.forEach(s=>s.addEventListener("focusin",a,!1)),()=>{l.removeEventListener("focusin",a,!1),n==null||n.forEach(s=>s.removeEventListener("focusin",a,!1))}},[e,o]),E(()=>{const n=M(e.current?e.current[0]:void 0);if(!t)return;let l=a=>{if(a.key!=="Tab"||a.altKey||a.ctrlKey||a.metaKey||!W(e))return;let s=n.activeElement;if(!y(s,e.current))return;let c=h.getTreeNode(e);if(!c)return;let d=c.nodeToRestore,i=L(n.body,{tabbable:!0});i.currentNode=s;let p=a.shiftKey?i.previousNode():i.nextNode();if((!d||!n.body.contains(d)||d===n.body)&&(d=void 0,c.nodeToRestore=void 0),(!p||!y(p,e.current))&&d){i.currentNode=d;do p=a.shiftKey?i.previousNode():i.nextNode();while(y(p,e.current));a.preventDefault(),a.stopPropagation(),p?F(p,!0):_e(d)?F(d,!0):s.blur()}};return o||n.addEventListener("keydown",l,!0),()=>{o||n.removeEventListener("keydown",l,!0)}},[e,t,o]),E(()=>{const n=M(e.current?e.current[0]:void 0);if(!t)return;let l=h.getTreeNode(e);if(!!l){var a;return l.nodeToRestore=(a=r.current)!==null&&a!==void 0?a:void 0,()=>{let s=h.getTreeNode(e);if(!s)return;let c=s.nodeToRestore;if(t&&c&&(y(n.activeElement,e.current)||n.activeElement===n.body&&eo(e))){let d=h.clone();requestAnimationFrame(()=>{if(n.activeElement===n.body){let i=d.getTreeNode(e);for(;i;){if(i.nodeToRestore&&i.nodeToRestore.isConnected){F(i.nodeToRestore);return}i=i.parent}for(i=d.getTreeNode(e);i;){if(i.scopeRef&&i.scopeRef.current&&h.getTreeNode(i.scopeRef)){Y(i.scopeRef.current,!0);return}i=i.parent}}})}}}},[e,t])}function L(e,t,o){let r=t!=null&&t.tabbable?Xt:Gt,n=M(e).createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(l){var a;return!(t==null||(a=t.from)===null||a===void 0)&&a.contains(l)?NodeFilter.FILTER_REJECT:l.matches(r)&&qe(l)&&(!o||y(l,o))&&(!(t!=null&&t.accept)||t.accept(l))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(n.currentNode=t.from),n}class fe{get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,o,r){let n=this.fastMap.get(o!=null?o:null);if(!n)return;let l=new se({scopeRef:t});n.addChild(l),l.parent=n,this.fastMap.set(t,l),r&&(l.nodeToRestore=r)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let o=this.fastMap.get(t);if(!o)return;let r=o.parent;for(let l of this.traverse())l!==o&&o.nodeToRestore&&l.nodeToRestore&&o.scopeRef&&o.scopeRef.current&&y(l.nodeToRestore,o.scopeRef.current)&&(l.nodeToRestore=o.nodeToRestore);let n=o.children;r&&(r.removeChild(o),n.size>0&&n.forEach(l=>r&&r.addChild(l))),this.fastMap.delete(o.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let o of t.children)yield*this.traverse(o)}clone(){var t;let o=new fe;var r;for(let n of this.traverse())o.addTreeNode(n.scopeRef,(r=(t=n.parent)===null||t===void 0?void 0:t.scopeRef)!==null&&r!==void 0?r:null,n.nodeToRestore);return o}constructor(){this.fastMap=new Map,this.root=new se({scopeRef:null}),this.fastMap.set(null,this.root)}}class se{addChild(t){this.children.add(t),t.parent=this}removeChild(t){this.children.delete(t),t.parent=void 0}constructor(t){this.children=new Set,this.contain=!1,this.scopeRef=t.scopeRef}}let h=new fe;const oo=new WeakMap,S=[];function ro(e,t){let{onClose:o,shouldCloseOnBlur:r,isOpen:n,isDismissable:l=!1,isKeyboardDismissDisabled:a=!1,shouldCloseOnInteractOutside:s}=e;m.useEffect(()=>(n&&S.push(t),()=>{let g=S.indexOf(t);g>=0&&S.splice(g,1)}),[n,t]);let c=()=>{S[S.length-1]===t&&o&&o()},d=g=>{(!s||s(g.target))&&S[S.length-1]===t&&(g.stopPropagation(),g.preventDefault())},i=g=>{(!s||s(g.target))&&(S[S.length-1]===t&&(g.stopPropagation(),g.preventDefault()),c())},p=g=>{g.key==="Escape"&&!a&&(g.stopPropagation(),g.preventDefault(),c())};Ht({ref:t,onInteractOutside:l&&n?i:null,onInteractOutsideStart:d});let{focusWithinProps:f}=_t({isDisabled:!r,onBlurWithin:g=>{!g.relatedTarget||Yt(g.relatedTarget)||(!s||s(g.relatedTarget))&&o()}}),b=g=>{g.target===g.currentTarget&&g.preventDefault()};return{overlayProps:{onKeyDown:p,...f},underlayProps:{onPointerDown:b}}}function no(e,t,o){let{type:r}=e,{isOpen:n}=t;m.useEffect(()=>{o&&o.current&&oo.set(o.current,t.close)});let l;r==="menu"?l=!0:r==="listbox"&&(l="listbox");let a=Ne();return{triggerProps:{"aria-haspopup":l,"aria-expanded":n,"aria-controls":n?a:null,onPress:t.toggle},overlayProps:{id:a}}}const re=typeof document<"u"&&window.visualViewport,ao=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let H=0,ne;function lo(e={}){let{isDisabled:t}=e;E(()=>{if(!t)return H++,H===1&&(Ct()?ne=so():ne=io()),()=>{H--,H===0&&ne()}},[t])}function io(){return K(O(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),O(document.documentElement,"overflow","hidden"))}function so(){let e,t,o=d=>{e=De(d.target,!0),!(e===document.documentElement&&e===document.body)&&e instanceof HTMLElement&&window.getComputedStyle(e).overscrollBehavior==="auto"&&(t=O(e,"overscrollBehavior","contain"))},r=d=>{if(!e||e===document.documentElement||e===document.body){d.preventDefault();return}e.scrollHeight===e.clientHeight&&e.scrollWidth===e.clientWidth&&d.preventDefault()},n=d=>{let i=d.target;xe(i)&&i!==document.activeElement&&(d.preventDefault(),s(),i.style.transform="translateY(-2000px)",i.focus(),requestAnimationFrame(()=>{i.style.transform=""})),t&&t()},l=d=>{let i=d.target;xe(i)&&(s(),i.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{i.style.transform="",re&&(re.height<window.innerHeight?requestAnimationFrame(()=>{ke(i)}):re.addEventListener("resize",()=>ke(i),{once:!0}))}))},a=null,s=()=>{if(a)return;let d=()=>{window.scrollTo(0,0)},i=window.pageXOffset,p=window.pageYOffset;a=K(D(window,"scroll",d),O(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),O(document.documentElement,"overflow","hidden"),O(document.body,"marginTop",`-${p}px`),()=>{window.scrollTo(i,p)}),window.scrollTo(0,0)},c=K(D(document,"touchstart",o,{passive:!1,capture:!0}),D(document,"touchmove",r,{passive:!1,capture:!0}),D(document,"touchend",n,{passive:!1,capture:!0}),D(document,"focus",l,!0));return()=>{t==null||t(),a==null||a(),c()}}function O(e,t,o){let r=e.style[t];return e.style[t]=o,()=>{e.style[t]=r}}function D(e,t,o,r){return e.addEventListener(t,o,r),()=>{e.removeEventListener(t,o,r)}}function ke(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let o=De(e);if(o!==document.documentElement&&o!==document.body&&o!==e){let r=o.getBoundingClientRect().top,n=e.getBoundingClientRect().top;n>r+e.clientHeight&&(o.scrollTop+=n-r)}e=o.parentElement}}function xe(e){return e instanceof HTMLInputElement&&!ao.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}let R=new WeakMap,k=[];function uo(e,t=document.body){let o=new Set(e),r=new Set,n=c=>{for(let f of c.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))o.add(f);let d=f=>{if(o.has(f)||r.has(f.parentElement)&&f.parentElement.getAttribute("role")!=="row")return NodeFilter.FILTER_REJECT;for(let b of o)if(f.contains(b))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},i=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,{acceptNode:d}),p=d(c);if(p===NodeFilter.FILTER_ACCEPT&&l(c),p!==NodeFilter.FILTER_REJECT){let f=i.nextNode();for(;f!=null;)l(f),f=i.nextNode()}},l=c=>{var d;let i=(d=R.get(c))!==null&&d!==void 0?d:0;c.getAttribute("aria-hidden")==="true"&&i===0||(i===0&&c.setAttribute("aria-hidden","true"),r.add(c),R.set(c,i+1))};k.length&&k[k.length-1].disconnect(),n(t);let a=new MutationObserver(c=>{for(let d of c)if(!(d.type!=="childList"||d.addedNodes.length===0)&&![...o,...r].some(i=>i.contains(d.target))){for(let i of d.removedNodes)i instanceof Element&&(o.delete(i),r.delete(i));for(let i of d.addedNodes)(i instanceof HTMLElement||i instanceof SVGElement)&&(i.dataset.liveAnnouncer==="true"||i.dataset.reactAriaTopLayer==="true")?o.add(i):i instanceof Element&&n(i)}});a.observe(t,{childList:!0,subtree:!0});let s={observe(){a.observe(t,{childList:!0,subtree:!0})},disconnect(){a.disconnect()}};return k.push(s),()=>{a.disconnect();for(let c of r){let d=R.get(c);d===1?(c.removeAttribute("aria-hidden"),R.delete(c)):R.set(c,d-1)}s===k[k.length-1]?(k.pop(),k.length&&k[k.length-1].observe()):k.splice(k.indexOf(s),1)}}const He=w.default.createContext(null);function co(e){let t=Ce(),{portalContainer:o=t?null:document.body,isExiting:r}=e,[n,l]=m.useState(!1),a=m.useMemo(()=>({contain:n,setContain:l}),[n,l]);if(!o)return null;let s=e.children;return e.disableFocusManagement||(s=w.default.createElement(Kt,{restoreFocus:!0,contain:n&&!r},s)),s=w.default.createElement(He.Provider,{value:a},w.default.createElement(Dt,null,s)),rt.default.createPortal(s,o)}function Ve(){let e=m.useContext(He),t=e==null?void 0:e.setContain;E(()=>{t==null||t(!0)},[t])}function mo(e,t,o){let{overlayProps:r,underlayProps:n}=ro({...e,isOpen:t.isOpen,onClose:t.close},o);return lo({isDisabled:!t.isOpen}),Ve(),m.useEffect(()=>{if(t.isOpen)return uo([o.current])},[t.isOpen,o]),{modalProps:ht(r),underlayProps:n}}function fo(e,t){let{role:o="dialog"}=e,r=$t();r=e["aria-label"]?void 0:r;let n=m.useRef(!1);return m.useEffect(()=>{if(t.current&&!t.current.contains(document.activeElement)){ie(t.current);let l=setTimeout(()=>{document.activeElement===t.current&&(n.current=!0,t.current&&(t.current.blur(),ie(t.current)),n.current=!1)},500);return()=>{clearTimeout(l)}}},[t]),Ve(),{dialogProps:{...Pt(e,{labelable:!0}),role:o,tabIndex:-1,"aria-labelledby":e["aria-labelledby"]||r,onBlur:l=>{n.current&&l.stopPropagation()}},titleProps:{id:r}}}function po(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function Te(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),o.push.apply(o,r)}return o}function Se(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?arguments[t]:{};t%2?Te(Object(o),!0).forEach(function(r){po(e,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):Te(Object(o)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))})}return e}var go=(e,t,o)=>{for(var r of Object.keys(e)){var n;if(e[r]!==((n=t[r])!==null&&n!==void 0?n:o[r]))return!1}return!0},je=e=>t=>{var o=e.defaultClassName,r=Se(Se({},e.defaultVariants),t);for(var n in r){var l,a=(l=r[n])!==null&&l!==void 0?l:e.defaultVariants[n];if(a!=null){var s=a;typeof s=="boolean"&&(s=s===!0?"true":"false");var c=e.variantClassNames[n][s];c&&(o+=" "+c)}}for(var[d,i]of e.compoundVariants)go(d,r,e.defaultVariants)&&(o+=" "+i);return o},bo="_3moto2o",vo="_3moto2q",$o="_3moto2r",Ke="_3moto2p",ho=je({defaultClassName:"_3moto20",variantClassNames:{kind:{informational:"_3moto21",delete:"_3moto22",failure:"_3moto23",success:"_3moto24",warning:"_3moto25",successWithFailures:"_3moto26",form:"_3moto27"},size:{sm:"_3moto28",md:"_3moto29",lg:"_3moto2a",xl:"_3moto2b"},fullHeight:{true:"_3moto2c",false:"_3moto2d"}},defaultVariants:{},compoundVariants:[]}),wo="_3moto2n",Eo=je({defaultClassName:"_3moto2e",variantClassNames:{kind:{form:"_3moto2f",delete:"_3moto2g",failure:"_3moto2h",informational:"_3moto2i",success:"_3moto2j",warning:"_3moto2k",successWithFailures:"_3moto2l"}},defaultVariants:{},compoundVariants:[]}),Mo="_3moto2m",yo="_3moto2s";function pe({children:e,className:t="",...o}){return u.createElement("div",{className:P.cl(Ke,t),...o},e)}P.Metadata.set(pe,{name:"ModalFooter"});const de=Object.freeze({form:"pencil",delete:"trash",failure:"status-error",informational:"info-circle",success:"status-ok",successWithFailures:"status-warning",warning:"status-warning"});function Po({children:e,className:t,"data-testid":o,kind:r="informational",onBlur:n,onFocus:l,overlayProps:a,size:s="sm",state:c,title:d,dismissible:i,dismissable:p=!0,onClose:f,fullHeight:b=!1,...g}){const T=i!=null?i:p,Q=u.useRef(null),{modalProps:Z,underlayProps:Ue}=mo({isKeyboardDismissDisabled:!T,...g},c,Q),{dialogProps:ee,titleProps:Ge}=fo(g,Q),Xe=P.combineEventHandlers(Z.onFocus,ee.onFocus,l),Je=P.combineEventHandlers(Z.onBlur,ee.onBlur,n),{t:Ye}=u.useContext(P.I18nContext),Qe=P.useChildTestIdAttrBuilder({"data-testid":o}),[te,Ze]=P.selectChildren(e,[{type:pe}]);function be(){f&&typeof f=="function"&&f(),c.close()}const ve=function(){return T?u.createElement(he.Button,{"aria-label":"Close",onClick:be,kind:"icon",icon:"x",className:vo}):null},et=P.modChildren(Ze,$e=>$e.type===ve?[{className:P.cl($e.props.classname,$o)}]:[]);return u.createElement(co,null,u.createElement("div",{className:yo,...Ue,...g},u.createElement("div",{...Z,...ee,...a,onFocus:Xe,onBlur:Je,...Qe("dialog"),ref:Q,className:P.cl(ho({kind:r,size:s,fullHeight:b}),t)},u.createElement("div",{...Ge,className:Eo({kind:r})},r&&u.createElement(P.Icon,{icon:de[r]||de.informational,className:wo}),u.createElement("div",{className:Mo},P.contentOf(d,c.close)),u.createElement(ve,null)),u.createElement("div",{className:bo},P.contentOf(et,c.close)),te&&te.length>0?u.createElement(u.Fragment,null,P.contentOf(te,c.close)):u.createElement("div",{className:Ke},u.createElement(he.Button,{kind:"key",onClick:be},Ye("design-system:modal.defaultButtonLabel"))))))}function ge(e){return e.state.isOpen?u.createElement(Po,{...e},e.children):u.createElement(u.Fragment,null)}P.Metadata.set(ge,{name:"Modal",props:{dismissable:{type:"boolean",default:"true"},fullHeight:{type:"boolean",default:"false"},kind:{type:"ModalKind",default:"informational"},onBlur:{type:"() => void"},onClose:{type:"() => void"},onFocus:{type:"() => void"},size:{type:"ModalSize",default:"sm"},title:{type:"string"}}});function ko(e){let[t,o]=nt(e.isOpen,e.defaultOpen||!1,e.onOpenChange);const r=m.useCallback(()=>{o(!0)},[o]),n=m.useCallback(()=>{o(!1)},[o]),l=m.useCallback(()=>{o(!t)},[o,t]);return{isOpen:t,setOpen:o,open:r,close:n,toggle:l}}function xo(e={}){const t=ko(e),o=m.useRef(null),{triggerProps:r,overlayProps:n}=no({type:"dialog"},t,o),{onPress:l,...a}=r;return{triggerProps:{...a,onClick:l,ref:o},modalState:t,modalProps:{overlayProps:n,state:t}}}const To={description:()=>u.createElement("p",null,"Modals are overlays on a page that focus a user\u2019s attention on an important message or a simple action. Examples of a Modal include confirming the deletion of a record, or making a single selection."),components:[ge],examples:{general:{label:"Usage",description:({NavigateTo:e})=>u.createElement(u.Fragment,null,u.createElement("h5",null,"Use a Modal:"),u.createElement("ul",null,u.createElement("li",null,"When the user needs to confirm a basic decision, such as deleting a record."),u.createElement("li",null,"When important information needs to be displayed to the user before continuing."),u.createElement("li",null,"When a simple selection, such as a single form input, is required before proceeding.")),u.createElement("h5",null,"Avoid a Modal:"),u.createElement("ul",null,u.createElement("li",null,"When a complex form is required. Use a ",u.createElement(e,{to:"focused-task"},"Focused Task View")," instead."),u.createElement("li",null,"When sharing non-critical or tertiary information. Use a ",u.createElement(e,{to:"growlers"},"Growler")," instead.")))},implementation:{label:"Close Button",description:()=>u.createElement(u.Fragment,null,u.createElement("h5",null,"Close Button and Modal dismissiability"),u.createElement("p",null,"Remove the Close Button in the upper right of the Modal if the user must choose the course of action before proceeding."),u.createElement("p",null,"The close button is included by default and omitted when the prop ",u.createElement("code",null,"dismissable")," is set to ",u.createElement("strong",null,"false"),"."),u.createElement("p",null,"Setting the ",u.createElement("code",null,"dismissable")," prop to false also prevents dismissing the modal by clicking outside of the modal or by using the"," ",u.createElement("strong",null,"escape")," key.")),examples:{basic:{react:v.code`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@sps-woodland/core"),$e=require("@sps-woodland/buttons"),m=require("react"),Ze=require("react-dom"),v=require("@spscommerce/utils");function et(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const u=et(m),w=typeof document<"u"?m.useLayoutEffect:()=>{};function A(e){const t=m.useRef(null);return w(()=>{t.current=e},[e]),m.useCallback((...o)=>{const n=t.current;return n==null?void 0:n(...o)},[])}function tt(e){let[t,o]=m.useState(e),n=m.useRef(null),r=A(()=>{if(!n.current)return;let a=n.current.next();if(a.done){n.current=null;return}t===a.value?r():o(a.value)});w(()=>{n.current&&r()});let l=A(a=>{n.current=a(t),r()});return[t,l]}const V={prefix:String(Math.round(Math.random()*1e10)),current:0},Se=m.createContext(V),ot=m.createContext(!1);let nt=!!(typeof window<"u"&&window.document&&window.document.createElement),te=new WeakMap;function rt(e=!1){let t=m.useContext(Se),o=m.useRef(null);if(o.current===null&&!e){var n,r;let l=(r=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)===null||r===void 0||(n=r.ReactCurrentOwner)===null||n===void 0?void 0:n.current;if(l){let a=te.get(l);a==null?te.set(l,{id:t.current,state:l.memoizedState}):l.memoizedState!==a.state&&(t.current=a.id,te.delete(l))}o.current=++t.current}return o.current}function at(e){let t=m.useContext(Se);t===V&&!nt&&console.warn("When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.");let o=rt(!!e),n=t===V&&process.env.NODE_ENV==="test"?"react-aria":`react-aria${t.prefix}`;return e||`${n}-${o}`}function lt(e){let t=m.useId(),[o]=m.useState(Fe()),n=o||process.env.NODE_ENV==="test"?"react-aria":`react-aria${V.prefix}`;return e||`${n}-${t}`}const it=typeof m.useId=="function"?lt:at;function st(){return!1}function dt(){return!0}function ut(e){return()=>{}}function Fe(){return typeof m.useSyncExternalStore=="function"?m.useSyncExternalStore(ut,st,dt):m.useContext(ot)}let ct=!!(typeof window<"u"&&window.document&&window.document.createElement),j=new Map;function Le(e){let[t,o]=m.useState(e),n=m.useRef(null),r=it(t),l=m.useCallback(a=>{n.current=a},[]);return ct&&j.set(r,l),w(()=>{let a=r;return()=>{j.delete(a)}},[r]),m.useEffect(()=>{let a=n.current;a&&(n.current=null,o(a))}),r}function mt(e,t){if(e===t)return e;let o=j.get(e);if(o)return o(t),t;let n=j.get(t);return n?(n(e),e):t}function ft(e=[]){let t=Le(),[o,n]=tt(t),r=m.useCallback(()=>{n(function*(){yield t,yield document.getElementById(t)?t:void 0})},[t,n]);return w(r,[t,r,...e]),o}function K(...e){return(...t)=>{for(let o of e)typeof o=="function"&&o(...t)}}const E=e=>{var t;return(t=e==null?void 0:e.ownerDocument)!==null&&t!==void 0?t:document},_=e=>e&&"window"in e&&e.window===e?e:E(e).defaultView||window;function Ce(e){var t,o,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(o=Ce(e[t]))&&(n&&(n+=" "),n+=o)}else for(o in e)e[o]&&(n&&(n+=" "),n+=o);return n}function pt(){for(var e,t,o=0,n="",r=arguments.length;o<r;o++)(e=arguments[o])&&(t=Ce(e))&&(n&&(n+=" "),n+=t);return n}function gt(...e){let t={...e[0]};for(let o=1;o<e.length;o++){let n=e[o];for(let r in n){let l=t[r],a=n[r];typeof l=="function"&&typeof a=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?t[r]=K(l,a):(r==="className"||r==="UNSAFE_className")&&typeof l=="string"&&typeof a=="string"?t[r]=pt(l,a):r==="id"&&l&&a?t.id=mt(l,a):t[r]=a!==void 0?a:l}}return t}const bt=new Set(["id"]),vt=new Set(["aria-label","aria-labelledby","aria-describedby","aria-details"]),$t=new Set(["href","hrefLang","target","rel","download","ping","referrerPolicy"]),ht=/^(data-.*)$/;function wt(e,t={}){let{labelable:o,isLink:n,propNames:r}=t,l={};for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(bt.has(a)||o&&vt.has(a)||n&&$t.has(a)||r!=null&&r.has(a)||ht.test(a))&&(l[a]=e[a]);return l}function he(e){if(Et())e.focus({preventScroll:!0});else{let t=Mt(e);e.focus(),yt(t)}}let z=null;function Et(){if(z==null){z=!1;try{document.createElement("div").focus({get preventScroll(){return z=!0,!0}})}catch{}}return z}function Mt(e){let t=e.parentNode,o=[],n=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==n;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&o.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return n instanceof HTMLElement&&o.push({element:n,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft}),o}function yt(e){for(let{element:t,scrollTop:o,scrollLeft:n}of e)t.scrollTop=o,t.scrollLeft=n}function Pt(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(o=>e.test(o.brand)))||e.test(window.navigator.userAgent)}function de(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function Be(){return de(/^Mac/i)}function kt(){return de(/^iPhone/i)}function xt(){return de(/^iPad/i)||Be()&&navigator.maxTouchPoints>1}function Tt(){return kt()||xt()}function St(){return Pt(/Android/i)}let B=new Map,re=new Set;function we(){if(typeof window>"u")return;function e(n){return"propertyName"in n}let t=n=>{if(!e(n)||!n.target)return;let r=B.get(n.target);r||(r=new Set,B.set(n.target,r),n.target.addEventListener("transitioncancel",o,{once:!0})),r.add(n.propertyName)},o=n=>{if(!e(n)||!n.target)return;let r=B.get(n.target);if(r&&(r.delete(n.propertyName),r.size===0&&(n.target.removeEventListener("transitioncancel",o),B.delete(n.target)),B.size===0)){for(let l of re)l();re.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",o)}typeof document<"u"&&(document.readyState!=="loading"?we():document.addEventListener("DOMContentLoaded",we));function Ft(e){requestAnimationFrame(()=>{B.size===0?e():re.add(e)})}function Ee(e,t){let o=window.getComputedStyle(e),n=/(auto|scroll)/.test(o.overflow+o.overflowX+o.overflowY);return n&&t&&(n=e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth),n}function Ne(e,t){let o=e;for(Ee(o,t)&&(o=o.parentElement);o&&!Ee(o,t);)o=o.parentElement;return o||document.scrollingElement||document.documentElement}function Lt(e){return e.mozInputSource===0&&e.isTrusted?!0:St()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Ct(e,t,o){let[n,r]=m.useState(e||t),l=m.useRef(e!==void 0),a=e!==void 0;m.useEffect(()=>{let i=l.current;i!==a&&console.warn(`WARN: A component changed from ${i?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}.`),l.current=a},[a]);let d=a?e:n,c=m.useCallback((i,...s)=>{let p=(f,...b)=>{o&&(Object.is(d,f)||o(f,...b)),a||(d=f)};typeof i=="function"?(console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),r((b,...g)=>{let x=i(a?d:b,...g);return p(x,...s),a?b:x})):(a||r(i),p(i,...s))},[a,d,o]);return[d,c]}const Oe=m.createContext({register:()=>{}});Oe.displayName="PressResponderContext";function Bt({children:e}){let t=m.useMemo(()=>({register:()=>{}}),[]);return m.createElement(Oe.Provider,{value:t},e)}class Nt{isDefaultPrevented(){return this.nativeEvent.defaultPrevented}preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPropagationStopped=()=>!0}isPropagationStopped(){return!1}persist(){}constructor(t,o){this.nativeEvent=o,this.target=o.target,this.currentTarget=o.currentTarget,this.relatedTarget=o.relatedTarget,this.bubbles=o.bubbles,this.cancelable=o.cancelable,this.defaultPrevented=o.defaultPrevented,this.eventPhase=o.eventPhase,this.isTrusted=o.isTrusted,this.timeStamp=o.timeStamp,this.type=t}}function Ot(e){let t=m.useRef({isFocused:!1,observer:null});w(()=>{const n=t.current;return()=>{n.observer&&(n.observer.disconnect(),n.observer=null)}},[]);let o=A(n=>{e==null||e(n)});return m.useCallback(n=>{if(n.target instanceof HTMLButtonElement||n.target instanceof HTMLInputElement||n.target instanceof HTMLTextAreaElement||n.target instanceof HTMLSelectElement){t.current.isFocused=!0;let r=n.target,l=a=>{t.current.isFocused=!1,r.disabled&&o(new Nt("blur",a)),t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};r.addEventListener("focusout",l,{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&r.disabled){var a;(a=t.current.observer)===null||a===void 0||a.disconnect();let d=r===document.activeElement?null:document.activeElement;r.dispatchEvent(new FocusEvent("blur",{relatedTarget:d})),r.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:d}))}}),t.current.observer.observe(r,{attributes:!0,attributeFilter:["disabled"]})}},[o])}let I=null,Dt=new Set,W=new Map,C=!1,ae=!1;function ue(e,t){for(let o of Dt)o(e,t)}function Rt(e){return!(e.metaKey||!Be()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function U(e){C=!0,Rt(e)&&(I="keyboard",ue("keyboard",e))}function k(e){I="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(C=!0,ue("pointer",e))}function De(e){Lt(e)&&(C=!0,I="virtual")}function Re(e){e.target===window||e.target===document||(!C&&!ae&&(I="virtual",ue("virtual",e)),C=!1,ae=!1)}function We(){C=!1,ae=!0}function Me(e){if(typeof window>"u"||W.get(_(e)))return;const t=_(e),o=E(e);let n=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){C=!0,n.apply(this,arguments)},o.addEventListener("keydown",U,!0),o.addEventListener("keyup",U,!0),o.addEventListener("click",De,!0),t.addEventListener("focus",Re,!0),t.addEventListener("blur",We,!1),typeof PointerEvent<"u"?(o.addEventListener("pointerdown",k,!0),o.addEventListener("pointermove",k,!0),o.addEventListener("pointerup",k,!0)):(o.addEventListener("mousedown",k,!0),o.addEventListener("mousemove",k,!0),o.addEventListener("mouseup",k,!0)),t.addEventListener("beforeunload",()=>{Ae(e)},{once:!0}),W.set(t,{focus:n})}const Ae=(e,t)=>{const o=_(e),n=E(e);t&&n.removeEventListener("DOMContentLoaded",t),W.has(o)&&(o.HTMLElement.prototype.focus=W.get(o).focus,n.removeEventListener("keydown",U,!0),n.removeEventListener("keyup",U,!0),n.removeEventListener("click",De,!0),o.removeEventListener("focus",Re,!0),o.removeEventListener("blur",We,!1),typeof PointerEvent<"u"?(n.removeEventListener("pointerdown",k,!0),n.removeEventListener("pointermove",k,!0),n.removeEventListener("pointerup",k,!0)):(n.removeEventListener("mousedown",k,!0),n.removeEventListener("mousemove",k,!0),n.removeEventListener("mouseup",k,!0)),W.delete(o))};function Wt(e){const t=E(e);let o;return t.readyState!=="loading"?Me(e):(o=()=>{Me(e)},t.addEventListener("DOMContentLoaded",o)),()=>Ae(e,o)}typeof document<"u"&&Wt();function At(){return I}function It(e){let{isDisabled:t,onBlurWithin:o,onFocusWithin:n,onFocusWithinChange:r}=e,l=m.useRef({isFocusWithin:!1}),a=m.useCallback(i=>{l.current.isFocusWithin&&!i.currentTarget.contains(i.relatedTarget)&&(l.current.isFocusWithin=!1,o&&o(i),r&&r(!1))},[o,r,l]),d=Ot(a),c=m.useCallback(i=>{!l.current.isFocusWithin&&document.activeElement===i.target&&(n&&n(i),r&&r(!0),l.current.isFocusWithin=!0,d(i))},[n,r,d]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:c,onBlur:a}}}function zt(e){let{ref:t,onInteractOutside:o,isDisabled:n,onInteractOutsideStart:r}=e,l=m.useRef({isPointerDown:!1,ignoreEmulatedMouseEvents:!1}),a=A(c=>{o&&q(c,t)&&(r&&r(c),l.current.isPointerDown=!0)}),d=A(c=>{o&&o(c)});m.useEffect(()=>{let c=l.current;if(n)return;const i=t.current,s=E(i);if(typeof PointerEvent<"u"){let p=f=>{c.isPointerDown&&q(f,t)&&d(f),c.isPointerDown=!1};return s.addEventListener("pointerdown",a,!0),s.addEventListener("pointerup",p,!0),()=>{s.removeEventListener("pointerdown",a,!0),s.removeEventListener("pointerup",p,!0)}}else{let p=b=>{c.ignoreEmulatedMouseEvents?c.ignoreEmulatedMouseEvents=!1:c.isPointerDown&&q(b,t)&&d(b),c.isPointerDown=!1},f=b=>{c.ignoreEmulatedMouseEvents=!0,c.isPointerDown&&q(b,t)&&d(b),c.isPointerDown=!1};return s.addEventListener("mousedown",a,!0),s.addEventListener("mouseup",p,!0),s.addEventListener("touchstart",a,!0),s.addEventListener("touchend",f,!0),()=>{s.removeEventListener("mousedown",a,!0),s.removeEventListener("mouseup",p,!0),s.removeEventListener("touchstart",a,!0),s.removeEventListener("touchend",f,!0)}}},[t,n,a,d])}function q(e,t){if(e.button>0)return!1;if(e.target){const o=e.target.ownerDocument;if(!o||!o.documentElement.contains(e.target)||e.target.closest("[data-react-aria-top-layer]"))return!1}return t.current&&!t.current.contains(e.target)}function le(e){const t=E(e);if(At()==="virtual"){let o=t.activeElement;Ft(()=>{t.activeElement===o&&e.isConnected&&he(e)})}else he(e)}function qt(e){const t=_(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:o,visibility:n}=e.style,r=o!=="none"&&n!=="hidden"&&n!=="collapse";if(r){const{getComputedStyle:l}=e.ownerDocument.defaultView;let{display:a,visibility:d}=l(e);r=a!=="none"&&d!=="hidden"&&d!=="collapse"}return r}function Ht(e,t){return!e.hasAttribute("hidden")&&!e.hasAttribute("data-react-aria-prevent-focus")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function Ie(e,t){return e.nodeName!=="#comment"&&qt(e)&&Ht(e,t)&&(!e.parentElement||Ie(e.parentElement,e))}const ye=m.createContext(null);let $=null;function Vt(e){let{children:t,contain:o,restoreFocus:n,autoFocus:r}=e,l=m.useRef(null),a=m.useRef(null),d=m.useRef([]),{parentNode:c}=m.useContext(ye)||{},i=m.useMemo(()=>new ie({scopeRef:d}),[d]);w(()=>{let f=c||h.root;if(h.getTreeNode(f.scopeRef)&&$&&!X($,f.scopeRef)){let b=h.getTreeNode($);b&&(f=b)}f.addChild(i),h.addNode(i)},[i,c]),w(()=>{let f=h.getTreeNode(d);f&&(f.contain=!!o)},[o]),w(()=>{var f;let b=(f=l.current)===null||f===void 0?void 0:f.nextSibling,g=[];for(;b&&b!==a.current;)g.push(b),b=b.nextSibling;d.current=g},[t]),Jt(d,n,o),Ut(d,o),Qt(d,n,o),Xt(d,r),m.useEffect(()=>{const f=E(d.current?d.current[0]:void 0).activeElement;let b=null;if(M(f,d.current)){for(let g of h.traverse())g.scopeRef&&M(f,g.scopeRef.current)&&(b=g);b===h.getTreeNode(d)&&($=b.scopeRef)}},[d]),w(()=>()=>{var f,b,g;let x=(g=(b=h.getTreeNode(d))===null||b===void 0||(f=b.parent)===null||f===void 0?void 0:f.scopeRef)!==null&&g!==void 0?g:null;(d===$||X(d,$))&&(!x||h.getTreeNode(x))&&($=x),h.removeTreeNode(d)},[d]);let s=m.useMemo(()=>jt(d),[]),p=m.useMemo(()=>({focusManager:s,parentNode:i}),[i,s]);return m.createElement(ye.Provider,{value:p},m.createElement("span",{"data-focus-scope-start":!0,hidden:!0,ref:l}),t,m.createElement("span",{"data-focus-scope-end":!0,hidden:!0,ref:a}))}function jt(e){return{focusNext(t={}){let o=e.current,{from:n,tabbable:r,wrap:l,accept:a}=t,d=n||E(o[0]).activeElement,c=o[0].previousElementSibling,i=L(o),s=F(i,{tabbable:r,accept:a},o);s.currentNode=M(d,o)?d:c;let p=s.nextNode();return!p&&l&&(s.currentNode=c,p=s.nextNode()),p&&S(p,!0),p},focusPrevious(t={}){let o=e.current,{from:n,tabbable:r,wrap:l,accept:a}=t,d=n||E(o[0]).activeElement,c=o[o.length-1].nextElementSibling,i=L(o),s=F(i,{tabbable:r,accept:a},o);s.currentNode=M(d,o)?d:c;let p=s.previousNode();return!p&&l&&(s.currentNode=c,p=s.previousNode()),p&&S(p,!0),p},focusFirst(t={}){let o=e.current,{tabbable:n,accept:r}=t,l=L(o),a=F(l,{tabbable:n,accept:r},o);a.currentNode=o[0].previousElementSibling;let d=a.nextNode();return d&&S(d,!0),d},focusLast(t={}){let o=e.current,{tabbable:n,accept:r}=t,l=L(o),a=F(l,{tabbable:n,accept:r},o);a.currentNode=o[o.length-1].nextElementSibling;let d=a.previousNode();return d&&S(d,!0),d}}}const ce=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]"],Kt=ce.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";ce.push('[tabindex]:not([tabindex="-1"]):not([disabled])');const _t=ce.join(':not([hidden]):not([tabindex="-1"]),');function L(e){return e[0].parentElement}function R(e){let t=h.getTreeNode($);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function Ut(e,t){let o=m.useRef(),n=m.useRef();w(()=>{let r=e.current;if(!t){n.current&&(cancelAnimationFrame(n.current),n.current=void 0);return}const l=E(r?r[0]:void 0);let a=i=>{if(i.key!=="Tab"||i.altKey||i.ctrlKey||i.metaKey||!R(e)||i.isComposing)return;let s=l.activeElement,p=e.current;if(!p||!M(s,p))return;let f=L(p),b=F(f,{tabbable:!0},p);if(!s)return;b.currentNode=s;let g=i.shiftKey?b.previousNode():b.nextNode();g||(b.currentNode=i.shiftKey?p[p.length-1].nextElementSibling:p[0].previousElementSibling,g=i.shiftKey?b.previousNode():b.nextNode()),i.preventDefault(),g&&S(g,!0)},d=i=>{(!$||X($,e))&&M(i.target,e.current)?($=e,o.current=i.target):R(e)&&!G(i.target,e)?o.current?o.current.focus():$&&$.current&&J($.current):R(e)&&(o.current=i.target)},c=i=>{n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{if(l.activeElement&&R(e)&&!G(l.activeElement,e))if($=e,l.body.contains(i.target)){var s;o.current=i.target,(s=o.current)===null||s===void 0||s.focus()}else $.current&&J($.current)})};return l.addEventListener("keydown",a,!1),l.addEventListener("focusin",d,!1),r==null||r.forEach(i=>i.addEventListener("focusin",d,!1)),r==null||r.forEach(i=>i.addEventListener("focusout",c,!1)),()=>{l.removeEventListener("keydown",a,!1),l.removeEventListener("focusin",d,!1),r==null||r.forEach(i=>i.removeEventListener("focusin",d,!1)),r==null||r.forEach(i=>i.removeEventListener("focusout",c,!1))}},[e,t]),w(()=>()=>{n.current&&cancelAnimationFrame(n.current)},[n])}function ze(e){return G(e)}function M(e,t){return!e||!t?!1:t.some(o=>o.contains(e))}function G(e,t=null){if(e instanceof Element&&e.closest("[data-react-aria-top-layer]"))return!0;for(let{scopeRef:o}of h.traverse(h.getTreeNode(t)))if(o&&M(e,o.current))return!0;return!1}function Gt(e){return G(e,$)}function X(e,t){var o;let n=(o=h.getTreeNode(t))===null||o===void 0?void 0:o.parent;for(;n;){if(n.scopeRef===e)return!0;n=n.parent}return!1}function S(e,t=!1){if(e!=null&&!t)try{le(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function J(e,t=!0){let o=e[0].previousElementSibling,n=L(e),r=F(n,{tabbable:t},e);r.currentNode=o;let l=r.nextNode();t&&!l&&(n=L(e),r=F(n,{tabbable:!1},e),r.currentNode=o,l=r.nextNode()),S(l)}function Xt(e,t){const o=m.useRef(t);m.useEffect(()=>{if(o.current){$=e;const n=E(e.current?e.current[0]:void 0);!M(n.activeElement,$.current)&&e.current&&J(e.current)}o.current=!1},[e])}function Jt(e,t,o){w(()=>{if(t||o)return;let n=e.current;const r=E(n?n[0]:void 0);let l=a=>{let d=a.target;M(d,e.current)?$=e:ze(d)||($=null)};return r.addEventListener("focusin",l,!1),n==null||n.forEach(a=>a.addEventListener("focusin",l,!1)),()=>{r.removeEventListener("focusin",l,!1),n==null||n.forEach(a=>a.removeEventListener("focusin",l,!1))}},[e,t,o])}function Yt(e){let t=h.getTreeNode($);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return(t==null?void 0:t.scopeRef)===e}function Qt(e,t,o){const n=m.useRef(typeof document<"u"?E(e.current?e.current[0]:void 0).activeElement:null);w(()=>{let r=e.current;const l=E(r?r[0]:void 0);if(!t||o)return;let a=()=>{(!$||X($,e))&&M(l.activeElement,e.current)&&($=e)};return l.addEventListener("focusin",a,!1),r==null||r.forEach(d=>d.addEventListener("focusin",a,!1)),()=>{l.removeEventListener("focusin",a,!1),r==null||r.forEach(d=>d.removeEventListener("focusin",a,!1))}},[e,o]),w(()=>{const r=E(e.current?e.current[0]:void 0);if(!t)return;let l=a=>{if(a.key!=="Tab"||a.altKey||a.ctrlKey||a.metaKey||!R(e)||a.isComposing)return;let d=r.activeElement;if(!M(d,e.current))return;let c=h.getTreeNode(e);if(!c)return;let i=c.nodeToRestore,s=F(r.body,{tabbable:!0});s.currentNode=d;let p=a.shiftKey?s.previousNode():s.nextNode();if((!i||!r.body.contains(i)||i===r.body)&&(i=void 0,c.nodeToRestore=void 0),(!p||!M(p,e.current))&&i){s.currentNode=i;do p=a.shiftKey?s.previousNode():s.nextNode();while(M(p,e.current));a.preventDefault(),a.stopPropagation(),p?S(p,!0):ze(i)?S(i,!0):d.blur()}};return o||r.addEventListener("keydown",l,!0),()=>{o||r.removeEventListener("keydown",l,!0)}},[e,t,o]),w(()=>{const r=E(e.current?e.current[0]:void 0);if(!t)return;let l=h.getTreeNode(e);if(l){var a;return l.nodeToRestore=(a=n.current)!==null&&a!==void 0?a:void 0,()=>{let d=h.getTreeNode(e);if(!d)return;let c=d.nodeToRestore;if(t&&c&&(M(r.activeElement,e.current)||r.activeElement===r.body&&Yt(e))){let i=h.clone();requestAnimationFrame(()=>{if(r.activeElement===r.body){let s=i.getTreeNode(e);for(;s;){if(s.nodeToRestore&&s.nodeToRestore.isConnected){S(s.nodeToRestore);return}s=s.parent}for(s=i.getTreeNode(e);s;){if(s.scopeRef&&s.scopeRef.current&&h.getTreeNode(s.scopeRef)){J(s.scopeRef.current,!0);return}s=s.parent}}})}}}},[e,t])}function F(e,t,o){let n=t!=null&&t.tabbable?_t:Kt,r=E(e).createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(l){var a;return!(t==null||(a=t.from)===null||a===void 0)&&a.contains(l)?NodeFilter.FILTER_REJECT:l.matches(n)&&Ie(l)&&(!o||M(l,o))&&(!(t!=null&&t.accept)||t.accept(l))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(r.currentNode=t.from),r}class me{get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,o,n){let r=this.fastMap.get(o??null);if(!r)return;let l=new ie({scopeRef:t});r.addChild(l),l.parent=r,this.fastMap.set(t,l),n&&(l.nodeToRestore=n)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let o=this.fastMap.get(t);if(!o)return;let n=o.parent;for(let l of this.traverse())l!==o&&o.nodeToRestore&&l.nodeToRestore&&o.scopeRef&&o.scopeRef.current&&M(l.nodeToRestore,o.scopeRef.current)&&(l.nodeToRestore=o.nodeToRestore);let r=o.children;n&&(n.removeChild(o),r.size>0&&r.forEach(l=>n&&n.addChild(l))),this.fastMap.delete(o.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let o of t.children)yield*this.traverse(o)}clone(){var t;let o=new me;var n;for(let r of this.traverse())o.addTreeNode(r.scopeRef,(n=(t=r.parent)===null||t===void 0?void 0:t.scopeRef)!==null&&n!==void 0?n:null,r.nodeToRestore);return o}constructor(){this.fastMap=new Map,this.root=new ie({scopeRef:null}),this.fastMap.set(null,this.root)}}class ie{addChild(t){this.children.add(t),t.parent=this}removeChild(t){this.children.delete(t),t.parent=void 0}constructor(t){this.children=new Set,this.contain=!1,this.scopeRef=t.scopeRef}}let h=new me;const Zt=new WeakMap,T=[];function eo(e,t){let{onClose:o,shouldCloseOnBlur:n,isOpen:r,isDismissable:l=!1,isKeyboardDismissDisabled:a=!1,shouldCloseOnInteractOutside:d}=e;m.useEffect(()=>(r&&T.push(t),()=>{let g=T.indexOf(t);g>=0&&T.splice(g,1)}),[r,t]);let c=()=>{T[T.length-1]===t&&o&&o()},i=g=>{(!d||d(g.target))&&T[T.length-1]===t&&(g.stopPropagation(),g.preventDefault())},s=g=>{(!d||d(g.target))&&(T[T.length-1]===t&&(g.stopPropagation(),g.preventDefault()),c())},p=g=>{g.key==="Escape"&&!a&&!g.nativeEvent.isComposing&&(g.stopPropagation(),g.preventDefault(),c())};zt({ref:t,onInteractOutside:l&&r?s:null,onInteractOutsideStart:i});let{focusWithinProps:f}=It({isDisabled:!n,onBlurWithin:g=>{!g.relatedTarget||Gt(g.relatedTarget)||(!d||d(g.relatedTarget))&&o()}}),b=g=>{g.target===g.currentTarget&&g.preventDefault()};return{overlayProps:{onKeyDown:p,...f},underlayProps:{onPointerDown:b}}}function to(e,t,o){let{type:n}=e,{isOpen:r}=t;m.useEffect(()=>{o&&o.current&&Zt.set(o.current,t.close)});let l;n==="menu"?l=!0:n==="listbox"&&(l="listbox");let a=Le();return{triggerProps:{"aria-haspopup":l,"aria-expanded":r,"aria-controls":r?a:null,onPress:t.toggle},overlayProps:{id:a}}}const oe=typeof document<"u"&&window.visualViewport,oo=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let H=0,ne;function no(e={}){let{isDisabled:t}=e;w(()=>{if(!t)return H++,H===1&&(Tt()?ne=ao():ne=ro()),()=>{H--,H===0&&ne()}},[t])}function ro(){return K(N(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),N(document.documentElement,"overflow","hidden"))}function ao(){let e,t,o=i=>{e=Ne(i.target,!0),!(e===document.documentElement&&e===document.body)&&e instanceof HTMLElement&&window.getComputedStyle(e).overscrollBehavior==="auto"&&(t=N(e,"overscrollBehavior","contain"))},n=i=>{if(!e||e===document.documentElement||e===document.body){i.preventDefault();return}e.scrollHeight===e.clientHeight&&e.scrollWidth===e.clientWidth&&i.preventDefault()},r=i=>{let s=i.target;ke(s)&&s!==document.activeElement&&(i.preventDefault(),d(),s.style.transform="translateY(-2000px)",s.focus(),requestAnimationFrame(()=>{s.style.transform=""})),t&&t()},l=i=>{let s=i.target;ke(s)&&(d(),s.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{s.style.transform="",oe&&(oe.height<window.innerHeight?requestAnimationFrame(()=>{Pe(s)}):oe.addEventListener("resize",()=>Pe(s),{once:!0}))}))},a=null,d=()=>{if(a)return;let i=()=>{window.scrollTo(0,0)},s=window.pageXOffset,p=window.pageYOffset;a=K(O(window,"scroll",i),N(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`),N(document.documentElement,"overflow","hidden"),N(document.body,"marginTop",`-${p}px`),()=>{window.scrollTo(s,p)}),window.scrollTo(0,0)},c=K(O(document,"touchstart",o,{passive:!1,capture:!0}),O(document,"touchmove",n,{passive:!1,capture:!0}),O(document,"touchend",r,{passive:!1,capture:!0}),O(document,"focus",l,!0));return()=>{t==null||t(),a==null||a(),c()}}function N(e,t,o){let n=e.style[t];return e.style[t]=o,()=>{e.style[t]=n}}function O(e,t,o,n){return e.addEventListener(t,o,n),()=>{e.removeEventListener(t,o,n)}}function Pe(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let o=Ne(e);if(o!==document.documentElement&&o!==document.body&&o!==e){let n=o.getBoundingClientRect().top,r=e.getBoundingClientRect().top;r>n+e.clientHeight&&(o.scrollTop+=r-n)}e=o.parentElement}}function ke(e){return e instanceof HTMLInputElement&&!oo.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}let D=new WeakMap,P=[];function lo(e,t=document.body){let o=new Set(e),n=new Set,r=c=>{for(let f of c.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))o.add(f);let i=f=>{if(o.has(f)||n.has(f.parentElement)&&f.parentElement.getAttribute("role")!=="row")return NodeFilter.FILTER_REJECT;for(let b of o)if(f.contains(b))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},s=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,{acceptNode:i}),p=i(c);if(p===NodeFilter.FILTER_ACCEPT&&l(c),p!==NodeFilter.FILTER_REJECT){let f=s.nextNode();for(;f!=null;)l(f),f=s.nextNode()}},l=c=>{var i;let s=(i=D.get(c))!==null&&i!==void 0?i:0;c.getAttribute("aria-hidden")==="true"&&s===0||(s===0&&c.setAttribute("aria-hidden","true"),n.add(c),D.set(c,s+1))};P.length&&P[P.length-1].disconnect(),r(t);let a=new MutationObserver(c=>{for(let i of c)if(!(i.type!=="childList"||i.addedNodes.length===0)&&![...o,...n].some(s=>s.contains(i.target))){for(let s of i.removedNodes)s instanceof Element&&(o.delete(s),n.delete(s));for(let s of i.addedNodes)(s instanceof HTMLElement||s instanceof SVGElement)&&(s.dataset.liveAnnouncer==="true"||s.dataset.reactAriaTopLayer==="true")?o.add(s):s instanceof Element&&r(s)}});a.observe(t,{childList:!0,subtree:!0});let d={observe(){a.observe(t,{childList:!0,subtree:!0})},disconnect(){a.disconnect()}};return P.push(d),()=>{a.disconnect();for(let c of n){let i=D.get(c);i===1?(c.removeAttribute("aria-hidden"),D.delete(c)):D.set(c,i-1)}d===P[P.length-1]?(P.pop(),P.length&&P[P.length-1].observe()):P.splice(P.indexOf(d),1)}}const io=m.createContext({});function so(){var e;return(e=m.useContext(io))!==null&&e!==void 0?e:{}}const qe=m.createContext(null);function uo(e){let t=Fe(),{portalContainer:o=t?null:document.body,isExiting:n}=e,[r,l]=m.useState(!1),a=m.useMemo(()=>({contain:r,setContain:l}),[r,l]),{getContainer:d}=so();if(!e.portalContainer&&d&&(o=d()),!o)return null;let c=e.children;return e.disableFocusManagement||(c=m.createElement(Vt,{restoreFocus:!0,contain:r&&!n},c)),c=m.createElement(qe.Provider,{value:a},m.createElement(Bt,null,c)),Ze.createPortal(c,o)}function He(){let e=m.useContext(qe),t=e==null?void 0:e.setContain;w(()=>{t==null||t(!0)},[t])}function co(e,t,o){let{overlayProps:n,underlayProps:r}=eo({...e,isOpen:t.isOpen,onClose:t.close},o);return no({isDisabled:!t.isOpen}),He(),m.useEffect(()=>{if(t.isOpen)return lo([o.current])},[t.isOpen,o]),{modalProps:gt(n),underlayProps:r}}function mo(e,t){let{role:o="dialog"}=e,n=ft();n=e["aria-label"]?void 0:n;let r=m.useRef(!1);return m.useEffect(()=>{if(t.current&&!t.current.contains(document.activeElement)){le(t.current);let l=setTimeout(()=>{document.activeElement===t.current&&(r.current=!0,t.current&&(t.current.blur(),le(t.current)),r.current=!1)},500);return()=>{clearTimeout(l)}}},[t]),He(),{dialogProps:{...wt(e,{labelable:!0}),role:o,tabIndex:-1,"aria-labelledby":e["aria-labelledby"]||n,onBlur:l=>{r.current&&l.stopPropagation()}},titleProps:{id:n}}}function fo(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function xe(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),o.push.apply(o,n)}return o}function Te(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?arguments[t]:{};t%2?xe(Object(o),!0).forEach(function(n){fo(e,n,o[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):xe(Object(o)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))})}return e}var po=(e,t,o)=>{for(var n of Object.keys(e)){var r;if(e[n]!==((r=t[n])!==null&&r!==void 0?r:o[n]))return!1}return!0},Ve=e=>t=>{var o=e.defaultClassName,n=Te(Te({},e.defaultVariants),t);for(var r in n){var l,a=(l=n[r])!==null&&l!==void 0?l:e.defaultVariants[r];if(a!=null){var d=a;typeof d=="boolean"&&(d=d===!0?"true":"false");var c=e.variantClassNames[r][d];c&&(o+=" "+c)}}for(var[i,s]of e.compoundVariants)po(i,n,e.defaultVariants)&&(o+=" "+s);return o},go="_3moto2o",bo="_3moto2q",vo="_3moto2r",je="_3moto2p",$o=Ve({defaultClassName:"_3moto20",variantClassNames:{kind:{informational:"_3moto21",delete:"_3moto22",failure:"_3moto23",success:"_3moto24",warning:"_3moto25",successWithFailures:"_3moto26",form:"_3moto27"},size:{sm:"_3moto28",md:"_3moto29",lg:"_3moto2a",xl:"_3moto2b"},fullHeight:{true:"_3moto2c",false:"_3moto2d"}},defaultVariants:{},compoundVariants:[]}),ho="_3moto2n",wo=Ve({defaultClassName:"_3moto2e",variantClassNames:{kind:{form:"_3moto2f",delete:"_3moto2g",failure:"_3moto2h",informational:"_3moto2i",success:"_3moto2j",warning:"_3moto2k",successWithFailures:"_3moto2l"}},defaultVariants:{},compoundVariants:[]}),Eo="_3moto2m",Mo="_3moto2s";function fe({children:e,className:t="",...o}){return u.createElement("div",{className:y.cl(je,t),...o},e)}y.Metadata.set(fe,{name:"ModalFooter"});const se=Object.freeze({form:"pencil",delete:"trash",failure:"status-error",informational:"info-circle",success:"status-ok",successWithFailures:"status-warning",warning:"status-warning"});function yo({children:e,className:t,"data-testid":o,kind:n="informational",onBlur:r,onFocus:l,overlayProps:a,size:d="sm",state:c,title:i,dismissible:s,dismissable:p=!0,onClose:f,fullHeight:b=!1,...g}){const x=s??p,Y=u.useRef(null),{modalProps:Q,underlayProps:Ke}=co({isKeyboardDismissDisabled:!x,...g},c,Y),{dialogProps:Z,titleProps:_e}=mo(g,Y),Ue=y.combineEventHandlers(Q.onFocus,Z.onFocus,l),Ge=y.combineEventHandlers(Q.onBlur,Z.onBlur,r),{t:Xe}=u.useContext(y.I18nContext),Je=y.useChildTestIdAttrBuilder({"data-testid":o}),[ee,Ye]=y.selectChildren(e,[{type:fe}]);function ge(){f&&typeof f=="function"&&f(),c.close()}const be=function(){return x?u.createElement($e.Button,{"aria-label":"Close",onClick:ge,kind:"icon",icon:"x",className:bo}):null},Qe=y.modChildren(Ye,ve=>ve.type===be?[{className:y.cl(ve.props.classname,vo)}]:[]);return u.createElement(uo,null,u.createElement("div",{className:Mo,...Ke,...g},u.createElement("div",{...Q,...Z,...a,onFocus:Ue,onBlur:Ge,...Je("dialog"),ref:Y,className:y.cl($o({kind:n,size:d,fullHeight:b}),t)},u.createElement("div",{..._e,className:wo({kind:n})},n&&u.createElement(y.Icon,{icon:se[n]||se.informational,className:ho}),u.createElement("div",{className:Eo},y.contentOf(i,c.close)),u.createElement(be,null)),u.createElement("div",{className:go},y.contentOf(Qe,c.close)),ee&&ee.length>0?u.createElement(u.Fragment,null,y.contentOf(ee,c.close)):u.createElement("div",{className:je},u.createElement($e.Button,{kind:"key",onClick:ge},Xe("design-system:modal.defaultButtonLabel"))))))}function pe(e){return e.state.isOpen?u.createElement(yo,{...e},e.children):u.createElement(u.Fragment,null)}y.Metadata.set(pe,{name:"Modal",props:{dismissable:{type:"boolean",default:"true"},fullHeight:{type:"boolean",default:"false"},kind:{type:"ModalKind",default:"informational"},onBlur:{type:"() => void"},onClose:{type:"() => void"},onFocus:{type:"() => void"},size:{type:"ModalSize",default:"sm"},title:{type:"string"}}});function Po(e){let[t,o]=Ct(e.isOpen,e.defaultOpen||!1,e.onOpenChange);const n=m.useCallback(()=>{o(!0)},[o]),r=m.useCallback(()=>{o(!1)},[o]),l=m.useCallback(()=>{o(!t)},[o,t]);return{isOpen:t,setOpen:o,open:n,close:r,toggle:l}}function ko(e={}){const t=Po(e),o=m.useRef(null),{triggerProps:n,overlayProps:r}=to({type:"dialog"},t,o),{onPress:l,...a}=n;return{triggerProps:{...a,onClick:l,ref:o},modalState:t,modalProps:{overlayProps:r,state:t}}}const xo={description:()=>u.createElement("p",null,"Modals are overlays on a page that focus a user’s attention on an important message or a simple action. Examples of a Modal include confirming the deletion of a record, or making a single selection."),components:[pe],examples:{general:{label:"Usage",description:({NavigateTo:e})=>u.createElement(u.Fragment,null,u.createElement("h5",null,"Use a Modal:"),u.createElement("ul",null,u.createElement("li",null,"When the user needs to confirm a basic decision, such as deleting a record."),u.createElement("li",null,"When important information needs to be displayed to the user before continuing."),u.createElement("li",null,"When a simple selection, such as a single form input, is required before proceeding.")),u.createElement("h5",null,"Avoid a Modal:"),u.createElement("ul",null,u.createElement("li",null,"When a complex form is required. Use a ",u.createElement(e,{to:"focused-task"},"Focused Task View")," instead."),u.createElement("li",null,"When sharing non-critical or tertiary information. Use a ",u.createElement(e,{to:"growlers"},"Growler")," instead.")))},implementation:{label:"Close Button",description:()=>u.createElement(u.Fragment,null,u.createElement("h5",null,"Close Button and Modal dismissiability"),u.createElement("p",null,"Remove the Close Button in the upper right of the Modal if the user must choose the course of action before proceeding."),u.createElement("p",null,"The close button is included by default and omitted when the prop ",u.createElement("code",null,"dismissable")," is set to ",u.createElement("strong",null,"false"),"."),u.createElement("p",null,"Setting the ",u.createElement("code",null,"dismissable")," prop to false also prevents dismissing the modal by clicking outside of the modal or by using the"," ",u.createElement("strong",null,"escape")," key.")),examples:{basic:{react:v.code`
2
2
  import { Modal, ModalFooter, useModal } from "@sps-woodland/modal";
3
3
  import { sprinkles } from "@sps-woodland/tokens";
4
4
  import { Button } from "@sps-woodland/buttons";
@@ -559,4 +559,4 @@
559
559
  </>
560
560
  )
561
561
  }
562
- `}}}}},So={Modals:To};exports.MANIFEST=So;exports.Modal=ge;exports.ModalFooter=pe;exports.ModalIcons=de;exports.useModal=xo;
562
+ `}}}}},To={Modals:xo};exports.MANIFEST=To;exports.Modal=pe;exports.ModalFooter=fe;exports.ModalIcons=se;exports.useModal=ko;