"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=require("../../../node_modules/.pnpm/@emotion_hash@0.9.2/node_modules/@emotion/hash/dist/emotion-hash.esm.js"),u=require("vue"),v=require("../StyleContext.js"),d=require("../util.js"),_=require("./useGlobalCache.js"),m={},p="css",r=new Map;function C(e){r.set(e,(r.get(e)||0)+1)}function E(e,c){typeof document<"u"&&document.querySelectorAll(`style[${v.ATTR_TOKEN}="${e}"]`).forEach(t=>{t[v.CSS_IN_JS_INSTANCE]===c&&t.parentNode?.removeChild(t)})}const I=0;function q(e,c){r.set(e,(r.get(e)||0)-1);const n=Array.from(r.keys()),t=n.filter(o=>(r.get(o)||0)<=0);n.length-t.length>I&&t.forEach(o=>{E(o,c),r.delete(o)})}const g=(e,c,n,t)=>{let s={...n.getDerivativeToken(e),...c};return t&&(s=t(s)),s};function K(e,c,n=u.ref({})){const t=v.useStyleInject(),o=u.computed(()=>Object.assign({},...c.value)),s=u.computed(()=>d.flattenToken(o.value)),h=u.computed(()=>d.flattenToken(n.value.override||m));return _.default("token",u.computed(()=>[n.value.salt||"",e.value.id,s.value,h.value]),()=>{const{salt:l="",override:T=m,formatToken:y,getComputedToken:k}=n.value,a=k?k(o.value,T,e.value):g(o.value,T,e.value,y),i=d.token2key(a,l);a._tokenKey=i,C(i);const f=`${p}-${S.default(i)}`;return a._hashId=f,[a,f]},l=>{q(l[0]._tokenKey,t.value?.cache.instanceId)})}exports.default=K;exports.getComputedToken=g;
