import{defineComponent as b,shallowRef as P,watch as A,onBeforeUnmount as D,createVNode as t,isVNode as $,cloneVNode as N}from"vue";import{debounce as z}from"../node_modules/.pnpm/throttle-debounce@5.0.2/node_modules/throttle-debounce/esm/index.mjs";import{filterEmpty as E,getPropsSlot as V}from"../_util/props-util/index.mjs";import k from"../_util/props-util/initDefaultProps.mjs";import h from"../_util/vue-types/index.mjs";import B from"../config-provider/hooks/useConfigInject.mjs";import R from"./style/index.mjs";const j=()=>({prefixCls:String,spinning:{type:Boolean,default:void 0},size:String,wrapperClassName:String,tip:h.any,delay:Number,indicator:h.any});let o=null;function M(n,i){return!!n&&!!i&&!isNaN(Number(i))}function H(n){const i=n.indicator;o=typeof i=="function"?i:()=>t(i,null,null)}const J=b({compatConfig:{MODE:3},name:"ASpin",inheritAttrs:!1,props:k(j(),{size:"default",spinning:!0,wrapperClassName:""}),setup(n,{attrs:i,slots:u}){const{prefixCls:e,size:f,direction:S}=B("spin",n),[p,v]=R(e),s=P(n.spinning&&!M(n.spinning,n.delay));let r;return A([()=>n.spinning,()=>n.delay],()=>{r?.cancel(),r=z(n.delay,()=>{s.value=n.spinning}),r?.()},{immediate:!0,flush:"post"}),D(()=>{r?.cancel()}),()=>{const{class:g,...w}=i,{tip:c=u.tip?.()}=n,d=u.default?.(),C={[v.value]:!0,[e.value]:!0,[`${e.value}-sm`]:f.value==="small",[`${e.value}-lg`]:f.value==="large",[`${e.value}-spinning`]:s.value,[`${e.value}-show-text`]:!!c,[`${e.value}-rtl`]:S.value==="rtl",[g]:!!g};function I(a){const m=`${a}-dot`;let l=V(u,n,"indicator");return l===null?null:(Array.isArray(l)&&(l=l.length===1?l[0]:l),$(l)?N(l,{class:m}):o&&$(o())?N(o(),{class:m}):t("span",{class:`${m} ${a}-dot-spin`},[t("i",{class:`${a}-dot-item`},null),t("i",{class:`${a}-dot-item`},null),t("i",{class:`${a}-dot-item`},null),t("i",{class:`${a}-dot-item`},null)]))}const y=t("div",{...w,class:C,"aria-live":"polite","aria-busy":s.value},[I(e.value),c?t("div",{class:`${e.value}-text`},[c]):null]);if(d&&E(d).length){const a={[`${e.value}-container`]:!0,[`${e.value}-blur`]:s.value};return p(t("div",{class:[`${e.value}-nested-loading`,n.wrapperClassName,v.value]},[s.value&&t("div",{key:"loading"},[y]),t("div",{class:a,key:"container"},[d])]))}return p(y)}}});export{J as default,H as setDefaultIndicator,j as spinProps};
