{"version":3,"file":"UserDesignerContentEditor.DbcO2qZV.mjs","names":["useRef","useState","SecondaryButton"],"sources":["https:/framerusercontent.com/modules/tG94euNwgSqRO2tTcyMA/dWZo8QGV77GyLqUU2GbE/UserDesignerContentEditor.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import SecondaryButton from\"https://framer.com/m/SecondaryButton-DILd.js@hJ2IwZ5cR59rjt2Qqmow\";export default function UserDesignerContentEditor({customerUUID,...props}){const timeoutRef=useRef(null);const contentDataRef=useRef(\"\");const[contentData,setContentData]=useState(null);const objectKey=`users/photos/${customerUUID}/content.json`;async function getContentData(){const __fetch=async()=>{clearTimeout(timeoutRef.current);await window.fetch(`https://whataroom.s3.us-west-2.amazonaws.com/${objectKey}`,{method:\"GET\",headers:{\"Cache-Control\":\"no-cache, no-store, must-revalidate\",Pragma:\"no-cache\",Expires:\"0\"},cache:\"no-store\"}).then(async resp=>{const data=await resp.json();contentDataRef.current=JSON.stringify(data,null,2);setContentData(contentDataRef.current);}).catch(()=>{timeoutRef.current=setTimeout(__fetch,1e3);});};__fetch();}async function handleSaveContent(){await window.fetch(\"https://cluster.mage.ai/mageai-3345-dev/api/runs\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\",Authorization:\"Bearer c9fa357137e2426a86652b606f5d4efd\"},body:JSON.stringify({api_key:\"zkWlN0PkIKSN0C11CfUHUj84OT5XOJ6tDZ6bDRO2\",run:{variables:{payload:{object_key:objectKey,content:contentDataRef.current}},pipeline_uuid:\"update_object_content\",block_uuid:\"update_object\",record:false}})}).then(async response=>{alert(\"Content saved!\");}).catch(error=>{alert(`Error: ${error}`);});}useEffect(()=>{customerUUID&&getContentData();},[]);console.log(contentData);return contentData&&/*#__PURE__*/_jsxs(\"div\",{style:{height:\"100%\",width:\"100%\",display:\"grid\",gridRowGap:10,gridTemplateRows:\"1fr auto\"},children:[/*#__PURE__*/_jsx(\"textarea\",{onChange:e=>{contentDataRef.current=e.target.value;setContentData(contentDataRef.current);},value:contentData,style:{whiteSpace:\"pre\",overflowWrap:\"normal\",overflowX:\"scroll\",width:\"100%\",height:\"100%\",fontFamily:\"Fira Code\"}}),/*#__PURE__*/_jsx(SecondaryButton,{label:\"Save content\",onClick:async()=>{await handleSaveContent();}})]});}addPropertyControls(UserDesignerContentEditor,{customerUUID:{title:\"Customer UUID\",type:ControlType.String}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"UserDesignerContentEditor\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./UserDesignerContentEditor.map"],"mappings":"4QAAyP,SAAwB,EAA0B,CAAC,eAAa,GAAG,GAAO,CAAC,IAAM,EAAWA,EAAO,KAAK,CAAO,EAAeA,EAAO,GAAG,CAAM,CAAC,EAAY,GAAgBC,EAAS,KAAK,CAAO,EAAU,gBAAgB,EAAa,eAAe,eAAe,GAAgB,CAAC,IAAM,EAAQ,SAAS,CAAC,aAAa,EAAW,QAAQ,CAAC,MAAM,EAAO,MAAM,gDAAgD,IAAY,CAAC,OAAO,MAAM,QAAQ,CAAC,gBAAgB,sCAAsC,OAAO,WAAW,QAAQ,IAAI,CAAC,MAAM,WAAW,CAAC,CAAC,KAAK,KAAM,IAAM,CAAC,IAAM,EAAK,MAAM,EAAK,MAAM,CAAC,EAAe,QAAQ,KAAK,UAAU,EAAK,KAAK,EAAE,CAAC,EAAe,EAAe,QAAQ,EAAG,CAAC,UAAU,CAAC,EAAW,QAAQ,WAAW,EAAQ,IAAI,EAAG,EAAG,GAAS,CAAE,eAAe,GAAmB,CAAC,MAAM,EAAO,MAAM,mDAAmD,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,mBAAmB,cAAc,0CAA0C,CAAC,KAAK,KAAK,UAAU,CAAC,QAAQ,2CAA2C,IAAI,C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