"use strict";exports.id=8704,exports.ids=[8704],exports.modules={39506:(e,t,a)=>{a.d(t,{A:()=>o});vars=a(8732),l=a(82015),n=a.n(l),r=a(16757),i=a(83921),d=a(46169);functionc({paradigm:e,payload:t,setLoading:a,table:s,database:l}){a(!0),(0,d.A)("/api/exportTableData",{method:"POST",body:{paradigm:e,dbName:l.db_slug,tableName:s.tableName,payload:t}},!0).then(t=>{if(t.success){if("export"==e){lete=newBlob([JSON.stringify(t.data||[],null,4)],{type:"application/json"}),a=URL.createObjectURL(e),n=document.createElement("a");n.href=a,n.style.display="none",n.download=`${l.db_slug}-${s.tableName}-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n)}else"import"==e&&(window.alert("Data Imported Successfully"),window.location.reload())}elset.msg&&window.alert(t.msg)}).catch(e=>{console.log(e)}).finally(()=>{a(!1)})}functiono({database:e,table:t}){let[a,l]=n().useState(!1),[d,o]=n().useState(!0),u=n().useRef(null);returnn().useRef(null),(0,s.jsxs)("div",{className:"relative",children:[a&&(0,s.jsx)(r.A,{width:"15px"}),(0,s.jsx)("div",{className:"button outlined gray",onClick:a=>{c({paradigm:"export",database:e,setLoading:l,table:t})},children:"Export"}),(0,s.jsx)("div",{className:"button outlined gray",onClick:a=>{u.current?.addEventListener("change",a=>{l(!0);lets=a.target;if(!s.files?.[0]){window.alert("No FIles selected"),l(!1);return}i.A({inputFile:s.files[0]}).then(a=>{window.confirm(`Use this file '${a.fileName}' as your import file?`)?c({paradigm:"import",payload:a.fileBase64,database:e,setLoading:l,table:t}):l(!1),o(!1),setTimeout(()=>{o(!0)},200)})}),u.current?.click()},children:"Import"}),d&&(0,s.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:u})]})}},42427:(e,t,a)=>{a.d(t,{A:()=>x});vars=a(8732),l=a(82015),n=a.n(l),r=a(41836),i=a(95939),d=a(1346),c=a(80830),o=a(16757),u=a(84483),m=a(46169);functionh({database:e,table:t,setOpenPopover:a,dbSchemaData:l,query:r}){let[i,d]=n().useState(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{className:"ghost p-3 justify-start",onClick:()=>{d(!0),setTimeout(()=>{a&&a(!1)},200)},children:"Sync Data"}),(0,s.jsx)(u.A,{open:i,setOpen:d,children:(0,s.jsx)(b,{database:e,table:t,dbSchemaData:l,query:r})})]})}functionb({database:e,table:t,query:a,dbSchemaData:l}){let[r,i]=n().useState(l),[u,h]=n().useState("Push"),[b,x]=n().useState(r?.[0]),[p,f]=n().useState(b?.tables),[g,j]=n().useState(p?.[0]),[N,y]=n().useState(!1),[w,v]=n().useState(!1);return(0,s.jsxs)("div",{className:"stack gap-2 relative w-full",children:[N||!r&&(0,s.jsx)(o.A,{width:"20px"}),(0,s.jsx)("h3",{className:"m-0 text-lg",children:"Sync Data with another table"}),w?(0,s.jsxs)("span",{className:"info green inline",children:["The selected table matches ",(0,s.jsx)("b",{children:t.tableFullName})," ","schema"]}):(0,s.jsxs)("span",{className:"info warning inline",children:["The selected table is not compatible with"," ",(0,s.jsx)("b",{children:t.tableFullName})]}),r&&(0,s.jsxs)("form",{onSubmit:s=>{!function({e,setLoading:t,database:a,table:s,query:l}){e.preventDefault(),t(!0);letn=e.target,r=n.paradigm?.value,i=n.database?.value,d=n.table?.value,c={paradigm:r,src:{db:a.db_slug,table:s.tableName},dst:{db:i,table:d},delegated:l.delegated};if(!window.confirm("Pull"==r?"NOTE: This operation will override the current database entries. Continue?":"NOTE: This operation will override the selected database entries. Continue?")){setTimeout(()=>{t(!1)},1e3);return}(0,m.A)("/api/sync-table-data",{method:"POST",body:{...c}},!0).then(e=>{e.success?(window.alert("Data Sync Successful"),window.location.reload()):e.msg&&window.alert("ERROR: "+e.msg)}).finally(()=>{setTimeout(()=>{t(!1)},1e3)})}({e:s,database:e,setLoading:y,table:t,query:a})},className:"w-full stack gap-2 items-stretch",children:[(0,s.jsxs)("div",{className:"stack gap-2 my-2",children:[(0,s.jsx)(d.A,{radioValues:[{title:"Push",payload:"Push",default:!0},{title:"Pull",payload:"Pull"}],name:"paradigm",smallText:!0,flexRow:!0,onChangeHandler:e=>{h(e.target.valu