{"version":3,"file":"FunnelAnalyticsRuntime.BbOBOf-M.mjs","names":[],"sources":["https:/framerusercontent.com/modules/HpGSkwV8wOa6acqpxvy8/mUsTapkewLKPksE7ZpOb/FunnelAnalyticsRuntime.js"],"sourcesContent":["// @ts-nocheck\n// TODAY, LIFTING funnel analytics runtime v1.1 (2026-09-15)\n// Lightweight, non-blocking event tracking.\n// Safe to import from public Framer code components.\n//\n// v1.1\n// - Keeps analytics fire-and-forget.\n// - Surfaces Supabase RPC errors in the browser console.\n// - Does NOT block search, navigation, favorite actions, or rendering.\nconst VISITOR_KEY=\"tl_funnel_visitor_id_v1\";const SESSION_KEY=\"tl_funnel_session_v1\";const FIRST_TOUCH_KEY=\"tl_funnel_first_touch_v1\";const SESSION_TTL_MS=30*60*1e3;function uuid(){try{if(typeof crypto!==\"undefined\"&&typeof crypto.randomUUID===\"function\"){return crypto.randomUUID();}}catch(_){}return`tl_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,12)}`;}function safeGet(storage,key){try{return storage?.getItem(key)??\"\";}catch(_){return\"\";}}function safeSet(storage,key,value){try{storage?.setItem(key,value);}catch(_){}}export function getFunnelIdentity(){if(typeof window===\"undefined\"){return{visitorId:\"\",sessionId:\"\"};}let visitorId=safeGet(window.localStorage,VISITOR_KEY);if(!visitorId){visitorId=uuid();safeSet(window.localStorage,VISITOR_KEY,visitorId);}const now=Date.now();let session=null;try{session=JSON.parse(safeGet(window.sessionStorage,SESSION_KEY)||\"null\");}catch(_){}if(!session?.id||!session?.last||now-Number(session.last)>SESSION_TTL_MS){session={id:uuid(),last:now};}else{session.last=now;}safeSet(window.sessionStorage,SESSION_KEY,JSON.stringify(session));return{visitorId,sessionId:String(session.id)};}function classifySource(raw,referrer){const s=String(raw??\"\").toLowerCase();const r=String(referrer??\"\").toLowerCase();if(s.includes(\"instagram\")||r.includes(\"instagram.com\")){return\"Instagram\";}if(s.includes(\"youtube\")||s.includes(\"youtu\")||r.includes(\"youtube.com\")||r.includes(\"youtu.be\")){return\"YouTube\";}if(s.includes(\"naver\")||r.includes(\"naver.com\")){return\"Naver\";}if(s.includes(\"google\")||r.includes(\"google.\")){return\"Google\";}if(s.includes(\"kakao\")||r.includes(\"kakao\")){return\"Kakao\";}if(!raw&&!referrer){return\"Direct\";}return\"Other\";}function getFirstTouch(){if(typeof window===\"undefined\"){return{};}const existing=safeGet(window.localStorage,FIRST_TOUCH_KEY);if(existing){try{return JSON.parse(existing);}catch(_){}}const url=new URL(window.location.href);const rawSource=url.searchParams.get(\"utm_source\")||\"\";const referrer=String(document.referrer||\"\");const touch={source:classifySource(rawSource,referrer),medium:url.searchParams.get(\"utm_medium\")||\"\",campaign:url.searchParams.get(\"utm_campaign\")||\"\",content:url.searchParams.get(\"utm_content\")||\"\",referrer,landingPath:`${url.pathname}${url.search}`};safeSet(window.localStorage,FIRST_TOUCH_KEY,JSON.stringify(touch));return touch;}export function trackFunnelEvent(options){if(typeof window===\"undefined\"||!options?.supabase){return;}const{visitorId,sessionId}=getFunnelIdentity();if(!visitorId||!sessionId){return;}const touch=getFirstTouch();const path=`${window.location.pathname}${window.location.search}`;const width=Number(window.innerWidth||0);const deviceType=width<=767?\"Mobile\":width<=1100?\"Tablet\":\"Desktop\";const payload={p_visitor_id:visitorId,p_session_id:sessionId,p_event_name:options.eventName,p_source:touch.source||\"Direct\",p_medium:touch.medium||null,p_campaign:touch.campaign||null,p_content:touch.content||null,p_landing_path:touch.landingPath||path,p_current_path:path,p_referrer:touch.referrer||null,p_device_type:deviceType,p_hospital_id:options.hospitalId||null,p_search_query:options.searchQuery||null,p_province:options.province||null,p_district:options.district||null,p_equipment_codes:Array.isArray(options.equipmentCodes)?options.equipmentCodes:[],p_properties:options.properties||{}};/*\n     * IMPORTANT\n     *\n     * Analytics must never delay:\n     * - page rendering\n     * - search\n     * - hospital navigation\n     * - favorite saving\n     *\n     * Therefore this remains fire-and-forget.\n     *\n     * Supabase RPC errors are usually returned as\n     * { data, error } rather than rejected Promises.\n     * v1.1 exposes those errors in DevTools only.\n     */void options.supabase.rpc(\"tl_track_funnel_event\",payload).then(result=>{const error=result?.error;if(error){console.error(\"[TodayLifting Funnel] tracking failed:\",options.eventName,error);}}).catch(error=>{console.error(\"[TodayLifting Funnel] unexpected tracking error:\",options.eventName,error);});}\nexport const __FramerMetadata__ = {\"exports\":{\"trackFunnelEvent\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getFunnelIdentity\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FunnelAnalyticsRuntime.map"],"mappings":"oGASqK,SAAS,GAAM,CAAC,GAAG,CAAC,GAAG,OAAO,OAAS,KAAa,OAAO,OAAO,YAAa,WAAY,OAAO,OAAO,WAAW,CAAG,MAAS,CAAC,CAAC,MAAM,MAAM,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,GAAI,CAAC,SAAS,EAAQ,EAAQ,EAAI,CAAC,GAAG,CAAC,OAAO,GAAS,QAAQ,CAAG,GAAG,EAAG,MAAS,CAAC,MAAM,EAAG,CAAC,CAAC,SAAS,EAAQ,EAAQ,EAAI,EAAM,CAAC,GAAG,CAAC,GAAS,QAAQ,EAAI,CAAK,CAAE,MAAS,CAAC,CAAC,CAAC,SAAgB,GAAmB,CAAC,GAAU,IAAS,OAAa,MAAM,CAAC,UAAU,GAAG,UAAU,EAAE,EAAG,IAAI,EAAU,EAAQ,EAAO,aAAa,CAAW,EAAM,IAAW,EAAU,EAAK,EAAE,EAAQ,EAAO,aAAa,EAAY,CAAS,GAAG,IAAM,EAAI,KAAK,IAAI,EAAM,EAAQ,KAAK,GAAG,CAAC,EAAQ,KAAK,MAAM,EAAQ,EAAO,eAAe,CAAW,GAAG,MAAM,CAAE,MAAS,CAAC,CAAmM,MAA/L,CAAC,GAAS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