{"version":3,"file":"UTMTracker.CQ4PyY0s.mjs","names":["useState","e"],"sources":["https:/framerusercontent.com/modules/7EK3fys7uvPGKNzuJb87/Xx0OcG70Ei2yvIf6ARbz/UTMTracker.js"],"sourcesContent":["// UTM Tracker for Framer Forms - Captures and stores UTM parameters from URL\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * UTM Tracker\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 100\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function UTMTracker(props){const{storageKey,expiryDays,trackParameters,showDebug,debugBackground,debugTextColor,debugFont}=props;const[utmData,setUtmData]=useState({});useEffect(()=>{if(typeof window===\"undefined\")return;const urlParams=new URLSearchParams(window.location.search);const newUtmData={};let hasNewData=false;trackParameters.forEach(param=>{const value=urlParams.get(param);if(value){newUtmData[param]=value;hasNewData=true;}});if(hasNewData){const dataToStore={...newUtmData,timestamp:new Date().toISOString()};try{localStorage.setItem(storageKey,JSON.stringify(dataToStore));startTransition(()=>setUtmData(newUtmData));}catch(e){console.error(\"Failed to store UTM data:\",e);}}else{try{const stored=localStorage.getItem(storageKey);if(stored){const parsed=JSON.parse(stored);const timestamp=new Date(parsed.timestamp);const now=new Date;const daysDiff=(now.getTime()-timestamp.getTime())/(1e3*60*60*24);if(daysDiff<expiryDays){delete parsed.timestamp;startTransition(()=>setUtmData(parsed));}else{localStorage.removeItem(storageKey);}}}catch(e){console.error(\"Failed to retrieve UTM data:\",e);}}const handleFormSubmit=e=>{const form=e.target;if(!form||form.tagName!==\"FORM\")return;try{const stored=localStorage.getItem(storageKey);if(stored){const parsed=JSON.parse(stored);delete parsed.timestamp;Object.entries(parsed).forEach(([key,value])=>{let input=form.querySelector(`input[name=\"${key}\"]`);if(!input){input=document.createElement(\"input\");input.type=\"hidden\";input.name=key;form.appendChild(input);}input.value=value;});}}catch(e){console.error(\"Failed to attach UTM data to form:\",e);}};document.addEventListener(\"submit\",handleFormSubmit,true);return()=>{document.removeEventListener(\"submit\",handleFormSubmit,true);};},[storageKey,expiryDays,trackParameters]);if(!showDebug)return null;const hasData=Object.keys(utmData).length>0;return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",backgroundColor:debugBackground,color:debugTextColor,padding:16,borderRadius:8,overflow:\"auto\",...debugFont},children:[/*#__PURE__*/_jsx(\"div\",{style:{marginBottom:8,fontWeight:600},children:\"UTM Tracker Debug\"}),hasData?/*#__PURE__*/_jsx(\"div\",{children:Object.entries(utmData).map(([key,value])=>/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:4},children:[/*#__PURE__*/_jsxs(\"span\",{style:{opacity:.7},children:[key,\":\"]}),\" \",value]},key))}):/*#__PURE__*/_jsx(\"div\",{style:{opacity:.5},children:\"No UTM parameters detected\"})]});}addPropertyControls(UTMTracker,{storageKey:{type:ControlType.String,title:\"Storage Key\",defaultValue:\"framer_utm_data\"},expiryDays:{type:ControlType.Number,title:\"Expiry Days\",defaultValue:30,min:1,max:365,step:1},trackParameters:{type:ControlType.Array,title:\"Track Parameters\",control:{type:ControlType.String},defaultValue:[\"utm_source\",\"utm_medium\",\"utm_campaign\",\"utm_term\",\"utm_content\"]},showDebug:{type:ControlType.Boolean,title:\"Show Debug\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},debugBackground:{type:ControlType.Color,title:\"Debug Background\",defaultValue:\"#F5F5F5\",hidden:({showDebug})=>!showDebug},debugTextColor:{type:ControlType.Color,title:\"Debug Text\",defaultValue:\"#000000\",hidden:({showDebug})=>!showDebug},debugFont:{type:ControlType.Font,title:\"Debug Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"},hidden:({showDebug})=>!showDebug}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"UTMTracker\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"300\",\"framerIntrinsicHeight\":\"100\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./UTMTracker.map"],"mappings":"8MASG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,aAAW,aAAW,kBAAgB,YAAU,kBAAgB,iBAAe,aAAW,EAAW,CAAC,EAAQ,GAAYA,EAAS,EAAE,CAAC,CAAklD,GAAjlD,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAU,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAO,EAAW,EAAE,CAAK,EAAW,GAA6H,GAAvH,EAAgB,QAAQ,GAAO,CAAC,IAAM,EAAM,EAAU,IAAI,EAAM,CAAI,IAAO,EAAW,GAAO,EAAM,EAAW,KAAQ,CAAI,EAAW,CAAC,IAAM,EAAY,CAAC,GAAG,EAAW,UAAU,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,aAAa,QAAQ,EAAW,KAAK,UAAU,EAAY,CAAC,CAAC,MAAoB,EAAW,EAAW,CAAC,OAAQ,EAAE,CAAC,QAAQ,MAAM,4BAA4B,EAAE,OAAQ,GAAG,CAAC,IAAM,EAAO,aAAa,QAAQ,EAAW,CAAC,GAAG,EAAO,CAAC,IAAM,EAAO,KAAK,MAAM,EAAO,CAAO,EAAU,IAAI,KAAK,EAAO,UAAU,EAAW,IAAI,MAAI,CAAqB,SAAS,CAAC,EAAU,SAAS,GAAG,IAAI,GAAG,GAAG,IAAgB,GAAY,OAAO,EAAO,UAAU,MAAoB,EAAW,EAAO,CAAC,EAAO,aAAa,WAAW,EAAW,QAAU,EAAE,CAAC,QAAQ,MAAM,+BAA+B,EAAE,CAAG,I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