{"version":3,"file":"CalComEmbed.B00t-9gC.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/Q18AnMCxEJa5mKr0R7uN/wBDDcTwpSYDbcUctHu32/CalComEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const NAMESPACE=\"kime-cal-embed\";const ELEMENT_ID=\"kime-cal-inline-embed\";// [KIME-TRACKING] START (added 2026-10-06)\n// Sends demo-booking steps to PostHog and passes the visit's attribution\n// into the Cal.com booking as metadata. Everything is wrapped in try/catch\n// so a tracking failure can never break the booking embed.\n// To revert: delete every block marked [KIME-TRACKING], or restore\n// CalComEmbed_BACKUP_2026_10_06.tsx.\nconst KIME_ATTRIBUTION_KEYS=[\"utm_source\",\"utm_medium\",\"utm_campaign\",\"utm_term\",\"utm_content\",\"gclid\",\"fbclid\",\"gbraid\",\"wbraid\",\"li_fat_id\",\"msclkid\",\"ref\"];// Same sessionStorage key the UTMForwarder component writes to.\nconst KIME_ATTRIBUTION_STORAGE_KEY=\"kime_attribution\";function kimeGetAttribution(){const out={};try{if(typeof window===\"undefined\")return out;try{const raw=window.sessionStorage.getItem(KIME_ATTRIBUTION_STORAGE_KEY);const stored=raw?JSON.parse(raw)||{}:{};KIME_ATTRIBUTION_KEYS.forEach(function(k){if(stored[k])out[k]=String(stored[k]);});}catch(e){// sessionStorage unavailable; ignore\n}const urlParams=new URLSearchParams(window.location.search);KIME_ATTRIBUTION_KEYS.forEach(function(k){const v=urlParams.get(k);if(v)out[k]=v;});const ph=window.posthog;if(ph){const id=typeof ph.get_distinct_id===\"function\"?ph.get_distinct_id():null;if(id)out.ph_distinct_id=String(id);const sid=typeof ph.get_session_id===\"function\"?ph.get_session_id():null;if(sid)out.ph_session_id=String(sid);}}catch(e){// never block the embed\n}return out;}function kimeTrack(event,props){try{if(typeof window===\"undefined\")return;const ph=window.posthog;if(ph&&typeof ph.capture===\"function\")ph.capture(event,props);}catch(e){// never block the embed\n}}// [KIME-TRACKING] END\n/**\n * Cal.com inline embed. The container height mirrors Cal's reported\n * iframe height (no artificial cap), with one exception: when the\n * iframe is on a routing-form route (calLink starts with `forms/`),\n * Cal reserves the booker's full height even though only the short\n * form card is visible. To avoid a big empty band around the form,\n * we clamp the wrapper to `routingFormMaxHeight` while a routing-form\n * route is active, then release the clamp once Cal navigates to the\n * booker route (event-type slug). Detection is done by listening for\n * Cal's `__routeChanged` postMessage events.\n *\n * If `pageBackground` is provided, Cal's internal page background\n * (cal-bg) is overridden so any padding Cal adds inside the iframe\n * blends with the surrounding section. Leave it empty to use Cal's\n * own default. The white booker card (cal-bg-emphasis) is never\n * touched.\n */export default function CalComEmbed({calLink=\"forms/208a102c-c108-454a-ad75-d26cf9b91c40\",theme=\"light\",brandColor=\"#4C7A6D\",pageBackground=\"\",layout=\"month_view\",minHeight=200,routingFormMaxHeight=420}){const initialized=useRef(false);const containerRef=useRef(null);const[contentHeight,setContentHeight]=useState(minHeight);// Whether the iframe is currently on a routing-form route. Start as\n// true when the initial calLink is a routing form so we clamp from\n// the first render, then flip to false once Cal navigates to the\n// booker (or any non-form) route.\nconst[onRoutingForm,setOnRoutingForm]=useState(()=>(calLink||\"\").startsWith(\"forms/\"));// 1) Initialise Cal.com inline embed once\nuseEffect(()=>{if(initialized.current)return;initialized.current=true;(function(C,A,L){const p=(a,ar)=>a.q.push(ar);const d=C.document;C.Cal=C.Cal||function(){const cal=C.Cal;const ar=arguments;if(!cal.loaded){cal.ns={};cal.q=cal.q||[];d.head.appendChild(d.createElement(\"script\")).src=A;cal.loaded=true;}if(ar[0]===L){const api=function(){p(api,arguments);};const ns=ar[1];api.q=api.q||[];if(typeof ns===\"string\"){cal.ns[ns]=cal.ns[ns]||api;p(cal.ns[ns],ar);p(cal,[\"initNamespace\",ns]);}else{p(cal,ar);}return;}p(cal,ar);};})(window,\"https://app.cal.com/embed/embed.js\",\"init\");// Build the css vars per theme — only include cal-bg when the\n// user provided a pageBackground. Otherwise Cal uses its own\n// default light/dark page background.\nconst buildVars=()=>{const vars={\"cal-brand\":brandColor};if(pageBackground&&pageBackground.trim()!==\"\"){vars[\"cal-bg\"]=pageBackground;}return vars;};// [KIME-TRACKING] START: attribution passed to Cal.com as booking metadata\nconst kimeAttribution=kimeGetAttribution();const kimeMetadata={};try{Object.keys(kimeAttribution).forEach(function(k){kimeMetadata[`metadata[${k}]`]=kimeAttribution[k].slice(0,500);});}catch(e){// ignore\n}// [KIME-TRACKING] END\nwindow.Cal(\"init\",NAMESPACE,{origin:\"https://app.cal.com\"});window.Cal.ns[NAMESPACE](\"inline\",{elementOrSelector:`#${ELEMENT_ID}`,config:{layout,useSlotsViewOnSmallScreen:\"true\",theme,...kimeMetadata},calLink});// [KIME-TRACKING] START: forward Cal.com embed events to PostHog\ntry{const kimeCal=window.Cal.ns[NAMESPACE];const kimeBooked={};const kimePage=()=>({...kimeGetAttribution(),cal_link:calLink,page_path:typeof window!==\"undefined\"?window.location.pathname:\"\"});kimeCal(\"on\",{action:\"routed\",callback:()=>kimeTrack(\"demo_form_submitted\",kimePage())});kimeCal(\"on\",{action:\"bookerViewed\",callback:()=>kimeTrack(\"demo_calendar_viewed\",kimePage())});const kimeOnBooked=e=>{try{const data=e?.detail?.data||{};const booking=data.booking||data;const uid=booking?.uid||data?.uid||\"unknown\";if(kimeBooked[uid])return;kimeBooked[uid]=true;const email=booking?.responses?.email||booking?.attendees?.[0]?.email||data?.responses?.email||undefined;kimeTrack(\"demo_booked\",{...kimePage(),booking_uid:uid,event_type_id:data?.eventTypeId??data?.eventType?.id??null,event_type_slug:data?.eventType?.slug??null,booking_start:data?.startTime??booking?.startTime??null});const ph=window.posthog;if(email&&ph&&typeof ph.setPersonProperties===\"function\"){ph.setPersonProperties({email});}}catch(err){// never block the embed\n}};kimeCal(\"on\",{action:\"bookingSuccessfulV2\",callback:kimeOnBooked});kimeCal(\"on\",{action:\"bookingSuccessful\",callback:kimeOnBooked});}catch(e){// never block the embed\n}// [KIME-TRACKING] END\nwindow.Cal.ns[NAMESPACE](\"ui\",{theme,cssVarsPerTheme:{light:buildVars(),dark:buildVars()},hideEventTypeDetails:false,layout});// eslint-disable-next-line react-hooks/exhaustive-deps\n},[]);// 2) Track the iframe's actual rendered height — Cal.com sizes its\n//    iframe to fit content in each state, so we just mirror that.\nuseEffect(()=>{const root=containerRef.current;if(!root)return;let stopped=false;let timer=null;let resizeObs=null;const attach=()=>{if(stopped)return;const iframe=root.querySelector(\"iframe\");if(!iframe){timer=window.setTimeout(attach,200);return;}const update=()=>{const h=iframe.offsetHeight;if(h&&h>0){setContentHeight(Math.max(h,minHeight));}};resizeObs=new ResizeObserver(update);resizeObs.observe(iframe);update();};attach();return()=>{stopped=true;if(timer)window.clearTimeout(timer);resizeObs?.disconnect();};},[minHeight]);// 3) postMessage backup channel — also used to detect route changes\n//    (form -> booker) so we can release the routing-form height clamp.\nuseEffect(()=>{const handler=event=>{if(typeof event.origin!==\"string\"||!event.origin.includes(\"cal.com\")){return;}const d=event.data;if(!d||typeof d!==\"object\")return;const action=d.type||d.action;if(action===\"__dimensionChanged\"){const h=d?.data?.iframeHeight??d?.detail?.data?.iframeHeight;if(typeof h===\"number\"&&h>0){setContentHeight(Math.max(h,minHeight));}return;}if(action===\"__routeChanged\"){// Cal posts a routeChanged event with the new path/url.\n// Common shapes: data.data.pathname, data.detail.data.pathname,\n// data.data.url. Sniff a few fallbacks.\nconst detail=d?.data??d?.detail?.data??{};const path=detail.pathname??detail.path??detail.url??\"\";const isForm=typeof path===\"string\"&&path.includes(\"/forms/\");setOnRoutingForm(isForm);}};window.addEventListener(\"message\",handler);return()=>window.removeEventListener(\"message\",handler);},[minHeight]);// Effective height: when the routing form is showing, clamp so the\n// wrapper doesn't reserve the booker's full height. When the booker\n// (or any non-form) route is showing, use the height Cal reports.\nconst effectiveHeight=onRoutingForm?Math.min(contentHeight,routingFormMaxHeight):contentHeight;return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:`${effectiveHeight}px`,overflow:\"hidden\",transition:\"height 0.45s cubic-bezier(0.4, 0, 0.2, 1)\"},children:/*#__PURE__*/_jsx(\"div\",{id:ELEMENT_ID,ref:containerRef,style:{width:\"100%\",height:\"100%\"}})});}addPropertyControls(CalComEmbed,{calLink:{type:ControlType.String,title:\"Cal Link\",defaultValue:\"forms/208a102c-c108-454a-ad75-d26cf9b91c40\"},theme:{type:ControlType.Enum,title:\"Theme\",options:[\"light\",\"dark\"],defaultValue:\"light\"},brandColor:{type:ControlType.Color,title:\"Brand Color\",defaultValue:\"#4C7A6D\"},pageBackground:{type:ControlType.String,title:\"Cal Page BG\",description:\"Override Cal's page background (cal-bg). Leave empty to use Cal.com's default.\",defaultValue:\"\",placeholder:\"e.g. #4C7A6D or empty for default\"},layout:{type:ControlType.Enum,title:\"Layout\",options:[\"month_view\",\"week_view\",\"column_view\"],defaultValue:\"month_view\"},minHeight:{type:ControlType.Number,title:\"Min Height (px)\",defaultValue:200,min:100,max:600,step:10},routingFormMaxHeight:{type:ControlType.Number,title:\"Form Max Height (px)\",description:\"Max wrapper height while a routing form is showing, so the short form doesn't sit in a big empty band.\",defaultValue:420,min:200,max:800,step:10}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CalComEmbed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CalComEmbed.map"],"mappings":"uMAOsD,SAAS,GAAoB,CAAC,IAAM,EAAI,CAAC,EAAE,GAAG,CAAC,GAAU,IAAS,OAAY,OAAO,EAAI,GAAG,CAAC,IAAM,EAAI,EAAO,eAAe,QAAQ,CAA4B,EAAQ,EAAO,GAAI,KAAK,MAAM,CAAG,GAAM,CAAC,EAAE,EAAsB,QAAQ,SAAS,EAAE,CAAI,EAAO,KAAG,EAAI,GAAG,OAAO,EAAO,EAAE,EAAE,CAAC,CAAE,MAAS,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