{"version":3,"file":"RtxD2JqO2.CIXBGCTU.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/bmRxsmOaquU0WcZEkWLf/y7tcTEFjTcAxLrriILq1/DownloadStart.js","https:/framerusercontent.com/modules/VsdErFhBudh00vU8pZGE/W8hLutjJbZ7gBvjNcRZY/RtxD2JqO2.js"],"sourcesContent":["// Starts the desktop app download when the bettership.ai \"download started\" page opens (PRO-1917). Every \"Download\n// for macOS\" button on the site links to that page, so the visitor still gets the file with one click and lands on\n// the install steps. It draws nothing visible.\n// The download goes through a hidden iframe rather than by sending the page to the download address: the address\n// answers with a redirect to the file, which a browser saves without leaving the page, but before opening day (and\n// whenever no build can be served) it redirects to the home page instead, and an iframe keeps that from carrying the\n// visitor away from the steps.\n// It does nothing on the Framer canvas, and nothing when the page address carries ?start=0, so the page can be\n// opened to read or check the steps without downloading anything.\n// Each download it starts is counted in PostHog as `desktop_download_started`, with `from_path` naming the page whose\n// Download button was clicked. The site's own PostHog snippet records page views only on a full page load, and the\n// site moves between pages without reloading, so a page view of this page would miss almost every download. The\n// clicked page is noted by `withDownloadSource`, an override on the Download Ask component's button, because by the\n// time this page opens the address bar already shows it.\n// This file is the source of truth for the Framer code file of the same name: change it here, then push it\n// (site/framer/download-start/README.md).\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";// The backend's public download link (PRO-1922): always the latest promoted build.\nconst DOWNLOAD_URL=\"https://api.bettership.ai/desktop/download\";const EVENT=\"desktop_download_started\";const SOURCE_KEY=\"bettership:download-from\";// Session storage can be switched off or full; a missing note only costs the event its `from_path`.\nfunction remember(path){try{window.sessionStorage.setItem(SOURCE_KEY,path);}catch{}}function recall(){try{const path=window.sessionStorage.getItem(SOURCE_KEY);window.sessionStorage.removeItem(SOURCE_KEY);return path;}catch{return null;}}// The page whose Download button was clicked, or, when this page was opened by a full load from another page on the\n// site (a link in a new tab, say), that page. Null for a visit from outside the site.\nfunction sourcePath(){const noted=recall();if(noted)return noted;try{const referrer=new URL(document.referrer);return referrer.origin===window.location.origin?referrer.pathname:null;}catch{return null;}}function shouldStart(target,search){if(target===RenderTarget.canvas||target===RenderTarget.thumbnail||target===RenderTarget.export)return false;return new URLSearchParams(search).get(\"start\")!==\"0\";}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 1\n * @framerIntrinsicHeight 1\n */export default function DownloadStart({url=DOWNLOAD_URL}){// Once per visit to the page: a re-render, or React running the effect twice in development, must not start a\n// second download. Kept on the instance, not the module, because the site moves between pages without reloading,\n// and a visitor who comes back through another Download button should get the file again.\nconst started=useRef(false);useEffect(()=>{if(started.current||!url)return;if(!shouldStart(RenderTarget.current(),window.location.search))return;started.current=true;const frame=document.createElement(\"iframe\");frame.src=url;frame.title=\"Bettership download\";frame.setAttribute(\"aria-hidden\",\"true\");frame.tabIndex=-1;frame.style.cssText=\"position:absolute;width:0;height:0;border:0;visibility:hidden\";document.body.appendChild(frame);// Blocked or not yet loaded PostHog must never stop the download, so this comes after it.\ntry{window.posthog?.capture(EVENT,{from_path:sourcePath()});}catch{}},[url]);return /*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",style:{display:\"block\",width:1,height:1}});}addPropertyControls(DownloadStart,{url:{type:ControlType.String,title:\"Download link\",defaultValue:DOWNLOAD_URL}});// Override for the Download Ask component's button: notes the page the visitor clicked Download on, for the event\n// above. The button's own link still does the navigating.\nexport function withDownloadSource(Component){return props=>/*#__PURE__*/_jsx(Component,{...props,onClick:event=>{remember(window.location.pathname);props.onClick?.(event);}});}\nexport const __FramerMetadata__ = {\"exports\":{\"withDownloadSource\":{\"type\":\"reactHoc\",\"name\":\"withDownloadSource\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"DownloadStart\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"1\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\",\"framerIntrinsicWidth\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadStart.map","// Generated by Framer (719f2c1)\nimport{fontStore}from\"framer\";fontStore.loadFonts([\"GF;IBM Plex Mono-500\",\"GF;IBM Plex Mono-700\",\"GF;IBM Plex Mono-700italic\",\"GF;IBM Plex Mono-500italic\"]);export const fonts=[{explicitInter:true,fonts:[{cssFamilyName:\"IBM Plex Mono\",openType:true,source:\"google\",style:\"normal\",uiFamilyName:\"IBM Plex Mono\",url:\"https://fonts.gstatic.com/s/ibmplexmono/v20/-F6qfjptAgt5VM-kVkqdyU8n3twJ8lJPg-IUDNg.woff2\",weight:\"500\"},{cssFamilyName:\"IBM Plex Mono\",openType:true,source:\"google\",style:\"normal\",uiFamilyName:\"IBM Plex Mono\",url:\"https://fonts.gstatic.com/s/ibmplexmono/v20/-F6qfjptAgt5VM-kVkqdyU8n3pQP8lJPg-IUDNg.woff2\",weight:\"700\"},{cssFamilyName:\"IBM Plex Mono\",openType:true,source:\"google\",style:\"italic\",uiFamilyName:\"IBM Plex Mono\",url:\"https://fonts.gstatic.com/s/ibmplexmono/v20/-F6sfjptAgt5VM-kVkqdyU8n1ioSblJFgsARHNh4zg.woff2\",weight:\"700\"},{cssFamilyName:\"IBM Plex Mono\",openType:true,source:\"google\",style:\"italic\",uiFamilyName:\"IBM Plex Mono\",url:\"https://fonts.gstatic.com/s/ibmplexmono/v20/-F6sfjptAgt5VM-kVkqdyU8n1ioSJlRFgsARHNh4zg.woff2\",weight:\"500\"}]}];export const css=['.framer-m6qFb .framer-styles-preset-1mm4h5e:not(.rich-text-wrapper), .framer-m6qFb .framer-styles-preset-1mm4h5e.rich-text-wrapper p { --framer-font-family: \"IBM Plex Mono\", \"IBM Plex Mono Placeholder\", monospace; --framer-font-family-bold: \"IBM Plex Mono\", \"IBM Plex Mono Placeholder\", monospace; --framer-font-family-bold-italic: \"IBM Plex Mono\", \"IBM Plex Mono Placeholder\", monospace; --framer-font-family-italic: \"IBM Plex Mono\", \"IBM Plex Mono Placeholder\", monospace; --framer-font-open-type-features: \\'blwf\\' on, \\'cv03\\' on, \\'cv04\\' on, \\'cv09\\' on, \\'cv11\\' on; --framer-font-size: 12px; --framer-font-style: normal; --framer-font-style-bold: normal; --framer-font-style-bold-italic: italic; --framer-font-style-italic: italic; --framer-font-variation-axes: normal; --framer-font-weight: 500; --framer-font-weight-bold: 700; --framer-font-weight-bold-italic: 700; --framer-font-weight-italic: 500; --framer-letter-spacing: 0.02em; --framer-line-height: 1.4em; --framer-paragraph-spacing: 20px; --framer-text-alignment: start; --framer-text-color: var(--token-bc77339a-9220-4bf7-ae38-c11fb55027fd); --framer-text-decoration: none; --framer-text-stroke-color: initial; --framer-text-stroke-width: initial; --framer-text-transform: none; }'];export const className=\"framer-m6qFb\";\nexport const __FramerMetadata__ = {\"exports\":{\"className\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"css\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"fonts\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"6MAkBA,SAAS,EAAS,EAAK,CAAC,GAAG,CAAC,EAAO,eAAe,QAAQ,EAAW,CAAI,CAAE,MAAM,CAAC,CAAC,CAAC,SAAS,GAAQ,CAAC,GAAG,CAAC,IAAM,EAAK,EAAO,eAAe,QAAQ,CAAU,EAA+C,OAA7C,EAAO,eAAe,WAAW,CAAU,EAAS,CAAK,MAAM,CAAC,OAAO,IAAK,CAAC,CAE5O,SAAS,GAAY,CAAC,IAAM,EAAM,EAAO,EAAE,GAAG,EAAM,OAAO,EAAM,GAAG,CAAC,IAAM,EAAS,IAAI,IAAI,SAAS,QAAQ,EAAE,OAAO,EAAS,SAAS,EAAO,SAAS,OAAO,EAAS,SAAS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