@devtable/settings-form 8.13.1 → 8.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(K,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@mantine/core"),require("@mantine/notifications"),require("react"),require("tabler-icons-react"),require("axios"),require("crypto-js"),require("lodash"),require("react-hook-form"),require("ahooks"),require("monaco-editor"),require("@mantine/modals")):typeof define=="function"&&define.amd?define(["exports","@mantine/core","@mantine/notifications","react","tabler-icons-react","axios","crypto-js","lodash","react-hook-form","ahooks","monaco-editor","@mantine/modals"],f):(K=typeof globalThis<"u"?globalThis:K||self,f(K["settings-form"]={},K["@mantine/core"],K["@mantine/notifications"],K.React,K["tabler-icons-react"],K.axios,K["crypto-js"],K._,K["react-hook-form"],K.ahooks,K["monaco-editor"],K["@mantine/modals"]))})(this,function(K,f,ee,O,Te,xr,Cr,jr,Y,Re,Ar,Ie){"use strict";const Ue=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function wt(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const xe=Ue(O),De=wt(O),Mr=Ue(xr),Ir=Ue(Cr),Dr=Ue(jr),zr=wt(Ar);function kr(e){e=e||{};const t=Object.keys(e).sort(),r=[];for(let o=0;o<t.length;o++){const s=t[o];if(s!="authentication"&&e[s])r.push(t[o]+"="+(typeof e[s]=="object"?JSON.stringify(e[s]):e[s]));else{const i=Object.keys(e[s]).sort();for(let c=0;c<i.length;c++){const u=i[c];u!="sign"&&e[s][u]&&r.push(i[c]+"="+(typeof e[s][u]=="object"?JSON.stringify(e[s][u]):e[s][u]))}}}return r.sort().join("&")}function qr(e,t){let r=kr(e);return r+="&key="+t,Ir.default.MD5(r).toString().toUpperCase()}const ae={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!this.app_id||!this.app_secret)return;const t=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:t,sign:qr({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e){return(t,r,o={})=>{const s=window.localStorage.getItem("token"),i={"X-Requested-With":"XMLHttpRequest","Content-Type":o.string?"application/x-www-form-urlencoded":"application/json",authorization:s?`bearer ${s}`:"",...o.headers},c={baseURL:this.baseURL,method:e,url:t,params:e==="GET"?r:o.params,headers:i};return["POST","PUT"].includes(e)&&(c.data=o.string?JSON.stringify(r):r,c.data.authentication=this.getAuthentication(c.data)),Mr.default(c).then(u=>u.data).catch(u=>Dr.default.has(u,"response.data.detail.message")?Promise.reject(new Error(u.response.data.detail.message)):Promise.reject(u))}}};function Be(e){ae.baseURL!==e.apiBaseURL&&(ae.baseURL=e.apiBaseURL),e.app_id&&(ae.app_id=e.app_id),e.app_secret&&(ae.app_secret=e.app_secret)}const de={datasource:{list:async()=>await ae.getRequest("POST")("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}}),create:async(e,t,r)=>await ae.getRequest("POST")("/datasource/create",{type:e,key:t,config:r}),delete:async e=>{await ae.getRequest("POST")("/datasource/delete",{id:e})}},account:{login:async(e,t)=>{const r={name:e,password:t};return await ae.getRequest("POST")("/account/login",r)},list:async()=>await ae.getRequest("POST")("/account/list",{filter:{},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}}),get:async()=>await ae.getRequest("GET")("/account/get",{}),update:async(e,t)=>{const r={name:e,email:t};return await ae.getRequest("PUT")("/account/update",r)},changepassword:async(e,t)=>{const r={old_password:e,new_password:t};return await ae.getRequest("POST")("/account/changepassword",r)},create:async(e,t,r,o)=>await ae.getRequest("POST")("/account/create",{name:e,email:t,password:r,role_id:o}),edit:async e=>(e.reset_password||(e.new_password=void 0),await ae.getRequest("PUT")("/account/edit",e)),delete:async e=>{if(!!e)return ae.getRequest("POST")("/account/delete",{id:e})}},role:{list:async()=>await ae.getRequest("GET")("/role/list",{})},api_key:{list:async()=>await ae.getRequest("POST")("/api/key/list",{filter:{search:""},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}}),create:async(e,t)=>ae.getRequest("POST")("/api/key/create",{name:e,role_id:t}),delete:async e=>{if(!!e)return ae.getRequest("POST")("/api/key/delete",{id:e})}}},Ce={size:"sm",spacing:"md",button:{size:"xs"}};var Ye={exports:{}},ze={};/**
1
+ (function(y,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@mantine/core"),require("@mantine/notifications"),require("react"),require("tabler-icons-react"),require("axios"),require("crypto-js"),require("lodash"),require("react-hook-form"),require("ahooks"),require("@monaco-editor/react"),require("monaco-editor"),require("monaco-editor/esm/vs/editor/editor.worker?worker"),require("monaco-editor/esm/vs/language/css/css.worker?worker"),require("monaco-editor/esm/vs/language/html/html.worker?worker"),require("monaco-editor/esm/vs/language/json/json.worker?worker"),require("monaco-editor/esm/vs/language/typescript/ts.worker?worker"),require("@mantine/modals")):typeof define=="function"&&define.amd?define(["exports","@mantine/core","@mantine/notifications","react","tabler-icons-react","axios","crypto-js","lodash","react-hook-form","ahooks","@monaco-editor/react","monaco-editor","monaco-editor/esm/vs/editor/editor.worker?worker","monaco-editor/esm/vs/language/css/css.worker?worker","monaco-editor/esm/vs/language/html/html.worker?worker","monaco-editor/esm/vs/language/json/json.worker?worker","monaco-editor/esm/vs/language/typescript/ts.worker?worker","@mantine/modals"],o):(y=typeof globalThis<"u"?globalThis:y||self,o(y["settings-form"]={},y["@mantine/core"],y["@mantine/notifications"],y.React,y["tabler-icons-react"],y.axios,y["crypto-js"],y._,y["react-hook-form"],y.ahooks,y["@monaco-editor/react"],y["monaco-editor"],y["monaco-editor/esm/vs/editor/editor"]["worker?worker"],y["monaco-editor/esm/vs/language/css/css"]["worker?worker"],y["monaco-editor/esm/vs/language/html/html"]["worker?worker"],y["monaco-editor/esm/vs/language/json/json"]["worker?worker"],y["monaco-editor/esm/vs/language/typescript/ts"]["worker?worker"],y["@mantine/modals"]))})(this,function(y,o,T,I,F,vt,bt,wt,P,V,ne,_t,yt,St,Ct,Pt,Rt,Q){"use strict";const q=t=>t&&typeof t=="object"&&"default"in t?t:{default:t};function Pe(t){if(t&&t.__esModule)return t;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,s.get?s:{enumerable:!0,get:()=>t[i]})}}return n.default=t,Object.freeze(n)}const Y=q(I),Z=Pe(I),Tt=q(vt),Et=q(bt),xt=q(wt),Ot=q(ne),zt=Pe(_t),kt=q(yt),At=q(St),jt=q(Ct),Dt=q(Pt),It=q(Rt);function qt(t){t=t||{};const n=Object.keys(t).sort(),i=[];for(let s=0;s<n.length;s++){const u=n[s];if(u!="authentication"&&t[u])i.push(n[s]+"="+(typeof t[u]=="object"?JSON.stringify(t[u]):t[u]));else{const l=Object.keys(t[u]).sort();for(let c=0;c<l.length;c++){const f=l[c];f!="sign"&&t[u][f]&&i.push(l[c]+"="+(typeof t[u][f]=="object"?JSON.stringify(t[u][f]):t[u][f]))}}}return i.sort().join("&")}function Nt(t,n){let i=qt(t);return i+="&key="+n,Et.default.MD5(i).toString().toUpperCase()}const O={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(t){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:Nt({app_id:this.app_id,nonce_str:n,...t},this.app_secret)}},getRequest(t){return(n,i,s={})=>{const u=window.localStorage.getItem("token"),l={"X-Requested-With":"XMLHttpRequest","Content-Type":s.string?"application/x-www-form-urlencoded":"application/json",authorization:u?`bearer ${u}`:"",...s.headers},c={baseURL:this.baseURL,method:t,url:n,params:t==="GET"?i:s.params,headers:l};return["POST","PUT"].includes(t)&&(c.data=s.string?JSON.stringify(i):i,c.data.authentication=this.getAuthentication(c.data)),Tt.default(c).then(f=>f.data).catch(f=>xt.default.has(f,"response.data.detail.message")?Promise.reject(new Error(f.response.data.detail.message)):Promise.reject(f))}}};function ie(t){O.baseURL!==t.apiBaseURL&&(O.baseURL=t.apiBaseURL),t.app_id&&(O.app_id=t.app_id),t.app_secret&&(O.app_secret=t.app_secret)}const j={datasource:{list:async()=>await O.getRequest("POST")("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}}),create:async(t,n,i)=>await O.getRequest("POST")("/datasource/create",{type:t,key:n,config:i}),delete:async t=>{await O.getRequest("POST")("/datasource/delete",{id:t})}},account:{login:async(t,n)=>{const i={name:t,password:n};return await O.getRequest("POST")("/account/login",i)},list:async()=>await O.getRequest("POST")("/account/list",{filter:{},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}}),get:async()=>await O.getRequest("GET")("/account/get",{}),update:async(t,n)=>{const i={name:t,email:n};return await O.getRequest("PUT")("/account/update",i)},changepassword:async(t,n)=>{const i={old_password:t,new_password:n};return await O.getRequest("POST")("/account/changepassword",i)},create:async(t,n,i,s)=>await O.getRequest("POST")("/account/create",{name:t,email:n,password:i,role_id:s}),edit:async t=>(t.reset_password||(t.new_password=void 0),await O.getRequest("PUT")("/account/edit",t)),delete:async t=>{if(!!t)return O.getRequest("POST")("/account/delete",{id:t})}},role:{list:async()=>await O.getRequest("GET")("/role/list",{})},api_key:{list:async()=>await O.getRequest("POST")("/api/key/list",{filter:{search:""},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}}),create:async(t,n)=>O.getRequest("POST")("/api/key/create",{name:t,role_id:n}),delete:async t=>{if(!!t)return O.getRequest("POST")("/api/key/delete",{id:t})}}},K={size:"sm",spacing:"md",button:{size:"xs"}};var ae={exports:{}},H={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var St;function $r(){if(St)return ze;St=1;var e=xe.default,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(u,p,m){var w,v={},y=null,j=null;m!==void 0&&(y=""+m),p.key!==void 0&&(y=""+p.key),p.ref!==void 0&&(j=p.ref);for(w in p)o.call(p,w)&&!i.hasOwnProperty(w)&&(v[w]=p[w]);if(u&&u.defaultProps)for(w in p=u.defaultProps,p)v[w]===void 0&&(v[w]=p[w]);return{$$typeof:t,type:u,key:y,ref:j,props:v,_owner:s.current}}return ze.Fragment=r,ze.jsx=c,ze.jsxs=c,ze}var ke={};/**
9
+ */var Re;function Lt(){if(Re)return H;Re=1;var t=Y.default,n=Symbol.for("react.element"),i=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,u=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(f,g,w){var S,h={},p=null,z=null;w!==void 0&&(p=""+w),g.key!==void 0&&(p=""+g.key),g.ref!==void 0&&(z=g.ref);for(S in g)s.call(g,S)&&!l.hasOwnProperty(S)&&(h[S]=g[S]);if(f&&f.defaultProps)for(S in g=f.defaultProps,g)h[S]===void 0&&(h[S]=g[S]);return{$$typeof:n,type:f,key:p,ref:z,props:h,_owner:u.current}}return H.Fragment=i,H.jsx=c,H.jsxs=c,H}var ee={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,45 +14,16 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Tt;function Lr(){return Tt||(Tt=1,process.env.NODE_ENV!=="production"&&function(){var e=xe.default,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),V=Symbol.iterator,q="@@iterator";function H(n){if(n===null||typeof n!="object")return null;var d=V&&n[V]||n[q];return typeof d=="function"?d:null}var Q=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function $(n){{for(var d=arguments.length,b=new Array(d>1?d-1:0),E=1;E<d;E++)b[E-1]=arguments[E];Z("error",n,b)}}function Z(n,d,b){{var E=Q.ReactDebugCurrentFrame,F=E.getStackAddendum();F!==""&&(d+="%s",b=b.concat([F]));var J=b.map(function(L){return String(L)});J.unshift("Warning: "+d),Function.prototype.apply.call(console[n],console,J)}}var G=!1,g=!1,te=!1,oe=!1,ye=!1,re;re=Symbol.for("react.module.reference");function W(n){return!!(typeof n=="string"||typeof n=="function"||n===o||n===i||ye||n===s||n===m||n===w||oe||n===j||G||g||te||typeof n=="object"&&n!==null&&(n.$$typeof===y||n.$$typeof===v||n.$$typeof===c||n.$$typeof===u||n.$$typeof===p||n.$$typeof===re||n.getModuleId!==void 0))}function pe(n,d,b){var E=n.displayName;if(E)return E;var F=d.displayName||d.name||"";return F!==""?b+"("+F+")":b}function me(n){return n.displayName||"Context"}function ce(n){if(n==null)return null;if(typeof n.tag=="number"&&$("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case o:return"Fragment";case r:return"Portal";case i:return"Profiler";case s:return"StrictMode";case m:return"Suspense";case w:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case u:var d=n;return me(d)+".Consumer";case c:var b=n;return me(b._context)+".Provider";case p:return pe(n,n.render,"ForwardRef");case v:var E=n.displayName||null;return E!==null?E:ce(n.type)||"Memo";case y:{var F=n,J=F._payload,L=F._init;try{return ce(L(J))}catch{return null}}}return null}var k=Object.assign,X=0,se,fe,be,Pe,l,h,P;function R(){}R.__reactDisabledLog=!0;function _(){{if(X===0){se=console.log,fe=console.info,be=console.warn,Pe=console.error,l=console.group,h=console.groupCollapsed,P=console.groupEnd;var n={configurable:!0,enumerable:!0,value:R,writable:!0};Object.defineProperties(console,{info:n,log:n,warn:n,error:n,group:n,groupCollapsed:n,groupEnd:n})}X++}}function A(){{if(X--,X===0){var n={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},n,{value:se}),info:k({},n,{value:fe}),warn:k({},n,{value:be}),error:k({},n,{value:Pe}),group:k({},n,{value:l}),groupCollapsed:k({},n,{value:h}),groupEnd:k({},n,{value:P})})}X<0&&$("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var x=Q.ReactCurrentDispatcher,C;function M(n,d,b){{if(C===void 0)try{throw Error()}catch(F){var E=F.stack.trim().match(/\n( *(at )?)/);C=E&&E[1]||""}return`
18
- `+C+n}}var N=!1,I;{var ue=typeof WeakMap=="function"?WeakMap:Map;I=new ue}function S(n,d){if(!n||N)return"";{var b=I.get(n);if(b!==void 0)return b}var E;N=!0;var F=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var J;J=x.current,x.current=null,_();try{if(d){var L=function(){throw Error()};if(Object.defineProperty(L.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(L,[])}catch(Se){E=Se}Reflect.construct(n,[],L)}else{try{L.call()}catch(Se){E=Se}n.call(L.prototype)}}else{try{throw Error()}catch(Se){E=Se}n()}}catch(Se){if(Se&&E&&typeof Se.stack=="string"){for(var z=Se.stack.split(`
19
- `),le=E.stack.split(`
20
- `),ne=z.length-1,ie=le.length-1;ne>=1&&ie>=0&&z[ne]!==le[ie];)ie--;for(;ne>=1&&ie>=0;ne--,ie--)if(z[ne]!==le[ie]){if(ne!==1||ie!==1)do if(ne--,ie--,ie<0||z[ne]!==le[ie]){var he=`
21
- `+z[ne].replace(" at new "," at ");return n.displayName&&he.includes("<anonymous>")&&(he=he.replace("<anonymous>",n.displayName)),typeof n=="function"&&I.set(n,he),he}while(ne>=1&&ie>=0);break}}}finally{N=!1,x.current=J,A(),Error.prepareStackTrace=F}var Me=n?n.displayName||n.name:"",_r=Me?M(Me):"";return typeof n=="function"&&I.set(n,_r),_r}function ge(n,d,b){return S(n,!1)}function je(n){var d=n.prototype;return!!(d&&d.isReactComponent)}function _e(n,d,b){if(n==null)return"";if(typeof n=="function")return S(n,je(n));if(typeof n=="string")return M(n);switch(n){case m:return M("Suspense");case w:return M("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case p:return ge(n.render);case v:return _e(n.type,d,b);case y:{var E=n,F=E._payload,J=E._init;try{return _e(J(F),d,b)}catch{}}}return""}var He=Object.prototype.hasOwnProperty,hr={},vr=Q.ReactDebugCurrentFrame;function et(n){if(n){var d=n._owner,b=_e(n.type,n._source,d?d.type:null);vr.setExtraStackFrame(b)}else vr.setExtraStackFrame(null)}function go(n,d,b,E,F){{var J=Function.call.bind(He);for(var L in n)if(J(n,L)){var z=void 0;try{if(typeof n[L]!="function"){var le=Error((E||"React class")+": "+b+" type `"+L+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[L]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw le.name="Invariant Violation",le}z=n[L](d,L,E,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ne){z=ne}z&&!(z instanceof Error)&&(et(F),$("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",E||"React class",b,L,typeof z),et(null)),z instanceof Error&&!(z.message in hr)&&(hr[z.message]=!0,et(F),$("Failed %s type: %s",b,z.message),et(null))}}}var ho=Array.isArray;function ht(n){return ho(n)}function vo(n){{var d=typeof Symbol=="function"&&Symbol.toStringTag,b=d&&n[Symbol.toStringTag]||n.constructor.name||"Object";return b}}function mo(n){try{return mr(n),!1}catch{return!0}}function mr(n){return""+n}function yr(n){if(mo(n))return $("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",vo(n)),mr(n)}var Fe=Q.ReactCurrentOwner,yo={key:!0,ref:!0,__self:!0,__source:!0},br,wr,vt;vt={};function bo(n){if(He.call(n,"ref")){var d=Object.getOwnPropertyDescriptor(n,"ref").get;if(d&&d.isReactWarning)return!1}return n.ref!==void 0}function wo(n){if(He.call(n,"key")){var d=Object.getOwnPropertyDescriptor(n,"key").get;if(d&&d.isReactWarning)return!1}return n.key!==void 0}function So(n,d){if(typeof n.ref=="string"&&Fe.current&&d&&Fe.current.stateNode!==d){var b=ce(Fe.current.type);vt[b]||($('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',ce(Fe.current.type),n.ref),vt[b]=!0)}}function To(n,d){{var b=function(){br||(br=!0,$("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",d))};b.isReactWarning=!0,Object.defineProperty(n,"key",{get:b,configurable:!0})}}function Eo(n,d){{var b=function(){wr||(wr=!0,$("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",d))};b.isReactWarning=!0,Object.defineProperty(n,"ref",{get:b,configurable:!0})}}var Oo=function(n,d,b,E,F,J,L){var z={$$typeof:t,type:n,key:d,ref:b,props:L,_owner:J};return z._store={},Object.defineProperty(z._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(z,"_self",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.defineProperty(z,"_source",{configurable:!1,enumerable:!1,writable:!1,value:F}),Object.freeze&&(Object.freeze(z.props),Object.freeze(z)),z};function Po(n,d,b,E,F){{var J,L={},z=null,le=null;b!==void 0&&(yr(b),z=""+b),wo(d)&&(yr(d.key),z=""+d.key),bo(d)&&(le=d.ref,So(d,F));for(J in d)He.call(d,J)&&!yo.hasOwnProperty(J)&&(L[J]=d[J]);if(n&&n.defaultProps){var ne=n.defaultProps;for(J in ne)L[J]===void 0&&(L[J]=ne[J])}if(z||le){var ie=typeof n=="function"?n.displayName||n.name||"Unknown":n;z&&To(L,ie),le&&Eo(L,ie)}return Oo(n,z,le,F,E,Fe.current,L)}}var mt=Q.ReactCurrentOwner,Sr=Q.ReactDebugCurrentFrame;function Ae(n){if(n){var d=n._owner,b=_e(n.type,n._source,d?d.type:null);Sr.setExtraStackFrame(b)}else Sr.setExtraStackFrame(null)}var yt;yt=!1;function bt(n){return typeof n=="object"&&n!==null&&n.$$typeof===t}function Tr(){{if(mt.current){var n=ce(mt.current.type);if(n)return`
17
+ */var Te;function Mt(){return Te||(Te=1,process.env.NODE_ENV!=="production"&&function(){var t=Y.default,n=Symbol.for("react.element"),i=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),f=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),z=Symbol.for("react.offscreen"),N=Symbol.iterator,W="@@iterator";function me(e){if(e===null||typeof e!="object")return null;var a=N&&e[N]||e[W];return typeof a=="function"?a:null}var U=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function k(e){{for(var a=arguments.length,d=new Array(a>1?a-1:0),m=1;m<a;m++)d[m-1]=arguments[m];or("error",e,d)}}function or(e,a,d){{var m=U.ReactDebugCurrentFrame,C=m.getStackAddendum();C!==""&&(a+="%s",d=d.concat([C]));var R=d.map(function(_){return String(_)});R.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,R)}}var sr=!1,lr=!1,cr=!1,ur=!1,dr=!1,Ye;Ye=Symbol.for("react.module.reference");function fr(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===l||dr||e===u||e===w||e===S||ur||e===z||sr||lr||cr||typeof e=="object"&&e!==null&&(e.$$typeof===p||e.$$typeof===h||e.$$typeof===c||e.$$typeof===f||e.$$typeof===g||e.$$typeof===Ye||e.getModuleId!==void 0))}function pr(e,a,d){var m=e.displayName;if(m)return m;var C=a.displayName||a.name||"";return C!==""?d+"("+C+")":d}function Ke(e){return e.displayName||"Context"}function M(e){if(e==null)return null;if(typeof e.tag=="number"&&k("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case s:return"Fragment";case i:return"Portal";case l:return"Profiler";case u:return"StrictMode";case w:return"Suspense";case S:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case f:var a=e;return Ke(a)+".Consumer";case c:var d=e;return Ke(d._context)+".Provider";case g:return pr(e,e.render,"ForwardRef");case h:var m=e.displayName||null;return m!==null?m:M(e.type)||"Memo";case p:{var C=e,R=C._payload,_=C._init;try{return M(_(R))}catch{return null}}}return null}var G=Object.assign,te=0,Je,Xe,Qe,Ze,He,et,tt;function rt(){}rt.__reactDisabledLog=!0;function gr(){{if(te===0){Je=console.log,Xe=console.info,Qe=console.warn,Ze=console.error,He=console.group,et=console.groupCollapsed,tt=console.groupEnd;var e={configurable:!0,enumerable:!0,value:rt,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}te++}}function mr(){{if(te--,te===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:G({},e,{value:Je}),info:G({},e,{value:Xe}),warn:G({},e,{value:Qe}),error:G({},e,{value:Ze}),group:G({},e,{value:He}),groupCollapsed:G({},e,{value:et}),groupEnd:G({},e,{value:tt})})}te<0&&k("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=U.ReactCurrentDispatcher,ve;function le(e,a,d){{if(ve===void 0)try{throw Error()}catch(C){var m=C.stack.trim().match(/\n( *(at )?)/);ve=m&&m[1]||""}return`
18
+ `+ve+e}}var be=!1,ce;{var hr=typeof WeakMap=="function"?WeakMap:Map;ce=new hr}function nt(e,a){if(!e||be)return"";{var d=ce.get(e);if(d!==void 0)return d}var m;be=!0;var C=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var R;R=he.current,he.current=null,gr();try{if(a){var _=function(){throw Error()};if(Object.defineProperty(_.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_,[])}catch(B){m=B}Reflect.construct(e,[],_)}else{try{_.call()}catch(B){m=B}e.call(_.prototype)}}else{try{throw Error()}catch(B){m=B}e()}}catch(B){if(B&&m&&typeof B.stack=="string"){for(var v=B.stack.split(`
19
+ `),A=m.stack.split(`
20
+ `),E=v.length-1,x=A.length-1;E>=1&&x>=0&&v[E]!==A[x];)x--;for(;E>=1&&x>=0;E--,x--)if(v[E]!==A[x]){if(E!==1||x!==1)do if(E--,x--,x<0||v[E]!==A[x]){var D=`
21
+ `+v[E].replace(" at new "," at ");return e.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",e.displayName)),typeof e=="function"&&ce.set(e,D),D}while(E>=1&&x>=0);break}}}finally{be=!1,he.current=R,mr(),Error.prepareStackTrace=C}var X=e?e.displayName||e.name:"",ht=X?le(X):"";return typeof e=="function"&&ce.set(e,ht),ht}function vr(e,a,d){return nt(e,!1)}function br(e){var a=e.prototype;return!!(a&&a.isReactComponent)}function ue(e,a,d){if(e==null)return"";if(typeof e=="function")return nt(e,br(e));if(typeof e=="string")return le(e);switch(e){case w:return le("Suspense");case S:return le("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case g:return vr(e.render);case h:return ue(e.type,a,d);case p:{var m=e,C=m._payload,R=m._init;try{return ue(R(C),a,d)}catch{}}}return""}var de=Object.prototype.hasOwnProperty,it={},at=U.ReactDebugCurrentFrame;function fe(e){if(e){var a=e._owner,d=ue(e.type,e._source,a?a.type:null);at.setExtraStackFrame(d)}else at.setExtraStackFrame(null)}function wr(e,a,d,m,C){{var R=Function.call.bind(de);for(var _ in e)if(R(e,_)){var v=void 0;try{if(typeof e[_]!="function"){var A=Error((m||"React class")+": "+d+" type `"+_+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[_]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw A.name="Invariant Violation",A}v=e[_](a,_,m,d,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){v=E}v&&!(v instanceof Error)&&(fe(C),k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",m||"React class",d,_,typeof v),fe(null)),v instanceof Error&&!(v.message in it)&&(it[v.message]=!0,fe(C),k("Failed %s type: %s",d,v.message),fe(null))}}}var _r=Array.isArray;function we(e){return _r(e)}function yr(e){{var a=typeof Symbol=="function"&&Symbol.toStringTag,d=a&&e[Symbol.toStringTag]||e.constructor.name||"Object";return d}}function Sr(e){try{return ot(e),!1}catch{return!0}}function ot(e){return""+e}function st(e){if(Sr(e))return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",yr(e)),ot(e)}var re=U.ReactCurrentOwner,Cr={key:!0,ref:!0,__self:!0,__source:!0},lt,ct,_e;_e={};function Pr(e){if(de.call(e,"ref")){var a=Object.getOwnPropertyDescriptor(e,"ref").get;if(a&&a.isReactWarning)return!1}return e.ref!==void 0}function Rr(e){if(de.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function Tr(e,a){if(typeof e.ref=="string"&&re.current&&a&&re.current.stateNode!==a){var d=M(re.current.type);_e[d]||(k('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',M(re.current.type),e.ref),_e[d]=!0)}}function Er(e,a){{var d=function(){lt||(lt=!0,k("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};d.isReactWarning=!0,Object.defineProperty(e,"key",{get:d,configurable:!0})}}function xr(e,a){{var d=function(){ct||(ct=!0,k("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};d.isReactWarning=!0,Object.defineProperty(e,"ref",{get:d,configurable:!0})}}var Or=function(e,a,d,m,C,R,_){var v={$$typeof:n,type:e,key:a,ref:d,props:_,_owner:R};return v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(v,"_self",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.defineProperty(v,"_source",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v};function zr(e,a,d,m,C){{var R,_={},v=null,A=null;d!==void 0&&(st(d),v=""+d),Rr(a)&&(st(a.key),v=""+a.key),Pr(a)&&(A=a.ref,Tr(a,C));for(R in a)de.call(a,R)&&!Cr.hasOwnProperty(R)&&(_[R]=a[R]);if(e&&e.defaultProps){var E=e.defaultProps;for(R in E)_[R]===void 0&&(_[R]=E[R])}if(v||A){var x=typeof e=="function"?e.displayName||e.name||"Unknown":e;v&&Er(_,x),A&&xr(_,x)}return Or(e,v,A,C,m,re.current,_)}}var ye=U.ReactCurrentOwner,ut=U.ReactDebugCurrentFrame;function J(e){if(e){var a=e._owner,d=ue(e.type,e._source,a?a.type:null);ut.setExtraStackFrame(d)}else ut.setExtraStackFrame(null)}var Se;Se=!1;function Ce(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function dt(){{if(ye.current){var e=M(ye.current.type);if(e)return`
22
22
 
23
- Check the render method of \``+n+"`."}return""}}function Ro(n){{if(n!==void 0){var d=n.fileName.replace(/^.*[\\\/]/,""),b=n.lineNumber;return`
23
+ Check the render method of \``+e+"`."}return""}}function kr(e){{if(e!==void 0){var a=e.fileName.replace(/^.*[\\\/]/,""),d=e.lineNumber;return`
24
24
 
25
- Check your code at `+d+":"+b+"."}return""}}var Er={};function _o(n){{var d=Tr();if(!d){var b=typeof n=="string"?n:n.displayName||n.name;b&&(d=`
25
+ Check your code at `+a+":"+d+"."}return""}}var ft={};function Ar(e){{var a=dt();if(!a){var d=typeof e=="string"?e:e.displayName||e.name;d&&(a=`
26
26
 
27
- Check the top-level render call using <`+b+">.")}return d}}function Or(n,d){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var b=_o(d);if(Er[b])return;Er[b]=!0;var E="";n&&n._owner&&n._owner!==mt.current&&(E=" It was passed a child from "+ce(n._owner.type)+"."),Ae(n),$('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,E),Ae(null)}}function Pr(n,d){{if(typeof n!="object")return;if(ht(n))for(var b=0;b<n.length;b++){var E=n[b];bt(E)&&Or(E,d)}else if(bt(n))n._store&&(n._store.validated=!0);else if(n){var F=H(n);if(typeof F=="function"&&F!==n.entries)for(var J=F.call(n),L;!(L=J.next()).done;)bt(L.value)&&Or(L.value,d)}}}function xo(n){{var d=n.type;if(d==null||typeof d=="string")return;var b;if(typeof d=="function")b=d.propTypes;else if(typeof d=="object"&&(d.$$typeof===p||d.$$typeof===v))b=d.propTypes;else return;if(b){var E=ce(d);go(b,n.props,"prop",E,n)}else if(d.PropTypes!==void 0&&!yt){yt=!0;var F=ce(d);$("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",F||"Unknown")}typeof d.getDefaultProps=="function"&&!d.getDefaultProps.isReactClassApproved&&$("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Co(n){{for(var d=Object.keys(n.props),b=0;b<d.length;b++){var E=d[b];if(E!=="children"&&E!=="key"){Ae(n),$("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",E),Ae(null);break}}n.ref!==null&&(Ae(n),$("Invalid attribute `ref` supplied to `React.Fragment`."),Ae(null))}}function Rr(n,d,b,E,F,J){{var L=W(n);if(!L){var z="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(z+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var le=Ro(F);le?z+=le:z+=Tr();var ne;n===null?ne="null":ht(n)?ne="array":n!==void 0&&n.$$typeof===t?(ne="<"+(ce(n.type)||"Unknown")+" />",z=" Did you accidentally export a JSX literal instead of a component?"):ne=typeof n,$("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ne,z)}var ie=Po(n,d,b,F,J);if(ie==null)return ie;if(L){var he=d.children;if(he!==void 0)if(E)if(ht(he)){for(var Me=0;Me<he.length;Me++)Pr(he[Me],n);Object.freeze&&Object.freeze(he)}else $("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Pr(he,n)}return n===o?Co(ie):xo(ie),ie}}function jo(n,d,b){return Rr(n,d,b,!0)}function Ao(n,d,b){return Rr(n,d,b,!1)}var Mo=Ao,Io=jo;ke.Fragment=o,ke.jsx=Mo,ke.jsxs=Io}()),ke}(function(e){process.env.NODE_ENV==="production"?e.exports=$r():e.exports=Lr()})(Ye);const we=Ye.exports.Fragment,a=Ye.exports.jsx,D=Ye.exports.jsxs;function Nr({submit:e,styles:t=Ce,type:r}){const{control:o,setValue:s,handleSubmit:i}=Y.useForm({defaultValues:{type:r,key:"",config:{host:"",port:5432,username:"",password:"",database:""}}});return O.useEffect(()=>{s("type",r)},[s,r]),a(f.Box,{mx:"auto",children:D("form",{onSubmit:i(e),children:[a(Y.Controller,{name:"key",control:o,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",placeholder:"A unique name",...c})}),a(f.Divider,{label:"Connection Info",labelPosition:"center"}),D(f.Group,{grow:!0,children:[a(Y.Controller,{name:"config.host",control:o,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Host",sx:{flexGrow:1},...c})}),a(Y.Controller,{name:"config.port",control:o,render:({field:c})=>a(f.NumberInput,{mb:t.spacing,size:t.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...c})})]}),a(Y.Controller,{name:"config.username",control:o,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...c})}),a(Y.Controller,{name:"config.password",control:o,render:({field:c})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...c})}),a(Y.Controller,{name:"config.database",control:o,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Database",...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Wr(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Et(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,o)}return r}function Ot(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Et(Object(r),!0).forEach(function(o){Wr(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Et(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Fr(e,t){if(e==null)return{};var r={},o=Object.keys(e),s,i;for(i=0;i<o.length;i++)s=o[i],!(t.indexOf(s)>=0)&&(r[s]=e[s]);return r}function Ur(e,t){if(e==null)return{};var r=Fr(e,t),o,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)o=i[s],!(t.indexOf(o)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,o)||(r[o]=e[o]))}return r}function Br(e,t){return Yr(e)||Vr(e,t)||Gr(e,t)||Kr()}function Yr(e){if(Array.isArray(e))return e}function Vr(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var r=[],o=!0,s=!1,i=void 0;try{for(var c=e[Symbol.iterator](),u;!(o=(u=c.next()).done)&&(r.push(u.value),!(t&&r.length===t));o=!0);}catch(p){s=!0,i=p}finally{try{!o&&c.return!=null&&c.return()}finally{if(s)throw i}}return r}}function Gr(e,t){if(!!e){if(typeof e=="string")return Pt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Pt(e,t)}}function Pt(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function Kr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
28
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jr(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Rt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,o)}return r}function _t(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rt(Object(r),!0).forEach(function(o){Jr(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rt(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Xr(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(o){return t.reduceRight(function(s,i){return i(s)},o)}}function qe(e){return function t(){for(var r=this,o=arguments.length,s=new Array(o),i=0;i<o;i++)s[i]=arguments[i];return s.length>=e.length?e.apply(this,s):function(){for(var c=arguments.length,u=new Array(c),p=0;p<c;p++)u[p]=arguments[p];return t.apply(r,[].concat(s,u))}}}function Ve(e){return{}.toString.call(e).includes("Object")}function Qr(e){return!Object.keys(e).length}function $e(e){return typeof e=="function"}function Zr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Hr(e,t){return Ve(t)||Ee("changeType"),Object.keys(t).some(function(r){return!Zr(e,r)})&&Ee("changeField"),t}function en(e){$e(e)||Ee("selectorType")}function tn(e){$e(e)||Ve(e)||Ee("handlerType"),Ve(e)&&Object.values(e).some(function(t){return!$e(t)})&&Ee("handlersType")}function rn(e){e||Ee("initialIsRequired"),Ve(e)||Ee("initialType"),Qr(e)&&Ee("initialContent")}function nn(e,t){throw new Error(e[t]||e.default)}var on={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ee=qe(nn)(on),Ge={changes:Hr,selector:en,handler:tn,initial:rn};function an(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ge.initial(e),Ge.handler(t);var r={current:e},o=qe(un)(r,t),s=qe(cn)(r),i=qe(Ge.changes)(e),c=qe(sn)(r);function u(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(w){return w};return Ge.selector(m),m(r.current)}function p(m){Xr(o,s,i,c)(m)}return[u,p]}function sn(e,t){return $e(t)?t(e.current):t}function cn(e,t){return e.current=_t(_t({},e.current),t),t}function un(e,t,r){return $e(t)?t(e.current):Object.keys(r).forEach(function(o){var s;return(s=t[o])===null||s===void 0?void 0:s.call(t,e.current[o])}),r}var ln={create:an},dn={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs"}};function fn(e){return function t(){for(var r=this,o=arguments.length,s=new Array(o),i=0;i<o;i++)s[i]=arguments[i];return s.length>=e.length?e.apply(this,s):function(){for(var c=arguments.length,u=new Array(c),p=0;p<c;p++)u[p]=arguments[p];return t.apply(r,[].concat(s,u))}}}function pn(e){return{}.toString.call(e).includes("Object")}function gn(e){return e||Ct("configIsRequired"),pn(e)||Ct("configType"),e.urls?(hn(),{paths:{vs:e.urls.monacoBase}}):e}function hn(){console.warn(xt.deprecation)}function vn(e,t){throw new Error(e[t]||e.default)}var xt={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
29
- You are using deprecated way of configuration.
30
-
31
- Instead of using
32
- monaco.config({ urls: { monacoBase: '...' } })
33
- use
34
- monaco.config({ paths: { vs: '...' } })
35
-
36
- For more please check the link https://github.com/suren-atoyan/monaco-loader#config
37
- `},Ct=fn(vn)(xt),mn={config:gn},yn=function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return function(s){return r.reduceRight(function(i,c){return c(i)},s)}};function jt(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],jt(e[r],t[r]))}),Ot(Ot({},e),t)}var bn={type:"cancelation",msg:"operation is manually canceled"};function tt(e){var t=!1,r=new Promise(function(o,s){e.then(function(i){return t?s(bn):o(i)}),e.catch(s)});return r.cancel=function(){return t=!0},r}var wn=ln.create({config:dn,isInitialized:!1,resolve:null,reject:null,monaco:null}),At=Br(wn,2),Le=At[0],Ke=At[1];function Sn(e){var t=mn.config(e),r=t.monaco,o=Ur(t,["monaco"]);Ke(function(s){return{config:jt(s.config,o),monaco:r}})}function Tn(){var e=Le(function(t){var r=t.monaco,o=t.isInitialized,s=t.resolve;return{monaco:r,isInitialized:o,resolve:s}});if(!e.isInitialized){if(Ke({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),tt(rt);if(window.monaco&&window.monaco.editor)return Mt(window.monaco),e.resolve(window.monaco),tt(rt);yn(En,Pn)(Rn)}return tt(rt)}function En(e){return document.body.appendChild(e)}function On(e){var t=document.createElement("script");return e&&(t.src=e),t}function Pn(e){var t=Le(function(o){var s=o.config,i=o.reject;return{config:s,reject:i}}),r=On("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function Rn(){var e=Le(function(r){var o=r.config,s=r.resolve,i=r.reject;return{config:o,resolve:s,reject:i}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){Mt(r),e.resolve(r)},function(r){e.reject(r)})}function Mt(e){Le().monaco||Ke({monaco:e})}function _n(){return Le(function(e){var t=e.monaco;return t})}var rt=new Promise(function(e,t){return Ke({resolve:e,reject:t})}),Ne={config:Sn,init:Tn,__getMonacoInstance:_n},T={exports:{}},nt={exports:{}},U={};/** @license React v16.13.1
38
- * react-is.production.min.js
39
- *
40
- * Copyright (c) Facebook, Inc. and its affiliates.
41
- *
42
- * This source code is licensed under the MIT license found in the
43
- * LICENSE file in the root directory of this source tree.
44
- */var It;function xn(){if(It)return U;It=1;var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,u=e?Symbol.for("react.context"):60110,p=e?Symbol.for("react.async_mode"):60111,m=e?Symbol.for("react.concurrent_mode"):60111,w=e?Symbol.for("react.forward_ref"):60112,v=e?Symbol.for("react.suspense"):60113,y=e?Symbol.for("react.suspense_list"):60120,j=e?Symbol.for("react.memo"):60115,V=e?Symbol.for("react.lazy"):60116,q=e?Symbol.for("react.block"):60121,H=e?Symbol.for("react.fundamental"):60117,Q=e?Symbol.for("react.responder"):60118,$=e?Symbol.for("react.scope"):60119;function Z(g){if(typeof g=="object"&&g!==null){var te=g.$$typeof;switch(te){case t:switch(g=g.type,g){case p:case m:case o:case i:case s:case v:return g;default:switch(g=g&&g.$$typeof,g){case u:case w:case V:case j:case c:return g;default:return te}}case r:return te}}}function G(g){return Z(g)===m}return U.AsyncMode=p,U.ConcurrentMode=m,U.ContextConsumer=u,U.ContextProvider=c,U.Element=t,U.ForwardRef=w,U.Fragment=o,U.Lazy=V,U.Memo=j,U.Portal=r,U.Profiler=i,U.StrictMode=s,U.Suspense=v,U.isAsyncMode=function(g){return G(g)||Z(g)===p},U.isConcurrentMode=G,U.isContextConsumer=function(g){return Z(g)===u},U.isContextProvider=function(g){return Z(g)===c},U.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===t},U.isForwardRef=function(g){return Z(g)===w},U.isFragment=function(g){return Z(g)===o},U.isLazy=function(g){return Z(g)===V},U.isMemo=function(g){return Z(g)===j},U.isPortal=function(g){return Z(g)===r},U.isProfiler=function(g){return Z(g)===i},U.isStrictMode=function(g){return Z(g)===s},U.isSuspense=function(g){return Z(g)===v},U.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===o||g===m||g===i||g===s||g===v||g===y||typeof g=="object"&&g!==null&&(g.$$typeof===V||g.$$typeof===j||g.$$typeof===c||g.$$typeof===u||g.$$typeof===w||g.$$typeof===H||g.$$typeof===Q||g.$$typeof===$||g.$$typeof===q)},U.typeOf=Z,U}var B={};/** @license React v16.13.1
45
- * react-is.development.js
46
- *
47
- * Copyright (c) Facebook, Inc. and its affiliates.
48
- *
49
- * This source code is licensed under the MIT license found in the
50
- * LICENSE file in the root directory of this source tree.
51
- */var Dt;function Cn(){return Dt||(Dt=1,process.env.NODE_ENV!=="production"&&function(){var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,u=e?Symbol.for("react.context"):60110,p=e?Symbol.for("react.async_mode"):60111,m=e?Symbol.for("react.concurrent_mode"):60111,w=e?Symbol.for("react.forward_ref"):60112,v=e?Symbol.for("react.suspense"):60113,y=e?Symbol.for("react.suspense_list"):60120,j=e?Symbol.for("react.memo"):60115,V=e?Symbol.for("react.lazy"):60116,q=e?Symbol.for("react.block"):60121,H=e?Symbol.for("react.fundamental"):60117,Q=e?Symbol.for("react.responder"):60118,$=e?Symbol.for("react.scope"):60119;function Z(S){return typeof S=="string"||typeof S=="function"||S===o||S===m||S===i||S===s||S===v||S===y||typeof S=="object"&&S!==null&&(S.$$typeof===V||S.$$typeof===j||S.$$typeof===c||S.$$typeof===u||S.$$typeof===w||S.$$typeof===H||S.$$typeof===Q||S.$$typeof===$||S.$$typeof===q)}function G(S){if(typeof S=="object"&&S!==null){var ge=S.$$typeof;switch(ge){case t:var je=S.type;switch(je){case p:case m:case o:case i:case s:case v:return je;default:var _e=je&&je.$$typeof;switch(_e){case u:case w:case V:case j:case c:return _e;default:return ge}}case r:return ge}}}var g=p,te=m,oe=u,ye=c,re=t,W=w,pe=o,me=V,ce=j,k=r,X=i,se=s,fe=v,be=!1;function Pe(S){return be||(be=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),l(S)||G(S)===p}function l(S){return G(S)===m}function h(S){return G(S)===u}function P(S){return G(S)===c}function R(S){return typeof S=="object"&&S!==null&&S.$$typeof===t}function _(S){return G(S)===w}function A(S){return G(S)===o}function x(S){return G(S)===V}function C(S){return G(S)===j}function M(S){return G(S)===r}function N(S){return G(S)===i}function I(S){return G(S)===s}function ue(S){return G(S)===v}B.AsyncMode=g,B.ConcurrentMode=te,B.ContextConsumer=oe,B.ContextProvider=ye,B.Element=re,B.ForwardRef=W,B.Fragment=pe,B.Lazy=me,B.Memo=ce,B.Portal=k,B.Profiler=X,B.StrictMode=se,B.Suspense=fe,B.isAsyncMode=Pe,B.isConcurrentMode=l,B.isContextConsumer=h,B.isContextProvider=P,B.isElement=R,B.isForwardRef=_,B.isFragment=A,B.isLazy=x,B.isMemo=C,B.isPortal=M,B.isProfiler=N,B.isStrictMode=I,B.isSuspense=ue,B.isValidElementType=Z,B.typeOf=G}()),B}var zt;function kt(){return zt||(zt=1,function(e){process.env.NODE_ENV==="production"?e.exports=xn():e.exports=Cn()}(nt)),nt.exports}/*
52
- object-assign
53
- (c) Sindre Sorhus
54
- @license MIT
55
- */var ot,qt;function jn(){if(qt)return ot;qt=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function o(i){if(i==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(i)}function s(){try{if(!Object.assign)return!1;var i=new String("abc");if(i[5]="de",Object.getOwnPropertyNames(i)[0]==="5")return!1;for(var c={},u=0;u<10;u++)c["_"+String.fromCharCode(u)]=u;var p=Object.getOwnPropertyNames(c).map(function(w){return c[w]});if(p.join("")!=="0123456789")return!1;var m={};return"abcdefghijklmnopqrst".split("").forEach(function(w){m[w]=w}),Object.keys(Object.assign({},m)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return ot=s()?Object.assign:function(i,c){for(var u,p=o(i),m,w=1;w<arguments.length;w++){u=Object(arguments[w]);for(var v in u)t.call(u,v)&&(p[v]=u[v]);if(e){m=e(u);for(var y=0;y<m.length;y++)r.call(u,m[y])&&(p[m[y]]=u[m[y]])}}return p},ot}var it,$t;function at(){if($t)return it;$t=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return it=e,it}var st,Lt;function Nt(){return Lt||(Lt=1,st=Function.call.bind(Object.prototype.hasOwnProperty)),st}var ct,Wt;function An(){if(Wt)return ct;Wt=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=at(),r={},o=Nt();e=function(i){var c="Warning: "+i;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(i,c,u,p,m){if(process.env.NODE_ENV!=="production"){for(var w in i)if(o(i,w)){var v;try{if(typeof i[w]!="function"){var y=Error((p||"React class")+": "+u+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw y.name="Invariant Violation",y}v=i[w](c,w,p,u,null,t)}catch(V){v=V}if(v&&!(v instanceof Error)&&e((p||"React class")+": type specification of "+u+" `"+w+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof v+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),v instanceof Error&&!(v.message in r)){r[v.message]=!0;var j=m?m():"";e("Failed "+u+" type: "+v.message+(j!=null?j:""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(r={})},ct=s,ct}var ut,Ft;function Mn(){if(Ft)return ut;Ft=1;var e=kt(),t=jn(),r=at(),o=Nt(),s=An(),i=function(){};process.env.NODE_ENV!=="production"&&(i=function(u){var p="Warning: "+u;typeof console<"u"&&console.error(p);try{throw new Error(p)}catch{}});function c(){return null}return ut=function(u,p){var m=typeof Symbol=="function"&&Symbol.iterator,w="@@iterator";function v(l){var h=l&&(m&&l[m]||l[w]);if(typeof h=="function")return h}var y="<<anonymous>>",j={array:Q("array"),bigint:Q("bigint"),bool:Q("boolean"),func:Q("function"),number:Q("number"),object:Q("object"),string:Q("string"),symbol:Q("symbol"),any:$(),arrayOf:Z,element:G(),elementType:g(),instanceOf:te,node:W(),objectOf:ye,oneOf:oe,oneOfType:re,shape:me,exact:ce};function V(l,h){return l===h?l!==0||1/l===1/h:l!==l&&h!==h}function q(l,h){this.message=l,this.data=h&&typeof h=="object"?h:{},this.stack=""}q.prototype=Error.prototype;function H(l){if(process.env.NODE_ENV!=="production")var h={},P=0;function R(A,x,C,M,N,I,ue){if(M=M||y,I=I||C,ue!==r){if(p){var S=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw S.name="Invariant Violation",S}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ge=M+":"+C;!h[ge]&&P<3&&(i("You are manually calling a React.PropTypes validation function for the `"+I+"` prop on `"+M+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),h[ge]=!0,P++)}}return x[C]==null?A?x[C]===null?new q("The "+N+" `"+I+"` is marked as required "+("in `"+M+"`, but its value is `null`.")):new q("The "+N+" `"+I+"` is marked as required in "+("`"+M+"`, but its value is `undefined`.")):null:l(x,C,M,N,I)}var _=R.bind(null,!1);return _.isRequired=R.bind(null,!0),_}function Q(l){function h(P,R,_,A,x,C){var M=P[R],N=se(M);if(N!==l){var I=fe(M);return new q("Invalid "+A+" `"+x+"` of type "+("`"+I+"` supplied to `"+_+"`, expected ")+("`"+l+"`."),{expectedType:l})}return null}return H(h)}function $(){return H(c)}function Z(l){function h(P,R,_,A,x){if(typeof l!="function")return new q("Property `"+x+"` of component `"+_+"` has invalid PropType notation inside arrayOf.");var C=P[R];if(!Array.isArray(C)){var M=se(C);return new q("Invalid "+A+" `"+x+"` of type "+("`"+M+"` supplied to `"+_+"`, expected an array."))}for(var N=0;N<C.length;N++){var I=l(C,N,_,A,x+"["+N+"]",r);if(I instanceof Error)return I}return null}return H(h)}function G(){function l(h,P,R,_,A){var x=h[P];if(!u(x)){var C=se(x);return new q("Invalid "+_+" `"+A+"` of type "+("`"+C+"` supplied to `"+R+"`, expected a single ReactElement."))}return null}return H(l)}function g(){function l(h,P,R,_,A){var x=h[P];if(!e.isValidElementType(x)){var C=se(x);return new q("Invalid "+_+" `"+A+"` of type "+("`"+C+"` supplied to `"+R+"`, expected a single ReactElement type."))}return null}return H(l)}function te(l){function h(P,R,_,A,x){if(!(P[R]instanceof l)){var C=l.name||y,M=Pe(P[R]);return new q("Invalid "+A+" `"+x+"` of type "+("`"+M+"` supplied to `"+_+"`, expected ")+("instance of `"+C+"`."))}return null}return H(h)}function oe(l){if(!Array.isArray(l))return process.env.NODE_ENV!=="production"&&(arguments.length>1?i("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):i("Invalid argument supplied to oneOf, expected an array.")),c;function h(P,R,_,A,x){for(var C=P[R],M=0;M<l.length;M++)if(V(C,l[M]))return null;var N=JSON.stringify(l,function(ue,S){var ge=fe(S);return ge==="symbol"?String(S):S});return new q("Invalid "+A+" `"+x+"` of value `"+String(C)+"` "+("supplied to `"+_+"`, expected one of "+N+"."))}return H(h)}function ye(l){function h(P,R,_,A,x){if(typeof l!="function")return new q("Property `"+x+"` of component `"+_+"` has invalid PropType notation inside objectOf.");var C=P[R],M=se(C);if(M!=="object")return new q("Invalid "+A+" `"+x+"` of type "+("`"+M+"` supplied to `"+_+"`, expected an object."));for(var N in C)if(o(C,N)){var I=l(C,N,_,A,x+"."+N,r);if(I instanceof Error)return I}return null}return H(h)}function re(l){if(!Array.isArray(l))return process.env.NODE_ENV!=="production"&&i("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var h=0;h<l.length;h++){var P=l[h];if(typeof P!="function")return i("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+be(P)+" at index "+h+"."),c}function R(_,A,x,C,M){for(var N=[],I=0;I<l.length;I++){var ue=l[I],S=ue(_,A,x,C,M,r);if(S==null)return null;S.data&&o(S.data,"expectedType")&&N.push(S.data.expectedType)}var ge=N.length>0?", expected one of type ["+N.join(", ")+"]":"";return new q("Invalid "+C+" `"+M+"` supplied to "+("`"+x+"`"+ge+"."))}return H(R)}function W(){function l(h,P,R,_,A){return k(h[P])?null:new q("Invalid "+_+" `"+A+"` supplied to "+("`"+R+"`, expected a ReactNode."))}return H(l)}function pe(l,h,P,R,_){return new q((l||"React class")+": "+h+" type `"+P+"."+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+_+"`.")}function me(l){function h(P,R,_,A,x){var C=P[R],M=se(C);if(M!=="object")return new q("Invalid "+A+" `"+x+"` of type `"+M+"` "+("supplied to `"+_+"`, expected `object`."));for(var N in l){var I=l[N];if(typeof I!="function")return pe(_,A,x,N,fe(I));var ue=I(C,N,_,A,x+"."+N,r);if(ue)return ue}return null}return H(h)}function ce(l){function h(P,R,_,A,x){var C=P[R],M=se(C);if(M!=="object")return new q("Invalid "+A+" `"+x+"` of type `"+M+"` "+("supplied to `"+_+"`, expected `object`."));var N=t({},P[R],l);for(var I in N){var ue=l[I];if(o(l,I)&&typeof ue!="function")return pe(_,A,x,I,fe(ue));if(!ue)return new q("Invalid "+A+" `"+x+"` key `"+I+"` supplied to `"+_+"`.\nBad object: "+JSON.stringify(P[R],null," ")+`
56
- Valid keys: `+JSON.stringify(Object.keys(l),null," "));var S=ue(C,I,_,A,x+"."+I,r);if(S)return S}return null}return H(h)}function k(l){switch(typeof l){case"number":case"string":case"undefined":return!0;case"boolean":return!l;case"object":if(Array.isArray(l))return l.every(k);if(l===null||u(l))return!0;var h=v(l);if(h){var P=h.call(l),R;if(h!==l.entries){for(;!(R=P.next()).done;)if(!k(R.value))return!1}else for(;!(R=P.next()).done;){var _=R.value;if(_&&!k(_[1]))return!1}}else return!1;return!0;default:return!1}}function X(l,h){return l==="symbol"?!0:h?h["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&h instanceof Symbol:!1}function se(l){var h=typeof l;return Array.isArray(l)?"array":l instanceof RegExp?"object":X(h,l)?"symbol":h}function fe(l){if(typeof l>"u"||l===null)return""+l;var h=se(l);if(h==="object"){if(l instanceof Date)return"date";if(l instanceof RegExp)return"regexp"}return h}function be(l){var h=fe(l);switch(h){case"array":case"object":return"an "+h;case"boolean":case"date":case"regexp":return"a "+h;default:return h}}function Pe(l){return!l.constructor||!l.constructor.name?y:l.constructor.name}return j.checkPropTypes=s,j.resetWarningCache=s.resetWarningCache,j.PropTypes=j,j},ut}var lt,Ut;function In(){if(Ut)return lt;Ut=1;var e=at();function t(){}function r(){}return r.resetWarningCache=t,lt=function(){function o(c,u,p,m,w,v){if(v!==e){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}}o.isRequired=o;function s(){return o}var i={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:s,element:o,elementType:o,instanceOf:s,node:o,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:r,resetWarningCache:t};return i.PropTypes=i,i},lt}if(process.env.NODE_ENV!=="production"){var Dn=kt(),zn=!0;T.exports=Mn()(Dn.isElement,zn)}else T.exports=In()();const kn={display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"};function qn({content:e}){return a("div",{style:kn,children:e})}const dt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}};function Bt({width:e,height:t,isEditorReady:r,loading:o,_ref:s,className:i,wrapperProps:c}){return D("section",{style:{...dt.wrapper,width:e,height:t},...c,children:[!r&&a(qn,{content:o}),a("div",{ref:s,style:{...dt.fullWidth,...!r&&dt.hide},className:i})]})}Bt.propTypes={width:T.exports.oneOfType([T.exports.number,T.exports.string]).isRequired,height:T.exports.oneOfType([T.exports.number,T.exports.string]).isRequired,loading:T.exports.oneOfType([T.exports.element,T.exports.string]).isRequired,isEditorReady:T.exports.bool.isRequired,className:T.exports.string,wrapperProps:T.exports.object};var Yt=O.memo(Bt);function Vt(e){O.useEffect(e,[])}function ve(e,t,r=!0){const o=O.useRef(!0);O.useEffect(o.current||!r?()=>{o.current=!1}:e,t)}function We(){}function Je(e,t,r,o){return $n(e,o)||Ln(e,t,r,o)}function $n(e,t){return e.editor.getModel(Gt(e,t))}function Ln(e,t,r,o){return e.editor.createModel(t,r,o&&Gt(e,o))}function Gt(e,t){return e.Uri.parse(t)}function Nn(e){return e===void 0}function Kt({original:e,modified:t,language:r,originalLanguage:o,modifiedLanguage:s,originalModelPath:i,modifiedModelPath:c,keepCurrentOriginalModel:u,keepCurrentModifiedModel:p,theme:m,loading:w,options:v,height:y,width:j,className:V,wrapperProps:q,beforeMount:H,onMount:Q}){const[$,Z]=O.useState(!1),[G,g]=O.useState(!0),te=O.useRef(null),oe=O.useRef(null),ye=O.useRef(null),re=O.useRef(Q),W=O.useRef(H);Vt(()=>{const k=Ne.init();return k.then(X=>(oe.current=X)&&g(!1)).catch(X=>(X==null?void 0:X.type)!=="cancelation"&&console.error("Monaco initialization: error:",X)),()=>te.current?ce():k.cancel()}),ve(()=>{const k=te.current.getModifiedEditor();k.getOption(oe.current.editor.EditorOption.readOnly)?k.setValue(t):t!==k.getValue()&&(k.executeEdits("",[{range:k.getModel().getFullModelRange(),text:t,forceMoveMarkers:!0}]),k.pushUndoStop())},[t],$),ve(()=>{te.current.getModel().original.setValue(e)},[e],$),ve(()=>{const{original:k,modified:X}=te.current.getModel();oe.current.editor.setModelLanguage(k,o||r),oe.current.editor.setModelLanguage(X,s||r)},[r,o,s],$),ve(()=>{oe.current.editor.setTheme(m)},[m],$),ve(()=>{te.current.updateOptions(v)},[v],$);const pe=O.useCallback(()=>{W.current(oe.current);const k=Je(oe.current,e,o||r,i),X=Je(oe.current,t,s||r,c);te.current.setModel({original:k,modified:X})},[r,t,s,e,o,i,c]),me=O.useCallback(()=>{te.current=oe.current.editor.createDiffEditor(ye.current,{automaticLayout:!0,...v}),pe(),oe.current.editor.setTheme(m),Z(!0)},[v,m,pe]);O.useEffect(()=>{$&&re.current(te.current,oe.current)},[$]),O.useEffect(()=>{!G&&!$&&me()},[G,$,me]);function ce(){const k=te.current.getModel();if(!u){var X;(X=k.original)===null||X===void 0||X.dispose()}if(!p){var se;(se=k.modified)===null||se===void 0||se.dispose()}te.current.dispose()}return a(Yt,{width:j,height:y,isEditorReady:$,loading:w,_ref:ye,className:V,wrapperProps:q})}Kt.propTypes={original:T.exports.string,modified:T.exports.string,language:T.exports.string,originalLanguage:T.exports.string,modifiedLanguage:T.exports.string,originalModelPath:T.exports.string,modifiedModelPath:T.exports.string,keepCurrentOriginalModel:T.exports.bool,keepCurrentModifiedModel:T.exports.bool,theme:T.exports.string,loading:T.exports.oneOfType([T.exports.element,T.exports.string]),options:T.exports.object,width:T.exports.oneOfType([T.exports.number,T.exports.string]),height:T.exports.oneOfType([T.exports.number,T.exports.string]),className:T.exports.string,wrapperProps:T.exports.object,beforeMount:T.exports.func,onMount:T.exports.func},Kt.defaultProps={theme:"light",loading:"Loading...",options:{},keepCurrentOriginalModel:!1,keepCurrentModifiedModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:We,onMount:We};function Wn(e){const t=O.useRef();return O.useEffect(()=>{t.current=e},[e]),t.current}const Xe=new Map;function ft({defaultValue:e,defaultLanguage:t,defaultPath:r,value:o,language:s,path:i,theme:c,line:u,loading:p,options:m,overrideServices:w,saveViewState:v,keepCurrentModel:y,width:j,height:V,className:q,wrapperProps:H,beforeMount:Q,onMount:$,onChange:Z,onValidate:G}){const[g,te]=O.useState(!1),[oe,ye]=O.useState(!0),re=O.useRef(null),W=O.useRef(null),pe=O.useRef(null),me=O.useRef($),ce=O.useRef(Q),k=O.useRef(null),X=O.useRef(o),se=Wn(i),fe=O.useRef(!1);Vt(()=>{const l=Ne.init();return l.then(h=>(re.current=h)&&ye(!1)).catch(h=>(h==null?void 0:h.type)!=="cancelation"&&console.error("Monaco initialization: error:",h)),()=>W.current?Pe():l.cancel()}),ve(()=>{const l=Je(re.current,e||o,t||s,i);l!==W.current.getModel()&&(v&&Xe.set(se,W.current.saveViewState()),W.current.setModel(l),v&&W.current.restoreViewState(Xe.get(i)))},[i],g),ve(()=>{W.current.updateOptions(m)},[m],g),ve(()=>{W.current.getOption(re.current.editor.EditorOption.readOnly)?W.current.setValue(o):o!==W.current.getValue()&&(W.current.executeEdits("",[{range:W.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),W.current.pushUndoStop())},[o],g),ve(()=>{re.current.editor.setModelLanguage(W.current.getModel(),s)},[s],g),ve(()=>{Nn(u)||W.current.revealLine(u)},[u],g),ve(()=>{re.current.editor.setTheme(c)},[c],g);const be=O.useCallback(()=>{if(!fe.current){ce.current(re.current);const l=i||r,h=Je(re.current,o||e,t||s,l);W.current=re.current.editor.create(pe.current,{model:h,automaticLayout:!0,...m},w),v&&W.current.restoreViewState(Xe.get(l)),re.current.editor.setTheme(c),te(!0),fe.current=!0}},[e,t,r,o,s,i,m,w,v,c]);O.useEffect(()=>{g&&me.current(W.current,re.current)},[g]),O.useEffect(()=>{!oe&&!g&&be()},[oe,g,be]),X.current=o,O.useEffect(()=>{if(g&&Z){var l,h;(l=k.current)===null||l===void 0||l.dispose(),k.current=(h=W.current)===null||h===void 0?void 0:h.onDidChangeModelContent(P=>{Z(W.current.getValue(),P)})}},[g,Z]),O.useEffect(()=>{if(g){const l=re.current.editor.onDidChangeMarkers(h=>{var P;const R=(P=W.current.getModel())===null||P===void 0?void 0:P.uri;if(R&&h.find(A=>A.path===R.path)){const A=re.current.editor.getModelMarkers({resource:R});G==null||G(A)}});return()=>{l==null||l.dispose()}}},[g,G]);function Pe(){var l;if((l=k.current)===null||l===void 0||l.dispose(),y)v&&Xe.set(i,W.current.saveViewState());else{var h;(h=W.current.getModel())===null||h===void 0||h.dispose()}W.current.dispose()}return a(Yt,{width:j,height:V,isEditorReady:g,loading:p,_ref:pe,className:q,wrapperProps:H})}ft.propTypes={defaultValue:T.exports.string,defaultPath:T.exports.string,defaultLanguage:T.exports.string,value:T.exports.string,language:T.exports.string,path:T.exports.string,theme:T.exports.string,line:T.exports.number,loading:T.exports.oneOfType([T.exports.element,T.exports.string]),options:T.exports.object,overrideServices:T.exports.object,saveViewState:T.exports.bool,keepCurrentModel:T.exports.bool,width:T.exports.oneOfType([T.exports.number,T.exports.string]),height:T.exports.oneOfType([T.exports.number,T.exports.string]),className:T.exports.string,wrapperProps:T.exports.object,beforeMount:T.exports.func,onMount:T.exports.func,onChange:T.exports.func,onValidate:T.exports.func},ft.defaultProps={theme:"light",loading:"Loading...",options:{},overrideServices:{},saveViewState:!0,keepCurrentModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:We,onMount:We,onValidate:We};var Fn=O.memo(ft);function Un(){return new Worker("/assets/editor.worker.64456f42.js")}function Bn(){return new Worker("/assets/css.worker.72a68640.js")}function Yn(){return new Worker("/assets/html.worker.76e8b0f3.js")}function Vn(){return new Worker("/assets/json.worker.e7a84e5c.js")}function Gn(){return new Worker("/assets/ts.worker.b3dc4cb9.js")}self.MonacoEnvironment={getWorker(e,t){return t==="json"?new Vn:t==="css"||t==="scss"||t==="less"?new Bn:t==="html"||t==="handlebars"||t==="razor"?new Yn:t==="typescript"||t==="javascript"?new Gn:new Un}};function Kn(){Ne.__getMonacoInstance()||(console.log("loading monaco"),Ne.config({monaco:zr}),Ne.init().then(t=>console.log("here is the monaco instance:",t)))}Kn();const Jn=({value:e,onChange:t})=>{const r=o=>{!o||t(o)};return a(f.Box,{sx:{position:"relative"},children:a(Fn,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Jt=O.forwardRef(({value:e,onChange:t,label:r,modalTitle:o,defaultValue:s,styles:i},c)=>{const[u,{setTrue:p,setFalse:m}]=Re.useBoolean(),[w,v]=O.useState(e),y=()=>{m(),t(w)},j=()=>{m(),v(e)},V=()=>{v(s)};return O.useEffect(()=>{v(e)},[e]),D(we,{children:[a(f.Button,{variant:"filled",size:i.button.size,onClick:p,sx:{flexGrow:1},children:r}),a(f.Modal,{size:800,title:o,opened:u,onClose:m,closeOnClickOutside:!1,withCloseButton:!1,children:u&&D(f.Stack,{children:[a(Jn,{value:w,onChange:v}),D(f.Group,{position:"apart",children:[a(f.Button,{onClick:V,color:"red",leftIcon:a(Te.Recycle,{size:20}),children:"Rest"}),D(f.Group,{position:"right",children:[a(f.Button,{onClick:j,variant:"subtle",children:"Cancel"}),a(f.Button,{onClick:y,children:"OK"})]})]})]})})]})}),Qe={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
27
+ Check the top-level render call using <`+d+">.")}return a}}function pt(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var d=Ar(a);if(ft[d])return;ft[d]=!0;var m="";e&&e._owner&&e._owner!==ye.current&&(m=" It was passed a child from "+M(e._owner.type)+"."),J(e),k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,m),J(null)}}function gt(e,a){{if(typeof e!="object")return;if(we(e))for(var d=0;d<e.length;d++){var m=e[d];Ce(m)&&pt(m,a)}else if(Ce(e))e._store&&(e._store.validated=!0);else if(e){var C=me(e);if(typeof C=="function"&&C!==e.entries)for(var R=C.call(e),_;!(_=R.next()).done;)Ce(_.value)&&pt(_.value,a)}}}function jr(e){{var a=e.type;if(a==null||typeof a=="string")return;var d;if(typeof a=="function")d=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===g||a.$$typeof===h))d=a.propTypes;else return;if(d){var m=M(a);wr(d,e.props,"prop",m,e)}else if(a.PropTypes!==void 0&&!Se){Se=!0;var C=M(a);k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",C||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Dr(e){{for(var a=Object.keys(e.props),d=0;d<a.length;d++){var m=a[d];if(m!=="children"&&m!=="key"){J(e),k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",m),J(null);break}}e.ref!==null&&(J(e),k("Invalid attribute `ref` supplied to `React.Fragment`."),J(null))}}function mt(e,a,d,m,C,R){{var _=fr(e);if(!_){var v="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(v+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var A=kr(C);A?v+=A:v+=dt();var E;e===null?E="null":we(e)?E="array":e!==void 0&&e.$$typeof===n?(E="<"+(M(e.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,v)}var x=zr(e,a,d,C,R);if(x==null)return x;if(_){var D=a.children;if(D!==void 0)if(m)if(we(D)){for(var X=0;X<D.length;X++)gt(D[X],e);Object.freeze&&Object.freeze(D)}else k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else gt(D,e)}return e===s?Dr(x):jr(x),x}}function Ir(e,a,d){return mt(e,a,d,!0)}function qr(e,a,d){return mt(e,a,d,!1)}var Nr=qr,Lr=Ir;ee.Fragment=s,ee.jsx=Nr,ee.jsxs=Lr}()),ee}(function(t){process.env.NODE_ENV==="production"?t.exports=Lt():t.exports=Mt()})(ae);const L=ae.exports.Fragment,r=ae.exports.jsx,b=ae.exports.jsxs;function Bt({submit:t,styles:n=K,type:i}){const{control:s,setValue:u,handleSubmit:l}=P.useForm({defaultValues:{type:i,key:"",config:{host:"",port:5432,username:"",password:"",database:""}}});return I.useEffect(()=>{u("type",i)},[u,i]),r(o.Box,{mx:"auto",children:b("form",{onSubmit:l(t),children:[r(P.Controller,{name:"key",control:s,render:({field:c})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",placeholder:"A unique name",...c})}),r(o.Divider,{label:"Connection Info",labelPosition:"center"}),b(o.Group,{grow:!0,children:[r(P.Controller,{name:"config.host",control:s,render:({field:c})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Host",sx:{flexGrow:1},...c})}),r(P.Controller,{name:"config.port",control:s,render:({field:c})=>r(o.NumberInput,{mb:n.spacing,size:n.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...c})})]}),r(P.Controller,{name:"config.username",control:s,render:({field:c})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...c})}),r(P.Controller,{name:"config.password",control:s,render:({field:c})=>r(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...c})}),r(P.Controller,{name:"config.database",control:s,render:({field:c})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Database",...c})}),r(o.Group,{position:"right",mt:n.spacing,children:r(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}self.MonacoEnvironment={getWorker(t,n){return n==="json"?new Dt.default:n==="css"||n==="scss"||n==="less"?new At.default:n==="html"||n==="handlebars"||n==="razor"?new jt.default:n==="typescript"||n==="javascript"?new It.default:new kt.default}};function Ft(){ne.loader.__getMonacoInstance()||(console.log("loading monaco"),ne.loader.config({monaco:zt}),ne.loader.init().then(n=>console.log("here is the monaco instance:",n)))}Ft();const $t=({value:t,onChange:n})=>{const i=s=>{!s||n(s)};return r(o.Box,{sx:{position:"relative"},children:r(Ot.default,{height:"500px",defaultLanguage:"javascript",value:t,onChange:i,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Ee=I.forwardRef(({value:t,onChange:n,label:i,modalTitle:s,defaultValue:u,styles:l},c)=>{const[f,{setTrue:g,setFalse:w}]=V.useBoolean(),[S,h]=I.useState(t),p=()=>{w(),n(S)},z=()=>{w(),h(t)},N=()=>{h(u)};return I.useEffect(()=>{h(t)},[t]),b(L,{children:[r(o.Button,{variant:"filled",size:l.button.size,onClick:g,sx:{flexGrow:1},children:i}),r(o.Modal,{size:800,title:s,opened:f,onClose:w,closeOnClickOutside:!1,withCloseButton:!1,children:f&&b(o.Stack,{children:[r($t,{value:S,onChange:h}),b(o.Group,{position:"apart",children:[r(o.Button,{onClick:N,color:"red",leftIcon:r(F.Recycle,{size:20}),children:"Rest"}),b(o.Group,{position:"right",children:[r(o.Button,{onClick:z,variant:"subtle",children:"Cancel"}),r(o.Button,{onClick:p,children:"OK"})]})]})]})})]})}),oe={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
57
28
  `),post:["function post_process(res, utils) {"," // your code goes here"," return data","}"].join(`
58
- `)};function Xn({submit:e,styles:t=Ce}){const{control:r,setValue:o,handleSubmit:s}=Y.useForm({defaultValues:{type:"http",key:"",config:{host:"",processing:{pre:Qe.pre,post:Qe.post}}}});return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(e),children:[a(Y.Controller,{name:"key",control:r,render:({field:i})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",placeholder:"A unique name",...i})}),a(f.Divider,{label:"Connection Info",labelPosition:"center"}),a(Y.Controller,{name:"config.host",control:r,render:({field:i})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Base URL",sx:{flexGrow:1},...i})}),D(f.Group,{grow:!0,children:[a(Y.Controller,{name:"config.processing.pre",control:r,render:({field:i})=>a(Jt,{label:"Pre Processing",modalTitle:"This function will run before sending the request (for scenarios like encryption)",defaultValue:Qe.pre,...i,styles:t})}),a(Y.Controller,{name:"config.processing.post",control:r,render:({field:i})=>a(Jt,{label:"Post Processing",modalTitle:"This function will run after sending the request (for scenarios like decryption)",defaultValue:Qe.post,...i,styles:t})})]}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Qn({postSubmit:e,styles:t=Ce}){const[r,o]=O.useState("postgresql"),s=async({type:u,key:p,config:m})=>{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{console.log({type:u,key:p,config:m}),await de.datasource.create(u,p,m),ee.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),e()}catch(w){ee.updateNotification({id:"for-creating",title:"Failed",message:w.message,color:"red"})}},i=r==="postgresql"||r==="mysql",c=r==="http";return D(f.Box,{mx:"auto",children:[a(f.SegmentedControl,{fullWidth:!0,mb:t.spacing,size:t.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http"}],value:r,onChange:u=>o(u)}),i&&a(Nr,{submit:s,styles:t,type:r}),c&&a(Xn,{submit:s,styles:t})]})}function Xt({onSuccess:e,styles:t=Ce}){const[r,o]=xe.default.useState(!1),s=()=>o(!0),i=()=>o(!1),c=()=>{e(),i()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:r,onClose:()=>o(!1),title:"Add a data source",trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:a(Qn,{postSubmit:c,styles:t})}),a(f.Button,{size:t.button.size,onClick:s,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function pt(){return pt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},pt.apply(this,arguments)}function Zn(e,t){if(e==null)return{};var r,o,s=function(c,u){if(c==null)return{};var p,m,w={},v=Object.keys(c);for(m=0;m<v.length;m++)p=v[m],u.indexOf(p)>=0||(w[p]=c[p]);return w}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}var Hn=["size","color","stroke"];function eo(e){var t=e.size,r=t===void 0?24:t,o=e.color,s=o===void 0?"currentColor":o,i=e.stroke,c=i===void 0?2:i,u=Zn(e,Hn);return De.createElement("svg",pt({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-lock",width:r,height:r,viewBox:"0 0 24 24",strokeWidth:c,stroke:s,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},u),De.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),De.createElement("rect",{x:5,y:11,width:14,height:10,rx:2}),De.createElement("circle",{cx:12,cy:16,r:1}),De.createElement("path",{d:"M8 11v-4a4 4 0 0 1 8 0v4"}))}function Qt({id:e,name:t,isProtected:r,onSuccess:o,styles:s=Ce}){const i=Ie.useModals(),c=async()=>{!e||(ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await de.datasource.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${t}] is deleted`,color:"green"}),o())},u=()=>i.openConfirmModal({title:"Delete this data source?",children:a(f.Text,{size:s.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:c}),p=f.useMantineTheme();return r?a(f.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:a("span",{children:a(eo,{size:16,color:p.colors.gray[7]})})}):a(f.Button,{size:s.button.size,color:"red",onClick:u,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function to({styles:e=Ce,config:t}){Be(t);const{data:r=[],loading:o,refresh:s}=Re.useRequest(async()=>{const{data:i}=await de.datasource.list();return i},{refreshDeps:[]});return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Xt,{onSuccess:s})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:o}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Type"}),a("th",{children:"Name"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(({id:i,key:c,type:u,is_preset:p})=>D("tr",{children:[a("td",{width:200,children:u}),a("td",{children:c}),a("td",{width:200,children:a(f.Group,{position:"left",children:a(Qt,{isProtected:p,id:i,name:c,onSuccess:s})})})]},c))})]})]})]})}const ro=O.forwardRef(({label:e,value:t,description:r,...o},s)=>D(f.Stack,{spacing:2,ref:s,...o,children:[a(f.Text,{size:"sm",children:e}),a(f.Text,{size:"xs",color:"dimmed",className:"role-description",children:r})]})),gt=O.forwardRef(({styles:e,value:t,onChange:r},o)=>{const{data:s=[],loading:i}=Re.useRequest(async()=>(await de.role.list()).map(u=>({label:u.name,value:u.id,description:u.description,disabled:u.id===50})),{refreshDeps:[]});return a(f.Select,{ref:o,mb:e.spacing,size:e.size,required:!0,label:"Role",itemComponent:ro,data:s,disabled:i,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:t,onChange:r})}),Oe={size:"sm",spacing:"md",button:{size:"xs"}};function no({postSubmit:e,styles:t=Oe,initialRoleID:r}){const{control:o,handleSubmit:s}=Y.useForm({defaultValues:{name:"",email:"",role_id:r,password:""}}),i=async({name:c,email:u,password:p,role_id:m})=>{try{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await de.account.create(c,u,p,m),ee.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),e()}catch(w){ee.updateNotification({id:"for-creating",title:"Failed",message:w.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(i),children:[a(Y.Controller,{name:"name",control:o,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...c})}),a(Y.Controller,{name:"email",control:o,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Email",...c})}),a(Y.Controller,{name:"password",control:o,render:({field:c})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...c})}),a(Y.Controller,{name:"role_id",control:o,render:({field:c})=>a(gt,{styles:t,...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Zt({onSuccess:e,styles:t=Oe,initialRoleID:r}){const[o,s]=xe.default.useState(!1),i=()=>s(!0),c=()=>s(!1),u=()=>{e(),c()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:o,onClose:()=>s(!1),title:"Add an Account",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a(no,{postSubmit:u,styles:t,initialRoleID:r})}),a(f.Button,{size:t.button.size,onClick:i,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Ht({id:e,name:t,onSuccess:r,styles:o=Oe}){const s=Ie.useModals(),i=async()=>{if(!!e){ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await de.account.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${t}] is deleted`,color:"green"}),r()}catch(u){ee.updateNotification({id:"for-deleting",title:"Failed",message:u.message,color:"red"})}}},c=()=>s.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return a(f.Button,{size:o.button.size,color:"red",onClick:c,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function oo({id:e,name:t,email:r,role_id:o,postSubmit:s,styles:i=Oe}){const{control:c,handleSubmit:u,watch:p}=Y.useForm({defaultValues:{name:t,email:r,role_id:o,reset_password:!1,new_password:""}}),m=async({name:y,email:j,role_id:V,reset_password:q,new_password:H})=>{try{ee.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await de.account.edit({id:e,name:y,email:j,role_id:V,reset_password:q,new_password:H}),ee.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),s()}catch(Q){ee.updateNotification({id:"for-updating",title:"Failed",message:Q.message,color:"red"})}},[w,v]=p(["reset_password","new_password"]);return a(f.Box,{mx:"auto",children:D("form",{onSubmit:u(m),children:[a(Y.Controller,{name:"name",control:c,render:({field:y})=>a(f.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Username",...y})}),a(Y.Controller,{name:"email",control:c,render:({field:y})=>a(f.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Email",...y})}),a(Y.Controller,{name:"role_id",control:c,render:({field:y})=>a(gt,{styles:i,...y})}),a(f.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),a(Y.Controller,{name:"reset_password",control:c,render:({field:y})=>a(f.Switch,{mb:i.spacing,size:i.size,label:"Reset password",checked:y.value,onChange:j=>y.onChange(j.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),w&&a(Y.Controller,{name:"new_password",control:c,render:({field:y})=>a(f.PasswordInput,{autoComplete:"off",mb:i.spacing,size:i.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...y})}),a(f.Group,{position:"right",mt:i.spacing,children:a(f.Button,{type:"submit",size:i.button.size,children:"Submit"})})]})})}function io({account:e,onSuccess:t,styles:r=Oe}){const[o,s]=xe.default.useState(!1),i=()=>s(!0),c=()=>s(!1),u=()=>{t(),c()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:o,onClose:()=>s(!1),title:`Editing ${e.name}`,trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a(oo,{...e,postSubmit:u,styles:r})}),a(f.Button,{size:r.button.size,onClick:i,leftIcon:a(Te.Edit,{size:20}),children:"Edit"})]})}function ao({styles:e=Oe,config:t}){var m,w;Be(t);const{data:r=[],loading:o,refresh:s}=Re.useRequest(async()=>{const{data:v}=await de.account.list();return v},{refreshDeps:[]}),{data:i=[],loading:c}=Re.useRequest(async()=>(await de.role.list()).map(y=>({label:y.name,value:y.id,description:y.description,disabled:y.id===50})),{refreshDeps:[]}),u=O.useMemo(()=>i.reduce((v,y)=>(v.set(y.value,y.label),v),new Map),[i]),p=v=>{var y;return(y=u.get(v))!=null?y:v};return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Zt,{onSuccess:s,initialRoleID:(w=(m=i==null?void 0:i[0])==null?void 0:m.value)!=null?w:0})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:o||c}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Username"}),a("th",{children:"Email"}),a("th",{children:"Role"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(v=>{const{id:y,name:j,email:V,role_id:q}=v;return D("tr",{children:[a("td",{width:200,children:j}),a("td",{width:200,children:V}),a("td",{width:200,children:p(q)}),a("td",{width:200,children:D(f.Group,{position:"left",children:[a(io,{account:v,onSuccess:s}),a(Ht,{id:y,name:j,onSuccess:s})]})})]},y)})})]})]})]})}function so({postSubmit:e,styles:t=Oe}){const{control:r,handleSubmit:o}=Y.useForm({defaultValues:{name:"",password:""}}),s=async({name:i,password:c})=>{try{ee.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const u=await de.account.login(i,c);window.localStorage.setItem("token",u.token),ee.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),e(u)}catch(u){ee.updateNotification({id:"for-login",title:"Login Failed",message:u.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:o(s),children:[a(Y.Controller,{name:"name",control:r,render:({field:i})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...i})}),a(Y.Controller,{name:"password",control:r,render:({field:i})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...i})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Submit"})})]})})}function co({styles:e=Oe,config:t,onSuccess:r}){return Be(t),a(we,{children:a(f.Box,{mt:e.spacing,sx:{position:"relative"},children:a(so,{styles:e,postSubmit:r})})})}const Ze={size:"sm",spacing:"md",button:{size:"xs"}};function uo({postSubmit:e,styles:t=Ze,initialRoleID:r}){const{control:o,handleSubmit:s}=Y.useForm({defaultValues:{name:"",role_id:r}}),i=async({name:c,role_id:u})=>{try{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:p,app_secret:m}=await de.api_key.create(c,u);ee.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),e(p,m)}catch(p){ee.updateNotification({id:"for-creating",title:"Failed",message:p.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(i),children:[a(Y.Controller,{name:"name",control:o,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...c})}),a(Y.Controller,{name:"role_id",control:o,render:({field:c})=>a(gt,{styles:t,...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function er({onSuccess:e,styles:t=Ze,initialRoleID:r}){const o=Ie.useModals(),[s,i]=xe.default.useState(!1),c=()=>i(!0),u=()=>i(!1),p=(m,w)=>{u(),o.openModal({title:"API Key is generated",children:D(f.Stack,{children:[a(f.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),a(f.TextInput,{defaultValue:m,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),a(f.TextInput,{defaultValue:w,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),a(f.Button,{size:"sm",onClick:()=>{Ie.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{e()}})};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:s,onClose:()=>i(!1),title:"Add an API Key",trapFocus:!0,onDragStart:m=>{m.stopPropagation()},children:a(uo,{postSubmit:p,styles:t,initialRoleID:r})}),a(f.Button,{size:t.button.size,onClick:c,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function tr({id:e,name:t,onSuccess:r,styles:o=Ze}){const s=Ie.useModals(),i=async()=>{if(!!e){ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await de.api_key.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${t}] is deleted`,color:"green"}),r()}catch(u){ee.updateNotification({id:"for-deleting",title:"Failed",message:u.message,color:"red"})}}},c=()=>s.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return a(f.Button,{size:o.button.size,color:"red",onClick:c,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function lo({styles:e=Ze,config:t}){var m,w;Be(t);const{data:r=[],loading:o,refresh:s}=Re.useRequest(async()=>{const{data:v}=await de.api_key.list();return v},{refreshDeps:[]}),{data:i=[],loading:c}=Re.useRequest(async()=>(await de.role.list()).map(y=>({label:y.name,value:y.id,description:y.description,disabled:y.id===50})),{refreshDeps:[]}),u=O.useMemo(()=>i.reduce((v,y)=>(v.set(y.value,y.label),v),new Map),[i]),p=v=>{var y;return(y=u.get(v))!=null?y:v};return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(er,{onSuccess:s,initialRoleID:(w=(m=i==null?void 0:i[0])==null?void 0:m.value)!=null?w:0})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:o||c}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Name"}),a("th",{children:"APP ID"}),a("th",{children:"Role"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(v=>{const{id:y,name:j,app_id:V,role_id:q}=v;return D("tr",{children:[a("td",{width:200,children:j}),a("td",{width:200,children:V}),a("td",{width:200,children:p(q)}),a("td",{width:200,children:a(f.Group,{position:"left",children:a(tr,{id:y,name:j,onSuccess:s})})})]},y)})})]})]})]})}const fo=()=>Promise.resolve().then(()=>po).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e)),rr="@devtable/settings-form",nr="8.13.1",or="Apache-2.0",ir={access:"public",registry:"https://registry.npmjs.org/"},ar=["dist"],sr="./dist/settings-form.umd.js",cr="./dist/settings-form.es.js",ur="./dist/index.d.ts",lr={".":{import:"./dist/settings-form.es.js",require:"./dist/settings-form.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},dr={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview"},fr={"@monaco-editor/react":"4.4.6","monaco-editor":"0.36.0"},pr={"@types/crypto-js":"v4.1.1","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2","rollup-plugin-visualizer":"5.6.0",typescript:"^4.6.3"},gr={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5",ahooks:"^3.3.11",axios:"^0.27.2","crypto-js":"^4.1.1",lodash:"^4.17.21",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-hook-form":"^7.31.2","tabler-icons-react":"^1.48.0"},po=Object.freeze(Object.defineProperty({__proto__:null,name:rr,version:nr,license:or,publishConfig:ir,files:ar,main:sr,module:cr,types:ur,exports:lr,scripts:dr,dependencies:fr,devDependencies:pr,peerDependencies:gr,default:{name:rr,version:nr,license:or,publishConfig:ir,files:ar,main:sr,module:cr,types:ur,exports:lr,scripts:dr,dependencies:fr,devDependencies:pr,peerDependencies:gr}},Symbol.toStringTag,{value:"Module"}));K.APIKeyList=lo,K.AccountList=ao,K.AddAPIKey=er,K.AddAccount=Zt,K.AddDataSource=Xt,K.DataSourceList=to,K.DeleteAPIKey=tr,K.DeleteAccount=Ht,K.DeleteDataSource=Qt,K.Login=co,K.getVersion=fo,Object.defineProperties(K,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
29
+ `)};function Ut({submit:t,styles:n=K}){const{control:i,setValue:s,handleSubmit:u}=P.useForm({defaultValues:{type:"http",key:"",config:{host:"",processing:{pre:oe.pre,post:oe.post}}}});return r(o.Box,{mx:"auto",children:b("form",{onSubmit:u(t),children:[r(P.Controller,{name:"key",control:i,render:({field:l})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",placeholder:"A unique name",...l})}),r(o.Divider,{label:"Connection Info",labelPosition:"center"}),r(P.Controller,{name:"config.host",control:i,render:({field:l})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Base URL",sx:{flexGrow:1},...l})}),b(o.Group,{grow:!0,children:[r(P.Controller,{name:"config.processing.pre",control:i,render:({field:l})=>r(Ee,{label:"Pre Processing",modalTitle:"This function will run before sending the request (for scenarios like encryption)",defaultValue:oe.pre,...l,styles:n})}),r(P.Controller,{name:"config.processing.post",control:i,render:({field:l})=>r(Ee,{label:"Post Processing",modalTitle:"This function will run after sending the request (for scenarios like decryption)",defaultValue:oe.post,...l,styles:n})})]}),r(o.Group,{position:"right",mt:n.spacing,children:r(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Vt({postSubmit:t,styles:n=K}){const[i,s]=I.useState("postgresql"),u=async({type:f,key:g,config:w})=>{T.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{console.log({type:f,key:g,config:w}),await j.datasource.create(f,g,w),T.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),t()}catch(S){T.updateNotification({id:"for-creating",title:"Failed",message:S.message,color:"red"})}},l=i==="postgresql"||i==="mysql",c=i==="http";return b(o.Box,{mx:"auto",children:[r(o.SegmentedControl,{fullWidth:!0,mb:n.spacing,size:n.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http"}],value:i,onChange:f=>s(f)}),l&&r(Bt,{submit:u,styles:n,type:i}),c&&r(Ut,{submit:u,styles:n})]})}function xe({onSuccess:t,styles:n=K}){const[i,s]=Y.default.useState(!1),u=()=>s(!0),l=()=>s(!1),c=()=>{t(),l()};return b(L,{children:[r(o.Modal,{overflow:"inside",opened:i,onClose:()=>s(!1),title:"Add a data source",trapFocus:!0,onDragStart:f=>{f.stopPropagation()},children:r(Vt,{postSubmit:c,styles:n})}),r(o.Button,{size:n.button.size,onClick:u,leftIcon:r(F.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function pe(){return pe=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},pe.apply(this,arguments)}function Wt(t,n){if(t==null)return{};var i,s,u=function(c,f){if(c==null)return{};var g,w,S={},h=Object.keys(c);for(w=0;w<h.length;w++)g=h[w],f.indexOf(g)>=0||(S[g]=c[g]);return S}(t,n);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(s=0;s<l.length;s++)i=l[s],n.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(u[i]=t[i])}return u}var Gt=["size","color","stroke"];function Yt(t){var n=t.size,i=n===void 0?24:n,s=t.color,u=s===void 0?"currentColor":s,l=t.stroke,c=l===void 0?2:l,f=Wt(t,Gt);return Z.createElement("svg",pe({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-lock",width:i,height:i,viewBox:"0 0 24 24",strokeWidth:c,stroke:u,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},f),Z.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Z.createElement("rect",{x:5,y:11,width:14,height:10,rx:2}),Z.createElement("circle",{cx:12,cy:16,r:1}),Z.createElement("path",{d:"M8 11v-4a4 4 0 0 1 8 0v4"}))}function Oe({id:t,name:n,isProtected:i,onSuccess:s,styles:u=K}){const l=Q.useModals(),c=async()=>{!t||(T.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await j.datasource.delete(t),T.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${n}] is deleted`,color:"green"}),s())},f=()=>l.openConfirmModal({title:"Delete this data source?",children:r(o.Text,{size:u.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:c}),g=o.useMantineTheme();return i?r(o.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:r("span",{children:r(Yt,{size:16,color:g.colors.gray[7]})})}):r(o.Button,{size:u.button.size,color:"red",onClick:f,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function Kt({styles:t=K,config:n}){ie(n);const{data:i=[],loading:s,refresh:u}=V.useRequest(async()=>{const{data:l}=await j.datasource.list();return l},{refreshDeps:[]});return b(L,{children:[r(o.Group,{pt:t.spacing,position:"right",children:r(xe,{onSuccess:u})}),b(o.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(o.LoadingOverlay,{visible:s}),b(o.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:b("tr",{children:[r("th",{children:"Type"}),r("th",{children:"Name"}),r("th",{children:"Action"})]})}),r("tbody",{children:i.map(({id:l,key:c,type:f,is_preset:g})=>b("tr",{children:[r("td",{width:200,children:f}),r("td",{children:c}),r("td",{width:200,children:r(o.Group,{position:"left",children:r(Oe,{isProtected:g,id:l,name:c,onSuccess:u})})})]},c))})]})]})]})}const Jt=I.forwardRef(({label:t,value:n,description:i,...s},u)=>b(o.Stack,{spacing:2,ref:u,...s,children:[r(o.Text,{size:"sm",children:t}),r(o.Text,{size:"xs",color:"dimmed",className:"role-description",children:i})]})),ge=I.forwardRef(({styles:t,value:n,onChange:i},s)=>{const{data:u=[],loading:l}=V.useRequest(async()=>(await j.role.list()).map(f=>({label:f.name,value:f.id,description:f.description,disabled:f.id===50})),{refreshDeps:[]});return r(o.Select,{ref:s,mb:t.spacing,size:t.size,required:!0,label:"Role",itemComponent:Jt,data:u,disabled:l,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:n,onChange:i})}),$={size:"sm",spacing:"md",button:{size:"xs"}};function Xt({postSubmit:t,styles:n=$,initialRoleID:i}){const{control:s,handleSubmit:u}=P.useForm({defaultValues:{name:"",email:"",role_id:i,password:""}}),l=async({name:c,email:f,password:g,role_id:w})=>{try{T.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await j.account.create(c,f,g,w),T.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),t()}catch(S){T.updateNotification({id:"for-creating",title:"Failed",message:S.message,color:"red"})}};return r(o.Box,{mx:"auto",children:b("form",{onSubmit:u(l),children:[r(P.Controller,{name:"name",control:s,render:({field:c})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...c})}),r(P.Controller,{name:"email",control:s,render:({field:c})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Email",...c})}),r(P.Controller,{name:"password",control:s,render:({field:c})=>r(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...c})}),r(P.Controller,{name:"role_id",control:s,render:({field:c})=>r(ge,{styles:n,...c})}),r(o.Group,{position:"right",mt:n.spacing,children:r(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function ze({onSuccess:t,styles:n=$,initialRoleID:i}){const[s,u]=Y.default.useState(!1),l=()=>u(!0),c=()=>u(!1),f=()=>{t(),c()};return b(L,{children:[r(o.Modal,{overflow:"inside",opened:s,onClose:()=>u(!1),title:"Add an Account",trapFocus:!0,onDragStart:g=>{g.stopPropagation()},children:r(Xt,{postSubmit:f,styles:n,initialRoleID:i})}),r(o.Button,{size:n.button.size,onClick:l,leftIcon:r(F.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function ke({id:t,name:n,onSuccess:i,styles:s=$}){const u=Q.useModals(),l=async()=>{if(!!t){T.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await j.account.delete(t),T.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${n}] is deleted`,color:"green"}),i()}catch(f){T.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},c=()=>u.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:l});return r(o.Button,{size:s.button.size,color:"red",onClick:c,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function Qt({id:t,name:n,email:i,role_id:s,postSubmit:u,styles:l=$}){const{control:c,handleSubmit:f,watch:g}=P.useForm({defaultValues:{name:n,email:i,role_id:s,reset_password:!1,new_password:""}}),w=async({name:p,email:z,role_id:N,reset_password:W,new_password:me})=>{try{T.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await j.account.edit({id:t,name:p,email:z,role_id:N,reset_password:W,new_password:me}),T.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),u()}catch(U){T.updateNotification({id:"for-updating",title:"Failed",message:U.message,color:"red"})}},[S,h]=g(["reset_password","new_password"]);return r(o.Box,{mx:"auto",children:b("form",{onSubmit:f(w),children:[r(P.Controller,{name:"name",control:c,render:({field:p})=>r(o.TextInput,{mb:l.spacing,size:l.size,required:!0,label:"Username",...p})}),r(P.Controller,{name:"email",control:c,render:({field:p})=>r(o.TextInput,{mb:l.spacing,size:l.size,required:!0,label:"Email",...p})}),r(P.Controller,{name:"role_id",control:c,render:({field:p})=>r(ge,{styles:l,...p})}),r(o.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),r(P.Controller,{name:"reset_password",control:c,render:({field:p})=>r(o.Switch,{mb:l.spacing,size:l.size,label:"Reset password",checked:p.value,onChange:z=>p.onChange(z.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),S&&r(P.Controller,{name:"new_password",control:c,render:({field:p})=>r(o.PasswordInput,{autoComplete:"off",mb:l.spacing,size:l.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...p})}),r(o.Group,{position:"right",mt:l.spacing,children:r(o.Button,{type:"submit",size:l.button.size,children:"Submit"})})]})})}function Zt({account:t,onSuccess:n,styles:i=$}){const[s,u]=Y.default.useState(!1),l=()=>u(!0),c=()=>u(!1),f=()=>{n(),c()};return b(L,{children:[r(o.Modal,{overflow:"inside",opened:s,onClose:()=>u(!1),title:`Editing ${t.name}`,trapFocus:!0,onDragStart:g=>{g.stopPropagation()},children:r(Qt,{...t,postSubmit:f,styles:i})}),r(o.Button,{size:i.button.size,onClick:l,leftIcon:r(F.Edit,{size:20}),children:"Edit"})]})}function Ht({styles:t=$,config:n}){var w,S;ie(n);const{data:i=[],loading:s,refresh:u}=V.useRequest(async()=>{const{data:h}=await j.account.list();return h},{refreshDeps:[]}),{data:l=[],loading:c}=V.useRequest(async()=>(await j.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=I.useMemo(()=>l.reduce((h,p)=>(h.set(p.value,p.label),h),new Map),[l]),g=h=>{var p;return(p=f.get(h))!=null?p:h};return b(L,{children:[r(o.Group,{pt:t.spacing,position:"right",children:r(ze,{onSuccess:u,initialRoleID:(S=(w=l==null?void 0:l[0])==null?void 0:w.value)!=null?S:0})}),b(o.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(o.LoadingOverlay,{visible:s||c}),b(o.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:b("tr",{children:[r("th",{children:"Username"}),r("th",{children:"Email"}),r("th",{children:"Role"}),r("th",{children:"Action"})]})}),r("tbody",{children:i.map(h=>{const{id:p,name:z,email:N,role_id:W}=h;return b("tr",{children:[r("td",{width:200,children:z}),r("td",{width:200,children:N}),r("td",{width:200,children:g(W)}),r("td",{width:200,children:b(o.Group,{position:"left",children:[r(Zt,{account:h,onSuccess:u}),r(ke,{id:p,name:z,onSuccess:u})]})})]},p)})})]})]})]})}function er({postSubmit:t,styles:n=$}){const{control:i,handleSubmit:s}=P.useForm({defaultValues:{name:"",password:""}}),u=async({name:l,password:c})=>{try{T.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const f=await j.account.login(l,c);window.localStorage.setItem("token",f.token),T.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),t(f)}catch(f){T.updateNotification({id:"for-login",title:"Login Failed",message:f.message,color:"red"})}};return r(o.Box,{mx:"auto",children:b("form",{onSubmit:s(u),children:[r(P.Controller,{name:"name",control:i,render:({field:l})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...l})}),r(P.Controller,{name:"password",control:i,render:({field:l})=>r(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...l})}),r(o.Group,{position:"right",mt:n.spacing,children:r(o.Button,{type:"submit",size:n.button.size,children:"Submit"})})]})})}function tr({styles:t=$,config:n,onSuccess:i}){return ie(n),r(L,{children:r(o.Box,{mt:t.spacing,sx:{position:"relative"},children:r(er,{styles:t,postSubmit:i})})})}const se={size:"sm",spacing:"md",button:{size:"xs"}};function rr({postSubmit:t,styles:n=se,initialRoleID:i}){const{control:s,handleSubmit:u}=P.useForm({defaultValues:{name:"",role_id:i}}),l=async({name:c,role_id:f})=>{try{T.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:g,app_secret:w}=await j.api_key.create(c,f);T.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),t(g,w)}catch(g){T.updateNotification({id:"for-creating",title:"Failed",message:g.message,color:"red"})}};return r(o.Box,{mx:"auto",children:b("form",{onSubmit:u(l),children:[r(P.Controller,{name:"name",control:s,render:({field:c})=>r(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",...c})}),r(P.Controller,{name:"role_id",control:s,render:({field:c})=>r(ge,{styles:n,...c})}),r(o.Group,{position:"right",mt:n.spacing,children:r(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Ae({onSuccess:t,styles:n=se,initialRoleID:i}){const s=Q.useModals(),[u,l]=Y.default.useState(!1),c=()=>l(!0),f=()=>l(!1),g=(w,S)=>{f(),s.openModal({title:"API Key is generated",children:b(o.Stack,{children:[r(o.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),r(o.TextInput,{defaultValue:w,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),r(o.TextInput,{defaultValue:S,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),r(o.Button,{size:"sm",onClick:()=>{Q.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{t()}})};return b(L,{children:[r(o.Modal,{overflow:"inside",opened:u,onClose:()=>l(!1),title:"Add an API Key",trapFocus:!0,onDragStart:w=>{w.stopPropagation()},children:r(rr,{postSubmit:g,styles:n,initialRoleID:i})}),r(o.Button,{size:n.button.size,onClick:c,leftIcon:r(F.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function je({id:t,name:n,onSuccess:i,styles:s=se}){const u=Q.useModals(),l=async()=>{if(!!t){T.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await j.api_key.delete(t),T.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${n}] is deleted`,color:"green"}),i()}catch(f){T.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},c=()=>u.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:l});return r(o.Button,{size:s.button.size,color:"red",onClick:c,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function nr({styles:t=se,config:n}){var w,S;ie(n);const{data:i=[],loading:s,refresh:u}=V.useRequest(async()=>{const{data:h}=await j.api_key.list();return h},{refreshDeps:[]}),{data:l=[],loading:c}=V.useRequest(async()=>(await j.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=I.useMemo(()=>l.reduce((h,p)=>(h.set(p.value,p.label),h),new Map),[l]),g=h=>{var p;return(p=f.get(h))!=null?p:h};return b(L,{children:[r(o.Group,{pt:t.spacing,position:"right",children:r(Ae,{onSuccess:u,initialRoleID:(S=(w=l==null?void 0:l[0])==null?void 0:w.value)!=null?S:0})}),b(o.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(o.LoadingOverlay,{visible:s||c}),b(o.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:b("tr",{children:[r("th",{children:"Name"}),r("th",{children:"APP ID"}),r("th",{children:"Role"}),r("th",{children:"Action"})]})}),r("tbody",{children:i.map(h=>{const{id:p,name:z,app_id:N,role_id:W}=h;return b("tr",{children:[r("td",{width:200,children:z}),r("td",{width:200,children:N}),r("td",{width:200,children:g(W)}),r("td",{width:200,children:r(o.Group,{position:"left",children:r(je,{id:p,name:z,onSuccess:u})})})]},p)})})]})]})]})}const ir=()=>Promise.resolve().then(()=>ar).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t)),De="@devtable/settings-form",Ie="8.13.3",qe="Apache-2.0",Ne={access:"public",registry:"https://registry.npmjs.org/"},Le=["dist"],Me="./dist/settings-form.umd.js",Be="./dist/settings-form.es.js",Fe="./dist/index.d.ts",$e={".":{import:"./dist/settings-form.es.js",require:"./dist/settings-form.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Ue={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview"},Ve={"@monaco-editor/react":"4.4.6","monaco-editor":"0.36.0"},We={"@types/crypto-js":"v4.1.1","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2","rollup-plugin-visualizer":"5.6.0",typescript:"^4.6.3"},Ge={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5",ahooks:"^3.3.11",axios:"^0.27.2","crypto-js":"^4.1.1",lodash:"^4.17.21",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-hook-form":"^7.31.2","tabler-icons-react":"^1.48.0"},ar=Object.freeze(Object.defineProperty({__proto__:null,name:De,version:Ie,license:qe,publishConfig:Ne,files:Le,main:Me,module:Be,types:Fe,exports:$e,scripts:Ue,dependencies:Ve,devDependencies:We,peerDependencies:Ge,default:{name:De,version:Ie,license:qe,publishConfig:Ne,files:Le,main:Me,module:Be,types:Fe,exports:$e,scripts:Ue,dependencies:Ve,devDependencies:We,peerDependencies:Ge}},Symbol.toStringTag,{value:"Module"}));y.APIKeyList=nr,y.AccountList=Ht,y.AddAPIKey=Ae,y.AddAccount=ze,y.AddDataSource=xe,y.DataSourceList=Kt,y.DeleteAPIKey=je,y.DeleteAccount=ke,y.DeleteDataSource=Oe,y.Login=tr,y.getVersion=ir,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/settings-form",
3
- "version": "8.13.1",
3
+ "version": "8.13.3",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",