proje-react-panel 1.0.11 → 1.0.13

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.
@@ -0,0 +1,5 @@
1
+ export declare const AuthApi: {
2
+ login: (fetchSettings: {
3
+ baseUrl: string;
4
+ }, username: string, password: string) => Promise<any>;
5
+ };
@@ -1,7 +1,9 @@
1
+ interface FetchOptions {
2
+ token: string;
3
+ baseUrl: string;
4
+ }
1
5
  export declare const CrudApi: {
2
- getList: (fetchSettings: {
3
- baseUrl: string;
4
- }, api: string) => Promise<any>;
6
+ getList: (options: FetchOptions, api: string) => Promise<any>;
5
7
  create: (fetchSettings: {
6
8
  baseUrl: string;
7
9
  }, api: string, data: any) => Promise<any>;
@@ -12,3 +14,4 @@ export declare const CrudApi: {
12
14
  baseUrl: string;
13
15
  }, api: string, data: any) => Promise<any>;
14
16
  };
17
+ export {};
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  export declare function ErrorComponent({ error }: {
3
- error: unknown;
3
+ error: unknown | Response;
4
4
  }): React.JSX.Element;
@@ -1,4 +1,2 @@
1
1
  import React from "react";
2
- import "../../styles/login.scss";
3
- declare function Login(): React.JSX.Element;
4
- export default Login;
2
+ export declare function Login(): React.JSX.Element;
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("zustand/middleware"),e=require("zustand/traditional"),r=require("zustand/vanilla/shallow"),n=require("react"),o=require("react-router"),a=require("react-hook-form");const i=e.createWithEqualityFn()(t.persist((t=>({screens:null,fetchSettings:null})),{name:"app-store-1",storage:t.createJSONStorage((()=>localStorage)),partialize:t=>({})}),r.shallow);function s(t){i.setState({screens:t})}const c=(t,e)=>fetch(`${t.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}}).then((t=>t.json())),u=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json())),l=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r}`,{method:"GET",headers:{"Content-Type":"application/json"}}).then((t=>t.json())),p=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json()));function f({htmlFor:t,label:e,fieldName:r}){return n.createElement("label",{htmlFor:t},e??r.charAt(0).toUpperCase()+r.slice(1))}function d({input:t,register:e,isEditForm:r,error:o}){const a=t.name||"";return n.createElement("div",{className:"form-field"},n.createElement(f,{htmlFor:a,label:t.label,fieldName:a}),(()=>{switch(t.type){case"textarea":return n.createElement("textarea",{...e(a),placeholder:t.placeholder,id:a,disabled:r&&!1===t.editable});case"select":return n.createElement("select",{...e(a),id:a,disabled:r&&!1===t.editable},n.createElement("option",{value:""},"Select ",a),t.selectOptions?.map((t=>n.createElement("option",{key:t,value:t},t))));default:return n.createElement("input",{type:t.inputType,...e(a),placeholder:t.placeholder,id:a,disabled:r&&!1===t.editable})}})(),o&&n.createElement("span",{className:"error-message"},o.message))}function h({data:t,screen:e}){const{screens:r,fetchSettings:s}=i((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings}))),c=!!t,{register:l,handleSubmit:f,reset:h,formState:{errors:y}}=a.useForm({resolver:r[e.controller].resolver,defaultValues:{...t,__formEdit:c}}),v=o.useNavigate(),m=r[e.controller].inputs;return n.useEffect((()=>{h({...t,__formEdit:c})}),[c,t,h]),n.createElement("div",{className:"form-wrapper"},n.createElement("form",{onSubmit:f((t=>{s&&(delete t.__formEdit,c?p(s,e.controller,t).then((()=>{v("/"+e.controller,{replace:!0})})):u(s,e.controller,t).then((()=>{v("/"+e.controller,{replace:!0})})))}))},m.map((t=>n.createElement(d,{key:t.name||"",input:t,register:l,isEditForm:c,error:y[t.name||""]}))),n.createElement("button",{type:"submit",className:"submit-button"},"Submit")))}function y({screen:t}){return n.createElement(h,{screen:t})}function v({error:t}){return n.createElement("div",{className:"error-container"},n.createElement("div",{className:"error-icon"},n.createElement("i",{className:"fa fa-exclamation-circle"})),n.createElement("div",{className:"error-content"},n.createElement("h3",null,"Error Occurred"),n.createElement("p",null,t?.message||"Something went wrong. Please try again later.")))}function m({screen:t}){const{fetchSettings:e}=i((t=>({fetchSettings:t.fetchSettings}))),{id:r}=o.useParams(),[a,s]=n.useState(null),[c,u]=n.useState(null);return n.useEffect((()=>{e&&t.controller&&r&&l(e,t.controller,r).then((t=>{s(t)})).catch((t=>{u(t),console.error(t)}))}),[e,r,t]),c?n.createElement(v,{error:c}):n.createElement("p",{dangerouslySetInnerHTML:{__html:JSON.stringify(a,null," <br/>")}})}function g({screen:t}){const{fetchSettings:e}=i((t=>({fetchSettings:t.fetchSettings}))),{id:r}=o.useParams(),[a,s]=n.useState(null),[c,u]=n.useState(null);return n.useEffect((()=>{e&&t.controller&&r&&l(e,t.controller,r).then((t=>{s(t)})).catch((t=>{u(t),console.error(t)}))}),[e,r,t]),c?n.createElement(v,{error:c}):n.createElement(h,{data:a,screen:t})}function S({data:t,cells:e}){return t&&0!==t.length?n.createElement("div",{className:"list-wrapper"},n.createElement("div",{className:"header"},"List"),n.createElement("table",{className:"list-table"},n.createElement("thead",null,n.createElement("tr",null,e.map((t=>n.createElement("th",{key:t.name},t.title??t.name))),n.createElement("th",null))),n.createElement("tbody",null,t.map(((t,r)=>n.createElement("tr",{key:r},e.map((e=>{const r=t[e.name];let o=r??"-";if("date"===e.type){if(r){const t=new Date(r);o=`${t.getDate().toString().padStart(2,"0")}/${(t.getMonth()+1).toString().padStart(2,"0")}/${t.getFullYear()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}}else o=r?r.toString():e?.placeHolder??"-";let a=o;return n.createElement("td",{key:e.name},a)})),n.createElement("td",null,n.createElement(o.Link,{to:"edit/"+(t?.id??"-")},"Edit"),n.createElement(o.Link,{to:"details/"+(t?.id??"-")},"Details")))))))):n.createElement("div",null,"No items available")}function _({screen:t}){const{screens:e,fetchSettings:r}=i((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings}))),[a,s]=n.useState(0),[u,l]=n.useState(null),[p,f]=n.useState(null);return n.useEffect((()=>{t.controller&&r&&c(r,t.controller).then((t=>{l(t)})).catch((t=>{f(t),console.error(t)}))}),[a,t.controller,r]),p?n.createElement(v,{error:p}):n.createElement("div",null,n.createElement(o.Link,{to:"create"},"Create"),n.createElement(S,{screen:t,cells:e[t.key].cells,data:u}))}var O,E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},w={};!function(){return O||(O=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof E?E:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=n(t);function n(t,e){return function(r,n){Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0!==e.Reflect&&(r=n(e.Reflect,r)),function(t,e){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,o=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",a=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,u={create:i?function(){return pt(Object.create(null))}:s?function(){return pt({__proto__:null})}:function(){return pt({})},has:c?function(t,e){return r.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return r.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},l=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ct(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:ut(),d="function"==typeof WeakMap?WeakMap:lt(),h=n?Symbol.for("@reflect-metadata:registry"):void 0,y=ot(),v=at(y);function m(t,e,r,n){if(D(r)){if(!H(t))throw new TypeError;if(!J(e))throw new TypeError;return A(t,e)}if(!H(t))throw new TypeError;if(!$(e))throw new TypeError;if(!$(n)&&!D(n)&&!R(n))throw new TypeError;return R(n)&&(n=void 0),x(t,e,r=G(r),n)}function g(t,e){function r(r,n){if(!$(r))throw new TypeError;if(!D(n)&&!q(n))throw new TypeError;k(t,e,r,n)}return r}function S(t,e,r,n){if(!$(r))throw new TypeError;return D(n)||(n=G(n)),k(t,e,r,n)}function _(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),N(t,e,r)}function O(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),C(t,e,r)}function E(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),L(t,e,r)}function w(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),P(t,e,r)}function b(t,e){if(!$(t))throw new TypeError;return D(e)||(e=G(e)),I(t,e)}function T(t,e){if(!$(t))throw new TypeError;return D(e)||(e=G(e)),j(t,e)}function M(t,e,r){if(!$(e))throw new TypeError;if(D(r)||(r=G(r)),!$(e))throw new TypeError;D(r)||(r=G(r));var n=st(e,r,!1);return!D(n)&&n.OrdinaryDeleteMetadata(t,e,r)}function A(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!D(n)&&!R(n)){if(!J(n))throw new TypeError;e=n}}return e}function x(t,e,r,n){for(var o=t.length-1;o>=0;--o){var a=(0,t[o])(e,r,n);if(!D(a)&&!R(a)){if(!$(a))throw new TypeError;n=a}}return n}function N(t,e,r){if(C(t,e,r))return!0;var n=rt(e);return!R(n)&&N(t,n,r)}function C(t,e,r){var n=st(e,r,!1);return!D(n)&&K(n.OrdinaryHasOwnMetadata(t,e,r))}function L(t,e,r){if(C(t,e,r))return P(t,e,r);var n=rt(e);return R(n)?void 0:L(t,n,r)}function P(t,e,r){var n=st(e,r,!1);if(!D(n))return n.OrdinaryGetOwnMetadata(t,e,r)}function k(t,e,r,n){st(r,n,!0).OrdinaryDefineOwnMetadata(t,e,r,n)}function I(t,e){var r=j(t,e),n=rt(t);if(null===n)return r;var o=I(n,e);if(o.length<=0)return r;if(r.length<=0)return o;for(var a=new f,i=[],s=0,c=r;s<c.length;s++){var u=c[s];a.has(u)||(a.add(u),i.push(u))}for(var l=0,p=o;l<p.length;l++){u=p[l];a.has(u)||(a.add(u),i.push(u))}return i}function j(t,e){var r=st(t,e,!1);return r?r.OrdinaryOwnMetadataKeys(t,e):[]}function V(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function D(t){return void 0===t}function R(t){return null===t}function F(t){return"symbol"==typeof t}function $(t){return"object"==typeof t?null!==t:"function"==typeof t}function U(t,e){switch(V(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r="string",n=Q(t,o);if(void 0!==n){var a=n.call(t,r);if($(a))throw new TypeError;return a}return z(t)}function z(t,e){var r,n,o=t.toString;if(W(o)&&!$(n=o.call(t)))return n;if(W(r=t.valueOf)&&!$(n=r.call(t)))return n;throw new TypeError}function K(t){return!!t}function B(t){return""+t}function G(t){var e=U(t);return F(e)?e:B(e)}function H(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function W(t){return"function"==typeof t}function J(t){return"function"==typeof t}function q(t){switch(V(t)){case 3:case 4:return!0;default:return!1}}function Y(t,e){return t===e||t!=t&&e!=e}function Q(t,e){var r=t[e];if(null!=r){if(!W(r))throw new TypeError;return r}}function X(t){var e=Q(t,a);if(!W(e))throw new TypeError;var r=e.call(t);if(!$(r))throw new TypeError;return r}function Z(t){return t.value}function tt(t){var e=t.next();return!e.done&&e}function et(t){var e=t.return;e&&e.call(t)}function rt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===l)return e;if(e!==l)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var o=n.constructor;return"function"!=typeof o||o===t?e:o}function nt(){var t,r,n,o;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var a=new d,i={registerProvider:s,getProvider:u,setProvider:y};return i;function s(e){if(!Object.isExtensible(i))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case D(r):r=e;break;case r===e:break;case D(n):n=e;break;case n===e:break;default:void 0===o&&(o=new f),o.add(e)}}function c(e,a){if(!D(r)){if(r.isProviderFor(e,a))return r;if(!D(n)){if(n.isProviderFor(e,a))return r;if(!D(o))for(var i=X(o);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,a))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,a))return t}function u(t,e){var r,n=a.get(t);return D(n)||(r=n.get(e)),D(r)?(D(r=c(t,e))||(D(n)&&(n=new p,a.set(t,n)),n.set(e,r)),r):r}function l(t){if(D(t))throw new TypeError;return r===t||n===t||!D(o)&&o.has(t)}function y(t,e,r){if(!l(r))throw new Error("Metadata provider not registered.");var n=u(t,e);if(n!==r){if(!D(n))return!1;var o=a.get(t);D(o)&&(o=new p,a.set(t,o)),o.set(e,r)}return!0}}function ot(){var t;return!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=nt()),!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function at(t){var e=new d,r={isProviderFor:function(t,r){var n=e.get(t);return!D(n)&&n.has(r)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:o,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return y.registerProvider(r),r;function n(n,o,a){var i=e.get(n),s=!1;if(D(i)){if(!a)return;i=new p,e.set(n,i),s=!0}var c=i.get(o);if(D(c)){if(!a)return;if(c=new p,i.set(o,c),!t.setProvider(n,o,r))throw i.delete(o),s&&e.delete(n),new Error("Wrong provider for target.")}return c}function o(t,e,r){var o=n(e,r,!1);return!D(o)&&K(o.has(t))}function a(t,e,r){var o=n(e,r,!1);if(!D(o))return o.get(t)}function i(t,e,r,o){n(r,o,!0).set(t,e)}function s(t,e){var r=[],o=n(t,e,!1);if(D(o))return r;for(var a=X(o.keys()),i=0;;){var s=tt(a);if(!s)return r.length=i,r;var c=Z(s);try{r[i]=c}catch(t){try{et(a)}finally{throw t}}i++}}function c(t,r,o){var a=n(r,o,!1);if(D(a))return!1;if(!a.delete(t))return!1;if(0===a.size){var i=e.get(r);D(i)||(i.delete(o),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,r=t.hasOwnMetadata,n=t.getOwnMetadata,o=t.getOwnMetadataKeys,a=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var r=i.get(t);return!(D(r)||!r.has(e))||!!o(t,e).length&&(D(r)&&(r=new f,i.set(t,r)),r.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:o,OrdinaryDeleteMetadata:a}}function st(t,e,r){var n=y.getProvider(t,e);if(!D(n))return n;if(r){if(y.setProvider(t,e,v))return v;throw new Error("Illegal state.")}}function ct(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[a]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}(),n=function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,Y(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,o)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[a]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Y(this._keys[r],t)){this._cacheIndex=r;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return n;function o(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function ut(){return function(){function t(){this._map=new p}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[a]=function(){return this.keys()},t}()}function lt(){var t=16,e=u.create(),n=o();return function(){function t(){this._key=o()}return t.prototype.has=function(t){var e=a(t,!1);return void 0!==e&&u.has(e,this._key)},t.prototype.get=function(t){var e=a(t,!1);return void 0!==e?u.get(e,this._key):void 0},t.prototype.set=function(t,e){return a(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=a(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=o()},t}();function o(){var t;do{t="@@WeakMap@@"+c()}while(u.has(e,t));return e[t]=!0,t}function a(t,e){if(!r.call(t,n)){if(!e)return;Object.defineProperty(t,n,{value:u.create()})}return t[n]}function i(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function s(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):i(e,t),e}return i(new Array(t),t)}function c(){var e=s(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var r="",n=0;n<t;++n){var o=e[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function pt(t){return t.__=void 0,delete t.__,t}t("decorate",m),t("metadata",g),t("defineMetadata",S),t("hasMetadata",_),t("hasOwnMetadata",O),t("getMetadata",E),t("getOwnMetadata",w),t("getMetadataKeys",b),t("getOwnMetadataKeys",T),t("deleteMetadata",M)}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),w;var t}();const b="Crud";const T=Symbol("cell");function M(t){const e=t.prototype;return(Reflect.getMetadata(T,e)||[]).map((t=>{const r=Reflect.getMetadata(`${T.toString()}:${t}:options`,e)||{};return{...r,name:r?.name??t}}))}const A=Symbol("input");function x(t){const e=t.prototype;return(Reflect.getMetadata(A,e)||[]).map((t=>{const r=Reflect.getMetadata(`${A.toString()}:${t}:options`,e)||{},n=r?.inputType??(o=t,["password"].some((t=>o.toLowerCase().includes(t)))?"password":"text");var o;return{...r,editable:r.editable??!0,sensitive:r.sensitive,name:r?.name??t,label:r?.label??t,placeholder:r?.placeholder??t,inputType:n,selectOptions:r?.selectOptions??[],cancelPasswordValidationOnEdit:r?.cancelPasswordValidationOnEdit??"password"===n}}))}function N({menu:t,getIcons:e}){const r=i((t=>t.screens??{})),[a,s]=n.useState(!0);return n.createElement("div",{className:"sidebar "+(a?"open":"closed")},n.createElement("button",{className:"toggle-button",onClick:()=>s(!a)},a?"<":">"),n.createElement("nav",{className:"nav-links"},t?.(r).map(((t,r)=>n.createElement(o.Link,{key:r,to:t.path,className:"nav-link"},n.createElement("span",{className:"nav-links-icon"},e?.(t.iconType)),a?n.createElement("span",null,t.name):null)))))}class C extends n.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(t){return{hasError:!0,error:t,errorInfo:null}}componentDidCatch(t,e){this.setState({error:t,errorInfo:e})}render(){return this.state.hasError?n.createElement("div",{className:"error-boundary"},n.createElement("div",{className:"error-boundary__content"},n.createElement("div",{className:"error-boundary__icon"},n.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},n.createElement("circle",{cx:"12",cy:"12",r:"10"}),n.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),n.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),n.createElement("h1",null,"Oops! Something went wrong"),n.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),n.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&n.createElement("details",{className:"error-boundary__details"},n.createElement("summary",null,"Error Details"),n.createElement("pre",null,this.state.error?.toString()),n.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}var L=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.name=t.name,this.target=t.target,this.propertyName=t.propertyName,this.constraints=null==t?void 0:t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},P=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(r){t.properties[r].forEach((function(n){var o={message:n.message,groups:n.groups,always:n.always,each:n.each},a={type:n.type,name:n.name,target:t.name,propertyName:r,constraints:n.constraints,validationTypeOptions:n.options,validationOptions:o};e.push(new L(a))}))})),e},t}();function k(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function I(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var j=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},V=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},D=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},R=function(){function t(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new P).transform(t).forEach((function(t){return e.addValidationMetadata(t)}))},t.prototype.addValidationMetadata=function(t){var e=this.validationMetadatas.get(t.target);e?e.push(t):this.validationMetadatas.set(t.target,[t])},t.prototype.addConstraintMetadata=function(t){var e=this.constraintMetadatas.get(t.target);e?e.push(t):this.constraintMetadatas.set(t.target,[t])},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach((function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)})),e},t.prototype.getTargetValidationMetadatas=function(t,e,r,n,o){var a,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&r},c=function(t){return!(!n||o&&o.length||!t.groups||!t.groups.length)},u=(this.validationMetadatas.get(t)||[]).filter((function(r){return(r.target===t||r.target===e)&&(!!s(r)||!c(r)&&(!(o&&o.length>0)||r.groups&&!!r.groups.find((function(t){return-1!==o.indexOf(t)}))))})),l=[];try{for(var p=j(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=V(f.value,2),h=d[0],y=d[1];t.prototype instanceof h&&l.push.apply(l,D([],V(y),!1))}}catch(t){a={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}var v=l.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!s(e)||!c(e)&&(!(o&&o.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==o.indexOf(t)}))))))})).filter((function(t){return!u.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return u.concat(v)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();function F(){var t=k();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new R),t.classValidatorMetadataStorage}var $=function(){function t(){}return t.prototype.toString=function(t,e,r,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===r&&(r=""),void 0===n&&(n=!1);var a=t?"":"",i=t?"":"",s=function(t){return" - property ".concat(a).concat(r).concat(t).concat(i," has failed the following constraints: ").concat(a).concat((n?Object.values:Object.keys)(null!==(e=o.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(r?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(r).concat(c),n)})).join(""):""}return"An instance of ".concat(a).concat(this.target?this.target.constructor.name:"an object").concat(i," has failed the validation:\n")+(this.constraints?s(this.property):"")+(this.children?this.children.map((function(e){return e.toString(t,!0,o.property,n)})).join(""):"")},t}(),U=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map((function(t){return e[t]})).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}();var z=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var r;return t instanceof Function?r=t(e):"string"==typeof t&&(r=t),r&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){r=r.replace(new RegExp("\\$constraint".concat(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):("symbol"==typeof t&&(t=t.description),"".concat(t))}(t))})),r&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(r=r.replace(/\$value/g,e.value)),r&&(r=r.replace(/\$property/g,e.property)),r&&(r=r.replace(/\$target/g,e.targetName)),r},t}(),K=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},B=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=F()}return t.prototype.execute=function(t,e,r){var n,o,a=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(n=this.validatorOptions)||void 0===n?void 0:n.enableDebugMessages)||console.warn("No validation metadata found. No validation will be performed. There are multiple possible reasons:\n - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n - This validation runs before any file with validation decorator was parsed by NodeJS.");var i=this.validatorOptions?this.validatorOptions.groups:void 0,s=this.validatorOptions&&this.validatorOptions.strictGroups||!1,c=this.validatorOptions&&this.validatorOptions.always||!1,u=void 0===(null===(o=this.validatorOptions)||void 0===o?void 0:o.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,l=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,c,s,i),p=this.metadataStorage.groupByPropertyName(l);if(this.validatorOptions&&u&&!l.length){var f=new $;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=t),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void r.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,r),Object.keys(p).forEach((function(e){var n=t[e],o=p[e].filter((function(t){return t.type===U.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==U.IS_DEFINED&&t.type!==U.WHITELIST}));n instanceof Promise&&i.find((function(t){return t.type===U.PROMISE_VALIDATION}))?a.awaitingPromises.push(n.then((function(n){a.performValidations(t,n,e,o,i,r)}))):a.performValidations(t,n,e,o,i,r)}))},t.prototype.whitelist=function(t,e,r){var n=this,o=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||o.push(t)})),o.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?o.forEach((function(e){var o,a=n.generateValidationError(t,t[e],e);a.constraints=((o={})[U.WHITELIST]="property ".concat(e," should not exist"),o),a.children=void 0,r.push(a)})):o.forEach((function(e){return delete t[e]})))},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter((function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0}))},t.prototype.performValidations=function(t,e,r,n,o,a){var i=o.filter((function(t){return t.type===U.CUSTOM_VALIDATION})),s=o.filter((function(t){return t.type===U.NESTED_VALIDATION})),c=o.filter((function(t){return t.type===U.CONDITIONAL_VALIDATION})),u=this.generateValidationError(t,e,r);a.push(u),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,n,u),this.mapContexts(t,e,n,u),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,i,u),this.nestedValidations(e,s,u),this.mapContexts(t,e,o,u),this.mapContexts(t,e,i,u)))},t.prototype.generateValidationError=function(t,e,r){var n=new $;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(n.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(n.value=e),n.property=r,n.children=[],n.constraints={},n},t.prototype.conditionalValidations=function(t,e,r){return r.map((function(r){return r.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,r,n){var o=this;r.forEach((function(r){o.metadataStorage.getTargetValidatorConstraints(r.constraintCls).forEach((function(a){if(!(a.async&&o.ignoreAsyncValidations||o.validatorOptions&&o.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:r.propertyName,object:t,value:e,constraints:r.constraints};if(r.each&&(Array.isArray(e)||e instanceof Set||e instanceof Map)){var s,c=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map((function(t){return a.instance.validate(t,i)}));if(c.some((function(t){return I(t)}))){var u=c.map((function(t){return I(t)?t:Promise.resolve(t)})),l=Promise.all(u).then((function(i){if(!i.every((function(t){return t}))){var s=K(o.createValidationError(t,e,r,a),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(l)}else{if(!c.every((function(t){return t}))){var p=K(o.createValidationError(t,e,r,a),2);y=p[0],v=p[1];n.constraints[y]=v}}}else{var f=a.instance.validate(e,i);if(I(f)){var d=f.then((function(i){if(!i){var s=K(o.createValidationError(t,e,r,a),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(d)}else if(!f){var h=K(o.createValidationError(t,e,r,a),2),y=h[0],v=h[1];n.constraints[y]=v}}}}))}))},t.prototype.nestedValidations=function(t,e,r){var n=this;void 0!==t&&e.forEach((function(o){if((o.type===U.NESTED_VALIDATION||o.type===U.PROMISE_VALIDATION)&&!(n.validatorOptions&&n.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(o,a){n.performValidations(t,o,a.toString(),[],e,r.children)}));else if(t instanceof Object){var a="string"==typeof o.target?o.target:o.target.name;n.execute(t,a,r.children)}else{var i=K(n.createValidationError(o.target,t,o),2),s=i[0],c=i[1];r.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,r,n){var o=this;return r.forEach((function(t){if(t.context){var e=void 0;if(t.type===U.CUSTOM_VALIDATION)e=o.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var r=o.getConstraintType(t,e);n.constraints[r]&&(n.contexts||(n.contexts={}),n.contexts[r]=Object.assign(n.contexts[r]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,r,n){var o=t.constructor?t.constructor.name:void 0,a=this.getConstraintType(r,n),i={targetName:o,property:r.propertyName,object:t,value:e,constraints:r.constraints},s=r.message||"";return r.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||n&&n.instance.defaultMessage instanceof Function&&(s=n.instance.defaultMessage(i)),[a,z.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),G=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{c(n.next(t))}catch(t){a(t)}}function s(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,s)}c((n=n.apply(t,e||[])).next())}))},H=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},W=function(){function t(){}return t.prototype.validate=function(t,e,r){return this.coreValidate(t,e,r)},t.prototype.validateOrReject=function(t,e,r){return G(this,void 0,void 0,(function(){var n;return H(this,(function(o){switch(o.label){case 0:return[4,this.coreValidate(t,e,r)];case 1:return(n=o.sent()).length?[2,Promise.reject(n)]:[2]}}))}))},t.prototype.validateSync=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new B(this,"string"==typeof t?r:e);a.ignoreAsyncValidations=!0;var i=[];return a.execute(n,o,i),a.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new B(this,"string"==typeof t?r:e),i=[];return a.execute(n,o,i),Promise.all(a.awaitingPromises).then((function(){return a.stripEmptyErrors(i)}))},t}(),J=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find((function(e){return e.type===t}));return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function q(t){return J.get(t)}function Y(t,e,r){return"string"==typeof t?q(W).validate(t,e,r):q(W).validate(t,e)}function Q(t,e,r){return"string"==typeof t?q(W).validateSync(t,e,r):q(W).validateSync(t,e)}const X=(t,e,r)=>{if(t&&"reportValidity"in t){const n=a.get(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},Z=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?X(n.ref,r,t):n&&n.refs&&n.refs.forEach((e=>X(e,r,t)))}},tt=(t,e)=>{e.shouldUseNativeValidation&&Z(t,e);const r={};for(const n in t){const o=a.get(e.fields,n),i=Object.assign(t[n]||{},{ref:o&&o.ref});if(et(e.names||Object.keys(t),n)){const t=Object.assign({},a.get(r,n));a.set(t,"root",i),a.set(r,n,t)}else a.set(r,n,i)}return r},et=(t,e)=>{const r=rt(e);return t.some((t=>rt(t).match(`^${r}\\.\\d+`)))};function rt(t){return t.replace(/\]|\[/g,"")}var nt;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(nt||(nt={}));var ot=new(function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,r){return this.findMetadatas(this._transformMetadatas,t,e).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?r===nt.CLASS_TO_CLASS||r===nt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===nt.CLASS_TO_PLAIN))}))},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find((function(t){return t.options&&t.options.name===e}))},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),n=this._exposeMetadatas.get(t),o=n&&n.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===nt.CLASS_TO_CLASS||e===nt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===nt.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===nt.CLASS_TO_CLASS||e===nt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===nt.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,n=t.get(e);n&&(r=Array.from(n.values()).filter((function(t){return void 0!==t.propertyName})));for(var o=[],a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var u=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));o.push.apply(o,u)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var n=t.get(e);if(n){var o=n.get(r);if(o)return o}for(var a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var u=c.get(r);if(u)return u}}},t.prototype.findMetadatas=function(t,e,r){var n,o=t.get(e);o&&(n=o.get(r));for(var a=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],u=t.get(c);u&&u.has(r)&&a.push.apply(a,u.get(r))}return a.slice().reverse().concat((n||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}());var at=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var it=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,r,n,o,a){var i,s=this;if(void 0===a&&(a=0),Array.isArray(e)||e instanceof Set){var c=n&&this.transformationType===nt.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(n):[];return e.forEach((function(e,n){var o=t?t[n]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===nt.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(s.transformationType===nt.PLAIN_TO_CLASS){i=r.options.discriminator.subTypes.find((function(t){return t.name===e[r.options.discriminator.property]}));var u={newObject:c,object:e,property:void 0},l=r.typeFunction(u);i=void 0===i?l:i.value,r.options.keepDiscriminatorProperty||delete e[r.options.discriminator.property]}s.transformationType===nt.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===nt.CLASS_TO_PLAIN&&(e[r.options.discriminator.property]=r.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=r;var p=s.transform(o,e,i,void 0,e instanceof Map,a+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(r!==String||o){if(r!==Number||o){if(r!==Boolean||o){if((r===Date||e instanceof Date)&&!o)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||e instanceof Buffer)&&!o)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||o){if(o||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){r||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(r=e.constructor),!r&&t&&(r=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var u=this.getKeys(r,e,o),l=t||{};t||this.transformationType!==nt.PLAIN_TO_CLASS&&this.transformationType!==nt.CLASS_TO_CLASS||(l=o?new Map:r?new r:{});for(var p=function(n){if("__proto__"===n||"constructor"===n)return"continue";var i=n,s=n,c=n;if(!f.options.ignoreDecorators&&r)if(f.transformationType===nt.PLAIN_TO_CLASS)(u=ot.findExposeMetadataByCustomName(r,n))&&(c=u.propertyName,s=u.propertyName);else if(f.transformationType===nt.CLASS_TO_PLAIN||f.transformationType===nt.CLASS_TO_CLASS){var u;(u=ot.findExposeMetadata(r,n))&&u.options&&u.options.name&&(s=u.options.name)}var p=void 0;p=f.transformationType===nt.PLAIN_TO_CLASS?e[i]:e instanceof Map?e.get(i):e[i]instanceof Function?e[i]():e[i];var d=void 0,h=p instanceof Map;if(r&&o)d=r;else if(r){var y=ot.findTypeMetadata(r,c);if(y){var v={newObject:l,object:e,property:c},m=y.typeFunction?y.typeFunction(v):y.reflectedType;y.options&&y.options.discriminator&&y.options.discriminator.property&&y.options.discriminator.subTypes?e[i]instanceof Array?d=y:(f.transformationType===nt.PLAIN_TO_CLASS&&(d=void 0===(d=y.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&y.options.discriminator.property in p)return t.name===p[y.options.discriminator.property]})))?m:d.value,y.options.keepDiscriminatorProperty||p&&p instanceof Object&&y.options.discriminator.property in p&&delete p[y.options.discriminator.property]),f.transformationType===nt.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===nt.CLASS_TO_PLAIN&&p&&(p[y.options.discriminator.property]=y.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=m,h=h||y.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===r&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===nt.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",r.prototype,c);g&&(d=g)}}var S=Array.isArray(e[i])?f.getReflectedType(r,c):void 0,_=t?t[i]:void 0;if(l.constructor.prototype){var O=Object.getOwnPropertyDescriptor(l.constructor.prototype,s);if((f.transformationType===nt.PLAIN_TO_CLASS||f.transformationType===nt.CLASS_TO_CLASS)&&(O&&!O.set||l[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===nt.CLASS_TO_CLASS){w=p;(void 0!==(w=f.applyCustomTransformations(w,r,n,e,f.transformationType))||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}}else{var E=f.transformationType===nt.PLAIN_TO_CLASS?s:n,w=void 0;f.transformationType===nt.CLASS_TO_PLAIN?(w=e[E],w=f.applyCustomTransformations(w,r,E,e,f.transformationType),w=e[E]===w?p:w,w=f.transform(_,w,d,S,h,a+1)):void 0===p&&f.options.exposeDefaultValues?w=l[s]:(w=f.transform(_,p,d,S,h,a+1),w=f.applyCustomTransformations(w,r,E,e,f.transformationType)),(void 0!==w||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}},f=this,d=0,h=u;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}return e}return e}return new Promise((function(t,n){e.then((function(e){return t(s.transform(void 0,e,r,void 0,void 0,a+1))}),n)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,r,n,o){var a=this,i=ot.findTransformMetadatas(e,r,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||a.checkGroups(t.options.groups)})):i.filter((function(t){return!t.options||!t.options.groups||!t.options.groups.length}))).forEach((function(e){t=e.transformFn({value:t,key:r,obj:n,type:o,options:a.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=ot.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var n=this,o=ot.getStrategy(t);"none"===o&&(o=this.options.strategy||"exposeAll");var a=[];if(("exposeAll"===o||r)&&(a=e instanceof Map?Array.from(e.keys()):Object.keys(e)),r)return a;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=ot.getExposedProperties(t,this.transformationType),s=ot.getExcludedProperties(t,this.transformationType);a=at(at([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=ot.getExposedProperties(t,this.transformationType);this.transformationType===nt.PLAIN_TO_CLASS&&(i=i.map((function(e){var r=ot.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e}))),a=this.options.excludeExtraneousValues?i:a.concat(i);var c=ot.getExcludedProperties(t,this.transformationType);c.length>0&&(a=a.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(a=a.filter((function(e){var r=ot.findExposeMetadata(t,e);return!r||!r.options||n.checkVersion(r.options.since,r.options.until)}))),a=this.options.groups&&this.options.groups.length?a.filter((function(e){var r=ot.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)})):a.filter((function(e){var r=ot.findExposeMetadata(t,e);return!(r&&r.options&&r.options.groups&&r.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(a=a.filter((function(t){return n.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),a=a.filter((function(t,e,r){return r.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),st={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},ct=function(){return ct=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ct.apply(this,arguments)},ut=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new it(nt.CLASS_TO_PLAIN,ct(ct({},st),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new it(nt.CLASS_TO_PLAIN,ct(ct({},st),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,r){return new it(nt.PLAIN_TO_CLASS,ct(ct({},st),r)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new it(nt.PLAIN_TO_CLASS,ct(ct({},st),r)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new it(nt.CLASS_TO_CLASS,ct(ct({},st),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new it(nt.CLASS_TO_CLASS,ct(ct({},st),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.instanceToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t.prototype.deserializeArray=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t}());function lt(t,e,r,n){return void 0===r&&(r={}),void 0===n&&(n=""),t.reduce((function(t,r){var o=n?n+"."+r.property:r.property;if(r.constraints){var a=Object.keys(r.constraints)[0];t[o]={type:a,message:r.constraints[a]};var i=t[o];e&&i&&Object.assign(i,{types:r.constraints})}return r.children&&r.children.length&&lt(r.children,e,t,o),t}),r)}function pt(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),function(n,o,a){try{var i=e.validator,s=(c=t,u=n,l=e.transformer,ut.plainToInstance(c,u,l));return Promise.resolve(("sync"===r.mode?Q:Y)(s,i)).then((function(t){return t.length?{values:{},errors:tt(lt(t,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&Z({},a),{values:r.raw?Object.assign({},n):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,u,l}}function ft(t,e){const r=F().getTargetValidationMetadatas(e,"",!1,!1),n=function(t){return Reflect.getMetadata(b,t)}(e);return{resolver:pt(e),fields:Array.from(new Set(r.map((t=>t.propertyName)))),inputs:x(e),cells:M(e),crud:n,path:"/"+(n?.controller??t)}}exports.Cell=function(t){return(e,r)=>{const n=Reflect.getMetadata(T,e)||[];if(Reflect.defineMetadata(T,[...n,r.toString()],e),t){const n=`${T.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}},exports.Crud=function(t){return e=>{t&&Reflect.defineMetadata(b,t,e)}},exports.Input=function(t){return(e,r)=>{const n=Reflect.getMetadata(A,e)||[];if(Reflect.defineMetadata(A,[...n,r.toString()],e),t){const n=`${A.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}},exports.Layout=function({children:t,menu:e,getIcons:r}){return n.createElement("div",{className:"layout"},n.createElement(N,{menu:e,getIcons:r}),n.createElement("main",{className:"content"},t))},exports.Panel=function({children:t,init:e}){return n.useEffect((()=>{!function({crud:t,fetch:e}){const r={};Object.entries(t).forEach((([t,e])=>{r[t]=ft(t,e)})),s(r),i.setState({fetchSettings:{baseUrl:e.baseURL}})}(e())}),[e]),n.createElement(C,null,t)},exports.createScreens=s,exports.useScreens=function(){const t=i((t=>t.screens??{}));return n.useMemo((()=>n.createElement(n.Fragment,null,Object.entries(t).map((([t,e])=>{const r=e.crud?.controller??t;let a=`${e.path}`;const i={key:t,controller:r};return n.createElement(n.Fragment,{key:"index"},n.createElement(o.Route,{path:a+"/create",element:n.createElement(y,{screen:i})}),n.createElement(o.Route,{path:a+"/details/:id",element:n.createElement(m,{screen:i})}),n.createElement(o.Route,{path:a+"/edit/:id",element:n.createElement(g,{screen:i})}),n.createElement(o.Route,{path:a,element:n.createElement(_,{screen:i})}))})),n.createElement(o.Route,{path:"*",element:n.createElement("div",null,"404 - Not Found")}))),[t])};
1
+ "use strict";var t=require("react"),e=require("react-hook-form"),r=require("zustand/middleware"),n=require("zustand/traditional"),o=require("zustand/vanilla/shallow"),a=require("react-router");function i({htmlFor:e,label:r,fieldName:n}){return t.createElement("label",{htmlFor:e},r??n.charAt(0).toUpperCase()+n.slice(1))}function s({input:e,register:r,isEditForm:n,error:o}){const a=e.name||"";return t.createElement("div",{className:"form-field"},t.createElement(i,{htmlFor:a,label:e.label,fieldName:a}),(()=>{switch(e.type){case"textarea":return t.createElement("textarea",{...r(a),placeholder:e.placeholder,id:a,disabled:n&&!1===e.editable});case"select":return t.createElement("select",{...r(a),id:a,disabled:n&&!1===e.editable},t.createElement("option",{value:""},"Select ",a),e.selectOptions?.map((e=>t.createElement("option",{key:e,value:e},e))));default:return t.createElement("input",{type:e.inputType,...r(a),placeholder:e.placeholder,id:a,disabled:n&&!1===e.editable})}})(),o&&t.createElement("span",{className:"error-message"},o.message))}const c=(t,e,r)=>fetch(`${t.baseUrl}/auth/login`,{method:"POST",body:JSON.stringify({username:e,password:r}),headers:{"Content-Type":"application/json"}}).then((t=>{if(t.ok)return t.json();throw t})),u=n.createWithEqualityFn()(r.persist((t=>({screens:null,user:null,fetchSettings:null,screenPaths:{},token:null})),{name:"app-store-1",storage:r.createJSONStorage((()=>localStorage)),partialize:t=>({user:t.user,token:t.token})}),o.shallow);function l(t){u.setState({screens:t})}const p=(t,e)=>fetch(`${t.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.token}`}}).then((t=>{if(t.ok)return t.json();throw t})),f=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json())),d=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r}`,{method:"GET",headers:{"Content-Type":"application/json"}}).then((t=>t.json())),h=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json()));function y({data:r,screen:n}){const{screens:o,fetchSettings:i}=u((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings}))),c=!!r,{register:l,handleSubmit:p,reset:d,formState:{errors:y}}=e.useForm({resolver:o[n.controller].resolver,defaultValues:{...r,__formEdit:c}}),v=a.useNavigate(),m=o[n.controller].inputs;return t.useEffect((()=>{d({...r,__formEdit:c})}),[c,r,d]),t.createElement("div",{className:"form-wrapper"},t.createElement("form",{onSubmit:p((t=>{i&&(delete t.__formEdit,c?h(i,n.controller,t).then((()=>{v("/"+n.controller,{replace:!0})})):f(i,n.controller,t).then((()=>{v("/"+n.controller,{replace:!0})})))}))},m.map((e=>t.createElement(s,{key:e.name||"",input:e,register:l,isEditForm:c,error:y[e.name||""]}))),t.createElement("button",{type:"submit",className:"submit-button"},"Submit")))}function v({screen:e}){return t.createElement(y,{screen:e})}function m({error:e}){return t.createElement("div",{className:"error-container"},t.createElement("div",{className:"error-icon"},t.createElement("i",{className:"fa fa-exclamation-circle"})),t.createElement("div",{className:"error-content"},t.createElement("h3",null,"Error Occurred"),t.createElement("p",null,(t=>{if(t instanceof Response)switch(t.status){case 400:return"Bad Request: The request was invalid or malformed.";case 401:return"Unauthorized: Please log in to access this resource.";case 404:return"Not Found: The requested resource could not be found.";case 403:return"Forbidden: You don't have permission to access this resource.";case 500:return"Internal Server Error: Something went wrong on our end.";default:return`Error ${t.status}: ${t.statusText||"Something went wrong."}`}return t?.message||"Something went wrong. Please try again later."})(e))))}function g({screen:e}){const{fetchSettings:r}=u((t=>({fetchSettings:t.fetchSettings}))),{id:n}=a.useParams(),[o,i]=t.useState(null),[s,c]=t.useState(null);return t.useEffect((()=>{r&&e.controller&&n&&d(r,e.controller,n).then((t=>{i(t)})).catch((t=>{c(t),console.error(t)}))}),[r,n,e]),s?t.createElement(m,{error:s}):t.createElement("p",{dangerouslySetInnerHTML:{__html:JSON.stringify(o,null," <br/>")}})}function S({screen:e}){const{fetchSettings:r}=u((t=>({fetchSettings:t.fetchSettings}))),{id:n}=a.useParams(),[o,i]=t.useState(null),[s,c]=t.useState(null);return t.useEffect((()=>{r&&e.controller&&n&&d(r,e.controller,n).then((t=>{i(t)})).catch((t=>{c(t),console.error(t)}))}),[r,n,e]),s?t.createElement(m,{error:s}):t.createElement(y,{data:o,screen:e})}function _({data:e,cells:r}){return e&&0!==e.length?t.createElement("div",{className:"list-wrapper"},t.createElement("div",{className:"header"},"List"),t.createElement("table",{className:"list-table"},t.createElement("thead",null,t.createElement("tr",null,r.map((e=>t.createElement("th",{key:e.name},e.title??e.name))),t.createElement("th",null))),t.createElement("tbody",null,e.map(((e,n)=>t.createElement("tr",{key:n},r.map((r=>{const n=e[r.name];let o=n??"-";if("date"===r.type){if(n){const t=new Date(n);o=`${t.getDate().toString().padStart(2,"0")}/${(t.getMonth()+1).toString().padStart(2,"0")}/${t.getFullYear()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}}else o=n?n.toString():r?.placeHolder??"-";let a=o;return t.createElement("td",{key:r.name},a)})),t.createElement("td",null,t.createElement(a.Link,{to:"edit/"+(e?.id??"-")},"Edit"),t.createElement(a.Link,{to:"details/"+(e?.id??"-")},"Details")))))))):t.createElement("div",null,"No items available")}function E({screen:e}){const{screens:r,fetchSettings:n,token:o}=u((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings,token:t.token}))),[i,s]=t.useState(0),[c,l]=t.useState(null),[f,d]=t.useState(null);return t.useEffect((()=>{e.controller&&n&&o&&p({...n,token:o},e.controller).then((t=>{l(t)})).catch((t=>{d(t),console.error(t)}))}),[i,e.controller,n]),f?t.createElement(m,{error:f}):t.createElement("div",null,t.createElement(a.Link,{to:"create"},"Create"),t.createElement(_,{screen:e,cells:r[e.key].cells,data:c}))}var O,w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},b={};!function(){return O||(O=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof w?w:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=n(t);function n(t,e){return function(r,n){Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0!==e.Reflect&&(r=n(e.Reflect,r)),function(t,e){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,o=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",a=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,u={create:i?function(){return pt(Object.create(null))}:s?function(){return pt({__proto__:null})}:function(){return pt({})},has:c?function(t,e){return r.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return r.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},l=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ct(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:ut(),d="function"==typeof WeakMap?WeakMap:lt(),h=n?Symbol.for("@reflect-metadata:registry"):void 0,y=ot(),v=at(y);function m(t,e,r,n){if(D(r)){if(!G(t))throw new TypeError;if(!H(e))throw new TypeError;return A(t,e)}if(!G(t))throw new TypeError;if(!$(e))throw new TypeError;if(!$(n)&&!D(n)&&!F(n))throw new TypeError;return F(n)&&(n=void 0),x(t,e,r=q(r),n)}function g(t,e){function r(r,n){if(!$(r))throw new TypeError;if(!D(n)&&!J(n))throw new TypeError;L(t,e,r,n)}return r}function S(t,e,r,n){if(!$(r))throw new TypeError;return D(n)||(n=q(n)),L(t,e,r,n)}function _(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=q(r)),N(t,e,r)}function E(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=q(r)),C(t,e,r)}function O(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=q(r)),k(t,e,r)}function w(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=q(r)),P(t,e,r)}function b(t,e){if(!$(t))throw new TypeError;return D(e)||(e=q(e)),I(t,e)}function T(t,e){if(!$(t))throw new TypeError;return D(e)||(e=q(e)),j(t,e)}function M(t,e,r){if(!$(e))throw new TypeError;if(D(r)||(r=q(r)),!$(e))throw new TypeError;D(r)||(r=q(r));var n=st(e,r,!1);return!D(n)&&n.OrdinaryDeleteMetadata(t,e,r)}function A(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!D(n)&&!F(n)){if(!H(n))throw new TypeError;e=n}}return e}function x(t,e,r,n){for(var o=t.length-1;o>=0;--o){var a=(0,t[o])(e,r,n);if(!D(a)&&!F(a)){if(!$(a))throw new TypeError;n=a}}return n}function N(t,e,r){if(C(t,e,r))return!0;var n=rt(e);return!F(n)&&N(t,n,r)}function C(t,e,r){var n=st(e,r,!1);return!D(n)&&B(n.OrdinaryHasOwnMetadata(t,e,r))}function k(t,e,r){if(C(t,e,r))return P(t,e,r);var n=rt(e);return F(n)?void 0:k(t,n,r)}function P(t,e,r){var n=st(e,r,!1);if(!D(n))return n.OrdinaryGetOwnMetadata(t,e,r)}function L(t,e,r,n){st(r,n,!0).OrdinaryDefineOwnMetadata(t,e,r,n)}function I(t,e){var r=j(t,e),n=rt(t);if(null===n)return r;var o=I(n,e);if(o.length<=0)return r;if(r.length<=0)return o;for(var a=new f,i=[],s=0,c=r;s<c.length;s++){var u=c[s];a.has(u)||(a.add(u),i.push(u))}for(var l=0,p=o;l<p.length;l++){u=p[l];a.has(u)||(a.add(u),i.push(u))}return i}function j(t,e){var r=st(t,e,!1);return r?r.OrdinaryOwnMetadataKeys(t,e):[]}function V(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function D(t){return void 0===t}function F(t){return null===t}function R(t){return"symbol"==typeof t}function $(t){return"object"==typeof t?null!==t:"function"==typeof t}function U(t,e){switch(V(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r="string",n=Q(t,o);if(void 0!==n){var a=n.call(t,r);if($(a))throw new TypeError;return a}return z(t)}function z(t,e){var r,n,o=t.toString;if(W(o)&&!$(n=o.call(t)))return n;if(W(r=t.valueOf)&&!$(n=r.call(t)))return n;throw new TypeError}function B(t){return!!t}function K(t){return""+t}function q(t){var e=U(t);return R(e)?e:K(e)}function G(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function W(t){return"function"==typeof t}function H(t){return"function"==typeof t}function J(t){switch(V(t)){case 3:case 4:return!0;default:return!1}}function Y(t,e){return t===e||t!=t&&e!=e}function Q(t,e){var r=t[e];if(null!=r){if(!W(r))throw new TypeError;return r}}function X(t){var e=Q(t,a);if(!W(e))throw new TypeError;var r=e.call(t);if(!$(r))throw new TypeError;return r}function Z(t){return t.value}function tt(t){var e=t.next();return!e.done&&e}function et(t){var e=t.return;e&&e.call(t)}function rt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===l)return e;if(e!==l)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var o=n.constructor;return"function"!=typeof o||o===t?e:o}function nt(){var t,r,n,o;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var a=new d,i={registerProvider:s,getProvider:u,setProvider:y};return i;function s(e){if(!Object.isExtensible(i))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case D(r):r=e;break;case r===e:break;case D(n):n=e;break;case n===e:break;default:void 0===o&&(o=new f),o.add(e)}}function c(e,a){if(!D(r)){if(r.isProviderFor(e,a))return r;if(!D(n)){if(n.isProviderFor(e,a))return r;if(!D(o))for(var i=X(o);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,a))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,a))return t}function u(t,e){var r,n=a.get(t);return D(n)||(r=n.get(e)),D(r)?(D(r=c(t,e))||(D(n)&&(n=new p,a.set(t,n)),n.set(e,r)),r):r}function l(t){if(D(t))throw new TypeError;return r===t||n===t||!D(o)&&o.has(t)}function y(t,e,r){if(!l(r))throw new Error("Metadata provider not registered.");var n=u(t,e);if(n!==r){if(!D(n))return!1;var o=a.get(t);D(o)&&(o=new p,a.set(t,o)),o.set(e,r)}return!0}}function ot(){var t;return!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=nt()),!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function at(t){var e=new d,r={isProviderFor:function(t,r){var n=e.get(t);return!D(n)&&n.has(r)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:o,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return y.registerProvider(r),r;function n(n,o,a){var i=e.get(n),s=!1;if(D(i)){if(!a)return;i=new p,e.set(n,i),s=!0}var c=i.get(o);if(D(c)){if(!a)return;if(c=new p,i.set(o,c),!t.setProvider(n,o,r))throw i.delete(o),s&&e.delete(n),new Error("Wrong provider for target.")}return c}function o(t,e,r){var o=n(e,r,!1);return!D(o)&&B(o.has(t))}function a(t,e,r){var o=n(e,r,!1);if(!D(o))return o.get(t)}function i(t,e,r,o){n(r,o,!0).set(t,e)}function s(t,e){var r=[],o=n(t,e,!1);if(D(o))return r;for(var a=X(o.keys()),i=0;;){var s=tt(a);if(!s)return r.length=i,r;var c=Z(s);try{r[i]=c}catch(t){try{et(a)}finally{throw t}}i++}}function c(t,r,o){var a=n(r,o,!1);if(D(a))return!1;if(!a.delete(t))return!1;if(0===a.size){var i=e.get(r);D(i)||(i.delete(o),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,r=t.hasOwnMetadata,n=t.getOwnMetadata,o=t.getOwnMetadataKeys,a=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var r=i.get(t);return!(D(r)||!r.has(e))||!!o(t,e).length&&(D(r)&&(r=new f,i.set(t,r)),r.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:o,OrdinaryDeleteMetadata:a}}function st(t,e,r){var n=y.getProvider(t,e);if(!D(n))return n;if(r){if(y.setProvider(t,e,v))return v;throw new Error("Illegal state.")}}function ct(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[a]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}(),n=function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,Y(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,o)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[a]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Y(this._keys[r],t)){this._cacheIndex=r;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return n;function o(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function ut(){return function(){function t(){this._map=new p}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[a]=function(){return this.keys()},t}()}function lt(){var t=16,e=u.create(),n=o();return function(){function t(){this._key=o()}return t.prototype.has=function(t){var e=a(t,!1);return void 0!==e&&u.has(e,this._key)},t.prototype.get=function(t){var e=a(t,!1);return void 0!==e?u.get(e,this._key):void 0},t.prototype.set=function(t,e){return a(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=a(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=o()},t}();function o(){var t;do{t="@@WeakMap@@"+c()}while(u.has(e,t));return e[t]=!0,t}function a(t,e){if(!r.call(t,n)){if(!e)return;Object.defineProperty(t,n,{value:u.create()})}return t[n]}function i(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function s(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):i(e,t),e}return i(new Array(t),t)}function c(){var e=s(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var r="",n=0;n<t;++n){var o=e[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function pt(t){return t.__=void 0,delete t.__,t}t("decorate",m),t("metadata",g),t("defineMetadata",S),t("hasMetadata",_),t("hasOwnMetadata",E),t("getMetadata",O),t("getOwnMetadata",w),t("getMetadataKeys",b),t("getOwnMetadataKeys",T),t("deleteMetadata",M)}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),b;var t}();const T="Crud";const M=Symbol("cell");function A(t){const e=t.prototype;return(Reflect.getMetadata(M,e)||[]).map((t=>{const r=Reflect.getMetadata(`${M.toString()}:${t}:options`,e)||{};return{...r,name:r?.name??t}}))}const x=Symbol("input");function N(t){const e=t.prototype;return(Reflect.getMetadata(x,e)||[]).map((t=>{const r=Reflect.getMetadata(`${x.toString()}:${t}:options`,e)||{},n=r?.inputType??(o=t,["password"].some((t=>o.toLowerCase().includes(t)))?"password":"text");var o;return{...r,editable:r.editable??!0,sensitive:r.sensitive,name:r?.name??t,label:r?.label??t,placeholder:r?.placeholder??t,inputType:n,selectOptions:r?.selectOptions??[],cancelPasswordValidationOnEdit:r?.cancelPasswordValidationOnEdit??"password"===n}}))}function C({menu:e,getIcons:r}){const n=u((t=>t.screens??{})),[o,i]=t.useState(!0);return t.createElement("div",{className:"sidebar "+(o?"open":"closed")},t.createElement("button",{className:"toggle-button",onClick:()=>i(!o)},o?"<":">"),t.createElement("nav",{className:"nav-links"},e?.(n).map(((e,n)=>t.createElement(a.Link,{key:n,to:e.path,className:"nav-link"},t.createElement("span",{className:"nav-links-icon"},r?.(e.iconType)),o?t.createElement("span",null,e.name):null)))))}class k extends t.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(t){return{hasError:!0,error:t,errorInfo:null}}componentDidCatch(t,e){this.setState({error:t,errorInfo:e})}render(){return this.state.hasError?t.createElement("div",{className:"error-boundary"},t.createElement("div",{className:"error-boundary__content"},t.createElement("div",{className:"error-boundary__icon"},t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},t.createElement("circle",{cx:"12",cy:"12",r:"10"}),t.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),t.createElement("h1",null,"Oops! Something went wrong"),t.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),t.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&t.createElement("details",{className:"error-boundary__details"},t.createElement("summary",null,"Error Details"),t.createElement("pre",null,this.state.error?.toString()),t.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}var P=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.name=t.name,this.target=t.target,this.propertyName=t.propertyName,this.constraints=null==t?void 0:t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},L=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(r){t.properties[r].forEach((function(n){var o={message:n.message,groups:n.groups,always:n.always,each:n.each},a={type:n.type,name:n.name,target:t.name,propertyName:r,constraints:n.constraints,validationTypeOptions:n.options,validationOptions:o};e.push(new P(a))}))})),e},t}();function I(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function j(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var V=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},D=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},F=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},R=function(){function t(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new L).transform(t).forEach((function(t){return e.addValidationMetadata(t)}))},t.prototype.addValidationMetadata=function(t){var e=this.validationMetadatas.get(t.target);e?e.push(t):this.validationMetadatas.set(t.target,[t])},t.prototype.addConstraintMetadata=function(t){var e=this.constraintMetadatas.get(t.target);e?e.push(t):this.constraintMetadatas.set(t.target,[t])},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach((function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)})),e},t.prototype.getTargetValidationMetadatas=function(t,e,r,n,o){var a,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&r},c=function(t){return!(!n||o&&o.length||!t.groups||!t.groups.length)},u=(this.validationMetadatas.get(t)||[]).filter((function(r){return(r.target===t||r.target===e)&&(!!s(r)||!c(r)&&(!(o&&o.length>0)||r.groups&&!!r.groups.find((function(t){return-1!==o.indexOf(t)}))))})),l=[];try{for(var p=V(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=D(f.value,2),h=d[0],y=d[1];t.prototype instanceof h&&l.push.apply(l,F([],D(y),!1))}}catch(t){a={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}var v=l.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!s(e)||!c(e)&&(!(o&&o.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==o.indexOf(t)}))))))})).filter((function(t){return!u.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return u.concat(v)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();function $(){var t=I();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new R),t.classValidatorMetadataStorage}var U=function(){function t(){}return t.prototype.toString=function(t,e,r,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===r&&(r=""),void 0===n&&(n=!1);var a=t?"":"",i=t?"":"",s=function(t){return" - property ".concat(a).concat(r).concat(t).concat(i," has failed the following constraints: ").concat(a).concat((n?Object.values:Object.keys)(null!==(e=o.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(r?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(r).concat(c),n)})).join(""):""}return"An instance of ".concat(a).concat(this.target?this.target.constructor.name:"an object").concat(i," has failed the validation:\n")+(this.constraints?s(this.property):"")+(this.children?this.children.map((function(e){return e.toString(t,!0,o.property,n)})).join(""):"")},t}(),z=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map((function(t){return e[t]})).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}();var B=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var r;return t instanceof Function?r=t(e):"string"==typeof t&&(r=t),r&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){r=r.replace(new RegExp("\\$constraint".concat(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):("symbol"==typeof t&&(t=t.description),"".concat(t))}(t))})),r&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(r=r.replace(/\$value/g,e.value)),r&&(r=r.replace(/\$property/g,e.property)),r&&(r=r.replace(/\$target/g,e.targetName)),r},t}(),K=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},q=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=$()}return t.prototype.execute=function(t,e,r){var n,o,a=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(n=this.validatorOptions)||void 0===n?void 0:n.enableDebugMessages)||console.warn("No validation metadata found. No validation will be performed. There are multiple possible reasons:\n - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n - This validation runs before any file with validation decorator was parsed by NodeJS.");var i=this.validatorOptions?this.validatorOptions.groups:void 0,s=this.validatorOptions&&this.validatorOptions.strictGroups||!1,c=this.validatorOptions&&this.validatorOptions.always||!1,u=void 0===(null===(o=this.validatorOptions)||void 0===o?void 0:o.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,l=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,c,s,i),p=this.metadataStorage.groupByPropertyName(l);if(this.validatorOptions&&u&&!l.length){var f=new U;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=t),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void r.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,r),Object.keys(p).forEach((function(e){var n=t[e],o=p[e].filter((function(t){return t.type===z.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==z.IS_DEFINED&&t.type!==z.WHITELIST}));n instanceof Promise&&i.find((function(t){return t.type===z.PROMISE_VALIDATION}))?a.awaitingPromises.push(n.then((function(n){a.performValidations(t,n,e,o,i,r)}))):a.performValidations(t,n,e,o,i,r)}))},t.prototype.whitelist=function(t,e,r){var n=this,o=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||o.push(t)})),o.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?o.forEach((function(e){var o,a=n.generateValidationError(t,t[e],e);a.constraints=((o={})[z.WHITELIST]="property ".concat(e," should not exist"),o),a.children=void 0,r.push(a)})):o.forEach((function(e){return delete t[e]})))},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter((function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0}))},t.prototype.performValidations=function(t,e,r,n,o,a){var i=o.filter((function(t){return t.type===z.CUSTOM_VALIDATION})),s=o.filter((function(t){return t.type===z.NESTED_VALIDATION})),c=o.filter((function(t){return t.type===z.CONDITIONAL_VALIDATION})),u=this.generateValidationError(t,e,r);a.push(u),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,n,u),this.mapContexts(t,e,n,u),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,i,u),this.nestedValidations(e,s,u),this.mapContexts(t,e,o,u),this.mapContexts(t,e,i,u)))},t.prototype.generateValidationError=function(t,e,r){var n=new U;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(n.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(n.value=e),n.property=r,n.children=[],n.constraints={},n},t.prototype.conditionalValidations=function(t,e,r){return r.map((function(r){return r.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,r,n){var o=this;r.forEach((function(r){o.metadataStorage.getTargetValidatorConstraints(r.constraintCls).forEach((function(a){if(!(a.async&&o.ignoreAsyncValidations||o.validatorOptions&&o.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:r.propertyName,object:t,value:e,constraints:r.constraints};if(r.each&&(Array.isArray(e)||e instanceof Set||e instanceof Map)){var s,c=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map((function(t){return a.instance.validate(t,i)}));if(c.some((function(t){return j(t)}))){var u=c.map((function(t){return j(t)?t:Promise.resolve(t)})),l=Promise.all(u).then((function(i){if(!i.every((function(t){return t}))){var s=K(o.createValidationError(t,e,r,a),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(l)}else{if(!c.every((function(t){return t}))){var p=K(o.createValidationError(t,e,r,a),2);y=p[0],v=p[1];n.constraints[y]=v}}}else{var f=a.instance.validate(e,i);if(j(f)){var d=f.then((function(i){if(!i){var s=K(o.createValidationError(t,e,r,a),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(d)}else if(!f){var h=K(o.createValidationError(t,e,r,a),2),y=h[0],v=h[1];n.constraints[y]=v}}}}))}))},t.prototype.nestedValidations=function(t,e,r){var n=this;void 0!==t&&e.forEach((function(o){if((o.type===z.NESTED_VALIDATION||o.type===z.PROMISE_VALIDATION)&&!(n.validatorOptions&&n.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(o,a){n.performValidations(t,o,a.toString(),[],e,r.children)}));else if(t instanceof Object){var a="string"==typeof o.target?o.target:o.target.name;n.execute(t,a,r.children)}else{var i=K(n.createValidationError(o.target,t,o),2),s=i[0],c=i[1];r.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,r,n){var o=this;return r.forEach((function(t){if(t.context){var e=void 0;if(t.type===z.CUSTOM_VALIDATION)e=o.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var r=o.getConstraintType(t,e);n.constraints[r]&&(n.contexts||(n.contexts={}),n.contexts[r]=Object.assign(n.contexts[r]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,r,n){var o=t.constructor?t.constructor.name:void 0,a=this.getConstraintType(r,n),i={targetName:o,property:r.propertyName,object:t,value:e,constraints:r.constraints},s=r.message||"";return r.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||n&&n.instance.defaultMessage instanceof Function&&(s=n.instance.defaultMessage(i)),[a,B.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),G=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{c(n.next(t))}catch(t){a(t)}}function s(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,s)}c((n=n.apply(t,e||[])).next())}))},W=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},H=function(){function t(){}return t.prototype.validate=function(t,e,r){return this.coreValidate(t,e,r)},t.prototype.validateOrReject=function(t,e,r){return G(this,void 0,void 0,(function(){var n;return W(this,(function(o){switch(o.label){case 0:return[4,this.coreValidate(t,e,r)];case 1:return(n=o.sent()).length?[2,Promise.reject(n)]:[2]}}))}))},t.prototype.validateSync=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new q(this,"string"==typeof t?r:e);a.ignoreAsyncValidations=!0;var i=[];return a.execute(n,o,i),a.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new q(this,"string"==typeof t?r:e),i=[];return a.execute(n,o,i),Promise.all(a.awaitingPromises).then((function(){return a.stripEmptyErrors(i)}))},t}(),J=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find((function(e){return e.type===t}));return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function Y(t){return J.get(t)}function Q(t,e,r){return"string"==typeof t?Y(H).validate(t,e,r):Y(H).validate(t,e)}function X(t,e,r){return"string"==typeof t?Y(H).validateSync(t,e,r):Y(H).validateSync(t,e)}const Z=(t,r,n)=>{if(t&&"reportValidity"in t){const o=e.get(n,r);t.setCustomValidity(o&&o.message||""),t.reportValidity()}},tt=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?Z(n.ref,r,t):n&&n.refs&&n.refs.forEach((e=>Z(e,r,t)))}},et=(t,r)=>{r.shouldUseNativeValidation&&tt(t,r);const n={};for(const o in t){const a=e.get(r.fields,o),i=Object.assign(t[o]||{},{ref:a&&a.ref});if(rt(r.names||Object.keys(t),o)){const t=Object.assign({},e.get(n,o));e.set(t,"root",i),e.set(n,o,t)}else e.set(n,o,i)}return n},rt=(t,e)=>{const r=nt(e);return t.some((t=>nt(t).match(`^${r}\\.\\d+`)))};function nt(t){return t.replace(/\]|\[/g,"")}var ot;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(ot||(ot={}));var at=new(function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,r){return this.findMetadatas(this._transformMetadatas,t,e).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?r===ot.CLASS_TO_CLASS||r===ot.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===ot.CLASS_TO_PLAIN))}))},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find((function(t){return t.options&&t.options.name===e}))},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),n=this._exposeMetadatas.get(t),o=n&&n.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===ot.CLASS_TO_CLASS||e===ot.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===ot.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===ot.CLASS_TO_CLASS||e===ot.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===ot.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,n=t.get(e);n&&(r=Array.from(n.values()).filter((function(t){return void 0!==t.propertyName})));for(var o=[],a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var u=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));o.push.apply(o,u)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var n=t.get(e);if(n){var o=n.get(r);if(o)return o}for(var a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var u=c.get(r);if(u)return u}}},t.prototype.findMetadatas=function(t,e,r){var n,o=t.get(e);o&&(n=o.get(r));for(var a=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],u=t.get(c);u&&u.has(r)&&a.push.apply(a,u.get(r))}return a.slice().reverse().concat((n||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}());var it=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var st=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,r,n,o,a){var i,s=this;if(void 0===a&&(a=0),Array.isArray(e)||e instanceof Set){var c=n&&this.transformationType===ot.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(n):[];return e.forEach((function(e,n){var o=t?t[n]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===ot.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(s.transformationType===ot.PLAIN_TO_CLASS){i=r.options.discriminator.subTypes.find((function(t){return t.name===e[r.options.discriminator.property]}));var u={newObject:c,object:e,property:void 0},l=r.typeFunction(u);i=void 0===i?l:i.value,r.options.keepDiscriminatorProperty||delete e[r.options.discriminator.property]}s.transformationType===ot.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===ot.CLASS_TO_PLAIN&&(e[r.options.discriminator.property]=r.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=r;var p=s.transform(o,e,i,void 0,e instanceof Map,a+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(r!==String||o){if(r!==Number||o){if(r!==Boolean||o){if((r===Date||e instanceof Date)&&!o)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||e instanceof Buffer)&&!o)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||o){if(o||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){r||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(r=e.constructor),!r&&t&&(r=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var u=this.getKeys(r,e,o),l=t||{};t||this.transformationType!==ot.PLAIN_TO_CLASS&&this.transformationType!==ot.CLASS_TO_CLASS||(l=o?new Map:r?new r:{});for(var p=function(n){if("__proto__"===n||"constructor"===n)return"continue";var i=n,s=n,c=n;if(!f.options.ignoreDecorators&&r)if(f.transformationType===ot.PLAIN_TO_CLASS)(u=at.findExposeMetadataByCustomName(r,n))&&(c=u.propertyName,s=u.propertyName);else if(f.transformationType===ot.CLASS_TO_PLAIN||f.transformationType===ot.CLASS_TO_CLASS){var u;(u=at.findExposeMetadata(r,n))&&u.options&&u.options.name&&(s=u.options.name)}var p=void 0;p=f.transformationType===ot.PLAIN_TO_CLASS?e[i]:e instanceof Map?e.get(i):e[i]instanceof Function?e[i]():e[i];var d=void 0,h=p instanceof Map;if(r&&o)d=r;else if(r){var y=at.findTypeMetadata(r,c);if(y){var v={newObject:l,object:e,property:c},m=y.typeFunction?y.typeFunction(v):y.reflectedType;y.options&&y.options.discriminator&&y.options.discriminator.property&&y.options.discriminator.subTypes?e[i]instanceof Array?d=y:(f.transformationType===ot.PLAIN_TO_CLASS&&(d=void 0===(d=y.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&y.options.discriminator.property in p)return t.name===p[y.options.discriminator.property]})))?m:d.value,y.options.keepDiscriminatorProperty||p&&p instanceof Object&&y.options.discriminator.property in p&&delete p[y.options.discriminator.property]),f.transformationType===ot.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===ot.CLASS_TO_PLAIN&&p&&(p[y.options.discriminator.property]=y.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=m,h=h||y.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===r&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===ot.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",r.prototype,c);g&&(d=g)}}var S=Array.isArray(e[i])?f.getReflectedType(r,c):void 0,_=t?t[i]:void 0;if(l.constructor.prototype){var E=Object.getOwnPropertyDescriptor(l.constructor.prototype,s);if((f.transformationType===ot.PLAIN_TO_CLASS||f.transformationType===ot.CLASS_TO_CLASS)&&(E&&!E.set||l[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===ot.CLASS_TO_CLASS){w=p;(void 0!==(w=f.applyCustomTransformations(w,r,n,e,f.transformationType))||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}}else{var O=f.transformationType===ot.PLAIN_TO_CLASS?s:n,w=void 0;f.transformationType===ot.CLASS_TO_PLAIN?(w=e[O],w=f.applyCustomTransformations(w,r,O,e,f.transformationType),w=e[O]===w?p:w,w=f.transform(_,w,d,S,h,a+1)):void 0===p&&f.options.exposeDefaultValues?w=l[s]:(w=f.transform(_,p,d,S,h,a+1),w=f.applyCustomTransformations(w,r,O,e,f.transformationType)),(void 0!==w||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}},f=this,d=0,h=u;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}return e}return e}return new Promise((function(t,n){e.then((function(e){return t(s.transform(void 0,e,r,void 0,void 0,a+1))}),n)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,r,n,o){var a=this,i=at.findTransformMetadatas(e,r,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||a.checkGroups(t.options.groups)})):i.filter((function(t){return!t.options||!t.options.groups||!t.options.groups.length}))).forEach((function(e){t=e.transformFn({value:t,key:r,obj:n,type:o,options:a.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=at.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var n=this,o=at.getStrategy(t);"none"===o&&(o=this.options.strategy||"exposeAll");var a=[];if(("exposeAll"===o||r)&&(a=e instanceof Map?Array.from(e.keys()):Object.keys(e)),r)return a;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=at.getExposedProperties(t,this.transformationType),s=at.getExcludedProperties(t,this.transformationType);a=it(it([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=at.getExposedProperties(t,this.transformationType);this.transformationType===ot.PLAIN_TO_CLASS&&(i=i.map((function(e){var r=at.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e}))),a=this.options.excludeExtraneousValues?i:a.concat(i);var c=at.getExcludedProperties(t,this.transformationType);c.length>0&&(a=a.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(a=a.filter((function(e){var r=at.findExposeMetadata(t,e);return!r||!r.options||n.checkVersion(r.options.since,r.options.until)}))),a=this.options.groups&&this.options.groups.length?a.filter((function(e){var r=at.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)})):a.filter((function(e){var r=at.findExposeMetadata(t,e);return!(r&&r.options&&r.options.groups&&r.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(a=a.filter((function(t){return n.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),a=a.filter((function(t,e,r){return r.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),ct={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},ut=function(){return ut=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ut.apply(this,arguments)},lt=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new st(ot.CLASS_TO_PLAIN,ut(ut({},ct),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new st(ot.CLASS_TO_PLAIN,ut(ut({},ct),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,r){return new st(ot.PLAIN_TO_CLASS,ut(ut({},ct),r)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new st(ot.PLAIN_TO_CLASS,ut(ut({},ct),r)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new st(ot.CLASS_TO_CLASS,ut(ut({},ct),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new st(ot.CLASS_TO_CLASS,ut(ut({},ct),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.instanceToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t.prototype.deserializeArray=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t}());function pt(t,e,r,n){return void 0===r&&(r={}),void 0===n&&(n=""),t.reduce((function(t,r){var o=n?n+"."+r.property:r.property;if(r.constraints){var a=Object.keys(r.constraints)[0];t[o]={type:a,message:r.constraints[a]};var i=t[o];e&&i&&Object.assign(i,{types:r.constraints})}return r.children&&r.children.length&&pt(r.children,e,t,o),t}),r)}function ft(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),function(n,o,a){try{var i=e.validator,s=(c=t,u=n,l=e.transformer,lt.plainToInstance(c,u,l));return Promise.resolve(("sync"===r.mode?X:Q)(s,i)).then((function(t){return t.length?{values:{},errors:et(pt(t,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&tt({},a),{values:r.raw?Object.assign({},n):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,u,l}}function dt(t,e){const r=$().getTargetValidationMetadatas(e,"",!1,!1),n=function(t){return Reflect.getMetadata(T,t)}(e);return{resolver:ft(e),fields:Array.from(new Set(r.map((t=>t.propertyName)))),inputs:N(e),cells:A(e),crud:n,path:"/"+(n?.controller??t)}}exports.Cell=function(t){return(e,r)=>{const n=Reflect.getMetadata(M,e)||[];if(Reflect.defineMetadata(M,[...n,r.toString()],e),t){const n=`${M.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}},exports.Crud=function(t){return e=>{t&&Reflect.defineMetadata(T,t,e)}},exports.Input=function(t){return(e,r)=>{const n=Reflect.getMetadata(x,e)||[];if(Reflect.defineMetadata(x,[...n,r.toString()],e),t){const n=`${x.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}},exports.Layout=function({children:e,menu:r,getIcons:n}){const{user:o,screenPaths:i}=u((t=>({user:t.user,screenPaths:t.screenPaths}))),s=a.useNavigate();return o||s(i.login),t.createElement("div",{className:"layout"},t.createElement(C,{menu:r,getIcons:n}),t.createElement("main",{className:"content"},e))},exports.Login=function(){const{register:r,handleSubmit:n,formState:{errors:o}}=e.useForm(),{fetchSettings:i}=u((t=>({fetchSettings:t.fetchSettings}))),l=a.useNavigate();return t.createElement("div",{className:"login-container"},t.createElement("div",{className:"login-panel"},t.createElement("div",{className:"login-header"},t.createElement("h1",null,"Welcome Back"),t.createElement("p",null,"Please sign in to continue")),t.createElement("form",{onSubmit:n((async t=>{c(i,t.username,t.password).then((t=>{const{access_token:e,admin:r}=t;u.setState({user:r,token:e}),l("/")}))})),className:"login-form"},t.createElement(s,{input:{name:"username",label:"Username",inputType:"text",placeholder:"Enter your username"},register:r,isEditForm:!1,error:o.username}),t.createElement(s,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password"},register:r,isEditForm:!1,error:o.password}),t.createElement("div",{className:"form-actions"},t.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))},exports.Panel=function({children:e,init:r}){return t.useEffect((()=>{!function({crud:t,fetch:e,screenPaths:r}){const n={};Object.entries(t).forEach((([t,e])=>{n[t]=dt(t,e)})),l(n),u.setState({fetchSettings:{baseUrl:e.baseURL},screenPaths:r})}(r())}),[r]),t.createElement(k,null,e)},exports.createScreens=l,exports.useScreens=function(){const e=u((t=>t.screens??{}));return t.useMemo((()=>t.createElement(t.Fragment,null,Object.entries(e).map((([e,r])=>{const n=r.crud?.controller??e;let o=`${r.path}`;const i={key:e,controller:n};return t.createElement(t.Fragment,{key:"index"},t.createElement(a.Route,{path:o+"/create",element:t.createElement(v,{screen:i})}),t.createElement(a.Route,{path:o+"/details/:id",element:t.createElement(g,{screen:i})}),t.createElement(a.Route,{path:o+"/edit/:id",element:t.createElement(S,{screen:i})}),t.createElement(a.Route,{path:o,element:t.createElement(E,{screen:i})}))})),t.createElement(a.Route,{path:"*",element:t.createElement("div",null,"404 - Not Found")}))),[e])};
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { Login } from "./components/screens/Login";
1
2
  export { type InitPanelOptions } from "./types/initPanelOptions";
2
3
  export { type ScreenCreatorData } from "./types/ScreenCreatorData";
3
4
  export { createScreens } from "./utils/createScreens";
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import{persist as t,createJSONStorage as e}from"zustand/middleware";import{createWithEqualityFn as r}from"zustand/traditional";import{shallow as n}from"zustand/vanilla/shallow";import o,{useEffect as i,useState as a,useMemo as s,Component as c}from"react";import{useNavigate as u,useParams as l,Link as p,Route as f}from"react-router";import{useForm as d,get as h,set as y}from"react-hook-form";const v=r()(t((t=>({screens:null,fetchSettings:null})),{name:"app-store-1",storage:e((()=>localStorage)),partialize:t=>({})}),n);function m(t){v.setState({screens:t})}const g=(t,e)=>fetch(`${t.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}}).then((t=>t.json())),_=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json())),S=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r}`,{method:"GET",headers:{"Content-Type":"application/json"}}).then((t=>t.json())),O=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json()));function E({htmlFor:t,label:e,fieldName:r}){return o.createElement("label",{htmlFor:t},e??r.charAt(0).toUpperCase()+r.slice(1))}function w({input:t,register:e,isEditForm:r,error:n}){const i=t.name||"";return o.createElement("div",{className:"form-field"},o.createElement(E,{htmlFor:i,label:t.label,fieldName:i}),(()=>{switch(t.type){case"textarea":return o.createElement("textarea",{...e(i),placeholder:t.placeholder,id:i,disabled:r&&!1===t.editable});case"select":return o.createElement("select",{...e(i),id:i,disabled:r&&!1===t.editable},o.createElement("option",{value:""},"Select ",i),t.selectOptions?.map((t=>o.createElement("option",{key:t,value:t},t))));default:return o.createElement("input",{type:t.inputType,...e(i),placeholder:t.placeholder,id:i,disabled:r&&!1===t.editable})}})(),n&&o.createElement("span",{className:"error-message"},n.message))}function b({data:t,screen:e}){const{screens:r,fetchSettings:n}=v((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings}))),a=!!t,{register:s,handleSubmit:c,reset:l,formState:{errors:p}}=d({resolver:r[e.controller].resolver,defaultValues:{...t,__formEdit:a}}),f=u(),h=r[e.controller].inputs;return i((()=>{l({...t,__formEdit:a})}),[a,t,l]),o.createElement("div",{className:"form-wrapper"},o.createElement("form",{onSubmit:c((t=>{n&&(delete t.__formEdit,a?O(n,e.controller,t).then((()=>{f("/"+e.controller,{replace:!0})})):_(n,e.controller,t).then((()=>{f("/"+e.controller,{replace:!0})})))}))},h.map((t=>o.createElement(w,{key:t.name||"",input:t,register:s,isEditForm:a,error:p[t.name||""]}))),o.createElement("button",{type:"submit",className:"submit-button"},"Submit")))}function T({screen:t}){return o.createElement(b,{screen:t})}function M({error:t}){return o.createElement("div",{className:"error-container"},o.createElement("div",{className:"error-icon"},o.createElement("i",{className:"fa fa-exclamation-circle"})),o.createElement("div",{className:"error-content"},o.createElement("h3",null,"Error Occurred"),o.createElement("p",null,t?.message||"Something went wrong. Please try again later.")))}function A({screen:t}){const{fetchSettings:e}=v((t=>({fetchSettings:t.fetchSettings}))),{id:r}=l(),[n,s]=a(null),[c,u]=a(null);return i((()=>{e&&t.controller&&r&&S(e,t.controller,r).then((t=>{s(t)})).catch((t=>{u(t),console.error(t)}))}),[e,r,t]),c?o.createElement(M,{error:c}):o.createElement("p",{dangerouslySetInnerHTML:{__html:JSON.stringify(n,null," <br/>")}})}function x({screen:t}){const{fetchSettings:e}=v((t=>({fetchSettings:t.fetchSettings}))),{id:r}=l(),[n,s]=a(null),[c,u]=a(null);return i((()=>{e&&t.controller&&r&&S(e,t.controller,r).then((t=>{s(t)})).catch((t=>{u(t),console.error(t)}))}),[e,r,t]),c?o.createElement(M,{error:c}):o.createElement(b,{data:n,screen:t})}function N({data:t,cells:e}){return t&&0!==t.length?o.createElement("div",{className:"list-wrapper"},o.createElement("div",{className:"header"},"List"),o.createElement("table",{className:"list-table"},o.createElement("thead",null,o.createElement("tr",null,e.map((t=>o.createElement("th",{key:t.name},t.title??t.name))),o.createElement("th",null))),o.createElement("tbody",null,t.map(((t,r)=>o.createElement("tr",{key:r},e.map((e=>{const r=t[e.name];let n=r??"-";if("date"===e.type){if(r){const t=new Date(r);n=`${t.getDate().toString().padStart(2,"0")}/${(t.getMonth()+1).toString().padStart(2,"0")}/${t.getFullYear()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}}else n=r?r.toString():e?.placeHolder??"-";let i=n;return o.createElement("td",{key:e.name},i)})),o.createElement("td",null,o.createElement(p,{to:"edit/"+(t?.id??"-")},"Edit"),o.createElement(p,{to:"details/"+(t?.id??"-")},"Details")))))))):o.createElement("div",null,"No items available")}function C({screen:t}){const{screens:e,fetchSettings:r}=v((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings}))),[n,s]=a(0),[c,u]=a(null),[l,f]=a(null);return i((()=>{t.controller&&r&&g(r,t.controller).then((t=>{u(t)})).catch((t=>{f(t),console.error(t)}))}),[n,t.controller,r]),l?o.createElement(M,{error:l}):o.createElement("div",null,o.createElement(p,{to:"create"},"Create"),o.createElement(N,{screen:t,cells:e[t.key].cells,data:c}))}function P(){const t=v((t=>t.screens??{}));return s((()=>o.createElement(o.Fragment,null,Object.entries(t).map((([t,e])=>{const r=e.crud?.controller??t;let n=`${e.path}`;const i={key:t,controller:r};return o.createElement(o.Fragment,{key:"index"},o.createElement(f,{path:n+"/create",element:o.createElement(T,{screen:i})}),o.createElement(f,{path:n+"/details/:id",element:o.createElement(A,{screen:i})}),o.createElement(f,{path:n+"/edit/:id",element:o.createElement(x,{screen:i})}),o.createElement(f,{path:n,element:o.createElement(C,{screen:i})}))})),o.createElement(f,{path:"*",element:o.createElement("div",null,"404 - Not Found")}))),[t])}var L,k="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},I={};!function(){return L||(L=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof k?k:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=n(t);function n(t,e){return function(r,n){Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0!==e.Reflect&&(r=n(e.Reflect,r)),function(t,e){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,o=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",i=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",a="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!a&&!s,u={create:a?function(){return pt(Object.create(null))}:s?function(){return pt({__proto__:null})}:function(){return pt({})},has:c?function(t,e){return r.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return r.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},l=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ct(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:ut(),d="function"==typeof WeakMap?WeakMap:lt(),h=n?Symbol.for("@reflect-metadata:registry"):void 0,y=ot(),v=it(y);function m(t,e,r,n){if(D(r)){if(!H(t))throw new TypeError;if(!J(e))throw new TypeError;return A(t,e)}if(!H(t))throw new TypeError;if(!$(e))throw new TypeError;if(!$(n)&&!D(n)&&!F(n))throw new TypeError;return F(n)&&(n=void 0),x(t,e,r=G(r),n)}function g(t,e){function r(r,n){if(!$(r))throw new TypeError;if(!D(n)&&!Y(n))throw new TypeError;k(t,e,r,n)}return r}function _(t,e,r,n){if(!$(r))throw new TypeError;return D(n)||(n=G(n)),k(t,e,r,n)}function S(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),N(t,e,r)}function O(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),C(t,e,r)}function E(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),P(t,e,r)}function w(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),L(t,e,r)}function b(t,e){if(!$(t))throw new TypeError;return D(e)||(e=G(e)),I(t,e)}function T(t,e){if(!$(t))throw new TypeError;return D(e)||(e=G(e)),j(t,e)}function M(t,e,r){if(!$(e))throw new TypeError;if(D(r)||(r=G(r)),!$(e))throw new TypeError;D(r)||(r=G(r));var n=st(e,r,!1);return!D(n)&&n.OrdinaryDeleteMetadata(t,e,r)}function A(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!D(n)&&!F(n)){if(!J(n))throw new TypeError;e=n}}return e}function x(t,e,r,n){for(var o=t.length-1;o>=0;--o){var i=(0,t[o])(e,r,n);if(!D(i)&&!F(i)){if(!$(i))throw new TypeError;n=i}}return n}function N(t,e,r){if(C(t,e,r))return!0;var n=rt(e);return!F(n)&&N(t,n,r)}function C(t,e,r){var n=st(e,r,!1);return!D(n)&&K(n.OrdinaryHasOwnMetadata(t,e,r))}function P(t,e,r){if(C(t,e,r))return L(t,e,r);var n=rt(e);return F(n)?void 0:P(t,n,r)}function L(t,e,r){var n=st(e,r,!1);if(!D(n))return n.OrdinaryGetOwnMetadata(t,e,r)}function k(t,e,r,n){st(r,n,!0).OrdinaryDefineOwnMetadata(t,e,r,n)}function I(t,e){var r=j(t,e),n=rt(t);if(null===n)return r;var o=I(n,e);if(o.length<=0)return r;if(r.length<=0)return o;for(var i=new f,a=[],s=0,c=r;s<c.length;s++){var u=c[s];i.has(u)||(i.add(u),a.push(u))}for(var l=0,p=o;l<p.length;l++){u=p[l];i.has(u)||(i.add(u),a.push(u))}return a}function j(t,e){var r=st(t,e,!1);return r?r.OrdinaryOwnMetadataKeys(t,e):[]}function V(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function D(t){return void 0===t}function F(t){return null===t}function R(t){return"symbol"==typeof t}function $(t){return"object"==typeof t?null!==t:"function"==typeof t}function U(t,e){switch(V(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r="string",n=Q(t,o);if(void 0!==n){var i=n.call(t,r);if($(i))throw new TypeError;return i}return z(t)}function z(t,e){var r,n,o=t.toString;if(W(o)&&!$(n=o.call(t)))return n;if(W(r=t.valueOf)&&!$(n=r.call(t)))return n;throw new TypeError}function K(t){return!!t}function B(t){return""+t}function G(t){var e=U(t);return R(e)?e:B(e)}function H(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function W(t){return"function"==typeof t}function J(t){return"function"==typeof t}function Y(t){switch(V(t)){case 3:case 4:return!0;default:return!1}}function q(t,e){return t===e||t!=t&&e!=e}function Q(t,e){var r=t[e];if(null!=r){if(!W(r))throw new TypeError;return r}}function X(t){var e=Q(t,i);if(!W(e))throw new TypeError;var r=e.call(t);if(!$(r))throw new TypeError;return r}function Z(t){return t.value}function tt(t){var e=t.next();return!e.done&&e}function et(t){var e=t.return;e&&e.call(t)}function rt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===l)return e;if(e!==l)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var o=n.constructor;return"function"!=typeof o||o===t?e:o}function nt(){var t,r,n,o;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=at(e.Reflect));var i=new d,a={registerProvider:s,getProvider:u,setProvider:y};return a;function s(e){if(!Object.isExtensible(a))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case D(r):r=e;break;case r===e:break;case D(n):n=e;break;case n===e:break;default:void 0===o&&(o=new f),o.add(e)}}function c(e,i){if(!D(r)){if(r.isProviderFor(e,i))return r;if(!D(n)){if(n.isProviderFor(e,i))return r;if(!D(o))for(var a=X(o);;){var s=tt(a);if(!s)return;var c=Z(s);if(c.isProviderFor(e,i))return et(a),c}}}if(!D(t)&&t.isProviderFor(e,i))return t}function u(t,e){var r,n=i.get(t);return D(n)||(r=n.get(e)),D(r)?(D(r=c(t,e))||(D(n)&&(n=new p,i.set(t,n)),n.set(e,r)),r):r}function l(t){if(D(t))throw new TypeError;return r===t||n===t||!D(o)&&o.has(t)}function y(t,e,r){if(!l(r))throw new Error("Metadata provider not registered.");var n=u(t,e);if(n!==r){if(!D(n))return!1;var o=i.get(t);D(o)&&(o=new p,i.set(t,o)),o.set(e,r)}return!0}}function ot(){var t;return!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=nt()),!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function it(t){var e=new d,r={isProviderFor:function(t,r){var n=e.get(t);return!D(n)&&n.has(r)},OrdinaryDefineOwnMetadata:a,OrdinaryHasOwnMetadata:o,OrdinaryGetOwnMetadata:i,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return y.registerProvider(r),r;function n(n,o,i){var a=e.get(n),s=!1;if(D(a)){if(!i)return;a=new p,e.set(n,a),s=!0}var c=a.get(o);if(D(c)){if(!i)return;if(c=new p,a.set(o,c),!t.setProvider(n,o,r))throw a.delete(o),s&&e.delete(n),new Error("Wrong provider for target.")}return c}function o(t,e,r){var o=n(e,r,!1);return!D(o)&&K(o.has(t))}function i(t,e,r){var o=n(e,r,!1);if(!D(o))return o.get(t)}function a(t,e,r,o){n(r,o,!0).set(t,e)}function s(t,e){var r=[],o=n(t,e,!1);if(D(o))return r;for(var i=X(o.keys()),a=0;;){var s=tt(i);if(!s)return r.length=a,r;var c=Z(s);try{r[a]=c}catch(t){try{et(i)}finally{throw t}}a++}}function c(t,r,o){var i=n(r,o,!1);if(D(i))return!1;if(!i.delete(t))return!1;if(0===i.size){var a=e.get(r);D(a)||(a.delete(o),0===a.size&&e.delete(a))}return!0}}function at(t){var e=t.defineMetadata,r=t.hasOwnMetadata,n=t.getOwnMetadata,o=t.getOwnMetadataKeys,i=t.deleteMetadata,a=new d;return{isProviderFor:function(t,e){var r=a.get(t);return!(D(r)||!r.has(e))||!!o(t,e).length&&(D(r)&&(r=new f,a.set(t,r)),r.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:o,OrdinaryDeleteMetadata:i}}function st(t,e,r){var n=y.getProvider(t,e);if(!D(n))return n;if(r){if(y.setProvider(t,e,v))return v;throw new Error("Illegal state.")}}function ct(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[i]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}(),n=function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,q(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,o)},e.prototype.values=function(){return new r(this._keys,this._values,a)},e.prototype.entries=function(){return new r(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[i]=function(){return this.entries()},e.prototype._find=function(t,e){if(!q(this._cacheKey,t)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(q(this._keys[r],t)){this._cacheIndex=r;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return n;function o(t,e){return t}function a(t,e){return e}function s(t,e){return[t,e]}}function ut(){return function(){function t(){this._map=new p}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[i]=function(){return this.keys()},t}()}function lt(){var t=16,e=u.create(),n=o();return function(){function t(){this._key=o()}return t.prototype.has=function(t){var e=i(t,!1);return void 0!==e&&u.has(e,this._key)},t.prototype.get=function(t){var e=i(t,!1);return void 0!==e?u.get(e,this._key):void 0},t.prototype.set=function(t,e){return i(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=i(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=o()},t}();function o(){var t;do{t="@@WeakMap@@"+c()}while(u.has(e,t));return e[t]=!0,t}function i(t,e){if(!r.call(t,n)){if(!e)return;Object.defineProperty(t,n,{value:u.create()})}return t[n]}function a(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function s(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):a(e,t),e}return a(new Array(t),t)}function c(){var e=s(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var r="",n=0;n<t;++n){var o=e[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function pt(t){return t.__=void 0,delete t.__,t}t("decorate",m),t("metadata",g),t("defineMetadata",_),t("hasMetadata",S),t("hasOwnMetadata",O),t("getMetadata",E),t("getOwnMetadata",w),t("getMetadataKeys",b),t("getOwnMetadataKeys",T),t("deleteMetadata",M)}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),I;var t}();const j="Crud";function V(t){return e=>{t&&Reflect.defineMetadata(j,t,e)}}const D=Symbol("cell");function F(t){return(e,r)=>{const n=Reflect.getMetadata(D,e)||[];if(Reflect.defineMetadata(D,[...n,r.toString()],e),t){const n=`${D.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function R(t){const e=t.prototype;return(Reflect.getMetadata(D,e)||[]).map((t=>{const r=Reflect.getMetadata(`${D.toString()}:${t}:options`,e)||{};return{...r,name:r?.name??t}}))}const $=Symbol("input");function U(t){return(e,r)=>{const n=Reflect.getMetadata($,e)||[];if(Reflect.defineMetadata($,[...n,r.toString()],e),t){const n=`${$.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function z(t){const e=t.prototype;return(Reflect.getMetadata($,e)||[]).map((t=>{const r=Reflect.getMetadata(`${$.toString()}:${t}:options`,e)||{},n=r?.inputType??(o=t,["password"].some((t=>o.toLowerCase().includes(t)))?"password":"text");var o;return{...r,editable:r.editable??!0,sensitive:r.sensitive,name:r?.name??t,label:r?.label??t,placeholder:r?.placeholder??t,inputType:n,selectOptions:r?.selectOptions??[],cancelPasswordValidationOnEdit:r?.cancelPasswordValidationOnEdit??"password"===n}}))}function K({menu:t,getIcons:e}){const r=v((t=>t.screens??{})),[n,i]=a(!0);return o.createElement("div",{className:"sidebar "+(n?"open":"closed")},o.createElement("button",{className:"toggle-button",onClick:()=>i(!n)},n?"<":">"),o.createElement("nav",{className:"nav-links"},t?.(r).map(((t,r)=>o.createElement(p,{key:r,to:t.path,className:"nav-link"},o.createElement("span",{className:"nav-links-icon"},e?.(t.iconType)),n?o.createElement("span",null,t.name):null)))))}function B({children:t,menu:e,getIcons:r}){return o.createElement("div",{className:"layout"},o.createElement(K,{menu:e,getIcons:r}),o.createElement("main",{className:"content"},t))}class G extends c{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(t){return{hasError:!0,error:t,errorInfo:null}}componentDidCatch(t,e){this.setState({error:t,errorInfo:e})}render(){return this.state.hasError?o.createElement("div",{className:"error-boundary"},o.createElement("div",{className:"error-boundary__content"},o.createElement("div",{className:"error-boundary__icon"},o.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},o.createElement("circle",{cx:"12",cy:"12",r:"10"}),o.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),o.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),o.createElement("h1",null,"Oops! Something went wrong"),o.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),o.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&o.createElement("details",{className:"error-boundary__details"},o.createElement("summary",null,"Error Details"),o.createElement("pre",null,this.state.error?.toString()),o.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}var H=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.name=t.name,this.target=t.target,this.propertyName=t.propertyName,this.constraints=null==t?void 0:t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},W=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(r){t.properties[r].forEach((function(n){var o={message:n.message,groups:n.groups,always:n.always,each:n.each},i={type:n.type,name:n.name,target:t.name,propertyName:r,constraints:n.constraints,validationTypeOptions:n.options,validationOptions:o};e.push(new H(i))}))})),e},t}();function J(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function Y(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var q=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Q=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},X=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},Z=function(){function t(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new W).transform(t).forEach((function(t){return e.addValidationMetadata(t)}))},t.prototype.addValidationMetadata=function(t){var e=this.validationMetadatas.get(t.target);e?e.push(t):this.validationMetadatas.set(t.target,[t])},t.prototype.addConstraintMetadata=function(t){var e=this.constraintMetadatas.get(t.target);e?e.push(t):this.constraintMetadatas.set(t.target,[t])},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach((function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)})),e},t.prototype.getTargetValidationMetadatas=function(t,e,r,n,o){var i,a,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&r},c=function(t){return!(!n||o&&o.length||!t.groups||!t.groups.length)},u=(this.validationMetadatas.get(t)||[]).filter((function(r){return(r.target===t||r.target===e)&&(!!s(r)||!c(r)&&(!(o&&o.length>0)||r.groups&&!!r.groups.find((function(t){return-1!==o.indexOf(t)}))))})),l=[];try{for(var p=q(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=Q(f.value,2),h=d[0],y=d[1];t.prototype instanceof h&&l.push.apply(l,X([],Q(y),!1))}}catch(t){i={error:t}}finally{try{f&&!f.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}var v=l.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!s(e)||!c(e)&&(!(o&&o.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==o.indexOf(t)}))))))})).filter((function(t){return!u.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return u.concat(v)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();function tt(){var t=J();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new Z),t.classValidatorMetadataStorage}var et=function(){function t(){}return t.prototype.toString=function(t,e,r,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===r&&(r=""),void 0===n&&(n=!1);var i=t?"":"",a=t?"":"",s=function(t){return" - property ".concat(i).concat(r).concat(t).concat(a," has failed the following constraints: ").concat(i).concat((n?Object.values:Object.keys)(null!==(e=o.constraints)&&void 0!==e?e:{}).join(", ")).concat(a," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(r?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(r).concat(c),n)})).join(""):""}return"An instance of ".concat(i).concat(this.target?this.target.constructor.name:"an object").concat(a," has failed the validation:\n")+(this.constraints?s(this.property):"")+(this.children?this.children.map((function(e){return e.toString(t,!0,o.property,n)})).join(""):"")},t}(),rt=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map((function(t){return e[t]})).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}();var nt=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var r;return t instanceof Function?r=t(e):"string"==typeof t&&(r=t),r&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){r=r.replace(new RegExp("\\$constraint".concat(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):("symbol"==typeof t&&(t=t.description),"".concat(t))}(t))})),r&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(r=r.replace(/\$value/g,e.value)),r&&(r=r.replace(/\$property/g,e.property)),r&&(r=r.replace(/\$target/g,e.targetName)),r},t}(),ot=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},it=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=tt()}return t.prototype.execute=function(t,e,r){var n,o,i=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(n=this.validatorOptions)||void 0===n?void 0:n.enableDebugMessages)||console.warn("No validation metadata found. No validation will be performed. There are multiple possible reasons:\n - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n - This validation runs before any file with validation decorator was parsed by NodeJS.");var a=this.validatorOptions?this.validatorOptions.groups:void 0,s=this.validatorOptions&&this.validatorOptions.strictGroups||!1,c=this.validatorOptions&&this.validatorOptions.always||!1,u=void 0===(null===(o=this.validatorOptions)||void 0===o?void 0:o.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,l=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,c,s,a),p=this.metadataStorage.groupByPropertyName(l);if(this.validatorOptions&&u&&!l.length){var f=new et;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=t),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void r.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,r),Object.keys(p).forEach((function(e){var n=t[e],o=p[e].filter((function(t){return t.type===rt.IS_DEFINED})),a=p[e].filter((function(t){return t.type!==rt.IS_DEFINED&&t.type!==rt.WHITELIST}));n instanceof Promise&&a.find((function(t){return t.type===rt.PROMISE_VALIDATION}))?i.awaitingPromises.push(n.then((function(n){i.performValidations(t,n,e,o,a,r)}))):i.performValidations(t,n,e,o,a,r)}))},t.prototype.whitelist=function(t,e,r){var n=this,o=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||o.push(t)})),o.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?o.forEach((function(e){var o,i=n.generateValidationError(t,t[e],e);i.constraints=((o={})[rt.WHITELIST]="property ".concat(e," should not exist"),o),i.children=void 0,r.push(i)})):o.forEach((function(e){return delete t[e]})))},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter((function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0}))},t.prototype.performValidations=function(t,e,r,n,o,i){var a=o.filter((function(t){return t.type===rt.CUSTOM_VALIDATION})),s=o.filter((function(t){return t.type===rt.NESTED_VALIDATION})),c=o.filter((function(t){return t.type===rt.CONDITIONAL_VALIDATION})),u=this.generateValidationError(t,e,r);i.push(u),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,n,u),this.mapContexts(t,e,n,u),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,a,u),this.nestedValidations(e,s,u),this.mapContexts(t,e,o,u),this.mapContexts(t,e,a,u)))},t.prototype.generateValidationError=function(t,e,r){var n=new et;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(n.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(n.value=e),n.property=r,n.children=[],n.constraints={},n},t.prototype.conditionalValidations=function(t,e,r){return r.map((function(r){return r.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,r,n){var o=this;r.forEach((function(r){o.metadataStorage.getTargetValidatorConstraints(r.constraintCls).forEach((function(i){if(!(i.async&&o.ignoreAsyncValidations||o.validatorOptions&&o.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0)){var a={targetName:t.constructor?t.constructor.name:void 0,property:r.propertyName,object:t,value:e,constraints:r.constraints};if(r.each&&(Array.isArray(e)||e instanceof Set||e instanceof Map)){var s,c=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map((function(t){return i.instance.validate(t,a)}));if(c.some((function(t){return Y(t)}))){var u=c.map((function(t){return Y(t)?t:Promise.resolve(t)})),l=Promise.all(u).then((function(a){if(!a.every((function(t){return t}))){var s=ot(o.createValidationError(t,e,r,i),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(l)}else{if(!c.every((function(t){return t}))){var p=ot(o.createValidationError(t,e,r,i),2);y=p[0],v=p[1];n.constraints[y]=v}}}else{var f=i.instance.validate(e,a);if(Y(f)){var d=f.then((function(a){if(!a){var s=ot(o.createValidationError(t,e,r,i),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(d)}else if(!f){var h=ot(o.createValidationError(t,e,r,i),2),y=h[0],v=h[1];n.constraints[y]=v}}}}))}))},t.prototype.nestedValidations=function(t,e,r){var n=this;void 0!==t&&e.forEach((function(o){if((o.type===rt.NESTED_VALIDATION||o.type===rt.PROMISE_VALIDATION)&&!(n.validatorOptions&&n.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(o,i){n.performValidations(t,o,i.toString(),[],e,r.children)}));else if(t instanceof Object){var i="string"==typeof o.target?o.target:o.target.name;n.execute(t,i,r.children)}else{var a=ot(n.createValidationError(o.target,t,o),2),s=a[0],c=a[1];r.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,r,n){var o=this;return r.forEach((function(t){if(t.context){var e=void 0;if(t.type===rt.CUSTOM_VALIDATION)e=o.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var r=o.getConstraintType(t,e);n.constraints[r]&&(n.contexts||(n.contexts={}),n.contexts[r]=Object.assign(n.contexts[r]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,r,n){var o=t.constructor?t.constructor.name:void 0,i=this.getConstraintType(r,n),a={targetName:o,property:r.propertyName,object:t,value:e,constraints:r.constraints},s=r.message||"";return r.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||n&&n.instance.defaultMessage instanceof Function&&(s=n.instance.defaultMessage(a)),[i,nt.replaceMessageSpecialTokens(s,a)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),at=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},st=function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},ct=function(){function t(){}return t.prototype.validate=function(t,e,r){return this.coreValidate(t,e,r)},t.prototype.validateOrReject=function(t,e,r){return at(this,void 0,void 0,(function(){var n;return st(this,(function(o){switch(o.label){case 0:return[4,this.coreValidate(t,e,r)];case 1:return(n=o.sent()).length?[2,Promise.reject(n)]:[2]}}))}))},t.prototype.validateSync=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,i=new it(this,"string"==typeof t?r:e);i.ignoreAsyncValidations=!0;var a=[];return i.execute(n,o,a),i.stripEmptyErrors(a)},t.prototype.coreValidate=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,i=new it(this,"string"==typeof t?r:e),a=[];return i.execute(n,o,a),Promise.all(i.awaitingPromises).then((function(){return i.stripEmptyErrors(a)}))},t}(),ut=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find((function(e){return e.type===t}));return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function lt(t){return ut.get(t)}function pt(t,e,r){return"string"==typeof t?lt(ct).validate(t,e,r):lt(ct).validate(t,e)}function ft(t,e,r){return"string"==typeof t?lt(ct).validateSync(t,e,r):lt(ct).validateSync(t,e)}const dt=(t,e,r)=>{if(t&&"reportValidity"in t){const n=h(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},ht=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?dt(n.ref,r,t):n&&n.refs&&n.refs.forEach((e=>dt(e,r,t)))}},yt=(t,e)=>{e.shouldUseNativeValidation&&ht(t,e);const r={};for(const n in t){const o=h(e.fields,n),i=Object.assign(t[n]||{},{ref:o&&o.ref});if(vt(e.names||Object.keys(t),n)){const t=Object.assign({},h(r,n));y(t,"root",i),y(r,n,t)}else y(r,n,i)}return r},vt=(t,e)=>{const r=mt(e);return t.some((t=>mt(t).match(`^${r}\\.\\d+`)))};function mt(t){return t.replace(/\]|\[/g,"")}var gt;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(gt||(gt={}));var _t=new(function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,r){return this.findMetadatas(this._transformMetadatas,t,e).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?r===gt.CLASS_TO_CLASS||r===gt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===gt.CLASS_TO_PLAIN))}))},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find((function(t){return t.options&&t.options.name===e}))},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),n=this._exposeMetadatas.get(t),o=n&&n.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===gt.CLASS_TO_CLASS||e===gt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===gt.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===gt.CLASS_TO_CLASS||e===gt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===gt.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,n=t.get(e);n&&(r=Array.from(n.values()).filter((function(t){return void 0!==t.propertyName})));for(var o=[],i=0,a=this.getAncestors(e);i<a.length;i++){var s=a[i],c=t.get(s);if(c){var u=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));o.push.apply(o,u)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var n=t.get(e);if(n){var o=n.get(r);if(o)return o}for(var i=0,a=this.getAncestors(e);i<a.length;i++){var s=a[i],c=t.get(s);if(c){var u=c.get(r);if(u)return u}}},t.prototype.findMetadatas=function(t,e,r){var n,o=t.get(e);o&&(n=o.get(r));for(var i=[],a=0,s=this.getAncestors(e);a<s.length;a++){var c=s[a],u=t.get(c);u&&u.has(r)&&i.push.apply(i,u.get(r))}return i.slice().reverse().concat((n||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}());var St=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var Ot=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,r,n,o,i){var a,s=this;if(void 0===i&&(i=0),Array.isArray(e)||e instanceof Set){var c=n&&this.transformationType===gt.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(n):[];return e.forEach((function(e,n){var o=t?t[n]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===gt.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var a=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(s.transformationType===gt.PLAIN_TO_CLASS){a=r.options.discriminator.subTypes.find((function(t){return t.name===e[r.options.discriminator.property]}));var u={newObject:c,object:e,property:void 0},l=r.typeFunction(u);a=void 0===a?l:a.value,r.options.keepDiscriminatorProperty||delete e[r.options.discriminator.property]}s.transformationType===gt.CLASS_TO_CLASS&&(a=e.constructor),s.transformationType===gt.CLASS_TO_PLAIN&&(e[r.options.discriminator.property]=r.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else a=r;var p=s.transform(o,e,a,void 0,e instanceof Map,i+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(r!==String||o){if(r!==Number||o){if(r!==Boolean||o){if((r===Date||e instanceof Date)&&!o)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||e instanceof Buffer)&&!o)return null==e?e:Buffer.from(e);if(null===(a=e)||"object"!=typeof a||"function"!=typeof a.then||o){if(o||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){r||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(r=e.constructor),!r&&t&&(r=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var u=this.getKeys(r,e,o),l=t||{};t||this.transformationType!==gt.PLAIN_TO_CLASS&&this.transformationType!==gt.CLASS_TO_CLASS||(l=o?new Map:r?new r:{});for(var p=function(n){if("__proto__"===n||"constructor"===n)return"continue";var a=n,s=n,c=n;if(!f.options.ignoreDecorators&&r)if(f.transformationType===gt.PLAIN_TO_CLASS)(u=_t.findExposeMetadataByCustomName(r,n))&&(c=u.propertyName,s=u.propertyName);else if(f.transformationType===gt.CLASS_TO_PLAIN||f.transformationType===gt.CLASS_TO_CLASS){var u;(u=_t.findExposeMetadata(r,n))&&u.options&&u.options.name&&(s=u.options.name)}var p=void 0;p=f.transformationType===gt.PLAIN_TO_CLASS?e[a]:e instanceof Map?e.get(a):e[a]instanceof Function?e[a]():e[a];var d=void 0,h=p instanceof Map;if(r&&o)d=r;else if(r){var y=_t.findTypeMetadata(r,c);if(y){var v={newObject:l,object:e,property:c},m=y.typeFunction?y.typeFunction(v):y.reflectedType;y.options&&y.options.discriminator&&y.options.discriminator.property&&y.options.discriminator.subTypes?e[a]instanceof Array?d=y:(f.transformationType===gt.PLAIN_TO_CLASS&&(d=void 0===(d=y.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&y.options.discriminator.property in p)return t.name===p[y.options.discriminator.property]})))?m:d.value,y.options.keepDiscriminatorProperty||p&&p instanceof Object&&y.options.discriminator.property in p&&delete p[y.options.discriminator.property]),f.transformationType===gt.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===gt.CLASS_TO_PLAIN&&p&&(p[y.options.discriminator.property]=y.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=m,h=h||y.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===r&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===gt.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",r.prototype,c);g&&(d=g)}}var _=Array.isArray(e[a])?f.getReflectedType(r,c):void 0,S=t?t[a]:void 0;if(l.constructor.prototype){var O=Object.getOwnPropertyDescriptor(l.constructor.prototype,s);if((f.transformationType===gt.PLAIN_TO_CLASS||f.transformationType===gt.CLASS_TO_CLASS)&&(O&&!O.set||l[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===gt.CLASS_TO_CLASS){w=p;(void 0!==(w=f.applyCustomTransformations(w,r,n,e,f.transformationType))||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}}else{var E=f.transformationType===gt.PLAIN_TO_CLASS?s:n,w=void 0;f.transformationType===gt.CLASS_TO_PLAIN?(w=e[E],w=f.applyCustomTransformations(w,r,E,e,f.transformationType),w=e[E]===w?p:w,w=f.transform(S,w,d,_,h,i+1)):void 0===p&&f.options.exposeDefaultValues?w=l[s]:(w=f.transform(S,p,d,_,h,i+1),w=f.applyCustomTransformations(w,r,E,e,f.transformationType)),(void 0!==w||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}},f=this,d=0,h=u;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}return e}return e}return new Promise((function(t,n){e.then((function(e){return t(s.transform(void 0,e,r,void 0,void 0,i+1))}),n)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,r,n,o){var i=this,a=_t.findTransformMetadatas(e,r,this.transformationType);return void 0!==this.options.version&&(a=a.filter((function(t){return!t.options||i.checkVersion(t.options.since,t.options.until)}))),(a=this.options.groups&&this.options.groups.length?a.filter((function(t){return!t.options||i.checkGroups(t.options.groups)})):a.filter((function(t){return!t.options||!t.options.groups||!t.options.groups.length}))).forEach((function(e){t=e.transformFn({value:t,key:r,obj:n,type:o,options:i.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=_t.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var n=this,o=_t.getStrategy(t);"none"===o&&(o=this.options.strategy||"exposeAll");var i=[];if(("exposeAll"===o||r)&&(i=e instanceof Map?Array.from(e.keys()):Object.keys(e)),r)return i;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var a=_t.getExposedProperties(t,this.transformationType),s=_t.getExcludedProperties(t,this.transformationType);i=St(St([],a,!0),s,!0)}if(!this.options.ignoreDecorators&&t){a=_t.getExposedProperties(t,this.transformationType);this.transformationType===gt.PLAIN_TO_CLASS&&(a=a.map((function(e){var r=_t.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e}))),i=this.options.excludeExtraneousValues?a:i.concat(a);var c=_t.getExcludedProperties(t,this.transformationType);c.length>0&&(i=i.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(i=i.filter((function(e){var r=_t.findExposeMetadata(t,e);return!r||!r.options||n.checkVersion(r.options.since,r.options.until)}))),i=this.options.groups&&this.options.groups.length?i.filter((function(e){var r=_t.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)})):i.filter((function(e){var r=_t.findExposeMetadata(t,e);return!(r&&r.options&&r.options.groups&&r.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(i=i.filter((function(t){return n.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),i=i.filter((function(t,e,r){return r.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),Et={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},wt=function(){return wt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},wt.apply(this,arguments)},bt=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new Ot(gt.CLASS_TO_PLAIN,wt(wt({},Et),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new Ot(gt.CLASS_TO_PLAIN,wt(wt({},Et),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,r){return new Ot(gt.PLAIN_TO_CLASS,wt(wt({},Et),r)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new Ot(gt.PLAIN_TO_CLASS,wt(wt({},Et),r)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new Ot(gt.CLASS_TO_CLASS,wt(wt({},Et),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new Ot(gt.CLASS_TO_CLASS,wt(wt({},Et),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.instanceToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t.prototype.deserializeArray=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t}());function Tt(t,e,r,n){return void 0===r&&(r={}),void 0===n&&(n=""),t.reduce((function(t,r){var o=n?n+"."+r.property:r.property;if(r.constraints){var i=Object.keys(r.constraints)[0];t[o]={type:i,message:r.constraints[i]};var a=t[o];e&&a&&Object.assign(a,{types:r.constraints})}return r.children&&r.children.length&&Tt(r.children,e,t,o),t}),r)}function Mt(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),function(n,o,i){try{var a=e.validator,s=(c=t,u=n,l=e.transformer,bt.plainToInstance(c,u,l));return Promise.resolve(("sync"===r.mode?ft:pt)(s,a)).then((function(t){return t.length?{values:{},errors:yt(Tt(t,!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&ht({},i),{values:r.raw?Object.assign({},n):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,u,l}}function At(t,e){const r=tt().getTargetValidationMetadatas(e,"",!1,!1),n=function(t){return Reflect.getMetadata(j,t)}(e);return{resolver:Mt(e),fields:Array.from(new Set(r.map((t=>t.propertyName)))),inputs:z(e),cells:R(e),crud:n,path:"/"+(n?.controller??t)}}function xt({children:t,init:e}){return i((()=>{!function({crud:t,fetch:e}){const r={};Object.entries(t).forEach((([t,e])=>{r[t]=At(t,e)})),m(r),v.setState({fetchSettings:{baseUrl:e.baseURL}})}(e())}),[e]),o.createElement(G,null,t)}export{F as Cell,V as Crud,U as Input,B as Layout,xt as Panel,m as createScreens,P as useScreens};
1
+ import t,{useEffect as e,useState as r,useMemo as n,Component as o}from"react";import{useForm as a,get as i,set as s}from"react-hook-form";import{persist as c,createJSONStorage as u}from"zustand/middleware";import{createWithEqualityFn as l}from"zustand/traditional";import{shallow as p}from"zustand/vanilla/shallow";import{useNavigate as f,useParams as d,Link as h,Route as y}from"react-router";function v({htmlFor:e,label:r,fieldName:n}){return t.createElement("label",{htmlFor:e},r??n.charAt(0).toUpperCase()+n.slice(1))}function m({input:e,register:r,isEditForm:n,error:o}){const a=e.name||"";return t.createElement("div",{className:"form-field"},t.createElement(v,{htmlFor:a,label:e.label,fieldName:a}),(()=>{switch(e.type){case"textarea":return t.createElement("textarea",{...r(a),placeholder:e.placeholder,id:a,disabled:n&&!1===e.editable});case"select":return t.createElement("select",{...r(a),id:a,disabled:n&&!1===e.editable},t.createElement("option",{value:""},"Select ",a),e.selectOptions?.map((e=>t.createElement("option",{key:e,value:e},e))));default:return t.createElement("input",{type:e.inputType,...r(a),placeholder:e.placeholder,id:a,disabled:n&&!1===e.editable})}})(),o&&t.createElement("span",{className:"error-message"},o.message))}const g=(t,e,r)=>fetch(`${t.baseUrl}/auth/login`,{method:"POST",body:JSON.stringify({username:e,password:r}),headers:{"Content-Type":"application/json"}}).then((t=>{if(t.ok)return t.json();throw t})),S=l()(c((t=>({screens:null,user:null,fetchSettings:null,screenPaths:{},token:null})),{name:"app-store-1",storage:u((()=>localStorage)),partialize:t=>({user:t.user,token:t.token})}),p);function _(){const{register:e,handleSubmit:r,formState:{errors:n}}=a(),{fetchSettings:o}=S((t=>({fetchSettings:t.fetchSettings}))),i=f();return t.createElement("div",{className:"login-container"},t.createElement("div",{className:"login-panel"},t.createElement("div",{className:"login-header"},t.createElement("h1",null,"Welcome Back"),t.createElement("p",null,"Please sign in to continue")),t.createElement("form",{onSubmit:r((async t=>{g(o,t.username,t.password).then((t=>{const{access_token:e,admin:r}=t;S.setState({user:r,token:e}),i("/")}))})),className:"login-form"},t.createElement(m,{input:{name:"username",label:"Username",inputType:"text",placeholder:"Enter your username"},register:e,isEditForm:!1,error:n.username}),t.createElement(m,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password"},register:e,isEditForm:!1,error:n.password}),t.createElement("div",{className:"form-actions"},t.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))}function O(t){S.setState({screens:t})}const E=(t,e)=>fetch(`${t.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.token}`}}).then((t=>{if(t.ok)return t.json();throw t})),w=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json())),b=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r}`,{method:"GET",headers:{"Content-Type":"application/json"}}).then((t=>t.json())),T=(t,e,r)=>fetch(`${t?.baseUrl??""}/${e}/${r.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then((t=>t.json()));function M({data:r,screen:n}){const{screens:o,fetchSettings:i}=S((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings}))),s=!!r,{register:c,handleSubmit:u,reset:l,formState:{errors:p}}=a({resolver:o[n.controller].resolver,defaultValues:{...r,__formEdit:s}}),d=f(),h=o[n.controller].inputs;return e((()=>{l({...r,__formEdit:s})}),[s,r,l]),t.createElement("div",{className:"form-wrapper"},t.createElement("form",{onSubmit:u((t=>{i&&(delete t.__formEdit,s?T(i,n.controller,t).then((()=>{d("/"+n.controller,{replace:!0})})):w(i,n.controller,t).then((()=>{d("/"+n.controller,{replace:!0})})))}))},h.map((e=>t.createElement(m,{key:e.name||"",input:e,register:c,isEditForm:s,error:p[e.name||""]}))),t.createElement("button",{type:"submit",className:"submit-button"},"Submit")))}function A({screen:e}){return t.createElement(M,{screen:e})}function x({error:e}){return t.createElement("div",{className:"error-container"},t.createElement("div",{className:"error-icon"},t.createElement("i",{className:"fa fa-exclamation-circle"})),t.createElement("div",{className:"error-content"},t.createElement("h3",null,"Error Occurred"),t.createElement("p",null,(t=>{if(t instanceof Response)switch(t.status){case 400:return"Bad Request: The request was invalid or malformed.";case 401:return"Unauthorized: Please log in to access this resource.";case 404:return"Not Found: The requested resource could not be found.";case 403:return"Forbidden: You don't have permission to access this resource.";case 500:return"Internal Server Error: Something went wrong on our end.";default:return`Error ${t.status}: ${t.statusText||"Something went wrong."}`}return t?.message||"Something went wrong. Please try again later."})(e))))}function N({screen:n}){const{fetchSettings:o}=S((t=>({fetchSettings:t.fetchSettings}))),{id:a}=d(),[i,s]=r(null),[c,u]=r(null);return e((()=>{o&&n.controller&&a&&b(o,n.controller,a).then((t=>{s(t)})).catch((t=>{u(t),console.error(t)}))}),[o,a,n]),c?t.createElement(x,{error:c}):t.createElement("p",{dangerouslySetInnerHTML:{__html:JSON.stringify(i,null," <br/>")}})}function C({screen:n}){const{fetchSettings:o}=S((t=>({fetchSettings:t.fetchSettings}))),{id:a}=d(),[i,s]=r(null),[c,u]=r(null);return e((()=>{o&&n.controller&&a&&b(o,n.controller,a).then((t=>{s(t)})).catch((t=>{u(t),console.error(t)}))}),[o,a,n]),c?t.createElement(x,{error:c}):t.createElement(M,{data:i,screen:n})}function P({data:e,cells:r}){return e&&0!==e.length?t.createElement("div",{className:"list-wrapper"},t.createElement("div",{className:"header"},"List"),t.createElement("table",{className:"list-table"},t.createElement("thead",null,t.createElement("tr",null,r.map((e=>t.createElement("th",{key:e.name},e.title??e.name))),t.createElement("th",null))),t.createElement("tbody",null,e.map(((e,n)=>t.createElement("tr",{key:n},r.map((r=>{const n=e[r.name];let o=n??"-";if("date"===r.type){if(n){const t=new Date(n);o=`${t.getDate().toString().padStart(2,"0")}/${(t.getMonth()+1).toString().padStart(2,"0")}/${t.getFullYear()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}}else o=n?n.toString():r?.placeHolder??"-";let a=o;return t.createElement("td",{key:r.name},a)})),t.createElement("td",null,t.createElement(h,{to:"edit/"+(e?.id??"-")},"Edit"),t.createElement(h,{to:"details/"+(e?.id??"-")},"Details")))))))):t.createElement("div",null,"No items available")}function k({screen:n}){const{screens:o,fetchSettings:a,token:i}=S((t=>({screens:t.screens??{},fetchSettings:t.fetchSettings,token:t.token}))),[s,c]=r(0),[u,l]=r(null),[p,f]=r(null);return e((()=>{n.controller&&a&&i&&E({...a,token:i},n.controller).then((t=>{l(t)})).catch((t=>{f(t),console.error(t)}))}),[s,n.controller,a]),p?t.createElement(x,{error:p}):t.createElement("div",null,t.createElement(h,{to:"create"},"Create"),t.createElement(P,{screen:n,cells:o[n.key].cells,data:u}))}function L(){const e=S((t=>t.screens??{}));return n((()=>t.createElement(t.Fragment,null,Object.entries(e).map((([e,r])=>{const n=r.crud?.controller??e;let o=`${r.path}`;const a={key:e,controller:n};return t.createElement(t.Fragment,{key:"index"},t.createElement(y,{path:o+"/create",element:t.createElement(A,{screen:a})}),t.createElement(y,{path:o+"/details/:id",element:t.createElement(N,{screen:a})}),t.createElement(y,{path:o+"/edit/:id",element:t.createElement(C,{screen:a})}),t.createElement(y,{path:o,element:t.createElement(k,{screen:a})}))})),t.createElement(y,{path:"*",element:t.createElement("div",null,"404 - Not Found")}))),[e])}var I,j="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},V={};!function(){return I||(I=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof j?j:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=n(t);function n(t,e){return function(r,n){Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0!==e.Reflect&&(r=n(e.Reflect,r)),function(t,e){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,o=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",a=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,u={create:i?function(){return pt(Object.create(null))}:s?function(){return pt({__proto__:null})}:function(){return pt({})},has:c?function(t,e){return r.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return r.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},l=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ct(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:ut(),d="function"==typeof WeakMap?WeakMap:lt(),h=n?Symbol.for("@reflect-metadata:registry"):void 0,y=ot(),v=at(y);function m(t,e,r,n){if(D(r)){if(!H(t))throw new TypeError;if(!J(e))throw new TypeError;return A(t,e)}if(!H(t))throw new TypeError;if(!$(e))throw new TypeError;if(!$(n)&&!D(n)&&!F(n))throw new TypeError;return F(n)&&(n=void 0),x(t,e,r=G(r),n)}function g(t,e){function r(r,n){if(!$(r))throw new TypeError;if(!D(n)&&!q(n))throw new TypeError;L(t,e,r,n)}return r}function S(t,e,r,n){if(!$(r))throw new TypeError;return D(n)||(n=G(n)),L(t,e,r,n)}function _(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),N(t,e,r)}function O(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),C(t,e,r)}function E(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),P(t,e,r)}function w(t,e,r){if(!$(e))throw new TypeError;return D(r)||(r=G(r)),k(t,e,r)}function b(t,e){if(!$(t))throw new TypeError;return D(e)||(e=G(e)),I(t,e)}function T(t,e){if(!$(t))throw new TypeError;return D(e)||(e=G(e)),j(t,e)}function M(t,e,r){if(!$(e))throw new TypeError;if(D(r)||(r=G(r)),!$(e))throw new TypeError;D(r)||(r=G(r));var n=st(e,r,!1);return!D(n)&&n.OrdinaryDeleteMetadata(t,e,r)}function A(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!D(n)&&!F(n)){if(!J(n))throw new TypeError;e=n}}return e}function x(t,e,r,n){for(var o=t.length-1;o>=0;--o){var a=(0,t[o])(e,r,n);if(!D(a)&&!F(a)){if(!$(a))throw new TypeError;n=a}}return n}function N(t,e,r){if(C(t,e,r))return!0;var n=rt(e);return!F(n)&&N(t,n,r)}function C(t,e,r){var n=st(e,r,!1);return!D(n)&&B(n.OrdinaryHasOwnMetadata(t,e,r))}function P(t,e,r){if(C(t,e,r))return k(t,e,r);var n=rt(e);return F(n)?void 0:P(t,n,r)}function k(t,e,r){var n=st(e,r,!1);if(!D(n))return n.OrdinaryGetOwnMetadata(t,e,r)}function L(t,e,r,n){st(r,n,!0).OrdinaryDefineOwnMetadata(t,e,r,n)}function I(t,e){var r=j(t,e),n=rt(t);if(null===n)return r;var o=I(n,e);if(o.length<=0)return r;if(r.length<=0)return o;for(var a=new f,i=[],s=0,c=r;s<c.length;s++){var u=c[s];a.has(u)||(a.add(u),i.push(u))}for(var l=0,p=o;l<p.length;l++){u=p[l];a.has(u)||(a.add(u),i.push(u))}return i}function j(t,e){var r=st(t,e,!1);return r?r.OrdinaryOwnMetadataKeys(t,e):[]}function V(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function D(t){return void 0===t}function F(t){return null===t}function R(t){return"symbol"==typeof t}function $(t){return"object"==typeof t?null!==t:"function"==typeof t}function U(t,e){switch(V(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r="string",n=Q(t,o);if(void 0!==n){var a=n.call(t,r);if($(a))throw new TypeError;return a}return z(t)}function z(t,e){var r,n,o=t.toString;if(W(o)&&!$(n=o.call(t)))return n;if(W(r=t.valueOf)&&!$(n=r.call(t)))return n;throw new TypeError}function B(t){return!!t}function K(t){return""+t}function G(t){var e=U(t);return R(e)?e:K(e)}function H(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function W(t){return"function"==typeof t}function J(t){return"function"==typeof t}function q(t){switch(V(t)){case 3:case 4:return!0;default:return!1}}function Y(t,e){return t===e||t!=t&&e!=e}function Q(t,e){var r=t[e];if(null!=r){if(!W(r))throw new TypeError;return r}}function X(t){var e=Q(t,a);if(!W(e))throw new TypeError;var r=e.call(t);if(!$(r))throw new TypeError;return r}function Z(t){return t.value}function tt(t){var e=t.next();return!e.done&&e}function et(t){var e=t.return;e&&e.call(t)}function rt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===l)return e;if(e!==l)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var o=n.constructor;return"function"!=typeof o||o===t?e:o}function nt(){var t,r,n,o;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var a=new d,i={registerProvider:s,getProvider:u,setProvider:y};return i;function s(e){if(!Object.isExtensible(i))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case D(r):r=e;break;case r===e:break;case D(n):n=e;break;case n===e:break;default:void 0===o&&(o=new f),o.add(e)}}function c(e,a){if(!D(r)){if(r.isProviderFor(e,a))return r;if(!D(n)){if(n.isProviderFor(e,a))return r;if(!D(o))for(var i=X(o);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,a))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,a))return t}function u(t,e){var r,n=a.get(t);return D(n)||(r=n.get(e)),D(r)?(D(r=c(t,e))||(D(n)&&(n=new p,a.set(t,n)),n.set(e,r)),r):r}function l(t){if(D(t))throw new TypeError;return r===t||n===t||!D(o)&&o.has(t)}function y(t,e,r){if(!l(r))throw new Error("Metadata provider not registered.");var n=u(t,e);if(n!==r){if(!D(n))return!1;var o=a.get(t);D(o)&&(o=new p,a.set(t,o)),o.set(e,r)}return!0}}function ot(){var t;return!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=nt()),!D(h)&&$(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function at(t){var e=new d,r={isProviderFor:function(t,r){var n=e.get(t);return!D(n)&&n.has(r)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:o,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return y.registerProvider(r),r;function n(n,o,a){var i=e.get(n),s=!1;if(D(i)){if(!a)return;i=new p,e.set(n,i),s=!0}var c=i.get(o);if(D(c)){if(!a)return;if(c=new p,i.set(o,c),!t.setProvider(n,o,r))throw i.delete(o),s&&e.delete(n),new Error("Wrong provider for target.")}return c}function o(t,e,r){var o=n(e,r,!1);return!D(o)&&B(o.has(t))}function a(t,e,r){var o=n(e,r,!1);if(!D(o))return o.get(t)}function i(t,e,r,o){n(r,o,!0).set(t,e)}function s(t,e){var r=[],o=n(t,e,!1);if(D(o))return r;for(var a=X(o.keys()),i=0;;){var s=tt(a);if(!s)return r.length=i,r;var c=Z(s);try{r[i]=c}catch(t){try{et(a)}finally{throw t}}i++}}function c(t,r,o){var a=n(r,o,!1);if(D(a))return!1;if(!a.delete(t))return!1;if(0===a.size){var i=e.get(r);D(i)||(i.delete(o),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,r=t.hasOwnMetadata,n=t.getOwnMetadata,o=t.getOwnMetadataKeys,a=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var r=i.get(t);return!(D(r)||!r.has(e))||!!o(t,e).length&&(D(r)&&(r=new f,i.set(t,r)),r.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:o,OrdinaryDeleteMetadata:a}}function st(t,e,r){var n=y.getProvider(t,e);if(!D(n))return n;if(r){if(y.setProvider(t,e,v))return v;throw new Error("Illegal state.")}}function ct(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[a]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}(),n=function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,Y(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,o)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[a]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Y(this._keys[r],t)){this._cacheIndex=r;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return n;function o(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function ut(){return function(){function t(){this._map=new p}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[a]=function(){return this.keys()},t}()}function lt(){var t=16,e=u.create(),n=o();return function(){function t(){this._key=o()}return t.prototype.has=function(t){var e=a(t,!1);return void 0!==e&&u.has(e,this._key)},t.prototype.get=function(t){var e=a(t,!1);return void 0!==e?u.get(e,this._key):void 0},t.prototype.set=function(t,e){return a(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=a(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=o()},t}();function o(){var t;do{t="@@WeakMap@@"+c()}while(u.has(e,t));return e[t]=!0,t}function a(t,e){if(!r.call(t,n)){if(!e)return;Object.defineProperty(t,n,{value:u.create()})}return t[n]}function i(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function s(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):i(e,t),e}return i(new Array(t),t)}function c(){var e=s(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var r="",n=0;n<t;++n){var o=e[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function pt(t){return t.__=void 0,delete t.__,t}t("decorate",m),t("metadata",g),t("defineMetadata",S),t("hasMetadata",_),t("hasOwnMetadata",O),t("getMetadata",E),t("getOwnMetadata",w),t("getMetadataKeys",b),t("getOwnMetadataKeys",T),t("deleteMetadata",M)}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),V;var t}();const D="Crud";function F(t){return e=>{t&&Reflect.defineMetadata(D,t,e)}}const R=Symbol("cell");function $(t){return(e,r)=>{const n=Reflect.getMetadata(R,e)||[];if(Reflect.defineMetadata(R,[...n,r.toString()],e),t){const n=`${R.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function U(t){const e=t.prototype;return(Reflect.getMetadata(R,e)||[]).map((t=>{const r=Reflect.getMetadata(`${R.toString()}:${t}:options`,e)||{};return{...r,name:r?.name??t}}))}const z=Symbol("input");function B(t){return(e,r)=>{const n=Reflect.getMetadata(z,e)||[];if(Reflect.defineMetadata(z,[...n,r.toString()],e),t){const n=`${z.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function K(t){const e=t.prototype;return(Reflect.getMetadata(z,e)||[]).map((t=>{const r=Reflect.getMetadata(`${z.toString()}:${t}:options`,e)||{},n=r?.inputType??(o=t,["password"].some((t=>o.toLowerCase().includes(t)))?"password":"text");var o;return{...r,editable:r.editable??!0,sensitive:r.sensitive,name:r?.name??t,label:r?.label??t,placeholder:r?.placeholder??t,inputType:n,selectOptions:r?.selectOptions??[],cancelPasswordValidationOnEdit:r?.cancelPasswordValidationOnEdit??"password"===n}}))}function G({menu:e,getIcons:n}){const o=S((t=>t.screens??{})),[a,i]=r(!0);return t.createElement("div",{className:"sidebar "+(a?"open":"closed")},t.createElement("button",{className:"toggle-button",onClick:()=>i(!a)},a?"<":">"),t.createElement("nav",{className:"nav-links"},e?.(o).map(((e,r)=>t.createElement(h,{key:r,to:e.path,className:"nav-link"},t.createElement("span",{className:"nav-links-icon"},n?.(e.iconType)),a?t.createElement("span",null,e.name):null)))))}function H({children:e,menu:r,getIcons:n}){const{user:o,screenPaths:a}=S((t=>({user:t.user,screenPaths:t.screenPaths}))),i=f();return o||i(a.login),t.createElement("div",{className:"layout"},t.createElement(G,{menu:r,getIcons:n}),t.createElement("main",{className:"content"},e))}class W extends o{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(t){return{hasError:!0,error:t,errorInfo:null}}componentDidCatch(t,e){this.setState({error:t,errorInfo:e})}render(){return this.state.hasError?t.createElement("div",{className:"error-boundary"},t.createElement("div",{className:"error-boundary__content"},t.createElement("div",{className:"error-boundary__icon"},t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},t.createElement("circle",{cx:"12",cy:"12",r:"10"}),t.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),t.createElement("h1",null,"Oops! Something went wrong"),t.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),t.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&t.createElement("details",{className:"error-boundary__details"},t.createElement("summary",null,"Error Details"),t.createElement("pre",null,this.state.error?.toString()),t.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}var J=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.name=t.name,this.target=t.target,this.propertyName=t.propertyName,this.constraints=null==t?void 0:t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},q=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(r){t.properties[r].forEach((function(n){var o={message:n.message,groups:n.groups,always:n.always,each:n.each},a={type:n.type,name:n.name,target:t.name,propertyName:r,constraints:n.constraints,validationTypeOptions:n.options,validationOptions:o};e.push(new J(a))}))})),e},t}();function Y(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function Q(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var X=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Z=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},tt=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},et=function(){function t(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new q).transform(t).forEach((function(t){return e.addValidationMetadata(t)}))},t.prototype.addValidationMetadata=function(t){var e=this.validationMetadatas.get(t.target);e?e.push(t):this.validationMetadatas.set(t.target,[t])},t.prototype.addConstraintMetadata=function(t){var e=this.constraintMetadatas.get(t.target);e?e.push(t):this.constraintMetadatas.set(t.target,[t])},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach((function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)})),e},t.prototype.getTargetValidationMetadatas=function(t,e,r,n,o){var a,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&r},c=function(t){return!(!n||o&&o.length||!t.groups||!t.groups.length)},u=(this.validationMetadatas.get(t)||[]).filter((function(r){return(r.target===t||r.target===e)&&(!!s(r)||!c(r)&&(!(o&&o.length>0)||r.groups&&!!r.groups.find((function(t){return-1!==o.indexOf(t)}))))})),l=[];try{for(var p=X(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=Z(f.value,2),h=d[0],y=d[1];t.prototype instanceof h&&l.push.apply(l,tt([],Z(y),!1))}}catch(t){a={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}var v=l.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!s(e)||!c(e)&&(!(o&&o.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==o.indexOf(t)}))))))})).filter((function(t){return!u.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return u.concat(v)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();function rt(){var t=Y();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new et),t.classValidatorMetadataStorage}var nt=function(){function t(){}return t.prototype.toString=function(t,e,r,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===r&&(r=""),void 0===n&&(n=!1);var a=t?"":"",i=t?"":"",s=function(t){return" - property ".concat(a).concat(r).concat(t).concat(i," has failed the following constraints: ").concat(a).concat((n?Object.values:Object.keys)(null!==(e=o.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(r?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(r).concat(c),n)})).join(""):""}return"An instance of ".concat(a).concat(this.target?this.target.constructor.name:"an object").concat(i," has failed the validation:\n")+(this.constraints?s(this.property):"")+(this.children?this.children.map((function(e){return e.toString(t,!0,o.property,n)})).join(""):"")},t}(),ot=function(){function t(){}return t.isValid=function(t){var e=this;return"isValid"!==t&&"getMessage"!==t&&-1!==Object.keys(this).map((function(t){return e[t]})).indexOf(t)},t.CUSTOM_VALIDATION="customValidation",t.NESTED_VALIDATION="nestedValidation",t.PROMISE_VALIDATION="promiseValidation",t.CONDITIONAL_VALIDATION="conditionalValidation",t.WHITELIST="whitelistValidation",t.IS_DEFINED="isDefined",t}();var at=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var r;return t instanceof Function?r=t(e):"string"==typeof t&&(r=t),r&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){r=r.replace(new RegExp("\\$constraint".concat(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):("symbol"==typeof t&&(t=t.description),"".concat(t))}(t))})),r&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(r=r.replace(/\$value/g,e.value)),r&&(r=r.replace(/\$property/g,e.property)),r&&(r=r.replace(/\$target/g,e.targetName)),r},t}(),it=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},st=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=rt()}return t.prototype.execute=function(t,e,r){var n,o,a=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(n=this.validatorOptions)||void 0===n?void 0:n.enableDebugMessages)||console.warn("No validation metadata found. No validation will be performed. There are multiple possible reasons:\n - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n - This validation runs before any file with validation decorator was parsed by NodeJS.");var i=this.validatorOptions?this.validatorOptions.groups:void 0,s=this.validatorOptions&&this.validatorOptions.strictGroups||!1,c=this.validatorOptions&&this.validatorOptions.always||!1,u=void 0===(null===(o=this.validatorOptions)||void 0===o?void 0:o.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,l=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,c,s,i),p=this.metadataStorage.groupByPropertyName(l);if(this.validatorOptions&&u&&!l.length){var f=new nt;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=t),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void r.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,r),Object.keys(p).forEach((function(e){var n=t[e],o=p[e].filter((function(t){return t.type===ot.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==ot.IS_DEFINED&&t.type!==ot.WHITELIST}));n instanceof Promise&&i.find((function(t){return t.type===ot.PROMISE_VALIDATION}))?a.awaitingPromises.push(n.then((function(n){a.performValidations(t,n,e,o,i,r)}))):a.performValidations(t,n,e,o,i,r)}))},t.prototype.whitelist=function(t,e,r){var n=this,o=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||o.push(t)})),o.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?o.forEach((function(e){var o,a=n.generateValidationError(t,t[e],e);a.constraints=((o={})[ot.WHITELIST]="property ".concat(e," should not exist"),o),a.children=void 0,r.push(a)})):o.forEach((function(e){return delete t[e]})))},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter((function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0}))},t.prototype.performValidations=function(t,e,r,n,o,a){var i=o.filter((function(t){return t.type===ot.CUSTOM_VALIDATION})),s=o.filter((function(t){return t.type===ot.NESTED_VALIDATION})),c=o.filter((function(t){return t.type===ot.CONDITIONAL_VALIDATION})),u=this.generateValidationError(t,e,r);a.push(u),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,n,u),this.mapContexts(t,e,n,u),void 0===e&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===e&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==e&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(t,e,i,u),this.nestedValidations(e,s,u),this.mapContexts(t,e,o,u),this.mapContexts(t,e,i,u)))},t.prototype.generateValidationError=function(t,e,r){var n=new nt;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(n.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(n.value=e),n.property=r,n.children=[],n.constraints={},n},t.prototype.conditionalValidations=function(t,e,r){return r.map((function(r){return r.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,r,n){var o=this;r.forEach((function(r){o.metadataStorage.getTargetValidatorConstraints(r.constraintCls).forEach((function(a){if(!(a.async&&o.ignoreAsyncValidations||o.validatorOptions&&o.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:r.propertyName,object:t,value:e,constraints:r.constraints};if(r.each&&(Array.isArray(e)||e instanceof Set||e instanceof Map)){var s,c=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map((function(t){return a.instance.validate(t,i)}));if(c.some((function(t){return Q(t)}))){var u=c.map((function(t){return Q(t)?t:Promise.resolve(t)})),l=Promise.all(u).then((function(i){if(!i.every((function(t){return t}))){var s=it(o.createValidationError(t,e,r,a),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(l)}else{if(!c.every((function(t){return t}))){var p=it(o.createValidationError(t,e,r,a),2);y=p[0],v=p[1];n.constraints[y]=v}}}else{var f=a.instance.validate(e,i);if(Q(f)){var d=f.then((function(i){if(!i){var s=it(o.createValidationError(t,e,r,a),2),c=s[0],u=s[1];n.constraints[c]=u,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(d)}else if(!f){var h=it(o.createValidationError(t,e,r,a),2),y=h[0],v=h[1];n.constraints[y]=v}}}}))}))},t.prototype.nestedValidations=function(t,e,r){var n=this;void 0!==t&&e.forEach((function(o){if((o.type===ot.NESTED_VALIDATION||o.type===ot.PROMISE_VALIDATION)&&!(n.validatorOptions&&n.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(o,a){n.performValidations(t,o,a.toString(),[],e,r.children)}));else if(t instanceof Object){var a="string"==typeof o.target?o.target:o.target.name;n.execute(t,a,r.children)}else{var i=it(n.createValidationError(o.target,t,o),2),s=i[0],c=i[1];r.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,r,n){var o=this;return r.forEach((function(t){if(t.context){var e=void 0;if(t.type===ot.CUSTOM_VALIDATION)e=o.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var r=o.getConstraintType(t,e);n.constraints[r]&&(n.contexts||(n.contexts={}),n.contexts[r]=Object.assign(n.contexts[r]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,r,n){var o=t.constructor?t.constructor.name:void 0,a=this.getConstraintType(r,n),i={targetName:o,property:r.propertyName,object:t,value:e,constraints:r.constraints},s=r.message||"";return r.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||n&&n.instance.defaultMessage instanceof Function&&(s=n.instance.defaultMessage(i)),[a,at.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),ct=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{c(n.next(t))}catch(t){a(t)}}function s(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,s)}c((n=n.apply(t,e||[])).next())}))},ut=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},lt=function(){function t(){}return t.prototype.validate=function(t,e,r){return this.coreValidate(t,e,r)},t.prototype.validateOrReject=function(t,e,r){return ct(this,void 0,void 0,(function(){var n;return ut(this,(function(o){switch(o.label){case 0:return[4,this.coreValidate(t,e,r)];case 1:return(n=o.sent()).length?[2,Promise.reject(n)]:[2]}}))}))},t.prototype.validateSync=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new st(this,"string"==typeof t?r:e);a.ignoreAsyncValidations=!0;var i=[];return a.execute(n,o,i),a.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new st(this,"string"==typeof t?r:e),i=[];return a.execute(n,o,i),Promise.all(a.awaitingPromises).then((function(){return a.stripEmptyErrors(i)}))},t}(),pt=new(function(){function t(){this.instances=[]}return t.prototype.get=function(t){var e=this.instances.find((function(e){return e.type===t}));return e||(e={type:t,object:new t},this.instances.push(e)),e.object},t}());function ft(t){return pt.get(t)}function dt(t,e,r){return"string"==typeof t?ft(lt).validate(t,e,r):ft(lt).validate(t,e)}function ht(t,e,r){return"string"==typeof t?ft(lt).validateSync(t,e,r):ft(lt).validateSync(t,e)}const yt=(t,e,r)=>{if(t&&"reportValidity"in t){const n=i(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},vt=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?yt(n.ref,r,t):n&&n.refs&&n.refs.forEach((e=>yt(e,r,t)))}},mt=(t,e)=>{e.shouldUseNativeValidation&&vt(t,e);const r={};for(const n in t){const o=i(e.fields,n),a=Object.assign(t[n]||{},{ref:o&&o.ref});if(gt(e.names||Object.keys(t),n)){const t=Object.assign({},i(r,n));s(t,"root",a),s(r,n,t)}else s(r,n,a)}return r},gt=(t,e)=>{const r=St(e);return t.some((t=>St(t).match(`^${r}\\.\\d+`)))};function St(t){return t.replace(/\]|\[/g,"")}var _t;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(_t||(_t={}));var Ot=new(function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,r){return this.findMetadatas(this._transformMetadatas,t,e).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?r===_t.CLASS_TO_CLASS||r===_t.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===_t.CLASS_TO_PLAIN))}))},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find((function(t){return t.options&&t.options.name===e}))},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),n=this._exposeMetadatas.get(t),o=n&&n.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===_t.CLASS_TO_CLASS||e===_t.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===_t.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===_t.CLASS_TO_CLASS||e===_t.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===_t.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,n=t.get(e);n&&(r=Array.from(n.values()).filter((function(t){return void 0!==t.propertyName})));for(var o=[],a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var u=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));o.push.apply(o,u)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var n=t.get(e);if(n){var o=n.get(r);if(o)return o}for(var a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var u=c.get(r);if(u)return u}}},t.prototype.findMetadatas=function(t,e,r){var n,o=t.get(e);o&&(n=o.get(r));for(var a=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],u=t.get(c);u&&u.has(r)&&a.push.apply(a,u.get(r))}return a.slice().reverse().concat((n||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}());var Et=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var wt=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,r,n,o,a){var i,s=this;if(void 0===a&&(a=0),Array.isArray(e)||e instanceof Set){var c=n&&this.transformationType===_t.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(n):[];return e.forEach((function(e,n){var o=t?t[n]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===_t.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(s.transformationType===_t.PLAIN_TO_CLASS){i=r.options.discriminator.subTypes.find((function(t){return t.name===e[r.options.discriminator.property]}));var u={newObject:c,object:e,property:void 0},l=r.typeFunction(u);i=void 0===i?l:i.value,r.options.keepDiscriminatorProperty||delete e[r.options.discriminator.property]}s.transformationType===_t.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===_t.CLASS_TO_PLAIN&&(e[r.options.discriminator.property]=r.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=r;var p=s.transform(o,e,i,void 0,e instanceof Map,a+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(r!==String||o){if(r!==Number||o){if(r!==Boolean||o){if((r===Date||e instanceof Date)&&!o)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||e instanceof Buffer)&&!o)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||o){if(o||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){r||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(r=e.constructor),!r&&t&&(r=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var u=this.getKeys(r,e,o),l=t||{};t||this.transformationType!==_t.PLAIN_TO_CLASS&&this.transformationType!==_t.CLASS_TO_CLASS||(l=o?new Map:r?new r:{});for(var p=function(n){if("__proto__"===n||"constructor"===n)return"continue";var i=n,s=n,c=n;if(!f.options.ignoreDecorators&&r)if(f.transformationType===_t.PLAIN_TO_CLASS)(u=Ot.findExposeMetadataByCustomName(r,n))&&(c=u.propertyName,s=u.propertyName);else if(f.transformationType===_t.CLASS_TO_PLAIN||f.transformationType===_t.CLASS_TO_CLASS){var u;(u=Ot.findExposeMetadata(r,n))&&u.options&&u.options.name&&(s=u.options.name)}var p=void 0;p=f.transformationType===_t.PLAIN_TO_CLASS?e[i]:e instanceof Map?e.get(i):e[i]instanceof Function?e[i]():e[i];var d=void 0,h=p instanceof Map;if(r&&o)d=r;else if(r){var y=Ot.findTypeMetadata(r,c);if(y){var v={newObject:l,object:e,property:c},m=y.typeFunction?y.typeFunction(v):y.reflectedType;y.options&&y.options.discriminator&&y.options.discriminator.property&&y.options.discriminator.subTypes?e[i]instanceof Array?d=y:(f.transformationType===_t.PLAIN_TO_CLASS&&(d=void 0===(d=y.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&y.options.discriminator.property in p)return t.name===p[y.options.discriminator.property]})))?m:d.value,y.options.keepDiscriminatorProperty||p&&p instanceof Object&&y.options.discriminator.property in p&&delete p[y.options.discriminator.property]),f.transformationType===_t.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===_t.CLASS_TO_PLAIN&&p&&(p[y.options.discriminator.property]=y.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=m,h=h||y.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===r&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===_t.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",r.prototype,c);g&&(d=g)}}var S=Array.isArray(e[i])?f.getReflectedType(r,c):void 0,_=t?t[i]:void 0;if(l.constructor.prototype){var O=Object.getOwnPropertyDescriptor(l.constructor.prototype,s);if((f.transformationType===_t.PLAIN_TO_CLASS||f.transformationType===_t.CLASS_TO_CLASS)&&(O&&!O.set||l[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===_t.CLASS_TO_CLASS){w=p;(void 0!==(w=f.applyCustomTransformations(w,r,n,e,f.transformationType))||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}}else{var E=f.transformationType===_t.PLAIN_TO_CLASS?s:n,w=void 0;f.transformationType===_t.CLASS_TO_PLAIN?(w=e[E],w=f.applyCustomTransformations(w,r,E,e,f.transformationType),w=e[E]===w?p:w,w=f.transform(_,w,d,S,h,a+1)):void 0===p&&f.options.exposeDefaultValues?w=l[s]:(w=f.transform(_,p,d,S,h,a+1),w=f.applyCustomTransformations(w,r,E,e,f.transformationType)),(void 0!==w||f.options.exposeUnsetFields)&&(l instanceof Map?l.set(s,w):l[s]=w)}},f=this,d=0,h=u;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}return e}return e}return new Promise((function(t,n){e.then((function(e){return t(s.transform(void 0,e,r,void 0,void 0,a+1))}),n)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,r,n,o){var a=this,i=Ot.findTransformMetadatas(e,r,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||a.checkGroups(t.options.groups)})):i.filter((function(t){return!t.options||!t.options.groups||!t.options.groups.length}))).forEach((function(e){t=e.transformFn({value:t,key:r,obj:n,type:o,options:a.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=Ot.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var n=this,o=Ot.getStrategy(t);"none"===o&&(o=this.options.strategy||"exposeAll");var a=[];if(("exposeAll"===o||r)&&(a=e instanceof Map?Array.from(e.keys()):Object.keys(e)),r)return a;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=Ot.getExposedProperties(t,this.transformationType),s=Ot.getExcludedProperties(t,this.transformationType);a=Et(Et([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=Ot.getExposedProperties(t,this.transformationType);this.transformationType===_t.PLAIN_TO_CLASS&&(i=i.map((function(e){var r=Ot.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e}))),a=this.options.excludeExtraneousValues?i:a.concat(i);var c=Ot.getExcludedProperties(t,this.transformationType);c.length>0&&(a=a.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(a=a.filter((function(e){var r=Ot.findExposeMetadata(t,e);return!r||!r.options||n.checkVersion(r.options.since,r.options.until)}))),a=this.options.groups&&this.options.groups.length?a.filter((function(e){var r=Ot.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)})):a.filter((function(e){var r=Ot.findExposeMetadata(t,e);return!(r&&r.options&&r.options.groups&&r.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(a=a.filter((function(t){return n.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),a=a.filter((function(t,e,r){return r.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),bt={enableCircularCheck:!1,enableImplicitConversion:!1,excludeExtraneousValues:!1,excludePrefixes:void 0,exposeDefaultValues:!1,exposeUnsetFields:!0,groups:void 0,ignoreDecorators:!1,strategy:void 0,targetMaps:void 0,version:void 0},Tt=function(){return Tt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Tt.apply(this,arguments)},Mt=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new wt(_t.CLASS_TO_PLAIN,Tt(Tt({},bt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new wt(_t.CLASS_TO_PLAIN,Tt(Tt({},bt),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,r){return new wt(_t.PLAIN_TO_CLASS,Tt(Tt({},bt),r)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new wt(_t.PLAIN_TO_CLASS,Tt(Tt({},bt),r)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new wt(_t.CLASS_TO_CLASS,Tt(Tt({},bt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new wt(_t.CLASS_TO_CLASS,Tt(Tt({},bt),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.instanceToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t.prototype.deserializeArray=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t}());function At(t,e,r,n){return void 0===r&&(r={}),void 0===n&&(n=""),t.reduce((function(t,r){var o=n?n+"."+r.property:r.property;if(r.constraints){var a=Object.keys(r.constraints)[0];t[o]={type:a,message:r.constraints[a]};var i=t[o];e&&i&&Object.assign(i,{types:r.constraints})}return r.children&&r.children.length&&At(r.children,e,t,o),t}),r)}function xt(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),function(n,o,a){try{var i=e.validator,s=(c=t,u=n,l=e.transformer,Mt.plainToInstance(c,u,l));return Promise.resolve(("sync"===r.mode?ht:dt)(s,i)).then((function(t){return t.length?{values:{},errors:mt(At(t,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&vt({},a),{values:r.raw?Object.assign({},n):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,u,l}}function Nt(t,e){const r=rt().getTargetValidationMetadatas(e,"",!1,!1),n=function(t){return Reflect.getMetadata(D,t)}(e);return{resolver:xt(e),fields:Array.from(new Set(r.map((t=>t.propertyName)))),inputs:K(e),cells:U(e),crud:n,path:"/"+(n?.controller??t)}}function Ct({children:r,init:n}){return e((()=>{!function({crud:t,fetch:e,screenPaths:r}){const n={};Object.entries(t).forEach((([t,e])=>{n[t]=Nt(t,e)})),O(n),S.setState({fetchSettings:{baseUrl:e.baseURL},screenPaths:r})}(n())}),[n]),t.createElement(W,null,r)}export{$ as Cell,F as Crud,B as Input,H as Layout,_ as Login,Ct as Panel,O as createScreens,L as useScreens};
@@ -1,2 +1,2 @@
1
1
  import { InitPanelOptions } from "./types/initPanelOptions";
2
- export declare function initPanel({ crud, fetch }: InitPanelOptions): void;
2
+ export declare function initPanel({ crud, fetch, screenPaths }: InitPanelOptions): void;
@@ -1,9 +1,15 @@
1
1
  import { ScreenCreatorData } from "../types/ScreenCreatorData";
2
+ interface User {
3
+ username: string;
4
+ }
2
5
  interface AppState {
6
+ user: User | null;
3
7
  screens: Record<string, ScreenCreatorData> | null;
4
8
  fetchSettings: {
5
9
  baseUrl: string;
6
10
  } | null;
11
+ screenPaths: Record<string, string>;
12
+ token: string | null;
7
13
  }
8
14
  export declare const useAppStore: import("zustand/traditional").UseBoundStoreWithEqualityFn<Omit<import("zustand/vanilla").StoreApi<AppState>, "persist"> & {
9
15
  persist: {
@@ -4,5 +4,6 @@ export interface InitPanelOptions {
4
4
  fetch: {
5
5
  baseURL: string;
6
6
  };
7
+ screenPaths: Record<string, string>;
7
8
  }
8
9
  export {};
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "proje-react-panel",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "author": "SEFA DEMİR",
6
6
  "license": "ISC",
7
7
  "main": "dist/index.cjs.js",
8
8
  "module": "dist/index.esm.js",
9
9
  "source": "src/index.ts",
10
- "types": "dist/index.d.t s",
10
+ "types": "dist/index.d.ts",
11
11
  "scripts": {
12
12
  "test": "echo \"Error: no test specified\" && exit 1",
13
13
  "build": "rollup -c ",
@@ -0,0 +1,14 @@
1
+ export const AuthApi = {
2
+ login: (fetchSettings: { baseUrl: string }, username: string, password: string) => {
3
+ return fetch(`${fetchSettings.baseUrl}/auth/login`, {
4
+ method: "POST",
5
+ body: JSON.stringify({ username, password }),
6
+ headers: { "Content-Type": "application/json" },
7
+ }).then((res) => {
8
+ if (res.ok) {
9
+ return res.json();
10
+ }
11
+ throw res;
12
+ });
13
+ },
14
+ };
@@ -1,12 +1,18 @@
1
- import axios from "axios";
1
+ interface FetchOptions {
2
+ token: string;
3
+ baseUrl: string;
4
+ }
2
5
 
3
6
  export const CrudApi = {
4
- getList: (fetchSettings: { baseUrl: string }, api: string) => {
5
- return fetch(`${fetchSettings.baseUrl}/${api}`, {
7
+ getList: (options: FetchOptions, api: string) => {
8
+ return fetch(`${options.baseUrl}/${api}`, {
6
9
  method: "GET",
7
- headers: { "Content-Type": "application/json" },
10
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${options.token}` },
8
11
  }).then((res) => {
9
- return res.json();
12
+ if (res.ok) {
13
+ return res.json();
14
+ }
15
+ throw res;
10
16
  });
11
17
  },
12
18
  create: (fetchSettings: { baseUrl: string }, api: string, data: any) => {
@@ -1,6 +1,26 @@
1
1
  import React from "react";
2
+ //TODO: create, edit, details
3
+ export function ErrorComponent({ error }: { error: unknown | Response }) {
4
+ const getErrorMessage = (errorInner: unknown | Response) => {
5
+ if (errorInner instanceof Response) {
6
+ switch (errorInner.status) {
7
+ case 400:
8
+ return "Bad Request: The request was invalid or malformed.";
9
+ case 401:
10
+ return "Unauthorized: Please log in to access this resource.";
11
+ case 404:
12
+ return "Not Found: The requested resource could not be found.";
13
+ case 403:
14
+ return "Forbidden: You don't have permission to access this resource.";
15
+ case 500:
16
+ return "Internal Server Error: Something went wrong on our end.";
17
+ default:
18
+ return `Error ${errorInner.status}: ${errorInner.statusText || "Something went wrong."}`;
19
+ }
20
+ }
21
+ return (errorInner as { message?: string })?.message || "Something went wrong. Please try again later.";
22
+ };
2
23
 
3
- export function ErrorComponent({ error }: { error: unknown }) {
4
24
  return (
5
25
  <div className="error-container">
6
26
  <div className="error-icon">
@@ -8,7 +28,7 @@ export function ErrorComponent({ error }: { error: unknown }) {
8
28
  </div>
9
29
  <div className="error-content">
10
30
  <h3>Error Occurred</h3>
11
- <p>{(error as { message?: string })?.message || "Something went wrong. Please try again later."}</p>
31
+ <p>{getErrorMessage(error)}</p>
12
32
  </div>
13
33
  </div>
14
34
  );
@@ -2,7 +2,7 @@ import React, { useEffect } from "react";
2
2
  import { Screen } from "../types/Screen";
3
3
  import { useForm } from "react-hook-form";
4
4
  import { useNavigate } from "react-router";
5
- import { CrudApi } from "../api/crudApi";
5
+ import { CrudApi } from "../api/CrudApi";
6
6
  import { useAppStore } from "../store/store";
7
7
  import { InputOptions } from "../decorators/Input";
8
8
  import { FormField } from "./FormField";
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
2
  import { SideBar } from "./SideBar";
3
3
  import { ScreenCreatorData } from "../../types/ScreenCreatorData";
4
+ import { useAppStore } from "../../store/store";
5
+ import { useNavigate } from "react-router";
4
6
 
5
7
  export function Layout<IconType>({
6
8
  children,
@@ -11,6 +13,15 @@ export function Layout<IconType>({
11
13
  menu?: (screens: Record<string, ScreenCreatorData>) => { name: string; path: string; iconType: IconType }[];
12
14
  getIcons?: (iconType: IconType) => React.ReactNode;
13
15
  }) {
16
+ const { user, screenPaths } = useAppStore((s) => ({
17
+ user: s.user,
18
+ screenPaths: s.screenPaths,
19
+ }));
20
+ const navigate = useNavigate();
21
+ if (!user) {
22
+ navigate(screenPaths.login);
23
+ }
24
+
14
25
  return (
15
26
  <div className="layout">
16
27
  <SideBar menu={menu} getIcons={getIcons} />
@@ -1,6 +1,6 @@
1
1
  import { useParams } from "react-router";
2
2
  import React, { useEffect, useState } from "react";
3
- import { CrudApi } from "../../api/crudApi";
3
+ import { CrudApi } from "../../api/CrudApi";
4
4
  import { Screen } from "../../types/Screen";
5
5
  import { useAppStore } from "../../store/store";
6
6
  import { ErrorComponent } from "../ErrorComponent";
@@ -2,7 +2,7 @@ import { Form } from "../Form";
2
2
  import React, { useEffect, useState } from "react";
3
3
  import { Screen } from "../../types/Screen";
4
4
  import { useParams } from "react-router";
5
- import { CrudApi } from "../../api/crudApi";
5
+ import { CrudApi } from "../../api/CrudApi";
6
6
  import { useAppStore } from "../../store/store";
7
7
  import { ErrorComponent } from "../ErrorComponent";
8
8
 
@@ -1,24 +1,25 @@
1
1
  import React from "react";
2
2
  import { Screen } from "../../types/Screen";
3
3
  import { useEffect, useState } from "react";
4
- import { CrudApi } from "../../api/crudApi";
4
+ import { CrudApi } from "../../api/CrudApi";
5
5
  import { Link } from "react-router";
6
6
  import { List } from "../list/List";
7
7
  import { useAppStore } from "../../store/store";
8
8
  import { ErrorComponent } from "../ErrorComponent";
9
9
 
10
10
  export function ControllerList({ screen }: { screen: Screen }) {
11
- const { screens, fetchSettings } = useAppStore((s) => ({
11
+ const { screens, fetchSettings, token } = useAppStore((s) => ({
12
12
  screens: s.screens ?? {},
13
13
  fetchSettings: s.fetchSettings,
14
+ token: s.token,
14
15
  }));
15
16
  const [page, setPage] = useState(0);
16
17
  const [data, setData] = useState<any>(null);
17
18
  const [error, setError] = useState(null);
18
19
 
19
20
  useEffect(() => {
20
- if (screen.controller && fetchSettings) {
21
- CrudApi.getList(fetchSettings, screen.controller)
21
+ if (screen.controller && fetchSettings && token) {
22
+ CrudApi.getList({ ...fetchSettings, token }, screen.controller)
22
23
  .then((res) => {
23
24
  setData(res);
24
25
  })
@@ -1,23 +1,29 @@
1
1
  import React from "react";
2
2
  import { useForm } from "react-hook-form";
3
3
  import { FormField } from "../FormField";
4
- import { Screen } from "../../types/Screen";
5
- import "../../styles/login.scss";
4
+ import { AuthApi } from "../../api/AuthApi";
5
+ import { useAppStore } from "../../store/store";
6
+ import { useNavigate } from "react-router";
6
7
 
7
8
  interface LoginFormData {
8
- email: string;
9
+ username: string;
9
10
  password: string;
10
11
  }
11
- function Login() {
12
+
13
+ export function Login() {
12
14
  const {
13
15
  register,
14
16
  handleSubmit,
15
17
  formState: { errors },
16
18
  } = useForm<LoginFormData>();
17
-
19
+ const { fetchSettings } = useAppStore((s) => ({ fetchSettings: s.fetchSettings }));
20
+ const navigate = useNavigate();
18
21
  const onSubmit = async (data: LoginFormData) => {
19
- // TODO: Implement login logic
20
- console.log("Login attempt:", data);
22
+ AuthApi.login(fetchSettings!, data.username, data.password).then((dataInner) => {
23
+ const { access_token, admin } = dataInner;
24
+ useAppStore.setState({ user: admin, token: access_token });
25
+ navigate("/");
26
+ });
21
27
  };
22
28
 
23
29
  return (
@@ -30,14 +36,14 @@ function Login() {
30
36
  <form onSubmit={handleSubmit(onSubmit)} className="login-form">
31
37
  <FormField
32
38
  input={{
33
- name: "email",
34
- label: "Email",
35
- inputType: "email",
36
- placeholder: "Enter your email",
39
+ name: "username",
40
+ label: "Username",
41
+ inputType: "text",
42
+ placeholder: "Enter your username",
37
43
  }}
38
44
  register={register}
39
45
  isEditForm={false}
40
- error={errors.email}
46
+ error={errors.username}
41
47
  />
42
48
  <FormField
43
49
  input={{
@@ -60,5 +66,3 @@ function Login() {
60
66
  </div>
61
67
  );
62
68
  }
63
-
64
- export default Login;
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { Login } from "./components/screens/Login";
1
2
  export { type InitPanelOptions } from "./types/initPanelOptions";
2
3
  export { type ScreenCreatorData } from "./types/ScreenCreatorData";
3
4
  export { createScreens } from "./utils/createScreens";
package/src/initPanel.ts CHANGED
@@ -4,11 +4,11 @@ import { ScreenCreatorData } from "./types/ScreenCreatorData";
4
4
  import { InitPanelOptions } from "./types/initPanelOptions";
5
5
  import { useAppStore } from "./store/store";
6
6
 
7
- export function initPanel({ crud, fetch }: InitPanelOptions) {
7
+ export function initPanel({ crud, fetch, screenPaths }: InitPanelOptions) {
8
8
  const screensCrudOptions: Record<string, ScreenCreatorData> = {};
9
9
  Object.entries(crud).forEach(([key, value]) => {
10
10
  screensCrudOptions[key] = getFields(key, value);
11
11
  });
12
12
  createScreens(screensCrudOptions);
13
- useAppStore.setState({ fetchSettings: { baseUrl: fetch.baseURL } });
13
+ useAppStore.setState({ fetchSettings: { baseUrl: fetch.baseURL }, screenPaths });
14
14
  }
@@ -3,16 +3,35 @@ import { createWithEqualityFn } from "zustand/traditional";
3
3
  import { shallow } from "zustand/vanilla/shallow";
4
4
  import { ScreenCreatorData } from "../types/ScreenCreatorData";
5
5
 
6
+ interface User {
7
+ username: string;
8
+ }
9
+
6
10
  interface AppState {
11
+ user: User | null;
7
12
  screens: Record<string, ScreenCreatorData> | null;
8
13
  fetchSettings: { baseUrl: string } | null;
14
+ screenPaths: Record<string, string>;
15
+ token: string | null;
9
16
  }
10
17
 
11
18
  export const useAppStore = createWithEqualityFn<AppState>()(
12
- persist((_) => ({ screens: null, fetchSettings: null }), {
13
- name: "app-store-1",
14
- storage: createJSONStorage(() => localStorage),
15
- partialize: (_) => ({}),
16
- }),
19
+ persist(
20
+ (_) => ({
21
+ screens: null,
22
+ user: null,
23
+ fetchSettings: null,
24
+ screenPaths: {},
25
+ token: null,
26
+ }),
27
+ {
28
+ name: "app-store-1",
29
+ storage: createJSONStorage(() => localStorage),
30
+ partialize: (state) => ({
31
+ user: state.user,
32
+ token: state.token,
33
+ }),
34
+ }
35
+ ),
17
36
  shallow
18
37
  );
@@ -2,6 +2,7 @@
2
2
  @use './form';
3
3
  @use './layout';
4
4
  @use './list';
5
+ @use './login';
5
6
  @use './error-boundary';
6
7
 
7
8
  .layout{
@@ -3,15 +3,15 @@
3
3
  justify-content: center;
4
4
  align-items: center;
5
5
  min-height: 100vh;
6
- background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
6
+ background: linear-gradient(135deg, #1a1a1a 0%, #2d3436 100%);
7
7
  padding: 20px;
8
8
 
9
9
  .login-panel {
10
10
  width: 100%;
11
11
  max-width: 400px;
12
- background: white;
12
+ background: #2c2c2c;
13
13
  border-radius: 12px;
14
- box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
14
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
15
15
  padding: 32px;
16
16
  }
17
17
 
@@ -21,12 +21,12 @@
21
21
 
22
22
  h1 {
23
23
  font-size: 24px;
24
- color: #333;
24
+ color: #ffffff;
25
25
  margin-bottom: 8px;
26
26
  }
27
27
 
28
28
  p {
29
- color: #666;
29
+ color: #b3b3b3;
30
30
  font-size: 14px;
31
31
  }
32
32
  }
@@ -34,30 +34,33 @@
34
34
  .login-form {
35
35
  display: flex;
36
36
  flex-direction: column;
37
- gap: 20px;
37
+ align-items: center;
38
38
 
39
39
  .form-field {
40
+ width: 100%;
40
41
  margin-bottom: 16px;
41
42
 
42
43
  label {
43
44
  display: block;
44
45
  margin-bottom: 8px;
45
- color: #333;
46
+ color: #ffffff;
46
47
  font-weight: 500;
47
48
  }
48
49
 
49
50
  input {
50
51
  width: 100%;
51
- padding: 12px;
52
- border: 1px solid #e1e1e1;
52
+ box-sizing: border-box;
53
+ padding: 12px 16px;
54
+ border: 1px solid #404040;
53
55
  border-radius: 8px;
54
56
  font-size: 14px;
57
+ background: #363636;
58
+ color: #ffffff;
55
59
  transition: border-color 0.2s ease;
56
-
57
60
  &:focus {
58
61
  outline: none;
59
- border-color: #007bff;
60
- box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
62
+ border-color: #0066cc;
63
+ box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
61
64
  }
62
65
  }
63
66
  }
@@ -68,7 +71,7 @@
68
71
  .submit-button {
69
72
  width: 100%;
70
73
  padding: 12px;
71
- background: #007bff;
74
+ background: #0066cc;
72
75
  color: white;
73
76
  border: none;
74
77
  border-radius: 8px;
@@ -78,7 +81,7 @@
78
81
  transition: background-color 0.2s ease;
79
82
 
80
83
  &:hover {
81
- background: #0056b3;
84
+ background: #0052a3;
82
85
  }
83
86
 
84
87
  &:active {
@@ -87,4 +90,4 @@
87
90
  }
88
91
  }
89
92
  }
90
- }
93
+ }
@@ -5,4 +5,5 @@ export interface InitPanelOptions {
5
5
  fetch: {
6
6
  baseURL: string;
7
7
  };
8
+ screenPaths: Record<string, string>;
8
9
  }