import{reactive as m,defineComponent as L,computed as t,watch as q,watchEffect as h,createVNode as v}from"vue";import"../_util/cssinjs/StyleContext.mjs";import z from"../_util/cssinjs/theme/createTheme.mjs";import"../_util/cssinjs/transformers/legacyLogicalProperties.mjs";import J,{ANT_MARK as Q}from"../locale/index.mjs";import U from"../locale/LocaleReceiver.mjs";import X from"../locale/en_US.mjs";import Y from"../message/index.mjs";import Z from"../notification/index.mjs";import{DesignTokenProvider as ee}from"../theme/internal.mjs";import te from"../theme/themes/seed.mjs";import{useProviderDisabled as ne}from"./DisabledContext.mjs";import{useProviderSize as oe}from"./SizeContext.mjs";import{useConfigContextInject as re,defaultIconPrefixCls as T,useConfigContextProvider as ie,useProvideGlobalForm as ae,configProviderProps as le}from"./context.mjs";import{registerTheme as ce}from"./cssVariables.mjs";import fe from"./hooks/useTheme.mjs";import ue from"./renderEmpty.mjs";import se from"./style/index.mjs";const de="ant";function f(){return r.prefixCls||de}function b(){return r.iconPrefixCls||T}const P=m({}),r=m({});h(()=>{Object.assign(r,P),r.prefixCls=f(),r.iconPrefixCls=b(),r.getPrefixCls=(e,a)=>a||(e?`${r.prefixCls}-${e}`:r.prefixCls),r.getRootPrefixCls=()=>r.prefixCls?r.prefixCls:f()});let C;const me=e=>{C&&C(),C=h(()=>{Object.assign(P,m(e)),Object.assign(r,m(e))}),e.theme&&ce(f(),e.theme)},_e=()=>({getPrefixCls:(e,a)=>a||(e?`${f()}-${e}`:f()),getIconPrefixCls:b,getRootPrefixCls:()=>r.prefixCls?r.prefixCls:f()}),d=L({compatConfig:{MODE:3},name:"AConfigProvider",inheritAttrs:!1,props:le(),setup(e,{slots:a}){const n=re(),M=(o,i)=>{const{prefixCls:l="ant"}=e;if(i)return i;const s=l||n.getPrefixCls("");return o?`${s}-${o}`:s},g=t(()=>e.iconPrefixCls||n.iconPrefixCls.value||T),y=t(()=>g.value!==n.iconPrefixCls.value),E=t(()=>e.csp||n.csp?.value),I=se(g),x=fe(t(()=>e.theme),t(()=>n.theme?.value)),$=o=>(e.renderEmpty||a.renderEmpty||n.renderEmpty||ue)(o),w=t(()=>e.autoInsertSpaceInButton??n.autoInsertSpaceInButton?.value),c=t(()=>e.locale||n.locale?.value);q(c,()=>{P.locale=c.value},{immediate:!0});const u=t(()=>e.direction||n.direction?.value),A=t(()=>e.space??n.space?.value),R=t(()=>e.virtual??n.virtual?.value),_=t(()=>e.dropdownMatchSelectWidth??n.dropdownMatchSelectWidth?.value),j=t(()=>e.getTargetContainer!==void 0?e.getTargetContainer:n.getTargetContainer?.value),D=t(()=>e.getPopupContainer!==void 0?e.getPopupContainer:n.getPopupContainer?.value),N=t(()=>e.pageHeader!==void 0?e.pageHeader:n.pageHeader?.value),O=t(()=>e.input!==void 0?e.input:n.input?.value),W=t(()=>e.pagination!==void 0?e.pagination:n.pagination?.value),k=t(()=>e.form!==void 0?e.form:n.form?.value),B=t(()=>e.select!==void 0?e.select:n.select?.value),p=t(()=>e.componentSize),S=t(()=>e.componentDisabled),F=t(()=>e.wave??n.wave?.value),G={csp:E,autoInsertSpaceInButton:w,locale:c,direction:u,space:A,virtual:R,dropdownMatchSelectWidth:_,getPrefixCls:M,iconPrefixCls:g,theme:t(()=>x.value??n.theme?.value),renderEmpty:$,getTargetContainer:j,getPopupContainer:D,pageHeader:N,input:O,pagination:W,form:k,select:B,componentSize:p,componentDisabled:S,transformCellText:t(()=>e.transformCellText),wave:F},H=t(()=>{const{algorithm:o,token:i,...l}=x.value||{},s=o&&(!Array.isArray(o)||o.length>0)?z(o):void 0;return{...l,theme:s,token:{...te,...i}}}),V=t(()=>{let o={};return c.value&&(o=c.value.Form?.defaultValidateMessages||X.Form?.defaultValidateMessages||{}),e.form&&e.form.validateMessages&&(o={...o,...e.form.validateMessages}),o});ie(G),ae({validateMessages:V}),oe(p),ne(S);const K=o=>{let i=y.value?I(a.default?.()):a.default?.();if(e.theme){const l=(function(){return i})();i=v(ee,{value:H.value},{default:()=>[l]})}return v(J,{locale:c.value||o,ANT_MARK__:Q},{default:()=>[i]})};return h(()=>{u.value&&(Y.config({rtl:u.value==="rtl"}),Z.config({rtl:u.value==="rtl"}))}),()=>v(U,{children:(o,i,l)=>K(l)},null)}});d.config=me;d.install=function(e){e.component(d.name,d)};export{d as default,T as defaultIconPrefixCls,de as defaultPrefixCls,_e as globalConfig,r as globalConfigForApi};
