{"version":3,"file":"WithTracking.CsWaCsAx.mjs","names":["useRef","_Fragment","useState","useCallback","SecondaryButtonLink","ls","uuidv4"],"sources":["https:/framerusercontent.com/modules/qJPiKjRvr8oGiKkDz7hn/KPtnKv0V0yG1G5fsYRNU/WithTracking.js"],"sourcesContent":["function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import ls from\"local-storage\";import{v4 as uuidv4}from\"uuid\";import SecondaryButtonLink from\"https://framer.com/m/SecondaryButtonLink-Lc7J.js@5c2AzjRU9txYO9kLkJII\";import{useEffect,useCallback,useState,useRef}from\"react\";import{useInView}from\"framer\";const TRACKING_URL=\"https://cluster.mage.ai/mageai-3345-dev/api/pipeline_schedules/1/pipeline_runs/07af532756ce4ff3bd1a31b96805a400\";class SessionTracker{getSessionUUID(){if(typeof window===\"undefined\"||!window.localStorage){// throw new Error(\"localStorage is not available\")\nconsole.log(\"localStorage is not available, but it’s okay because it’s available when the page is live\");}// @ts-ignore\nconst uuid=ls.get(this.STORAGE_KEY)??uuidv4();// @ts-ignore\nls.set(this.STORAGE_KEY,uuid);return uuid;}constructor(){_define_property(this,\"STORAGE_KEY\",\"__planeswalker_power_level\");}}export const sessionTracker=new SessionTracker;function queryFromUrl(url=null){const query={};let urlToTest=url;if(!url&&typeof window!==\"undefined\"){urlToTest=window.location.search;}if(urlToTest){const params=new URLSearchParams(urlToTest.split(\"?\").slice(1).join(\"\"));// @ts-ignore\nArray.from(params.keys()).forEach(key=>{const isList=key.match(/\\[\\]/);// @ts-ignore\nconst values=params.getAll(key);if(values.length===1&&!isList){[query[key]]=values;}else{// @ts-ignore\nquery[key]=values;}});}return query;}async function track(event,props){const{action,uuid,component,section,shadow,payload:_payload,...rest}=props;const props2=props?.children?findButtonComponent(props?.children):{};const session=sessionTracker.getSessionUUID();// console.log(\"WTFFFFFFFFFFF\", props, props2)\nconst tags={action,uuid,component:[component,props?.text,props?.label,props?.ariaLabel,props?.[\"aria-label\"],typeof props?.children===\"string\"?props?.children:null,props2?.ariaLabel,props2?.[\"aria-label\"],typeof props2?.children===\"string\"?props2?.children:null,typeof props2===\"string\"?props2:null].filter(Boolean)[0],section,path:null,url:null,payload:_payload};if(typeof window!==\"undefined\"){const path=typeof window!==\"undefined\"?window.location.pathname:\"\";const url=window.location.href;tags.path=path;tags.url=url;}const payload={event:{action,tags},source:\"marketing\",service:\"framer\",ts:Number(new Date),user:{uuid:session}};// console.log(payload)\nreturn await window.fetch(TRACKING_URL,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(payload)}).then(data=>{// console.log(\"SUCCESS\", data)\n// timeoutRef.current = setTimeout(() => {\n//     setStore({ modalVisible: false })\n// }, 3000)\n}).catch(error=>{console.error(\"ERROR\",error);throw error;}).finally(()=>{// console.log(\"FINALLY\")\n});}function findButtonComponent(nodes){if(!nodes)return null;// Handle function nodes\nif(typeof nodes===\"function\"){return findButtonComponent(nodes());}// Handle single node\nif(!Array.isArray(nodes)){const ps=nodes?.props??nodes;// Check if this node has children as a string\nif(ps?.children&&typeof ps.children===\"string\"){return ps.children;}// Check if it matches button criteria\nif(ps&&(ps?.buttonText&&ps?.action&&(ps?.uuid||ps?.link)||ps?.text||ps?.ariaLabel||ps?.[\"aria-label\"]||nodes?.href)){// Added href check\nreturn nodes;}// Check nested children properties\nif(ps?.children){// If children is a function\nif(typeof ps.children===\"function\"){const resolvedJSX=ps.children([]);const found=findButtonComponent(resolvedJSX);if(found)return found;}else{const childrenArray=Array.isArray(ps.children)?ps.children:[ps.children];const found=findButtonComponent(childrenArray);if(found)return found;}}// Inspect properties recursively if they might contain components\nfor(const key in ps){if(typeof ps[key]===\"object\"&&ps[key]!==null){const found=findButtonComponent(ps[key]);if(found)return found;}}return null;}// Handle array of nodes\nfor(const node of nodes){const found=findButtonComponent(node);if(found)return found;}return null;}export function withTracking(Component){return({onClick:__onClick,...props})=>{let button=props.children?findButtonComponent(props.children):null;if(!button){button=findButtonComponent([props]);}// console.log(\"WTFFFFFFFFFFFFFFFFF\", props, button)\nconst onClick=async event=>{await track(event,{...props,...button?.props});__onClick&&__onClick(event);};const el=/*#__PURE__*/_jsx(Component,{...props,...button?.props?{disableLink:true}:{},onClick:onClick});const{asLink,link,newTab}=button?.props??{};console.log(\"WTFFFFFFFFFFFFFFFFFFF\",props);if(button){return el;}return /*#__PURE__*/_jsx(\"a\",{onClick:onClick,href:link,target:newTab?\"_blank\":undefined,style:{cursor:\"pointer !important\",textDecoration:\"none\",color:\"unset\"},children:el});};}export function withImpression(Component){return props=>{const ref=useRef(null);const isInView=useInView(ref);const trackedRef=useRef(false);useEffect(()=>{const __track=async()=>await track(null,{...props,action:\"impression\"});if(!trackedRef.current&&isInView){trackedRef.current=true;__track();}},[isInView]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{ref:ref}),/*#__PURE__*/_jsx(Component,{...props})]});};}export function withSubmit(Component){return({onSubmit,...props})=>{const ref=useRef(null);const[isSubmitting,setIsSubmitting]=useState(false);const[success,setSuccess]=useState(false);const[videoSrc,setVideoSrc]=useState(\"\");const handleSubmit=useCallback(async event=>{event.preventDefault();event.stopPropagation();setIsSubmitting(true);const form=ref.current;if(!form){console.error(`No form found for ${ref.current}`);setIsSubmitting(false);return;}const formData=new FormData(form);const payload={};formData.forEach((value,key)=>{payload[key]=value;});// console.log('SSSSSSSSSSSSSSSSSSSSSSSSSSS', formData, payload)\ntry{await track(event,{...props,action:\"submit\",payload});}catch(error){}finally{}try{// If you're unsure whether H is accessible directly, you can use window.H to be safe\nwindow.H.identify(payload?.email,{id:sessionTracker.getSessionUUID(),name:payload?.name});}catch(error){console.error(\"Error identifying user\",error);}return await window.fetch(\"https://cluster.mage.ai/mageai-3345-dev/api/pipeline_schedules/4/pipeline_runs/9e1b48a47f974c7386911b4e0250c7cf\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({payload})}).then(response=>{setSuccess(true);setVideoSrc(\"https://framerusercontent.com/assets/bNXxdIHquy660W8yOu7mPDJzY.mp4\");onSubmit&&onSubmit?.();ls.set(\"booking_image_urls\",[]);}).catch(error=>{console.error(\"Form submission error:\",error);throw error;}).finally(()=>{setIsSubmitting(false);});},[]);useEffect(()=>{if(ref.current){const form=ref.current;form?.addEventListener(\"submit\",handleSubmit);return()=>{form?.removeEventListener(\"submit\",handleSubmit);};}},[handleSubmit]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:20,...!success||isSubmitting?{opacity:0,position:\"absolute\",zIndex:-1,visibility:\"hidden\",height:0,width:0}:{}},children:[/*#__PURE__*/_jsx(\"p\",{style:{fontSize:14,fontFamily:\"Inter\"},children:\"Thank you for sending your request. Our team of interior designers will reach out to you in less than 24 hours to review your details.\"}),/*#__PURE__*/_jsx(\"video\",{src:videoSrc,autoPlay:true,loop:true,muted:true,playsInline:true,style:{cursor:\"auto\",width:\"100%\",height:\"100%\",borderRadius:\"10px\",display:\"block\",objectFit:\"cover\",backgroundColor:\"rgba(0, 0, 0, 0)\",objectPosition:\"50% 50%\"}}),/*#__PURE__*/_jsx(\"p\",{style:{fontSize:14,fontFamily:\"Inter\"},children:\"In the meantime, please explore our famous collection of custom sofas\"}),/*#__PURE__*/_jsx(SecondaryButtonLink,{label:\"Explore sofa collections\",link:\"https://whataroom.com/collections/custom-sofas\"})]}),!success&&/*#__PURE__*/_jsx(Component,{...props,ref:ref,disabled:isSubmitting,isSubmitting:isSubmitting})]});};}export function withAdmin(Component){return props=>{const[visible,setVisible]=useState(false);useEffect(()=>{if(queryFromUrl()?.admin){setVisible(true);}},[]);return visible&&/*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withAdmin\":{\"type\":\"reactHoc\",\"name\":\"withAdmin\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withImpression\":{\"type\":\"reactHoc\",\"name\":\"withImpression\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSubmit\":{\"type\":\"reactHoc\",\"name\":\"withSubmit\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withTracking\":{\"type\":\"reactHoc\",\"name\":\"withTracking\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionTracker\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithTracking.map"],"mappings":"8XAAA,SAAS,EAAiB,EAAI,EAAI,EAAM,CAAmI,OAA/H,KAAO,EAAK,OAAO,eAAe,EAAI,EAAI,CAAO,QAAM,WAAW,GAAK,aAAa,GAAK,SAAS,GAAK,CAAC,CAAO,EAAI,GAAK,EAAc,EAM7I,eAAe,EAAM,EAAM,EAAM,CAAC,GAAK,CAAC,SAAO,OAAK,YAAU,UAAQ,SAAO,QAAQ,EAAS,GAAG,GAAM,EAAY,EAAO,GAAO,SAAS,EAAoB,GAAO,SAAS,CAAC,EAAE,CAAO,EAAQ,EAAe,gBAAgB,CAC9P,EAAK,CAAC,SAAO,OAAK,UAAU,CAAC,EAAU,GAAO,KAAK,GAAO,MAAM,GAAO,UAAU,IAAQ,cAAc,OAAO,GAAO,UAAW,SAAS,GAAO,SAAS,KAAK,GAAQ,UAAU,IAAS,cAAc,OAAO,GAAQ,UAAW,SAAS,GAAQ,SAAS,KAAK,OAAO,GAAS,SAAS,EAAO,KAAK,CAAC,OAAO,QAAQ,CAAC,GAAG,UAAQ,KAAK,KAAK,IAAI,KAAK,QAAQ,EAAS,CAAC,GAAU,IAAS,OAAY,CAAC,IAAM,EAAY,IAAS,OAAqC,GAAzB,EAAO,SAAS,SAAkB,EAAI,EAAO,SAAS,KAAK,EAAK,KAAK,EAAK,EAAK,IAAI,EAAK,IAAM,EAAQ,CAAC,MAAM,CA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