import{J as c,c5 as C,aa as E,r as u,Q as v,O as R}from"./main-tangy-colts-beg.js";import{A as I}from"./index-tangy-colts-beg-131.js";function F(t){if(t)return{closable:t.closable,closeIcon:t.closeIcon}}function g(t){const{closable:n,closeIcon:s}=t||{};return c.useMemo(()=>{if(!n&&(n===!1||s===!1||s===null))return!1;if(n===void 0&&s===void 0)return null;let e={closeIcon:typeof s!="boolean"&&s!==null?s:void 0};return n&&typeof n=="object"&&(e=Object.assign(Object.assign({},e),n)),e},[n,s])}function b(){const t={};for(var n=arguments.length,s=new Array(n),e=0;e<n;e++)s[e]=arguments[e];return s.forEach(o=>{o&&Object.keys(o).forEach(r=>{o[r]!==void 0&&(t[r]=o[r])})}),t}const O={};function M(t,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:O;const e=g(t),o=g(n),r=typeof e!="boolean"?!!(e!=null&&e.disabled):!1,a=c.useMemo(()=>Object.assign({closeIcon:c.createElement(C,null)},s),[s]),f=c.useMemo(()=>e===!1?!1:e?b(a,o,e):o===!1?!1:o?b(a,o):a.closable?a:!1,[e,o,a]);return c.useMemo(()=>{if(f===!1)return[!1,null,r];const{closeIconRender:d}=a,{closeIcon:m}=f;let l=m;if(l!=null){d&&(l=d(m));const i=E(f,!0);Object.keys(i).length&&(l=c.isValidElement(l)?c.cloneElement(l,i):c.createElement("span",Object.assign({},i),l))}return[!0,l,r]},[f,a])}function p(){}const h=u.createContext({add:p,remove:p});function U(t){const n=u.useContext(h),s=u.useRef(null);return v(o=>{if(o){const r=t?o.querySelector(t):o;n.add(r),s.current=r}else n.remove(s.current)})}function k(){const[,t]=u.useReducer(n=>n+1,0);return t}function j(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const n=u.useRef({}),s=k(),e=I();return R(()=>{const o=e.subscribe(r=>{n.current=r,t&&s()});return()=>e.unsubscribe(o)},[]),n.current}export{j as a,M as b,U as c,F as p,k as u};
