import TailwindManager from"./mt-tailwind-processor.js";import baseUserConfig from"./mt-tailwind-default-config.js";const isObject=e=>e&&"object"==typeof e&&!Array.isArray(e);function deepMerge(e,...r){const n={...e};for(const t of r)if(isObject(e)&&isObject(t))for(const r in t)isObject(t[r])?r in e?n[r]=deepMerge(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Array.isArray(t[r])&&Array.isArray(e[r])?n[r]=[...e[r],...t[r]]:Object.assign(n,{[r]:t[r]});return n}const WP_VARS_TO_TAILWIND_MAPPINGS=[{sourceKey:"colors",targetKey:"colors"},{sourceKey:"fontFamily",targetKey:"fontFamily"},{sourceKey:"fontSize",targetKey:"fontSize"},{sourceKey:"spacing",targetKey:"spacing"}];function createConfigFragmentFromWpVars(){const e={theme:{extend:{}}};if(!window.amenderThemeVars)return{};for(const{sourceKey:r,targetKey:n}of WP_VARS_TO_TAILWIND_MAPPINGS){const t=window.amenderThemeVars[r];t&&Object.keys(t).length>0&&(e.theme.extend[n]=t)}return e}document.addEventListener("DOMContentLoaded",(()=>{if(!window.MTDynFrontData)return void console.error("Tailwind Manager: MTDynFrontData is not available. Aborting initialization.");const e=createConfigFragmentFromWpVars(),r=deepMerge(baseUserConfig,e),n=new TailwindManager(r);window.TvrMTTailwind=n,n.init()}));