1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
"use strict";exports.id=725,exports.ids=[725],exports.modules={6748:(e,t,a)=>{a.d(t,{A:()=>E});var r=a(8732),l=a(82015),s=a.n(l),d=a(16757),i=a(40373);function n({editor:e}){navigator.clipboard.writeText(e?.getContent()||"").then(()=>{alert("Html Copied to Clipboard!")})}var o=a(1976),c=a.n(o),u=a(58150);function m({editor:e,rootElement:t}){e.getContent();let a=s().useRef(),l=s().useRef(),[d,i]=s().useState();return(0,r.jsxs)("div",{onKeyUp:e=>{e.ctrlKey&&"Enter"==e.key&&l.current?.click()},children:[(0,r.jsx)("div",{className:"embed-popup-form-content-wrapper relative flex flex-col items-center justify-center",children:(0,r.jsxs)("div",{className:"max-w-[1200px] rounded-md overflow-hidden bg-white w-[90vw] items-start justify-start relative",children:[(0,r.jsx)("div",{ref:a,className:"w-full h-[80vh] text-[18px]"}),(0,r.jsx)("button",{className:"absolute bottom-4 right-4",onClick:a=>{if(d){let a=d.getValue();e.setContent(a),setTimeout(()=>{document.body.removeChild(t)},200)}},ref:l,children:"Save"})]})}),(0,r.jsx)("button",{className:"absolute top-4 right-8 rounded-full white",onClick:()=>{try{document.body.removeChild(t)}catch(e){}},style:{width:"40px",height:"40px",padding:"0",zIndex:"12039800000"},children:(0,r.jsx)(u.A,{})})]})}function p({editor:e}){let t=document.createElement("div");t.style.position="fixed",t.style.width="100vw",t.style.height="100vh",t.style.zIndex="123000000000000000",t.style.backgroundColor="rgba(0,0,0,0.8)",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.top="0",t.style.left="0",document.body.append(t),t.onclick=e=>{e.target.closest(".embed-popup-form-content-wrapper")||document.body.removeChild(t)},e&&c().createRoot(t).render((0,r.jsx)(m,{editor:e,rootElement:t}))}function f({editor:e,rootElement:t}){return(0,r.jsx)("div",{className:"embed-popup-form-content-wrapper text-sm mt-2 flex-wrap bg-white p-10 rounded max-w-2xl w-full",children:(0,r.jsxs)("form",{onSubmit:a=>{a.preventDefault();let r=a.target["embed-text-area"].value;if(!r?.match(/./))return alert("Please Enter HTML Text to continue.");e.insertContent(r),document.body.removeChild(t)},className:"w-full flex flex-col items-stretch gap-2",children:[(0,r.jsx)("h3",{className:"m-0 text-center text-lg",children:"Enter HTML code"}),(0,r.jsx)("textarea",{name:"embed-text-area",id:"embed-text-area",cols:30,rows:10,placeholder:"Paste Code here ..."}),(0,r.jsx)("button",{type:"submit",children:"Embed"})]})})}function x({editor:e}){let t=document.createElement("div");t.style.position="fixed",t.style.width="100vw",t.style.height="100vh",t.style.zIndex="123000000000000000",t.style.backgroundColor="rgba(0,0,0,0.8)",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.top="0",t.style.left="0",document.body.append(t),t.onclick=e=>{if(e.target.closest(".embed-popup-form-content-wrapper")){console.log("Still In Form");return}document.body.removeChild(t)},e&&c().createRoot(t).render((0,r.jsx)(f,{editor:e,rootElement:t}))}a(90317);var h=a(17855);function y({fieldObject:e,dataTypeSchema:t,richTextEditors:a,entry:l,currentRichTextEditorForms:o,entryPage:c,formButtonId:u}){let[m,f]=s().useState(!1),y=s().useRef(),g=s().useRef();return(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full rich-text-editor-wrapper",children:[(0,r.jsxs)("label",{className:"font-bold text-slate-700 dark:text-slate-300 text-base px-3 py-1 bg-slate-100 dark:bg-slate-700 rounded-t-md border border-solid border-slate-300 dark:border-slate-300/20 flex items-center gap-2",htmlFor:e.fieldName,children:[e.encrypted&&(0,r.jsx)(h.A,{}),(0,r.jsx)("span",{children:e.fieldName})]}),(0,r.jsxs)("div",{ref:y,id:e.fieldName,className:"w-full p-0 sm:p-4 flex-col items-stretch bg-slate-100 relative dark:bg-slate-700 border border-solid border-slate-300 dark:border-slate-300/20",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},children:[!m&&(0,r.jsx)(d.A,{}),m&&(0,r.jsx)(s().Fragment,{children:(0,r.jsx)(i.Editor,{tinymceScriptSrc:"https://datasquirel.com/tinymce-public/tinymce.min.js",onInit:(e,t)=>{g.current=t},initialValue:e.defaultValue||(l&&e.fieldName&&l[e.fieldName]?l[e.fieldName]:""),init:{height:c?400:300,width:"100%",convert_urls:!1,menubar:!1,plugins:["advlist","lists","link","image","charmap","anchor","searchreplace","visualblocks","code","fullscreen","insertdatetime","media","table","preview","help","wordcount"],toolbar:"undo redo | blocks | bold italic forecolor | link image | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat help | editCode embedCode copyCode",placeholder:"Type something ...",document_base_url:"/",content_css:e.cssFiles||void 0,setup:e=>{!function({editor:e,formButtonId:t}){e.addShortcut("meta+13","Save Entry.",()=>{window.confirm("Update this Form?")&&t&&document.getElementById(t)?.click()}),e.addShortcut("meta+shift+e","Edit Code.",()=>{p({editor:e})}),e.addShortcut("meta+shift+d","Embed Code.",()=>{x({editor:e})}),e.addShortcut("meta+shift+c","Copy Code.",()=>{n({editor:e})}),e.ui.registry.addButton("editCode",{icon:"edit-block",onAction:t=>p({editor:e}),tooltip:"Edit HTML Code"}),e.ui.registry.addButton("embedCode",{icon:"sourcecode",onAction:t=>x({editor:e}),tooltip:"Embed Code"}),e.ui.registry.addButton("copyCode",{icon:"copy",onAction:t=>n({editor:e}),tooltip:"Copy HTML"})}({editor:e,formButtonId:u})}}})})]})]})}a(46169),a(6789);var g=a(82544);let b=(0,g.A)("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),N=(0,g.A)("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);function v({fieldObject:e,typeFinal:t,isExpanded:a,setHeight:l,COLLAPSED_HEIGHT:s,EXPANDED_HEIGHT:d}){return(0,r.jsxs)("div",{className:"gap-2 w-full",children:[(0,r.jsxs)("label",{className:"font-bold text-slate-700 dark:text-slate-300 text-base px-3 py-1 bg-slate-100 dark:bg-slate-700 rounded-t-md border border-solid border-slate-300 dark:border-slate-300/20 flex items-center gap-2",htmlFor:e.fieldName,children:[e.encrypted&&(0,r.jsx)(h.A,{}),(0,r.jsx)("span",{children:e.fieldName})]}),(0,r.jsx)("div",{className:"px-4 py-1 bg-secondary text-white rounded-full text-sm font-bold -mt-2",children:(0,r.jsx)("span",{children:t})}),(0,r.jsxs)("div",{className:"ml-auto cursor-pointer gap-1 text-slate-400 hover:text-slate-800 -mt-2 items-center flex",onClick:e=>{a?l(s):l(d)},children:[(0,r.jsx)("span",{className:"font-semibold text-sm",children:a?"Collapse":"Expand"}),a?(0,r.jsx)(b,{size:18,className:"mt-[-1px]"}):(0,r.jsx)(N,{size:18,className:"mt-[-1px]"})]})]})}function j({fieldObject:e,dataTypeSchema:t,entry:a,entryPage:l,jsonTextEditors:d,type:i}){try{let[t,a]=s().useState(0),[l,d]=s().useState(300),n=s().useRef();return s().useRef(),(0,r.jsx)(s().Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full rich-text-editor-wrapper",children:[(0,r.jsx)(v,{fieldObject:e,isExpanded:300!==l,setHeight:d,typeFinal:i||"json",COLLAPSED_HEIGHT:300,EXPANDED_HEIGHT:600}),(0,r.jsx)(w,{height:l,jsonEditorRef:n})]})})}catch(e){return(0,r.jsx)(s().Fragment,{children:(0,r.jsx)("span",{children:"Editor Load Error"})})}}function w({height:e,jsonEditorRef:t}){return(0,r.jsx)("div",{className:"w-full p-0 sm:p-4 flex-col relative dark:bg-slate-700 border border-solid border-slate-300 dark:border-slate-300/20 overflow-hidden",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px",height:`${e}px`},children:(0,r.jsx)("div",{ref:t,className:"w-full text-[18px] h-full"})})}function E({fieldObject:e,dataTypeSchema:t,richTextEditors:a,jsonTextEditors:l,entry:d,currentRichTextEditorForms:i,confirmedDelegetedUser:n,query:o,entryPage:c,formButtonId:u}){n?.delegated,n?.priviledges?.match(/Edit Tables/i),n?.priviledges?.match(/Delete Tables/i),n?.priviledges?.match(/Create Tables/i),n?.priviledges?.match(/Edit Entries/i),n?.priviledges?.match(/Delete Entries/i);let m=function({fieldObject:e,dataTypeSchema:t,elementRef:a,entry:l}){let s;let d=e=>{let t=e.target.closest("form");if(!t)return;let a=t?.querySelector("#slug");a&&(a.value=e.target.value.toLowerCase().replace(/ /g,"-").replace(/[^a-z\-0-9]/g,""))};return e.defaultField?s=(0,r.jsx)("input",{ref:a,type:"text",name:"def_field_"+e.fieldName,id:"def_field_"+e.fieldName,placeholder:e.fieldName,defaultValue:l&&l[e.fieldName||""]?l[e.fieldName||""]:e.defaultValue?e.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},readOnly:!0,"data-default":"true"}):(e.dataType?.match(/varchar/i)&&(s=(0,r.jsx)("textarea",{ref:a,name:e.fieldName,id:e.fieldName,placeholder:e.fieldName,required:!!e.notNullValue,maxLength:e.dataType?.match(/\d+/)?.[0]?parseInt(e.dataType?.match(/\d+/)?.[0]||""):void 0,defaultValue:l&&l[e.fieldName||""]?l[e.fieldName||""]:e.defaultValue?e.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},onChange:t=>{e.fieldName?.match(/^title$/)&&d(t)}})),e.dataType?.match(/int$/i)&&(s=(0,r.jsx)("input",{ref:a,type:"number",name:e.fieldName,id:e.fieldName,placeholder:e.fieldName,required:!!e.notNullValue,max:t.maxValue,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:l&&l[e.fieldName||""]?l[e.fieldName||""]:e.defaultValue?e.defaultValue:"",onChange:e=>{}})),e.dataType?.match(/text$/i)&&(s=(0,r.jsx)("textarea",{ref:a,name:e.fieldName,id:e.fieldName,placeholder:e.fieldName,required:!!e.notNullValue,defaultValue:l&&l[e.fieldName||""]?l[e.fieldName||""]:e.defaultValue?e.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},rows:10,onChange:e=>{}})),e.fieldName?.match(/password|^pass$|^key$/i)&&(s=(0,r.jsxs)("div",{className:"w-full relative",children:[(0,r.jsx)("input",{ref:a,type:"password",name:e.fieldName,id:e.fieldName,placeholder:e.fieldName,required:!!e.notNullValue,max:t.maxValue,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:l&&l[e.fieldName]?l[e.fieldName]:e.defaultValue?e.defaultValue:"",onChange:e=>{}}),(0,r.jsx)("span",{className:"absolute right-4 cursor-pointer",onClick:e=>{let t=e.target.closest("div").querySelector("input");"password"===t.type?(t.type="text",e.target.innerText="Hide"):(t.type="password",e.target.innerText="Reveal")},children:"Reveal"})]})),s||(s=(0,r.jsx)("input",{ref:a,type:"text",name:e.fieldName,id:e.fieldName,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:l&&l[e.fieldName||""]?l[e.fieldName||""]:e.defaultValue?e.defaultValue:"",onChange:e=>{}})),s)}({fieldObject:e,dataTypeSchema:t,elementRef:s().useRef(),entry:d});if(e.dataType?.match(/text$/i)&&e.richText&&!e.plainText&&!e.fieldName?.match(/^pass|^key$/i)&&!e.encrypted||e.encrypted&&e.richText)return(0,r.jsx)(s().Fragment,{children:(0,r.jsx)(y,{fieldObject:e,dataTypeSchema:t,richTextEditors:a,currentRichTextEditorForms:i,entry:d,entryPage:c,formButtonId:u})});let p=e.json||e.yaml||e.html||e.css||e.javascript||e.shell;return e.dataType?.match(/text$/i)&&p&&!e.plainText&&!e.fieldName?.match(/^pass|^key$/i)&&!e.encrypted||e.encrypted&&p?(0,r.jsx)(j,{fieldObject:e,dataTypeSchema:t,entry:d,entryPage:c,jsonTextEditors:l,type:e.json?"json":e.yaml?"yaml":e.html?"html":e.css?"css":e.javascript?"javascript":e.shell?"shell":"json"}):(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full"+(e.defaultField?" opacity-50":""),children:[(0,r.jsxs)("label",{className:"font-bold text-slate-700 dark:text-slate-300 text-base px-3 py-1 bg-slate-100 dark:bg-slate-700 rounded-t-md border border-solid border-slate-300 dark:border-slate-300/20 flex items-center gap-2",htmlFor:e.fieldName,children:[e.encrypted&&(0,r.jsx)(s().Fragment,{children:(0,r.jsx)(h.A,{})}),(0,r.jsx)("span",{children:e.fieldName}),e.defaultField&&(0,r.jsx)("span",{className:"bg-white dark:bg-slate-900 text-primary dark:text-slate-300 font-semibold text-xs px-2 py-0.5 rounded-xs",children:"Default Field"})]}),m]})}},6789:(e,t,a)=>{a.d(t,{A:()=>r});function r({editorHTMLElementRef:e,fieldObject:t,setRefresh:a,language:r="javascript",entry:l,jsonTextEditors:s,editorRef:d,readOnly:i,initialContent:n,options:o}){try{if(!ace?.edit||!e.current){console.log("Ace Editor not found!"),setTimeout(()=>{a?.(e=>e+1)},1e3);return}let c=ace.edit(e.current);c.setOptions({mode:"ace/mode/"+r,value:n||(t?.defaultValue?t.defaultValue:t?.fieldName&&l?.[t.fieldName]?(()=>{if("json"!==r)return l[t.fieldName];try{return JSON.stringify(JSON.parse(l[t.fieldName]),null,4)}catch(e){return l[t.fieldName]}})():""),placeholder:"json"==r?"{}":"",enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,readOnly:i,...o}),d&&t?.fieldName&&(s?.current.push({fieldName:t.fieldName,ref:d}),d.current=c);try{ace.require("ace/ext/beautify").beautify(c.session)}catch(e){}}catch(e){console.log("JSON Editor ERROR =>",e.message)}}},22873:(e,t,a)=>{a.d(t,{A:()=>l});var r=a(71205);async function l({request:e,databaseSlug:t,user:a,query:l}){try{let s=a.id,d=null;if(!l?.delegated)return{dbUserId:s};let i=l.dbUserId,n=`${process.env.DSQL_USER_DB_PREFIX}${i}_${t}`,o=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${n}`;try{if(!e.cookies?.[o])throw Error("Cookie not present");let a=(0,r.A)({encryptedString:e.cookies[o]});if(!a)throw Error("Invalid Token");if((d=JSON.parse(a)).databaseSlug===t)return{dbUserId:s=d.rootUserId,rootUserId:d.rootUserId,rootUserName:d.rootUserName,rootUserEmail:d.rootUserEmail,rootUserImage:d.rootUserImage,databaseFullName:d.databaseFullName,databaseSlug:d.databaseSlug,allowedTables:d.allowedTables,priviledges:d.priviledges,database:d.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:s}}catch(e){return null}}},17855:(e,t,a)=>{a.d(t,{A:()=>r});let r=(0,a(82544).A)("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]])},52854:(e,t,a)=>{a.d(t,{A:()=>c});var r=a(71205);let l=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/;async function s({unparsedResults:e,tableSchema:t}){let a=[];try{for(let s=0;s<e.length;s++){let d=e[s],i=Object.keys(d);for(let e=0;e<i.length;e++){let a=i[e],s=t?.fields[e];if(a?.match(l))continue;let n=d[a];("number"==typeof n||n)&&s?.encrypted&&n?.match(/./)&&(d[a]=(0,r.A)({encryptedString:n}))}a.push(d)}return a}catch(t){return console.log("ERROR in parseDbResults Function =>",t.message),e}}var d=a(77047),i=a(71934),n=a(43651),o=a(16175);async function c({queryString:e,queryValuesArray:t,database:a,tableSchema:r,useLocal:l}){let c;let u=!!l||!!a?.match(/^datasquirel$/),m=l?o.A:u?i.A:n.A;try{c=e&&t&&Array.isArray(t)&&t[0]?u?await m(e,t):await m({paradigm:"Full Access",queryString:e,queryValues:t}):u?await m(e):await m({paradigm:"Full Access",queryString:e})}catch(e){console.log(`varDatabaseDbHandler Error: ${e.message}`),(0,d.A)({component:"varDatabaseDbHandler/lines-29-32",message:e.message})}if(c&&r)try{let e=c;return await s({unparsedResults:e,tableSchema:r})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",a,e),(0,d.A)({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(c)return c;else return null}},43651:(e,t,a)=>{async function r(e,t,a){try{if("string"==typeof t){let r=await e.query(l(t),a);return JSON.parse(JSON.stringify(r))}if("object"!=typeof t)return null;{let a=[];for(let r=0;r<t.length;r++)try{let s=t[r],d=await e.query(l(s.query),s.values);a.push(JSON.parse(JSON.stringify(d)))}catch(e){a.push(null)}return a}}catch(e){return null}finally{e.end()}}function l(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}async function s({paradigm:e,queryString:t,queryValues:a}){try{switch(e){case"Read Only":return await r(global.DSQL_READ_ONLY_DB_CONN,t,a);case"Full Access":case"FA":return await r(global.DSQL_FULL_ACCESS_DB_CONN,t,a);default:return null}}catch(e){return console.log(`DSQL_USER_DB_HANDLER Error: ${e.message}`),null}}a.d(t,{A:()=>s})},16175:(e,t,a)=>{a.d(t,{A:()=>i});var r=a(9973),l=a.n(r),s=a(29021),d=a.n(s);async function i(...e){let t=l()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let t=`${e}/ca-cert.pem`;if(!d().existsSync(t)){console.log(`${t} does not exist`);return}return{ca:d().readFileSync(`${e}/ca-cert.pem`),rejectUnauthorized:!1}}()},onConnect:()=>{console.log("Connection Successful!")},onConnectError:e=>{console.log("Connection Error",e.message)},onError:e=>{console.log("Client Error",e.message)}});console.log("Querying ...");try{let a=await t.query(...e);return await t.end(),JSON.parse(JSON.stringify(a))}catch(e){return console.log("DB Error =>",e.message),{success:!1,error:e.message}}}}}; |