"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2163],{98214:(e,t,l)=>{l.d(t,{A:()=>T});var a=l(74848),d=l(96540),i=l(620),r=l(17500),s=l(93813),n=l(5338);function o(e){let{editor:t,rootElement:l}=e;return(0,a.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,a.jsxs)("form",{onSubmit:e=>{e.preventDefault();let a=e.target["embed-text-area"].value;if(!(null==a?void 0:a.match(/./)))return alert("Please Enter HTML Text to continue.");t.insertContent(a),document.body.removeChild(l)},className:"w-full flex flex-col items-stretch gap-2",children:[(0,a.jsx)("h3",{className:"m-0 text-center text-lg",children:"Enter HTML code"}),(0,a.jsx)("textarea",{name:"embed-text-area",id:"embed-text-area",cols:30,rows:10,placeholder:"Paste Code here ..."}),(0,a.jsx)("button",{type:"submit",children:"Embed"})]})})}function c(e){let{editor:t}=e;navigator.clipboard.writeText((null==t?void 0:t.getContent())||"").then(()=>{alert("Html Copied to Clipboard!")})}var u=l(76897),m=l(85471),p=l.n(m);function f(e){let{editor:t,rootElement:l}=e,i=t.getContent(),r=d.useRef(),s=d.useRef(),[n,o]=d.useState(null);return d.useEffect(()=>{try{var e;if(!(null===(e=ace)||void 0===e?void 0:e.edit)||!r.current){console.log("Ace Editor not found!");return}let t=ace.edit(r.current);t.setOptions({mode:"ace/mode/html",value:p()(i)}),o(t);try{ace.require("ace/ext/beautify").beautify(t.session)}catch(e){}}catch(e){console.log("JSON Editor ERROR =>",e.message)}},[]),(0,a.jsxs)("div",{onKeyUp:e=>{if(e.ctrlKey&&"Enter"==e.key){var t;null===(t=s.current)||void 0===t||t.click()}},children:[(0,a.jsx)("div",{className:"embed-popup-form-content-wrapper relative flex flex-col items-center justify-center",children:(0,a.jsxs)("div",{className:"max-w-[1200px] rounded-md overflow-hidden bg-white w-[90vw] items-start justify-start relative",children:[(0,a.jsx)("div",{ref:r,className:"w-full h-[80vh] text-[18px]"}),(0,a.jsx)("button",{className:"absolute bottom-4 right-4",onClick:e=>{if(n){let e=n.getValue();t.setContent(e),setTimeout(()=>{document.body.removeChild(l)},200)}},ref:s,children:"Save"})]})}),(0,a.jsx)("button",{className:"absolute top-4 right-8 rounded-full white",onClick:()=>{try{document.body.removeChild(l)}catch(e){}},style:{width:"40px",height:"40px",padding:"0",zIndex:"12039800000"},children:(0,a.jsx)(u.A,{})})]})}function x(e){let{editor:t}=e,l=document.createElement("div");l.style.position="fixed",l.style.width="100vw",l.style.height="100vh",l.style.zIndex="123000000000000000",l.style.backgroundColor="rgba(0,0,0,0.8)",l.style.display="flex",l.style.alignItems="center",l.style.justifyContent="center",l.style.top="0",l.style.left="0",document.body.append(l),l.onclick=e=>{e.target.closest(".embed-popup-form-content-wrapper")||document.body.removeChild(l)},t&&n.createRoot(l).render((0,a.jsx)(f,{editor:t,rootElement:l}))}function h(e){let{editor:t}=e,l=document.createElement("div");l.style.position="fixed",l.style.width="100vw",l.style.height="100vh",l.style.zIndex="123000000000000000",l.style.backgroundColor="rgba(0,0,0,0.8)",l.style.display="flex",l.style.alignItems="center",l.style.justifyContent="center",l.style.top="0",l.style.left="0",document.body.append(l),l.onclick=e=>{if(e.target.closest(".embed-popup-form-content-wrapper")){console.log("Still In Form");return}document.body.removeChild(l)},t&&n.createRoot(l).render((0,a.jsx)(o,{editor:t,rootElement:l}))}function b(e){let{fieldObject:t,dataTypeSchema:l,richTextEditors:n,entry:o,currentRichTextEditorForms:u,entryPage:m,formButtonId:p}=e,[f,b]=d.useState(!1),y=d.useRef(),v=d.useRef();return d.useEffect(()=>{b(!0)},[]),d.useEffect(()=>{f&&(n.current.push({fieldName:t.fieldName||"",ref:v}),u.current.push({fieldName:t.fieldName||"",ref:v}))},[f]),(0,a.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full rich-text-editor-wrapper",children:[(0,a.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:t.fieldName,children:[t.encrypted&&(0,a.jsx)(r.A,{fontSize:"small",className:"opacity-50"}),(0,a.jsx)("span",{children:t.fieldName})]}),(0,a.jsxs)("div",{ref:y,id:t.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:[!f&&(0,a.jsx)(i.A,{}),f&&(0,a.jsx)(d.Fragment,{children:(0,a.jsx)(s.K,{tinymceScriptSrc:"/tinymce/tinymce.min.js",onInit:(e,t)=>{v.current=t},initialValue:t.defaultValue||(o&&t.fieldName&&o[t.fieldName]?o[t.fieldName]:""),init:{height:m?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:t.cssFiles||void 0,setup:e=>{!function(e){let{editor:t,formButtonId:l}=e;t.addShortcut("meta+13","Save Entry.",()=>{var e;window.confirm("Update this Form?")&&l&&(null===(e=document.getElementById(l))||void 0===e||e.click())}),t.addShortcut("meta+shift+e","Edit Code.",()=>{x({editor:t})}),t.addShortcut("meta+shift+d","Embed Code.",()=>{h({editor:t})}),t.addShortcut("meta+shift+c","Copy Code.",()=>{c({editor:t})}),t.ui.registry.addButton("editCode",{icon:"edit-block",onAction:e=>x({editor:t}),tooltip:"Edit HTML Code"}),t.ui.registry.addButton("embedCode",{icon:"sourcecode",onAction:e=>h({editor:t}),tooltip:"Embed Code"}),t.ui.registry.addButton("copyCode",{icon:"copy",onAction:e=>c({editor:t}),tooltip:"Copy HTML"})}({editor:e,formButtonId:p})}}})})]})]})}var y=l(23698);l(68553);var v=l(68698),g=l(61356),N=l(89894);function j(e){let{fieldObject:t,typeFinal:l,isExpanded:d,setHeight:i,COLLAPSED_HEIGHT:s,EXPANDED_HEIGHT:n}=e;return(0,a.jsxs)("div",{className:"gap-2 w-full",children:[(0,a.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:t.fieldName,children:[t.encrypted&&(0,a.jsx)(r.A,{fontSize:"small",className:"opacity-50"}),(0,a.jsx)("span",{children:t.fieldName})]}),(0,a.jsx)("div",{className:"px-4 py-1 bg-secondary text-white rounded-full text-sm font-bold -mt-2",children:(0,a.jsx)("span",{children:l})}),(0,a.jsxs)("div",{className:"ml-auto cursor-pointer gap-1 text-slate-400 hover:text-slate-800 -mt-2 items-center flex",onClick:e=>{d?i(s):i(n)},children:[(0,a.jsx)("span",{className:"font-semibold text-sm",children:d?"Collapse":"Expand"}),d?(0,a.jsx)(g.A,{size:18,className:"mt-[-1px]"}):(0,a.jsx)(N.A,{size:18,className:"mt-[-1px]"})]})]})}function w(e){let{fieldObject:t,dataTypeSchema:l,entry:i,entryPage:r,jsonTextEditors:s,type:n}=e,o=n||"json";try{let[e,l]=d.useState(0),[r,n]=d.useState(300),c=d.useRef(),u=d.useRef();return d.useEffect(()=>{(0,v.A)({editorRef:u,entry:i,fieldObject:t,editorHTMLElementRef:c,jsonTextEditors:s,setRefresh:l,language:o})},[e]),(0,a.jsx)(d.Fragment,{children:(0,a.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full rich-text-editor-wrapper",children:[(0,a.jsx)(j,{fieldObject:t,isExpanded:300!==r,setHeight:n,typeFinal:o,COLLAPSED_HEIGHT:300,EXPANDED_HEIGHT:600}),(0,a.jsx)(E,{height:r,jsonEditorRef:c})]})})}catch(e){return d.useEffect(()=>{(0,y.A)("/api/admin/clientError",{method:"post",body:{component:"DatabaseShellContent/catch-error-return",message:e.message}})},[]),(0,a.jsx)(d.Fragment,{children:(0,a.jsx)("span",{children:"Editor Load Error"})})}}function E(e){let{height:t,jsonEditorRef:l}=e;return(0,a.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:"".concat(t,"px")},children:(0,a.jsx)("div",{ref:l,className:"w-full text-[18px] h-full"})})}function T(e){var t,l,i,s,n,o,c,u,m;let{fieldObject:p,dataTypeSchema:f,richTextEditors:x,jsonTextEditors:h,entry:y,currentRichTextEditorForms:v,confirmedDelegetedUser:g,query:N,entryPage:j,formButtonId:E}=e;null==g||g.delegated,null==g||null===(t=g.priviledges)||void 0===t||t.match(/Edit Tables/i),null==g||null===(l=g.priviledges)||void 0===l||l.match(/Delete Tables/i),null==g||null===(i=g.priviledges)||void 0===i||i.match(/Create Tables/i),null==g||null===(s=g.priviledges)||void 0===s||s.match(/Edit Entries/i),null==g||null===(n=g.priviledges)||void 0===n||n.match(/Delete Entries/i);let T=function(e){var t,l,d,i,r,s,n,o;let c,{fieldObject:u,dataTypeSchema:m,elementRef:p,entry:f}=e,x=e=>{let t=e.target.closest("form");if(!t)return;let l=null==t?void 0:t.querySelector("#slug");l&&(l.value=e.target.value.toLowerCase().replace(/ /g,"-").replace(/[^a-z\-0-9]/g,""))};return u.defaultField?c=(0,a.jsx)("input",{ref:p,type:"text",name:"def_field_"+u.fieldName,id:"def_field_"+u.fieldName,placeholder:u.fieldName,defaultValue:f&&f[u.fieldName||""]?f[u.fieldName||""]:u.defaultValue?u.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},readOnly:!0,"data-default":"true"}):((null===(t=u.dataType)||void 0===t?void 0:t.match(/varchar/i))&&(c=(0,a.jsx)("textarea",{ref:p,name:u.fieldName,id:u.fieldName,placeholder:u.fieldName,required:!!u.notNullValue,maxLength:(null===(s=u.dataType)||void 0===s?void 0:null===(r=s.match(/\d+/))||void 0===r?void 0:r[0])?parseInt((null===(o=u.dataType)||void 0===o?void 0:null===(n=o.match(/\d+/))||void 0===n?void 0:n[0])||""):void 0,defaultValue:f&&f[u.fieldName||""]?f[u.fieldName||""]:u.defaultValue?u.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},onChange:e=>{var t;(null===(t=u.fieldName)||void 0===t?void 0:t.match(/^title$/))&&x(e)}})),(null===(l=u.dataType)||void 0===l?void 0:l.match(/int$/i))&&(c=(0,a.jsx)("input",{ref:p,type:"number",name:u.fieldName,id:u.fieldName,placeholder:u.fieldName,required:!!u.notNullValue,max:m.maxValue,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:f&&f[u.fieldName||""]?f[u.fieldName||""]:u.defaultValue?u.defaultValue:"",onChange:e=>{}})),(null===(d=u.dataType)||void 0===d?void 0:d.match(/text$/i))&&(c=(0,a.jsx)("textarea",{ref:p,name:u.fieldName,id:u.fieldName,placeholder:u.fieldName,required:!!u.notNullValue,defaultValue:f&&f[u.fieldName||""]?f[u.fieldName||""]:u.defaultValue?u.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},rows:10,onChange:e=>{}})),(null===(i=u.fieldName)||void 0===i?void 0:i.match(/password|^pass$|^key$/i))&&(c=(0,a.jsxs)("div",{className:"w-full relative",children:[(0,a.jsx)("input",{ref:p,type:"password",name:u.fieldName,id:u.fieldName,placeholder:u.fieldName,required:!!u.notNullValue,max:m.maxValue,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:f&&f[u.fieldName]?f[u.fieldName]:u.defaultValue?u.defaultValue:"",onChange:e=>{}}),(0,a.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"})]})),c||(c=(0,a.jsx)("input",{ref:p,type:"text",name:u.fieldName,id:u.fieldName,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:f&&f[u.fieldName||""]?f[u.fieldName||""]:u.defaultValue?u.defaultValue:"",onChange:e=>{}})),c)}({fieldObject:p,dataTypeSchema:f,elementRef:d.useRef(),entry:y});if((null===(o=p.dataType)||void 0===o?void 0:o.match(/text$/i))&&p.richText&&!p.plainText&&!(null===(c=p.fieldName)||void 0===c?void 0:c.match(/^pass|^key$/i))&&!p.encrypted||p.encrypted&&p.richText)return(0,a.jsx)(d.Fragment,{children:(0,a.jsx)(b,{fieldObject:p,dataTypeSchema:f,richTextEditors:x,currentRichTextEditorForms:v,entry:y,entryPage:j,formButtonId:E})});let C=p.json||p.yaml||p.html||p.css||p.javascript||p.shell;return(null===(u=p.dataType)||void 0===u?void 0:u.match(/text$/i))&&C&&!p.plainText&&!(null===(m=p.fieldName)||void 0===m?void 0:m.match(/^pass|^key$/i))&&!p.encrypted||p.encrypted&&C?(0,a.jsx)(w,{fieldObject:p,dataTypeSchema:f,entry:y,entryPage:j,jsonTextEditors:h,type:p.json?"json":p.yaml?"yaml":p.html?"html":p.css?"css":p.javascript?"javascript":p.shell?"shell":"json"}):(0,a.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full"+(p.defaultField?" opacity-50":""),children:[(0,a.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:p.fieldName,children:[p.encrypted&&(0,a.jsx)(d.Fragment,{children:(0,a.jsx)(r.A,{fontSize:"small",className:"opacity-50"})}),(0,a.jsx)("span",{children:p.fieldName}),p.defaultField&&(0,a.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"})]}),T]})}},68698:(e,t,l)=>{l.d(t,{A:()=>a});function a(e){let{editorHTMLElementRef:t,fieldObject:l,setRefresh:a,language:d="javascript",entry:i,jsonTextEditors:r,editorRef:s,readOnly:n,initialContent:o,options:c}=e;try{var u;if(!(null===(u=ace)||void 0===u?void 0:u.edit)||!t.current){console.log("Ace Editor not found!"),setTimeout(()=>{null==a||a(e=>e+1)},1e3);return}let e=ace.edit(t.current);e.setOptions({mode:"ace/mode/"+d,value:o||((null==l?void 0:l.defaultValue)?l.defaultValue:(null==l?void 0:l.fieldName)&&(null==i?void 0:i[l.fieldName])?(()=>{if("json"!==d)return i[l.fieldName];try{return JSON.stringify(JSON.parse(i[l.fieldName]),null,4)}catch(e){return i[l.fieldName]}})():""),placeholder:"json"==d?"{}":"",enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,readOnly:n,...c}),s&&(null==l?void 0:l.fieldName)&&(null==r||r.current.push({fieldName:l.fieldName,ref:s}),s.current=e);try{ace.require("ace/ext/beautify").beautify(e.session)}catch(e){}}catch(e){console.log("JSON Editor ERROR =>",e.message)}}},98070:(e,t,l)=>{l.d(t,{A:()=>i});var a=l(74848),d=l(96540);function i(e){let{table:t,database:l,user:i,activeDbClone:r}=e,s=(null==t?void 0:t.childTableDbFullName)?t.childTableDbFullName.replace(new RegExp(/datasquirel_user_\d+_/),""):null,n=t.childTableDbFullName===l.db_full_name;return s?(0,a.jsxs)("span",{className:"info small green gap-1"+((null==l?void 0:l.active_clone)?" -mt-6":""),style:{fontWeight:"500"},children:["This Table is an active clone of"," ",(0,a.jsx)("a",{href:"/admin/".concat(null==i?void 0:i.id,"/databases/").concat(s,"/tables/").concat(t.childTableName),target:"_blank",className:"button gray outlined small-text",style:{display:"inline-block",fontSize:"12px",padding:"3px 7px"},children:(0,a.jsx)("b",{children:t.childTableName})})," ","in"," ",n?(0,a.jsxs)("span",{children:["this current database(",(0,a.jsx)("b",{children:l.db_name}),")."]}):(0,a.jsxs)(d.Fragment,{children:[(0,a.jsx)("a",{href:"/admin/".concat(null==i?void 0:i.id,"/databases/").concat(s),target:"_blank",className:"button gray outlined small-text",style:{display:"inline-block",fontSize:"12px",padding:"3px 7px"},children:(0,a.jsx)("b",{children:s})}),(0,a.jsx)("span",{children:"database."})]})," ",(null==l?void 0:l.active_clone)?"":"Only Foreign keys and Entries can be updated."]}):(0,a.jsx)(d.Fragment,{})}}}]);