proje-react-panel 1.0.12 → 1.0.14-test-1

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.
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
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])};
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=u();console.log("-----\x3e"),console.log(s);const c=a.useNavigate();return o||c(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.esm.js CHANGED
@@ -1 +1 @@
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
+ 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=S();console.log("-----\x3e"),console.log(i);const s=f();return o||s(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};
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "proje-react-panel",
3
- "version": "1.0.12",
3
+ "version": "1.0.14-test-1",
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 ",
@@ -17,6 +17,9 @@ export function Layout<IconType>({
17
17
  user: s.user,
18
18
  screenPaths: s.screenPaths,
19
19
  }));
20
+ const data = useAppStore();
21
+ console.log("----->");
22
+ console.log(data);
20
23
  const navigate = useNavigate();
21
24
  if (!user) {
22
25
  navigate(screenPaths.login);
@@ -1,9 +1,9 @@
1
- @use './sidebar';
2
- @use './form';
3
- @use './layout';
4
- @use './list';
5
- @use './login';
6
- @use './error-boundary';
1
+ @import './sidebar';
2
+ @import './form';
3
+ @import './layout';
4
+ @import './list';
5
+ @import './login';
6
+ @import './error-boundary';
7
7
 
8
8
  .layout{
9
9
  a {