"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("@aplus-frontend/antdv/es/theme/internal"),k=require("@emotion/css"),$=require("@emotion/css/create-instance"),i=require("lodash-unified"),o=require("vue");require("../../config-provider/index.js");const b=require("../../config-provider/hooks/use-token.js"),h=require("./instance.js"),w=require("./plugin-specificity.js"),V=require("./TokenUtil.js"),C=require("./utils.js"),j=require("../../config-provider/hooks/use-global-config.js"),{css:P}=$({key:"css-dev-only",stylisPlugins:[w.downSpecificityPlugin]});function A(l){const s={};for(const t in l)s[t]=`var(${C.camelToKebab(t)})`;return s}function G(l,s,t,T){return c=>{const m=l.split("."),{token:u,rootCls:p}=b.useToken(),[,g]=S.useToken(),y=o.ref(),r=j.useGlobalConfig("namespace"),q=o.computed(()=>({...i.omit(u.value||{},"components"),...u.value.components?.[m[0]]||{}})),v=o.computed(()=>{const e=u.value.components?.[m[0]]||{};return{...i.isFunction(t)?t(q.value):t||{},...e}}),d=o.computed(()=>({...i.omit(u.value||{},"components"),...v.value,componentCls:`.${r.value}-${c}`,namespace:r.value}));return o.watch(()=>r.value,e=>{const n=A(d.value);n.componentCls=`.${e}-${c}`,n.namespace=e,n.calc=f=>new V.TokenUtil(f),n.antdv=g.value;const a=s(n,{...d.value,componentCls:`.${e}-${c}`,namespace:e});k.injectGlobal(a)},{immediate:!0}),o.watch([()=>v.value,()=>p.value],([e,n])=>{const a=C.generateCssVar(e,T);Object.keys(a).length&&h.css({[`.${n}.${r.value}-${c}`]:a})},{deep:!0,immediate:!0}),o.computed(()=>k.cx(p.value,y.value))}}exports.genComponentStyleHook=G;
