(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[908],{4293:function(t,e,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/CodeInput",function(){return n(7330)}])},7330:function(t,e,n){"use strict";n.r(e);var o=n(5893),s=n(7294),i=n(3321);class r extends s.Component{componentDidUpdate(t){if(this.props.input!==t.input){let{input:t}=this.props;this.setState({input:t&&null!==t.code?t.code:""})}}render(){return console.log("from parent",this.state.input),(0,o.jsxs)("div",{style:{display:"inline-grid"},children:[(0,o.jsx)("textarea",{className:"code-input",value:null!==this.state.input?this.state.input:this.state.pythonCode,onChange:this.handleCodeChange,placeholder:"Enter Python code here",style:{width:"30rem",height:"30rem"}}),(0,o.jsx)(i.Z,{onClick:this.handleGenerateUI,children:"Generate UI"})]})}constructor(t){super(t),this.handleCodeChange=t=>{null===this.state.input?this.setState({pythonCode:t.target.value}):this.setState({input:t.target.value})},this.handleGenerateUI=async()=>{try{let t=null===this.state.input?this.state.pythonCode:this.state.input,{appName:e}=function(){let t=window.location.search.substring(0);return Object.fromEntries(new URLSearchParams(t))}(),n=await fetch("http://localhost:8080/execute_python_code/"+e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pythonCode:t})});if(n.ok){let t=await n.json();console.log("Python code execution result:",t.result)}else console.error("Error executing Python code:",n.statusText)}catch(t){console.error("Error:",t)}};let{input:e}=t;this.state={pythonCode:"",input:e&&null!==e.code?e.code:""}}}e.default=r}},function(t){t.O(0,[321,774,888,179],function(){return t(t.s=4293)}),_N_E=t.O()}]);