import{S as e}from"./p-BNpVu1WU.js";const t=(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout((()=>{e=0,(e=>{for(let t of e.keys()){const n=e.get(t).filter((e=>{const t=e.deref();return t&&(!("isConnected"in(n=t))||n.isConnected);var n}));e.set(t,n)}})(...t)}),2e3)}})(),n=e.forceUpdate,o=e.getRenderingRef,r=(e,t)=>{const n=e.indexOf(t);n>=0&&(e[n]=e[e.length-1],e.length--)},s="prod",a=e=>{const t=(e||"").toLowerCase();return t.includes("bot")?"bot":t.includes("cta")?"cta":t.includes("search")?"search":"unknown"},c=(()=>{const e=((e,t=(e,t)=>e!==t)=>{const n=()=>{return("function"==typeof(t=e)?t():t)??{};var t},o=n();let s=new Map(Object.entries(o));const a="undefined"!=typeof Proxy,c=a?null:{},d={dispose:[],get:[],set:[],reset:[]},u=new Map,i=()=>{s=new Map(Object.entries(n())),a||w(),d.reset.forEach((e=>e()))},p=e=>(d.get.forEach((t=>t(e))),s.get(e)),f=(e,n)=>{const o=s.get(e);t(n,o,e)&&(s.set(e,n),a||b(e),d.set.forEach((t=>t(e,n,o))))},l=a?new Proxy(o,{get:(e,t)=>p(t),ownKeys:()=>Array.from(s.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>s.has(t),set:(e,t,n)=>(f(t,n),!0)}):(w(),c),y=(e,t)=>(d[e].push(t),()=>{r(d[e],t)});function b(e){!a&&c&&(Object.prototype.hasOwnProperty.call(c,e)||Object.defineProperty(c,e,{configurable:!0,enumerable:!0,get:()=>p(e),set(t){f(e,t)}}))}function w(){if(a||!c)return;const e=new Set(s.keys());for(const t of Object.keys(c))e.has(t)||delete c[t];for(const t of e)b(t)}return{state:l,get:p,set:f,on:y,onChange:(e,t)=>{const o=(n,o)=>{n===e&&t(o)},r=()=>{const o=n();t(o[e])},s=y("set",o),a=y("reset",r);return u.set(t,{setHandler:o,resetHandler:r,propName:e}),()=>{s(),a(),u.delete(t)}},use:(...e)=>{const t=e.reduce(((e,t)=>(t.set&&e.push(y("set",t.set)),t.get&&e.push(y("get",t.get)),t.reset&&e.push(y("reset",t.reset)),t.dispose&&e.push(y("dispose",t.dispose)),e)),[]);return()=>t.forEach((e=>e()))},dispose:()=>{d.dispose.forEach((e=>e())),i()},reset:i,forceUpdate:e=>{const t=s.get(e);d.set.forEach((n=>n(e,t,t)))},removeListener:(e,t)=>{const n=u.get(t);n&&n.propName===e&&(r(d.set,n.setHandler),r(d.reset,n.resetHandler),u.delete(t))}}})({dataKey:"",dataMode:"prod",activeParentScope:"unknown",parentContexts:{bot:{dataKey:"",dataMode:s},cta:{dataKey:"",dataMode:s},search:{dataKey:"",dataMode:s},unknown:{dataKey:"",dataMode:s}}},void 0);return e.use((()=>{if("function"!=typeof o||"function"!=typeof n)return{};const e=n,r=o,s=new Map;return{dispose:()=>s.clear(),get:e=>{const t=r();t&&((e,t,n)=>{let o=e.get(t);o||(o=[],e.set(t,o)),o.some((e=>e.deref()===n))||o.push(new WeakRef(n))})(s,e,t)},set:n=>{const o=s.get(n);if(o){const t=o.filter((t=>{const n=t.deref();return!!n&&e(n)}));s.set(n,t)}t(s)},reset:()=>{s.forEach((t=>{t.forEach((t=>{const n=t.deref();n&&e(n)}))})),t(s)}}})()),e})(),d=e=>{c.state.activeParentScope=a(e)},u=(e,t,n)=>{const o=a(e),r={dataKey:t||"",dataMode:n||s};c.state.parentContexts=Object.assign(Object.assign({},c.state.parentContexts),{[o]:r}),c.state.dataKey=r.dataKey,c.state.dataMode=r.dataMode},i=e=>{const t=e?a(e):c.state.activeParentScope,n=c.state.parentContexts[t];return(null==n?void 0:n.dataKey)?n:{dataKey:c.state.dataKey||"",dataMode:c.state.dataMode||s}};export{u as a,i as g,d as s}