import{i as e,n as t}from"./jsx-runtime-bzQ4Vb5N.js";var n=e(t(),1);function r(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function i(...e){return t=>{let n=!1,i=e.map(e=>{let i=r(e,t);return!n&&typeof i==`function`&&(n=!0),i});if(n)return()=>{for(let t=0;t<i.length;t++){let n=i[t];typeof n==`function`?n():r(e[t],null)}}}}function a(...e){return n.useCallback(i(...e),e)}function o(e){let t=n.forwardRef((t,r)=>{let{children:i,...o}=t,s=null,c=!1,l=[];h(i)&&typeof y==`function`&&(i=y(i._payload)),n.Children.forEach(i,e=>{if(p(e)){c=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;h(n)&&typeof y==`function`&&(n=y(n._payload)),s=u(t,n),l.push(s?.props?.children)}else l.push(e)}),s?s=n.cloneElement(s,void 0,l):!c&&n.Children.count(i)===1&&n.isValidElement(i)&&(s=i);let m=s?f(s):void 0,g=a(r,m);if(!s){if(i||i===0)throw Error(c?v(e):_(e));return i}let b=d(o,s.props??{});return s.type!==n.Fragment&&(b.ref=r?g:m),n.cloneElement(s,b)});return t.displayName=`${e}.Slot`,t}var s=o(`Slot`),c=Symbol.for(`radix.slottable`);function l(e){let t=e=>`child`in e?e.children(e.child):e.children;return t.displayName=`${e}.Slottable`,t.__radixId=c,t}var u=(e,t)=>{if(`child`in e.props){let t=e.props.child;return n.isValidElement(t)?n.cloneElement(t,void 0,e.props.children(t.props.children)):null}return n.isValidElement(t)?t:null};function d(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function f(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function p(e){return n.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===c}var m=Symbol.for(`react.lazy`);function h(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===m&&`_payload`in e&&g(e._payload)}function g(e){return typeof e==`object`&&!!e&&`then`in e}var _=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,v=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,y=n.use;export{a as i,o as n,l as r,s as t};