{"version":3,"file":"DeferredAnalytics.5RLa0_VW.mjs","names":[],"sources":["https:/framerusercontent.com/modules/JpNlTqlcZjT61tjNHBxX/Nlu3IFOQ68R4gT6QXM78/DeferredAnalytics.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// ─────────────────────────────────────────────────────────────────────────────\n// PageMetaTags\n// Injects title, meta description, canonical URL, Open Graph, and Twitter Card\n// tags into document.head at runtime. Picked up by Googlebot's JS-rendering pass.\n//\n// Usage: Add (invisible, 1×1) to any page canvas. Fill props directly or\n// connect to CMS fields for dynamic pages (blog/:slug, service-area/:slug).\n//\n// Auto-detection (enabled by default):\n//   - Title: reads first <h1> on page → sets document.title as \"[Title] | MoJo Home Services\"\n//   - Canonical: auto-builds from window.location (no trailing slash, no query string)\n// ─────────────────────────────────────────────────────────────────────────────\nconst SITE_NAME=\"MoJo Home Services\";const SITE_SUFFIX=` | ${SITE_NAME}`;function upsertMeta(selector,attrKey,attrVal,contentVal){if(!contentVal)return;let el=document.head.querySelector(selector);if(!el){el=document.createElement(\"meta\");el.setAttribute(attrKey,attrVal);document.head.appendChild(el);}el.setAttribute(\"content\",contentVal);}function upsertLink(rel,href){if(!href)return;let el=document.head.querySelector(`link[rel=\"${rel}\"]`);if(!el){el=document.createElement(\"link\");el.setAttribute(\"rel\",rel);document.head.appendChild(el);}el.setAttribute(\"href\",href);}/** Read the first meaningful h1 from the rendered page (skips empty/whitespace). */function detectH1(){const h1s=document.querySelectorAll(\"h1\");for(const h1 of Array.from(h1s)){const text=(h1.textContent||\"\").trim();if(text.length>5)return text;}return\"\";}/** Build canonical URL from current location: origin + pathname, no trailing slash, no query. */function detectCanonical(){const{origin,pathname}=window.location;const clean=pathname===\"/\"?origin:origin+pathname.replace(/\\/$/,\"\");return clean;}export function PageMetaTags({pageTitle=\"\",metaDescription=\"\",canonicalUrl=\"\",ogTitle=\"\",ogDescription=\"\",ogImage=\"\",ogType=\"website\",articlePublishedTime=\"\",articleModifiedTime=\"\"}){useEffect(()=>{// ── Title resolution ──────────────────────────────────────────────────\n// Priority: explicit pageTitle prop → CMS-bound title\n//           → first h1 on the page (auto-detected from rendered DOM)\n//           → current document.title (Framer site default)\nconst rawTitle=pageTitle.trim()||detectH1();const fullTitle=rawTitle?rawTitle.endsWith(SITE_SUFFIX)?rawTitle:rawTitle+SITE_SUFFIX:document.title;if(rawTitle){document.title=fullTitle;}// ── Canonical resolution ──────────────────────────────────────────────\n// Priority: explicit canonicalUrl prop → auto-detected from window.location\nconst resolvedCanonical=canonicalUrl.trim()||detectCanonical();// ── OG / Twitter resolution ───────────────────────────────────────────\nconst resolvedTitle=ogTitle.trim()||fullTitle;const resolvedDesc=ogDescription.trim()||metaDescription;// ── Inject tags ───────────────────────────────────────────────────────\nif(metaDescription){upsertMeta('meta[name=\"description\"]',\"name\",\"description\",metaDescription);}upsertLink(\"canonical\",resolvedCanonical);upsertMeta('meta[property=\"og:site_name\"]',\"property\",\"og:site_name\",SITE_NAME);upsertMeta('meta[property=\"og:type\"]',\"property\",\"og:type\",ogType);upsertMeta('meta[property=\"og:title\"]',\"property\",\"og:title\",resolvedTitle);upsertMeta('meta[property=\"og:description\"]',\"property\",\"og:description\",resolvedDesc);upsertMeta('meta[property=\"og:url\"]',\"property\",\"og:url\",resolvedCanonical);upsertMeta('meta[property=\"og:image\"]',\"property\",\"og:image\",ogImage);if(ogImage){upsertMeta('meta[property=\"og:image:width\"]',\"property\",\"og:image:width\",\"1200\");upsertMeta('meta[property=\"og:image:height\"]',\"property\",\"og:image:height\",\"630\");}if(ogType===\"article\"){upsertMeta('meta[property=\"article:published_time\"]',\"property\",\"article:published_time\",articlePublishedTime);upsertMeta('meta[property=\"article:modified_time\"]',\"property\",\"article:modified_time\",articleModifiedTime);upsertMeta('meta[property=\"article:publisher\"]',\"property\",\"article:publisher\",\"https://www.facebook.com/profile.php?id=61578586713218\");}upsertMeta('meta[name=\"twitter:card\"]',\"name\",\"twitter:card\",\"summary_large_image\");upsertMeta('meta[name=\"twitter:site\"]',\"name\",\"twitter:site\",\"@mojoyourhomes\");upsertMeta('meta[name=\"twitter:title\"]',\"name\",\"twitter:title\",resolvedTitle);upsertMeta('meta[name=\"twitter:description\"]',\"name\",\"twitter:description\",resolvedDesc);upsertMeta('meta[name=\"twitter:image\"]',\"name\",\"twitter:image\",ogImage);},[pageTitle,metaDescription,canonicalUrl,ogTitle,ogDescription,ogImage,ogType,articlePublishedTime,articleModifiedTime]);return /*#__PURE__*/_jsx(\"div\",{style:{width:1,height:1,overflow:\"hidden\",opacity:0}});}PageMetaTags.displayName=\"Page Meta Tags\";addPropertyControls(PageMetaTags,{pageTitle:{type:ControlType.String,title:\"Page Title\",defaultValue:\"\",description:\"Connect to CMS 'Title' field. Auto-reads from page h1 if blank. Renders as '[Title] | MoJo Home Services'.\"},metaDescription:{type:ControlType.String,title:\"Meta Description\",defaultValue:\"\",description:\"Connect to CMS 'Meta Description' field. 150–160 chars.\",displayTextArea:true},canonicalUrl:{type:ControlType.String,title:\"Canonical URL\",defaultValue:\"\",description:\"Leave blank to auto-detect from page URL. Or set explicitly: https://mojoyourhomes.com/blog/slug\"},ogTitle:{type:ControlType.String,title:\"OG Title\",defaultValue:\"\",description:\"Social share title. Falls back to Page Title if blank.\"},ogDescription:{type:ControlType.String,title:\"OG Description\",defaultValue:\"\",description:\"Social share description. Falls back to Meta Description if blank.\",displayTextArea:true},ogImage:{type:ControlType.Image,title:\"OG Image (1200x630)\",description:\"Image shown on Facebook, LinkedIn, Twitter/X shares.\"},ogType:{type:ControlType.Enum,title:\"OG Type\",options:[\"website\",\"article\"],optionTitles:[\"Website\",\"Article (blog posts)\"],defaultValue:\"website\"},articlePublishedTime:{type:ControlType.String,title:\"Published Date\",defaultValue:\"\",description:\"Connect to CMS 'Date Published'. ISO 8601 e.g. 2026-01-15. Article type only.\"},articleModifiedTime:{type:ControlType.String,title:\"Modified Date\",defaultValue:\"\",description:\"ISO 8601 e.g. 2026-03-01. Article type only.\"}});export function DeferredAnalytics({ga4Id=\"G-NHQ3J9MVHQ\",clarityId=\"u4o5ob3xde\",delayMs=0,enableGA4=true,enableClarity=true}){useEffect(()=>{const load=()=>{const run=()=>{if(enableGA4&&ga4Id)loadGA4(ga4Id);if(enableClarity&&clarityId)loadClarity(clarityId);};if(delayMs>0){setTimeout(run,delayMs);}else{run();}};if(document.readyState===\"complete\"){load();}else{window.addEventListener(\"load\",load,{once:true});return()=>window.removeEventListener(\"load\",load);}},[ga4Id,clarityId,delayMs,enableGA4,enableClarity]);return /*#__PURE__*/_jsx(\"div\",{style:{width:1,height:1,overflow:\"hidden\",opacity:0}});}function loadGA4(measurementId){if(document.querySelector(`script[src*=\"${measurementId}\"]`))return;const s=document.createElement(\"script\");s.src=`https://www.googletagmanager.com/gtag/js?id=${measurementId}`;s.async=true;document.head.appendChild(s);window.dataLayer=window.dataLayer||[];function gtag(...args){window.dataLayer.push(args);}window.gtag=gtag;gtag(\"js\",new Date);gtag(\"config\",measurementId);}function loadClarity(projectId){if(window.clarity)return;(function(c,l,a,r,i){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments);};const t=l.createElement(r);t.async=1;t.src=\"https://www.clarity.ms/tag/\"+i;const y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window,document,\"clarity\",\"script\",projectId);}DeferredAnalytics.displayName=\"Deferred Analytics\";addPropertyControls(DeferredAnalytics,{enableGA4:{type:ControlType.Boolean,title:\"Enable GA4\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},ga4Id:{type:ControlType.String,title:\"GA4 ID\",defaultValue:\"G-NHQ3J9MVHQ\",description:\"Google Analytics 4 Measurement ID (e.g. G-XXXXXXXXXX)\",hidden:props=>!props.enableGA4},enableClarity:{type:ControlType.Boolean,title:\"Enable Clarity\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},clarityId:{type:ControlType.String,title:\"Clarity ID\",defaultValue:\"u4o5ob3xde\",description:\"Microsoft Clarity Project ID\",hidden:props=>!props.enableClarity},delayMs:{type:ControlType.Number,title:\"Delay (ms)\",defaultValue:0,min:0,max:1e4,step:500,description:\"Extra delay after page load before injecting scripts\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"DeferredAnalytics\":{\"type\":\"reactComponent\",\"name\":\"DeferredAnalytics\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"PageMetaTags\":{\"type\":\"reactComponent\",\"name\":\"PageMetaTags\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DeferredAnalytics.map"],"mappings":"oLAYyE,SAAS,EAAW,EAAS,EAAQ,EAAQ,EAAW,CAAC,GAAG,CAAC,EAAW,OAAO,IAAI,EAAG,SAAS,KAAK,cAAc,EAAS,CAAK,IAAI,EAAG,SAAS,cAAc,OAAO,CAAC,EAAG,aAAa,EAAQ,EAAQ,CAAC,SAAS,KAAK,YAAY,EAAG,EAAE,EAAG,aAAa,UAAU,EAAW,CAAE,SAAS,EAAW,EAAI,EAAK,CAAC,GAAG,CAAC,EAAK,OAAO,IAAI,EAAG,SAAS,KAAK,cAAc,aAAa,EAAI,IAAI,CAAK,IAAI,EAAG,SAAS,cAAc,OAAO,CAAC,EAAG,aAAa,MAAM,EAAI,CAAC,SAAS,KAAK,YAAY,EAAG,EAAE,EAAG,aAAa,OAAO,EAAK,CAAsF,SAAS,GAAU,CAAC,IAAM,EAAI,SAAS,iBAAiB,KAAK,CAAC,IAAI,IAAM,KAAM,MAAM,KAAK,EAAI,CAAC,CAAC,IAAM,GAAM,EAAG,aAAa,IAAI,MAAM,CAAC,GAAG,EAAK,OAAO,EAAE,OAAO,EAAM,MAAM,GAAqG,SAAS,GAAiB,CAAC,GAAK,CAAC,SAAO,YAAU,EAAO,SAA6E,OAAxD,IAAW,IAAI,EAAO,EAAO,EAAS,QAAQ,MAAM,GAAG,C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