"use strict";exports.id=8613,exports.ids=[8613],exports.modules={64417:(e,t,a)=>{a.d(t,{A:()=>u});var l=a(8732),s=a(82015),n=a.n(s),i=a(65388),r=a(84896),d=a(27825),o=a.n(d);function u({targetField:e,fieldIndex:t,tableFields:s,setTableFields:d,refreshFieldsListRef:u,setActiveEdit:c,database:m,currentTable:x,user:p}){let h=e?.dataType?e.dataType.replace(/\d|\(|\)/g,""):null,f=e?.dataType?e.dataType.replace(/[^\d]/g,""):"200",g=a(94327),v=n().useRef(o().cloneDeep(e)),y=n().useRef(),[N,j]=n().useState(e),[b,w]=n().useState(e?.fieldName),[T,_]=n().useState(h),[V,S]=n().useState(f),[F,I]=n().useState("Varchar is simply letters and numbers within the range 0 - 255"),[C,A]=n().useState(e?.richText&&!e?.encrypted?"Yes":"No"),k=!!T?.match(/uuid/i);return(0,l.jsx)("div",{className:"w-full -mt-3 bg-white dark:bg-slate-800 flex-wrap",ref:y,children:(0,l.jsxs)("form",{className:"flex flex-col xl:flex-row items-start gap-4 w-full justify-between border border-solid p-4 border-slate-200 dark:border-slate-600 rounded rounded-t-none focus:shadow-lg shadow-slate-700 dark:shadow-black relative flex-wrap",onSubmit:e=>{e.preventDefault(),d(e=>(e[t]=N,e)),u.current(e=>e+1);let a=e.target;a.closest(".table-field-wrapper")?.querySelector(".edit-table-field-section")?.classList.toggle("hidden")},children:[(0,l.jsxs)("div",{className:"gap-4 flex-wrap w-full md:w-auto flex-col xl:flex-row items-stretch",children:[(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,l.jsx)("label",{htmlFor:"new_field_name",children:"Field Name"}),(0,l.jsx)("input",{type:"text",name:"new_field_name",id:"new_field_name",placeholder:"Eg. post_title",onInput:async e=>{let t=e.target;t.value=t.value.toLowerCase().replace(/ /g,"_"),j(e=>(e.fieldName=t.value,e.updatedField=!0,e.originName||(e.originName=b),e))},required:!0,defaultValue:b})]}),(0,l.jsxs)("div",{className:"flex flex-col items-start gap-4 xl:gap-0.5",children:[(0,l.jsxs)("div",{className:"flex-wrap xl:flex-nowrap w-full md:w-auto",children:[(0,l.jsx)("label",{htmlFor:"new_field_data_type",children:"Data Type"}),(0,l.jsxs)("div",{className:"dropdown-wrapper reversed text-sm items-start",children:[(0,l.jsx)("span",{className:"px-2 bg-slate-200 dark:bg-slate-700 rounded-full hover:bg-slate-100 dark:hover:bg-slate-600 hidden xl:flex",children:"Info"}),(0,l.jsx)("div",{className:"dropdown mt-0 xl:-mt-2",children:(0,l.jsx)("span",{children:F})})]})]}),(0,l.jsxs)("div",{className:"w-auto",children:[(0,l.jsx)("select",{name:"new_field_data_type",id:"new_field_data_type",className:"w-full xl-w-auto",onChange:t=>{let a=t.target;_(a.value),a.childNodes.forEach(e=>{e.value===a.value&&e.dataset.desc&&I(e.dataset.desc),e.value===a.value&&e.dataset.literal?(N.defaultValueLiteral=e.dataset.literal,N.nullValue=!1):delete N.defaultValueLiteral}),e.dataType=a.value+(a.value.match(/VARCHAR/)?`(${V||200})`:"")},defaultValue:T||void 0,children:g.map((e,t)=>e.name.match(/VARCHAR/)?(0,l.jsx)("option",{value:e.name,"data-desc":e.description,children:e.title+"("+(V||200)+")"},t+1):(0,l.jsx)("option",{value:e.name,"data-desc":e.description,"data-literal":e.valueLiteral||void 0,children:e.title},t+1))}),T?.match(/VARCHAR/)&&(0,l.jsx)("input",{type:"number",defaultValue:V||200,className:"px-2",style:{maxWidth:"60px"},max:255,min:5,onChange:t=>{S(t.target.value),e.dataType=T+`(${t.target.value})`}})]})]}),T?.match(/text/i)&&(0,l.jsx)(n().Fragment,{children:(0,l.jsx)(r.A,{targetField:e})}),!e.dataType?.match(/text/i)&&!k&&(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5",style:{minWidth:"70px"},children:[(0,l.jsx)("label",{htmlFor:"new_field_required",children:"Required?"}),(0,l.jsxs)("select",{name:"new_field_required",id:"new_field_required",className:"px-2",defaultValue:e?.notNullValue?"Yes":"No",onChange:t=>{console.log(e),"Yes"===t.target.value?e.notNullValue=!0:(e.notNullValue=!1,delete e.notNullValue)},children:[(0,l.jsx)("option",{value:"No",children:"No"}),(0,l.jsx)("option",{value:"Yes",children:"Yes"})]})]}),!k&&(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,l.jsx)("label",{htmlFor:"new_field_default_value",children:N?.dataType?.match(/text$/i)?"Can't Set Default for text values":"Default Value (optional)"}),(0,l.jsx)("input",{type:"text",name:"new_field_default_value",id:"new_field_default_value",className:N?.dataType?.match(/text$/i)?"pointer-events-none opacity-50":"",placeholder:"Default Value",defaultValue:N?.defaultValue?N.defaultValue:N?.nullValue?"NULL":"",onInput:e=>{let t=e.target;N.dataType?.match(/text$/i)||j(e=>(t.value.match(/./)?delete e.notNullValue:(delete e.defaultValue,delete e.nullValue),t.value.match(/^null$/i)?(delete e.defaultValue,e.nullValue=!0):t.value.match(/./)&&(delete e.nullValue,e.defaultValue=t.value),e))}})]}),!k&&(0,l.jsx)(i.A,{database:m,setFieldData:j,setTableFields:d,tableFields:s,targetField:e,user:p,currentTable:x,fieldIndex:t})]}),(0,l.jsxs)("div",{className:"secondary mt-auto flex-wrap w-full xl:w-auto",children:[(0,l.jsx)("button",{type:"submit",className:"secondary mt-auto py-3 w-full md:w-auto grow",children:"Save Updates"}),(0,l.jsx)("div",{className:"button outlined gray mt-auto py-2.5 w-full md:w-auto justify-center grow",onClick:a=>{v.current&&(e=o().cloneDeep(v.current)),d(e=>{let a=o().cloneDeep(e);return t&&v.current&&(a[t]=o().cloneDeep(v.current)),a}),c&&c(!1)},children:"Cancel"})]})]})})}},65388:(e,t,a)=>{a.d(t,{A:()=>g});var l=a(8732),s=a(82015),n=a.n(s),i=a(13737),r=a(58150);function d({targetField:e}){if(!e?.richText)return null;let[t,a]=n().useState(e.cssFiles||[]),s=n().useRef(null);return(0,l.jsxs)("div",{className:"flex flex-col items-start gap-2 w-full my-4",style:{minWidth:"70px"},children:[(0,l.jsx)("span",{className:"label text-xs text-slate-500",children:"Add CSS"}),t.map((e,t)=>(0,l.jsxs)("div",{className:"relative border border-solid border-slate-300 text-xs px-2 py-1 rounded-full",children:[(0,l.jsx)("span",{children:e}),(0,l.jsx)(r.A,{size:20,onClick:()=>{a(t=>t.filter(t=>t!==e))},className:"cursor-pointer hover:opacity-60 "})]},t+1)),(0,l.jsxs)("div",{className:"row w-full",children:[(0,l.jsx)(i.A,{name:"css-file",placeholder:"CSS file URL",elementRef:s}),(0,l.jsx)("button",{className:"secondary outlined",onClick:()=>{let e=s.current?.value;e?.match(/./)&&a(t=>[...new Set([...t,e])])},children:"Add"})]}),(0,l.jsx)("span",{className:"text-sm text-slate-600",children:"Add CSS files to your Rich Text field"})]})}function o({targetField:e,setFieldData:t}){return(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",style:{minWidth:"70px"},children:[(0,l.jsx)("label",{htmlFor:"encryption_field",children:"Encrypt?"}),(0,l.jsxs)("select",{name:"encryption_field",id:"encryption_field",className:"px-2",defaultValue:e?.encrypted?"Yes":"No",onChange:e=>{t&&t(t=>(e.target.value.match(/yes/i)?t.encrypted=!0:(t.encrypted=!1,delete t.encrypted),t))},children:[(0,l.jsx)("option",{value:"No",children:"No"}),(0,l.jsx)("option",{value:"Yes",children:"Yes"})]})]})}var u=a(12097);function c({targetField:e,setFieldData:t}){return null}function m({targetField:e}){return(0,l.jsxs)("div",{className:"flex flex-col items-start gap-2 w-full",style:{minWidth:"70px"},children:[(0,l.jsx)("label",{htmlFor:"encryption_field",children:"Pattern"}),(0,l.jsx)("span",{className:"text-sm text-slate-500",children:'This describes a pattern that must be matched for this field to be valid. If you add a pattern and make a db entry that doesn\'t match, the entry will be "NULL" or an empty string or the default value.'}),(0,l.jsx)("input",{type:"text",placeholder:"Regex Pattern. Eg: '\\\\.[a-z]+'",onInput:t=>{let a=t.target;a?.value?.length>0?e.pattern=a.value:delete e.pattern},defaultValue:e?.pattern}),(0,l.jsx)("input",{type:"text",placeholder:"Regex Pattern Flags. Eg: igm",onInput:t=>{let a=t.target;a?.value?.length>0?e.patternFlags=a.value:delete e.patternFlags},defaultValue:e?.patternFlags})]})}var x=a(27825),p=a.n(x),h=a(2817);function f({targetField:e,setFieldData:t}){return(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",style:{minWidth:"70px"},children:[(0,l.jsx)("label",{htmlFor:"unique_field",children:"Unique Field?"}),(0,l.jsxs)("select",{name:"unique_field",id:"unique_field",className:"px-2",defaultValue:e?.unique?"Yes":"No",onChange:e=>{t&&t(t=>(e.target.value.match(/yes/i)?t.unique=!0:(t.unique=!1,delete t.unique),t))},children:[(0,l.jsx)("option",{value:"No",children:"No"}),(0,l.jsx)("option",{value:"Yes",children:"Yes"})]})]})}function g({targetField:e,currentTable:t,database:a,tableFields:s,setTableFields:i,setFieldData:r,user:x,fieldIndex:g}){let[v,y]=n().useState(!1),N=n().useRef(p().cloneDeep(e));return(0,l.jsxs)(n().Fragment,{children:[(0,l.jsx)("span",{className:"button outlined gray mt-5 w-full xl:w-auto",onClick:()=>{y(!0)},children:"More"}),(0,l.jsx)(h.A,{open:v,onClose:()=>{N.current&&(e=p().cloneDeep(N.current)),y(!1)},maxWidth:"600px",children:(0,l.jsxs)("div",{className:"m-auto flex flex-col max-w-xl w-full max-h-[90vh] overflow-y-auto",children:[(0,l.jsx)("div",{className:"w-full justify-between",children:(0,l.jsx)("span",{className:"text-xl",children:"More Options"})}),(0,l.jsx)(d,{targetField:e}),(0,l.jsx)(f,{targetField:e,setFieldData:r}),(0,l.jsx)(o,{targetField:e,setFieldData:r}),t&&(0,l.jsx)(u.A,{targetField:e,setFieldData:r,database:a,tableFields:s,setTableFields:i,currentTable:t,user:x}),(0,l.jsx)(c,{targetField:e,setFieldData:r}),(0,l.jsx)(m,{targetField:e}),(0,l.jsx)("button",{className:"w-full outlined more-padding",onClick:()=>{y(!1)},children:"Done"})]})})]})}},12097:(e,t,a)=>{a.d(t,{A:()=>o});var l=a(8732),s=a(82015),n=a.n(s),i=a(63715),r=a(32415),d=a(58403);function o({targetField:e,setFieldData:t,tableFields:a,setTableFields:s,database:o,currentTable:u,user:c,setActiveEdit:m,activeClonedTable:x}){let[p,h]=n().useState(!!e?.foreignKey),[f,g]=n().useState(null),[v,y]=n().useState(null),[N,j]=n().useState(null),[b,w]=n().useState(null),[T,_]=n().useState(!1),[V,S]=n().useState("boolean"!=typeof e.foreignKey?.cascadeDelete||e.foreignKey.cascadeDelete),[F,I]=n().useState("boolean"==typeof e.foreignKey?.cascadeUpdate&&e.foreignKey.cascadeUpdate);return(0,l.jsxs)("div",{className:"flex flex-col items-start gap-2 w-full mt-2 relative",style:{minWidth:"70px"},children:[T&&(0,l.jsx)(r.A,{}),(0,l.jsxs)("label",{htmlFor:"foreign_key_field",className:"flex flex-wrap items-center gap-2 mt-2",children:[(0,l.jsx)("span",{children:"Foreign Key?"}),(0,l.jsxs)("div",{className:"dropdown-wrapper reversed text-sm items-start",children:[(0,l.jsx)("span",{className:"px-2 bg-slate-200 rounded-full hover:bg-slate-100 hidden xl:flex text-slate-600",children:"Info"}),(0,l.jsx)("div",{className:"dropdown mt-0 xl:-mt-2",children:(0,l.jsx)("span",{children:"Foriegn key links the current table to another table"})})]})]}),(0,l.jsxs)("select",{name:"foreign_key_field",id:"foreign_key_field",className:"px-2",defaultValue:e?.foreignKey?"Yes":"No",onChange:e=>{e.target.value.match(/yes/i)?(h(!0),t&&t(e=>(e.foreignKey={foreignKeyName:void 0,destinationTableName:void 0,destinationTableColumnName:void 0,cascadeDelete:!0},e))):(h(!1),t&&t(e=>(delete e.foreignKey,e)))},children:[(0,l.jsx)("option",{value:"No",children:"No"}),(0,l.jsx)("option",{value:"Yes",children:"Yes"})]}),p&&f&&(0,l.jsx)(n().Fragment,{children:(0,l.jsxs)("select",{name:"foreign_key_destination_table_name",id:"foreign_key_destination_table_name",className:"px-2",defaultValue:e?.foreignKey?.destinationTableName?e.foreignKey.destinationTableName:void 0,onChange:e=>{let a=e.target;if(e.target.value?.match(/--/)){t?t(e=>{let t=e.foreignKey;return t&&(t.destinationTableName=void 0),e}):a.dataset.destinationTableName=void 0;return}let l=f.filter(t=>t.tableName===e.target.value)[0];y(l),l?.fields&&j(l.fields),t?t(t=>{let a=t.foreignKey;return a&&(a.destinationTableName=e.target.value),t}):e.target.dataset.destinationTableName=e.target.value},children:[(0,l.jsx)("option",{value:"--",children:"--Select Table--"}),f.map((e,t)=>(0,l.jsx)("option",{value:e.tableName,children:e.tableFullName},t+1))]})}),v&&N&&(0,l.jsxs)(n().Fragment,{children:[(0,l.jsxs)("select",{name:"foreign_key_destination_table_column_name",id:"foreign_key_destination_table_column_name",className:"px-2",defaultValue:e?.foreignKey?.destinationTableColumnName?e.foreignKey.destinationTableColumnName:void 0,onChange:e=>{try{let a=N.filter(t=>t.fieldName===e.target.value)[0];if(w(a),e.target.value?.match(/--/)){t&&t(e=>{let t=e.foreignKey;return t&&(t.destinationTableColumnName=void 0),e});return}let l=`dsql_${o.user_id}_${o.db_slug}_${Date.now()}`;t?t(e=>{e.dataType=a.dataType;let t=e.foreignKey;return t&&(t.destinationTableColumnName=a.fieldName,t.destinationTableColumnType=a.dataType,t.foreignKeyName=l),e}):(e.target.dataset.dataType=a.dataType,e.target.dataset.destinationTableColumnName=a.fieldName,e.target.dataset.foreignKeyName=l)}catch(e){(0,i.A)("/api/admin/clientError",{method:"post",body:{component:"ForeignKey/lines-232-264",message:e.message,user:c}})}},children:[(0,l.jsx)("option",{value:"--",children:"--Select Column--"}),N.map((e,t)=>(0,l.jsx)("option",{value:e.fieldName,children:e.fieldName},t+1))]}),x&&b&&(0,l.jsx)("button",{className:"secondary w-full",onClick:e=>{_(!0),(0,i.A)("/api/updateClonedTableForeignKeys",{method:"post",body:{tableData:u,database:o.db_full_name,dbSlug:o.db_slug,delegated:!!window.location?.search?.match(/delegated=true/i)}},!0).then(e=>{e.success?window.alert("Foreign Key Added Successfully!"):window.alert("Update Failed, Please Try again."),setTimeout(()=>{m&&m(!1)},1e3)})},children:"Add Foreign Key"}),(0,l.jsx)(d.A,{checkBoxValues:[{title:"Cascade Delete",default:V,name:"cascade-delete",onChangeHandler:e=>{S(e.target.checked)}},{title:"Cascade Update",name:"cascade-update",default:F,onChangeHandler:e=>{I(e.target.checked)}}],smallText:!0})]}),x&&(0,l.jsx)("button",{className:"light-gray w-full",onClick:t=>{delete e.foreignKey,m&&m(!1)},children:"Cancel"})]})}},84896:(e,t,a)=>{a.d(t,{A:()=>s});var l=a(8732);function s({targetField:e}){return(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5",style:{minWidth:"70px"},children:[(0,l.jsx)("label",{htmlFor:"rich_text_option",children:"Text Type"}),(0,l.jsxs)("select",{name:"rich_text_option",id:"rich_text_option",className:"px-2",onChange:t=>{switch(delete e.json,delete e.richText,delete e.yaml,delete e.html,delete e.javascript,delete e.shell,t.target.value){case"plain":break;case"rte":e.richText=!0;break;case"json":e.json=!0;break;case"yaml":e.yaml=!0;break;case"html":e.html=!0;break;case"css":e.css=!0;break;case"javascript":e.javascript=!0;break;case"shell":e.shell=!0}},defaultValue:e.richText?"rte":e.json?"json":e.yaml?"yaml":e.html?"html":e.javascript?"javascript":e.shell?"shell":e.css?"css":"plain",children:[(0,l.jsx)("option",{value:"plain",children:"Plain Text"}),(0,l.jsx)("option",{value:"rte",children:"Rich Text"}),(0,l.jsx)("option",{value:"json",children:"JSON"}),(0,l.jsx)("option",{value:"yaml",children:"YAML"}),(0,l.jsx)("option",{value:"html",children:"HTML"}),(0,l.jsx)("option",{value:"css",children:"CSS"}),(0,l.jsx)("option",{value:"javascript",children:"Javascript"}),(0,l.jsx)("option",{value:"shell",children:"Shell"})]})]})}a(82015)},58403:(e,t,a)=>{a.d(t,{A:()=>s});var l=a(8732);function s({name:e,checkBoxValues:t,setAlert:a,labelColor:s,flexRow:n,baseText:i,smallText:r,className:d}){return(0,l.jsx)("div",{className:"flex items-start gap-x-4"+(n?" flex-row flex-wrap gap-y-2 ":" flex-col gap-y-4 ")+(d||""),children:t.map((t,n)=>{let{payload:d,title:o,onChangeHandler:u,fixed:c,jsx:m}=t,x=t.name?`${e}-${t.name}`:d?e+"-"+d:e;return(0,l.jsxs)("div",{className:"flex items-center"+(t.default&&c?" pointer-events-none":"")+(r?" gap-1 ":" gap-2 ")+(t?.className?t.className:""),children:[(0,l.jsx)("input",{className:"m-0"+(r?" w-4 h-4":" w-5 h-5"),type:"checkbox",defaultChecked:!!t.default,name:x,id:x,onChange:e=>{a&&a(null),u&&u(e,t)},value:d,style:{minWidth:"20px"},...t.props}),m||(0,l.jsx)("label",{htmlFor:x,className:"m-0 "+(s||"text-slate-800 dark:text-white/80")+(i||r?" text-base":" text-lg"),children:o})]},n+1)})})}a(82015)},2817:(e,t,a)=>{a.d(t,{A:()=>s});var l=a(8732);function s({children:e,open:t,setOpen:a,onClose:s,maxWidth:n}){return(0,l.jsx)(l.Fragment,{})}a(82015),a(1976),a(58150)},22373:(e,t,a)=>{let l=a(29021),{IncomingMessage:s}=a(81630);e.exports=async function({user:e,message:t,component:a,noMail:s,req:n}){let i=new Date,r=(()=>{if(!n)return null;try{let e=n.headers["x-forwarded-for"],t=n.headers["x-real-ip"],a=n.headers["cf-connecting-ip"],l=Array.isArray(e)?e[0]:e?.split(",")[0],s=a||l||t||n.socket.remoteAddress;if(!s)return null;return String(s)}catch(e){return null}})();try{let s=`🚀 SERVER ERROR =========================== Error Message: ${t} Component: ${a}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(s+=` User Id: ${e?.id} User Name: ${e?.first_name} ${e?.last_name} User Email: ${e?.email}`),n?.url&&(s+=` URL: ${n.url}`),n?.body&&(s+=` Request Body: ${JSON.stringify(n.body,null,4)}`),r&&(s+=` IP: ${r}`),s+=` Date: ${i.toDateString()} ========================================`,l.existsSync("./.tmp/error.log")||l.writeFileSync("./.tmp/error.log","","utf-8");let d=l.readFileSync("./.tmp/error.log","utf-8");l.writeFileSync("./.tmp/error.log",s),l.appendFileSync("./.tmp/error.log",` ${d}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},94327:e=>{e.exports=JSON.parse('[{"title":"VARCHAR","name":"VARCHAR","value":"0-255","argument":true,"description":"Varchar is simply letters and numbers within the range 0 - 255","maxValue":255},{"title":"TINYINT","name":"TINYINT","value":"0-100","description":"TINYINT means Integers: 0 to 100","maxValue":127},{"title":"SMALLINT","name":"SMALLINT","value":"0-255","description":"SMALLINT means Integers: 0 to 240933","maxValue":32767},{"title":"MEDIUMINT","name":"MEDIUMINT","value":"0-255","description":"MEDIUMINT means Integers: 0 to 1245568545560","maxValue":8388607},{"title":"INT","name":"INT","value":"0-255","description":"INT means Integers: 0 to 12560","maxValue":2147483647},{"title":"BIGINT","name":"BIGINT","value":"0-255","description":"BIGINT means Integers: 0 to 1245569056767568545560","maxValue":2e+63},{"title":"TINYTEXT","name":"TINYTEXT","value":"0-255","description":"Text with 255 max characters","maxValue":127},{"title":"TEXT","name":"TEXT","value":"0-100","description":"MEDIUMTEXT is just text with max length 16,777,215","maxValue":127},{"title":"MEDIUMTEXT","name":"MEDIUMTEXT","value":"0-255","description":"MEDIUMTEXT is just text with max length 16,777,215","maxValue":127},{"title":"LONGTEXT","name":"LONGTEXT","value":"0-255","description":"LONGTEXT is just text with max length 4,294,967,295","maxValue":127},{"title":"UUID","name":"UUID","valueLiteral":"UUID()","description":"A Unique ID"}]')}};