@devtable/settings-form 14.12.0 → 14.14.0

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.
@@ -14,23 +14,23 @@
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 He;function Xt(){return He||(He=1,process.env.NODE_ENV!=="production"&&function(){var r=P,t=Symbol.for("react.element"),s=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),C=Symbol.for("react.offscreen"),q=Symbol.iterator,Y="@@iterator";function X(a){if(a===null||typeof a!="object")return null;var f=q&&a[q]||a[Y];return typeof f=="function"?f:null}var k=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function D(a){{for(var f=arguments.length,m=new Array(f>1?f-1:0),g=1;g<f;g++)m[g-1]=arguments[g];L("error",a,m)}}function L(a,f,m){{var g=k.ReactDebugCurrentFrame,w=g.getStackAddendum();w!==""&&(f+="%s",m=m.concat([w]));var E=m.map(function(S){return String(S)});E.unshift("Warning: "+f),Function.prototype.apply.call(console[a],console,E)}}var Z=!1,ce=!1,ke=!1,Zn=!1,ea=!1,jt;jt=Symbol.for("react.module.reference");function ta(a){return!!(typeof a=="string"||typeof a=="function"||a===n||a===l||ea||a===i||a===p||a===h||Zn||a===C||Z||ce||ke||typeof a=="object"&&a!==null&&(a.$$typeof===v||a.$$typeof===b||a.$$typeof===c||a.$$typeof===u||a.$$typeof===d||a.$$typeof===jt||a.getModuleId!==void 0))}function na(a,f,m){var g=a.displayName;if(g)return g;var w=f.displayName||f.name||"";return w!==""?m+"("+w+")":m}function _t(a){return a.displayName||"Context"}function G(a){if(a==null)return null;if(typeof a.tag=="number"&&D("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case n:return"Fragment";case s:return"Portal";case l:return"Profiler";case i:return"StrictMode";case p:return"Suspense";case h:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case u:var f=a;return _t(f)+".Consumer";case c:var m=a;return _t(m._context)+".Provider";case d:return na(a,a.render,"ForwardRef");case b:var g=a.displayName||null;return g!==null?g:G(a.type)||"Memo";case v:{var w=a,E=w._payload,S=w._init;try{return G(S(E))}catch{return null}}}return null}var te=Object.assign,ve=0,Tt,St,yt,wt,Ct,Dt,zt;function Et(){}Et.__reactDisabledLog=!0;function aa(){{if(ve===0){Tt=console.log,St=console.info,yt=console.warn,wt=console.error,Ct=console.group,Dt=console.groupCollapsed,zt=console.groupEnd;var a={configurable:!0,enumerable:!0,value:Et,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}ve++}}function ra(){{if(ve--,ve===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:te({},a,{value:Tt}),info:te({},a,{value:St}),warn:te({},a,{value:yt}),error:te({},a,{value:wt}),group:te({},a,{value:Ct}),groupCollapsed:te({},a,{value:Dt}),groupEnd:te({},a,{value:zt})})}ve<0&&D("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ne=k.ReactCurrentDispatcher,Fe;function ze(a,f,m){{if(Fe===void 0)try{throw Error()}catch(w){var g=w.stack.trim().match(/\n( *(at )?)/);Fe=g&&g[1]||""}return`
17
+ */var He;function Xt(){return He||(He=1,process.env.NODE_ENV!=="production"&&function(){var r=P,t=Symbol.for("react.element"),s=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),C=Symbol.for("react.offscreen"),L=Symbol.iterator,Y="@@iterator";function X(a){if(a===null||typeof a!="object")return null;var f=L&&a[L]||a[Y];return typeof f=="function"?f:null}var k=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function D(a){{for(var f=arguments.length,m=new Array(f>1?f-1:0),g=1;g<f;g++)m[g-1]=arguments[g];q("error",a,m)}}function q(a,f,m){{var g=k.ReactDebugCurrentFrame,w=g.getStackAddendum();w!==""&&(f+="%s",m=m.concat([w]));var E=m.map(function(S){return String(S)});E.unshift("Warning: "+f),Function.prototype.apply.call(console[a],console,E)}}var Z=!1,ce=!1,ke=!1,Zn=!1,ea=!1,jt;jt=Symbol.for("react.module.reference");function ta(a){return!!(typeof a=="string"||typeof a=="function"||a===n||a===l||ea||a===i||a===p||a===h||Zn||a===C||Z||ce||ke||typeof a=="object"&&a!==null&&(a.$$typeof===v||a.$$typeof===b||a.$$typeof===c||a.$$typeof===u||a.$$typeof===d||a.$$typeof===jt||a.getModuleId!==void 0))}function na(a,f,m){var g=a.displayName;if(g)return g;var w=f.displayName||f.name||"";return w!==""?m+"("+w+")":m}function _t(a){return a.displayName||"Context"}function G(a){if(a==null)return null;if(typeof a.tag=="number"&&D("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case n:return"Fragment";case s:return"Portal";case l:return"Profiler";case i:return"StrictMode";case p:return"Suspense";case h:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case u:var f=a;return _t(f)+".Consumer";case c:var m=a;return _t(m._context)+".Provider";case d:return na(a,a.render,"ForwardRef");case b:var g=a.displayName||null;return g!==null?g:G(a.type)||"Memo";case v:{var w=a,E=w._payload,S=w._init;try{return G(S(E))}catch{return null}}}return null}var te=Object.assign,ve=0,Tt,St,yt,wt,Ct,Dt,zt;function Et(){}Et.__reactDisabledLog=!0;function aa(){{if(ve===0){Tt=console.log,St=console.info,yt=console.warn,wt=console.error,Ct=console.group,Dt=console.groupCollapsed,zt=console.groupEnd;var a={configurable:!0,enumerable:!0,value:Et,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}ve++}}function ra(){{if(ve--,ve===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:te({},a,{value:Tt}),info:te({},a,{value:St}),warn:te({},a,{value:yt}),error:te({},a,{value:wt}),group:te({},a,{value:Ct}),groupCollapsed:te({},a,{value:Dt}),groupEnd:te({},a,{value:zt})})}ve<0&&D("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ne=k.ReactCurrentDispatcher,Fe;function ze(a,f,m){{if(Fe===void 0)try{throw Error()}catch(w){var g=w.stack.trim().match(/\n( *(at )?)/);Fe=g&&g[1]||""}return`
18
18
  `+Fe+a}}var Be=!1,Ee;{var sa=typeof WeakMap=="function"?WeakMap:Map;Ee=new sa}function At(a,f){if(!a||Be)return"";{var m=Ee.get(a);if(m!==void 0)return m}var g;Be=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var E;E=Ne.current,Ne.current=null,aa();try{if(f){var S=function(){throw Error()};if(Object.defineProperty(S.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(S,[])}catch(F){g=F}Reflect.construct(a,[],S)}else{try{S.call()}catch(F){g=F}a.call(S.prototype)}}else{try{throw Error()}catch(F){g=F}a()}}catch(F){if(F&&g&&typeof F.stack=="string"){for(var _=F.stack.split(`
19
19
  `),N=g.stack.split(`
20
20
  `),$=_.length-1,M=N.length-1;$>=1&&M>=0&&_[$]!==N[M];)M--;for(;$>=1&&M>=0;$--,M--)if(_[$]!==N[M]){if($!==1||M!==1)do if($--,M--,M<0||_[$]!==N[M]){var B=`
21
- `+_[$].replace(" at new "," at ");return a.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",a.displayName)),typeof a=="function"&&Ee.set(a,B),B}while($>=1&&M>=0);break}}}finally{Be=!1,Ne.current=E,ra(),Error.prepareStackTrace=w}var fe=a?a.displayName||a.name:"",ne=fe?ze(fe):"";return typeof a=="function"&&Ee.set(a,ne),ne}function ia(a,f,m){return At(a,!1)}function oa(a){var f=a.prototype;return!!(f&&f.isReactComponent)}function Ae(a,f,m){if(a==null)return"";if(typeof a=="function")return At(a,oa(a));if(typeof a=="string")return ze(a);switch(a){case p:return ze("Suspense");case h:return ze("SuspenseList")}if(typeof a=="object")switch(a.$$typeof){case d:return ia(a.render);case b:return Ae(a.type,f,m);case v:{var g=a,w=g._payload,E=g._init;try{return Ae(E(w),f,m)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,Pt={},Ot=k.ReactDebugCurrentFrame;function Pe(a){if(a){var f=a._owner,m=Ae(a.type,a._source,f?f.type:null);Ot.setExtraStackFrame(m)}else Ot.setExtraStackFrame(null)}function la(a,f,m,g,w){{var E=Function.call.bind(je);for(var S in a)if(E(a,S)){var _=void 0;try{if(typeof a[S]!="function"){var N=Error((g||"React class")+": "+m+" type `"+S+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[S]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw N.name="Invariant Violation",N}_=a[S](f,S,g,m,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch($){_=$}_&&!(_ instanceof Error)&&(Pe(w),D("%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).",g||"React class",m,S,typeof _),Pe(null)),_ instanceof Error&&!(_.message in Pt)&&(Pt[_.message]=!0,Pe(w),D("Failed %s type: %s",m,_.message),Pe(null))}}}var ua=Array.isArray;function Ue(a){return ua(a)}function ca(a){{var f=typeof Symbol=="function"&&Symbol.toStringTag,m=f&&a[Symbol.toStringTag]||a.constructor.name||"Object";return m}}function da(a){try{return $t(a),!1}catch{return!0}}function $t(a){return""+a}function Mt(a){if(da(a))return D("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ca(a)),$t(a)}var _e=k.ReactCurrentOwner,fa={key:!0,ref:!0,__self:!0,__source:!0},It,Rt,Ye;Ye={};function pa(a){if(je.call(a,"ref")){var f=Object.getOwnPropertyDescriptor(a,"ref").get;if(f&&f.isReactWarning)return!1}return a.ref!==void 0}function ma(a){if(je.call(a,"key")){var f=Object.getOwnPropertyDescriptor(a,"key").get;if(f&&f.isReactWarning)return!1}return a.key!==void 0}function ha(a,f){if(typeof a.ref=="string"&&_e.current&&f&&_e.current.stateNode!==f){var m=G(_e.current.type);Ye[m]||(D('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',G(_e.current.type),a.ref),Ye[m]=!0)}}function ga(a,f){{var m=function(){It||(It=!0,D("%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)",f))};m.isReactWarning=!0,Object.defineProperty(a,"key",{get:m,configurable:!0})}}function xa(a,f){{var m=function(){Rt||(Rt=!0,D("%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)",f))};m.isReactWarning=!0,Object.defineProperty(a,"ref",{get:m,configurable:!0})}}var ba=function(a,f,m,g,w,E,S){var _={$$typeof:t,type:a,key:f,ref:m,props:S,_owner:E};return _._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(_,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(_,"_source",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_};function va(a,f,m,g,w){{var E,S={},_=null,N=null;m!==void 0&&(Mt(m),_=""+m),ma(f)&&(Mt(f.key),_=""+f.key),pa(f)&&(N=f.ref,ha(f,w));for(E in f)je.call(f,E)&&!fa.hasOwnProperty(E)&&(S[E]=f[E]);if(a&&a.defaultProps){var $=a.defaultProps;for(E in $)S[E]===void 0&&(S[E]=$[E])}if(_||N){var M=typeof a=="function"?a.displayName||a.name||"Unknown":a;_&&ga(S,M),N&&xa(S,M)}return ba(a,_,N,w,g,_e.current,S)}}var Ve=k.ReactCurrentOwner,Lt=k.ReactDebugCurrentFrame;function de(a){if(a){var f=a._owner,m=Ae(a.type,a._source,f?f.type:null);Lt.setExtraStackFrame(m)}else Lt.setExtraStackFrame(null)}var Ge;Ge=!1;function We(a){return typeof a=="object"&&a!==null&&a.$$typeof===t}function qt(){{if(Ve.current){var a=G(Ve.current.type);if(a)return`
21
+ `+_[$].replace(" at new "," at ");return a.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",a.displayName)),typeof a=="function"&&Ee.set(a,B),B}while($>=1&&M>=0);break}}}finally{Be=!1,Ne.current=E,ra(),Error.prepareStackTrace=w}var fe=a?a.displayName||a.name:"",ne=fe?ze(fe):"";return typeof a=="function"&&Ee.set(a,ne),ne}function ia(a,f,m){return At(a,!1)}function oa(a){var f=a.prototype;return!!(f&&f.isReactComponent)}function Ae(a,f,m){if(a==null)return"";if(typeof a=="function")return At(a,oa(a));if(typeof a=="string")return ze(a);switch(a){case p:return ze("Suspense");case h:return ze("SuspenseList")}if(typeof a=="object")switch(a.$$typeof){case d:return ia(a.render);case b:return Ae(a.type,f,m);case v:{var g=a,w=g._payload,E=g._init;try{return Ae(E(w),f,m)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,Pt={},Ot=k.ReactDebugCurrentFrame;function Pe(a){if(a){var f=a._owner,m=Ae(a.type,a._source,f?f.type:null);Ot.setExtraStackFrame(m)}else Ot.setExtraStackFrame(null)}function la(a,f,m,g,w){{var E=Function.call.bind(je);for(var S in a)if(E(a,S)){var _=void 0;try{if(typeof a[S]!="function"){var N=Error((g||"React class")+": "+m+" type `"+S+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[S]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw N.name="Invariant Violation",N}_=a[S](f,S,g,m,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch($){_=$}_&&!(_ instanceof Error)&&(Pe(w),D("%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).",g||"React class",m,S,typeof _),Pe(null)),_ instanceof Error&&!(_.message in Pt)&&(Pt[_.message]=!0,Pe(w),D("Failed %s type: %s",m,_.message),Pe(null))}}}var ua=Array.isArray;function Ue(a){return ua(a)}function ca(a){{var f=typeof Symbol=="function"&&Symbol.toStringTag,m=f&&a[Symbol.toStringTag]||a.constructor.name||"Object";return m}}function da(a){try{return $t(a),!1}catch{return!0}}function $t(a){return""+a}function Mt(a){if(da(a))return D("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ca(a)),$t(a)}var _e=k.ReactCurrentOwner,fa={key:!0,ref:!0,__self:!0,__source:!0},It,Rt,Ye;Ye={};function pa(a){if(je.call(a,"ref")){var f=Object.getOwnPropertyDescriptor(a,"ref").get;if(f&&f.isReactWarning)return!1}return a.ref!==void 0}function ma(a){if(je.call(a,"key")){var f=Object.getOwnPropertyDescriptor(a,"key").get;if(f&&f.isReactWarning)return!1}return a.key!==void 0}function ha(a,f){if(typeof a.ref=="string"&&_e.current&&f&&_e.current.stateNode!==f){var m=G(_e.current.type);Ye[m]||(D('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',G(_e.current.type),a.ref),Ye[m]=!0)}}function ga(a,f){{var m=function(){It||(It=!0,D("%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)",f))};m.isReactWarning=!0,Object.defineProperty(a,"key",{get:m,configurable:!0})}}function xa(a,f){{var m=function(){Rt||(Rt=!0,D("%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)",f))};m.isReactWarning=!0,Object.defineProperty(a,"ref",{get:m,configurable:!0})}}var ba=function(a,f,m,g,w,E,S){var _={$$typeof:t,type:a,key:f,ref:m,props:S,_owner:E};return _._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(_,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(_,"_source",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_};function va(a,f,m,g,w){{var E,S={},_=null,N=null;m!==void 0&&(Mt(m),_=""+m),ma(f)&&(Mt(f.key),_=""+f.key),pa(f)&&(N=f.ref,ha(f,w));for(E in f)je.call(f,E)&&!fa.hasOwnProperty(E)&&(S[E]=f[E]);if(a&&a.defaultProps){var $=a.defaultProps;for(E in $)S[E]===void 0&&(S[E]=$[E])}if(_||N){var M=typeof a=="function"?a.displayName||a.name||"Unknown":a;_&&ga(S,M),N&&xa(S,M)}return ba(a,_,N,w,g,_e.current,S)}}var Ve=k.ReactCurrentOwner,qt=k.ReactDebugCurrentFrame;function de(a){if(a){var f=a._owner,m=Ae(a.type,a._source,f?f.type:null);qt.setExtraStackFrame(m)}else qt.setExtraStackFrame(null)}var Ge;Ge=!1;function We(a){return typeof a=="object"&&a!==null&&a.$$typeof===t}function Lt(){{if(Ve.current){var a=G(Ve.current.type);if(a)return`
22
22
 
23
23
  Check the render method of \``+a+"`."}return""}}function ja(a){{if(a!==void 0){var f=a.fileName.replace(/^.*[\\\/]/,""),m=a.lineNumber;return`
24
24
 
25
- Check your code at `+f+":"+m+"."}return""}}var kt={};function _a(a){{var f=qt();if(!f){var m=typeof a=="string"?a:a.displayName||a.name;m&&(f=`
25
+ Check your code at `+f+":"+m+"."}return""}}var kt={};function _a(a){{var f=Lt();if(!f){var m=typeof a=="string"?a:a.displayName||a.name;m&&(f=`
26
26
 
27
- Check the top-level render call using <`+m+">.")}return f}}function Nt(a,f){{if(!a._store||a._store.validated||a.key!=null)return;a._store.validated=!0;var m=_a(f);if(kt[m])return;kt[m]=!0;var g="";a&&a._owner&&a._owner!==Ve.current&&(g=" It was passed a child from "+G(a._owner.type)+"."),de(a),D('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',m,g),de(null)}}function Ft(a,f){{if(typeof a!="object")return;if(Ue(a))for(var m=0;m<a.length;m++){var g=a[m];We(g)&&Nt(g,f)}else if(We(a))a._store&&(a._store.validated=!0);else if(a){var w=X(a);if(typeof w=="function"&&w!==a.entries)for(var E=w.call(a),S;!(S=E.next()).done;)We(S.value)&&Nt(S.value,f)}}}function Ta(a){{var f=a.type;if(f==null||typeof f=="string")return;var m;if(typeof f=="function")m=f.propTypes;else if(typeof f=="object"&&(f.$$typeof===d||f.$$typeof===b))m=f.propTypes;else return;if(m){var g=G(f);la(m,a.props,"prop",g,a)}else if(f.PropTypes!==void 0&&!Ge){Ge=!0;var w=G(f);D("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof f.getDefaultProps=="function"&&!f.getDefaultProps.isReactClassApproved&&D("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Sa(a){{for(var f=Object.keys(a.props),m=0;m<f.length;m++){var g=f[m];if(g!=="children"&&g!=="key"){de(a),D("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),de(null);break}}a.ref!==null&&(de(a),D("Invalid attribute `ref` supplied to `React.Fragment`."),de(null))}}var Bt={};function Ut(a,f,m,g,w,E){{var S=ta(a);if(!S){var _="";(a===void 0||typeof a=="object"&&a!==null&&Object.keys(a).length===0)&&(_+=" 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 N=ja(w);N?_+=N:_+=qt();var $;a===null?$="null":Ue(a)?$="array":a!==void 0&&a.$$typeof===t?($="<"+(G(a.type)||"Unknown")+" />",_=" Did you accidentally export a JSX literal instead of a component?"):$=typeof a,D("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",$,_)}var M=va(a,f,m,w,E);if(M==null)return M;if(S){var B=f.children;if(B!==void 0)if(g)if(Ue(B)){for(var fe=0;fe<B.length;fe++)Ft(B[fe],a);Object.freeze&&Object.freeze(B)}else D("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 Ft(B,a)}if(je.call(f,"key")){var ne=G(a),F=Object.keys(f).filter(function(Ea){return Ea!=="key"}),Ke=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!Bt[ne+Ke]){var za=F.length>0?"{"+F.join(": ..., ")+": ...}":"{}";D(`A props object containing a "key" prop is being spread into JSX:
27
+ Check the top-level render call using <`+m+">.")}return f}}function Nt(a,f){{if(!a._store||a._store.validated||a.key!=null)return;a._store.validated=!0;var m=_a(f);if(kt[m])return;kt[m]=!0;var g="";a&&a._owner&&a._owner!==Ve.current&&(g=" It was passed a child from "+G(a._owner.type)+"."),de(a),D('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',m,g),de(null)}}function Ft(a,f){{if(typeof a!="object")return;if(Ue(a))for(var m=0;m<a.length;m++){var g=a[m];We(g)&&Nt(g,f)}else if(We(a))a._store&&(a._store.validated=!0);else if(a){var w=X(a);if(typeof w=="function"&&w!==a.entries)for(var E=w.call(a),S;!(S=E.next()).done;)We(S.value)&&Nt(S.value,f)}}}function Ta(a){{var f=a.type;if(f==null||typeof f=="string")return;var m;if(typeof f=="function")m=f.propTypes;else if(typeof f=="object"&&(f.$$typeof===d||f.$$typeof===b))m=f.propTypes;else return;if(m){var g=G(f);la(m,a.props,"prop",g,a)}else if(f.PropTypes!==void 0&&!Ge){Ge=!0;var w=G(f);D("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof f.getDefaultProps=="function"&&!f.getDefaultProps.isReactClassApproved&&D("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Sa(a){{for(var f=Object.keys(a.props),m=0;m<f.length;m++){var g=f[m];if(g!=="children"&&g!=="key"){de(a),D("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),de(null);break}}a.ref!==null&&(de(a),D("Invalid attribute `ref` supplied to `React.Fragment`."),de(null))}}var Bt={};function Ut(a,f,m,g,w,E){{var S=ta(a);if(!S){var _="";(a===void 0||typeof a=="object"&&a!==null&&Object.keys(a).length===0)&&(_+=" 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 N=ja(w);N?_+=N:_+=Lt();var $;a===null?$="null":Ue(a)?$="array":a!==void 0&&a.$$typeof===t?($="<"+(G(a.type)||"Unknown")+" />",_=" Did you accidentally export a JSX literal instead of a component?"):$=typeof a,D("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",$,_)}var M=va(a,f,m,w,E);if(M==null)return M;if(S){var B=f.children;if(B!==void 0)if(g)if(Ue(B)){for(var fe=0;fe<B.length;fe++)Ft(B[fe],a);Object.freeze&&Object.freeze(B)}else D("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 Ft(B,a)}if(je.call(f,"key")){var ne=G(a),F=Object.keys(f).filter(function(Ea){return Ea!=="key"}),Ke=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!Bt[ne+Ke]){var za=F.length>0?"{"+F.join(": ..., ")+": ...}":"{}";D(`A props object containing a "key" prop is being spread into JSX:
28
28
  let props = %s;
29
29
  <%s {...props} />
30
30
  React keys must be passed directly to JSX without using spread:
31
31
  let props = %s;
32
- <%s key={someKey} {...props} />`,Ke,ne,za,ne),Bt[ne+Ke]=!0}}return a===n?Sa(M):Ta(M),M}}function ya(a,f,m){return Ut(a,f,m,!0)}function wa(a,f,m){return Ut(a,f,m,!1)}var Ca=wa,Da=ya;he.Fragment=n,he.jsx=Ca,he.jsxs=Da}()),he}process.env.NODE_ENV==="production"?Oe.exports=Ht():Oe.exports=Xt();var e=Oe.exports;function Zt(r){r=r||{};const t=Object.keys(r).sort(),s=[];for(let n=0;n<t.length;n++){const i=t[n];if(i!="authentication"&&r[i])s.push(t[n]+"="+(typeof r[i]=="object"?JSON.stringify(r[i]):r[i]));else{const l=Object.keys(r[i]).sort();for(let c=0;c<l.length;c++){const u=l[c];u!="sign"&&r[i][u]&&s.push(l[c]+"="+(typeof r[i][u]=="object"?JSON.stringify(r[i][u]):r[i][u]))}}}return s.sort().join("&")}function en(r,t){let s=Zt(r);return s+="&key="+t,Jt.MD5(s).toString().toUpperCase()}class Xe{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const s=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:s,sign:en({app_id:this.app_id,nonce_str:s,...t},this.app_secret)}}getRequest(t,s){return(n,i,l,c)=>{const u=this.buildHeader(l),d=this.buildAxiosConfig(t,n,i,l,u,s);return Qe(d).then(p=>c?p:p.data).catch(p=>{if(Qe.isCancel(p))return Promise.reject(p);const h=p,b=Vt.get(h,"response.data.detail.message",h.message);return Promise.reject(new Error(b))})}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,s,n,i,l,c){const u={baseURL:this.baseURL,method:t,url:s,params:t==="GET"?n:i.params,headers:l,signal:c};return["POST","PUT"].includes(t)&&(u.data=i.string?JSON.stringify(n):n,u.data.authentication=this.getAuthentication(u.data)),u}buildHeader(t){const s=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:s?`bearer ${s}`:"",...t.headers}}}class Ze{constructor(t){this.implementation=t}getRequest(t,s){return this.implementation.getRequest(t,s)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const ge=new Xe,et=new Ze(ge),O=et;function tt(r){ge.baseURL!==r.apiBaseURL&&(ge.baseURL=r.apiBaseURL),r.app_id&&(ge.app_id=r.app_id),r.app_secret&&(ge.app_secret=r.app_secret)}const tn={login:async(r,t)=>{const s={name:r,password:t};return await O.post()("/account/login",s,{})},list:async()=>await O.post()("/account/list",{filter:{},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),get:async()=>await O.get()("/account/get",{},{}),update:async(r,t)=>{const s={name:r.trim(),email:t.trim()};return await O.put()("/account/update",s,{})},changepassword:async(r,t)=>{const s={old_password:r.trim(),new_password:t.trim()};return await O.post()("/account/changepassword",s,{})},create:async(r,t,s,n)=>await O.post()("/account/create",{name:r.trim(),email:t.trim(),password:s.trim(),role_id:n},{}),edit:async r=>(r.reset_password||(r.new_password=void 0),await O.put()("/account/edit",r,{})),delete:async r=>{if(r)return O.post()("/account/delete",{id:r},{})}},nn={list:async()=>await O.post()("/api/key/list",{filter:{search:""},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),create:async(r,t)=>O.post()("/api/key/create",{name:r,role_id:t},{}),delete:async r=>{if(r)return O.post()("/api/key/delete",{id:r},{})}},an={list:async()=>await O.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),create:async(r,t,s)=>await O.post()("/datasource/create",{type:r,key:t,config:s},{}),update:async(r,t)=>await O.put()("/datasource/update",{id:r,config:t},{}),delete:async r=>{await O.post()("/datasource/delete",{id:r},{})}},rn={list:async()=>await O.get()("/role/list",{},{})};var nt=60,at=nt*60,rt=at*24,sn=rt*7,re=1e3,$e=nt*re,st=at*re,on=rt*re,ln=sn*re,Me="millisecond",se="second",ie="minute",oe="hour",Q="day",Te="week",U="month",it="quarter",J="year",le="date",un="YYYY-MM-DDTHH:mm:ssZ",ot="Invalid Date",cn=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,dn=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;const fn={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var s=["th","st","nd","rd"],n=t%100;return"["+t+(s[(n-20)%10]||s[n]||s[0])+"]"}};var Ie=function(t,s,n){var i=String(t);return!i||i.length>=s?t:""+Array(s+1-i.length).join(n)+t},pn=function(t){var s=-t.utcOffset(),n=Math.abs(s),i=Math.floor(n/60),l=n%60;return(s<=0?"+":"-")+Ie(i,2,"0")+":"+Ie(l,2,"0")},mn=function r(t,s){if(t.date()<s.date())return-r(s,t);var n=(s.year()-t.year())*12+(s.month()-t.month()),i=t.clone().add(n,U),l=s-i<0,c=t.clone().add(n+(l?-1:1),U);return+(-(n+(s-i)/(l?i-c:c-i))||0)},hn=function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},gn=function(t){var s={M:U,y:J,w:Te,d:Q,D:le,h:oe,m:ie,s:se,ms:Me,Q:it};return s[t]||String(t||"").toLowerCase().replace(/s$/,"")},xn=function(t){return t===void 0};const bn={s:Ie,z:pn,m:mn,a:hn,p:gn,u:xn};var xe="en",ee={};ee[xe]=fn;var Re=function(t){return t instanceof ye},Se=function r(t,s,n){var i;if(!t)return xe;if(typeof t=="string"){var l=t.toLowerCase();ee[l]&&(i=l),s&&(ee[l]=s,i=l);var c=t.split("-");if(!i&&c.length>1)return r(c[0])}else{var u=t.name;ee[u]=t,i=u}return!n&&i&&(xe=i),i||!n&&xe},I=function(t,s){if(Re(t))return t.clone();var n=typeof s=="object"?s:{};return n.date=t,n.args=arguments,new ye(n)},vn=function(t,s){return I(t,{locale:s.$L,utc:s.$u,x:s.$x,$offset:s.$offset})},z=bn;z.l=Se,z.i=Re,z.w=vn;var jn=function(t){var s=t.date,n=t.utc;if(s===null)return new Date(NaN);if(z.u(s))return new Date;if(s instanceof Date)return new Date(s);if(typeof s=="string"&&!/Z$/i.test(s)){var i=s.match(cn);if(i){var l=i[2]-1||0,c=(i[7]||"0").substring(0,3);return n?new Date(Date.UTC(i[1],l,i[3]||1,i[4]||0,i[5]||0,i[6]||0,c)):new Date(i[1],l,i[3]||1,i[4]||0,i[5]||0,i[6]||0,c)}}return new Date(s)},ye=function(){function r(s){this.$L=Se(s.locale,null,!0),this.parse(s)}var t=r.prototype;return t.parse=function(n){this.$d=jn(n),this.$x=n.x||{},this.init()},t.init=function(){var n=this.$d;this.$y=n.getFullYear(),this.$M=n.getMonth(),this.$D=n.getDate(),this.$W=n.getDay(),this.$H=n.getHours(),this.$m=n.getMinutes(),this.$s=n.getSeconds(),this.$ms=n.getMilliseconds()},t.$utils=function(){return z},t.isValid=function(){return this.$d.toString()!==ot},t.isSame=function(n,i){var l=I(n);return this.startOf(i)<=l&&l<=this.endOf(i)},t.isAfter=function(n,i){return I(n)<this.startOf(i)},t.isBefore=function(n,i){return this.endOf(i)<I(n)},t.$g=function(n,i,l){return z.u(n)?this[i]:this.set(l,n)},t.unix=function(){return Math.floor(this.valueOf()/1e3)},t.valueOf=function(){return this.$d.getTime()},t.startOf=function(n,i){var l=this,c=z.u(i)?!0:i,u=z.p(n),d=function(k,D){var L=z.w(l.$u?Date.UTC(l.$y,D,k):new Date(l.$y,D,k),l);return c?L:L.endOf(Q)},p=function(k,D){var L=[0,0,0,0],Z=[23,59,59,999];return z.w(l.toDate()[k].apply(l.toDate("s"),(c?L:Z).slice(D)),l)},h=this.$W,b=this.$M,v=this.$D,C="set"+(this.$u?"UTC":"");switch(u){case J:return c?d(1,0):d(31,11);case U:return c?d(1,b):d(0,b+1);case Te:{var q=this.$locale().weekStart||0,Y=(h<q?h+7:h)-q;return d(c?v-Y:v+(6-Y),b)}case Q:case le:return p(C+"Hours",0);case oe:return p(C+"Minutes",1);case ie:return p(C+"Seconds",2);case se:return p(C+"Milliseconds",3);default:return this.clone()}},t.endOf=function(n){return this.startOf(n,!1)},t.$set=function(n,i){var l,c=z.p(n),u="set"+(this.$u?"UTC":""),d=(l={},l[Q]=u+"Date",l[le]=u+"Date",l[U]=u+"Month",l[J]=u+"FullYear",l[oe]=u+"Hours",l[ie]=u+"Minutes",l[se]=u+"Seconds",l[Me]=u+"Milliseconds",l)[c],p=c===Q?this.$D+(i-this.$W):i;if(c===U||c===J){var h=this.clone().set(le,1);h.$d[d](p),h.init(),this.$d=h.set(le,Math.min(this.$D,h.daysInMonth())).$d}else d&&this.$d[d](p);return this.init(),this},t.set=function(n,i){return this.clone().$set(n,i)},t.get=function(n){return this[z.p(n)]()},t.add=function(n,i){var l=this,c;n=Number(n);var u=z.p(i),d=function(v){var C=I(l);return z.w(C.date(C.date()+Math.round(v*n)),l)};if(u===U)return this.set(U,this.$M+n);if(u===J)return this.set(J,this.$y+n);if(u===Q)return d(1);if(u===Te)return d(7);var p=(c={},c[ie]=$e,c[oe]=st,c[se]=re,c)[u]||1,h=this.$d.getTime()+n*p;return z.w(h,this)},t.subtract=function(n,i){return this.add(n*-1,i)},t.format=function(n){var i=this,l=this.$locale();if(!this.isValid())return l.invalidDate||ot;var c=n||un,u=z.z(this),d=this.$H,p=this.$m,h=this.$M,b=l.weekdays,v=l.months,C=l.meridiem,q=function(L,Z,ce,ke){return L&&(L[Z]||L(i,c))||ce[Z].slice(0,ke)},Y=function(L){return z.s(d%12||12,L,"0")},X=C||function(D,L,Z){var ce=D<12?"AM":"PM";return Z?ce.toLowerCase():ce},k=function(L){switch(L){case"YY":return String(i.$y).slice(-2);case"YYYY":return z.s(i.$y,4,"0");case"M":return h+1;case"MM":return z.s(h+1,2,"0");case"MMM":return q(l.monthsShort,h,v,3);case"MMMM":return q(v,h);case"D":return i.$D;case"DD":return z.s(i.$D,2,"0");case"d":return String(i.$W);case"dd":return q(l.weekdaysMin,i.$W,b,2);case"ddd":return q(l.weekdaysShort,i.$W,b,3);case"dddd":return b[i.$W];case"H":return String(d);case"HH":return z.s(d,2,"0");case"h":return Y(1);case"hh":return Y(2);case"a":return X(d,p,!0);case"A":return X(d,p,!1);case"m":return String(p);case"mm":return z.s(p,2,"0");case"s":return String(i.$s);case"ss":return z.s(i.$s,2,"0");case"SSS":return z.s(i.$ms,3,"0");case"Z":return u}return null};return c.replace(dn,function(D,L){return L||k(D)||u.replace(":","")})},t.utcOffset=function(){return-Math.round(this.$d.getTimezoneOffset()/15)*15},t.diff=function(n,i,l){var c=this,u=z.p(i),d=I(n),p=(d.utcOffset()-this.utcOffset())*$e,h=this-d,b=function(){return z.m(c,d)},v;switch(u){case J:v=b()/12;break;case U:v=b();break;case it:v=b()/3;break;case Te:v=(h-p)/ln;break;case Q:v=(h-p)/on;break;case oe:v=h/st;break;case ie:v=h/$e;break;case se:v=h/re;break;default:v=h;break}return l?v:z.a(v)},t.daysInMonth=function(){return this.endOf(U).$D},t.$locale=function(){return ee[this.$L]},t.locale=function(n,i){if(!n)return this.$L;var l=this.clone(),c=Se(n,i,!0);return c&&(l.$L=c),l},t.clone=function(){return z.w(this.$d,this)},t.toDate=function(){return new Date(this.valueOf())},t.toJSON=function(){return this.isValid()?this.toISOString():null},t.toISOString=function(){return this.$d.toISOString()},t.toString=function(){return this.$d.toUTCString()},r}(),lt=ye.prototype;I.prototype=lt,[["$ms",Me],["$s",se],["$m",ie],["$H",oe],["$W",Q],["$M",U],["$y",J],["$D",le]].forEach(function(r){lt[r[1]]=function(t){return this.$g(t,r[0],r[1])}}),I.extend=function(r,t){return r.$i||(r(t,ye,I),r.$i=!0),I},I.locale=Se,I.isDayjs=Re,I.unix=function(r){return I(r*1e3)},I.en=ee[xe],I.Ls=ee,I.p={};const R={datasource:an,account:tn,role:rn,api_key:nn,sql_snippet:{list:async({pagination:r},t)=>{const s=await O.post(t)("/sql_snippet/list",{sort:[{field:"update_time",order:"DESC"}],pagination:r},{});return s.data.forEach(n=>{n.create_time=I(n.create_time).format("YYYY-MM-DD HH:mm:ss"),n.update_time=I(n.update_time).format("YYYY-MM-DD HH:mm:ss")}),s},get:async(r,t)=>await O.post(t)("/sql_snippet/get",{id:r},{}),create:async(r,t)=>await O.post(t)("/sql_snippet/create",r,{}),update:async(r,t)=>await O.put(t)("/sql_snippet/update",r,{}),delete:async(r,t)=>O.post(t)("/sql_snippet/delete",{id:r},{})}},V={size:"sm",spacing:"md",button:{size:"xs"}};function _n({styles:r=V}){return e.jsx(o.Box,{mx:"auto",children:e.jsx(o.Alert,{mt:r.spacing,icon:e.jsx(A.IconAlertCircle,{size:16}),children:e.jsxs(y.Trans,{i18nKey:"datasource.db.permission_tip",children:["Only ",e.jsx("b",{children:"SELECT"})," privilege is needed."]})})})}const ut=P.forwardRef(({value:r,onChange:t,height:s="200px",defaultLanguage:n="sql"},i)=>{const l=u=>{t==null||t(u??"")},c=!t;return e.jsx(pe,{className:"minimal-monaco-editor",height:s,defaultLanguage:n,value:r,onChange:c?void 0:l,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:c||!t}})});function W({size:r,disabled:t}){const{t:s}=y.useTranslation();return e.jsx(o.Button,{type:"submit",color:"green",leftSection:e.jsx(A.IconDeviceFloppy,{size:16}),size:r,disabled:t,children:s("common.actions.submit")})}const Tn={translation:{datasource:{label:"Data Source",add:"Add a data source",edit:"Edit data source",connection_info:"Connection Info",db:{host:"Host",port:"Port",username:"Username",password:"Password",database:"Database",permission_tip:"Only <1>SELECT</1> privilege is needed."},cant_edit:{db:"Only HTTP datasources can be edited",preset:"This is a preset datasource, it can not be changed"},delete:{title:"Delete this data source?",hint:"This action won't affect your database or HTTP service.",cant_delete_preset:"This is a preset datasource, it can not be deleted"},http:{base_url:"Base URL",processing:{pre:{label:"Pre processing of queries",description:"This function will run before sending the request (for scenarios like encryption)"},post:{label:"Post processing of queries",description:"This function will run after getting a response (for scenarios like decryption)"}}},state:{adding:"Adding data source...",added:"Data source is added",updating:"Updating data source...",updated:"Data source is updated",deleting:"Deleting data source...",deleted:"Data source [{{name}}] is deleted"}},account:{label:"Account",add:"Add an account",edit:"Edit account",editing_xx:"Editing account [{{name}}]",username:"Username",email:"Email",password:"Password",password_hint:"Password must be at least 8 characters long",new_password:"New password",reset_password:"Reset password",state:{adding:"Adding account...",added:"Account is added",updating:"Updating account...",updated:"Account is updated",deleting:"Deleting account...",deleted:"Account [{{name}}] is deleted",logging_in:"Logging in...",logged_in:"Logged in"},delete:"Delete this account?"},global_sql_snippet:{label:"Global SQL Snippet",add:"Add a snippet",edit:"Edit snippet",content:"Content",description:"Global SQL Snippets are shared among dashboards",state:{adding:"Adding snippet...",added:"Snippet is added",updating:"Updating snippet...",updated:"Snippet is updated",deleting:"Deleting snippet...",deleted:"Snippet [{{name}}] is deleted"},delete:"Delete this snippet?"},api_key:{label:"API Key",add:"Add an API Key",edit:"Edit API key",app_id:"APP ID",app_secret:"APP Secret",state:{adding:"Adding API key...",added:"API key is added",updating:"Updating API key...",updated:"API Key is updated",deleting:"Deleting API key...",deleted:"API key [{{name}}] is deleted"},save:{title:"API Key is generated",warn:"Make sure you save it - you won't be able to access it again.",saved:"I've saved this API Key"},delete:"Delete this key?"},role:{label:"Role"},common:{type:"Type",name:"Name",name_placeholder:"A unique name",created_at:"Created At",updated_at:"Updated At",state:{pending:"Pending",successful:"Successful",failed:"Failed"},action:"Action",actions:{edit:"Edit",delete:"Delete",submit:"Submit",reset_to_default:"Reset to default",cancel:"Cancel",save:"Save",confirm:"Confirm"}}}},Sn={translation:{datasource:{label:"数据源",add:"添加数据源",edit:"编辑数据源",connection_info:"连接信息",db:{host:"主机(host)",port:"端口(port)",username:"用户名(username)",password:"密码(password)",database:"数据库(database)",permission_tip:"只需具备 <1>SELECT</1> 权限"},cant_edit:{db:"只有HTTP数据源可以编辑",preset:"这是预设数据源,不可编辑"},delete:{title:"删除这个数据源?",hint:"此操作不会影响您的数据库或HTTP服务",cant_delete_preset:"这是预设数据源,不可删除"},http:{base_url:"访问地址",processing:{pre:{label:"查询请求预处理",description:"此函数在请求发起前执行(例如加密场景)"},post:{label:"查询请求后处理",description:"此函数在请求获得响应后执行(例如解密场景)"}}},state:{adding:"正在添加数据源...",added:"数据源已添加",updating:"正在更新数据源...",updated:"数据源已更新",deleting:"正在删除数据源...",deleted:'数据源"{{name}}"已删除'}},account:{label:"账户",add:"添加账户",edit:"编辑账户",editing_xx:'正在编辑账户 "{{name}}"',username:"用户名",email:"邮箱",password:"密码",password_hint:"密码得至少包含8个字符",new_password:"新密码",reset_password:"重置密码",state:{adding:"正在添加账户...",added:"账户已添加",updating:"正在更新账户...",updated:"账户已更新",deleting:"正在删除账户...",deleted:'账户"{{name}}"已删除',logging_in:"正在登录...",logged_in:"已登录"},delete:"删除这个账户?"},global_sql_snippet:{label:"全局SQL片段",add:"添加片段",edit:"编辑片段",content:"SQL片段内容",description:"在制作任何看板时,既可以制订该看板自己的SQL片段,也可以使用这里的全局SQL片段",state:{adding:"正在添加片段...",added:"片段已添加",updating:"正在更新片段...",updated:"片段已更新",deleting:"正在删除片段...",deleted:'片段"{{name}}"已删除'},delete:"删除这个片段?"},api_key:{label:"API令牌",add:"添加令牌",edit:"编辑令牌",app_id:"应用ID",app_secret:"应用密钥",state:{adding:"正在添加令牌...",added:"令牌已添加",updating:"正在更新令牌...",updated:"令牌已更新",deleting:"正在删除令牌...",deleted:'令牌"{{name}}"已删除'},save:{title:"API令牌已生成",warn:"此信息只出现一次,请务必保存",saved:"我已保存"},delete:"删除这个片段?"},role:{label:"角色"},common:{type:"类型",name:"名称",name_placeholder:"名称须唯一",created_at:"创建时间",updated_at:"更新时间",state:{pending:"处理中",successful:"成功",failed:"失败"},action:"动作",actions:{edit:"编辑",delete:"删除",submit:"提交",reset_to_default:"还原为默认值",cancel:"取消",save:"保存",confirm:"确认"}}}},Le=Gt.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:Tn,zh:Sn}}).use(Wt).use(y.initReactI18next);Le.init();function yn({lang:r,children:t}){return P.useEffect(()=>{Le.changeLanguage(r)},[r]),e.jsx(y.I18nextProvider,{i18n:Le,children:t})}const wn=r=>r.replace(/([^:])(\/\/+)/g,"$1/");function Cn(r){P.useEffect(()=>{if(pe.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/settings-form");const s=wn(r);pe.loader.config({paths:{vs:s}}),pe.loader.init().then(n=>console.log("monaco instance:",n))},[])}function be(r,t){const s=n=>{const{lang:i,config:l,...c}=n;return tt(l),Cn(l.monacoPath),e.jsx(P.Suspense,{fallback:e.jsx(o.Loader,{color:"gray"}),children:e.jsx(yn,{lang:i,children:e.jsx(t,{...c})})})};return s.displayName=`withEntry(${r})`,s}function Dn({submit:r,styles:t=V,type:s}){const{t:n}=y.useTranslation(),{control:i,setValue:l,handleSubmit:c}=j.useForm({defaultValues:{type:s,key:"",config:{host:"",port:5432,username:"",password:"",database:""}}});return P.useEffect(()=>{l("type",s)},[l,s]),e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:c(r),children:[e.jsx(j.Controller,{name:"key",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("common.name"),placeholder:n("common.name_placeholder"),...u})}),e.jsx(o.Divider,{label:n("datasource.connection_info"),labelPosition:"center"}),e.jsxs(o.Group,{grow:!0,children:[e.jsx(j.Controller,{name:"config.host",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.host"),sx:{flexGrow:1},...u})}),e.jsx(j.Controller,{name:"config.port",control:i,render:({field:u})=>e.jsx(o.NumberInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.port"),hideControls:!0,sx:{width:"8em"},...u})})]}),e.jsx(j.Controller,{name:"config.username",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.username"),...u})}),e.jsx(j.Controller,{name:"config.password",control:i,render:({field:u})=>e.jsx(o.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.password"),...u})}),e.jsx(j.Controller,{name:"config.database",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.database"),...u})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}const zn=({value:r,onChange:t})=>{const s=n=>{n&&t(n)};return e.jsx(o.Box,{sx:{position:"relative"},children:e.jsx(pe,{height:"500px",defaultLanguage:"javascript",value:r,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},we=P.forwardRef(({value:r,onChange:t,label:s,modalTitle:n,defaultValue:i,styles:l},c)=>{const{t:u}=y.useTranslation(),[d,{setTrue:p,setFalse:h}]=K.useBoolean(),[b,v]=P.useState(r),C=()=>{h(),t(b)},q=()=>{h(),v(r)},Y=()=>{v(i)};return P.useEffect(()=>{v(r)},[r]),e.jsxs(e.Fragment,{children:[e.jsx(o.Button,{color:"grape",variant:"filled",leftSection:e.jsx(A.IconMathFunction,{size:16}),size:l.button.size,onClick:p,sx:{flexGrow:1},children:s}),e.jsx(o.Modal,{size:800,title:n,opened:d,onClose:h,closeOnClickOutside:!1,withCloseButton:!1,children:d&&e.jsxs(o.Stack,{children:[e.jsx(zn,{value:b,onChange:v}),e.jsxs(o.Group,{justify:"space-between",children:[e.jsx(o.Button,{size:l.button.size,onClick:Y,color:"red",leftSection:e.jsx(A.IconRecycle,{size:20}),children:u("common.actions.reset_to_default")}),e.jsxs(o.Group,{justify:"flex-end",children:[e.jsx(o.Button,{size:l.button.size,onClick:q,variant:"subtle",children:u("common.actions.cancel")}),e.jsx(o.Button,{size:l.button.size,color:"green",leftSection:e.jsx(A.IconDeviceFloppy,{size:16}),onClick:C,children:u("common.actions.save")})]})]})]})})]})}),Ce={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
32
+ <%s key={someKey} {...props} />`,Ke,ne,za,ne),Bt[ne+Ke]=!0}}return a===n?Sa(M):Ta(M),M}}function ya(a,f,m){return Ut(a,f,m,!0)}function wa(a,f,m){return Ut(a,f,m,!1)}var Ca=wa,Da=ya;he.Fragment=n,he.jsx=Ca,he.jsxs=Da}()),he}process.env.NODE_ENV==="production"?Oe.exports=Ht():Oe.exports=Xt();var e=Oe.exports;function Zt(r){r=r||{};const t=Object.keys(r).sort(),s=[];for(let n=0;n<t.length;n++){const i=t[n];if(i!="authentication"&&r[i])s.push(t[n]+"="+(typeof r[i]=="object"?JSON.stringify(r[i]):r[i]));else{const l=Object.keys(r[i]).sort();for(let c=0;c<l.length;c++){const u=l[c];u!="sign"&&r[i][u]&&s.push(l[c]+"="+(typeof r[i][u]=="object"?JSON.stringify(r[i][u]):r[i][u]))}}}return s.sort().join("&")}function en(r,t){let s=Zt(r);return s+="&key="+t,Jt.MD5(s).toString().toUpperCase()}class Xe{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const s=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:s,sign:en({app_id:this.app_id,nonce_str:s,...t},this.app_secret)}}getRequest(t,s){return(n,i,l,c)=>{const u=this.buildHeader(l),d=this.buildAxiosConfig(t,n,i,l,u,s);return Qe(d).then(p=>c?p:p.data).catch(p=>{if(Qe.isCancel(p))return Promise.reject(p);const h=p,b=Vt.get(h,"response.data.detail.message",h.message);return Promise.reject(new Error(b))})}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,s,n,i,l,c){const u={baseURL:this.baseURL,method:t,url:s,params:t==="GET"?n:i.params,headers:l,signal:c};return["POST","PUT"].includes(t)&&(u.data=i.string?JSON.stringify(n):n,u.data.authentication=this.getAuthentication(u.data)),u}buildHeader(t){const s=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:s?`bearer ${s}`:"",...t.headers}}}class Ze{constructor(t){this.implementation=t}getRequest(t,s){return this.implementation.getRequest(t,s)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const ge=new Xe,et=new Ze(ge),O=et;function tt(r){ge.baseURL!==r.apiBaseURL&&(ge.baseURL=r.apiBaseURL),r.app_id&&(ge.app_id=r.app_id),r.app_secret&&(ge.app_secret=r.app_secret)}const tn={login:async(r,t)=>{const s={name:r,password:t};return await O.post()("/account/login",s,{})},list:async()=>await O.post()("/account/list",{filter:{},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),get:async()=>await O.get()("/account/get",{},{}),update:async(r,t)=>{const s={name:r.trim(),email:t.trim()};return await O.put()("/account/update",s,{})},changepassword:async(r,t)=>{const s={old_password:r.trim(),new_password:t.trim()};return await O.post()("/account/changepassword",s,{})},create:async(r,t,s,n)=>await O.post()("/account/create",{name:r.trim(),email:t.trim(),password:s.trim(),role_id:n},{}),edit:async r=>(r.reset_password||(r.new_password=void 0),await O.put()("/account/edit",r,{})),delete:async r=>{if(r)return O.post()("/account/delete",{id:r},{})}},nn={list:async()=>await O.post()("/api/key/list",{filter:{search:""},sort:[{field:"name",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),create:async(r,t)=>O.post()("/api/key/create",{name:r,role_id:t},{}),delete:async r=>{if(r)return O.post()("/api/key/delete",{id:r},{})}},an={list:async()=>await O.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{}),create:async(r,t,s)=>await O.post()("/datasource/create",{type:r,key:t,config:s},{}),update:async(r,t)=>await O.put()("/datasource/update",{id:r,config:t},{}),delete:async r=>{await O.post()("/datasource/delete",{id:r},{})}},rn={list:async()=>await O.get()("/role/list",{},{})};var nt=60,at=nt*60,rt=at*24,sn=rt*7,re=1e3,$e=nt*re,st=at*re,on=rt*re,ln=sn*re,Me="millisecond",se="second",ie="minute",oe="hour",Q="day",Te="week",U="month",it="quarter",J="year",le="date",un="YYYY-MM-DDTHH:mm:ssZ",ot="Invalid Date",cn=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,dn=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;const fn={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var s=["th","st","nd","rd"],n=t%100;return"["+t+(s[(n-20)%10]||s[n]||s[0])+"]"}};var Ie=function(t,s,n){var i=String(t);return!i||i.length>=s?t:""+Array(s+1-i.length).join(n)+t},pn=function(t){var s=-t.utcOffset(),n=Math.abs(s),i=Math.floor(n/60),l=n%60;return(s<=0?"+":"-")+Ie(i,2,"0")+":"+Ie(l,2,"0")},mn=function r(t,s){if(t.date()<s.date())return-r(s,t);var n=(s.year()-t.year())*12+(s.month()-t.month()),i=t.clone().add(n,U),l=s-i<0,c=t.clone().add(n+(l?-1:1),U);return+(-(n+(s-i)/(l?i-c:c-i))||0)},hn=function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},gn=function(t){var s={M:U,y:J,w:Te,d:Q,D:le,h:oe,m:ie,s:se,ms:Me,Q:it};return s[t]||String(t||"").toLowerCase().replace(/s$/,"")},xn=function(t){return t===void 0};const bn={s:Ie,z:pn,m:mn,a:hn,p:gn,u:xn};var xe="en",ee={};ee[xe]=fn;var Re=function(t){return t instanceof ye},Se=function r(t,s,n){var i;if(!t)return xe;if(typeof t=="string"){var l=t.toLowerCase();ee[l]&&(i=l),s&&(ee[l]=s,i=l);var c=t.split("-");if(!i&&c.length>1)return r(c[0])}else{var u=t.name;ee[u]=t,i=u}return!n&&i&&(xe=i),i||!n&&xe},I=function(t,s){if(Re(t))return t.clone();var n=typeof s=="object"?s:{};return n.date=t,n.args=arguments,new ye(n)},vn=function(t,s){return I(t,{locale:s.$L,utc:s.$u,x:s.$x,$offset:s.$offset})},z=bn;z.l=Se,z.i=Re,z.w=vn;var jn=function(t){var s=t.date,n=t.utc;if(s===null)return new Date(NaN);if(z.u(s))return new Date;if(s instanceof Date)return new Date(s);if(typeof s=="string"&&!/Z$/i.test(s)){var i=s.match(cn);if(i){var l=i[2]-1||0,c=(i[7]||"0").substring(0,3);return n?new Date(Date.UTC(i[1],l,i[3]||1,i[4]||0,i[5]||0,i[6]||0,c)):new Date(i[1],l,i[3]||1,i[4]||0,i[5]||0,i[6]||0,c)}}return new Date(s)},ye=function(){function r(s){this.$L=Se(s.locale,null,!0),this.parse(s)}var t=r.prototype;return t.parse=function(n){this.$d=jn(n),this.$x=n.x||{},this.init()},t.init=function(){var n=this.$d;this.$y=n.getFullYear(),this.$M=n.getMonth(),this.$D=n.getDate(),this.$W=n.getDay(),this.$H=n.getHours(),this.$m=n.getMinutes(),this.$s=n.getSeconds(),this.$ms=n.getMilliseconds()},t.$utils=function(){return z},t.isValid=function(){return this.$d.toString()!==ot},t.isSame=function(n,i){var l=I(n);return this.startOf(i)<=l&&l<=this.endOf(i)},t.isAfter=function(n,i){return I(n)<this.startOf(i)},t.isBefore=function(n,i){return this.endOf(i)<I(n)},t.$g=function(n,i,l){return z.u(n)?this[i]:this.set(l,n)},t.unix=function(){return Math.floor(this.valueOf()/1e3)},t.valueOf=function(){return this.$d.getTime()},t.startOf=function(n,i){var l=this,c=z.u(i)?!0:i,u=z.p(n),d=function(k,D){var q=z.w(l.$u?Date.UTC(l.$y,D,k):new Date(l.$y,D,k),l);return c?q:q.endOf(Q)},p=function(k,D){var q=[0,0,0,0],Z=[23,59,59,999];return z.w(l.toDate()[k].apply(l.toDate("s"),(c?q:Z).slice(D)),l)},h=this.$W,b=this.$M,v=this.$D,C="set"+(this.$u?"UTC":"");switch(u){case J:return c?d(1,0):d(31,11);case U:return c?d(1,b):d(0,b+1);case Te:{var L=this.$locale().weekStart||0,Y=(h<L?h+7:h)-L;return d(c?v-Y:v+(6-Y),b)}case Q:case le:return p(C+"Hours",0);case oe:return p(C+"Minutes",1);case ie:return p(C+"Seconds",2);case se:return p(C+"Milliseconds",3);default:return this.clone()}},t.endOf=function(n){return this.startOf(n,!1)},t.$set=function(n,i){var l,c=z.p(n),u="set"+(this.$u?"UTC":""),d=(l={},l[Q]=u+"Date",l[le]=u+"Date",l[U]=u+"Month",l[J]=u+"FullYear",l[oe]=u+"Hours",l[ie]=u+"Minutes",l[se]=u+"Seconds",l[Me]=u+"Milliseconds",l)[c],p=c===Q?this.$D+(i-this.$W):i;if(c===U||c===J){var h=this.clone().set(le,1);h.$d[d](p),h.init(),this.$d=h.set(le,Math.min(this.$D,h.daysInMonth())).$d}else d&&this.$d[d](p);return this.init(),this},t.set=function(n,i){return this.clone().$set(n,i)},t.get=function(n){return this[z.p(n)]()},t.add=function(n,i){var l=this,c;n=Number(n);var u=z.p(i),d=function(v){var C=I(l);return z.w(C.date(C.date()+Math.round(v*n)),l)};if(u===U)return this.set(U,this.$M+n);if(u===J)return this.set(J,this.$y+n);if(u===Q)return d(1);if(u===Te)return d(7);var p=(c={},c[ie]=$e,c[oe]=st,c[se]=re,c)[u]||1,h=this.$d.getTime()+n*p;return z.w(h,this)},t.subtract=function(n,i){return this.add(n*-1,i)},t.format=function(n){var i=this,l=this.$locale();if(!this.isValid())return l.invalidDate||ot;var c=n||un,u=z.z(this),d=this.$H,p=this.$m,h=this.$M,b=l.weekdays,v=l.months,C=l.meridiem,L=function(q,Z,ce,ke){return q&&(q[Z]||q(i,c))||ce[Z].slice(0,ke)},Y=function(q){return z.s(d%12||12,q,"0")},X=C||function(D,q,Z){var ce=D<12?"AM":"PM";return Z?ce.toLowerCase():ce},k=function(q){switch(q){case"YY":return String(i.$y).slice(-2);case"YYYY":return z.s(i.$y,4,"0");case"M":return h+1;case"MM":return z.s(h+1,2,"0");case"MMM":return L(l.monthsShort,h,v,3);case"MMMM":return L(v,h);case"D":return i.$D;case"DD":return z.s(i.$D,2,"0");case"d":return String(i.$W);case"dd":return L(l.weekdaysMin,i.$W,b,2);case"ddd":return L(l.weekdaysShort,i.$W,b,3);case"dddd":return b[i.$W];case"H":return String(d);case"HH":return z.s(d,2,"0");case"h":return Y(1);case"hh":return Y(2);case"a":return X(d,p,!0);case"A":return X(d,p,!1);case"m":return String(p);case"mm":return z.s(p,2,"0");case"s":return String(i.$s);case"ss":return z.s(i.$s,2,"0");case"SSS":return z.s(i.$ms,3,"0");case"Z":return u}return null};return c.replace(dn,function(D,q){return q||k(D)||u.replace(":","")})},t.utcOffset=function(){return-Math.round(this.$d.getTimezoneOffset()/15)*15},t.diff=function(n,i,l){var c=this,u=z.p(i),d=I(n),p=(d.utcOffset()-this.utcOffset())*$e,h=this-d,b=function(){return z.m(c,d)},v;switch(u){case J:v=b()/12;break;case U:v=b();break;case it:v=b()/3;break;case Te:v=(h-p)/ln;break;case Q:v=(h-p)/on;break;case oe:v=h/st;break;case ie:v=h/$e;break;case se:v=h/re;break;default:v=h;break}return l?v:z.a(v)},t.daysInMonth=function(){return this.endOf(U).$D},t.$locale=function(){return ee[this.$L]},t.locale=function(n,i){if(!n)return this.$L;var l=this.clone(),c=Se(n,i,!0);return c&&(l.$L=c),l},t.clone=function(){return z.w(this.$d,this)},t.toDate=function(){return new Date(this.valueOf())},t.toJSON=function(){return this.isValid()?this.toISOString():null},t.toISOString=function(){return this.$d.toISOString()},t.toString=function(){return this.$d.toUTCString()},r}(),lt=ye.prototype;I.prototype=lt,[["$ms",Me],["$s",se],["$m",ie],["$H",oe],["$W",Q],["$M",U],["$y",J],["$D",le]].forEach(function(r){lt[r[1]]=function(t){return this.$g(t,r[0],r[1])}}),I.extend=function(r,t){return r.$i||(r(t,ye,I),r.$i=!0),I},I.locale=Se,I.isDayjs=Re,I.unix=function(r){return I(r*1e3)},I.en=ee[xe],I.Ls=ee,I.p={};const R={datasource:an,account:tn,role:rn,api_key:nn,sql_snippet:{list:async({pagination:r},t)=>{const s=await O.post(t)("/sql_snippet/list",{sort:[{field:"update_time",order:"DESC"}],pagination:r},{});return s.data.forEach(n=>{n.create_time=I(n.create_time).format("YYYY-MM-DD HH:mm:ss"),n.update_time=I(n.update_time).format("YYYY-MM-DD HH:mm:ss")}),s},get:async(r,t)=>await O.post(t)("/sql_snippet/get",{id:r},{}),create:async(r,t)=>await O.post(t)("/sql_snippet/create",r,{}),update:async(r,t)=>await O.put(t)("/sql_snippet/update",r,{}),delete:async(r,t)=>O.post(t)("/sql_snippet/delete",{id:r},{})}},V={size:"sm",spacing:"md",button:{size:"xs"}};function _n({styles:r=V}){return e.jsx(o.Box,{mx:"auto",children:e.jsx(o.Alert,{mt:r.spacing,icon:e.jsx(A.IconAlertCircle,{size:16}),children:e.jsxs(y.Trans,{i18nKey:"datasource.db.permission_tip",children:["Only ",e.jsx("b",{children:"SELECT"})," privilege is needed."]})})})}const ut=P.forwardRef(({value:r,onChange:t,height:s="200px",defaultLanguage:n="sql"},i)=>{const l=u=>{t==null||t(u??"")},c=!t;return e.jsx(pe,{className:"minimal-monaco-editor",height:s,defaultLanguage:n,value:r,onChange:c?void 0:l,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:c||!t}})});function W({size:r,disabled:t}){const{t:s}=y.useTranslation();return e.jsx(o.Button,{type:"submit",color:"green",leftSection:e.jsx(A.IconDeviceFloppy,{size:16}),size:r,disabled:t,children:s("common.actions.submit")})}const Tn={translation:{datasource:{label:"Data Source",add:"Add a data source",edit:"Edit data source",connection_info:"Connection Info",db:{host:"Host",port:"Port",username:"Username",password:"Password",database:"Database",permission_tip:"Only <1>SELECT</1> privilege is needed."},cant_edit:{db:"Only HTTP datasources can be edited",preset:"This is a preset datasource, it can not be changed"},delete:{title:"Delete this data source?",hint:"This action won't affect your database or HTTP service.",cant_delete_preset:"This is a preset datasource, it can not be deleted"},http:{host:"Host",processing:{pre:{label:"Pre processing of queries",description:"This function will run before sending the request (for scenarios like encryption)"},post:{label:"Post processing of queries",description:"This function will run after getting a response (for scenarios like decryption)"}}},state:{adding:"Adding data source...",added:"Data source is added",updating:"Updating data source...",updated:"Data source is updated",deleting:"Deleting data source...",deleted:"Data source [{{name}}] is deleted"}},account:{label:"Account",add:"Add an account",edit:"Edit account",editing_xx:"Editing account [{{name}}]",username:"Username",email:"Email",password:"Password",password_hint:"Password must be at least 8 characters long",new_password:"New password",reset_password:"Reset password",state:{adding:"Adding account...",added:"Account is added",updating:"Updating account...",updated:"Account is updated",deleting:"Deleting account...",deleted:"Account [{{name}}] is deleted",logging_in:"Logging in...",logged_in:"Logged in"},delete:"Delete this account?"},global_sql_snippet:{label:"Global SQL Snippet",add:"Add a snippet",edit:"Edit snippet",content:"Content",description:"Global SQL Snippets are shared among dashboards",state:{adding:"Adding snippet...",added:"Snippet is added",updating:"Updating snippet...",updated:"Snippet is updated",deleting:"Deleting snippet...",deleted:"Snippet [{{name}}] is deleted"},delete:"Delete this snippet?"},api_key:{label:"API Key",add:"Add an API Key",edit:"Edit API key",app_id:"APP ID",app_secret:"APP Secret",state:{adding:"Adding API key...",added:"API key is added",updating:"Updating API key...",updated:"API Key is updated",deleting:"Deleting API key...",deleted:"API key [{{name}}] is deleted"},save:{title:"API Key is generated",warn:"Make sure you save it - you won't be able to access it again.",saved:"I've saved this API Key"},delete:"Delete this key?"},role:{label:"Role"},common:{type:"Type",name:"Name",name_placeholder:"A unique name",created_at:"Created At",updated_at:"Updated At",state:{pending:"Pending",successful:"Successful",failed:"Failed"},action:"Action",actions:{edit:"Edit",delete:"Delete",submit:"Submit",reset_to_default:"Reset to default",cancel:"Cancel",save:"Save",confirm:"Confirm"}}}},Sn={translation:{datasource:{label:"数据源",add:"添加数据源",edit:"编辑数据源",connection_info:"连接信息",db:{host:"主机(host)",port:"端口(port)",username:"用户名(username)",password:"密码(password)",database:"数据库(database)",permission_tip:"只需具备 <1>SELECT</1> 权限"},cant_edit:{db:"只有HTTP数据源可以编辑",preset:"这是预设数据源,不可编辑"},delete:{title:"删除这个数据源?",hint:"此操作不会影响您的数据库或HTTP服务",cant_delete_preset:"这是预设数据源,不可删除"},http:{host:"Host",processing:{pre:{label:"查询请求预处理",description:"此函数在请求发起前执行(例如加密场景)"},post:{label:"查询请求后处理",description:"此函数在请求获得响应后执行(例如解密场景)"}}},state:{adding:"正在添加数据源...",added:"数据源已添加",updating:"正在更新数据源...",updated:"数据源已更新",deleting:"正在删除数据源...",deleted:'数据源"{{name}}"已删除'}},account:{label:"账户",add:"添加账户",edit:"编辑账户",editing_xx:'正在编辑账户 "{{name}}"',username:"用户名",email:"邮箱",password:"密码",password_hint:"密码得至少包含8个字符",new_password:"新密码",reset_password:"重置密码",state:{adding:"正在添加账户...",added:"账户已添加",updating:"正在更新账户...",updated:"账户已更新",deleting:"正在删除账户...",deleted:'账户"{{name}}"已删除',logging_in:"正在登录...",logged_in:"已登录"},delete:"删除这个账户?"},global_sql_snippet:{label:"全局SQL片段",add:"添加片段",edit:"编辑片段",content:"SQL片段内容",description:"在制作任何看板时,既可以制订该看板自己的SQL片段,也可以使用这里的全局SQL片段",state:{adding:"正在添加片段...",added:"片段已添加",updating:"正在更新片段...",updated:"片段已更新",deleting:"正在删除片段...",deleted:'片段"{{name}}"已删除'},delete:"删除这个片段?"},api_key:{label:"API令牌",add:"添加令牌",edit:"编辑令牌",app_id:"应用ID",app_secret:"应用密钥",state:{adding:"正在添加令牌...",added:"令牌已添加",updating:"正在更新令牌...",updated:"令牌已更新",deleting:"正在删除令牌...",deleted:'令牌"{{name}}"已删除'},save:{title:"API令牌已生成",warn:"此信息只出现一次,请务必保存",saved:"我已保存"},delete:"删除这个片段?"},role:{label:"角色"},common:{type:"类型",name:"名称",name_placeholder:"名称须唯一",created_at:"创建时间",updated_at:"更新时间",state:{pending:"处理中",successful:"成功",failed:"失败"},action:"动作",actions:{edit:"编辑",delete:"删除",submit:"提交",reset_to_default:"还原为默认值",cancel:"取消",save:"保存",confirm:"确认"}}}},qe=Gt.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:Tn,zh:Sn}}).use(Wt).use(y.initReactI18next);qe.init();function yn({lang:r,children:t}){return P.useEffect(()=>{qe.changeLanguage(r)},[r]),e.jsx(y.I18nextProvider,{i18n:qe,children:t})}const wn=r=>r.replace(/([^:])(\/\/+)/g,"$1/");function Cn(r){P.useEffect(()=>{if(pe.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/settings-form");const s=wn(r);pe.loader.config({paths:{vs:s}}),pe.loader.init().then(n=>console.log("monaco instance:",n))},[])}function be(r,t){const s=n=>{const{lang:i,config:l,...c}=n;return tt(l),Cn(l.monacoPath),e.jsx(P.Suspense,{fallback:e.jsx(o.Loader,{color:"gray"}),children:e.jsx(yn,{lang:i,children:e.jsx(t,{...c})})})};return s.displayName=`withEntry(${r})`,s}function Dn({submit:r,styles:t=V,type:s}){const{t:n}=y.useTranslation(),{control:i,setValue:l,handleSubmit:c}=j.useForm({defaultValues:{type:s,key:"",config:{host:"",port:5432,username:"",password:"",database:""}}});return P.useEffect(()=>{l("type",s)},[l,s]),e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:c(r),children:[e.jsx(j.Controller,{name:"key",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("common.name"),placeholder:n("common.name_placeholder"),...u})}),e.jsx(o.Divider,{label:n("datasource.connection_info"),labelPosition:"center"}),e.jsxs(o.Group,{grow:!0,children:[e.jsx(j.Controller,{name:"config.host",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.host"),sx:{flexGrow:1},...u})}),e.jsx(j.Controller,{name:"config.port",control:i,render:({field:u})=>e.jsx(o.NumberInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.port"),hideControls:!0,sx:{width:"8em"},...u})})]}),e.jsx(j.Controller,{name:"config.username",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.username"),...u})}),e.jsx(j.Controller,{name:"config.password",control:i,render:({field:u})=>e.jsx(o.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.password"),...u})}),e.jsx(j.Controller,{name:"config.database",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("datasource.db.database"),...u})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}const zn=({value:r,onChange:t})=>{const s=n=>{n&&t(n)};return e.jsx(o.Box,{sx:{position:"relative"},children:e.jsx(pe,{height:"500px",defaultLanguage:"javascript",value:r,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},we=P.forwardRef(({value:r,onChange:t,label:s,modalTitle:n,defaultValue:i,styles:l},c)=>{const{t:u}=y.useTranslation(),[d,{setTrue:p,setFalse:h}]=K.useBoolean(),[b,v]=P.useState(r),C=()=>{h(),t(b)},L=()=>{h(),v(r)},Y=()=>{v(i)};return P.useEffect(()=>{v(r)},[r]),e.jsxs(e.Fragment,{children:[e.jsx(o.Button,{color:"grape",variant:"filled",leftSection:e.jsx(A.IconMathFunction,{size:16}),size:l.button.size,onClick:p,sx:{flexGrow:1},children:s}),e.jsx(o.Modal,{size:800,title:n,opened:d,onClose:h,closeOnClickOutside:!1,withCloseButton:!1,children:d&&e.jsxs(o.Stack,{children:[e.jsx(zn,{value:b,onChange:v}),e.jsxs(o.Group,{justify:"space-between",children:[e.jsx(o.Button,{size:l.button.size,onClick:Y,color:"red",leftSection:e.jsx(A.IconRecycle,{size:20}),children:u("common.actions.reset_to_default")}),e.jsxs(o.Group,{justify:"flex-end",children:[e.jsx(o.Button,{size:l.button.size,onClick:L,variant:"subtle",children:u("common.actions.cancel")}),e.jsx(o.Button,{size:l.button.size,color:"green",leftSection:e.jsx(A.IconDeviceFloppy,{size:16}),onClick:C,children:u("common.actions.save")})]})]})]})})]})}),Ce={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
33
33
  `),post:["function post_process(res, utils) {"," // your code goes here"," return data","}"].join(`
34
- `)};function En({submit:r,styles:t=V}){const{t:s}=y.useTranslation(),{control:n,setValue:i,handleSubmit:l}=j.useForm({defaultValues:{type:"http",key:"",config:{host:"",processing:{pre:Ce.pre,post:Ce.post}}}});return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:l(r),children:[e.jsx(j.Controller,{name:"key",control:n,render:({field:c})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:s("common.name"),placeholder:s("common.name_placeholder"),...c})}),e.jsx(o.Divider,{label:s("datasource.connection_info"),labelPosition:"center"}),e.jsx(j.Controller,{name:"config.host",control:n,render:({field:c})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,label:s("datasource.http.base_url"),sx:{flexGrow:1},...c})}),e.jsxs(o.Group,{grow:!0,children:[e.jsx(j.Controller,{name:"config.processing.pre",control:n,render:({field:c})=>e.jsx(we,{label:s("datasource.http.processing.pre.label"),modalTitle:s("datasource.http.processing.pre.description"),defaultValue:Ce.pre,...c,styles:t})}),e.jsx(j.Controller,{name:"config.processing.post",control:n,render:({field:c})=>e.jsx(we,{label:s("datasource.http.processing.post.label"),modalTitle:s("datasource.http.processing.post.description"),defaultValue:Ce.post,...c,styles:t})})]}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function An({postSubmit:r,styles:t=V}){const{t:s}=y.useTranslation(),[n,i]=P.useState("postgresql"),l=async({type:p,key:h,config:b})=>{T.showNotification({id:"for-creating",title:s("common.state.pending"),message:s("datasource.state.adding"),loading:!0,autoClose:!1});try{console.log({type:p,key:h,config:b}),await R.datasource.create(p,h,b),T.updateNotification({id:"for-creating",title:s("common.state.successful"),message:s("datasource.state.added"),color:"green",autoClose:!0}),r()}catch(v){console.error(v),T.updateNotification({id:"for-creating",title:s("common.state.failed"),message:v.message,color:"red",autoClose:!0})}},c=p=>{i(p)},u=n==="postgresql"||n==="mysql",d=n==="http";return e.jsxs(o.Box,{mx:"auto",children:[e.jsx(o.SegmentedControl,{fullWidth:!0,mb:t.spacing,size:t.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http"}],value:n,onChange:c}),u&&e.jsx(_n,{styles:t}),u&&e.jsx(Dn,{submit:l,styles:t,type:n}),d&&e.jsx(En,{submit:l,styles:t})]})}function ct({onSuccess:r,styles:t=V}){const{t:s}=y.useTranslation(),[n,i]=P.useState(!1),l=()=>i(!0),c=()=>i(!1),u=()=>{r(),c()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:n,onClose:()=>i(!1),title:s("datasource.add"),trapFocus:!0,onDragStart:d=>{d.stopPropagation()},children:e.jsx(An,{postSubmit:u,styles:t})}),e.jsx(o.Button,{size:t.button.size,onClick:l,leftSection:e.jsx(A.IconPlaylistAdd,{size:20}),children:s("datasource.add")})]})}const Pn={http:"HTTP",mysql:"MySQL",postgresql:"PostgreSQL",merico_metric_system:"Merico Metric System"},On={http:e.jsx(A.IconNetwork,{}),mysql:e.jsx(A.IconBrandMysql,{}),postgresql:e.jsx(A.IconDatabase,{}),merico_metric_system:e.jsx(A.IconTopologyRing3,{})};function $n({type:r}){return e.jsxs(o.Group,{children:[e.jsx(o.ActionIcon,{variant:"subtle",size:"xs",sx:{transform:"none !important"},children:On[r]}),e.jsx(o.Text,{sx:{cusor:"default",userSelect:"none"},children:Pn[r]})]})}function dt({id:r,name:t,isProtected:s,onSuccess:n,styles:i=V}){const{t:l}=y.useTranslation(),c=ae.useModals(),u=async()=>{r&&(T.showNotification({id:"for-deleting",title:l("common.state.pending"),message:l("datasource.state.deleting"),loading:!0,autoClose:!1}),await R.datasource.delete(r),T.updateNotification({id:"for-deleting",title:l("common.state.successful"),message:l("datasource.state.deleted",{name:t}),color:"green",autoClose:!0}),n())},d=()=>c.openConfirmModal({title:l("datasource.delete.title"),children:e.jsx(o.Text,{size:i.size,children:l("datasource.delete.hint")}),labels:{confirm:l("common.actions.confirm"),cancel:l("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:u,cancelProps:{size:i.button.size},confirmProps:{color:"red",size:i.button.size}});return s?e.jsx(o.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:l("datasource.delete.cant_delete_preset"),children:e.jsx(o.Button,{size:i.button.size,color:"gray",variant:"light",leftSection:e.jsx(A.IconLock,{size:16}),sx:{transform:"none !important"},children:l("common.actions.delete")})}):e.jsx(o.Button,{size:i.button.size,color:"red",onClick:d,leftSection:e.jsx(A.IconTrash,{size:16}),children:l("common.actions.delete")})}const ft={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
34
+ `)};function En({submit:r,styles:t=V}){const{t:s}=y.useTranslation(),{control:n,setValue:i,handleSubmit:l}=j.useForm({defaultValues:{type:"http",key:"",config:{host:"",processing:{pre:Ce.pre,post:Ce.post}}}});return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:l(r),children:[e.jsx(j.Controller,{name:"key",control:n,render:({field:c})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:s("common.name"),placeholder:s("common.name_placeholder"),...c})}),e.jsx(o.Divider,{label:s("datasource.connection_info"),labelPosition:"center"}),e.jsx(j.Controller,{name:"config.host",control:n,render:({field:c})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:s("datasource.http.host"),sx:{flexGrow:1},...c})}),e.jsxs(o.Group,{grow:!0,children:[e.jsx(j.Controller,{name:"config.processing.pre",control:n,render:({field:c})=>e.jsx(we,{label:s("datasource.http.processing.pre.label"),modalTitle:s("datasource.http.processing.pre.description"),defaultValue:Ce.pre,...c,styles:t})}),e.jsx(j.Controller,{name:"config.processing.post",control:n,render:({field:c})=>e.jsx(we,{label:s("datasource.http.processing.post.label"),modalTitle:s("datasource.http.processing.post.description"),defaultValue:Ce.post,...c,styles:t})})]}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function An({postSubmit:r,styles:t=V}){const{t:s}=y.useTranslation(),[n,i]=P.useState("postgresql"),l=async({type:p,key:h,config:b})=>{T.showNotification({id:"for-creating",title:s("common.state.pending"),message:s("datasource.state.adding"),loading:!0,autoClose:!1});try{console.log({type:p,key:h,config:b}),await R.datasource.create(p,h,b),T.updateNotification({id:"for-creating",title:s("common.state.successful"),message:s("datasource.state.added"),color:"green",autoClose:!0}),r()}catch(v){console.error(v),T.updateNotification({id:"for-creating",title:s("common.state.failed"),message:v.message,color:"red",autoClose:!0})}},c=p=>{i(p)},u=n==="postgresql"||n==="mysql",d=n==="http";return e.jsxs(o.Box,{mx:"auto",children:[e.jsx(o.SegmentedControl,{fullWidth:!0,mb:t.spacing,size:t.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http"}],value:n,onChange:c}),u&&e.jsx(_n,{styles:t}),u&&e.jsx(Dn,{submit:l,styles:t,type:n}),d&&e.jsx(En,{submit:l,styles:t})]})}function ct({onSuccess:r,styles:t=V}){const{t:s}=y.useTranslation(),[n,i]=P.useState(!1),l=()=>i(!0),c=()=>i(!1),u=()=>{r(),c()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:n,onClose:()=>i(!1),title:s("datasource.add"),trapFocus:!0,onDragStart:d=>{d.stopPropagation()},children:e.jsx(An,{postSubmit:u,styles:t})}),e.jsx(o.Button,{size:t.button.size,onClick:l,leftSection:e.jsx(A.IconPlaylistAdd,{size:20}),children:s("datasource.add")})]})}const Pn={http:"HTTP",mysql:"MySQL",postgresql:"PostgreSQL",merico_metric_system:"Merico Metric System"},On={http:e.jsx(A.IconNetwork,{}),mysql:e.jsx(A.IconBrandMysql,{}),postgresql:e.jsx(A.IconDatabase,{}),merico_metric_system:e.jsx(A.IconTopologyRing3,{})};function $n({type:r}){return e.jsxs(o.Group,{children:[e.jsx(o.ActionIcon,{variant:"subtle",size:"xs",sx:{transform:"none !important"},children:On[r]}),e.jsx(o.Text,{sx:{cusor:"default",userSelect:"none"},children:Pn[r]})]})}function dt({id:r,name:t,isProtected:s,onSuccess:n,styles:i=V}){const{t:l}=y.useTranslation(),c=ae.useModals(),u=async()=>{r&&(T.showNotification({id:"for-deleting",title:l("common.state.pending"),message:l("datasource.state.deleting"),loading:!0,autoClose:!1}),await R.datasource.delete(r),T.updateNotification({id:"for-deleting",title:l("common.state.successful"),message:l("datasource.state.deleted",{name:t}),color:"green",autoClose:!0}),n())},d=()=>c.openConfirmModal({title:l("datasource.delete.title"),children:e.jsx(o.Text,{size:i.size,children:l("datasource.delete.hint")}),labels:{confirm:l("common.actions.confirm"),cancel:l("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:u,cancelProps:{size:i.button.size},confirmProps:{color:"red",size:i.button.size}});return s?e.jsx(o.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:l("datasource.delete.cant_delete_preset"),children:e.jsx(o.Button,{size:i.button.size,color:"gray",variant:"light",leftSection:e.jsx(A.IconLock,{size:16}),sx:{transform:"none !important"},children:l("common.actions.delete")})}):e.jsx(o.Button,{size:i.button.size,color:"red",onClick:d,leftSection:e.jsx(A.IconTrash,{size:16}),children:l("common.actions.delete")})}const ft={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
35
35
  `),post:["function post_process(resp, utils) {"," return resp.data","}"].join(`
36
- `)};function Mn({name:r,config:t,submit:s,styles:n=V}){const{t:i}=y.useTranslation(),{control:l,handleSubmit:c}=j.useForm({defaultValues:{config:t}});return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:c(s),children:[e.jsx(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:i("common.name"),value:r,readOnly:!0}),e.jsx(o.Divider,{label:i("datasource.connection_info"),labelPosition:"center"}),e.jsx(j.Controller,{name:"config.host",control:l,render:({field:u})=>e.jsx(o.TextInput,{mb:n.spacing,size:n.size,label:i("datasource.http.base_url"),sx:{flexGrow:1},...u})}),e.jsxs(o.Group,{grow:!0,children:[e.jsx(j.Controller,{name:"config.processing.pre",control:l,render:({field:u})=>e.jsx(we,{label:i("datasource.http.processing.pre.label"),modalTitle:i("datasource.http.processing.pre.description"),defaultValue:ft.pre,...u,styles:n})}),e.jsx(j.Controller,{name:"config.processing.post",control:l,render:({field:u})=>e.jsx(we,{label:i("datasource.http.processing.post.label"),modalTitle:i("datasource.http.processing.post.description"),defaultValue:ft.post,...u,styles:n})})]}),e.jsx(o.Group,{justify:"flex-end",mt:n.spacing,children:e.jsx(W,{size:n.button.size})})]})})}function In({dataSource:r,postSubmit:t,styles:s=V}){const{t:n}=y.useTranslation(),i=async({config:l})=>{T.showNotification({id:"for-updating",title:n("common.state.pending"),message:n("datasource.state.updating"),loading:!0,autoClose:!1});try{console.log({config:l}),await R.datasource.update(r.id,l),T.updateNotification({id:"for-updating",title:n("common.state.successful"),message:n("datasource.state.updated"),color:"green",loading:!1,autoClose:!0}),t()}catch(c){T.updateNotification({id:"for-updating",title:n("common.state.failed"),message:c.message,color:"red",loading:!1,autoClose:!0})}};return r.config?e.jsx(o.Box,{mx:"auto",children:e.jsx(Mn,{name:r.key,config:r.config,submit:i,styles:s})}):(console.error(new Error("unexpected empty config of a http datasource")),null)}function Rn({dataSource:r,onSuccess:t,styles:s=V}){const{t:n}=y.useTranslation(),[i,l]=P.useState(!1),c=()=>l(!0),u=()=>l(!1),d=()=>{t(),u()};return r.is_preset?e.jsx(o.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:n("datasource.cant_edit.preset"),children:e.jsx(o.Button,{size:s.button.size,color:"gray",variant:"light",leftSection:e.jsx(A.IconLock,{size:16}),sx:{transform:"none !important"},children:n("common.actions.edit")})}):r.type!=="http"&&r.type!=="merico_metric_system"?e.jsx(o.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:n("datasource.cant_edit.db"),children:e.jsx(o.Button,{size:s.button.size,color:"gray",variant:"light",leftSection:e.jsx(A.IconEdit,{size:16}),sx:{transform:"none !important"},children:n("common.actions.edit")})}):e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:i,onClose:()=>l(!1),title:n("datasource.edit"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:e.jsx(In,{dataSource:r,postSubmit:d,styles:s})}),e.jsx(o.Button,{size:s.button.size,color:"blue",onClick:c,leftSection:e.jsx(A.IconEdit,{size:16}),children:n("common.actions.edit")})]})}const Ln=be("DataSourceList",({styles:r=V})=>{const{t}=y.useTranslation(),{data:s=[],loading:n,refresh:i}=K.useRequest(async()=>{const{data:l}=await R.datasource.list();return l},{refreshDeps:[]});return e.jsxs(e.Fragment,{children:[e.jsx(o.Group,{pt:r.spacing,justify:"flex-end",children:e.jsx(ct,{onSuccess:i})}),e.jsxs(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[e.jsx(o.LoadingOverlay,{visible:n}),e.jsxs(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fz:r.size,highlightOnHover:!0,children:[e.jsx(o.Table.Thead,{children:e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Th,{children:t("common.type")}),e.jsx(o.Table.Th,{children:t("common.name")}),e.jsx(o.Table.Th,{children:t("common.action")})]})}),e.jsx(o.Table.Tbody,{children:s.map(l=>{const{id:c,key:u,type:d,is_preset:p}=l,h=d==="merico_metric_system";return e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Td,{width:230,children:e.jsx($n,{type:d})}),e.jsx(o.Table.Td,{children:u}),e.jsx(o.Table.Td,{width:400,children:e.jsxs(o.Group,{justify:"flex-start",children:[e.jsx(Rn,{dataSource:l,onSuccess:i,styles:r}),e.jsx(dt,{isProtected:p||h,id:c,name:u,onSuccess:i,styles:r})]})})]},u)})})]})]})]})}),qn=({option:r,...t})=>{const{label:s,value:n,description:i}=r;return e.jsxs(o.Stack,{gap:2,...t,children:[e.jsx(o.Text,{size:"sm",children:s}),e.jsx(o.Text,{size:"xs",c:"dimmed",className:"role-description",children:i})]})},qe=P.forwardRef(({styles:r,value:t,onChange:s},n)=>{const{t:i}=y.useTranslation(),{data:l=[],loading:c}=K.useRequest(async()=>(await R.role.list()).map(d=>({label:d.id,value:d.id,description:d.description,disabled:d.id==="SUPERADMIN"})),{refreshDeps:[]});return e.jsx(o.Select,{ref:n,mb:r.spacing,size:r.size,required:!0,label:i("role.label"),renderOption:qn,data:l,disabled:c,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:t,onChange:u=>u!==null&&s(u),comboboxProps:{withinPortal:!0},maxDropdownHeight:500})}),H={size:"sm",spacing:"md",button:{size:"xs"}};function kn({postSubmit:r,styles:t=H,initialRoleID:s}){const{t:n}=y.useTranslation(),{control:i,handleSubmit:l}=j.useForm({defaultValues:{name:"",email:"",role_id:s,password:""}}),c=async({name:u,email:d,password:p,role_id:h})=>{try{T.showNotification({id:"for-creating",title:n("common.state.pending"),message:n("account.state.adding"),loading:!0,autoClose:!1}),await R.account.create(u,d,p,h),T.updateNotification({id:"for-creating",title:n("common.state.successful"),message:n("account.state.added"),color:"green",autoClose:!0,loading:!1}),r()}catch(b){T.updateNotification({id:"for-creating",title:n("common.state.failed"),message:b.message,color:"red",autoClose:!0,loading:!1})}};return e.jsx(o.Box,{mx:"auto",mb:10,children:e.jsxs("form",{onSubmit:l(c),children:[e.jsx(j.Controller,{name:"name",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("account.username"),...u})}),e.jsx(j.Controller,{name:"email",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("account.email"),...u})}),e.jsx(j.Controller,{name:"password",control:i,render:({field:u})=>e.jsx(o.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:n("account.password"),description:n("account.password_hint"),...u})}),e.jsx(j.Controller,{name:"role_id",control:i,render:({field:u})=>e.jsx(qe,{styles:t,...u})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function pt({onSuccess:r,styles:t=H,initialRoleID:s}){const{t:n}=y.useTranslation(),[i,l]=P.useState(!1),c=()=>l(!0),u=()=>l(!1),d=()=>{r(),u()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:i,onClose:()=>l(!1),title:n("account.add"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:e.jsx(kn,{postSubmit:d,styles:t,initialRoleID:s})}),e.jsx(o.Button,{size:t.button.size,onClick:c,leftSection:e.jsx(A.IconPlaylistAdd,{size:20}),children:n("account.add")})]})}function mt({id:r,name:t,onSuccess:s,styles:n=H}){const{t:i}=y.useTranslation(),l=ae.useModals(),c=async()=>{if(r){T.showNotification({id:"for-deleting",title:i("common.state.pending"),message:i("account.state.deleting"),loading:!0,autoClose:!1});try{await R.account.delete(r),T.updateNotification({id:"for-deleting",title:i("common.state.successful"),message:i("account.state.deleted",{name:t}),color:"green",autoClose:!0,loading:!1}),s()}catch(d){T.updateNotification({id:"for-deleting",title:i("common.state.failed"),message:d.message,color:"red",autoClose:!0,loading:!1})}}},u=()=>l.openConfirmModal({title:i("account.delete"),labels:{confirm:i("common.actions.confirm"),cancel:i("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:c,cancelProps:{size:n.button.size},confirmProps:{color:"red",size:n.button.size}});return e.jsx(o.Button,{size:n.button.size,color:"red",onClick:u,leftSection:e.jsx(A.IconTrash,{size:20}),children:i("common.actions.delete")})}function Nn({id:r,name:t,email:s,role_id:n,postSubmit:i,styles:l=H}){const{t:c}=y.useTranslation(),{control:u,handleSubmit:d,watch:p}=j.useForm({defaultValues:{name:t,email:s,role_id:n,reset_password:!1,new_password:""}}),h=async({name:C,email:q,role_id:Y,reset_password:X,new_password:k})=>{try{T.showNotification({id:"for-updating",title:c("common.state.pending"),message:c("account.state.updating"),loading:!0,autoClose:!1}),await R.account.edit({id:r,name:C.trim(),email:q.trim(),role_id:Y,reset_password:X,new_password:k.trim()}),T.updateNotification({id:"for-updating",title:c("common.state.successful"),message:c("account.state.updated"),color:"green",autoClose:!0,loading:!1}),i()}catch(D){T.updateNotification({id:"for-updating",title:c("common.state.failed"),message:D.message,color:"red",autoClose:!0,loading:!1})}},[b,v]=p(["reset_password","new_password"]);return e.jsx(o.Box,{mx:"auto",mb:10,children:e.jsxs("form",{onSubmit:d(h),children:[e.jsx(j.Controller,{name:"name",control:u,render:({field:C})=>e.jsx(o.TextInput,{mb:l.spacing,size:l.size,required:!0,label:c("account.username"),...C})}),e.jsx(j.Controller,{name:"email",control:u,render:({field:C})=>e.jsx(o.TextInput,{mb:l.spacing,size:l.size,required:!0,label:c("account.email"),...C})}),e.jsx(j.Controller,{name:"role_id",control:u,render:({field:C})=>e.jsx(qe,{styles:l,...C})}),e.jsx(o.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),e.jsx(j.Controller,{name:"reset_password",control:u,render:({field:C})=>e.jsx(o.Switch,{mb:l.spacing,size:l.size,label:c("account.reset_password"),checked:C.value,onChange:q=>C.onChange(q.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),b&&e.jsx(j.Controller,{name:"new_password",control:u,render:({field:C})=>e.jsx(o.PasswordInput,{autoComplete:"off",mb:l.spacing,size:l.size,required:!0,description:c("account.password_hint"),label:c("account.new_password"),...C})}),e.jsx(o.Group,{justify:"flex-end",mt:l.spacing,children:e.jsx(W,{size:l.button.size})})]})})}function Fn({account:r,onSuccess:t,styles:s=H}){const{t:n}=y.useTranslation(),[i,l]=P.useState(!1),c=()=>l(!0),u=()=>l(!1),d=()=>{t(),u()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:i,onClose:()=>l(!1),title:n("account.editing_xx",{name:r.name}),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:e.jsx(Nn,{...r,postSubmit:d,styles:s})}),e.jsx(o.Button,{size:s.button.size,onClick:c,leftSection:e.jsx(A.IconEdit,{size:20}),children:n("common.actions.edit")})]})}const Bn=be("AccountList",({styles:r=H})=>{var u;const{t}=y.useTranslation(),{data:s=[],loading:n,refresh:i}=K.useRequest(async()=>{const{data:d}=await R.account.list();return d},{refreshDeps:[]}),{data:l=[],loading:c}=K.useRequest(async()=>(await R.role.list()).map(p=>({label:p.id,value:p.id,description:p.description,disabled:p.id==="SUPERADMIN"})),{refreshDeps:[]});return e.jsxs(e.Fragment,{children:[e.jsx(o.Group,{pt:r.spacing,justify:"flex-end",children:e.jsx(pt,{onSuccess:i,initialRoleID:((u=l==null?void 0:l[0])==null?void 0:u.value)??"INACTIVE"})}),e.jsxs(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[e.jsx(o.LoadingOverlay,{visible:n||c}),e.jsxs(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fz:r.size,highlightOnHover:!0,children:[e.jsx(o.Table.Thead,{children:e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Th,{children:t("account.username")}),e.jsx(o.Table.Th,{children:t("account.email")}),e.jsx(o.Table.Th,{children:t("role.label")}),e.jsx(o.Table.Th,{children:t("common.action")})]})}),e.jsx(o.Table.Tbody,{children:s.map(d=>{const{id:p,name:h,email:b,role_id:v}=d;return e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Td,{width:200,children:h}),e.jsx(o.Table.Td,{width:200,children:b}),e.jsx(o.Table.Td,{width:200,children:v}),e.jsx(o.Table.Td,{width:200,children:e.jsxs(o.Group,{justify:"flex-start",children:[e.jsx(Fn,{account:d,onSuccess:i}),e.jsx(mt,{id:p,name:h,onSuccess:i})]})})]},p)})})]})]})]})});function Un({postSubmit:r,styles:t=H}){const{t:s}=y.useTranslation(),{control:n,handleSubmit:i}=j.useForm({defaultValues:{name:"",password:""}}),l=async({name:c,password:u})=>{try{T.showNotification({id:"for-login",title:s("common.state.pending"),message:s("account.state.logging_in"),loading:!0,autoClose:!1});const d=await R.account.login(c.trim(),u.trim());window.localStorage.setItem("token",d.token),T.updateNotification({id:"for-login",title:s("common.state.successful"),message:s("account.state.logged_in"),color:"green",autoClose:!0,loading:!1}),r(d)}catch(d){T.updateNotification({id:"for-login",title:s("common.state.failed"),message:d.message,color:"red",autoClose:!0,loading:!1})}};return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:i(l),children:[e.jsx(j.Controller,{name:"name",control:n,render:({field:c})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:s("account.username"),...c})}),e.jsx(j.Controller,{name:"password",control:n,render:({field:c})=>e.jsx(o.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:s("account.password"),...c})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}const Yn=be("Login",({styles:r=H,onSuccess:t})=>e.jsx(e.Fragment,{children:e.jsx(o.Box,{mt:r.spacing,sx:{position:"relative"},children:e.jsx(Un,{styles:r,postSubmit:t})})})),De={size:"sm",spacing:"md",button:{size:"xs"}};function Vn({postSubmit:r,styles:t=De,initialRoleID:s}){const{t:n}=y.useTranslation(),{control:i,handleSubmit:l}=j.useForm({defaultValues:{name:"",role_id:s}}),c=async({name:u,role_id:d})=>{try{T.showNotification({id:"for-creating",title:n("common.state.pending"),message:n("api_key.state.adding"),loading:!0,autoClose:!1});const{app_id:p,app_secret:h}=await R.api_key.create(u,d);T.updateNotification({id:"for-creating",title:n("common.state.successful"),message:n("api_key.state.added"),color:"green",autoClose:!0,loading:!1}),r(p,h)}catch(p){T.updateNotification({id:"for-creating",title:n("common.state.failed"),message:p.message,color:"red",autoClose:!0,loading:!1})}};return e.jsx(o.Box,{mx:"auto",mb:10,children:e.jsxs("form",{onSubmit:l(c),children:[e.jsx(j.Controller,{name:"name",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("common.name"),...u})}),e.jsx(j.Controller,{name:"role_id",control:i,render:({field:u})=>e.jsx(qe,{styles:t,...u})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function ht({onSuccess:r,styles:t=De,initialRoleID:s}){const{t:n}=y.useTranslation(),i=ae.useModals(),[l,c]=P.useState(!1),u=()=>c(!0),d=()=>c(!1),p=(h,b)=>{d(),i.openModal({title:n("api_key.save.title"),children:e.jsxs(o.Stack,{children:[e.jsx(o.Text,{size:"sm",c:"dimmed",children:n("api_key.save.warn")}),e.jsx(o.TextInput,{defaultValue:h,disabled:!0,label:n("api_key.app_id"),styles:{input:{cursor:"text !important"}}}),e.jsx(o.TextInput,{defaultValue:b,disabled:!0,label:n("api_key.app_secret"),styles:{input:{cursor:"text !important"}}}),e.jsx(o.Button,{size:"sm",onClick:()=>{ae.closeAllModals()},children:n("api_key.save.saved")})]}),onClose:()=>{r()}})};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:l,onClose:()=>c(!1),title:n("api_key.add"),trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:e.jsx(Vn,{postSubmit:p,styles:t,initialRoleID:s})}),e.jsx(o.Button,{size:t.button.size,onClick:u,leftSection:e.jsx(A.IconPlaylistAdd,{size:20}),children:n("api_key.add")})]})}function gt({id:r,name:t,onSuccess:s,styles:n=De}){const{t:i}=y.useTranslation(),l=ae.useModals(),c=async()=>{if(r){T.showNotification({id:"for-deleting",title:i("common.state.pending"),message:i("global_sql_snippet.state.deleting"),loading:!0,autoClose:!1});try{await R.api_key.delete(r),T.updateNotification({id:"for-deleting",title:i("common.state.successful"),message:i("global_sql_snippet.state.deleted",{name:t}),color:"green",autoClose:!0,loading:!1}),s()}catch(d){T.updateNotification({id:"for-deleting",title:i("common.state.failed"),message:d.message,color:"red",autoClose:!0,loading:!1})}}},u=()=>l.openConfirmModal({title:i("api_key.delete"),labels:{confirm:i("common.actions.confirm"),cancel:i("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:c,cancelProps:{size:n.button.size},confirmProps:{color:"red",size:n.button.size}});return e.jsx(o.Button,{size:n.button.size,color:"red",onClick:u,leftSection:e.jsx(A.IconTrash,{size:20}),children:i("common.actions.delete")})}const Gn=be("APIKeyList",({styles:r=De})=>{var u;const{t}=y.useTranslation(),{data:s=[],loading:n,refresh:i}=K.useRequest(async()=>{const{data:d}=await R.api_key.list();return d},{refreshDeps:[]}),{data:l=[],loading:c}=K.useRequest(async()=>(await R.role.list()).map(p=>({label:p.id,value:p.id,description:p.description,disabled:p.id==="SUPERADMIN"})),{refreshDeps:[]});return e.jsxs(e.Fragment,{children:[e.jsx(o.Group,{pt:r.spacing,justify:"flex-end",children:e.jsx(ht,{onSuccess:i,initialRoleID:((u=l==null?void 0:l[0])==null?void 0:u.value)??"INACTIVE"})}),e.jsxs(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[e.jsx(o.LoadingOverlay,{visible:n||c}),e.jsxs(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fz:r.size,highlightOnHover:!0,children:[e.jsx(o.Table.Thead,{children:e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Th,{children:t("common.name")}),e.jsx(o.Table.Th,{children:t("api_key.app_id")}),e.jsx(o.Table.Th,{children:t("role.label")}),e.jsx(o.Table.Th,{children:t("common.action")})]})}),e.jsx(o.Table.Tbody,{children:s.map(d=>{const{id:p,name:h,app_id:b,role_id:v}=d;return e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Td,{width:200,children:h}),e.jsx(o.Table.Td,{width:200,children:b}),e.jsx(o.Table.Td,{width:200,children:v}),e.jsx(o.Table.Td,{width:200,children:e.jsx(o.Group,{justify:"flex-start",children:e.jsx(gt,{id:p,name:h,onSuccess:i})})})]},p)})})]})]})]})}),ue={size:"sm",spacing:"md",button:{size:"xs"}};function Wn({postSubmit:r,styles:t=ue}){const{t:s}=y.useTranslation(),{control:n,handleSubmit:i}=j.useForm({defaultValues:{id:"",content:""}}),l=async c=>{try{T.showNotification({id:"for-creating",title:s("common.state.pending"),message:s("global_sql_snippet.state.adding"),loading:!0,autoClose:!1}),await R.sql_snippet.create(c),T.updateNotification({id:"for-creating",title:s("common.state.successful"),message:s("global_sql_snippet.state.added"),color:"green",autoClose:!0}),r()}catch(u){T.updateNotification({id:"for-creating",title:s("common.state.failed"),message:u.message,color:"red",autoClose:!0})}};return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:i(l),children:[e.jsx(j.Controller,{name:"id",control:n,render:({field:c})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:s("common.name"),placeholder:s("common.name_placeholder"),...c})}),e.jsx(j.Controller,{name:"content",control:n,render:({field:c})=>e.jsxs(o.Stack,{gap:4,children:[e.jsx(o.Text,{size:"14px",fw:500,c:"#212529",sx:{cursor:"default"},children:s("global_sql_snippet.content")}),e.jsx(ut,{height:"600px",...c})]})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function xt({onSuccess:r,styles:t=ue}){const{t:s}=y.useTranslation(),[n,i]=P.useState(!1),l=()=>i(!0),c=()=>i(!1),u=()=>{c(),r()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:n,onClose:()=>i(!1),title:s("global_sql_snippet.add"),trapFocus:!0,onDragStart:d=>{d.stopPropagation()},size:"80vw",children:e.jsx(Wn,{postSubmit:u,styles:t})}),e.jsx(o.Button,{size:t.button.size,onClick:l,leftSection:e.jsx(A.IconPlaylistAdd,{size:18}),children:s("global_sql_snippet.add")})]})}function Kn({postSubmit:r,styles:t=ue,id:s,content:n}){const{t:i}=y.useTranslation(),{control:l,handleSubmit:c}=j.useForm({defaultValues:{id:s,content:n}}),u=async d=>{try{T.showNotification({id:"for-updating",title:i("common.state.pending"),message:i("global_sql_snippet.state.updating"),loading:!0,autoClose:!1}),await R.sql_snippet.update(d),T.updateNotification({id:"for-updating",title:i("common.state.successful"),message:i("global_sql_snippet.state.updated"),color:"green",autoClose:!0}),r()}catch(p){T.updateNotification({id:"for-updating",title:i("common.state.failed"),message:p.message,color:"red",autoClose:!0})}};return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:c(u),children:[e.jsx(j.Controller,{name:"id",control:l,render:({field:d})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:i("common.name"),placeholder:i("common.name_placeholder"),...d})}),e.jsx(j.Controller,{name:"content",control:l,render:({field:d})=>e.jsxs(o.Stack,{gap:4,children:[e.jsx(o.Text,{size:"14px",fw:500,c:"#212529",sx:{cursor:"default"},children:i("global_sql_snippet.content")}),e.jsx(ut,{height:"600px",...d})]})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function bt({onSuccess:r,styles:t=ue,...s}){const{t:n}=y.useTranslation(),[i,l]=P.useState(!1),c=()=>l(!0),u=()=>l(!1),d=()=>{u(),r()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:i,onClose:()=>l(!1),title:n("global_sql_snippet.edit"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},size:"80vw",children:e.jsx(Kn,{postSubmit:d,styles:t,...s})}),e.jsx(o.Button,{size:t.button.size,onClick:c,leftSection:e.jsx(A.IconEdit,{size:18}),children:n("common.actions.edit")})]})}function vt({id:r,onSuccess:t,styles:s=ue}){const{t:n}=y.useTranslation(),i=ae.useModals(),l=async()=>{if(r){T.showNotification({id:"for-deleting",title:n("common.state.pending"),message:n("global_sql_snippet.state.deleting"),loading:!0,autoClose:!1});try{await R.sql_snippet.delete(r),T.updateNotification({id:"for-deleting",title:n("common.state.successful"),message:n("global_sql_snippet.state.deleted",{name:r}),color:"green",autoClose:!0}),t()}catch(u){T.updateNotification({id:"for-deleting",title:n("common.state.failed"),message:u.message,color:"red",autoClose:!0})}}},c=()=>i.openConfirmModal({title:n("global_sql_snippet.delete"),labels:{confirm:n("common.actions.confirm"),cancel:n("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:l,cancelProps:{size:s.button.size},confirmProps:{color:"red",size:s.button.size}});return e.jsx(o.Button,{size:s.button.size,color:"red",onClick:c,leftSection:e.jsx(A.IconTrash,{size:20}),children:n("common.actions.edit")})}function Qn({content:r}){return e.jsxs(o.HoverCard,{width:"60vw",shadow:"md",children:[e.jsx(o.HoverCard.Target,{children:e.jsx(o.ActionIcon,{variant:"subtle",size:16,children:e.jsx(A.IconEye,{})})}),e.jsx(o.HoverCard.Dropdown,{children:e.jsx(Kt.CodeHighlight,{code:r,language:"sql",withCopyButton:!1})})]})}const Jn=be("DataSourceList",({styles:r=ue})=>{const{t}=y.useTranslation(),{data:s=[],loading:n,refresh:i}=K.useRequest(async()=>{const{data:l}=await R.sql_snippet.list({pagination:{page:1,pagesize:10}});return l},{refreshDeps:[]});return e.jsxs(e.Fragment,{children:[e.jsxs(o.Group,{pt:r.spacing,justify:"space-between",children:[e.jsx(o.Alert,{children:t("global_sql_snippet.description")}),e.jsx(xt,{onSuccess:i})]}),e.jsxs(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[e.jsx(o.LoadingOverlay,{visible:n}),e.jsxs(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fz:r.size,highlightOnHover:!0,children:[e.jsx(o.Table.Thead,{children:e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Th,{children:t("common.name")}),e.jsx(o.Table.Th,{}),e.jsx(o.Table.Th,{children:t("common.created_at")}),e.jsx(o.Table.Th,{children:t("common.updated_at")}),e.jsx(o.Table.Th,{children:t("common.action")})]})}),e.jsx(o.Table.Tbody,{children:s.map(l=>{const{id:c,content:u,create_time:d,update_time:p}=l;return e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Td,{children:c}),e.jsx(o.Table.Td,{width:50,children:e.jsx(Qn,{content:u})}),e.jsx(o.Table.Td,{width:200,children:d}),e.jsx(o.Table.Td,{width:200,children:p}),e.jsx(o.Table.Td,{width:400,children:e.jsxs(o.Group,{justify:"flex-start",children:[e.jsx(bt,{...l,onSuccess:i}),e.jsx(vt,{id:c,onSuccess:i})]})})]},c)})})]})]})]})}),Hn=()=>Promise.resolve().then(()=>Xn).then(({version:r})=>(console.log(`[@devtable/settings-form] version: ${r}`),r)),Xn=Object.freeze(Object.defineProperty({__proto__:null,version:"14.12.0"},Symbol.toStringTag,{value:"Module"}));x.APIClient=O,x.APIKeyList=Gn,x.AccountList=Bn,x.AddAPIKey=ht,x.AddAccount=pt,x.AddDataSource=ct,x.AddSQLSnippet=xt,x.DataSourceList=Ln,x.DefaultApiClient=Xe,x.DeleteAPIKey=gt,x.DeleteAccount=mt,x.DeleteDataSource=dt,x.DeleteSQLSnippet=vt,x.FacadeApiClient=Ze,x.Login=Yn,x.SQLSnippetList=Jn,x.UpdateSQLSnippet=bt,x.configureAPIClient=tt,x.facadeApiClient=et,x.getVersion=Hn,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
36
+ `)};function Mn({name:r,config:t,submit:s,styles:n=V}){const{t:i}=y.useTranslation(),{control:l,handleSubmit:c}=j.useForm({defaultValues:{config:t}});return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:c(s),children:[e.jsx(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:i("common.name"),value:r,readOnly:!0}),e.jsx(o.Divider,{label:i("datasource.connection_info"),labelPosition:"center"}),e.jsx(j.Controller,{name:"config.host",control:l,render:({field:u})=>e.jsx(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:i("datasource.http.host"),sx:{flexGrow:1},...u})}),e.jsxs(o.Group,{grow:!0,children:[e.jsx(j.Controller,{name:"config.processing.pre",control:l,render:({field:u})=>e.jsx(we,{label:i("datasource.http.processing.pre.label"),modalTitle:i("datasource.http.processing.pre.description"),defaultValue:ft.pre,...u,styles:n})}),e.jsx(j.Controller,{name:"config.processing.post",control:l,render:({field:u})=>e.jsx(we,{label:i("datasource.http.processing.post.label"),modalTitle:i("datasource.http.processing.post.description"),defaultValue:ft.post,...u,styles:n})})]}),e.jsx(o.Group,{justify:"flex-end",mt:n.spacing,children:e.jsx(W,{size:n.button.size})})]})})}function In({dataSource:r,postSubmit:t,styles:s=V}){const{t:n}=y.useTranslation(),i=async({config:l})=>{T.showNotification({id:"for-updating",title:n("common.state.pending"),message:n("datasource.state.updating"),loading:!0,autoClose:!1});try{console.log({config:l}),await R.datasource.update(r.id,l),T.updateNotification({id:"for-updating",title:n("common.state.successful"),message:n("datasource.state.updated"),color:"green",loading:!1,autoClose:!0}),t()}catch(c){T.updateNotification({id:"for-updating",title:n("common.state.failed"),message:c.message,color:"red",loading:!1,autoClose:!0})}};return r.config?e.jsx(o.Box,{mx:"auto",children:e.jsx(Mn,{name:r.key,config:r.config,submit:i,styles:s})}):(console.error(new Error("unexpected empty config of a http datasource")),null)}function Rn({dataSource:r,onSuccess:t,styles:s=V}){const{t:n}=y.useTranslation(),[i,l]=P.useState(!1),c=()=>l(!0),u=()=>l(!1),d=()=>{t(),u()};return r.is_preset?e.jsx(o.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:n("datasource.cant_edit.preset"),children:e.jsx(o.Button,{size:s.button.size,color:"gray",variant:"light",leftSection:e.jsx(A.IconLock,{size:16}),sx:{transform:"none !important"},children:n("common.actions.edit")})}):r.type!=="http"&&r.type!=="merico_metric_system"?e.jsx(o.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:n("datasource.cant_edit.db"),children:e.jsx(o.Button,{size:s.button.size,color:"gray",variant:"light",leftSection:e.jsx(A.IconEdit,{size:16}),sx:{transform:"none !important"},children:n("common.actions.edit")})}):e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:i,onClose:()=>l(!1),title:n("datasource.edit"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:e.jsx(In,{dataSource:r,postSubmit:d,styles:s})}),e.jsx(o.Button,{size:s.button.size,color:"blue",onClick:c,leftSection:e.jsx(A.IconEdit,{size:16}),children:n("common.actions.edit")})]})}const qn=be("DataSourceList",({styles:r=V})=>{const{t}=y.useTranslation(),{data:s=[],loading:n,refresh:i}=K.useRequest(async()=>{const{data:l}=await R.datasource.list();return l},{refreshDeps:[]});return e.jsxs(e.Fragment,{children:[e.jsx(o.Group,{pt:r.spacing,justify:"flex-end",children:e.jsx(ct,{onSuccess:i})}),e.jsxs(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[e.jsx(o.LoadingOverlay,{visible:n}),e.jsxs(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fz:r.size,highlightOnHover:!0,children:[e.jsx(o.Table.Thead,{children:e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Th,{children:t("common.type")}),e.jsx(o.Table.Th,{children:t("common.name")}),e.jsx(o.Table.Th,{children:t("common.action")})]})}),e.jsx(o.Table.Tbody,{children:s.map(l=>{const{id:c,key:u,type:d,is_preset:p}=l,h=d==="merico_metric_system";return e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Td,{width:230,children:e.jsx($n,{type:d})}),e.jsx(o.Table.Td,{children:u}),e.jsx(o.Table.Td,{width:400,children:e.jsxs(o.Group,{justify:"flex-start",children:[e.jsx(Rn,{dataSource:l,onSuccess:i,styles:r}),e.jsx(dt,{isProtected:p||h,id:c,name:u,onSuccess:i,styles:r})]})})]},u)})})]})]})]})}),Ln=({option:r,...t})=>{const{label:s,value:n,description:i}=r;return e.jsxs(o.Stack,{gap:2,...t,children:[e.jsx(o.Text,{size:"sm",children:s}),e.jsx(o.Text,{size:"xs",c:"dimmed",className:"role-description",children:i})]})},Le=P.forwardRef(({styles:r,value:t,onChange:s},n)=>{const{t:i}=y.useTranslation(),{data:l=[],loading:c}=K.useRequest(async()=>(await R.role.list()).map(d=>({label:d.id,value:d.id,description:d.description,disabled:d.id==="SUPERADMIN"})),{refreshDeps:[]});return e.jsx(o.Select,{ref:n,mb:r.spacing,size:r.size,required:!0,label:i("role.label"),renderOption:Ln,data:l,disabled:c,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:t,onChange:u=>u!==null&&s(u),comboboxProps:{withinPortal:!0},maxDropdownHeight:500})}),H={size:"sm",spacing:"md",button:{size:"xs"}};function kn({postSubmit:r,styles:t=H,initialRoleID:s}){const{t:n}=y.useTranslation(),{control:i,handleSubmit:l}=j.useForm({defaultValues:{name:"",email:"",role_id:s,password:""}}),c=async({name:u,email:d,password:p,role_id:h})=>{try{T.showNotification({id:"for-creating",title:n("common.state.pending"),message:n("account.state.adding"),loading:!0,autoClose:!1}),await R.account.create(u,d,p,h),T.updateNotification({id:"for-creating",title:n("common.state.successful"),message:n("account.state.added"),color:"green",autoClose:!0,loading:!1}),r()}catch(b){T.updateNotification({id:"for-creating",title:n("common.state.failed"),message:b.message,color:"red",autoClose:!0,loading:!1})}};return e.jsx(o.Box,{mx:"auto",mb:10,children:e.jsxs("form",{onSubmit:l(c),children:[e.jsx(j.Controller,{name:"name",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("account.username"),...u})}),e.jsx(j.Controller,{name:"email",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("account.email"),...u})}),e.jsx(j.Controller,{name:"password",control:i,render:({field:u})=>e.jsx(o.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:n("account.password"),description:n("account.password_hint"),...u})}),e.jsx(j.Controller,{name:"role_id",control:i,render:({field:u})=>e.jsx(Le,{styles:t,...u})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function pt({onSuccess:r,styles:t=H,initialRoleID:s}){const{t:n}=y.useTranslation(),[i,l]=P.useState(!1),c=()=>l(!0),u=()=>l(!1),d=()=>{r(),u()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:i,onClose:()=>l(!1),title:n("account.add"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:e.jsx(kn,{postSubmit:d,styles:t,initialRoleID:s})}),e.jsx(o.Button,{size:t.button.size,onClick:c,leftSection:e.jsx(A.IconPlaylistAdd,{size:20}),children:n("account.add")})]})}function mt({id:r,name:t,onSuccess:s,styles:n=H}){const{t:i}=y.useTranslation(),l=ae.useModals(),c=async()=>{if(r){T.showNotification({id:"for-deleting",title:i("common.state.pending"),message:i("account.state.deleting"),loading:!0,autoClose:!1});try{await R.account.delete(r),T.updateNotification({id:"for-deleting",title:i("common.state.successful"),message:i("account.state.deleted",{name:t}),color:"green",autoClose:!0,loading:!1}),s()}catch(d){T.updateNotification({id:"for-deleting",title:i("common.state.failed"),message:d.message,color:"red",autoClose:!0,loading:!1})}}},u=()=>l.openConfirmModal({title:i("account.delete"),labels:{confirm:i("common.actions.confirm"),cancel:i("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:c,cancelProps:{size:n.button.size},confirmProps:{color:"red",size:n.button.size}});return e.jsx(o.Button,{size:n.button.size,color:"red",onClick:u,leftSection:e.jsx(A.IconTrash,{size:20}),children:i("common.actions.delete")})}function Nn({id:r,name:t,email:s,role_id:n,postSubmit:i,styles:l=H}){const{t:c}=y.useTranslation(),{control:u,handleSubmit:d,watch:p}=j.useForm({defaultValues:{name:t,email:s,role_id:n,reset_password:!1,new_password:""}}),h=async({name:C,email:L,role_id:Y,reset_password:X,new_password:k})=>{try{T.showNotification({id:"for-updating",title:c("common.state.pending"),message:c("account.state.updating"),loading:!0,autoClose:!1}),await R.account.edit({id:r,name:C.trim(),email:L.trim(),role_id:Y,reset_password:X,new_password:k.trim()}),T.updateNotification({id:"for-updating",title:c("common.state.successful"),message:c("account.state.updated"),color:"green",autoClose:!0,loading:!1}),i()}catch(D){T.updateNotification({id:"for-updating",title:c("common.state.failed"),message:D.message,color:"red",autoClose:!0,loading:!1})}},[b,v]=p(["reset_password","new_password"]);return e.jsx(o.Box,{mx:"auto",mb:10,children:e.jsxs("form",{onSubmit:d(h),children:[e.jsx(j.Controller,{name:"name",control:u,render:({field:C})=>e.jsx(o.TextInput,{mb:l.spacing,size:l.size,required:!0,label:c("account.username"),...C})}),e.jsx(j.Controller,{name:"email",control:u,render:({field:C})=>e.jsx(o.TextInput,{mb:l.spacing,size:l.size,required:!0,label:c("account.email"),...C})}),e.jsx(j.Controller,{name:"role_id",control:u,render:({field:C})=>e.jsx(Le,{styles:l,...C})}),e.jsx(o.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),e.jsx(j.Controller,{name:"reset_password",control:u,render:({field:C})=>e.jsx(o.Switch,{mb:l.spacing,size:l.size,label:c("account.reset_password"),checked:C.value,onChange:L=>C.onChange(L.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),b&&e.jsx(j.Controller,{name:"new_password",control:u,render:({field:C})=>e.jsx(o.PasswordInput,{autoComplete:"off",mb:l.spacing,size:l.size,required:!0,description:c("account.password_hint"),label:c("account.new_password"),...C})}),e.jsx(o.Group,{justify:"flex-end",mt:l.spacing,children:e.jsx(W,{size:l.button.size})})]})})}function Fn({account:r,onSuccess:t,styles:s=H}){const{t:n}=y.useTranslation(),[i,l]=P.useState(!1),c=()=>l(!0),u=()=>l(!1),d=()=>{t(),u()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:i,onClose:()=>l(!1),title:n("account.editing_xx",{name:r.name}),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:e.jsx(Nn,{...r,postSubmit:d,styles:s})}),e.jsx(o.Button,{size:s.button.size,onClick:c,leftSection:e.jsx(A.IconEdit,{size:20}),children:n("common.actions.edit")})]})}const Bn=be("AccountList",({styles:r=H})=>{var u;const{t}=y.useTranslation(),{data:s=[],loading:n,refresh:i}=K.useRequest(async()=>{const{data:d}=await R.account.list();return d},{refreshDeps:[]}),{data:l=[],loading:c}=K.useRequest(async()=>(await R.role.list()).map(p=>({label:p.id,value:p.id,description:p.description,disabled:p.id==="SUPERADMIN"})),{refreshDeps:[]});return e.jsxs(e.Fragment,{children:[e.jsx(o.Group,{pt:r.spacing,justify:"flex-end",children:e.jsx(pt,{onSuccess:i,initialRoleID:((u=l==null?void 0:l[0])==null?void 0:u.value)??"INACTIVE"})}),e.jsxs(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[e.jsx(o.LoadingOverlay,{visible:n||c}),e.jsxs(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fz:r.size,highlightOnHover:!0,children:[e.jsx(o.Table.Thead,{children:e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Th,{children:t("account.username")}),e.jsx(o.Table.Th,{children:t("account.email")}),e.jsx(o.Table.Th,{children:t("role.label")}),e.jsx(o.Table.Th,{children:t("common.action")})]})}),e.jsx(o.Table.Tbody,{children:s.map(d=>{const{id:p,name:h,email:b,role_id:v}=d;return e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Td,{width:200,children:h}),e.jsx(o.Table.Td,{width:200,children:b}),e.jsx(o.Table.Td,{width:200,children:v}),e.jsx(o.Table.Td,{width:200,children:e.jsxs(o.Group,{justify:"flex-start",children:[e.jsx(Fn,{account:d,onSuccess:i}),e.jsx(mt,{id:p,name:h,onSuccess:i})]})})]},p)})})]})]})]})});function Un({postSubmit:r,styles:t=H}){const{t:s}=y.useTranslation(),{control:n,handleSubmit:i}=j.useForm({defaultValues:{name:"",password:""}}),l=async({name:c,password:u})=>{try{T.showNotification({id:"for-login",title:s("common.state.pending"),message:s("account.state.logging_in"),loading:!0,autoClose:!1});const d=await R.account.login(c.trim(),u.trim());window.localStorage.setItem("token",d.token),T.updateNotification({id:"for-login",title:s("common.state.successful"),message:s("account.state.logged_in"),color:"green",autoClose:!0,loading:!1}),r(d)}catch(d){T.updateNotification({id:"for-login",title:s("common.state.failed"),message:d.message,color:"red",autoClose:!0,loading:!1})}};return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:i(l),children:[e.jsx(j.Controller,{name:"name",control:n,render:({field:c})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:s("account.username"),...c})}),e.jsx(j.Controller,{name:"password",control:n,render:({field:c})=>e.jsx(o.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:s("account.password"),...c})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}const Yn=be("Login",({styles:r=H,onSuccess:t})=>e.jsx(e.Fragment,{children:e.jsx(o.Box,{mt:r.spacing,sx:{position:"relative"},children:e.jsx(Un,{styles:r,postSubmit:t})})})),De={size:"sm",spacing:"md",button:{size:"xs"}};function Vn({postSubmit:r,styles:t=De,initialRoleID:s}){const{t:n}=y.useTranslation(),{control:i,handleSubmit:l}=j.useForm({defaultValues:{name:"",role_id:s}}),c=async({name:u,role_id:d})=>{try{T.showNotification({id:"for-creating",title:n("common.state.pending"),message:n("api_key.state.adding"),loading:!0,autoClose:!1});const{app_id:p,app_secret:h}=await R.api_key.create(u,d);T.updateNotification({id:"for-creating",title:n("common.state.successful"),message:n("api_key.state.added"),color:"green",autoClose:!0,loading:!1}),r(p,h)}catch(p){T.updateNotification({id:"for-creating",title:n("common.state.failed"),message:p.message,color:"red",autoClose:!0,loading:!1})}};return e.jsx(o.Box,{mx:"auto",mb:10,children:e.jsxs("form",{onSubmit:l(c),children:[e.jsx(j.Controller,{name:"name",control:i,render:({field:u})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:n("common.name"),...u})}),e.jsx(j.Controller,{name:"role_id",control:i,render:({field:u})=>e.jsx(Le,{styles:t,...u})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function ht({onSuccess:r,styles:t=De,initialRoleID:s}){const{t:n}=y.useTranslation(),i=ae.useModals(),[l,c]=P.useState(!1),u=()=>c(!0),d=()=>c(!1),p=(h,b)=>{d(),i.openModal({title:n("api_key.save.title"),children:e.jsxs(o.Stack,{children:[e.jsx(o.Text,{size:"sm",c:"dimmed",children:n("api_key.save.warn")}),e.jsx(o.TextInput,{defaultValue:h,disabled:!0,label:n("api_key.app_id"),styles:{input:{cursor:"text !important"}}}),e.jsx(o.TextInput,{defaultValue:b,disabled:!0,label:n("api_key.app_secret"),styles:{input:{cursor:"text !important"}}}),e.jsx(o.Button,{size:"sm",onClick:()=>{ae.closeAllModals()},children:n("api_key.save.saved")})]}),onClose:()=>{r()}})};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:l,onClose:()=>c(!1),title:n("api_key.add"),trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:e.jsx(Vn,{postSubmit:p,styles:t,initialRoleID:s})}),e.jsx(o.Button,{size:t.button.size,onClick:u,leftSection:e.jsx(A.IconPlaylistAdd,{size:20}),children:n("api_key.add")})]})}function gt({id:r,name:t,onSuccess:s,styles:n=De}){const{t:i}=y.useTranslation(),l=ae.useModals(),c=async()=>{if(r){T.showNotification({id:"for-deleting",title:i("common.state.pending"),message:i("global_sql_snippet.state.deleting"),loading:!0,autoClose:!1});try{await R.api_key.delete(r),T.updateNotification({id:"for-deleting",title:i("common.state.successful"),message:i("global_sql_snippet.state.deleted",{name:t}),color:"green",autoClose:!0,loading:!1}),s()}catch(d){T.updateNotification({id:"for-deleting",title:i("common.state.failed"),message:d.message,color:"red",autoClose:!0,loading:!1})}}},u=()=>l.openConfirmModal({title:i("api_key.delete"),labels:{confirm:i("common.actions.confirm"),cancel:i("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:c,cancelProps:{size:n.button.size},confirmProps:{color:"red",size:n.button.size}});return e.jsx(o.Button,{size:n.button.size,color:"red",onClick:u,leftSection:e.jsx(A.IconTrash,{size:20}),children:i("common.actions.delete")})}const Gn=be("APIKeyList",({styles:r=De})=>{var u;const{t}=y.useTranslation(),{data:s=[],loading:n,refresh:i}=K.useRequest(async()=>{const{data:d}=await R.api_key.list();return d},{refreshDeps:[]}),{data:l=[],loading:c}=K.useRequest(async()=>(await R.role.list()).map(p=>({label:p.id,value:p.id,description:p.description,disabled:p.id==="SUPERADMIN"})),{refreshDeps:[]});return e.jsxs(e.Fragment,{children:[e.jsx(o.Group,{pt:r.spacing,justify:"flex-end",children:e.jsx(ht,{onSuccess:i,initialRoleID:((u=l==null?void 0:l[0])==null?void 0:u.value)??"INACTIVE"})}),e.jsxs(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[e.jsx(o.LoadingOverlay,{visible:n||c}),e.jsxs(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fz:r.size,highlightOnHover:!0,children:[e.jsx(o.Table.Thead,{children:e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Th,{children:t("common.name")}),e.jsx(o.Table.Th,{children:t("api_key.app_id")}),e.jsx(o.Table.Th,{children:t("role.label")}),e.jsx(o.Table.Th,{children:t("common.action")})]})}),e.jsx(o.Table.Tbody,{children:s.map(d=>{const{id:p,name:h,app_id:b,role_id:v}=d;return e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Td,{width:200,children:h}),e.jsx(o.Table.Td,{width:200,children:b}),e.jsx(o.Table.Td,{width:200,children:v}),e.jsx(o.Table.Td,{width:200,children:e.jsx(o.Group,{justify:"flex-start",children:e.jsx(gt,{id:p,name:h,onSuccess:i})})})]},p)})})]})]})]})}),ue={size:"sm",spacing:"md",button:{size:"xs"}};function Wn({postSubmit:r,styles:t=ue}){const{t:s}=y.useTranslation(),{control:n,handleSubmit:i}=j.useForm({defaultValues:{id:"",content:""}}),l=async c=>{try{T.showNotification({id:"for-creating",title:s("common.state.pending"),message:s("global_sql_snippet.state.adding"),loading:!0,autoClose:!1}),await R.sql_snippet.create(c),T.updateNotification({id:"for-creating",title:s("common.state.successful"),message:s("global_sql_snippet.state.added"),color:"green",autoClose:!0}),r()}catch(u){T.updateNotification({id:"for-creating",title:s("common.state.failed"),message:u.message,color:"red",autoClose:!0})}};return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:i(l),children:[e.jsx(j.Controller,{name:"id",control:n,render:({field:c})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:s("common.name"),placeholder:s("common.name_placeholder"),...c})}),e.jsx(j.Controller,{name:"content",control:n,render:({field:c})=>e.jsxs(o.Stack,{gap:4,children:[e.jsx(o.Text,{size:"14px",fw:500,c:"#212529",sx:{cursor:"default"},children:s("global_sql_snippet.content")}),e.jsx(ut,{height:"600px",...c})]})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function xt({onSuccess:r,styles:t=ue}){const{t:s}=y.useTranslation(),[n,i]=P.useState(!1),l=()=>i(!0),c=()=>i(!1),u=()=>{c(),r()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:n,onClose:()=>i(!1),title:s("global_sql_snippet.add"),trapFocus:!0,onDragStart:d=>{d.stopPropagation()},size:"80vw",children:e.jsx(Wn,{postSubmit:u,styles:t})}),e.jsx(o.Button,{size:t.button.size,onClick:l,leftSection:e.jsx(A.IconPlaylistAdd,{size:18}),children:s("global_sql_snippet.add")})]})}function Kn({postSubmit:r,styles:t=ue,id:s,content:n}){const{t:i}=y.useTranslation(),{control:l,handleSubmit:c}=j.useForm({defaultValues:{id:s,content:n}}),u=async d=>{try{T.showNotification({id:"for-updating",title:i("common.state.pending"),message:i("global_sql_snippet.state.updating"),loading:!0,autoClose:!1}),await R.sql_snippet.update(d),T.updateNotification({id:"for-updating",title:i("common.state.successful"),message:i("global_sql_snippet.state.updated"),color:"green",autoClose:!0}),r()}catch(p){T.updateNotification({id:"for-updating",title:i("common.state.failed"),message:p.message,color:"red",autoClose:!0})}};return e.jsx(o.Box,{mx:"auto",children:e.jsxs("form",{onSubmit:c(u),children:[e.jsx(j.Controller,{name:"id",control:l,render:({field:d})=>e.jsx(o.TextInput,{mb:t.spacing,size:t.size,required:!0,label:i("common.name"),placeholder:i("common.name_placeholder"),...d})}),e.jsx(j.Controller,{name:"content",control:l,render:({field:d})=>e.jsxs(o.Stack,{gap:4,children:[e.jsx(o.Text,{size:"14px",fw:500,c:"#212529",sx:{cursor:"default"},children:i("global_sql_snippet.content")}),e.jsx(ut,{height:"600px",...d})]})}),e.jsx(o.Group,{justify:"flex-end",mt:t.spacing,children:e.jsx(W,{size:t.button.size})})]})})}function bt({onSuccess:r,styles:t=ue,...s}){const{t:n}=y.useTranslation(),[i,l]=P.useState(!1),c=()=>l(!0),u=()=>l(!1),d=()=>{u(),r()};return e.jsxs(e.Fragment,{children:[e.jsx(o.Modal,{opened:i,onClose:()=>l(!1),title:n("global_sql_snippet.edit"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},size:"80vw",children:e.jsx(Kn,{postSubmit:d,styles:t,...s})}),e.jsx(o.Button,{size:t.button.size,onClick:c,leftSection:e.jsx(A.IconEdit,{size:18}),children:n("common.actions.edit")})]})}function vt({id:r,onSuccess:t,styles:s=ue}){const{t:n}=y.useTranslation(),i=ae.useModals(),l=async()=>{if(r){T.showNotification({id:"for-deleting",title:n("common.state.pending"),message:n("global_sql_snippet.state.deleting"),loading:!0,autoClose:!1});try{await R.sql_snippet.delete(r),T.updateNotification({id:"for-deleting",title:n("common.state.successful"),message:n("global_sql_snippet.state.deleted",{name:r}),color:"green",autoClose:!0}),t()}catch(u){T.updateNotification({id:"for-deleting",title:n("common.state.failed"),message:u.message,color:"red",autoClose:!0})}}},c=()=>i.openConfirmModal({title:n("global_sql_snippet.delete"),labels:{confirm:n("common.actions.confirm"),cancel:n("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:l,cancelProps:{size:s.button.size},confirmProps:{color:"red",size:s.button.size}});return e.jsx(o.Button,{size:s.button.size,color:"red",onClick:c,leftSection:e.jsx(A.IconTrash,{size:20}),children:n("common.actions.edit")})}function Qn({content:r}){return e.jsxs(o.HoverCard,{width:"60vw",shadow:"md",children:[e.jsx(o.HoverCard.Target,{children:e.jsx(o.ActionIcon,{variant:"subtle",size:16,children:e.jsx(A.IconEye,{})})}),e.jsx(o.HoverCard.Dropdown,{children:e.jsx(Kt.CodeHighlight,{code:r,language:"sql",withCopyButton:!1})})]})}const Jn=be("DataSourceList",({styles:r=ue})=>{const{t}=y.useTranslation(),{data:s=[],loading:n,refresh:i}=K.useRequest(async()=>{const{data:l}=await R.sql_snippet.list({pagination:{page:1,pagesize:10}});return l},{refreshDeps:[]});return e.jsxs(e.Fragment,{children:[e.jsxs(o.Group,{pt:r.spacing,justify:"space-between",children:[e.jsx(o.Alert,{children:t("global_sql_snippet.description")}),e.jsx(xt,{onSuccess:i})]}),e.jsxs(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[e.jsx(o.LoadingOverlay,{visible:n}),e.jsxs(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fz:r.size,highlightOnHover:!0,children:[e.jsx(o.Table.Thead,{children:e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Th,{children:t("common.name")}),e.jsx(o.Table.Th,{}),e.jsx(o.Table.Th,{children:t("common.created_at")}),e.jsx(o.Table.Th,{children:t("common.updated_at")}),e.jsx(o.Table.Th,{children:t("common.action")})]})}),e.jsx(o.Table.Tbody,{children:s.map(l=>{const{id:c,content:u,create_time:d,update_time:p}=l;return e.jsxs(o.Table.Tr,{children:[e.jsx(o.Table.Td,{children:c}),e.jsx(o.Table.Td,{width:50,children:e.jsx(Qn,{content:u})}),e.jsx(o.Table.Td,{width:200,children:d}),e.jsx(o.Table.Td,{width:200,children:p}),e.jsx(o.Table.Td,{width:400,children:e.jsxs(o.Group,{justify:"flex-start",children:[e.jsx(bt,{...l,onSuccess:i}),e.jsx(vt,{id:c,onSuccess:i})]})})]},c)})})]})]})]})}),Hn=()=>Promise.resolve().then(()=>Xn).then(({version:r})=>(console.log(`[@devtable/settings-form] version: ${r}`),r)),Xn=Object.freeze(Object.defineProperty({__proto__:null,version:"14.14.0"},Symbol.toStringTag,{value:"Module"}));x.APIClient=O,x.APIKeyList=Gn,x.AccountList=Bn,x.AddAPIKey=ht,x.AddAccount=pt,x.AddDataSource=ct,x.AddSQLSnippet=xt,x.DataSourceList=qn,x.DefaultApiClient=Xe,x.DeleteAPIKey=gt,x.DeleteAccount=mt,x.DeleteDataSource=dt,x.DeleteSQLSnippet=vt,x.FacadeApiClient=Ze,x.Login=Yn,x.SQLSnippetList=Jn,x.UpdateSQLSnippet=bt,x.configureAPIClient=tt,x.facadeApiClient=et,x.getVersion=Hn,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
@@ -23,7 +23,7 @@ export declare const en: {
23
23
  cant_delete_preset: string;
24
24
  };
25
25
  http: {
26
- base_url: string;
26
+ host: string;
27
27
  processing: {
28
28
  pre: {
29
29
  label: string;
@@ -23,7 +23,7 @@ export declare const zh: {
23
23
  cant_delete_preset: string;
24
24
  };
25
25
  http: {
26
- base_url: string;
26
+ host: string;
27
27
  processing: {
28
28
  pre: {
29
29
  label: string;