{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/SiomRcvyoh8l6TNy7dcV/cQ0aQqNnbLP62ADzKY1A/AppEvent.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";const TEST=false;const COOKIE_NAME_CLIENT_ID=\"client_id\";function setTestCookie(cookieName,cookieValue){if(TEST){// Framer preview is in a iframe, so SameSite needs to be disabled.\nconst documentCookie=`${cookieName}=${cookieValue}; SameSite=None; Secure; Partitioned`;document.cookie=documentCookie;}}function setClientIdTestCookie(){// To do full end-to-end testing, launch sudowrite-express, get the content of the `client_id` cookie and past it there.  When previewing this component, you should be able to see the request going through your local sudowrite-express.\nconst clientId=\"bBxq5kW5Ym5QfNzJDBDalAp1l\";setTestCookie(COOKIE_NAME_CLIENT_ID,clientId);}function getUrl(){if(TEST){return\"http://localhost:5000/api/app-events/\";}else{return\"https://editor.sudowrite.com/api/app-events/\";}}// Extracted from https://github.com/jamesyu/sudowrite-express/blob/c9ccb84b42cf6cb24b8e42db1e46b9083f543e43/client/src/Utils.js#L35\nfunction makeId(length){let result=\"\";const characters=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";const charactersLength=characters.length;for(var i=0;i<length;i++){result+=characters.charAt(Math.floor(Math.random()*charactersLength));}return result;}function getCookie(cookieName){const cookiePrefix=`${cookieName}=`;const cookies=document.cookie.split(\"; \");const cookie=cookies.find(c=>c.startsWith(cookiePrefix));if(!cookie){return undefined;}return cookie.slice(cookiePrefix.length);}function setCookie(cookieName,cookieValue){const documentCookie=`${cookieName}=${cookieValue}; Domain=.sudowrite.com`;document.cookie=documentCookie;}/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/developers/#code-components-auto-sizing\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function AppEvent(props){useEffect(()=>{setClientIdTestCookie();let clientId=getCookie(COOKIE_NAME_CLIENT_ID);if(clientId===undefined){clientId=makeId(25);setCookie(COOKIE_NAME_CLIENT_ID,clientId);}// Using `credentials: \"include\"` triggers CORS.  To simplify things and make everything more robust simply send `clientId` as part of the request data.\nfetch(getUrl(),{headers:{\"Content-Type\":\"application/json\"},method:\"POST\",body:JSON.stringify({name:\"Homepage View\",clientId})}).then(response=>response.text()).then(text=>{if(TEST){console.log(text);}});},[]);return /*#__PURE__*/_jsx(\"div\",{});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AppEvent\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AppEvent.map"],
  "mappings": "gDAAwE,IAAMA,EAAK,GAAYC,EAAsB,YAAY,SAASC,EAAcC,EAAWC,EAAY,CAAC,GAAGJ,EAAK,CACxL,IAAMK,EAAe,GAAGF,CAAU,IAAIC,CAAW,uCAAuC,SAAS,OAAOC,CAAe,CAAC,CAAC,SAASC,GAAuB,CAC9GJ,EAAcD,EAA1C,2BAAwE,CAAE,CAAC,SAASM,GAAQ,CAAC,OAAGP,EAAY,wCAAoD,8CAAgD,CAC/N,SAASQ,EAAOC,EAAO,CAAC,IAAIC,EAAO,GAASC,EAAW,iEAAuEC,EAAiBD,EAAW,OAAO,QAAQ,EAAE,EAAE,EAAEF,EAAO,IAAKC,GAAQC,EAAW,OAAO,KAAK,MAAM,KAAK,OAAO,EAAEC,CAAgB,CAAC,EAAG,OAAOF,CAAO,CAAC,SAASG,EAAUV,EAAW,CAAC,IAAMW,EAAa,GAAGX,CAAU,IAAoDY,EAAlC,SAAS,OAAO,MAAM,IAAI,EAAuB,KAAKC,GAAGA,EAAE,WAAWF,CAAY,CAAC,EAAE,GAAIC,EAA0B,OAAOA,EAAO,MAAMD,EAAa,MAAM,CAAE,CAAC,SAASG,EAAUd,EAAWC,EAAY,CAAC,IAAMC,EAAe,GAAGF,CAAU,IAAIC,CAAW,0BAA0B,SAAS,OAAOC,CAAe,CAMloB,SAARa,EAA0BC,EAAM,CAAC,OAAAC,EAAU,IAAI,CAACd,EAAsB,EAAE,IAAIe,EAASR,EAAUZ,CAAqB,EAAKoB,IAAW,SAAWA,EAASb,EAAO,EAAE,EAAES,EAAUhB,EAAsBoB,CAAQ,GACrN,MAAMd,EAAO,EAAE,CAAC,QAAQ,CAAC,eAAe,kBAAkB,EAAE,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,KAAK,gBAAgB,SAAAc,CAAQ,CAAC,CAAC,CAAC,EAAE,KAAKC,GAAUA,EAAS,KAAK,CAAC,EAAE,KAAKC,GAAM,CAAIvB,GAAM,QAAQ,IAAIuB,CAAI,CAAG,CAAC,CAAE,EAAE,CAAC,CAAC,EAAsBC,EAAK,MAAM,CAAC,CAAC,CAAE",
  "names": ["TEST", "COOKIE_NAME_CLIENT_ID", "setTestCookie", "cookieName", "cookieValue", "documentCookie", "setClientIdTestCookie", "getUrl", "makeId", "length", "result", "characters", "charactersLength", "getCookie", "cookiePrefix", "cookie", "c", "setCookie", "AppEvent", "props", "ue", "clientId", "response", "text", "p"]
}
