proje-react-panel 1.0.16 → 1.0.17-test2
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/components/components/list/Datagrid.d.ts +3 -7
- package/dist/components/components/list/FilterPopup.d.ts +3 -3
- package/dist/components/components/list/ListPage.d.ts +1 -3
- package/dist/decorators/list/List.d.ts +5 -6
- package/dist/decorators/list/ListData.d.ts +4 -4
- package/dist/decorators/list/getListFields.d.ts +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/types/ScreenCreatorData.d.ts +5 -5
- package/package.json +1 -1
- package/src/components/components/list/Datagrid.tsx +24 -18
- package/src/components/components/list/FilterPopup.tsx +4 -4
- package/src/components/components/list/ListPage.tsx +4 -4
- package/src/decorators/list/List.ts +8 -7
- package/src/decorators/list/ListData.ts +5 -5
- package/src/decorators/list/getListFields.ts +8 -8
- package/src/styles/index.scss +11 -12
- package/src/types/ScreenCreatorData.ts +12 -12
@@ -1,13 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { ListData } from '../../../decorators/list/ListData';
|
3
|
-
interface DatagridProps<T
|
4
|
-
id: string;
|
5
|
-
}> {
|
3
|
+
interface DatagridProps<T> {
|
6
4
|
data: T[];
|
7
|
-
listData: ListData
|
5
|
+
listData: ListData<T>;
|
8
6
|
onRemoveItem?: (item: T) => Promise<void>;
|
9
7
|
}
|
10
|
-
export declare function Datagrid<T
|
11
|
-
id: string;
|
12
|
-
}>({ data, listData, onRemoveItem }: DatagridProps<T>): React.JSX.Element;
|
8
|
+
export declare function Datagrid<T>({ data, listData, onRemoveItem }: DatagridProps<T>): React.JSX.Element;
|
13
9
|
export {};
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { ListData } from '../../../decorators/list/ListData';
|
3
|
-
interface FilterPopupProps {
|
3
|
+
interface FilterPopupProps<T> {
|
4
4
|
isOpen: boolean;
|
5
5
|
onClose: () => void;
|
6
6
|
onApplyFilters: (filters: Record<string, string>) => void;
|
7
|
-
listData: ListData
|
7
|
+
listData: ListData<T>;
|
8
8
|
activeFilters?: Record<string, string>;
|
9
9
|
}
|
10
|
-
export declare function FilterPopup({ isOpen, onClose, onApplyFilters, listData, activeFilters, }: FilterPopupProps): React.ReactElement | null;
|
10
|
+
export declare function FilterPopup<T>({ isOpen, onClose, onApplyFilters, listData, activeFilters, }: FilterPopupProps<T>): React.ReactElement | null;
|
11
11
|
export {};
|
@@ -12,9 +12,7 @@ export interface PaginatedResponse<T> {
|
|
12
12
|
limit: number;
|
13
13
|
}
|
14
14
|
export type GetDataForList<T> = (params: GetDataParams) => Promise<PaginatedResponse<T>>;
|
15
|
-
export declare function ListPage<T extends AnyClass
|
16
|
-
id: string;
|
17
|
-
}>({ model, getData, onRemoveItem, customHeader, }: {
|
15
|
+
export declare function ListPage<T extends AnyClass>({ model, getData, onRemoveItem, customHeader, }: {
|
18
16
|
model: T;
|
19
17
|
getData: GetDataForList<T>;
|
20
18
|
customHeader?: React.ReactNode;
|
@@ -6,7 +6,7 @@ export interface ListHeaderOptions {
|
|
6
6
|
label: string;
|
7
7
|
};
|
8
8
|
}
|
9
|
-
export interface
|
9
|
+
export interface ListCellOptions<T> {
|
10
10
|
details?: {
|
11
11
|
path: string;
|
12
12
|
label: string;
|
@@ -16,13 +16,12 @@ export interface ListUtilCellOptions {
|
|
16
16
|
label: string;
|
17
17
|
};
|
18
18
|
delete?: {
|
19
|
-
path: string;
|
20
19
|
label: string;
|
21
20
|
};
|
22
21
|
}
|
23
|
-
export interface ListOptions {
|
22
|
+
export interface ListOptions<T> {
|
24
23
|
headers?: ListHeaderOptions;
|
25
|
-
|
24
|
+
cells?: ((item: T) => ListCellOptions<T>) | ListCellOptions<T>;
|
26
25
|
}
|
27
|
-
export declare function List(options?: ListOptions): ClassDecorator;
|
28
|
-
export declare function getClassListData(entityClass:
|
26
|
+
export declare function List<T>(options?: ListOptions<T> | ((item: T) => ListOptions<T>)): ClassDecorator;
|
27
|
+
export declare function getClassListData<T>(entityClass: T): ListOptions<T> | undefined;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { ListOptions } from
|
2
|
-
import { CellOptions } from
|
3
|
-
export interface ListData {
|
4
|
-
list?: ListOptions
|
1
|
+
import { ListOptions } from './List';
|
2
|
+
import { CellOptions } from './Cell';
|
3
|
+
export interface ListData<T> {
|
4
|
+
list?: ListOptions<T>;
|
5
5
|
cells: CellOptions[];
|
6
6
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { ListData } from
|
2
|
-
export declare function getListFields<T>(entityClass: T): ListData
|
1
|
+
import { ListData } from './ListData';
|
2
|
+
export declare function getListFields<T>(entityClass: T): ListData<T>;
|
package/dist/index.cjs.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var e=require("react"),t=require("react-router"),n=require("react-select"),r=require("react-hook-form"),a=require("zustand/middleware"),o=require("zustand/traditional"),i=require("zustand/vanilla/shallow");function s(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var c=s(e);const l=()=>e.createElement("div",{className:"empty-list"},e.createElement("div",{className:"empty-list-content"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),e.createElement("polyline",{points:"13 2 13 9 20 9"})),e.createElement("h3",null,"No Data Found"),e.createElement("p",null,"There are no items to display at the moment.")));var u,p;function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f.apply(null,arguments)}var d,h,m=function(e){return c.createElement("svg",f({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),u||(u=c.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),p||(p=c.createElement("path",{d:"m21 19-5.154-5.154a7 7 0 1 0-2 2L19 21zM5 10c0-2.757 2.243-5 5-5s5 2.243 5 5-2.243 5-5 5-5-2.243-5-5"})))};function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v.apply(null,arguments)}var y,g,E=function(e){return c.createElement("svg",v({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),d||(d=c.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),h||(h=c.createElement("path",{d:"m13 6 5 5-9.507 9.507a1.765 1.765 0 0 1-.012-2.485l-.002-.003c-.69.676-1.8.673-2.485-.013a1.763 1.763 0 0 1-.036-2.455l-.008-.008c-.694.65-1.78.64-2.456-.036zm7.586-.414-2.172-2.172a2 2 0 0 0-2.828 0L14 5l5 5 1.586-1.586c.78-.78.78-2.047 0-2.828M3 18v3h3a3 3 0 0 0-3-3"})))};function b(){return b=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},b.apply(null,arguments)}var w=function(e){return c.createElement("svg",b({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),y||(y=c.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),g||(g=c.createElement("path",{d:"M6.187 8h11.625l-.695 11.125A2 2 0 0 1 15.12 21H8.88a2 2 0 0 1-1.997-1.875zM19 5v2H5V5h3V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1zm-9 0h4V4h-4z"})))};function O({data:n,listData:r,onRemoveItem:a}){const o=r.cells,i=r.list?.utilCells;return e.createElement("div",{className:"datagrid"},n&&0!==n.length?e.createElement("table",{className:"datagrid-table"},e.createElement("thead",null,e.createElement("tr",null,o.map((t=>e.createElement("th",{key:t.name},t.title??t.name))),i?.details&&e.createElement("th",null,"Details"),i?.edit&&e.createElement("th",null,"Edit"),i?.delete&&e.createElement("th",null,"Delete"))),e.createElement("tbody",null,n.map(((n,r)=>e.createElement("tr",{key:r},o.map((t=>{const r=n[t.name];let a=r??"-";switch(t.type){case"date":if(r){const e=new Date(r);a=`${e.getDate().toString().padStart(2,"0")}/${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getFullYear()} ${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}`}break;case"image":{const n=t;a=e.createElement("img",{width:100,height:100,src:n.baseUrl+r,style:{objectFit:"contain"}});break}default:a=r?r.toString():t?.placeHolder??"-"}return e.createElement("td",{key:t.name},a)})),i?.details&&e.createElement("td",null,e.createElement(t.Link,{to:`${i.details.path}/${n.id}`,className:"util-cell-link"},e.createElement(m,{className:"icon icon-search"}),e.createElement("span",{className:"util-cell-label"},i.details.label))),i?.edit&&e.createElement("td",null,e.createElement(t.Link,{to:`${i.edit.path}/${n.id}`,className:"util-cell-link"},e.createElement(E,{className:"icon icon-pencil"}),e.createElement("span",{className:"util-cell-label"},i.edit.label))),i?.delete&&e.createElement("td",null,e.createElement("a",{onClick:()=>{a?.(n)},className:"util-cell-link"},e.createElement(w,{className:"icon icon-trash"}),e.createElement("span",{className:"util-cell-label"},i.delete.label)))))))):e.createElement(l,null))}function S({error:t}){return e.createElement("div",{className:"error-container"},e.createElement("div",{className:"error-icon"},e.createElement("i",{className:"fa fa-exclamation-circle"})),e.createElement("div",{className:"error-content"},e.createElement("h3",null,"Error Occurred"),e.createElement("p",null,(e=>{if(e instanceof Response)switch(e.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 ${e.status}: ${e.statusText||"Something went wrong."}`}return e?.message||"Something went wrong. Please try again later."})(t))))}function _(){return e.createElement("div",{className:"loading-screen"},e.createElement("div",{className:"loading-container"},e.createElement("div",{className:"loading-spinner"}),e.createElement("div",{className:"loading-text"},"Loading...")))}var M,x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},N={};!function(){return M||(M=1,function(e){!function(){var t="object"==typeof globalThis?globalThis:"object"==typeof x?x:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=r(e);function r(e,t){return function(n,r){Object.defineProperty(e,n,{configurable:!0,writable:!0,value:r}),t&&t(n,r)}}void 0!==t.Reflect&&(n=r(t.Reflect,n)),function(e,t){var n=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,a=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=r&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,l={create:i?function(){return pe(Object.create(null))}:s?function(){return pe({__proto__:null})}:function(){return pe({})},has:c?function(e,t){return n.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return n.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:le(),d="function"==typeof WeakMap?WeakMap:ue(),h=r?Symbol.for("@reflect-metadata:registry"):void 0,m=ae(),v=oe(m);function y(e,t,n,r){if(F(n)){if(!K(e))throw new TypeError;if(!G(t))throw new TypeError;return N(e,t)}if(!K(e))throw new TypeError;if(!z(t))throw new TypeError;if(!z(r)&&!F(r)&&!D(r))throw new TypeError;return D(r)&&(r=void 0),T(e,t,n=q(n),r)}function g(e,t){function n(n,r){if(!z(n))throw new TypeError;if(!F(r)&&!J(r))throw new TypeError;P(e,t,n,r)}return n}function E(e,t,n,r){if(!z(n))throw new TypeError;return F(r)||(r=q(r)),P(e,t,n,r)}function b(e,t,n){if(!z(t))throw new TypeError;return F(n)||(n=q(n)),A(e,t,n)}function w(e,t,n){if(!z(t))throw new TypeError;return F(n)||(n=q(n)),C(e,t,n)}function O(e,t,n){if(!z(t))throw new TypeError;return F(n)||(n=q(n)),k(e,t,n)}function S(e,t,n){if(!z(t))throw new TypeError;return F(n)||(n=q(n)),L(e,t,n)}function _(e,t){if(!z(e))throw new TypeError;return F(t)||(t=q(t)),I(e,t)}function M(e,t){if(!z(e))throw new TypeError;return F(t)||(t=q(t)),j(e,t)}function x(e,t,n){if(!z(t))throw new TypeError;if(F(n)||(n=q(n)),!z(t))throw new TypeError;F(n)||(n=q(n));var r=se(t,n,!1);return!F(r)&&r.OrdinaryDeleteMetadata(e,t,n)}function N(e,t){for(var n=e.length-1;n>=0;--n){var r=(0,e[n])(t);if(!F(r)&&!D(r)){if(!G(r))throw new TypeError;t=r}}return t}function T(e,t,n,r){for(var a=e.length-1;a>=0;--a){var o=(0,e[a])(t,n,r);if(!F(o)&&!D(o)){if(!z(o))throw new TypeError;r=o}}return r}function A(e,t,n){if(C(e,t,n))return!0;var r=ne(t);return!D(r)&&A(e,r,n)}function C(e,t,n){var r=se(t,n,!1);return!F(r)&&H(r.OrdinaryHasOwnMetadata(e,t,n))}function k(e,t,n){if(C(e,t,n))return L(e,t,n);var r=ne(t);return D(r)?void 0:k(e,r,n)}function L(e,t,n){var r=se(t,n,!1);if(!F(r))return r.OrdinaryGetOwnMetadata(e,t,n)}function P(e,t,n,r){se(n,r,!0).OrdinaryDefineOwnMetadata(e,t,n,r)}function I(e,t){var n=j(e,t),r=ne(e);if(null===r)return n;var a=I(r,t);if(a.length<=0)return n;if(n.length<=0)return a;for(var o=new f,i=[],s=0,c=n;s<c.length;s++){var l=c[s];o.has(l)||(o.add(l),i.push(l))}for(var u=0,p=a;u<p.length;u++){l=p[u];o.has(l)||(o.add(l),i.push(l))}return i}function j(e,t){var n=se(e,t,!1);return n?n.OrdinaryOwnMetadataKeys(e,t):[]}function V(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function F(e){return void 0===e}function D(e){return null===e}function R(e){return"symbol"==typeof e}function z(e){return"object"==typeof e?null!==e:"function"==typeof e}function B(e,t){switch(V(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var n="string",r=Q(e,a);if(void 0!==r){var o=r.call(e,n);if(z(o))throw new TypeError;return o}return $(e)}function $(e,t){var n,r,a=e.toString;if(W(a)&&!z(r=a.call(e)))return r;if(W(n=e.valueOf)&&!z(r=n.call(e)))return r;throw new TypeError}function H(e){return!!e}function U(e){return""+e}function q(e){var t=B(e);return R(t)?t:U(t)}function K(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function W(e){return"function"==typeof e}function G(e){return"function"==typeof e}function J(e){switch(V(e)){case 3:case 4:return!0;default:return!1}}function Y(e,t){return e===t||e!=e&&t!=t}function Q(e,t){var n=e[t];if(null!=n){if(!W(n))throw new TypeError;return n}}function X(e){var t=Q(e,o);if(!W(t))throw new TypeError;var n=t.call(e);if(!z(n))throw new TypeError;return n}function Z(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function ne(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===u)return t;if(t!==u)return t;var n=e.prototype,r=n&&Object.getPrototypeOf(n);if(null==r||r===Object.prototype)return t;var a=r.constructor;return"function"!=typeof a||a===e?t:a}function re(){var e,n,r,a;F(h)||void 0===t.Reflect||h in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=ie(t.Reflect));var o=new d,i={registerProvider:s,getProvider:l,setProvider:m};return i;function s(t){if(!Object.isExtensible(i))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case F(n):n=t;break;case n===t:break;case F(r):r=t;break;case r===t:break;default:void 0===a&&(a=new f),a.add(t)}}function c(t,o){if(!F(n)){if(n.isProviderFor(t,o))return n;if(!F(r)){if(r.isProviderFor(t,o))return n;if(!F(a))for(var i=X(a);;){var s=ee(i);if(!s)return;var c=Z(s);if(c.isProviderFor(t,o))return te(i),c}}}if(!F(e)&&e.isProviderFor(t,o))return e}function l(e,t){var n,r=o.get(e);return F(r)||(n=r.get(t)),F(n)?(F(n=c(e,t))||(F(r)&&(r=new p,o.set(e,r)),r.set(t,n)),n):n}function u(e){if(F(e))throw new TypeError;return n===e||r===e||!F(a)&&a.has(e)}function m(e,t,n){if(!u(n))throw new Error("Metadata provider not registered.");var r=l(e,t);if(r!==n){if(!F(r))return!1;var a=o.get(e);F(a)&&(a=new p,o.set(e,a)),a.set(t,n)}return!0}}function ae(){var e;return!F(h)&&z(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[h]),F(e)&&(e=re()),!F(h)&&z(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function oe(e){var t=new d,n={isProviderFor:function(e,n){var r=t.get(e);return!F(r)&&r.has(n)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:a,OrdinaryGetOwnMetadata:o,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return m.registerProvider(n),n;function r(r,a,o){var i=t.get(r),s=!1;if(F(i)){if(!o)return;i=new p,t.set(r,i),s=!0}var c=i.get(a);if(F(c)){if(!o)return;if(c=new p,i.set(a,c),!e.setProvider(r,a,n))throw i.delete(a),s&&t.delete(r),new Error("Wrong provider for target.")}return c}function a(e,t,n){var a=r(t,n,!1);return!F(a)&&H(a.has(e))}function o(e,t,n){var a=r(t,n,!1);if(!F(a))return a.get(e)}function i(e,t,n,a){r(n,a,!0).set(e,t)}function s(e,t){var n=[],a=r(e,t,!1);if(F(a))return n;for(var o=X(a.keys()),i=0;;){var s=ee(o);if(!s)return n.length=i,n;var c=Z(s);try{n[i]=c}catch(e){try{te(o)}finally{throw e}}i++}}function c(e,n,a){var o=r(n,a,!1);if(F(o))return!1;if(!o.delete(e))return!1;if(0===o.size){var i=t.get(n);F(i)||(i.delete(a),0===i.size&&t.delete(i))}return!0}}function ie(e){var t=e.defineMetadata,n=e.hasOwnMetadata,r=e.getOwnMetadata,a=e.getOwnMetadataKeys,o=e.deleteMetadata,i=new d;return{isProviderFor:function(e,t){var n=i.get(e);return!(F(n)||!n.has(t))||!!a(e,t).length&&(F(n)&&(n=new f,i.set(e,n)),n.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:o}}function se(e,t,n){var r=m.getProvider(e,t);if(!F(r))return r;if(n){if(m.setProvider(e,t,v))return v;throw new Error("Illegal state.")}}function ce(){var e={},t=[],n=function(){function e(e,t,n){this._index=0,this._keys=e,this._values=t,this._selector=n}return e.prototype["@@iterator"]=function(){return this},e.prototype[o]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var n=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:n,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}(),r=function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var n=this._find(e,!0);return this._values[n]=t,this},t.prototype.delete=function(t){var n=this._find(t,!1);if(n>=0){for(var r=this._keys.length,a=n+1;a<r;a++)this._keys[a-1]=this._keys[a],this._values[a-1]=this._values[a];return this._keys.length--,this._values.length--,Y(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new n(this._keys,this._values,a)},t.prototype.values=function(){return new n(this._keys,this._values,i)},t.prototype.entries=function(){return new n(this._keys,this._values,s)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[o]=function(){return this.entries()},t.prototype._find=function(e,t){if(!Y(this._cacheKey,e)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(Y(this._keys[n],e)){this._cacheIndex=n;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();return r;function a(e,t){return e}function i(e,t){return t}function s(e,t){return[e,t]}}function le(){return function(){function e(){this._map=new p}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[o]=function(){return this.keys()},e}()}function ue(){var e=16,t=l.create(),r=a();return function(){function e(){this._key=a()}return e.prototype.has=function(e){var t=o(e,!1);return void 0!==t&&l.has(t,this._key)},e.prototype.get=function(e){var t=o(e,!1);return void 0!==t?l.get(t,this._key):void 0},e.prototype.set=function(e,t){return o(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=o(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=a()},e}();function a(){var e;do{e="@@WeakMap@@"+c()}while(l.has(t,e));return t[e]=!0,e}function o(e,t){if(!n.call(e,r)){if(!t)return;Object.defineProperty(e,r,{value:l.create()})}return e[r]}function i(e,t){for(var n=0;n<t;++n)e[n]=255*Math.random()|0;return e}function s(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):i(t,e),t}return i(new Array(e),e)}function c(){var t=s(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var n="",r=0;r<e;++r){var a=t[r];4!==r&&6!==r&&8!==r||(n+="-"),a<16&&(n+="0"),n+=a.toString(16).toLowerCase()}return n}}function pe(e){return e.__=void 0,delete e.__,e}e("decorate",y),e("metadata",g),e("defineMetadata",E),e("hasMetadata",b),e("hasOwnMetadata",w),e("getMetadata",O),e("getOwnMetadata",S),e("getMetadataKeys",_),e("getOwnMetadataKeys",M),e("deleteMetadata",x)}(n,t),void 0===t.Reflect&&(t.Reflect=e)}()}(e||(e={}))),N;var e}();const T="List";function A(e){return Reflect.getMetadata(T,e)}const C=Symbol("cell");function k(e){return(t,n)=>{const r=Reflect.getMetadata(C,t)||[];if(Reflect.defineMetadata(C,[...r,n.toString()],t),e){const r=`${C.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,e,t)}}}function L(e){const t=e.prototype;return(Reflect.getMetadata(C,t)||[]).map((e=>{const n=Reflect.getMetadata(`${C.toString()}:${e}:options`,t)||{};return{...n,name:n?.name??e}}))}function P({pagination:t,onPageChange:n}){const{total:r,page:a,limit:o}=t,i=Math.floor(r/o);if(i<=1)return null;return e.createElement("div",{className:"pagination"},e.createElement("button",{onClick:()=>n(a-1),className:"pagination-item "+(1===a?"disabled":""),disabled:1===a,"aria-disabled":1===a},"Previous"),(()=>{const t=[];for(let r=1;r<=Math.min(2,i);r++)t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a-2>3&&t.push(e.createElement("span",{key:"ellipsis1",className:"pagination-ellipsis"},"..."));for(let r=Math.max(3,a-2);r<=Math.min(i-2,a+2);r++)r>2&&r<i-1&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a+2<i-2&&t.push(e.createElement("span",{key:"ellipsis2",className:"pagination-ellipsis"},"..."));for(let r=Math.max(i-1,3);r<=i;r++)r>2&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));return t})(),e.createElement("button",{onClick:()=>n(a+1),className:"pagination-item "+(a===i?"disabled":""),disabled:a===i,"aria-disabled":a===i},"Next"))}var I,j,V;function F(){return F=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},F.apply(null,arguments)}var D,R=function(e){return c.createElement("svg",F({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),I||(I=c.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),j||(j=c.createElement("path",{d:"M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5v2H5v14h14v-5z"})),V||(V=c.createElement("path",{d:"M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"})))};function z(){return z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},z.apply(null,arguments)}var B=function(e){return c.createElement("svg",z({xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e),D||(D=c.createElement("path",{d:"M22 3H2l8 9.46V19l4 2v-8.54z"})))};function $({field:t,value:r,onChange:a}){if("static-select"===t.filter?.type){const o=t.filter;return e.createElement(n,{id:t.name,menuPortalTarget:document.body,styles:{control:(e,t)=>({...e,backgroundColor:"#1f2937",borderColor:t.isFocused?"#6366f1":"#374151",boxShadow:t.isFocused?"0 0 0 1px #6366f1":"none","&:hover":{borderColor:"#6366f1"},borderRadius:"6px",padding:"2px",color:"white"}),option:(e,t)=>({...e,backgroundColor:t.isSelected?"#6366f1":t.isFocused?"#374151":"#1f2937",color:"white","&:active":{backgroundColor:"#6366f1"},"&:hover":{backgroundColor:"#374151"},cursor:"pointer"}),input:e=>({...e,color:"white"}),placeholder:e=>({...e,color:"#9ca3af"}),singleValue:e=>({...e,color:"white"}),menuPortal:e=>({...e,zIndex:9999}),menu:e=>({...e,backgroundColor:"#1f2937",border:"1px solid #374151",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"}),menuList:e=>({...e,padding:"4px"}),dropdownIndicator:e=>({...e,color:"#9ca3af","&:hover":{color:"#6366f1"}}),clearIndicator:e=>({...e,color:"#9ca3af","&:hover":{color:"#6366f1"}})},value:r?{value:r,label:o.options.find((e=>e.value===r))?.label||r}:null,onChange:e=>a(e?.value||""),options:o.options.map((e=>({value:e.value,label:e.label}))),placeholder:`Filter by ${t.title||t.name}`,isClearable:!0})}return e.createElement("input",{type:"number"===t.type?"number":"text",id:t.name,value:r||"",onChange:e=>a(e.target.value),placeholder:`Filter by ${t.title||t.name}`})}function H({isOpen:t,onClose:n,onApplyFilters:r,listData:a,activeFilters:o}){const[i,s]=e.useState(o??{}),c=e.useRef(null),l=e.useMemo((()=>a.cells.filter((e=>!!e.filter))),[a.cells]);if(e.useEffect((()=>{const e=e=>{c.current&&!c.current.contains(e.target)&&n()};return t&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[t,n]),!t)return null;return e.createElement("div",{className:"filter-popup-overlay"},e.createElement("div",{ref:c,className:"filter-popup"},e.createElement("div",{className:"filter-popup-header"},e.createElement("h3",null,"Filter"),e.createElement("button",{onClick:n,className:"close-button"},"×")),e.createElement("div",{className:"filter-popup-content"},l.map((t=>e.createElement("div",{key:t.name,className:"filter-field"},e.createElement("label",{htmlFor:t.name},t.title||t.name),e.createElement($,{field:t,value:i[t.name||""],onChange:e=>((e,t)=>{s((n=>({...n,[e]:t})))})(t.name||"",e)}))))),e.createElement("div",{className:"filter-popup-footer"},e.createElement("button",{onClick:n,className:"cancel-button"},"Cancel"),e.createElement("button",{onClick:()=>{r(i),n()},className:"apply-button"},"Apply Filters"))))}const U=({listData:n,filtered:r,onFilterClick:a,customHeader:o})=>{const i=e.useMemo((()=>n.cells.filter((e=>!!e.filter))),[n.cells]),s=n.list?.headers;return e.createElement("div",{className:"list-header"},e.createElement("div",{className:"header-title"},s?.title||"List"),o&&e.createElement("div",{className:"header-custom"},o),e.createElement("div",{className:"header-actions"},!!i.length&&e.createElement("button",{onClick:a,className:"filter-button"},e.createElement(B,{className:"icon icon-filter "+(r?"active":"")}),"Filter"),s?.create&&e.createElement(t.Link,{to:s.create.path,className:"create-button"},e.createElement(R,{className:"icon icon-create"}),s.create.label)))};function q({htmlFor:t,label:n,fieldName:r}){return e.createElement("label",{htmlFor:t},n??r.charAt(0).toUpperCase()+r.slice(1))}const K=Object.freeze({BEFORE:"before",HOVER:"hover",AFTER:"after"});function W(t){return e.createElement("div",null,e.createElement("img",{...t,style:{width:100}}),e.createElement("p",null,t.name," ",e.createElement("span",{style:{whiteSpace:"none"}},"(",(e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB","TB"][t]})(t.size),")")))}function G(){const{register:t,formState:{errors:n},watch:a,setValue:o,clearErrors:i,setError:s}=r.useFormContext(),c=a("uploader");return e.useEffect((()=>{t("uploader",{required:!0})}),[t]),e.createElement("div",null,e.createElement("span",{className:"form-error",style:{bottom:2,top:"unset"}},"required"===n.uploader?.type&&"At least 1 image is required!","custom"===n.uploader?.type&&n.uploader.message?.toString()),e.createElement(J,{reset:c,onError:e=>{e?s("uploader",{type:"custom",message:e}):(o("uploader",{files:[]}),i("uploader"))},onClear:()=>{o("uploader",{files:[]}),i("uploader")},onFilesChange:e=>{o("uploader",{files:e})}}))}function J(t){const[n,r]=e.useState(K.BEFORE),[a,o]=e.useState(t.value||[]),[i,s]=e.useState([]),[c,l]=e.useState(0);console.log("files",i);const u=e.useRef(null),p=e.useRef(null);e.useEffect((()=>{const e=u.current;if(!e)return;const n=e=>{e.preventDefault(),e.stopPropagation(),f()},a=e=>{e.preventDefault(),e.stopPropagation(),d()},o=e=>{e.preventDefault(),e.stopPropagation()},c=e=>{e.preventDefault(),e.stopPropagation(),l(0);const n=e.dataTransfer?.files;if(!n)return;s([]),r(K.AFTER);const a=[];for(let e=0;e<n.length;e++){const r=new FileReader;r.onload=r=>{if(!r.target)return;h([...i,{file:n[e],image:r.target.result}])&&(a.push(n[e]),p.current&&(p.current.files=n),s([])),t.onFilesChange&&t.onFilesChange(a)},r.readAsDataURL(n[e])}p.current&&(p.current.files=n)};return e.addEventListener("dragenter",n,!1),e.addEventListener("dragleave",a,!1),e.addEventListener("dragover",o,!1),e.addEventListener("drop",c,!1),()=>{e.removeEventListener("dragenter",n),e.removeEventListener("dragleave",a),e.removeEventListener("dragover",o),e.removeEventListener("drop",c)}}),[i]);const f=()=>{l((e=>e+1)),r(K.HOVER)},d=()=>{l((e=>e-1==0?(r(K.BEFORE),0):e-1))},h=e=>{const n=(e=>{if(!e)return null;if(e.length>=10)return"you can't send more than 10 images";for(let t=0;t<e.length;t++){const n=e[t].file,r=n.name.split(".");if(!["png","jpg","jpeg"].includes(r[r.length-1]))return'Extension of the file can only be "png", "jpg" or "jpeg" ';if(n&&n.size>1048576)return`Size of "${n.name}" can't be bigger than 1mb`}return null})(e);return n||s(e),t.onError?.(n),n};return e.createElement("div",{ref:u,className:"multi-image form-element dropzone "+n},e.createElement("input",{ref:p,type:"file",style:{display:"none"},className:"target",name:"file"}),e.createElement("div",{className:"container"},e.createElement("button",{className:"trash",onClick:()=>{s([]),p.current&&(p.current.value=""),t.onClear?.()},type:"button"},"Delete All"),(()=>{const t=[];if(i){console.log("----\x3e",i);for(let n=0;n<i.length;n++){let r="image";t.push(e.createElement("div",{key:n,className:"image-container"},e.createElement("div",{className:r},e.createElement(W,{name:i[n].file.name,src:i[n].image,size:i[n].file.size}))))}}return t})(),e.createElement("div",null,e.createElement("button",{type:"button",onClick:()=>{const e=document.getElementById("file__");e&&e.click()},className:"plus"},e.createElement("span",null,"+ Add Image",e.createElement("p",null,"Drag image here or Select Image")))),e.createElement("input",{hidden:!0,id:"file__",multiple:!0,type:"file",onChange:e=>{const t=e.target.files;if(t){s([]),r(K.AFTER);for(let e=0;e<t.length;e++){const n=new FileReader;n.onload=n=>{n.target&&h([...i,{file:t[e],image:n.target.result}])},n.readAsDataURL(t[e])}p.current&&(p.current.files=t)}}})))}function Y({id:t,...n}){return e.createElement("input",{type:"checkbox",id:t,className:"checkbox",...n})}function Q({input:t,register:n}){const a=r.useFormContext(),o=a.getValues(t.name);return e.createElement("div",null,o?.map(((r,o)=>e.createElement("div",{key:o},t.nestedFields?.map((r=>e.createElement(X,{key:r.name?.toString()??"",baseName:t.name+"["+o+"]",input:r,register:n,error:t.name?{message:a.formState.errors[t.name]?.message}:void 0})))))))}function X({input:t,register:n,error:r,baseName:a}){const o=(a?a.toString()+".":"")+t.name||"";return e.createElement("div",{className:"form-field"},e.createElement(q,{htmlFor:o,label:t.label,fieldName:o}),(()=>{switch(t.type){case"textarea":return e.createElement("textarea",{...n(o),placeholder:t.placeholder,id:o});case"select":return e.createElement("select",{...n(o),id:o},e.createElement("option",{value:""},"Select ",o),t.options?.map((t=>e.createElement("option",{key:t.value,value:t.value},t.label))));case"input":return e.createElement("input",{type:t.inputType,...n(o),placeholder:t.placeholder,id:o});case"file-upload":return e.createElement(G,null);case"checkbox":return e.createElement(Y,{...n(o),id:o});case"hidden":return e.createElement("input",{type:"hidden",...n(o),id:o});case"nested":return e.createElement(Q,{input:t,register:n})}})(),r&&e.createElement("span",{className:"error-message"},r.message))}function Z({formOptions:n,onSubmit:a,getDetailsData:o,redirectBackOnSuccess:i}){const s=t.useParams(),c=r.useForm({resolver:n.resolver}),l=t.useNavigate(),u=n.inputs;return e.useEffect((()=>{o&&o(s).then((e=>{c.reset({...e})}))}),[s,c.reset]),e.createElement("div",{className:"form-wrapper"},e.createElement(r.FormProvider,{...c},e.createElement("form",{onSubmit:c.handleSubmit((async e=>{await a(e),i&&l(-1)}),((e,t)=>{console.log("error creating creation",e,t)}))},e.createElement("div",null,u?.map((t=>e.createElement(X,{key:t.name||"",input:t,register:c.register,error:t.name?{message:c.formState.errors[t.name]?.message}:void 0}))),e.createElement("button",{type:"submit",className:"submit-button"},"Submit")))))}class ee extends e.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}render(){return this.state.hasError?e.createElement("div",{className:"error-boundary"},e.createElement("div",{className:"error-boundary__content"},e.createElement("div",{className:"error-boundary__icon"},e.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},e.createElement("circle",{cx:"12",cy:"12",r:"10"}),e.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),e.createElement("h1",null,"Oops! Something went wrong"),e.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),e.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&e.createElement("details",{className:"error-boundary__details"},e.createElement("summary",null,"Error Details"),e.createElement("pre",null,this.state.error?.toString()),e.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}const te=Symbol("input");function ne(e){const t=e.prototype;return(Reflect.getMetadata(te,t)||[]).map((e=>{const n=Reflect.getMetadata(`${te.toString()}:${e}:options`,t)||{},r=n?.inputType??(a=e,["password"].some((e=>a.toLowerCase().includes(e)))?"password":"text");var a;return{...n,editable:n.editable??!0,sensitive:n.sensitive,name:n?.name??e,label:n?.label??e,placeholder:n?.placeholder??e,inputType:r,type:n?.type??"input",selectOptions:n?.selectOptions??[],cancelPasswordValidationOnEdit:n?.cancelPasswordValidationOnEdit??"password"===r}}))}function re(e){return Reflect.getMetadata("FormMetadata",e)}const ae=(e,t,n)=>{if(e&&"reportValidity"in e){const a=r.get(n,t);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},oe=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?ae(r.ref,n,e):r&&r.refs&&r.refs.forEach((t=>ae(t,n,e)))}},ie=(e,t)=>{t.shouldUseNativeValidation&&oe(e,t);const n={};for(const a in e){const o=r.get(t.fields,a),i=Object.assign(e[a]||{},{ref:o&&o.ref});if(se(t.names||Object.keys(e),a)){const e=Object.assign({},r.get(n,a));r.set(e,"root",i),r.set(n,a,e)}else r.set(n,a,i)}return n},se=(e,t)=>{const n=ce(t);return e.some((e=>ce(e).match(`^${n}\\.\\d+`)))};function ce(e){return e.replace(/\]|\[/g,"")}var le;!function(e){e[e.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",e[e.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",e[e.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(le||(le={}));var ue=function(){function e(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return e.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},e.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},e.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},e.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},e.prototype.findTransformMetadatas=function(e,t,n){return this.findMetadatas(this._transformMetadatas,e,t).filter((function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?n===le.CLASS_TO_CLASS||n===le.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||n===le.CLASS_TO_PLAIN))}))},e.prototype.findExcludeMetadata=function(e,t){return this.findMetadata(this._excludeMetadatas,e,t)},e.prototype.findExposeMetadata=function(e,t){return this.findMetadata(this._exposeMetadatas,e,t)},e.prototype.findExposeMetadataByCustomName=function(e,t){return this.getExposedMetadatas(e).find((function(e){return e.options&&e.options.name===t}))},e.prototype.findTypeMetadata=function(e,t){return this.findMetadata(this._typeMetadatas,e,t)},e.prototype.getStrategy=function(e){var t=this._excludeMetadatas.get(e),n=t&&t.get(void 0),r=this._exposeMetadatas.get(e),a=r&&r.get(void 0);return n&&a||!n&&!a?"none":n?"excludeAll":"exposeAll"},e.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},e.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},e.prototype.getExposedProperties=function(e,t){return this.getExposedMetadatas(e).filter((function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?t===le.CLASS_TO_CLASS||t===le.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||t===le.CLASS_TO_PLAIN))})).map((function(e){return e.propertyName}))},e.prototype.getExcludedProperties=function(e,t){return this.getExcludedMetadatas(e).filter((function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?t===le.CLASS_TO_CLASS||t===le.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||t===le.CLASS_TO_PLAIN))})).map((function(e){return e.propertyName}))},e.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},e.prototype.getMetadata=function(e,t){var n,r=e.get(t);r&&(n=Array.from(r.values()).filter((function(e){return void 0!==e.propertyName})));for(var a=[],o=0,i=this.getAncestors(t);o<i.length;o++){var s=i[o],c=e.get(s);if(c){var l=Array.from(c.values()).filter((function(e){return void 0!==e.propertyName}));a.push.apply(a,l)}}return a.concat(n||[])},e.prototype.findMetadata=function(e,t,n){var r=e.get(t);if(r){var a=r.get(n);if(a)return a}for(var o=0,i=this.getAncestors(t);o<i.length;o++){var s=i[o],c=e.get(s);if(c){var l=c.get(n);if(l)return l}}},e.prototype.findMetadatas=function(e,t,n){var r,a=e.get(t);a&&(r=a.get(n));for(var o=[],i=0,s=this.getAncestors(t);i<s.length;i++){var c=s[i],l=e.get(c);l&&l.has(n)&&o.push.apply(o,l.get(n))}return o.slice().reverse().concat((r||[]).slice().reverse())},e.prototype.getAncestors=function(e){if(!e)return[];if(!this._ancestorsMap.has(e)){for(var t=[],n=Object.getPrototypeOf(e.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))t.push(n);this._ancestorsMap.set(e,t)}return this._ancestorsMap.get(e)},e}(),pe=new ue;var fe=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))};var de=function(){function e(e,t){this.transformationType=e,this.options=t,this.recursionStack=new Set}return e.prototype.transform=function(e,t,n,r,a,o){var i,s=this;if(void 0===o&&(o=0),Array.isArray(t)||t instanceof Set){var c=r&&this.transformationType===le.PLAIN_TO_CLASS?function(e){var t=new e;return t instanceof Set||"push"in t?t:[]}(r):[];return t.forEach((function(t,r){var a=e?e[r]:void 0;if(s.options.enableCircularCheck&&s.isCircular(t))s.transformationType===le.CLASS_TO_CLASS&&(c instanceof Set?c.add(t):c.push(t));else{var i=void 0;if("function"!=typeof n&&n&&n.options&&n.options.discriminator&&n.options.discriminator.property&&n.options.discriminator.subTypes){if(s.transformationType===le.PLAIN_TO_CLASS){i=n.options.discriminator.subTypes.find((function(e){return e.name===t[n.options.discriminator.property]}));var l={newObject:c,object:t,property:void 0},u=n.typeFunction(l);i=void 0===i?u:i.value,n.options.keepDiscriminatorProperty||delete t[n.options.discriminator.property]}s.transformationType===le.CLASS_TO_CLASS&&(i=t.constructor),s.transformationType===le.CLASS_TO_PLAIN&&(t[n.options.discriminator.property]=n.options.discriminator.subTypes.find((function(e){return e.value===t.constructor})).name)}else i=n;var p=s.transform(a,t,i,void 0,t instanceof Map,o+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(n!==String||a){if(n!==Number||a){if(n!==Boolean||a){if((n===Date||t instanceof Date)&&!a)return t instanceof Date?new Date(t.valueOf()):null==t?t:new Date(t);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(n===Buffer||t instanceof Buffer)&&!a)return null==t?t:Buffer.from(t);if(null===(i=t)||"object"!=typeof i||"function"!=typeof i.then||a){if(a||null===t||"object"!=typeof t||"function"!=typeof t.then){if("object"==typeof t&&null!==t){n||t.constructor===Object||(Array.isArray(t)||t.constructor!==Array)&&(n=t.constructor),!n&&e&&(n=e.constructor),this.options.enableCircularCheck&&this.recursionStack.add(t);var l=this.getKeys(n,t,a),u=e||{};e||this.transformationType!==le.PLAIN_TO_CLASS&&this.transformationType!==le.CLASS_TO_CLASS||(u=a?new Map:n?new n:{});for(var p=function(r){if("__proto__"===r||"constructor"===r)return"continue";var i=r,s=r,c=r;if(!f.options.ignoreDecorators&&n)if(f.transformationType===le.PLAIN_TO_CLASS)(l=pe.findExposeMetadataByCustomName(n,r))&&(c=l.propertyName,s=l.propertyName);else if(f.transformationType===le.CLASS_TO_PLAIN||f.transformationType===le.CLASS_TO_CLASS){var l;(l=pe.findExposeMetadata(n,r))&&l.options&&l.options.name&&(s=l.options.name)}var p=void 0;p=f.transformationType===le.PLAIN_TO_CLASS?t[i]:t instanceof Map?t.get(i):t[i]instanceof Function?t[i]():t[i];var d=void 0,h=p instanceof Map;if(n&&a)d=n;else if(n){var m=pe.findTypeMetadata(n,c);if(m){var v={newObject:u,object:t,property:c},y=m.typeFunction?m.typeFunction(v):m.reflectedType;m.options&&m.options.discriminator&&m.options.discriminator.property&&m.options.discriminator.subTypes?t[i]instanceof Array?d=m:(f.transformationType===le.PLAIN_TO_CLASS&&(d=void 0===(d=m.options.discriminator.subTypes.find((function(e){if(p&&p instanceof Object&&m.options.discriminator.property in p)return e.name===p[m.options.discriminator.property]})))?y:d.value,m.options.keepDiscriminatorProperty||p&&p instanceof Object&&m.options.discriminator.property in p&&delete p[m.options.discriminator.property]),f.transformationType===le.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===le.CLASS_TO_PLAIN&&p&&(p[m.options.discriminator.property]=m.options.discriminator.subTypes.find((function(e){return e.value===p.constructor})).name)):d=y,h=h||m.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(e){return e.target===n&&!!e.properties[c]})).forEach((function(e){return d=e.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===le.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",n.prototype,c);g&&(d=g)}}var E=Array.isArray(t[i])?f.getReflectedType(n,c):void 0,b=e?e[i]:void 0;if(u.constructor.prototype){var w=Object.getOwnPropertyDescriptor(u.constructor.prototype,s);if((f.transformationType===le.PLAIN_TO_CLASS||f.transformationType===le.CLASS_TO_CLASS)&&(w&&!w.set||u[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===le.CLASS_TO_CLASS){S=p;(void 0!==(S=f.applyCustomTransformations(S,n,r,t,f.transformationType))||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}}else{var O=f.transformationType===le.PLAIN_TO_CLASS?s:r,S=void 0;f.transformationType===le.CLASS_TO_PLAIN?(S=t[O],S=f.applyCustomTransformations(S,n,O,t,f.transformationType),S=t[O]===S?p:S,S=f.transform(b,S,d,E,h,o+1)):void 0===p&&f.options.exposeDefaultValues?S=u[s]:(S=f.transform(b,p,d,E,h,o+1),S=f.applyCustomTransformations(S,n,O,t,f.transformationType)),(void 0!==S||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}},f=this,d=0,h=l;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(t),u}return t}return t}return new Promise((function(e,r){t.then((function(t){return e(s.transform(void 0,t,n,void 0,void 0,o+1))}),r)}))}return null==t?t:Boolean(t)}return null==t?t:Number(t)}return null==t?t:String(t)},e.prototype.applyCustomTransformations=function(e,t,n,r,a){var o=this,i=pe.findTransformMetadatas(t,n,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(e){return!e.options||o.checkVersion(e.options.since,e.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(e){return!e.options||o.checkGroups(e.options.groups)})):i.filter((function(e){return!e.options||!e.options.groups||!e.options.groups.length}))).forEach((function(t){e=t.transformFn({value:e,key:n,obj:r,type:a,options:o.options})})),e},e.prototype.isCircular=function(e){return this.recursionStack.has(e)},e.prototype.getReflectedType=function(e,t){if(e){var n=pe.findTypeMetadata(e,t);return n?n.reflectedType:void 0}},e.prototype.getKeys=function(e,t,n){var r=this,a=pe.getStrategy(e);"none"===a&&(a=this.options.strategy||"exposeAll");var o=[];if(("exposeAll"===a||n)&&(o=t instanceof Map?Array.from(t.keys()):Object.keys(t)),n)return o;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&e){var i=pe.getExposedProperties(e,this.transformationType),s=pe.getExcludedProperties(e,this.transformationType);o=fe(fe([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&e){i=pe.getExposedProperties(e,this.transformationType);this.transformationType===le.PLAIN_TO_CLASS&&(i=i.map((function(t){var n=pe.findExposeMetadata(e,t);return n&&n.options&&n.options.name?n.options.name:t}))),o=this.options.excludeExtraneousValues?i:o.concat(i);var c=pe.getExcludedProperties(e,this.transformationType);c.length>0&&(o=o.filter((function(e){return!c.includes(e)}))),void 0!==this.options.version&&(o=o.filter((function(t){var n=pe.findExposeMetadata(e,t);return!n||!n.options||r.checkVersion(n.options.since,n.options.until)}))),o=this.options.groups&&this.options.groups.length?o.filter((function(t){var n=pe.findExposeMetadata(e,t);return!n||!n.options||r.checkGroups(n.options.groups)})):o.filter((function(t){var n=pe.findExposeMetadata(e,t);return!(n&&n.options&&n.options.groups&&n.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(o=o.filter((function(e){return r.options.excludePrefixes.every((function(t){return e.substr(0,t.length)!==t}))}))),o=o.filter((function(e,t,n){return n.indexOf(e)===t}))},e.prototype.checkVersion=function(e,t){var n=!0;return n&&e&&(n=this.options.version>=e),n&&t&&(n=this.options.version<t),n},e.prototype.checkGroups=function(e){return!e||this.options.groups.some((function(t){return e.includes(t)}))},e}(),he={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},me=function(){return me=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},me.apply(this,arguments)},ve=new(function(){function e(){}return e.prototype.instanceToPlain=function(e,t){return new de(le.CLASS_TO_PLAIN,me(me({},he),t)).transform(void 0,e,void 0,void 0,void 0,void 0)},e.prototype.classToPlainFromExist=function(e,t,n){return new de(le.CLASS_TO_PLAIN,me(me({},he),n)).transform(t,e,void 0,void 0,void 0,void 0)},e.prototype.plainToInstance=function(e,t,n){return new de(le.PLAIN_TO_CLASS,me(me({},he),n)).transform(void 0,t,e,void 0,void 0,void 0)},e.prototype.plainToClassFromExist=function(e,t,n){return new de(le.PLAIN_TO_CLASS,me(me({},he),n)).transform(e,t,void 0,void 0,void 0,void 0)},e.prototype.instanceToInstance=function(e,t){return new de(le.CLASS_TO_CLASS,me(me({},he),t)).transform(void 0,e,void 0,void 0,void 0,void 0)},e.prototype.classToClassFromExist=function(e,t,n){return new de(le.CLASS_TO_CLASS,me(me({},he),n)).transform(t,e,void 0,void 0,void 0,void 0)},e.prototype.serialize=function(e,t){return JSON.stringify(this.instanceToPlain(e,t))},e.prototype.deserialize=function(e,t,n){var r=JSON.parse(t);return this.plainToInstance(e,r,n)},e.prototype.deserializeArray=function(e,t,n){var r=JSON.parse(t);return this.plainToInstance(e,r,n)},e}());var ye=function(e){this.groups=[],this.each=!1,this.context=void 0,this.type=e.type,this.name=e.name,this.target=e.target,this.propertyName=e.propertyName,this.constraints=null==e?void 0:e.constraints,this.constraintCls=e.constraintCls,this.validationTypeOptions=e.validationTypeOptions,e.validationOptions&&(this.message=e.validationOptions.message,this.groups=e.validationOptions.groups,this.always=e.validationOptions.always,this.each=e.validationOptions.each,this.context=e.validationOptions.context)},ge=function(){function e(){}return e.prototype.transform=function(e){var t=[];return Object.keys(e.properties).forEach((function(n){e.properties[n].forEach((function(r){var a={message:r.message,groups:r.groups,always:r.always,each:r.each},o={type:r.type,name:r.name,target:e.name,propertyName:n,constraints:r.constraints,validationTypeOptions:r.options,validationOptions:a};t.push(new ye(o))}))})),t},e}();function Ee(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function be(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}var we=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Oe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},Se=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))},_e=function(){function e(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(e.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),e.prototype.addValidationSchema=function(e){var t=this;(new ge).transform(e).forEach((function(e){return t.addValidationMetadata(e)}))},e.prototype.addValidationMetadata=function(e){var t=this.validationMetadatas.get(e.target);t?t.push(e):this.validationMetadatas.set(e.target,[e])},e.prototype.addConstraintMetadata=function(e){var t=this.constraintMetadatas.get(e.target);t?t.push(e):this.constraintMetadatas.set(e.target,[e])},e.prototype.groupByPropertyName=function(e){var t={};return e.forEach((function(e){t[e.propertyName]||(t[e.propertyName]=[]),t[e.propertyName].push(e)})),t},e.prototype.getTargetValidationMetadatas=function(e,t,n,r,a){var o,i,s=function(e){return void 0!==e.always?e.always:(!e.groups||!e.groups.length)&&n},c=function(e){return!(!r||a&&a.length||!e.groups||!e.groups.length)},l=(this.validationMetadatas.get(e)||[]).filter((function(n){return(n.target===e||n.target===t)&&(!!s(n)||!c(n)&&(!(a&&a.length>0)||n.groups&&!!n.groups.find((function(e){return-1!==a.indexOf(e)}))))})),u=[];try{for(var p=we(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=Oe(f.value,2),h=d[0],m=d[1];e.prototype instanceof h&&u.push.apply(u,Se([],Oe(m),!1))}}catch(e){o={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}var v=u.filter((function(t){return"string"!=typeof t.target&&(t.target!==e&&((!(t.target instanceof Function)||e.prototype instanceof t.target)&&(!!s(t)||!c(t)&&(!(a&&a.length>0)||t.groups&&!!t.groups.find((function(e){return-1!==a.indexOf(e)}))))))})).filter((function(e){return!l.find((function(t){return t.propertyName===e.propertyName&&t.type===e.type}))}));return l.concat(v)},e.prototype.getTargetValidatorConstraints=function(e){return this.constraintMetadatas.get(e)||[]},e}();var Me=function(){function e(){}return e.prototype.toString=function(e,t,n,r){var a=this;void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===n&&(n=""),void 0===r&&(r=!1);var o=e?"[1m":"",i=e?"[22m":"",s=function(e){return" - property ".concat(o).concat(n).concat(e).concat(i," has failed the following constraints: ").concat(o).concat((r?Object.values:Object.keys)(null!==(t=a.constraints)&&void 0!==t?t:{}).join(", ")).concat(i," \n");var t};if(t){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(n?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(t){return t.toString(e,!0,"".concat(n).concat(c),r)})).join(""):""}return"An instance of ".concat(o).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(t){return t.toString(e,!0,a.property,r)})).join(""):"")},e}(),xe=function(){function e(){}return e.isValid=function(e){var t=this;return"isValid"!==e&&"getMessage"!==e&&-1!==Object.keys(this).map((function(e){return t[e]})).indexOf(e)},e.CUSTOM_VALIDATION="customValidation",e.NESTED_VALIDATION="nestedValidation",e.PROMISE_VALIDATION="promiseValidation",e.CONDITIONAL_VALIDATION="conditionalValidation",e.WHITELIST="whitelistValidation",e.IS_DEFINED="isDefined",e}();var Ne=function(){function e(){}return e.replaceMessageSpecialTokens=function(e,t){var n;return e instanceof Function?n=e(t):"string"==typeof e&&(n=e),n&&Array.isArray(t.constraints)&&t.constraints.forEach((function(e,t){n=n.replace(new RegExp("\\$constraint".concat(t+1),"g"),function(e){return Array.isArray(e)?e.join(", "):("symbol"==typeof e&&(e=e.description),"".concat(e))}(e))})),n&&void 0!==t.value&&null!==t.value&&["string","boolean","number"].includes(typeof t.value)&&(n=n.replace(/\$value/g,t.value)),n&&(n=n.replace(/\$property/g,t.property)),n&&(n=n.replace(/\$target/g,t.targetName)),n},e}(),Te=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},Ae=function(){function e(e,t){this.validator=e,this.validatorOptions=t,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var e=Ee();return e.classValidatorMetadataStorage||(e.classValidatorMetadataStorage=new _e),e.classValidatorMetadataStorage}()}return e.prototype.execute=function(e,t,n){var r,a,o=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(r=this.validatorOptions)||void 0===r?void 0:r.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,l=void 0===(null===(a=this.validatorOptions)||void 0===a?void 0:a.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,u=this.metadataStorage.getTargetValidationMetadatas(e.constructor,t,c,s,i),p=this.metadataStorage.groupByPropertyName(u);if(this.validatorOptions&&l&&!u.length){var f=new Me;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=e),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void n.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(e,p,n),Object.keys(p).forEach((function(t){var r=e[t],a=p[t].filter((function(e){return e.type===xe.IS_DEFINED})),i=p[t].filter((function(e){return e.type!==xe.IS_DEFINED&&e.type!==xe.WHITELIST}));r instanceof Promise&&i.find((function(e){return e.type===xe.PROMISE_VALIDATION}))?o.awaitingPromises.push(r.then((function(r){o.performValidations(e,r,t,a,i,n)}))):o.performValidations(e,r,t,a,i,n)}))},e.prototype.whitelist=function(e,t,n){var r=this,a=[];Object.keys(e).forEach((function(e){t[e]&&0!==t[e].length||a.push(e)})),a.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?a.forEach((function(t){var a,o=r.generateValidationError(e,e[t],t);o.constraints=((a={})[xe.WHITELIST]="property ".concat(t," should not exist"),a),o.children=void 0,n.push(o)})):a.forEach((function(t){return delete e[t]})))},e.prototype.stripEmptyErrors=function(e){var t=this;return e.filter((function(e){if(e.children&&(e.children=t.stripEmptyErrors(e.children)),0===Object.keys(e.constraints).length){if(0===e.children.length)return!1;delete e.constraints}return!0}))},e.prototype.performValidations=function(e,t,n,r,a,o){var i=a.filter((function(e){return e.type===xe.CUSTOM_VALIDATION})),s=a.filter((function(e){return e.type===xe.NESTED_VALIDATION})),c=a.filter((function(e){return e.type===xe.CONDITIONAL_VALIDATION})),l=this.generateValidationError(e,t,n);o.push(l),this.conditionalValidations(e,t,c)&&(this.customValidations(e,t,r,l),this.mapContexts(e,t,r,l),void 0===t&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===t&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==t&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(e,t,i,l),this.nestedValidations(t,s,l),this.mapContexts(e,t,a,l),this.mapContexts(e,t,i,l)))},e.prototype.generateValidationError=function(e,t,n){var r=new Me;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(r.target=e),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(r.value=t),r.property=n,r.children=[],r.constraints={},r},e.prototype.conditionalValidations=function(e,t,n){return n.map((function(n){return n.constraints[0](e,t)})).reduce((function(e,t){return e&&t}),!0)},e.prototype.customValidations=function(e,t,n,r){var a=this;n.forEach((function(n){a.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach((function(o){if(!(o.async&&a.ignoreAsyncValidations||a.validatorOptions&&a.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0)){var i={targetName:e.constructor?e.constructor.name:void 0,property:n.propertyName,object:e,value:t,constraints:n.constraints};if(n.each&&(Array.isArray(t)||t instanceof Set||t instanceof Map)){var s,c=((s=t)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map((function(e){return o.instance.validate(e,i)}));if(c.some((function(e){return be(e)}))){var l=c.map((function(e){return be(e)?e:Promise.resolve(e)})),u=Promise.all(l).then((function(i){if(!i.every((function(e){return e}))){var s=Te(a.createValidationError(e,t,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(u)}else{if(!c.every((function(e){return e}))){var p=Te(a.createValidationError(e,t,n,o),2);m=p[0],v=p[1];r.constraints[m]=v}}}else{var f=o.instance.validate(t,i);if(be(f)){var d=f.then((function(i){if(!i){var s=Te(a.createValidationError(e,t,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(d)}else if(!f){var h=Te(a.createValidationError(e,t,n,o),2),m=h[0],v=h[1];r.constraints[m]=v}}}}))}))},e.prototype.nestedValidations=function(e,t,n){var r=this;void 0!==e&&t.forEach((function(a){if((a.type===xe.NESTED_VALIDATION||a.type===xe.PROMISE_VALIDATION)&&!(r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0))if(Array.isArray(e)||e instanceof Set||e instanceof Map)(e instanceof Set?Array.from(e):e).forEach((function(a,o){r.performValidations(e,a,o.toString(),[],t,n.children)}));else if(e instanceof Object){var o="string"==typeof a.target?a.target:a.target.name;r.execute(e,o,n.children)}else{var i=Te(r.createValidationError(a.target,e,a),2),s=i[0],c=i[1];n.constraints[s]=c}}))},e.prototype.mapContexts=function(e,t,n,r){var a=this;return n.forEach((function(e){if(e.context){var t=void 0;if(e.type===xe.CUSTOM_VALIDATION)t=a.metadataStorage.getTargetValidatorConstraints(e.constraintCls)[0];var n=a.getConstraintType(e,t);r.constraints[n]&&(r.contexts||(r.contexts={}),r.contexts[n]=Object.assign(r.contexts[n]||{},e.context))}}))},e.prototype.createValidationError=function(e,t,n,r){var a=e.constructor?e.constructor.name:void 0,o=this.getConstraintType(n,r),i={targetName:a,property:n.propertyName,object:e,value:t,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||r&&r.instance.defaultMessage instanceof Function&&(s=r.instance.defaultMessage(i)),[o,Ne.replaceMessageSpecialTokens(s,i)]},e.prototype.getConstraintType=function(e,t){return t&&t.name?t.name:e.type},e}(),Ce=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},ke=function(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},Le=function(){function e(){}return e.prototype.validate=function(e,t,n){return this.coreValidate(e,t,n)},e.prototype.validateOrReject=function(e,t,n){return Ce(this,void 0,void 0,(function(){var r;return ke(this,(function(a){switch(a.label){case 0:return[4,this.coreValidate(e,t,n)];case 1:return(r=a.sent()).length?[2,Promise.reject(r)]:[2]}}))}))},e.prototype.validateSync=function(e,t,n){var r="string"==typeof e?t:e,a="string"==typeof e?e:void 0,o=new Ae(this,"string"==typeof e?n:t);o.ignoreAsyncValidations=!0;var i=[];return o.execute(r,a,i),o.stripEmptyErrors(i)},e.prototype.coreValidate=function(e,t,n){var r="string"==typeof e?t:e,a="string"==typeof e?e:void 0,o=new Ae(this,"string"==typeof e?n:t),i=[];return o.execute(r,a,i),Promise.all(o.awaitingPromises).then((function(){return o.stripEmptyErrors(i)}))},e}(),Pe=new(function(){function e(){this.instances=[]}return e.prototype.get=function(e){var t=this.instances.find((function(t){return t.type===e}));return t||(t={type:e,object:new e},this.instances.push(t)),t.object},e}());function Ie(e){return Pe.get(e)}function je(e,t,n){return"string"==typeof e?Ie(Le).validate(e,t,n):Ie(Le).validate(e,t)}function Ve(e,t,n){return"string"==typeof e?Ie(Le).validateSync(e,t,n):Ie(Le).validateSync(e,t)}function Fe(e,t,n,r){return void 0===n&&(n={}),void 0===r&&(r=""),e.reduce((function(e,n){var a=r?r+"."+n.property:n.property;if(n.constraints){var o=Object.keys(n.constraints)[0];e[a]={type:o,message:n.constraints[o]};var i=e[a];t&&i&&Object.assign(i,{types:n.constraints})}return n.children&&n.children.length&&Fe(n.children,t,e,a),e}),n)}function De(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),function(r,a,o){try{var i=t.validator,s=(c=e,l=r,u=t.transformer,ve.plainToInstance(c,l,u));return Promise.resolve(("sync"===n.mode?Ve:je)(s,i)).then((function(e){return e.length?{values:{},errors:ie(Fe(e,!o.shouldUseNativeValidation&&"all"===o.criteriaMode),o)}:(o.shouldUseNativeValidation&&oe({},o),{values:n.raw?Object.assign({},r):s,errors:{}})}))}catch(e){return Promise.reject(e)}var c,l,u}}function Re(e){return{resolver:De(e),form:re(e),inputs:ne(e)}}const ze=o.createWithEqualityFn()(a.persist((e=>({screens:null,user:null,screenPaths:{}})),{name:"app-store-1",storage:a.createJSONStorage((()=>localStorage)),partialize:e=>({user:e.user})}),i.shallow);function Be({menu:n,getIcons:r,onLogout:a}){const{screens:o,screenPaths:i}=ze((e=>({screens:e.screens??{},screenPaths:e.screenPaths??{}}))),[s,c]=e.useState(!0),l=t.useLocation(),u=t.useNavigate(),p=e=>{if("/"===e)return l.pathname===e;const t=e.replace(/^\/+|\/+$/g,""),n=l.pathname.replace(/^\/+|\/+$/g,"");return n===t||n.startsWith(`${t}/`)};return e.createElement("div",{className:"sidebar "+(s?"open":"closed")},e.createElement("button",{className:"toggle-button",onClick:()=>c(!s),"aria-label":s?"Collapse sidebar":"Expand sidebar","aria-expanded":s},s?"<":">"),e.createElement("nav",{className:"nav-links"},n?.(o).map(((n,a)=>e.createElement(t.Link,{key:a,to:n.path,className:"nav-link "+(p(n.path)?"active":""),"aria-current":p(n.path)?"page":void 0},e.createElement("span",{className:"nav-links-icon"},r?.(n.iconType)),s?e.createElement("span",null,n.name):null)))),a&&e.createElement("div",{className:"sidebar-footer"},e.createElement("button",{className:"logout-button",onClick:()=>{a&&(a(),u(i.login))},"aria-label":"Logout"},e.createElement("span",{className:"nav-links-icon"},e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M6 12H2V4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{d:"M10 8L14 4M14 4L10 0M14 4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))),s?e.createElement("span",null,"Logout"):null)))}exports.Cell=k,exports.Counter=function({image:t,text:n,targetNumber:r,duration:a=2e3}){const[o,i]=e.useState(0);return e.useEffect((()=>{let e,t;const n=o=>{e||(e=o);const s=o-e,c=Math.min(s/a,1);i(Math.floor(c*r)),c<1&&(t=requestAnimationFrame(n))};return t=requestAnimationFrame(n),()=>{t&&cancelAnimationFrame(t)}}),[r,a]),e.createElement("div",{className:"counter-container"},e.createElement("div",{className:"counter-image"},t),e.createElement("div",{className:"counter-text"},n),e.createElement("div",{className:"counter-value"},o))},exports.Crud=function(e){return t=>{e&&Reflect.defineMetadata("Crud",e,t)}},exports.FormPage=function({model:t,getDetailsData:n,onSubmit:r,redirect:a,redirectBackOnSuccess:o=!0,...i}){const s=e.useMemo((()=>Re(t)),[t]);return e.createElement(Z,{getDetailsData:n,onSubmit:r,formOptions:s,redirectBackOnSuccess:o})},exports.ImageCell=function(e){return k({...e,type:"image"})},exports.Input=function(e){return(t,n)=>{const r=Reflect.getMetadata(te,t)||[];if(Reflect.defineMetadata(te,[...r,n.toString()],t),e){const r=`${te.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,e,t)}}},exports.Layout=function({children:n,menu:r,getIcons:a,logout:o}){const{user:i,screenPaths:s}=ze((e=>({user:e.user,screenPaths:e.screenPaths})));ze();const c=t.useNavigate();return i||c(s.login),e.createElement("div",{className:"layout"},e.createElement(Be,{onLogout:()=>{o&&o()},menu:r,getIcons:a}),e.createElement("main",{className:"content"},n))},exports.List=function(e){return t=>{e&&Reflect.defineMetadata(T,e,t)}},exports.ListPage=function({model:n,getData:r,onRemoveItem:a,customHeader:o}){const[i,s]=e.useState(!0),[c,l]=e.useState({total:0,page:0,limit:0}),[u,p]=e.useState(null),[f,d]=e.useState(null),[h,m]=e.useState(!1),[v,y]=e.useState(),g=e.useMemo((()=>{return{list:A(e=n),cells:L(e)};var e}),[n]),E=t.useParams(),b=t.useNavigate(),w=e.useCallback((async(e,t)=>{s(!0);try{const n=await r({page:e,filters:t??v??{}});p(n.data),l({total:n.total,page:n.page,limit:n.limit})}catch(e){d(e),console.error(e)}finally{s(!1)}}),[r,v]);return e.useEffect((()=>{const e=new URLSearchParams(location.search),t={};e.forEach(((e,n)=>{t[n]=e})),y(t)}),[location.search]),e.useEffect((()=>{v&&w(parseInt(E.page)||1,v)}),[w,E.page,v]),i?e.createElement(_,null):f?e.createElement(S,{error:f}):e.createElement("div",{className:"list"},e.createElement(U,{listData:g,filtered:!(!v||!Object.keys(v).length),onFilterClick:()=>m(!0),customHeader:o}),e.createElement(O,{listData:g,data:u,onRemoveItem:async e=>{a&&alert({title:"Are you sure you want to delete this item?",message:"This action cannot be undone.",onConfirm:async()=>{await a(e),p(u.filter((t=>t.id!==e.id))),await w(c.page)}})}}),e.createElement("div",{className:"list-footer"},e.createElement(P,{pagination:c,onPageChange:w})),e.createElement(H,{isOpen:h,activeFilters:v,onClose:()=>m(!1),onApplyFilters:e=>{y(e);const t=new URLSearchParams;Object.entries(e).forEach((([e,n])=>{null!=n&&""!==n&&t.append(e,String(n))}));const n=t.toString(),r=`${location.pathname}${n?`?${n}`:""}`;b(r),w(1,e)},listData:g}))},exports.Login=function({onLogin:n}){const{register:a,handleSubmit:o,formState:{errors:i}}=r.useForm(),s=t.useNavigate();return e.createElement("div",{className:"login-container"},e.createElement("div",{className:"login-panel"},e.createElement("div",{className:"login-header"},e.createElement("h1",null,"Welcome Back"),e.createElement("p",null,"Please sign in to continue")),e.createElement("form",{onSubmit:o((async e=>{n.login(e.username,e.password).then((e=>{const{user:t,token:n}=e;localStorage.setItem("token",n),ze.setState({user:t}),s("/")}))})),className:"login-form"},e.createElement(X,{input:{name:"username",label:"Username",placeholder:"Enter your username",type:"input"},register:a,error:i.username}),e.createElement(X,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password",type:"input"},register:a,error:i.password}),e.createElement("div",{className:"form-actions"},e.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))},exports.Panel=function({children:t,init:n}){return e.useEffect((()=>{!function({screenPaths:e}){ze.setState({screenPaths:e})}(n())}),[n]),e.createElement(ee,null,t)},exports.getFormFields=Re,exports.getInputFields=ne;
|
1
|
+
"use strict";var e=require("react"),t=require("react-router"),n=require("react-select"),r=require("react-hook-form"),a=require("zustand/middleware"),o=require("zustand/traditional"),i=require("zustand/vanilla/shallow");function s(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var c=s(e);const l=()=>e.createElement("div",{className:"empty-list"},e.createElement("div",{className:"empty-list-content"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),e.createElement("polyline",{points:"13 2 13 9 20 9"})),e.createElement("h3",null,"No Data Found"),e.createElement("p",null,"There are no items to display at the moment.")));var u,p;function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f.apply(null,arguments)}var d,h,m=function(e){return c.createElement("svg",f({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),u||(u=c.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),p||(p=c.createElement("path",{d:"m21 19-5.154-5.154a7 7 0 1 0-2 2L19 21zM5 10c0-2.757 2.243-5 5-5s5 2.243 5 5-2.243 5-5 5-5-2.243-5-5"})))};function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v.apply(null,arguments)}var y,g,E=function(e){return c.createElement("svg",v({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),d||(d=c.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),h||(h=c.createElement("path",{d:"m13 6 5 5-9.507 9.507a1.765 1.765 0 0 1-.012-2.485l-.002-.003c-.69.676-1.8.673-2.485-.013a1.763 1.763 0 0 1-.036-2.455l-.008-.008c-.694.65-1.78.64-2.456-.036zm7.586-.414-2.172-2.172a2 2 0 0 0-2.828 0L14 5l5 5 1.586-1.586c.78-.78.78-2.047 0-2.828M3 18v3h3a3 3 0 0 0-3-3"})))};function b(){return b=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},b.apply(null,arguments)}var w=function(e){return c.createElement("svg",b({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),y||(y=c.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),g||(g=c.createElement("path",{d:"M6.187 8h11.625l-.695 11.125A2 2 0 0 1 15.12 21H8.88a2 2 0 0 1-1.997-1.875zM19 5v2H5V5h3V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1zm-9 0h4V4h-4z"})))};function O({data:n,listData:r,onRemoveItem:a}){const o=r.cells,i="function"==typeof r.list?.cells?r.list?.cells?.(n[0]):r.list?.cells;return e.createElement("div",{className:"datagrid"},n&&0!==n.length?e.createElement("table",{className:"datagrid-table"},e.createElement("thead",null,e.createElement("tr",null,o.map((t=>e.createElement("th",{key:t.name},t.title??t.name))),i?.details&&e.createElement("th",null,"Details"),i?.edit&&e.createElement("th",null,"Edit"),i?.delete&&e.createElement("th",null,"Delete"))),e.createElement("tbody",null,n.map(((n,r)=>e.createElement("tr",{key:r},o.map((t=>{const r=n[t.name];let a=r??"-";switch(t.type){case"date":if(r){const e=new Date(r);a=`${e.getDate().toString().padStart(2,"0")}/${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getFullYear()} ${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}`}break;case"image":{const n=t;a=e.createElement("img",{width:100,height:100,src:n.baseUrl+r,style:{objectFit:"contain"}});break}default:a=r?r.toString():t?.placeHolder??"-"}return e.createElement("td",{key:t.name},a)})),i?.details&&e.createElement("td",null,e.createElement(t.Link,{to:i.details.path,className:"util-cell-link"},e.createElement(m,{className:"icon icon-search"}),e.createElement("span",{className:"util-cell-label"},i.details.label))),i?.edit&&e.createElement("td",null,e.createElement(t.Link,{to:i.edit.path,className:"util-cell-link"},e.createElement(E,{className:"icon icon-pencil"}),e.createElement("span",{className:"util-cell-label"},i.edit.label))),i?.delete&&e.createElement("td",null,e.createElement("a",{onClick:()=>{a?.(n)},className:"util-cell-link"},e.createElement(w,{className:"icon icon-trash"}),e.createElement("span",{className:"util-cell-label"},i.delete.label)))))))):e.createElement(l,null))}function S({error:t}){return e.createElement("div",{className:"error-container"},e.createElement("div",{className:"error-icon"},e.createElement("i",{className:"fa fa-exclamation-circle"})),e.createElement("div",{className:"error-content"},e.createElement("h3",null,"Error Occurred"),e.createElement("p",null,(e=>{if(e instanceof Response)switch(e.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 ${e.status}: ${e.statusText||"Something went wrong."}`}return e?.message||"Something went wrong. Please try again later."})(t))))}function _(){return e.createElement("div",{className:"loading-screen"},e.createElement("div",{className:"loading-container"},e.createElement("div",{className:"loading-spinner"}),e.createElement("div",{className:"loading-text"},"Loading...")))}var M,x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},N={};!function(){return M||(M=1,function(e){!function(){var t="object"==typeof globalThis?globalThis:"object"==typeof x?x:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=r(e);function r(e,t){return function(n,r){Object.defineProperty(e,n,{configurable:!0,writable:!0,value:r}),t&&t(n,r)}}void 0!==t.Reflect&&(n=r(t.Reflect,n)),function(e,t){var n=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,a=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=r&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,l={create:i?function(){return pe(Object.create(null))}:s?function(){return pe({__proto__:null})}:function(){return pe({})},has:c?function(e,t){return n.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return n.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:le(),d="function"==typeof WeakMap?WeakMap:ue(),h=r?Symbol.for("@reflect-metadata:registry"):void 0,m=ae(),v=oe(m);function y(e,t,n,r){if(F(n)){if(!K(e))throw new TypeError;if(!G(t))throw new TypeError;return N(e,t)}if(!K(e))throw new TypeError;if(!z(t))throw new TypeError;if(!z(r)&&!F(r)&&!D(r))throw new TypeError;return D(r)&&(r=void 0),T(e,t,n=q(n),r)}function g(e,t){function n(n,r){if(!z(n))throw new TypeError;if(!F(r)&&!J(r))throw new TypeError;P(e,t,n,r)}return n}function E(e,t,n,r){if(!z(n))throw new TypeError;return F(r)||(r=q(r)),P(e,t,n,r)}function b(e,t,n){if(!z(t))throw new TypeError;return F(n)||(n=q(n)),A(e,t,n)}function w(e,t,n){if(!z(t))throw new TypeError;return F(n)||(n=q(n)),C(e,t,n)}function O(e,t,n){if(!z(t))throw new TypeError;return F(n)||(n=q(n)),k(e,t,n)}function S(e,t,n){if(!z(t))throw new TypeError;return F(n)||(n=q(n)),L(e,t,n)}function _(e,t){if(!z(e))throw new TypeError;return F(t)||(t=q(t)),I(e,t)}function M(e,t){if(!z(e))throw new TypeError;return F(t)||(t=q(t)),j(e,t)}function x(e,t,n){if(!z(t))throw new TypeError;if(F(n)||(n=q(n)),!z(t))throw new TypeError;F(n)||(n=q(n));var r=se(t,n,!1);return!F(r)&&r.OrdinaryDeleteMetadata(e,t,n)}function N(e,t){for(var n=e.length-1;n>=0;--n){var r=(0,e[n])(t);if(!F(r)&&!D(r)){if(!G(r))throw new TypeError;t=r}}return t}function T(e,t,n,r){for(var a=e.length-1;a>=0;--a){var o=(0,e[a])(t,n,r);if(!F(o)&&!D(o)){if(!z(o))throw new TypeError;r=o}}return r}function A(e,t,n){if(C(e,t,n))return!0;var r=ne(t);return!D(r)&&A(e,r,n)}function C(e,t,n){var r=se(t,n,!1);return!F(r)&&H(r.OrdinaryHasOwnMetadata(e,t,n))}function k(e,t,n){if(C(e,t,n))return L(e,t,n);var r=ne(t);return D(r)?void 0:k(e,r,n)}function L(e,t,n){var r=se(t,n,!1);if(!F(r))return r.OrdinaryGetOwnMetadata(e,t,n)}function P(e,t,n,r){se(n,r,!0).OrdinaryDefineOwnMetadata(e,t,n,r)}function I(e,t){var n=j(e,t),r=ne(e);if(null===r)return n;var a=I(r,t);if(a.length<=0)return n;if(n.length<=0)return a;for(var o=new f,i=[],s=0,c=n;s<c.length;s++){var l=c[s];o.has(l)||(o.add(l),i.push(l))}for(var u=0,p=a;u<p.length;u++){l=p[u];o.has(l)||(o.add(l),i.push(l))}return i}function j(e,t){var n=se(e,t,!1);return n?n.OrdinaryOwnMetadataKeys(e,t):[]}function V(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function F(e){return void 0===e}function D(e){return null===e}function R(e){return"symbol"==typeof e}function z(e){return"object"==typeof e?null!==e:"function"==typeof e}function B(e,t){switch(V(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var n="string",r=Q(e,a);if(void 0!==r){var o=r.call(e,n);if(z(o))throw new TypeError;return o}return $(e)}function $(e,t){var n,r,a=e.toString;if(W(a)&&!z(r=a.call(e)))return r;if(W(n=e.valueOf)&&!z(r=n.call(e)))return r;throw new TypeError}function H(e){return!!e}function U(e){return""+e}function q(e){var t=B(e);return R(t)?t:U(t)}function K(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function W(e){return"function"==typeof e}function G(e){return"function"==typeof e}function J(e){switch(V(e)){case 3:case 4:return!0;default:return!1}}function Y(e,t){return e===t||e!=e&&t!=t}function Q(e,t){var n=e[t];if(null!=n){if(!W(n))throw new TypeError;return n}}function X(e){var t=Q(e,o);if(!W(t))throw new TypeError;var n=t.call(e);if(!z(n))throw new TypeError;return n}function Z(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function ne(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===u)return t;if(t!==u)return t;var n=e.prototype,r=n&&Object.getPrototypeOf(n);if(null==r||r===Object.prototype)return t;var a=r.constructor;return"function"!=typeof a||a===e?t:a}function re(){var e,n,r,a;F(h)||void 0===t.Reflect||h in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=ie(t.Reflect));var o=new d,i={registerProvider:s,getProvider:l,setProvider:m};return i;function s(t){if(!Object.isExtensible(i))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case F(n):n=t;break;case n===t:break;case F(r):r=t;break;case r===t:break;default:void 0===a&&(a=new f),a.add(t)}}function c(t,o){if(!F(n)){if(n.isProviderFor(t,o))return n;if(!F(r)){if(r.isProviderFor(t,o))return n;if(!F(a))for(var i=X(a);;){var s=ee(i);if(!s)return;var c=Z(s);if(c.isProviderFor(t,o))return te(i),c}}}if(!F(e)&&e.isProviderFor(t,o))return e}function l(e,t){var n,r=o.get(e);return F(r)||(n=r.get(t)),F(n)?(F(n=c(e,t))||(F(r)&&(r=new p,o.set(e,r)),r.set(t,n)),n):n}function u(e){if(F(e))throw new TypeError;return n===e||r===e||!F(a)&&a.has(e)}function m(e,t,n){if(!u(n))throw new Error("Metadata provider not registered.");var r=l(e,t);if(r!==n){if(!F(r))return!1;var a=o.get(e);F(a)&&(a=new p,o.set(e,a)),a.set(t,n)}return!0}}function ae(){var e;return!F(h)&&z(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[h]),F(e)&&(e=re()),!F(h)&&z(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function oe(e){var t=new d,n={isProviderFor:function(e,n){var r=t.get(e);return!F(r)&&r.has(n)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:a,OrdinaryGetOwnMetadata:o,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return m.registerProvider(n),n;function r(r,a,o){var i=t.get(r),s=!1;if(F(i)){if(!o)return;i=new p,t.set(r,i),s=!0}var c=i.get(a);if(F(c)){if(!o)return;if(c=new p,i.set(a,c),!e.setProvider(r,a,n))throw i.delete(a),s&&t.delete(r),new Error("Wrong provider for target.")}return c}function a(e,t,n){var a=r(t,n,!1);return!F(a)&&H(a.has(e))}function o(e,t,n){var a=r(t,n,!1);if(!F(a))return a.get(e)}function i(e,t,n,a){r(n,a,!0).set(e,t)}function s(e,t){var n=[],a=r(e,t,!1);if(F(a))return n;for(var o=X(a.keys()),i=0;;){var s=ee(o);if(!s)return n.length=i,n;var c=Z(s);try{n[i]=c}catch(e){try{te(o)}finally{throw e}}i++}}function c(e,n,a){var o=r(n,a,!1);if(F(o))return!1;if(!o.delete(e))return!1;if(0===o.size){var i=t.get(n);F(i)||(i.delete(a),0===i.size&&t.delete(i))}return!0}}function ie(e){var t=e.defineMetadata,n=e.hasOwnMetadata,r=e.getOwnMetadata,a=e.getOwnMetadataKeys,o=e.deleteMetadata,i=new d;return{isProviderFor:function(e,t){var n=i.get(e);return!(F(n)||!n.has(t))||!!a(e,t).length&&(F(n)&&(n=new f,i.set(e,n)),n.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:o}}function se(e,t,n){var r=m.getProvider(e,t);if(!F(r))return r;if(n){if(m.setProvider(e,t,v))return v;throw new Error("Illegal state.")}}function ce(){var e={},t=[],n=function(){function e(e,t,n){this._index=0,this._keys=e,this._values=t,this._selector=n}return e.prototype["@@iterator"]=function(){return this},e.prototype[o]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var n=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:n,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}(),r=function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var n=this._find(e,!0);return this._values[n]=t,this},t.prototype.delete=function(t){var n=this._find(t,!1);if(n>=0){for(var r=this._keys.length,a=n+1;a<r;a++)this._keys[a-1]=this._keys[a],this._values[a-1]=this._values[a];return this._keys.length--,this._values.length--,Y(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new n(this._keys,this._values,a)},t.prototype.values=function(){return new n(this._keys,this._values,i)},t.prototype.entries=function(){return new n(this._keys,this._values,s)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[o]=function(){return this.entries()},t.prototype._find=function(e,t){if(!Y(this._cacheKey,e)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(Y(this._keys[n],e)){this._cacheIndex=n;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();return r;function a(e,t){return e}function i(e,t){return t}function s(e,t){return[e,t]}}function le(){return function(){function e(){this._map=new p}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[o]=function(){return this.keys()},e}()}function ue(){var e=16,t=l.create(),r=a();return function(){function e(){this._key=a()}return e.prototype.has=function(e){var t=o(e,!1);return void 0!==t&&l.has(t,this._key)},e.prototype.get=function(e){var t=o(e,!1);return void 0!==t?l.get(t,this._key):void 0},e.prototype.set=function(e,t){return o(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=o(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=a()},e}();function a(){var e;do{e="@@WeakMap@@"+c()}while(l.has(t,e));return t[e]=!0,e}function o(e,t){if(!n.call(e,r)){if(!t)return;Object.defineProperty(e,r,{value:l.create()})}return e[r]}function i(e,t){for(var n=0;n<t;++n)e[n]=255*Math.random()|0;return e}function s(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):i(t,e),t}return i(new Array(e),e)}function c(){var t=s(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var n="",r=0;r<e;++r){var a=t[r];4!==r&&6!==r&&8!==r||(n+="-"),a<16&&(n+="0"),n+=a.toString(16).toLowerCase()}return n}}function pe(e){return e.__=void 0,delete e.__,e}e("decorate",y),e("metadata",g),e("defineMetadata",E),e("hasMetadata",b),e("hasOwnMetadata",w),e("getMetadata",O),e("getOwnMetadata",S),e("getMetadataKeys",_),e("getOwnMetadataKeys",M),e("deleteMetadata",x)}(n,t),void 0===t.Reflect&&(t.Reflect=e)}()}(e||(e={}))),N;var e}();const T="List";function A(e){return Reflect.getMetadata(T,e)}const C=Symbol("cell");function k(e){return(t,n)=>{const r=Reflect.getMetadata(C,t)||[];if(Reflect.defineMetadata(C,[...r,n.toString()],t),e){const r=`${C.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,e,t)}}}function L(e){const t=e.prototype;return(Reflect.getMetadata(C,t)||[]).map((e=>{const n=Reflect.getMetadata(`${C.toString()}:${e}:options`,t)||{};return{...n,name:n?.name??e}}))}function P({pagination:t,onPageChange:n}){const{total:r,page:a,limit:o}=t,i=Math.floor(r/o);if(i<=1)return null;return e.createElement("div",{className:"pagination"},e.createElement("button",{onClick:()=>n(a-1),className:"pagination-item "+(1===a?"disabled":""),disabled:1===a,"aria-disabled":1===a},"Previous"),(()=>{const t=[];for(let r=1;r<=Math.min(2,i);r++)t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a-2>3&&t.push(e.createElement("span",{key:"ellipsis1",className:"pagination-ellipsis"},"..."));for(let r=Math.max(3,a-2);r<=Math.min(i-2,a+2);r++)r>2&&r<i-1&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a+2<i-2&&t.push(e.createElement("span",{key:"ellipsis2",className:"pagination-ellipsis"},"..."));for(let r=Math.max(i-1,3);r<=i;r++)r>2&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));return t})(),e.createElement("button",{onClick:()=>n(a+1),className:"pagination-item "+(a===i?"disabled":""),disabled:a===i,"aria-disabled":a===i},"Next"))}var I,j,V;function F(){return F=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},F.apply(null,arguments)}var D,R=function(e){return c.createElement("svg",F({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),I||(I=c.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),j||(j=c.createElement("path",{d:"M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5v2H5v14h14v-5z"})),V||(V=c.createElement("path",{d:"M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"})))};function z(){return z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},z.apply(null,arguments)}var B=function(e){return c.createElement("svg",z({xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e),D||(D=c.createElement("path",{d:"M22 3H2l8 9.46V19l4 2v-8.54z"})))};function $({field:t,value:r,onChange:a}){if("static-select"===t.filter?.type){const o=t.filter;return e.createElement(n,{id:t.name,menuPortalTarget:document.body,styles:{control:(e,t)=>({...e,backgroundColor:"#1f2937",borderColor:t.isFocused?"#6366f1":"#374151",boxShadow:t.isFocused?"0 0 0 1px #6366f1":"none","&:hover":{borderColor:"#6366f1"},borderRadius:"6px",padding:"2px",color:"white"}),option:(e,t)=>({...e,backgroundColor:t.isSelected?"#6366f1":t.isFocused?"#374151":"#1f2937",color:"white","&:active":{backgroundColor:"#6366f1"},"&:hover":{backgroundColor:"#374151"},cursor:"pointer"}),input:e=>({...e,color:"white"}),placeholder:e=>({...e,color:"#9ca3af"}),singleValue:e=>({...e,color:"white"}),menuPortal:e=>({...e,zIndex:9999}),menu:e=>({...e,backgroundColor:"#1f2937",border:"1px solid #374151",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"}),menuList:e=>({...e,padding:"4px"}),dropdownIndicator:e=>({...e,color:"#9ca3af","&:hover":{color:"#6366f1"}}),clearIndicator:e=>({...e,color:"#9ca3af","&:hover":{color:"#6366f1"}})},value:r?{value:r,label:o.options.find((e=>e.value===r))?.label||r}:null,onChange:e=>a(e?.value||""),options:o.options.map((e=>({value:e.value,label:e.label}))),placeholder:`Filter by ${t.title||t.name}`,isClearable:!0})}return e.createElement("input",{type:"number"===t.type?"number":"text",id:t.name,value:r||"",onChange:e=>a(e.target.value),placeholder:`Filter by ${t.title||t.name}`})}function H({isOpen:t,onClose:n,onApplyFilters:r,listData:a,activeFilters:o}){const[i,s]=e.useState(o??{}),c=e.useRef(null),l=e.useMemo((()=>a.cells.filter((e=>!!e.filter))),[a.cells]);if(e.useEffect((()=>{const e=e=>{c.current&&!c.current.contains(e.target)&&n()};return t&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[t,n]),!t)return null;return e.createElement("div",{className:"filter-popup-overlay"},e.createElement("div",{ref:c,className:"filter-popup"},e.createElement("div",{className:"filter-popup-header"},e.createElement("h3",null,"Filter"),e.createElement("button",{onClick:n,className:"close-button"},"×")),e.createElement("div",{className:"filter-popup-content"},l.map((t=>e.createElement("div",{key:t.name,className:"filter-field"},e.createElement("label",{htmlFor:t.name},t.title||t.name),e.createElement($,{field:t,value:i[t.name||""],onChange:e=>((e,t)=>{s((n=>({...n,[e]:t})))})(t.name||"",e)}))))),e.createElement("div",{className:"filter-popup-footer"},e.createElement("button",{onClick:n,className:"cancel-button"},"Cancel"),e.createElement("button",{onClick:()=>{r(i),n()},className:"apply-button"},"Apply Filters"))))}const U=({listData:n,filtered:r,onFilterClick:a,customHeader:o})=>{const i=e.useMemo((()=>n.cells.filter((e=>!!e.filter))),[n.cells]),s=n.list?.headers;return e.createElement("div",{className:"list-header"},e.createElement("div",{className:"header-title"},s?.title||"List"),o&&e.createElement("div",{className:"header-custom"},o),e.createElement("div",{className:"header-actions"},!!i.length&&e.createElement("button",{onClick:a,className:"filter-button"},e.createElement(B,{className:"icon icon-filter "+(r?"active":"")}),"Filter"),s?.create&&e.createElement(t.Link,{to:s.create.path,className:"create-button"},e.createElement(R,{className:"icon icon-create"}),s.create.label)))};function q({htmlFor:t,label:n,fieldName:r}){return e.createElement("label",{htmlFor:t},n??r.charAt(0).toUpperCase()+r.slice(1))}const K=Object.freeze({BEFORE:"before",HOVER:"hover",AFTER:"after"});function W(t){return e.createElement("div",null,e.createElement("img",{...t,style:{width:100}}),e.createElement("p",null,t.name," ",e.createElement("span",{style:{whiteSpace:"none"}},"(",(e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB","TB"][t]})(t.size),")")))}function G(){const{register:t,formState:{errors:n},watch:a,setValue:o,clearErrors:i,setError:s}=r.useFormContext(),c=a("uploader");return e.useEffect((()=>{t("uploader",{required:!0})}),[t]),e.createElement("div",null,e.createElement("span",{className:"form-error",style:{bottom:2,top:"unset"}},"required"===n.uploader?.type&&"At least 1 image is required!","custom"===n.uploader?.type&&n.uploader.message?.toString()),e.createElement(J,{reset:c,onError:e=>{e?s("uploader",{type:"custom",message:e}):(o("uploader",{files:[]}),i("uploader"))},onClear:()=>{o("uploader",{files:[]}),i("uploader")},onFilesChange:e=>{o("uploader",{files:e})}}))}function J(t){const[n,r]=e.useState(K.BEFORE),[a,o]=e.useState(t.value||[]),[i,s]=e.useState([]),[c,l]=e.useState(0);console.log("files",i);const u=e.useRef(null),p=e.useRef(null);e.useEffect((()=>{const e=u.current;if(!e)return;const n=e=>{e.preventDefault(),e.stopPropagation(),f()},a=e=>{e.preventDefault(),e.stopPropagation(),d()},o=e=>{e.preventDefault(),e.stopPropagation()},c=e=>{e.preventDefault(),e.stopPropagation(),l(0);const n=e.dataTransfer?.files;if(!n)return;s([]),r(K.AFTER);const a=[];for(let e=0;e<n.length;e++){const r=new FileReader;r.onload=r=>{if(!r.target)return;h([...i,{file:n[e],image:r.target.result}])&&(a.push(n[e]),p.current&&(p.current.files=n),s([])),t.onFilesChange&&t.onFilesChange(a)},r.readAsDataURL(n[e])}p.current&&(p.current.files=n)};return e.addEventListener("dragenter",n,!1),e.addEventListener("dragleave",a,!1),e.addEventListener("dragover",o,!1),e.addEventListener("drop",c,!1),()=>{e.removeEventListener("dragenter",n),e.removeEventListener("dragleave",a),e.removeEventListener("dragover",o),e.removeEventListener("drop",c)}}),[i]);const f=()=>{l((e=>e+1)),r(K.HOVER)},d=()=>{l((e=>e-1==0?(r(K.BEFORE),0):e-1))},h=e=>{const n=(e=>{if(!e)return null;if(e.length>=10)return"you can't send more than 10 images";for(let t=0;t<e.length;t++){const n=e[t].file,r=n.name.split(".");if(!["png","jpg","jpeg"].includes(r[r.length-1]))return'Extension of the file can only be "png", "jpg" or "jpeg" ';if(n&&n.size>1048576)return`Size of "${n.name}" can't be bigger than 1mb`}return null})(e);return n||s(e),t.onError?.(n),n};return e.createElement("div",{ref:u,className:"multi-image form-element dropzone "+n},e.createElement("input",{ref:p,type:"file",style:{display:"none"},className:"target",name:"file"}),e.createElement("div",{className:"container"},e.createElement("button",{className:"trash",onClick:()=>{s([]),p.current&&(p.current.value=""),t.onClear?.()},type:"button"},"Delete All"),(()=>{const t=[];if(i){console.log("----\x3e",i);for(let n=0;n<i.length;n++){let r="image";t.push(e.createElement("div",{key:n,className:"image-container"},e.createElement("div",{className:r},e.createElement(W,{name:i[n].file.name,src:i[n].image,size:i[n].file.size}))))}}return t})(),e.createElement("div",null,e.createElement("button",{type:"button",onClick:()=>{const e=document.getElementById("file__");e&&e.click()},className:"plus"},e.createElement("span",null,"+ Add Image",e.createElement("p",null,"Drag image here or Select Image")))),e.createElement("input",{hidden:!0,id:"file__",multiple:!0,type:"file",onChange:e=>{const t=e.target.files;if(t){s([]),r(K.AFTER);for(let e=0;e<t.length;e++){const n=new FileReader;n.onload=n=>{n.target&&h([...i,{file:t[e],image:n.target.result}])},n.readAsDataURL(t[e])}p.current&&(p.current.files=t)}}})))}function Y({id:t,...n}){return e.createElement("input",{type:"checkbox",id:t,className:"checkbox",...n})}function Q({input:t,register:n}){const a=r.useFormContext(),o=a.getValues(t.name);return e.createElement("div",null,o?.map(((r,o)=>e.createElement("div",{key:o},t.nestedFields?.map((r=>e.createElement(X,{key:r.name?.toString()??"",baseName:t.name+"["+o+"]",input:r,register:n,error:t.name?{message:a.formState.errors[t.name]?.message}:void 0})))))))}function X({input:t,register:n,error:r,baseName:a}){const o=(a?a.toString()+".":"")+t.name||"";return e.createElement("div",{className:"form-field"},e.createElement(q,{htmlFor:o,label:t.label,fieldName:o}),(()=>{switch(t.type){case"textarea":return e.createElement("textarea",{...n(o),placeholder:t.placeholder,id:o});case"select":return e.createElement("select",{...n(o),id:o},e.createElement("option",{value:""},"Select ",o),t.options?.map((t=>e.createElement("option",{key:t.value,value:t.value},t.label))));case"input":return e.createElement("input",{type:t.inputType,...n(o),placeholder:t.placeholder,id:o});case"file-upload":return e.createElement(G,null);case"checkbox":return e.createElement(Y,{...n(o),id:o});case"hidden":return e.createElement("input",{type:"hidden",...n(o),id:o});case"nested":return e.createElement(Q,{input:t,register:n})}})(),r&&e.createElement("span",{className:"error-message"},r.message))}function Z({formOptions:n,onSubmit:a,getDetailsData:o,redirectBackOnSuccess:i}){const s=t.useParams(),c=r.useForm({resolver:n.resolver}),l=t.useNavigate(),u=n.inputs;return e.useEffect((()=>{o&&o(s).then((e=>{c.reset({...e})}))}),[s,c.reset]),e.createElement("div",{className:"form-wrapper"},e.createElement(r.FormProvider,{...c},e.createElement("form",{onSubmit:c.handleSubmit((async e=>{await a(e),i&&l(-1)}),((e,t)=>{console.log("error creating creation",e,t)}))},e.createElement("div",null,u?.map((t=>e.createElement(X,{key:t.name||"",input:t,register:c.register,error:t.name?{message:c.formState.errors[t.name]?.message}:void 0}))),e.createElement("button",{type:"submit",className:"submit-button"},"Submit")))))}class ee extends e.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}render(){return this.state.hasError?e.createElement("div",{className:"error-boundary"},e.createElement("div",{className:"error-boundary__content"},e.createElement("div",{className:"error-boundary__icon"},e.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},e.createElement("circle",{cx:"12",cy:"12",r:"10"}),e.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),e.createElement("h1",null,"Oops! Something went wrong"),e.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),e.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&e.createElement("details",{className:"error-boundary__details"},e.createElement("summary",null,"Error Details"),e.createElement("pre",null,this.state.error?.toString()),e.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}const te=Symbol("input");function ne(e){const t=e.prototype;return(Reflect.getMetadata(te,t)||[]).map((e=>{const n=Reflect.getMetadata(`${te.toString()}:${e}:options`,t)||{},r=n?.inputType??(a=e,["password"].some((e=>a.toLowerCase().includes(e)))?"password":"text");var a;return{...n,editable:n.editable??!0,sensitive:n.sensitive,name:n?.name??e,label:n?.label??e,placeholder:n?.placeholder??e,inputType:r,type:n?.type??"input",selectOptions:n?.selectOptions??[],cancelPasswordValidationOnEdit:n?.cancelPasswordValidationOnEdit??"password"===r}}))}function re(e){return Reflect.getMetadata("FormMetadata",e)}const ae=(e,t,n)=>{if(e&&"reportValidity"in e){const a=r.get(n,t);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},oe=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?ae(r.ref,n,e):r&&r.refs&&r.refs.forEach((t=>ae(t,n,e)))}},ie=(e,t)=>{t.shouldUseNativeValidation&&oe(e,t);const n={};for(const a in e){const o=r.get(t.fields,a),i=Object.assign(e[a]||{},{ref:o&&o.ref});if(se(t.names||Object.keys(e),a)){const e=Object.assign({},r.get(n,a));r.set(e,"root",i),r.set(n,a,e)}else r.set(n,a,i)}return n},se=(e,t)=>{const n=ce(t);return e.some((e=>ce(e).match(`^${n}\\.\\d+`)))};function ce(e){return e.replace(/\]|\[/g,"")}var le;!function(e){e[e.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",e[e.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",e[e.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(le||(le={}));var ue=function(){function e(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return e.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},e.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},e.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},e.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},e.prototype.findTransformMetadatas=function(e,t,n){return this.findMetadatas(this._transformMetadatas,e,t).filter((function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?n===le.CLASS_TO_CLASS||n===le.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||n===le.CLASS_TO_PLAIN))}))},e.prototype.findExcludeMetadata=function(e,t){return this.findMetadata(this._excludeMetadatas,e,t)},e.prototype.findExposeMetadata=function(e,t){return this.findMetadata(this._exposeMetadatas,e,t)},e.prototype.findExposeMetadataByCustomName=function(e,t){return this.getExposedMetadatas(e).find((function(e){return e.options&&e.options.name===t}))},e.prototype.findTypeMetadata=function(e,t){return this.findMetadata(this._typeMetadatas,e,t)},e.prototype.getStrategy=function(e){var t=this._excludeMetadatas.get(e),n=t&&t.get(void 0),r=this._exposeMetadatas.get(e),a=r&&r.get(void 0);return n&&a||!n&&!a?"none":n?"excludeAll":"exposeAll"},e.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},e.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},e.prototype.getExposedProperties=function(e,t){return this.getExposedMetadatas(e).filter((function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?t===le.CLASS_TO_CLASS||t===le.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||t===le.CLASS_TO_PLAIN))})).map((function(e){return e.propertyName}))},e.prototype.getExcludedProperties=function(e,t){return this.getExcludedMetadatas(e).filter((function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?t===le.CLASS_TO_CLASS||t===le.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||t===le.CLASS_TO_PLAIN))})).map((function(e){return e.propertyName}))},e.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},e.prototype.getMetadata=function(e,t){var n,r=e.get(t);r&&(n=Array.from(r.values()).filter((function(e){return void 0!==e.propertyName})));for(var a=[],o=0,i=this.getAncestors(t);o<i.length;o++){var s=i[o],c=e.get(s);if(c){var l=Array.from(c.values()).filter((function(e){return void 0!==e.propertyName}));a.push.apply(a,l)}}return a.concat(n||[])},e.prototype.findMetadata=function(e,t,n){var r=e.get(t);if(r){var a=r.get(n);if(a)return a}for(var o=0,i=this.getAncestors(t);o<i.length;o++){var s=i[o],c=e.get(s);if(c){var l=c.get(n);if(l)return l}}},e.prototype.findMetadatas=function(e,t,n){var r,a=e.get(t);a&&(r=a.get(n));for(var o=[],i=0,s=this.getAncestors(t);i<s.length;i++){var c=s[i],l=e.get(c);l&&l.has(n)&&o.push.apply(o,l.get(n))}return o.slice().reverse().concat((r||[]).slice().reverse())},e.prototype.getAncestors=function(e){if(!e)return[];if(!this._ancestorsMap.has(e)){for(var t=[],n=Object.getPrototypeOf(e.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))t.push(n);this._ancestorsMap.set(e,t)}return this._ancestorsMap.get(e)},e}(),pe=new ue;var fe=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))};var de=function(){function e(e,t){this.transformationType=e,this.options=t,this.recursionStack=new Set}return e.prototype.transform=function(e,t,n,r,a,o){var i,s=this;if(void 0===o&&(o=0),Array.isArray(t)||t instanceof Set){var c=r&&this.transformationType===le.PLAIN_TO_CLASS?function(e){var t=new e;return t instanceof Set||"push"in t?t:[]}(r):[];return t.forEach((function(t,r){var a=e?e[r]:void 0;if(s.options.enableCircularCheck&&s.isCircular(t))s.transformationType===le.CLASS_TO_CLASS&&(c instanceof Set?c.add(t):c.push(t));else{var i=void 0;if("function"!=typeof n&&n&&n.options&&n.options.discriminator&&n.options.discriminator.property&&n.options.discriminator.subTypes){if(s.transformationType===le.PLAIN_TO_CLASS){i=n.options.discriminator.subTypes.find((function(e){return e.name===t[n.options.discriminator.property]}));var l={newObject:c,object:t,property:void 0},u=n.typeFunction(l);i=void 0===i?u:i.value,n.options.keepDiscriminatorProperty||delete t[n.options.discriminator.property]}s.transformationType===le.CLASS_TO_CLASS&&(i=t.constructor),s.transformationType===le.CLASS_TO_PLAIN&&(t[n.options.discriminator.property]=n.options.discriminator.subTypes.find((function(e){return e.value===t.constructor})).name)}else i=n;var p=s.transform(a,t,i,void 0,t instanceof Map,o+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(n!==String||a){if(n!==Number||a){if(n!==Boolean||a){if((n===Date||t instanceof Date)&&!a)return t instanceof Date?new Date(t.valueOf()):null==t?t:new Date(t);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(n===Buffer||t instanceof Buffer)&&!a)return null==t?t:Buffer.from(t);if(null===(i=t)||"object"!=typeof i||"function"!=typeof i.then||a){if(a||null===t||"object"!=typeof t||"function"!=typeof t.then){if("object"==typeof t&&null!==t){n||t.constructor===Object||(Array.isArray(t)||t.constructor!==Array)&&(n=t.constructor),!n&&e&&(n=e.constructor),this.options.enableCircularCheck&&this.recursionStack.add(t);var l=this.getKeys(n,t,a),u=e||{};e||this.transformationType!==le.PLAIN_TO_CLASS&&this.transformationType!==le.CLASS_TO_CLASS||(u=a?new Map:n?new n:{});for(var p=function(r){if("__proto__"===r||"constructor"===r)return"continue";var i=r,s=r,c=r;if(!f.options.ignoreDecorators&&n)if(f.transformationType===le.PLAIN_TO_CLASS)(l=pe.findExposeMetadataByCustomName(n,r))&&(c=l.propertyName,s=l.propertyName);else if(f.transformationType===le.CLASS_TO_PLAIN||f.transformationType===le.CLASS_TO_CLASS){var l;(l=pe.findExposeMetadata(n,r))&&l.options&&l.options.name&&(s=l.options.name)}var p=void 0;p=f.transformationType===le.PLAIN_TO_CLASS?t[i]:t instanceof Map?t.get(i):t[i]instanceof Function?t[i]():t[i];var d=void 0,h=p instanceof Map;if(n&&a)d=n;else if(n){var m=pe.findTypeMetadata(n,c);if(m){var v={newObject:u,object:t,property:c},y=m.typeFunction?m.typeFunction(v):m.reflectedType;m.options&&m.options.discriminator&&m.options.discriminator.property&&m.options.discriminator.subTypes?t[i]instanceof Array?d=m:(f.transformationType===le.PLAIN_TO_CLASS&&(d=void 0===(d=m.options.discriminator.subTypes.find((function(e){if(p&&p instanceof Object&&m.options.discriminator.property in p)return e.name===p[m.options.discriminator.property]})))?y:d.value,m.options.keepDiscriminatorProperty||p&&p instanceof Object&&m.options.discriminator.property in p&&delete p[m.options.discriminator.property]),f.transformationType===le.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===le.CLASS_TO_PLAIN&&p&&(p[m.options.discriminator.property]=m.options.discriminator.subTypes.find((function(e){return e.value===p.constructor})).name)):d=y,h=h||m.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(e){return e.target===n&&!!e.properties[c]})).forEach((function(e){return d=e.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===le.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",n.prototype,c);g&&(d=g)}}var E=Array.isArray(t[i])?f.getReflectedType(n,c):void 0,b=e?e[i]:void 0;if(u.constructor.prototype){var w=Object.getOwnPropertyDescriptor(u.constructor.prototype,s);if((f.transformationType===le.PLAIN_TO_CLASS||f.transformationType===le.CLASS_TO_CLASS)&&(w&&!w.set||u[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===le.CLASS_TO_CLASS){S=p;(void 0!==(S=f.applyCustomTransformations(S,n,r,t,f.transformationType))||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}}else{var O=f.transformationType===le.PLAIN_TO_CLASS?s:r,S=void 0;f.transformationType===le.CLASS_TO_PLAIN?(S=t[O],S=f.applyCustomTransformations(S,n,O,t,f.transformationType),S=t[O]===S?p:S,S=f.transform(b,S,d,E,h,o+1)):void 0===p&&f.options.exposeDefaultValues?S=u[s]:(S=f.transform(b,p,d,E,h,o+1),S=f.applyCustomTransformations(S,n,O,t,f.transformationType)),(void 0!==S||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}},f=this,d=0,h=l;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(t),u}return t}return t}return new Promise((function(e,r){t.then((function(t){return e(s.transform(void 0,t,n,void 0,void 0,o+1))}),r)}))}return null==t?t:Boolean(t)}return null==t?t:Number(t)}return null==t?t:String(t)},e.prototype.applyCustomTransformations=function(e,t,n,r,a){var o=this,i=pe.findTransformMetadatas(t,n,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(e){return!e.options||o.checkVersion(e.options.since,e.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(e){return!e.options||o.checkGroups(e.options.groups)})):i.filter((function(e){return!e.options||!e.options.groups||!e.options.groups.length}))).forEach((function(t){e=t.transformFn({value:e,key:n,obj:r,type:a,options:o.options})})),e},e.prototype.isCircular=function(e){return this.recursionStack.has(e)},e.prototype.getReflectedType=function(e,t){if(e){var n=pe.findTypeMetadata(e,t);return n?n.reflectedType:void 0}},e.prototype.getKeys=function(e,t,n){var r=this,a=pe.getStrategy(e);"none"===a&&(a=this.options.strategy||"exposeAll");var o=[];if(("exposeAll"===a||n)&&(o=t instanceof Map?Array.from(t.keys()):Object.keys(t)),n)return o;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&e){var i=pe.getExposedProperties(e,this.transformationType),s=pe.getExcludedProperties(e,this.transformationType);o=fe(fe([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&e){i=pe.getExposedProperties(e,this.transformationType);this.transformationType===le.PLAIN_TO_CLASS&&(i=i.map((function(t){var n=pe.findExposeMetadata(e,t);return n&&n.options&&n.options.name?n.options.name:t}))),o=this.options.excludeExtraneousValues?i:o.concat(i);var c=pe.getExcludedProperties(e,this.transformationType);c.length>0&&(o=o.filter((function(e){return!c.includes(e)}))),void 0!==this.options.version&&(o=o.filter((function(t){var n=pe.findExposeMetadata(e,t);return!n||!n.options||r.checkVersion(n.options.since,n.options.until)}))),o=this.options.groups&&this.options.groups.length?o.filter((function(t){var n=pe.findExposeMetadata(e,t);return!n||!n.options||r.checkGroups(n.options.groups)})):o.filter((function(t){var n=pe.findExposeMetadata(e,t);return!(n&&n.options&&n.options.groups&&n.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(o=o.filter((function(e){return r.options.excludePrefixes.every((function(t){return e.substr(0,t.length)!==t}))}))),o=o.filter((function(e,t,n){return n.indexOf(e)===t}))},e.prototype.checkVersion=function(e,t){var n=!0;return n&&e&&(n=this.options.version>=e),n&&t&&(n=this.options.version<t),n},e.prototype.checkGroups=function(e){return!e||this.options.groups.some((function(t){return e.includes(t)}))},e}(),he={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},me=function(){return me=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},me.apply(this,arguments)},ve=new(function(){function e(){}return e.prototype.instanceToPlain=function(e,t){return new de(le.CLASS_TO_PLAIN,me(me({},he),t)).transform(void 0,e,void 0,void 0,void 0,void 0)},e.prototype.classToPlainFromExist=function(e,t,n){return new de(le.CLASS_TO_PLAIN,me(me({},he),n)).transform(t,e,void 0,void 0,void 0,void 0)},e.prototype.plainToInstance=function(e,t,n){return new de(le.PLAIN_TO_CLASS,me(me({},he),n)).transform(void 0,t,e,void 0,void 0,void 0)},e.prototype.plainToClassFromExist=function(e,t,n){return new de(le.PLAIN_TO_CLASS,me(me({},he),n)).transform(e,t,void 0,void 0,void 0,void 0)},e.prototype.instanceToInstance=function(e,t){return new de(le.CLASS_TO_CLASS,me(me({},he),t)).transform(void 0,e,void 0,void 0,void 0,void 0)},e.prototype.classToClassFromExist=function(e,t,n){return new de(le.CLASS_TO_CLASS,me(me({},he),n)).transform(t,e,void 0,void 0,void 0,void 0)},e.prototype.serialize=function(e,t){return JSON.stringify(this.instanceToPlain(e,t))},e.prototype.deserialize=function(e,t,n){var r=JSON.parse(t);return this.plainToInstance(e,r,n)},e.prototype.deserializeArray=function(e,t,n){var r=JSON.parse(t);return this.plainToInstance(e,r,n)},e}());var ye=function(e){this.groups=[],this.each=!1,this.context=void 0,this.type=e.type,this.name=e.name,this.target=e.target,this.propertyName=e.propertyName,this.constraints=null==e?void 0:e.constraints,this.constraintCls=e.constraintCls,this.validationTypeOptions=e.validationTypeOptions,e.validationOptions&&(this.message=e.validationOptions.message,this.groups=e.validationOptions.groups,this.always=e.validationOptions.always,this.each=e.validationOptions.each,this.context=e.validationOptions.context)},ge=function(){function e(){}return e.prototype.transform=function(e){var t=[];return Object.keys(e.properties).forEach((function(n){e.properties[n].forEach((function(r){var a={message:r.message,groups:r.groups,always:r.always,each:r.each},o={type:r.type,name:r.name,target:e.name,propertyName:n,constraints:r.constraints,validationTypeOptions:r.options,validationOptions:a};t.push(new ye(o))}))})),t},e}();function Ee(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function be(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}var we=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Oe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},Se=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))},_e=function(){function e(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(e.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),e.prototype.addValidationSchema=function(e){var t=this;(new ge).transform(e).forEach((function(e){return t.addValidationMetadata(e)}))},e.prototype.addValidationMetadata=function(e){var t=this.validationMetadatas.get(e.target);t?t.push(e):this.validationMetadatas.set(e.target,[e])},e.prototype.addConstraintMetadata=function(e){var t=this.constraintMetadatas.get(e.target);t?t.push(e):this.constraintMetadatas.set(e.target,[e])},e.prototype.groupByPropertyName=function(e){var t={};return e.forEach((function(e){t[e.propertyName]||(t[e.propertyName]=[]),t[e.propertyName].push(e)})),t},e.prototype.getTargetValidationMetadatas=function(e,t,n,r,a){var o,i,s=function(e){return void 0!==e.always?e.always:(!e.groups||!e.groups.length)&&n},c=function(e){return!(!r||a&&a.length||!e.groups||!e.groups.length)},l=(this.validationMetadatas.get(e)||[]).filter((function(n){return(n.target===e||n.target===t)&&(!!s(n)||!c(n)&&(!(a&&a.length>0)||n.groups&&!!n.groups.find((function(e){return-1!==a.indexOf(e)}))))})),u=[];try{for(var p=we(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=Oe(f.value,2),h=d[0],m=d[1];e.prototype instanceof h&&u.push.apply(u,Se([],Oe(m),!1))}}catch(e){o={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}var v=u.filter((function(t){return"string"!=typeof t.target&&(t.target!==e&&((!(t.target instanceof Function)||e.prototype instanceof t.target)&&(!!s(t)||!c(t)&&(!(a&&a.length>0)||t.groups&&!!t.groups.find((function(e){return-1!==a.indexOf(e)}))))))})).filter((function(e){return!l.find((function(t){return t.propertyName===e.propertyName&&t.type===e.type}))}));return l.concat(v)},e.prototype.getTargetValidatorConstraints=function(e){return this.constraintMetadatas.get(e)||[]},e}();var Me=function(){function e(){}return e.prototype.toString=function(e,t,n,r){var a=this;void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===n&&(n=""),void 0===r&&(r=!1);var o=e?"[1m":"",i=e?"[22m":"",s=function(e){return" - property ".concat(o).concat(n).concat(e).concat(i," has failed the following constraints: ").concat(o).concat((r?Object.values:Object.keys)(null!==(t=a.constraints)&&void 0!==t?t:{}).join(", ")).concat(i," \n");var t};if(t){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(n?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(t){return t.toString(e,!0,"".concat(n).concat(c),r)})).join(""):""}return"An instance of ".concat(o).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(t){return t.toString(e,!0,a.property,r)})).join(""):"")},e}(),xe=function(){function e(){}return e.isValid=function(e){var t=this;return"isValid"!==e&&"getMessage"!==e&&-1!==Object.keys(this).map((function(e){return t[e]})).indexOf(e)},e.CUSTOM_VALIDATION="customValidation",e.NESTED_VALIDATION="nestedValidation",e.PROMISE_VALIDATION="promiseValidation",e.CONDITIONAL_VALIDATION="conditionalValidation",e.WHITELIST="whitelistValidation",e.IS_DEFINED="isDefined",e}();var Ne=function(){function e(){}return e.replaceMessageSpecialTokens=function(e,t){var n;return e instanceof Function?n=e(t):"string"==typeof e&&(n=e),n&&Array.isArray(t.constraints)&&t.constraints.forEach((function(e,t){n=n.replace(new RegExp("\\$constraint".concat(t+1),"g"),function(e){return Array.isArray(e)?e.join(", "):("symbol"==typeof e&&(e=e.description),"".concat(e))}(e))})),n&&void 0!==t.value&&null!==t.value&&["string","boolean","number"].includes(typeof t.value)&&(n=n.replace(/\$value/g,t.value)),n&&(n=n.replace(/\$property/g,t.property)),n&&(n=n.replace(/\$target/g,t.targetName)),n},e}(),Te=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},Ae=function(){function e(e,t){this.validator=e,this.validatorOptions=t,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var e=Ee();return e.classValidatorMetadataStorage||(e.classValidatorMetadataStorage=new _e),e.classValidatorMetadataStorage}()}return e.prototype.execute=function(e,t,n){var r,a,o=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(r=this.validatorOptions)||void 0===r?void 0:r.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,l=void 0===(null===(a=this.validatorOptions)||void 0===a?void 0:a.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,u=this.metadataStorage.getTargetValidationMetadatas(e.constructor,t,c,s,i),p=this.metadataStorage.groupByPropertyName(u);if(this.validatorOptions&&l&&!u.length){var f=new Me;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=e),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void n.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(e,p,n),Object.keys(p).forEach((function(t){var r=e[t],a=p[t].filter((function(e){return e.type===xe.IS_DEFINED})),i=p[t].filter((function(e){return e.type!==xe.IS_DEFINED&&e.type!==xe.WHITELIST}));r instanceof Promise&&i.find((function(e){return e.type===xe.PROMISE_VALIDATION}))?o.awaitingPromises.push(r.then((function(r){o.performValidations(e,r,t,a,i,n)}))):o.performValidations(e,r,t,a,i,n)}))},e.prototype.whitelist=function(e,t,n){var r=this,a=[];Object.keys(e).forEach((function(e){t[e]&&0!==t[e].length||a.push(e)})),a.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?a.forEach((function(t){var a,o=r.generateValidationError(e,e[t],t);o.constraints=((a={})[xe.WHITELIST]="property ".concat(t," should not exist"),a),o.children=void 0,n.push(o)})):a.forEach((function(t){return delete e[t]})))},e.prototype.stripEmptyErrors=function(e){var t=this;return e.filter((function(e){if(e.children&&(e.children=t.stripEmptyErrors(e.children)),0===Object.keys(e.constraints).length){if(0===e.children.length)return!1;delete e.constraints}return!0}))},e.prototype.performValidations=function(e,t,n,r,a,o){var i=a.filter((function(e){return e.type===xe.CUSTOM_VALIDATION})),s=a.filter((function(e){return e.type===xe.NESTED_VALIDATION})),c=a.filter((function(e){return e.type===xe.CONDITIONAL_VALIDATION})),l=this.generateValidationError(e,t,n);o.push(l),this.conditionalValidations(e,t,c)&&(this.customValidations(e,t,r,l),this.mapContexts(e,t,r,l),void 0===t&&this.validatorOptions&&!0===this.validatorOptions.skipUndefinedProperties||null===t&&this.validatorOptions&&!0===this.validatorOptions.skipNullProperties||null==t&&this.validatorOptions&&!0===this.validatorOptions.skipMissingProperties||(this.customValidations(e,t,i,l),this.nestedValidations(t,s,l),this.mapContexts(e,t,a,l),this.mapContexts(e,t,i,l)))},e.prototype.generateValidationError=function(e,t,n){var r=new Me;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(r.target=e),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(r.value=t),r.property=n,r.children=[],r.constraints={},r},e.prototype.conditionalValidations=function(e,t,n){return n.map((function(n){return n.constraints[0](e,t)})).reduce((function(e,t){return e&&t}),!0)},e.prototype.customValidations=function(e,t,n,r){var a=this;n.forEach((function(n){a.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach((function(o){if(!(o.async&&a.ignoreAsyncValidations||a.validatorOptions&&a.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0)){var i={targetName:e.constructor?e.constructor.name:void 0,property:n.propertyName,object:e,value:t,constraints:n.constraints};if(n.each&&(Array.isArray(t)||t instanceof Set||t instanceof Map)){var s,c=((s=t)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map((function(e){return o.instance.validate(e,i)}));if(c.some((function(e){return be(e)}))){var l=c.map((function(e){return be(e)?e:Promise.resolve(e)})),u=Promise.all(l).then((function(i){if(!i.every((function(e){return e}))){var s=Te(a.createValidationError(e,t,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(u)}else{if(!c.every((function(e){return e}))){var p=Te(a.createValidationError(e,t,n,o),2);m=p[0],v=p[1];r.constraints[m]=v}}}else{var f=o.instance.validate(t,i);if(be(f)){var d=f.then((function(i){if(!i){var s=Te(a.createValidationError(e,t,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(d)}else if(!f){var h=Te(a.createValidationError(e,t,n,o),2),m=h[0],v=h[1];r.constraints[m]=v}}}}))}))},e.prototype.nestedValidations=function(e,t,n){var r=this;void 0!==e&&t.forEach((function(a){if((a.type===xe.NESTED_VALIDATION||a.type===xe.PROMISE_VALIDATION)&&!(r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0))if(Array.isArray(e)||e instanceof Set||e instanceof Map)(e instanceof Set?Array.from(e):e).forEach((function(a,o){r.performValidations(e,a,o.toString(),[],t,n.children)}));else if(e instanceof Object){var o="string"==typeof a.target?a.target:a.target.name;r.execute(e,o,n.children)}else{var i=Te(r.createValidationError(a.target,e,a),2),s=i[0],c=i[1];n.constraints[s]=c}}))},e.prototype.mapContexts=function(e,t,n,r){var a=this;return n.forEach((function(e){if(e.context){var t=void 0;if(e.type===xe.CUSTOM_VALIDATION)t=a.metadataStorage.getTargetValidatorConstraints(e.constraintCls)[0];var n=a.getConstraintType(e,t);r.constraints[n]&&(r.contexts||(r.contexts={}),r.contexts[n]=Object.assign(r.contexts[n]||{},e.context))}}))},e.prototype.createValidationError=function(e,t,n,r){var a=e.constructor?e.constructor.name:void 0,o=this.getConstraintType(n,r),i={targetName:a,property:n.propertyName,object:e,value:t,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||r&&r.instance.defaultMessage instanceof Function&&(s=r.instance.defaultMessage(i)),[o,Ne.replaceMessageSpecialTokens(s,i)]},e.prototype.getConstraintType=function(e,t){return t&&t.name?t.name:e.type},e}(),Ce=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},ke=function(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},Le=function(){function e(){}return e.prototype.validate=function(e,t,n){return this.coreValidate(e,t,n)},e.prototype.validateOrReject=function(e,t,n){return Ce(this,void 0,void 0,(function(){var r;return ke(this,(function(a){switch(a.label){case 0:return[4,this.coreValidate(e,t,n)];case 1:return(r=a.sent()).length?[2,Promise.reject(r)]:[2]}}))}))},e.prototype.validateSync=function(e,t,n){var r="string"==typeof e?t:e,a="string"==typeof e?e:void 0,o=new Ae(this,"string"==typeof e?n:t);o.ignoreAsyncValidations=!0;var i=[];return o.execute(r,a,i),o.stripEmptyErrors(i)},e.prototype.coreValidate=function(e,t,n){var r="string"==typeof e?t:e,a="string"==typeof e?e:void 0,o=new Ae(this,"string"==typeof e?n:t),i=[];return o.execute(r,a,i),Promise.all(o.awaitingPromises).then((function(){return o.stripEmptyErrors(i)}))},e}(),Pe=new(function(){function e(){this.instances=[]}return e.prototype.get=function(e){var t=this.instances.find((function(t){return t.type===e}));return t||(t={type:e,object:new e},this.instances.push(t)),t.object},e}());function Ie(e){return Pe.get(e)}function je(e,t,n){return"string"==typeof e?Ie(Le).validate(e,t,n):Ie(Le).validate(e,t)}function Ve(e,t,n){return"string"==typeof e?Ie(Le).validateSync(e,t,n):Ie(Le).validateSync(e,t)}function Fe(e,t,n,r){return void 0===n&&(n={}),void 0===r&&(r=""),e.reduce((function(e,n){var a=r?r+"."+n.property:n.property;if(n.constraints){var o=Object.keys(n.constraints)[0];e[a]={type:o,message:n.constraints[o]};var i=e[a];t&&i&&Object.assign(i,{types:n.constraints})}return n.children&&n.children.length&&Fe(n.children,t,e,a),e}),n)}function De(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),function(r,a,o){try{var i=t.validator,s=(c=e,l=r,u=t.transformer,ve.plainToInstance(c,l,u));return Promise.resolve(("sync"===n.mode?Ve:je)(s,i)).then((function(e){return e.length?{values:{},errors:ie(Fe(e,!o.shouldUseNativeValidation&&"all"===o.criteriaMode),o)}:(o.shouldUseNativeValidation&&oe({},o),{values:n.raw?Object.assign({},r):s,errors:{}})}))}catch(e){return Promise.reject(e)}var c,l,u}}function Re(e){return{resolver:De(e),form:re(e),inputs:ne(e)}}const ze=o.createWithEqualityFn()(a.persist((e=>({screens:null,user:null,screenPaths:{}})),{name:"app-store-1",storage:a.createJSONStorage((()=>localStorage)),partialize:e=>({user:e.user})}),i.shallow);function Be({menu:n,getIcons:r,onLogout:a}){const{screens:o,screenPaths:i}=ze((e=>({screens:e.screens??{},screenPaths:e.screenPaths??{}}))),[s,c]=e.useState(!0),l=t.useLocation(),u=t.useNavigate(),p=e=>{if("/"===e)return l.pathname===e;const t=e.replace(/^\/+|\/+$/g,""),n=l.pathname.replace(/^\/+|\/+$/g,"");return n===t||n.startsWith(`${t}/`)};return e.createElement("div",{className:"sidebar "+(s?"open":"closed")},e.createElement("button",{className:"toggle-button",onClick:()=>c(!s),"aria-label":s?"Collapse sidebar":"Expand sidebar","aria-expanded":s},s?"<":">"),e.createElement("nav",{className:"nav-links"},n?.(o).map(((n,a)=>e.createElement(t.Link,{key:a,to:n.path,className:"nav-link "+(p(n.path)?"active":""),"aria-current":p(n.path)?"page":void 0},e.createElement("span",{className:"nav-links-icon"},r?.(n.iconType)),s?e.createElement("span",null,n.name):null)))),a&&e.createElement("div",{className:"sidebar-footer"},e.createElement("button",{className:"logout-button",onClick:()=>{a&&(a(),u(i.login))},"aria-label":"Logout"},e.createElement("span",{className:"nav-links-icon"},e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M6 12H2V4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{d:"M10 8L14 4M14 4L10 0M14 4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))),s?e.createElement("span",null,"Logout"):null)))}exports.Cell=k,exports.Counter=function({image:t,text:n,targetNumber:r,duration:a=2e3}){const[o,i]=e.useState(0);return e.useEffect((()=>{let e,t;const n=o=>{e||(e=o);const s=o-e,c=Math.min(s/a,1);i(Math.floor(c*r)),c<1&&(t=requestAnimationFrame(n))};return t=requestAnimationFrame(n),()=>{t&&cancelAnimationFrame(t)}}),[r,a]),e.createElement("div",{className:"counter-container"},e.createElement("div",{className:"counter-image"},t),e.createElement("div",{className:"counter-text"},n),e.createElement("div",{className:"counter-value"},o))},exports.Crud=function(e){return t=>{e&&Reflect.defineMetadata("Crud",e,t)}},exports.FormPage=function({model:t,getDetailsData:n,onSubmit:r,redirect:a,redirectBackOnSuccess:o=!0,...i}){const s=e.useMemo((()=>Re(t)),[t]);return e.createElement(Z,{getDetailsData:n,onSubmit:r,formOptions:s,redirectBackOnSuccess:o})},exports.ImageCell=function(e){return k({...e,type:"image"})},exports.Input=function(e){return(t,n)=>{const r=Reflect.getMetadata(te,t)||[];if(Reflect.defineMetadata(te,[...r,n.toString()],t),e){const r=`${te.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,e,t)}}},exports.Layout=function({children:n,menu:r,getIcons:a,logout:o}){const{user:i,screenPaths:s}=ze((e=>({user:e.user,screenPaths:e.screenPaths})));ze();const c=t.useNavigate();return i||c(s.login),e.createElement("div",{className:"layout"},e.createElement(Be,{onLogout:()=>{o&&o()},menu:r,getIcons:a}),e.createElement("main",{className:"content"},n))},exports.List=function(e){return t=>{e&&Reflect.defineMetadata(T,e,t)}},exports.ListPage=function({model:n,getData:r,onRemoveItem:a,customHeader:o}){const[i,s]=e.useState(!0),[c,l]=e.useState({total:0,page:0,limit:0}),[u,p]=e.useState(null),[f,d]=e.useState(null),[h,m]=e.useState(!1),[v,y]=e.useState(),g=e.useMemo((()=>{return{list:A(e=n),cells:L(e)};var e}),[n]),E=t.useParams(),b=t.useNavigate(),w=e.useCallback((async(e,t)=>{s(!0);try{const n=await r({page:e,filters:t??v??{}});p(n.data),l({total:n.total,page:n.page,limit:n.limit})}catch(e){d(e),console.error(e)}finally{s(!1)}}),[r,v]);return e.useEffect((()=>{const e=new URLSearchParams(location.search),t={};e.forEach(((e,n)=>{t[n]=e})),y(t)}),[location.search]),e.useEffect((()=>{v&&w(parseInt(E.page)||1,v)}),[w,E.page,v]),i?e.createElement(_,null):f?e.createElement(S,{error:f}):e.createElement("div",{className:"list"},e.createElement(U,{listData:g,filtered:!(!v||!Object.keys(v).length),onFilterClick:()=>m(!0),customHeader:o}),e.createElement(O,{listData:g,data:u,onRemoveItem:async e=>{a&&alert({title:"Are you sure you want to delete this item?",message:"This action cannot be undone.",onConfirm:async()=>{await a(e),await w(c.page)}})}}),e.createElement("div",{className:"list-footer"},e.createElement(P,{pagination:c,onPageChange:w})),e.createElement(H,{isOpen:h,activeFilters:v,onClose:()=>m(!1),onApplyFilters:e=>{y(e);const t=new URLSearchParams;Object.entries(e).forEach((([e,n])=>{null!=n&&""!==n&&t.append(e,String(n))}));const n=t.toString(),r=`${location.pathname}${n?`?${n}`:""}`;b(r),w(1,e)},listData:g}))},exports.Login=function({onLogin:n}){const{register:a,handleSubmit:o,formState:{errors:i}}=r.useForm(),s=t.useNavigate();return e.createElement("div",{className:"login-container"},e.createElement("div",{className:"login-panel"},e.createElement("div",{className:"login-header"},e.createElement("h1",null,"Welcome Back"),e.createElement("p",null,"Please sign in to continue")),e.createElement("form",{onSubmit:o((async e=>{n.login(e.username,e.password).then((e=>{const{user:t,token:n}=e;localStorage.setItem("token",n),ze.setState({user:t}),s("/")}))})),className:"login-form"},e.createElement(X,{input:{name:"username",label:"Username",placeholder:"Enter your username",type:"input"},register:a,error:i.username}),e.createElement(X,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password",type:"input"},register:a,error:i.password}),e.createElement("div",{className:"form-actions"},e.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))},exports.Panel=function({children:t,init:n}){return e.useEffect((()=>{!function({screenPaths:e}){ze.setState({screenPaths:e})}(n())}),[n]),e.createElement(ee,null,t)},exports.getFormFields=Re,exports.getInputFields=ne;
|
package/dist/index.esm.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import*as t from"react";import e,{useRef as n,useMemo as r,useEffect as a,useState as o,useCallback as i,Component as s}from"react";import{Link as c,useParams as l,useNavigate as u,useLocation as p}from"react-router";import f from"react-select";import{useFormContext as d,useForm as h,FormProvider as m,get as y,set as v}from"react-hook-form";import{persist as g,createJSONStorage as E}from"zustand/middleware";import{createWithEqualityFn as b}from"zustand/traditional";import{shallow as w}from"zustand/vanilla/shallow";const O=()=>e.createElement("div",{className:"empty-list"},e.createElement("div",{className:"empty-list-content"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),e.createElement("polyline",{points:"13 2 13 9 20 9"})),e.createElement("h3",null,"No Data Found"),e.createElement("p",null,"There are no items to display at the moment.")));var S,_;function M(){return M=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},M.apply(null,arguments)}var T,N,x=function(e){return t.createElement("svg",M({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),S||(S=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),_||(_=t.createElement("path",{d:"m21 19-5.154-5.154a7 7 0 1 0-2 2L19 21zM5 10c0-2.757 2.243-5 5-5s5 2.243 5 5-2.243 5-5 5-5-2.243-5-5"})))};function A(){return A=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},A.apply(null,arguments)}var C,k,L=function(e){return t.createElement("svg",A({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),T||(T=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),N||(N=t.createElement("path",{d:"m13 6 5 5-9.507 9.507a1.765 1.765 0 0 1-.012-2.485l-.002-.003c-.69.676-1.8.673-2.485-.013a1.763 1.763 0 0 1-.036-2.455l-.008-.008c-.694.65-1.78.64-2.456-.036zm7.586-.414-2.172-2.172a2 2 0 0 0-2.828 0L14 5l5 5 1.586-1.586c.78-.78.78-2.047 0-2.828M3 18v3h3a3 3 0 0 0-3-3"})))};function P(){return P=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P.apply(null,arguments)}var I=function(e){return t.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),C||(C=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),k||(k=t.createElement("path",{d:"M6.187 8h11.625l-.695 11.125A2 2 0 0 1 15.12 21H8.88a2 2 0 0 1-1.997-1.875zM19 5v2H5V5h3V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1zm-9 0h4V4h-4z"})))};function j({data:t,listData:n,onRemoveItem:r}){const a=n.cells,o=n.list?.utilCells;return e.createElement("div",{className:"datagrid"},t&&0!==t.length?e.createElement("table",{className:"datagrid-table"},e.createElement("thead",null,e.createElement("tr",null,a.map((t=>e.createElement("th",{key:t.name},t.title??t.name))),o?.details&&e.createElement("th",null,"Details"),o?.edit&&e.createElement("th",null,"Edit"),o?.delete&&e.createElement("th",null,"Delete"))),e.createElement("tbody",null,t.map(((t,n)=>e.createElement("tr",{key:n},a.map((n=>{const r=t[n.name];let a=r??"-";switch(n.type){case"date":if(r){const t=new Date(r);a=`${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")}`}break;case"image":{const t=n;a=e.createElement("img",{width:100,height:100,src:t.baseUrl+r,style:{objectFit:"contain"}});break}default:a=r?r.toString():n?.placeHolder??"-"}return e.createElement("td",{key:n.name},a)})),o?.details&&e.createElement("td",null,e.createElement(c,{to:`${o.details.path}/${t.id}`,className:"util-cell-link"},e.createElement(x,{className:"icon icon-search"}),e.createElement("span",{className:"util-cell-label"},o.details.label))),o?.edit&&e.createElement("td",null,e.createElement(c,{to:`${o.edit.path}/${t.id}`,className:"util-cell-link"},e.createElement(L,{className:"icon icon-pencil"}),e.createElement("span",{className:"util-cell-label"},o.edit.label))),o?.delete&&e.createElement("td",null,e.createElement("a",{onClick:()=>{r?.(t)},className:"util-cell-link"},e.createElement(I,{className:"icon icon-trash"}),e.createElement("span",{className:"util-cell-label"},o.delete.label)))))))):e.createElement(O,null))}function V({error:t}){return e.createElement("div",{className:"error-container"},e.createElement("div",{className:"error-icon"},e.createElement("i",{className:"fa fa-exclamation-circle"})),e.createElement("div",{className:"error-content"},e.createElement("h3",null,"Error Occurred"),e.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."})(t))))}function D(){return e.createElement("div",{className:"loading-screen"},e.createElement("div",{className:"loading-container"},e.createElement("div",{className:"loading-spinner"}),e.createElement("div",{className:"loading-text"},"Loading...")))}var F,R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},z={};!function(){return F||(F=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof R?R:"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){}}(),n=r(t);function r(t,e){return function(n,r){Object.defineProperty(t,n,{configurable:!0,writable:!0,value:r}),e&&e(n,r)}}void 0!==e.Reflect&&(n=r(e.Reflect,n)),function(t,e){var n=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,a=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=r&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,l={create:i?function(){return pt(Object.create(null))}:s?function(){return pt({__proto__:null})}:function(){return pt({})},has:c?function(t,e){return n.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return n.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},u=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ct(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:lt(),d="function"==typeof WeakMap?WeakMap:ut(),h=r?Symbol.for("@reflect-metadata:registry"):void 0,m=at(),y=ot(m);function v(t,e,n,r){if(D(n)){if(!W(t))throw new TypeError;if(!q(e))throw new TypeError;return N(t,e)}if(!W(t))throw new TypeError;if(!z(e))throw new TypeError;if(!z(r)&&!D(r)&&!F(r))throw new TypeError;return F(r)&&(r=void 0),x(t,e,n=K(n),r)}function g(t,e){function n(n,r){if(!z(n))throw new TypeError;if(!D(r)&&!J(r))throw new TypeError;P(t,e,n,r)}return n}function E(t,e,n,r){if(!z(n))throw new TypeError;return D(r)||(r=K(r)),P(t,e,n,r)}function b(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),A(t,e,n)}function w(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),C(t,e,n)}function O(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),k(t,e,n)}function S(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),L(t,e,n)}function _(t,e){if(!z(t))throw new TypeError;return D(e)||(e=K(e)),I(t,e)}function M(t,e){if(!z(t))throw new TypeError;return D(e)||(e=K(e)),j(t,e)}function T(t,e,n){if(!z(e))throw new TypeError;if(D(n)||(n=K(n)),!z(e))throw new TypeError;D(n)||(n=K(n));var r=st(e,n,!1);return!D(r)&&r.OrdinaryDeleteMetadata(t,e,n)}function N(t,e){for(var n=t.length-1;n>=0;--n){var r=(0,t[n])(e);if(!D(r)&&!F(r)){if(!q(r))throw new TypeError;e=r}}return e}function x(t,e,n,r){for(var a=t.length-1;a>=0;--a){var o=(0,t[a])(e,n,r);if(!D(o)&&!F(o)){if(!z(o))throw new TypeError;r=o}}return r}function A(t,e,n){if(C(t,e,n))return!0;var r=nt(e);return!F(r)&&A(t,r,n)}function C(t,e,n){var r=st(e,n,!1);return!D(r)&&H(r.OrdinaryHasOwnMetadata(t,e,n))}function k(t,e,n){if(C(t,e,n))return L(t,e,n);var r=nt(e);return F(r)?void 0:k(t,r,n)}function L(t,e,n){var r=st(e,n,!1);if(!D(r))return r.OrdinaryGetOwnMetadata(t,e,n)}function P(t,e,n,r){st(n,r,!0).OrdinaryDefineOwnMetadata(t,e,n,r)}function I(t,e){var n=j(t,e),r=nt(t);if(null===r)return n;var a=I(r,e);if(a.length<=0)return n;if(n.length<=0)return a;for(var o=new f,i=[],s=0,c=n;s<c.length;s++){var l=c[s];o.has(l)||(o.add(l),i.push(l))}for(var u=0,p=a;u<p.length;u++){l=p[u];o.has(l)||(o.add(l),i.push(l))}return i}function j(t,e){var n=st(t,e,!1);return n?n.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 z(t){return"object"==typeof t?null!==t:"function"==typeof t}function B(t,e){switch(V(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var n="string",r=Q(t,a);if(void 0!==r){var o=r.call(t,n);if(z(o))throw new TypeError;return o}return $(t)}function $(t,e){var n,r,a=t.toString;if(G(a)&&!z(r=a.call(t)))return r;if(G(n=t.valueOf)&&!z(r=n.call(t)))return r;throw new TypeError}function H(t){return!!t}function U(t){return""+t}function K(t){var e=B(t);return R(e)?e:U(e)}function W(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function G(t){return"function"==typeof t}function q(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 n=t[e];if(null!=n){if(!G(n))throw new TypeError;return n}}function X(t){var e=Q(t,o);if(!G(e))throw new TypeError;var n=e.call(t);if(!z(n))throw new TypeError;return n}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 nt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===u)return e;if(e!==u)return e;var n=t.prototype,r=n&&Object.getPrototypeOf(n);if(null==r||r===Object.prototype)return e;var a=r.constructor;return"function"!=typeof a||a===t?e:a}function rt(){var t,n,r,a;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var o=new d,i={registerProvider:s,getProvider:l,setProvider:m};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(n):n=e;break;case n===e:break;case D(r):r=e;break;case r===e:break;default:void 0===a&&(a=new f),a.add(e)}}function c(e,o){if(!D(n)){if(n.isProviderFor(e,o))return n;if(!D(r)){if(r.isProviderFor(e,o))return n;if(!D(a))for(var i=X(a);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,o))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,o))return t}function l(t,e){var n,r=o.get(t);return D(r)||(n=r.get(e)),D(n)?(D(n=c(t,e))||(D(r)&&(r=new p,o.set(t,r)),r.set(e,n)),n):n}function u(t){if(D(t))throw new TypeError;return n===t||r===t||!D(a)&&a.has(t)}function m(t,e,n){if(!u(n))throw new Error("Metadata provider not registered.");var r=l(t,e);if(r!==n){if(!D(r))return!1;var a=o.get(t);D(a)&&(a=new p,o.set(t,a)),a.set(e,n)}return!0}}function at(){var t;return!D(h)&&z(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=rt()),!D(h)&&z(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function ot(t){var e=new d,n={isProviderFor:function(t,n){var r=e.get(t);return!D(r)&&r.has(n)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:a,OrdinaryGetOwnMetadata:o,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return m.registerProvider(n),n;function r(r,a,o){var i=e.get(r),s=!1;if(D(i)){if(!o)return;i=new p,e.set(r,i),s=!0}var c=i.get(a);if(D(c)){if(!o)return;if(c=new p,i.set(a,c),!t.setProvider(r,a,n))throw i.delete(a),s&&e.delete(r),new Error("Wrong provider for target.")}return c}function a(t,e,n){var a=r(e,n,!1);return!D(a)&&H(a.has(t))}function o(t,e,n){var a=r(e,n,!1);if(!D(a))return a.get(t)}function i(t,e,n,a){r(n,a,!0).set(t,e)}function s(t,e){var n=[],a=r(t,e,!1);if(D(a))return n;for(var o=X(a.keys()),i=0;;){var s=tt(o);if(!s)return n.length=i,n;var c=Z(s);try{n[i]=c}catch(t){try{et(o)}finally{throw t}}i++}}function c(t,n,a){var o=r(n,a,!1);if(D(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var i=e.get(n);D(i)||(i.delete(a),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,n=t.hasOwnMetadata,r=t.getOwnMetadata,a=t.getOwnMetadataKeys,o=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var n=i.get(t);return!(D(n)||!n.has(e))||!!a(t,e).length&&(D(n)&&(n=new f,i.set(t,n)),n.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:o}}function st(t,e,n){var r=m.getProvider(t,e);if(!D(r))return r;if(n){if(m.setProvider(t,e,y))return y;throw new Error("Illegal state.")}}function ct(){var t={},e=[],n=function(){function t(t,e,n){this._index=0,this._keys=t,this._values=e,this._selector=n}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var n=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:n,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}(),r=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 n=this._find(t,!0);return this._values[n]=e,this},e.prototype.delete=function(e){var n=this._find(e,!1);if(n>=0){for(var r=this._keys.length,a=n+1;a<r;a++)this._keys[a-1]=this._keys[a],this._values[a-1]=this._values[a];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 n(this._keys,this._values,a)},e.prototype.values=function(){return new n(this._keys,this._values,i)},e.prototype.entries=function(){return new n(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(Y(this._keys[n],t)){this._cacheIndex=n;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return r;function a(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function lt(){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[o]=function(){return this.keys()},t}()}function ut(){var t=16,e=l.create(),r=a();return function(){function t(){this._key=a()}return t.prototype.has=function(t){var e=o(t,!1);return void 0!==e&&l.has(e,this._key)},t.prototype.get=function(t){var e=o(t,!1);return void 0!==e?l.get(e,this._key):void 0},t.prototype.set=function(t,e){return o(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=o(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=a()},t}();function a(){var t;do{t="@@WeakMap@@"+c()}while(l.has(e,t));return e[t]=!0,t}function o(t,e){if(!n.call(t,r)){if(!e)return;Object.defineProperty(t,r,{value:l.create()})}return t[r]}function i(t,e){for(var n=0;n<e;++n)t[n]=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 n="",r=0;r<t;++r){var a=e[r];4!==r&&6!==r&&8!==r||(n+="-"),a<16&&(n+="0"),n+=a.toString(16).toLowerCase()}return n}}function pt(t){return t.__=void 0,delete t.__,t}t("decorate",v),t("metadata",g),t("defineMetadata",E),t("hasMetadata",b),t("hasOwnMetadata",w),t("getMetadata",O),t("getOwnMetadata",S),t("getMetadataKeys",_),t("getOwnMetadataKeys",M),t("deleteMetadata",T)}(n,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),z;var t}();const B="List";function $(t){return e=>{t&&Reflect.defineMetadata(B,t,e)}}function H(t){return Reflect.getMetadata(B,t)}const U=Symbol("cell");function K(t){return(e,n)=>{const r=Reflect.getMetadata(U,e)||[];if(Reflect.defineMetadata(U,[...r,n.toString()],e),t){const r=`${U.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,t,e)}}}function W(t){const e=t.prototype;return(Reflect.getMetadata(U,e)||[]).map((t=>{const n=Reflect.getMetadata(`${U.toString()}:${t}:options`,e)||{};return{...n,name:n?.name??t}}))}function G({pagination:t,onPageChange:n}){const{total:r,page:a,limit:o}=t,i=Math.floor(r/o);if(i<=1)return null;return e.createElement("div",{className:"pagination"},e.createElement("button",{onClick:()=>n(a-1),className:"pagination-item "+(1===a?"disabled":""),disabled:1===a,"aria-disabled":1===a},"Previous"),(()=>{const t=[];for(let r=1;r<=Math.min(2,i);r++)t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a-2>3&&t.push(e.createElement("span",{key:"ellipsis1",className:"pagination-ellipsis"},"..."));for(let r=Math.max(3,a-2);r<=Math.min(i-2,a+2);r++)r>2&&r<i-1&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a+2<i-2&&t.push(e.createElement("span",{key:"ellipsis2",className:"pagination-ellipsis"},"..."));for(let r=Math.max(i-1,3);r<=i;r++)r>2&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));return t})(),e.createElement("button",{onClick:()=>n(a+1),className:"pagination-item "+(a===i?"disabled":""),disabled:a===i,"aria-disabled":a===i},"Next"))}var q,J,Y;function Q(){return Q=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Q.apply(null,arguments)}var X,Z=function(e){return t.createElement("svg",Q({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),q||(q=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),J||(J=t.createElement("path",{d:"M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5v2H5v14h14v-5z"})),Y||(Y=t.createElement("path",{d:"M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"})))};function tt(){return tt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},tt.apply(null,arguments)}var et=function(e){return t.createElement("svg",tt({xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e),X||(X=t.createElement("path",{d:"M22 3H2l8 9.46V19l4 2v-8.54z"})))};function nt({field:t,value:n,onChange:r}){if("static-select"===t.filter?.type){const a=t.filter;return e.createElement(f,{id:t.name,menuPortalTarget:document.body,styles:{control:(t,e)=>({...t,backgroundColor:"#1f2937",borderColor:e.isFocused?"#6366f1":"#374151",boxShadow:e.isFocused?"0 0 0 1px #6366f1":"none","&:hover":{borderColor:"#6366f1"},borderRadius:"6px",padding:"2px",color:"white"}),option:(t,e)=>({...t,backgroundColor:e.isSelected?"#6366f1":e.isFocused?"#374151":"#1f2937",color:"white","&:active":{backgroundColor:"#6366f1"},"&:hover":{backgroundColor:"#374151"},cursor:"pointer"}),input:t=>({...t,color:"white"}),placeholder:t=>({...t,color:"#9ca3af"}),singleValue:t=>({...t,color:"white"}),menuPortal:t=>({...t,zIndex:9999}),menu:t=>({...t,backgroundColor:"#1f2937",border:"1px solid #374151",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"}),menuList:t=>({...t,padding:"4px"}),dropdownIndicator:t=>({...t,color:"#9ca3af","&:hover":{color:"#6366f1"}}),clearIndicator:t=>({...t,color:"#9ca3af","&:hover":{color:"#6366f1"}})},value:n?{value:n,label:a.options.find((t=>t.value===n))?.label||n}:null,onChange:t=>r(t?.value||""),options:a.options.map((t=>({value:t.value,label:t.label}))),placeholder:`Filter by ${t.title||t.name}`,isClearable:!0})}return e.createElement("input",{type:"number"===t.type?"number":"text",id:t.name,value:n||"",onChange:t=>r(t.target.value),placeholder:`Filter by ${t.title||t.name}`})}function rt({isOpen:t,onClose:o,onApplyFilters:i,listData:s,activeFilters:c}){const[l,u]=e.useState(c??{}),p=n(null),f=r((()=>s.cells.filter((t=>!!t.filter))),[s.cells]);if(a((()=>{const e=t=>{p.current&&!p.current.contains(t.target)&&o()};return t&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[t,o]),!t)return null;return e.createElement("div",{className:"filter-popup-overlay"},e.createElement("div",{ref:p,className:"filter-popup"},e.createElement("div",{className:"filter-popup-header"},e.createElement("h3",null,"Filter"),e.createElement("button",{onClick:o,className:"close-button"},"×")),e.createElement("div",{className:"filter-popup-content"},f.map((t=>e.createElement("div",{key:t.name,className:"filter-field"},e.createElement("label",{htmlFor:t.name},t.title||t.name),e.createElement(nt,{field:t,value:l[t.name||""],onChange:e=>((t,e)=>{u((n=>({...n,[t]:e})))})(t.name||"",e)}))))),e.createElement("div",{className:"filter-popup-footer"},e.createElement("button",{onClick:o,className:"cancel-button"},"Cancel"),e.createElement("button",{onClick:()=>{i(l),o()},className:"apply-button"},"Apply Filters"))))}const at=({listData:t,filtered:n,onFilterClick:a,customHeader:o})=>{const i=r((()=>t.cells.filter((t=>!!t.filter))),[t.cells]),s=t.list?.headers;return e.createElement("div",{className:"list-header"},e.createElement("div",{className:"header-title"},s?.title||"List"),o&&e.createElement("div",{className:"header-custom"},o),e.createElement("div",{className:"header-actions"},!!i.length&&e.createElement("button",{onClick:a,className:"filter-button"},e.createElement(et,{className:"icon icon-filter "+(n?"active":"")}),"Filter"),s?.create&&e.createElement(c,{to:s.create.path,className:"create-button"},e.createElement(Z,{className:"icon icon-create"}),s.create.label)))};function ot({model:t,getData:n,onRemoveItem:s,customHeader:c}){const[p,f]=o(!0),[d,h]=o({total:0,page:0,limit:0}),[m,y]=o(null),[v,g]=o(null),[E,b]=o(!1),[w,O]=o(),S=r((()=>{return{list:H(e=t),cells:W(e)};var e}),[t]),_=l(),M=u(),T=i((async(t,e)=>{f(!0);try{const r=await n({page:t,filters:e??w??{}});y(r.data),h({total:r.total,page:r.page,limit:r.limit})}catch(t){g(t),console.error(t)}finally{f(!1)}}),[n,w]);a((()=>{const t=new URLSearchParams(location.search),e={};t.forEach(((t,n)=>{e[n]=t})),O(e)}),[location.search]),a((()=>{w&&T(parseInt(_.page)||1,w)}),[T,_.page,w]);return p?e.createElement(D,null):v?e.createElement(V,{error:v}):e.createElement("div",{className:"list"},e.createElement(at,{listData:S,filtered:!(!w||!Object.keys(w).length),onFilterClick:()=>b(!0),customHeader:c}),e.createElement(j,{listData:S,data:m,onRemoveItem:async t=>{s&&alert({title:"Are you sure you want to delete this item?",message:"This action cannot be undone.",onConfirm:async()=>{await s(t),y(m.filter((e=>e.id!==t.id))),await T(d.page)}})}}),e.createElement("div",{className:"list-footer"},e.createElement(G,{pagination:d,onPageChange:T})),e.createElement(rt,{isOpen:E,activeFilters:w,onClose:()=>b(!1),onApplyFilters:t=>{O(t);const e=new URLSearchParams;Object.entries(t).forEach((([t,n])=>{null!=n&&""!==n&&e.append(t,String(n))}));const n=e.toString(),r=`${location.pathname}${n?`?${n}`:""}`;M(r),T(1,t)},listData:S}))}function it({htmlFor:t,label:n,fieldName:r}){return e.createElement("label",{htmlFor:t},n??r.charAt(0).toUpperCase()+r.slice(1))}const st=Object.freeze({BEFORE:"before",HOVER:"hover",AFTER:"after"});function ct(t){return e.createElement("div",null,e.createElement("img",{...t,style:{width:100}}),e.createElement("p",null,t.name," ",e.createElement("span",{style:{whiteSpace:"none"}},"(",(t=>{if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(2))+" "+["Bytes","KB","MB","GB","TB"][e]})(t.size),")")))}function lt(){const{register:t,formState:{errors:n},watch:r,setValue:o,clearErrors:i,setError:s}=d(),c=r("uploader");return a((()=>{t("uploader",{required:!0})}),[t]),e.createElement("div",null,e.createElement("span",{className:"form-error",style:{bottom:2,top:"unset"}},"required"===n.uploader?.type&&"At least 1 image is required!","custom"===n.uploader?.type&&n.uploader.message?.toString()),e.createElement(ut,{reset:c,onError:t=>{t?s("uploader",{type:"custom",message:t}):(o("uploader",{files:[]}),i("uploader"))},onClear:()=>{o("uploader",{files:[]}),i("uploader")},onFilesChange:t=>{o("uploader",{files:t})}}))}function ut(t){const[n,r]=e.useState(st.BEFORE),[a,o]=e.useState(t.value||[]),[i,s]=e.useState([]),[c,l]=e.useState(0);console.log("files",i);const u=e.useRef(null),p=e.useRef(null);e.useEffect((()=>{const e=u.current;if(!e)return;const n=t=>{t.preventDefault(),t.stopPropagation(),f()},a=t=>{t.preventDefault(),t.stopPropagation(),d()},o=t=>{t.preventDefault(),t.stopPropagation()},c=e=>{e.preventDefault(),e.stopPropagation(),l(0);const n=e.dataTransfer?.files;if(!n)return;s([]),r(st.AFTER);const a=[];for(let e=0;e<n.length;e++){const r=new FileReader;r.onload=r=>{if(!r.target)return;h([...i,{file:n[e],image:r.target.result}])&&(a.push(n[e]),p.current&&(p.current.files=n),s([])),t.onFilesChange&&t.onFilesChange(a)},r.readAsDataURL(n[e])}p.current&&(p.current.files=n)};return e.addEventListener("dragenter",n,!1),e.addEventListener("dragleave",a,!1),e.addEventListener("dragover",o,!1),e.addEventListener("drop",c,!1),()=>{e.removeEventListener("dragenter",n),e.removeEventListener("dragleave",a),e.removeEventListener("dragover",o),e.removeEventListener("drop",c)}}),[i]);const f=()=>{l((t=>t+1)),r(st.HOVER)},d=()=>{l((t=>t-1==0?(r(st.BEFORE),0):t-1))},h=e=>{const n=(t=>{if(!t)return null;if(t.length>=10)return"you can't send more than 10 images";for(let e=0;e<t.length;e++){const n=t[e].file,r=n.name.split(".");if(!["png","jpg","jpeg"].includes(r[r.length-1]))return'Extension of the file can only be "png", "jpg" or "jpeg" ';if(n&&n.size>1048576)return`Size of "${n.name}" can't be bigger than 1mb`}return null})(e);return n||s(e),t.onError?.(n),n};return e.createElement("div",{ref:u,className:"multi-image form-element dropzone "+n},e.createElement("input",{ref:p,type:"file",style:{display:"none"},className:"target",name:"file"}),e.createElement("div",{className:"container"},e.createElement("button",{className:"trash",onClick:()=>{s([]),p.current&&(p.current.value=""),t.onClear?.()},type:"button"},"Delete All"),(()=>{const t=[];if(i){console.log("----\x3e",i);for(let n=0;n<i.length;n++){let r="image";t.push(e.createElement("div",{key:n,className:"image-container"},e.createElement("div",{className:r},e.createElement(ct,{name:i[n].file.name,src:i[n].image,size:i[n].file.size}))))}}return t})(),e.createElement("div",null,e.createElement("button",{type:"button",onClick:()=>{const t=document.getElementById("file__");t&&t.click()},className:"plus"},e.createElement("span",null,"+ Add Image",e.createElement("p",null,"Drag image here or Select Image")))),e.createElement("input",{hidden:!0,id:"file__",multiple:!0,type:"file",onChange:t=>{const e=t.target.files;if(e){s([]),r(st.AFTER);for(let t=0;t<e.length;t++){const n=new FileReader;n.onload=n=>{n.target&&h([...i,{file:e[t],image:n.target.result}])},n.readAsDataURL(e[t])}p.current&&(p.current.files=e)}}})))}function pt({id:t,...n}){return e.createElement("input",{type:"checkbox",id:t,className:"checkbox",...n})}function ft({input:t,register:n}){const r=d(),a=r.getValues(t.name);return e.createElement("div",null,a?.map(((a,o)=>e.createElement("div",{key:o},t.nestedFields?.map((a=>e.createElement(dt,{key:a.name?.toString()??"",baseName:t.name+"["+o+"]",input:a,register:n,error:t.name?{message:r.formState.errors[t.name]?.message}:void 0})))))))}function dt({input:t,register:n,error:r,baseName:a}){const o=(a?a.toString()+".":"")+t.name||"";return e.createElement("div",{className:"form-field"},e.createElement(it,{htmlFor:o,label:t.label,fieldName:o}),(()=>{switch(t.type){case"textarea":return e.createElement("textarea",{...n(o),placeholder:t.placeholder,id:o});case"select":return e.createElement("select",{...n(o),id:o},e.createElement("option",{value:""},"Select ",o),t.options?.map((t=>e.createElement("option",{key:t.value,value:t.value},t.label))));case"input":return e.createElement("input",{type:t.inputType,...n(o),placeholder:t.placeholder,id:o});case"file-upload":return e.createElement(lt,null);case"checkbox":return e.createElement(pt,{...n(o),id:o});case"hidden":return e.createElement("input",{type:"hidden",...n(o),id:o});case"nested":return e.createElement(ft,{input:t,register:n})}})(),r&&e.createElement("span",{className:"error-message"},r.message))}function ht({formOptions:t,onSubmit:n,getDetailsData:r,redirectBackOnSuccess:o}){const i=l(),s=h({resolver:t.resolver}),c=u(),p=t.inputs;return a((()=>{r&&r(i).then((t=>{s.reset({...t})}))}),[i,s.reset]),e.createElement("div",{className:"form-wrapper"},e.createElement(m,{...s},e.createElement("form",{onSubmit:s.handleSubmit((async t=>{await n(t),o&&c(-1)}),((t,e)=>{console.log("error creating creation",t,e)}))},e.createElement("div",null,p?.map((t=>e.createElement(dt,{key:t.name||"",input:t,register:s.register,error:t.name?{message:s.formState.errors[t.name]?.message}:void 0}))),e.createElement("button",{type:"submit",className:"submit-button"},"Submit")))))}function mt({image:t,text:n,targetNumber:r,duration:i=2e3}){const[s,c]=o(0);return a((()=>{let t,e;const n=a=>{t||(t=a);const o=a-t,s=Math.min(o/i,1);c(Math.floor(s*r)),s<1&&(e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>{e&&cancelAnimationFrame(e)}}),[r,i]),e.createElement("div",{className:"counter-container"},e.createElement("div",{className:"counter-image"},t),e.createElement("div",{className:"counter-text"},n),e.createElement("div",{className:"counter-value"},s))}class yt extends s{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?e.createElement("div",{className:"error-boundary"},e.createElement("div",{className:"error-boundary__content"},e.createElement("div",{className:"error-boundary__icon"},e.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},e.createElement("circle",{cx:"12",cy:"12",r:"10"}),e.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),e.createElement("h1",null,"Oops! Something went wrong"),e.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),e.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&e.createElement("details",{className:"error-boundary__details"},e.createElement("summary",null,"Error Details"),e.createElement("pre",null,this.state.error?.toString()),e.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}const vt=Symbol("input");function gt(t){return(e,n)=>{const r=Reflect.getMetadata(vt,e)||[];if(Reflect.defineMetadata(vt,[...r,n.toString()],e),t){const r=`${vt.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,t,e)}}}function Et(t){const e=t.prototype;return(Reflect.getMetadata(vt,e)||[]).map((t=>{const n=Reflect.getMetadata(`${vt.toString()}:${t}:options`,e)||{},r=n?.inputType??(a=t,["password"].some((t=>a.toLowerCase().includes(t)))?"password":"text");var a;return{...n,editable:n.editable??!0,sensitive:n.sensitive,name:n?.name??t,label:n?.label??t,placeholder:n?.placeholder??t,inputType:r,type:n?.type??"input",selectOptions:n?.selectOptions??[],cancelPasswordValidationOnEdit:n?.cancelPasswordValidationOnEdit??"password"===r}}))}function bt(t){return Reflect.getMetadata("FormMetadata",t)}const wt=(t,e,n)=>{if(t&&"reportValidity"in t){const r=y(n,e);t.setCustomValidity(r&&r.message||""),t.reportValidity()}},Ot=(t,e)=>{for(const n in e.fields){const r=e.fields[n];r&&r.ref&&"reportValidity"in r.ref?wt(r.ref,n,t):r&&r.refs&&r.refs.forEach((e=>wt(e,n,t)))}},St=(t,e)=>{e.shouldUseNativeValidation&&Ot(t,e);const n={};for(const r in t){const a=y(e.fields,r),o=Object.assign(t[r]||{},{ref:a&&a.ref});if(_t(e.names||Object.keys(t),r)){const t=Object.assign({},y(n,r));v(t,"root",o),v(n,r,t)}else v(n,r,o)}return n},_t=(t,e)=>{const n=Mt(e);return t.some((t=>Mt(t).match(`^${n}\\.\\d+`)))};function Mt(t){return t.replace(/\]|\[/g,"")}var Tt;!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"}(Tt||(Tt={}));var Nt=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,n){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?n===Tt.CLASS_TO_CLASS||n===Tt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||n===Tt.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),n=e&&e.get(void 0),r=this._exposeMetadatas.get(t),a=r&&r.get(void 0);return n&&a||!n&&!a?"none":n?"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===Tt.CLASS_TO_CLASS||e===Tt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===Tt.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===Tt.CLASS_TO_CLASS||e===Tt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===Tt.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 n,r=t.get(e);r&&(n=Array.from(r.values()).filter((function(t){return void 0!==t.propertyName})));for(var a=[],o=0,i=this.getAncestors(e);o<i.length;o++){var s=i[o],c=t.get(s);if(c){var l=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));a.push.apply(a,l)}}return a.concat(n||[])},t.prototype.findMetadata=function(t,e,n){var r=t.get(e);if(r){var a=r.get(n);if(a)return a}for(var o=0,i=this.getAncestors(e);o<i.length;o++){var s=i[o],c=t.get(s);if(c){var l=c.get(n);if(l)return l}}},t.prototype.findMetadatas=function(t,e,n){var r,a=t.get(e);a&&(r=a.get(n));for(var o=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],l=t.get(c);l&&l.has(n)&&o.push.apply(o,l.get(n))}return o.slice().reverse().concat((r||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],n=Object.getPrototypeOf(t.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))e.push(n);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),xt=new Nt;var At=function(t,e,n){if(n||2===arguments.length)for(var r,a=0,o=e.length;a<o;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))};var Ct=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,n,r,a,o){var i,s=this;if(void 0===o&&(o=0),Array.isArray(e)||e instanceof Set){var c=r&&this.transformationType===Tt.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(r):[];return e.forEach((function(e,r){var a=t?t[r]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===Tt.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof n&&n&&n.options&&n.options.discriminator&&n.options.discriminator.property&&n.options.discriminator.subTypes){if(s.transformationType===Tt.PLAIN_TO_CLASS){i=n.options.discriminator.subTypes.find((function(t){return t.name===e[n.options.discriminator.property]}));var l={newObject:c,object:e,property:void 0},u=n.typeFunction(l);i=void 0===i?u:i.value,n.options.keepDiscriminatorProperty||delete e[n.options.discriminator.property]}s.transformationType===Tt.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===Tt.CLASS_TO_PLAIN&&(e[n.options.discriminator.property]=n.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=n;var p=s.transform(a,e,i,void 0,e instanceof Map,o+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(n!==String||a){if(n!==Number||a){if(n!==Boolean||a){if((n===Date||e instanceof Date)&&!a)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&&(n===Buffer||e instanceof Buffer)&&!a)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||a){if(a||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){n||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(n=e.constructor),!n&&t&&(n=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var l=this.getKeys(n,e,a),u=t||{};t||this.transformationType!==Tt.PLAIN_TO_CLASS&&this.transformationType!==Tt.CLASS_TO_CLASS||(u=a?new Map:n?new n:{});for(var p=function(r){if("__proto__"===r||"constructor"===r)return"continue";var i=r,s=r,c=r;if(!f.options.ignoreDecorators&&n)if(f.transformationType===Tt.PLAIN_TO_CLASS)(l=xt.findExposeMetadataByCustomName(n,r))&&(c=l.propertyName,s=l.propertyName);else if(f.transformationType===Tt.CLASS_TO_PLAIN||f.transformationType===Tt.CLASS_TO_CLASS){var l;(l=xt.findExposeMetadata(n,r))&&l.options&&l.options.name&&(s=l.options.name)}var p=void 0;p=f.transformationType===Tt.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(n&&a)d=n;else if(n){var m=xt.findTypeMetadata(n,c);if(m){var y={newObject:u,object:e,property:c},v=m.typeFunction?m.typeFunction(y):m.reflectedType;m.options&&m.options.discriminator&&m.options.discriminator.property&&m.options.discriminator.subTypes?e[i]instanceof Array?d=m:(f.transformationType===Tt.PLAIN_TO_CLASS&&(d=void 0===(d=m.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&m.options.discriminator.property in p)return t.name===p[m.options.discriminator.property]})))?v:d.value,m.options.keepDiscriminatorProperty||p&&p instanceof Object&&m.options.discriminator.property in p&&delete p[m.options.discriminator.property]),f.transformationType===Tt.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===Tt.CLASS_TO_PLAIN&&p&&(p[m.options.discriminator.property]=m.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=v,h=h||m.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===n&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===Tt.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",n.prototype,c);g&&(d=g)}}var E=Array.isArray(e[i])?f.getReflectedType(n,c):void 0,b=t?t[i]:void 0;if(u.constructor.prototype){var w=Object.getOwnPropertyDescriptor(u.constructor.prototype,s);if((f.transformationType===Tt.PLAIN_TO_CLASS||f.transformationType===Tt.CLASS_TO_CLASS)&&(w&&!w.set||u[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===Tt.CLASS_TO_CLASS){S=p;(void 0!==(S=f.applyCustomTransformations(S,n,r,e,f.transformationType))||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}}else{var O=f.transformationType===Tt.PLAIN_TO_CLASS?s:r,S=void 0;f.transformationType===Tt.CLASS_TO_PLAIN?(S=e[O],S=f.applyCustomTransformations(S,n,O,e,f.transformationType),S=e[O]===S?p:S,S=f.transform(b,S,d,E,h,o+1)):void 0===p&&f.options.exposeDefaultValues?S=u[s]:(S=f.transform(b,p,d,E,h,o+1),S=f.applyCustomTransformations(S,n,O,e,f.transformationType)),(void 0!==S||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}},f=this,d=0,h=l;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),u}return e}return e}return new Promise((function(t,r){e.then((function(e){return t(s.transform(void 0,e,n,void 0,void 0,o+1))}),r)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,n,r,a){var o=this,i=xt.findTransformMetadatas(e,n,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||o.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||o.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:n,obj:r,type:a,options:o.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var n=xt.findTypeMetadata(t,e);return n?n.reflectedType:void 0}},t.prototype.getKeys=function(t,e,n){var r=this,a=xt.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var o=[];if(("exposeAll"===a||n)&&(o=e instanceof Map?Array.from(e.keys()):Object.keys(e)),n)return o;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=xt.getExposedProperties(t,this.transformationType),s=xt.getExcludedProperties(t,this.transformationType);o=At(At([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=xt.getExposedProperties(t,this.transformationType);this.transformationType===Tt.PLAIN_TO_CLASS&&(i=i.map((function(e){var n=xt.findExposeMetadata(t,e);return n&&n.options&&n.options.name?n.options.name:e}))),o=this.options.excludeExtraneousValues?i:o.concat(i);var c=xt.getExcludedProperties(t,this.transformationType);c.length>0&&(o=o.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(o=o.filter((function(e){var n=xt.findExposeMetadata(t,e);return!n||!n.options||r.checkVersion(n.options.since,n.options.until)}))),o=this.options.groups&&this.options.groups.length?o.filter((function(e){var n=xt.findExposeMetadata(t,e);return!n||!n.options||r.checkGroups(n.options.groups)})):o.filter((function(e){var n=xt.findExposeMetadata(t,e);return!(n&&n.options&&n.options.groups&&n.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(o=o.filter((function(t){return r.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),o=o.filter((function(t,e,n){return n.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var n=!0;return n&&t&&(n=this.options.version>=t),n&&e&&(n=this.options.version<e),n},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),kt={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},Lt=function(){return Lt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},Lt.apply(this,arguments)},Pt=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new Ct(Tt.CLASS_TO_PLAIN,Lt(Lt({},kt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,n){return new Ct(Tt.CLASS_TO_PLAIN,Lt(Lt({},kt),n)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,n){return new Ct(Tt.PLAIN_TO_CLASS,Lt(Lt({},kt),n)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,n){return new Ct(Tt.PLAIN_TO_CLASS,Lt(Lt({},kt),n)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new Ct(Tt.CLASS_TO_CLASS,Lt(Lt({},kt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,n){return new Ct(Tt.CLASS_TO_CLASS,Lt(Lt({},kt),n)).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,n){var r=JSON.parse(e);return this.plainToInstance(t,r,n)},t.prototype.deserializeArray=function(t,e,n){var r=JSON.parse(e);return this.plainToInstance(t,r,n)},t}());var It=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)},jt=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(n){t.properties[n].forEach((function(r){var a={message:r.message,groups:r.groups,always:r.always,each:r.each},o={type:r.type,name:r.name,target:t.name,propertyName:n,constraints:r.constraints,validationTypeOptions:r.options,validationOptions:a};e.push(new It(o))}))})),e},t}();function Vt(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function Dt(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var Ft=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Rt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,o=n.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},zt=function(t,e,n){if(n||2===arguments.length)for(var r,a=0,o=e.length;a<o;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))},Bt=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 jt).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,n,r,a){var o,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&n},c=function(t){return!(!r||a&&a.length||!t.groups||!t.groups.length)},l=(this.validationMetadatas.get(t)||[]).filter((function(n){return(n.target===t||n.target===e)&&(!!s(n)||!c(n)&&(!(a&&a.length>0)||n.groups&&!!n.groups.find((function(t){return-1!==a.indexOf(t)}))))})),u=[];try{for(var p=Ft(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=Rt(f.value,2),h=d[0],m=d[1];t.prototype instanceof h&&u.push.apply(u,zt([],Rt(m),!1))}}catch(t){o={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}var y=u.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!s(e)||!c(e)&&(!(a&&a.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==a.indexOf(t)}))))))})).filter((function(t){return!l.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return l.concat(y)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();var $t=function(){function t(){}return t.prototype.toString=function(t,e,n,r){var a=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===n&&(n=""),void 0===r&&(r=!1);var o=t?"[1m":"",i=t?"[22m":"",s=function(t){return" - property ".concat(o).concat(n).concat(t).concat(i," has failed the following constraints: ").concat(o).concat((r?Object.values:Object.keys)(null!==(e=a.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(n?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(n).concat(c),r)})).join(""):""}return"An instance of ".concat(o).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,a.property,r)})).join(""):"")},t}(),Ht=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 Ut=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var n;return t instanceof Function?n=t(e):"string"==typeof t&&(n=t),n&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){n=n.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))})),n&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(n=n.replace(/\$value/g,e.value)),n&&(n=n.replace(/\$property/g,e.property)),n&&(n=n.replace(/\$target/g,e.targetName)),n},t}(),Kt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,o=n.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},Wt=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=Vt();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new Bt),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,n){var r,a,o=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(r=this.validatorOptions)||void 0===r?void 0:r.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,l=void 0===(null===(a=this.validatorOptions)||void 0===a?void 0:a.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,u=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,c,s,i),p=this.metadataStorage.groupByPropertyName(u);if(this.validatorOptions&&l&&!u.length){var f=new $t;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 n.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,n),Object.keys(p).forEach((function(e){var r=t[e],a=p[e].filter((function(t){return t.type===Ht.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==Ht.IS_DEFINED&&t.type!==Ht.WHITELIST}));r instanceof Promise&&i.find((function(t){return t.type===Ht.PROMISE_VALIDATION}))?o.awaitingPromises.push(r.then((function(r){o.performValidations(t,r,e,a,i,n)}))):o.performValidations(t,r,e,a,i,n)}))},t.prototype.whitelist=function(t,e,n){var r=this,a=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||a.push(t)})),a.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?a.forEach((function(e){var a,o=r.generateValidationError(t,t[e],e);o.constraints=((a={})[Ht.WHITELIST]="property ".concat(e," should not exist"),a),o.children=void 0,n.push(o)})):a.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,n,r,a,o){var i=a.filter((function(t){return t.type===Ht.CUSTOM_VALIDATION})),s=a.filter((function(t){return t.type===Ht.NESTED_VALIDATION})),c=a.filter((function(t){return t.type===Ht.CONDITIONAL_VALIDATION})),l=this.generateValidationError(t,e,n);o.push(l),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,r,l),this.mapContexts(t,e,r,l),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,l),this.nestedValidations(e,s,l),this.mapContexts(t,e,a,l),this.mapContexts(t,e,i,l)))},t.prototype.generateValidationError=function(t,e,n){var r=new $t;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(r.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(r.value=e),r.property=n,r.children=[],r.constraints={},r},t.prototype.conditionalValidations=function(t,e,n){return n.map((function(n){return n.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,n,r){var a=this;n.forEach((function(n){a.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach((function(o){if(!(o.async&&a.ignoreAsyncValidations||a.validatorOptions&&a.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:n.propertyName,object:t,value:e,constraints:n.constraints};if(n.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 o.instance.validate(t,i)}));if(c.some((function(t){return Dt(t)}))){var l=c.map((function(t){return Dt(t)?t:Promise.resolve(t)})),u=Promise.all(l).then((function(i){if(!i.every((function(t){return t}))){var s=Kt(a.createValidationError(t,e,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(u)}else{if(!c.every((function(t){return t}))){var p=Kt(a.createValidationError(t,e,n,o),2);m=p[0],y=p[1];r.constraints[m]=y}}}else{var f=o.instance.validate(e,i);if(Dt(f)){var d=f.then((function(i){if(!i){var s=Kt(a.createValidationError(t,e,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(d)}else if(!f){var h=Kt(a.createValidationError(t,e,n,o),2),m=h[0],y=h[1];r.constraints[m]=y}}}}))}))},t.prototype.nestedValidations=function(t,e,n){var r=this;void 0!==t&&e.forEach((function(a){if((a.type===Ht.NESTED_VALIDATION||a.type===Ht.PROMISE_VALIDATION)&&!(r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(a,o){r.performValidations(t,a,o.toString(),[],e,n.children)}));else if(t instanceof Object){var o="string"==typeof a.target?a.target:a.target.name;r.execute(t,o,n.children)}else{var i=Kt(r.createValidationError(a.target,t,a),2),s=i[0],c=i[1];n.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,n,r){var a=this;return n.forEach((function(t){if(t.context){var e=void 0;if(t.type===Ht.CUSTOM_VALIDATION)e=a.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var n=a.getConstraintType(t,e);r.constraints[n]&&(r.contexts||(r.contexts={}),r.contexts[n]=Object.assign(r.contexts[n]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,n,r){var a=t.constructor?t.constructor.name:void 0,o=this.getConstraintType(n,r),i={targetName:a,property:n.propertyName,object:t,value:e,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||r&&r.instance.defaultMessage instanceof Function&&(s=r.instance.defaultMessage(i)),[o,Ut.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),Gt=function(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}c((r=r.apply(t,e||[])).next())}))},qt=function(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},Jt=function(){function t(){}return t.prototype.validate=function(t,e,n){return this.coreValidate(t,e,n)},t.prototype.validateOrReject=function(t,e,n){return Gt(this,void 0,void 0,(function(){var r;return qt(this,(function(a){switch(a.label){case 0:return[4,this.coreValidate(t,e,n)];case 1:return(r=a.sent()).length?[2,Promise.reject(r)]:[2]}}))}))},t.prototype.validateSync=function(t,e,n){var r="string"==typeof t?e:t,a="string"==typeof t?t:void 0,o=new Wt(this,"string"==typeof t?n:e);o.ignoreAsyncValidations=!0;var i=[];return o.execute(r,a,i),o.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,n){var r="string"==typeof t?e:t,a="string"==typeof t?t:void 0,o=new Wt(this,"string"==typeof t?n:e),i=[];return o.execute(r,a,i),Promise.all(o.awaitingPromises).then((function(){return o.stripEmptyErrors(i)}))},t}(),Yt=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 Qt(t){return Yt.get(t)}function Xt(t,e,n){return"string"==typeof t?Qt(Jt).validate(t,e,n):Qt(Jt).validate(t,e)}function Zt(t,e,n){return"string"==typeof t?Qt(Jt).validateSync(t,e,n):Qt(Jt).validateSync(t,e)}function te(t,e,n,r){return void 0===n&&(n={}),void 0===r&&(r=""),t.reduce((function(t,n){var a=r?r+"."+n.property:n.property;if(n.constraints){var o=Object.keys(n.constraints)[0];t[a]={type:o,message:n.constraints[o]};var i=t[a];e&&i&&Object.assign(i,{types:n.constraints})}return n.children&&n.children.length&&te(n.children,e,t,a),t}),n)}function ee(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),function(r,a,o){try{var i=e.validator,s=(c=t,l=r,u=e.transformer,Pt.plainToInstance(c,l,u));return Promise.resolve(("sync"===n.mode?Zt:Xt)(s,i)).then((function(t){return t.length?{values:{},errors:St(te(t,!o.shouldUseNativeValidation&&"all"===o.criteriaMode),o)}:(o.shouldUseNativeValidation&&Ot({},o),{values:n.raw?Object.assign({},r):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,l,u}}function ne(t){return{resolver:ee(t),form:bt(t),inputs:Et(t)}}function re({model:t,getDetailsData:n,onSubmit:a,redirect:o,redirectBackOnSuccess:i=!0,...s}){const c=r((()=>ne(t)),[t]);return e.createElement(ht,{getDetailsData:n,onSubmit:a,formOptions:c,redirectBackOnSuccess:i})}const ae=b()(g((t=>({screens:null,user:null,screenPaths:{}})),{name:"app-store-1",storage:E((()=>localStorage)),partialize:t=>({user:t.user})}),w);function oe({onLogin:t}){const{register:n,handleSubmit:r,formState:{errors:a}}=h(),o=u();return e.createElement("div",{className:"login-container"},e.createElement("div",{className:"login-panel"},e.createElement("div",{className:"login-header"},e.createElement("h1",null,"Welcome Back"),e.createElement("p",null,"Please sign in to continue")),e.createElement("form",{onSubmit:r((async e=>{t.login(e.username,e.password).then((t=>{const{user:e,token:n}=t;localStorage.setItem("token",n),ae.setState({user:e}),o("/")}))})),className:"login-form"},e.createElement(dt,{input:{name:"username",label:"Username",placeholder:"Enter your username",type:"input"},register:n,error:a.username}),e.createElement(dt,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password",type:"input"},register:n,error:a.password}),e.createElement("div",{className:"form-actions"},e.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))}function ie({menu:t,getIcons:n,onLogout:r}){const{screens:a,screenPaths:i}=ae((t=>({screens:t.screens??{},screenPaths:t.screenPaths??{}}))),[s,l]=o(!0),f=p(),d=u(),h=t=>{if("/"===t)return f.pathname===t;const e=t.replace(/^\/+|\/+$/g,""),n=f.pathname.replace(/^\/+|\/+$/g,"");return n===e||n.startsWith(`${e}/`)};return e.createElement("div",{className:"sidebar "+(s?"open":"closed")},e.createElement("button",{className:"toggle-button",onClick:()=>l(!s),"aria-label":s?"Collapse sidebar":"Expand sidebar","aria-expanded":s},s?"<":">"),e.createElement("nav",{className:"nav-links"},t?.(a).map(((t,r)=>e.createElement(c,{key:r,to:t.path,className:"nav-link "+(h(t.path)?"active":""),"aria-current":h(t.path)?"page":void 0},e.createElement("span",{className:"nav-links-icon"},n?.(t.iconType)),s?e.createElement("span",null,t.name):null)))),r&&e.createElement("div",{className:"sidebar-footer"},e.createElement("button",{className:"logout-button",onClick:()=>{r&&(r(),d(i.login))},"aria-label":"Logout"},e.createElement("span",{className:"nav-links-icon"},e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M6 12H2V4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{d:"M10 8L14 4M14 4L10 0M14 4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))),s?e.createElement("span",null,"Logout"):null)))}function se({children:t,menu:n,getIcons:r,logout:a}){const{user:o,screenPaths:i}=ae((t=>({user:t.user,screenPaths:t.screenPaths})));ae();const s=u();return o||s(i.login),e.createElement("div",{className:"layout"},e.createElement(ie,{onLogout:()=>{a&&a()},menu:n,getIcons:r}),e.createElement("main",{className:"content"},t))}function ce({children:t,init:n}){return a((()=>{!function({screenPaths:t}){ae.setState({screenPaths:t})}(n())}),[n]),e.createElement(yt,null,t)}function le(t){return K({...t,type:"image"})}function ue(t){return e=>{t&&Reflect.defineMetadata("Crud",t,e)}}export{K as Cell,mt as Counter,ue as Crud,re as FormPage,le as ImageCell,gt as Input,se as Layout,$ as List,ot as ListPage,oe as Login,ce as Panel,ne as getFormFields,Et as getInputFields};
|
1
|
+
import*as t from"react";import e,{useRef as n,useMemo as r,useEffect as a,useState as o,useCallback as i,Component as s}from"react";import{Link as c,useParams as l,useNavigate as u,useLocation as p}from"react-router";import f from"react-select";import{useFormContext as d,useForm as h,FormProvider as m,get as y,set as v}from"react-hook-form";import{persist as g,createJSONStorage as E}from"zustand/middleware";import{createWithEqualityFn as b}from"zustand/traditional";import{shallow as w}from"zustand/vanilla/shallow";const O=()=>e.createElement("div",{className:"empty-list"},e.createElement("div",{className:"empty-list-content"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),e.createElement("polyline",{points:"13 2 13 9 20 9"})),e.createElement("h3",null,"No Data Found"),e.createElement("p",null,"There are no items to display at the moment.")));var S,_;function M(){return M=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},M.apply(null,arguments)}var T,N,x=function(e){return t.createElement("svg",M({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),S||(S=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),_||(_=t.createElement("path",{d:"m21 19-5.154-5.154a7 7 0 1 0-2 2L19 21zM5 10c0-2.757 2.243-5 5-5s5 2.243 5 5-2.243 5-5 5-5-2.243-5-5"})))};function A(){return A=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},A.apply(null,arguments)}var C,k,L=function(e){return t.createElement("svg",A({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),T||(T=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),N||(N=t.createElement("path",{d:"m13 6 5 5-9.507 9.507a1.765 1.765 0 0 1-.012-2.485l-.002-.003c-.69.676-1.8.673-2.485-.013a1.763 1.763 0 0 1-.036-2.455l-.008-.008c-.694.65-1.78.64-2.456-.036zm7.586-.414-2.172-2.172a2 2 0 0 0-2.828 0L14 5l5 5 1.586-1.586c.78-.78.78-2.047 0-2.828M3 18v3h3a3 3 0 0 0-3-3"})))};function P(){return P=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P.apply(null,arguments)}var I=function(e){return t.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),C||(C=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),k||(k=t.createElement("path",{d:"M6.187 8h11.625l-.695 11.125A2 2 0 0 1 15.12 21H8.88a2 2 0 0 1-1.997-1.875zM19 5v2H5V5h3V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1zm-9 0h4V4h-4z"})))};function j({data:t,listData:n,onRemoveItem:r}){const a=n.cells,o="function"==typeof n.list?.cells?n.list?.cells?.(t[0]):n.list?.cells;return e.createElement("div",{className:"datagrid"},t&&0!==t.length?e.createElement("table",{className:"datagrid-table"},e.createElement("thead",null,e.createElement("tr",null,a.map((t=>e.createElement("th",{key:t.name},t.title??t.name))),o?.details&&e.createElement("th",null,"Details"),o?.edit&&e.createElement("th",null,"Edit"),o?.delete&&e.createElement("th",null,"Delete"))),e.createElement("tbody",null,t.map(((t,n)=>e.createElement("tr",{key:n},a.map((n=>{const r=t[n.name];let a=r??"-";switch(n.type){case"date":if(r){const t=new Date(r);a=`${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")}`}break;case"image":{const t=n;a=e.createElement("img",{width:100,height:100,src:t.baseUrl+r,style:{objectFit:"contain"}});break}default:a=r?r.toString():n?.placeHolder??"-"}return e.createElement("td",{key:n.name},a)})),o?.details&&e.createElement("td",null,e.createElement(c,{to:o.details.path,className:"util-cell-link"},e.createElement(x,{className:"icon icon-search"}),e.createElement("span",{className:"util-cell-label"},o.details.label))),o?.edit&&e.createElement("td",null,e.createElement(c,{to:o.edit.path,className:"util-cell-link"},e.createElement(L,{className:"icon icon-pencil"}),e.createElement("span",{className:"util-cell-label"},o.edit.label))),o?.delete&&e.createElement("td",null,e.createElement("a",{onClick:()=>{r?.(t)},className:"util-cell-link"},e.createElement(I,{className:"icon icon-trash"}),e.createElement("span",{className:"util-cell-label"},o.delete.label)))))))):e.createElement(O,null))}function V({error:t}){return e.createElement("div",{className:"error-container"},e.createElement("div",{className:"error-icon"},e.createElement("i",{className:"fa fa-exclamation-circle"})),e.createElement("div",{className:"error-content"},e.createElement("h3",null,"Error Occurred"),e.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."})(t))))}function D(){return e.createElement("div",{className:"loading-screen"},e.createElement("div",{className:"loading-container"},e.createElement("div",{className:"loading-spinner"}),e.createElement("div",{className:"loading-text"},"Loading...")))}var F,R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},z={};!function(){return F||(F=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof R?R:"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){}}(),n=r(t);function r(t,e){return function(n,r){Object.defineProperty(t,n,{configurable:!0,writable:!0,value:r}),e&&e(n,r)}}void 0!==e.Reflect&&(n=r(e.Reflect,n)),function(t,e){var n=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,a=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=r&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,l={create:i?function(){return pt(Object.create(null))}:s?function(){return pt({__proto__:null})}:function(){return pt({})},has:c?function(t,e){return n.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return n.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},u=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ct(),f="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:lt(),d="function"==typeof WeakMap?WeakMap:ut(),h=r?Symbol.for("@reflect-metadata:registry"):void 0,m=at(),y=ot(m);function v(t,e,n,r){if(D(n)){if(!W(t))throw new TypeError;if(!q(e))throw new TypeError;return N(t,e)}if(!W(t))throw new TypeError;if(!z(e))throw new TypeError;if(!z(r)&&!D(r)&&!F(r))throw new TypeError;return F(r)&&(r=void 0),x(t,e,n=K(n),r)}function g(t,e){function n(n,r){if(!z(n))throw new TypeError;if(!D(r)&&!J(r))throw new TypeError;P(t,e,n,r)}return n}function E(t,e,n,r){if(!z(n))throw new TypeError;return D(r)||(r=K(r)),P(t,e,n,r)}function b(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),A(t,e,n)}function w(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),C(t,e,n)}function O(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),k(t,e,n)}function S(t,e,n){if(!z(e))throw new TypeError;return D(n)||(n=K(n)),L(t,e,n)}function _(t,e){if(!z(t))throw new TypeError;return D(e)||(e=K(e)),I(t,e)}function M(t,e){if(!z(t))throw new TypeError;return D(e)||(e=K(e)),j(t,e)}function T(t,e,n){if(!z(e))throw new TypeError;if(D(n)||(n=K(n)),!z(e))throw new TypeError;D(n)||(n=K(n));var r=st(e,n,!1);return!D(r)&&r.OrdinaryDeleteMetadata(t,e,n)}function N(t,e){for(var n=t.length-1;n>=0;--n){var r=(0,t[n])(e);if(!D(r)&&!F(r)){if(!q(r))throw new TypeError;e=r}}return e}function x(t,e,n,r){for(var a=t.length-1;a>=0;--a){var o=(0,t[a])(e,n,r);if(!D(o)&&!F(o)){if(!z(o))throw new TypeError;r=o}}return r}function A(t,e,n){if(C(t,e,n))return!0;var r=nt(e);return!F(r)&&A(t,r,n)}function C(t,e,n){var r=st(e,n,!1);return!D(r)&&H(r.OrdinaryHasOwnMetadata(t,e,n))}function k(t,e,n){if(C(t,e,n))return L(t,e,n);var r=nt(e);return F(r)?void 0:k(t,r,n)}function L(t,e,n){var r=st(e,n,!1);if(!D(r))return r.OrdinaryGetOwnMetadata(t,e,n)}function P(t,e,n,r){st(n,r,!0).OrdinaryDefineOwnMetadata(t,e,n,r)}function I(t,e){var n=j(t,e),r=nt(t);if(null===r)return n;var a=I(r,e);if(a.length<=0)return n;if(n.length<=0)return a;for(var o=new f,i=[],s=0,c=n;s<c.length;s++){var l=c[s];o.has(l)||(o.add(l),i.push(l))}for(var u=0,p=a;u<p.length;u++){l=p[u];o.has(l)||(o.add(l),i.push(l))}return i}function j(t,e){var n=st(t,e,!1);return n?n.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 z(t){return"object"==typeof t?null!==t:"function"==typeof t}function B(t,e){switch(V(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var n="string",r=Q(t,a);if(void 0!==r){var o=r.call(t,n);if(z(o))throw new TypeError;return o}return $(t)}function $(t,e){var n,r,a=t.toString;if(G(a)&&!z(r=a.call(t)))return r;if(G(n=t.valueOf)&&!z(r=n.call(t)))return r;throw new TypeError}function H(t){return!!t}function U(t){return""+t}function K(t){var e=B(t);return R(e)?e:U(e)}function W(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function G(t){return"function"==typeof t}function q(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 n=t[e];if(null!=n){if(!G(n))throw new TypeError;return n}}function X(t){var e=Q(t,o);if(!G(e))throw new TypeError;var n=e.call(t);if(!z(n))throw new TypeError;return n}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 nt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===u)return e;if(e!==u)return e;var n=t.prototype,r=n&&Object.getPrototypeOf(n);if(null==r||r===Object.prototype)return e;var a=r.constructor;return"function"!=typeof a||a===t?e:a}function rt(){var t,n,r,a;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var o=new d,i={registerProvider:s,getProvider:l,setProvider:m};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(n):n=e;break;case n===e:break;case D(r):r=e;break;case r===e:break;default:void 0===a&&(a=new f),a.add(e)}}function c(e,o){if(!D(n)){if(n.isProviderFor(e,o))return n;if(!D(r)){if(r.isProviderFor(e,o))return n;if(!D(a))for(var i=X(a);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,o))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,o))return t}function l(t,e){var n,r=o.get(t);return D(r)||(n=r.get(e)),D(n)?(D(n=c(t,e))||(D(r)&&(r=new p,o.set(t,r)),r.set(e,n)),n):n}function u(t){if(D(t))throw new TypeError;return n===t||r===t||!D(a)&&a.has(t)}function m(t,e,n){if(!u(n))throw new Error("Metadata provider not registered.");var r=l(t,e);if(r!==n){if(!D(r))return!1;var a=o.get(t);D(a)&&(a=new p,o.set(t,a)),a.set(e,n)}return!0}}function at(){var t;return!D(h)&&z(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=rt()),!D(h)&&z(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function ot(t){var e=new d,n={isProviderFor:function(t,n){var r=e.get(t);return!D(r)&&r.has(n)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:a,OrdinaryGetOwnMetadata:o,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return m.registerProvider(n),n;function r(r,a,o){var i=e.get(r),s=!1;if(D(i)){if(!o)return;i=new p,e.set(r,i),s=!0}var c=i.get(a);if(D(c)){if(!o)return;if(c=new p,i.set(a,c),!t.setProvider(r,a,n))throw i.delete(a),s&&e.delete(r),new Error("Wrong provider for target.")}return c}function a(t,e,n){var a=r(e,n,!1);return!D(a)&&H(a.has(t))}function o(t,e,n){var a=r(e,n,!1);if(!D(a))return a.get(t)}function i(t,e,n,a){r(n,a,!0).set(t,e)}function s(t,e){var n=[],a=r(t,e,!1);if(D(a))return n;for(var o=X(a.keys()),i=0;;){var s=tt(o);if(!s)return n.length=i,n;var c=Z(s);try{n[i]=c}catch(t){try{et(o)}finally{throw t}}i++}}function c(t,n,a){var o=r(n,a,!1);if(D(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var i=e.get(n);D(i)||(i.delete(a),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,n=t.hasOwnMetadata,r=t.getOwnMetadata,a=t.getOwnMetadataKeys,o=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var n=i.get(t);return!(D(n)||!n.has(e))||!!a(t,e).length&&(D(n)&&(n=new f,i.set(t,n)),n.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:o}}function st(t,e,n){var r=m.getProvider(t,e);if(!D(r))return r;if(n){if(m.setProvider(t,e,y))return y;throw new Error("Illegal state.")}}function ct(){var t={},e=[],n=function(){function t(t,e,n){this._index=0,this._keys=t,this._values=e,this._selector=n}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var n=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:n,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}(),r=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 n=this._find(t,!0);return this._values[n]=e,this},e.prototype.delete=function(e){var n=this._find(e,!1);if(n>=0){for(var r=this._keys.length,a=n+1;a<r;a++)this._keys[a-1]=this._keys[a],this._values[a-1]=this._values[a];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 n(this._keys,this._values,a)},e.prototype.values=function(){return new n(this._keys,this._values,i)},e.prototype.entries=function(){return new n(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(Y(this._keys[n],t)){this._cacheIndex=n;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return r;function a(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function lt(){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[o]=function(){return this.keys()},t}()}function ut(){var t=16,e=l.create(),r=a();return function(){function t(){this._key=a()}return t.prototype.has=function(t){var e=o(t,!1);return void 0!==e&&l.has(e,this._key)},t.prototype.get=function(t){var e=o(t,!1);return void 0!==e?l.get(e,this._key):void 0},t.prototype.set=function(t,e){return o(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=o(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=a()},t}();function a(){var t;do{t="@@WeakMap@@"+c()}while(l.has(e,t));return e[t]=!0,t}function o(t,e){if(!n.call(t,r)){if(!e)return;Object.defineProperty(t,r,{value:l.create()})}return t[r]}function i(t,e){for(var n=0;n<e;++n)t[n]=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 n="",r=0;r<t;++r){var a=e[r];4!==r&&6!==r&&8!==r||(n+="-"),a<16&&(n+="0"),n+=a.toString(16).toLowerCase()}return n}}function pt(t){return t.__=void 0,delete t.__,t}t("decorate",v),t("metadata",g),t("defineMetadata",E),t("hasMetadata",b),t("hasOwnMetadata",w),t("getMetadata",O),t("getOwnMetadata",S),t("getMetadataKeys",_),t("getOwnMetadataKeys",M),t("deleteMetadata",T)}(n,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),z;var t}();const B="List";function $(t){return e=>{t&&Reflect.defineMetadata(B,t,e)}}function H(t){return Reflect.getMetadata(B,t)}const U=Symbol("cell");function K(t){return(e,n)=>{const r=Reflect.getMetadata(U,e)||[];if(Reflect.defineMetadata(U,[...r,n.toString()],e),t){const r=`${U.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,t,e)}}}function W(t){const e=t.prototype;return(Reflect.getMetadata(U,e)||[]).map((t=>{const n=Reflect.getMetadata(`${U.toString()}:${t}:options`,e)||{};return{...n,name:n?.name??t}}))}function G({pagination:t,onPageChange:n}){const{total:r,page:a,limit:o}=t,i=Math.floor(r/o);if(i<=1)return null;return e.createElement("div",{className:"pagination"},e.createElement("button",{onClick:()=>n(a-1),className:"pagination-item "+(1===a?"disabled":""),disabled:1===a,"aria-disabled":1===a},"Previous"),(()=>{const t=[];for(let r=1;r<=Math.min(2,i);r++)t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a-2>3&&t.push(e.createElement("span",{key:"ellipsis1",className:"pagination-ellipsis"},"..."));for(let r=Math.max(3,a-2);r<=Math.min(i-2,a+2);r++)r>2&&r<i-1&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));a+2<i-2&&t.push(e.createElement("span",{key:"ellipsis2",className:"pagination-ellipsis"},"..."));for(let r=Math.max(i-1,3);r<=i;r++)r>2&&t.push(e.createElement("button",{key:r,onClick:()=>n(r),className:"pagination-item "+(a===r?"active":""),disabled:a===r},r));return t})(),e.createElement("button",{onClick:()=>n(a+1),className:"pagination-item "+(a===i?"disabled":""),disabled:a===i,"aria-disabled":a===i},"Next"))}var q,J,Y;function Q(){return Q=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Q.apply(null,arguments)}var X,Z=function(e){return t.createElement("svg",Q({xmlns:"http://www.w3.org/2000/svg",width:800,height:800,viewBox:"0 0 24 24"},e),q||(q=t.createElement("path",{fill:"none",d:"M0 0h24v24H0z"})),J||(J=t.createElement("path",{d:"M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5v2H5v14h14v-5z"})),Y||(Y=t.createElement("path",{d:"M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"})))};function tt(){return tt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},tt.apply(null,arguments)}var et=function(e){return t.createElement("svg",tt({xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e),X||(X=t.createElement("path",{d:"M22 3H2l8 9.46V19l4 2v-8.54z"})))};function nt({field:t,value:n,onChange:r}){if("static-select"===t.filter?.type){const a=t.filter;return e.createElement(f,{id:t.name,menuPortalTarget:document.body,styles:{control:(t,e)=>({...t,backgroundColor:"#1f2937",borderColor:e.isFocused?"#6366f1":"#374151",boxShadow:e.isFocused?"0 0 0 1px #6366f1":"none","&:hover":{borderColor:"#6366f1"},borderRadius:"6px",padding:"2px",color:"white"}),option:(t,e)=>({...t,backgroundColor:e.isSelected?"#6366f1":e.isFocused?"#374151":"#1f2937",color:"white","&:active":{backgroundColor:"#6366f1"},"&:hover":{backgroundColor:"#374151"},cursor:"pointer"}),input:t=>({...t,color:"white"}),placeholder:t=>({...t,color:"#9ca3af"}),singleValue:t=>({...t,color:"white"}),menuPortal:t=>({...t,zIndex:9999}),menu:t=>({...t,backgroundColor:"#1f2937",border:"1px solid #374151",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"}),menuList:t=>({...t,padding:"4px"}),dropdownIndicator:t=>({...t,color:"#9ca3af","&:hover":{color:"#6366f1"}}),clearIndicator:t=>({...t,color:"#9ca3af","&:hover":{color:"#6366f1"}})},value:n?{value:n,label:a.options.find((t=>t.value===n))?.label||n}:null,onChange:t=>r(t?.value||""),options:a.options.map((t=>({value:t.value,label:t.label}))),placeholder:`Filter by ${t.title||t.name}`,isClearable:!0})}return e.createElement("input",{type:"number"===t.type?"number":"text",id:t.name,value:n||"",onChange:t=>r(t.target.value),placeholder:`Filter by ${t.title||t.name}`})}function rt({isOpen:t,onClose:o,onApplyFilters:i,listData:s,activeFilters:c}){const[l,u]=e.useState(c??{}),p=n(null),f=r((()=>s.cells.filter((t=>!!t.filter))),[s.cells]);if(a((()=>{const e=t=>{p.current&&!p.current.contains(t.target)&&o()};return t&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[t,o]),!t)return null;return e.createElement("div",{className:"filter-popup-overlay"},e.createElement("div",{ref:p,className:"filter-popup"},e.createElement("div",{className:"filter-popup-header"},e.createElement("h3",null,"Filter"),e.createElement("button",{onClick:o,className:"close-button"},"×")),e.createElement("div",{className:"filter-popup-content"},f.map((t=>e.createElement("div",{key:t.name,className:"filter-field"},e.createElement("label",{htmlFor:t.name},t.title||t.name),e.createElement(nt,{field:t,value:l[t.name||""],onChange:e=>((t,e)=>{u((n=>({...n,[t]:e})))})(t.name||"",e)}))))),e.createElement("div",{className:"filter-popup-footer"},e.createElement("button",{onClick:o,className:"cancel-button"},"Cancel"),e.createElement("button",{onClick:()=>{i(l),o()},className:"apply-button"},"Apply Filters"))))}const at=({listData:t,filtered:n,onFilterClick:a,customHeader:o})=>{const i=r((()=>t.cells.filter((t=>!!t.filter))),[t.cells]),s=t.list?.headers;return e.createElement("div",{className:"list-header"},e.createElement("div",{className:"header-title"},s?.title||"List"),o&&e.createElement("div",{className:"header-custom"},o),e.createElement("div",{className:"header-actions"},!!i.length&&e.createElement("button",{onClick:a,className:"filter-button"},e.createElement(et,{className:"icon icon-filter "+(n?"active":"")}),"Filter"),s?.create&&e.createElement(c,{to:s.create.path,className:"create-button"},e.createElement(Z,{className:"icon icon-create"}),s.create.label)))};function ot({model:t,getData:n,onRemoveItem:s,customHeader:c}){const[p,f]=o(!0),[d,h]=o({total:0,page:0,limit:0}),[m,y]=o(null),[v,g]=o(null),[E,b]=o(!1),[w,O]=o(),S=r((()=>{return{list:H(e=t),cells:W(e)};var e}),[t]),_=l(),M=u(),T=i((async(t,e)=>{f(!0);try{const r=await n({page:t,filters:e??w??{}});y(r.data),h({total:r.total,page:r.page,limit:r.limit})}catch(t){g(t),console.error(t)}finally{f(!1)}}),[n,w]);a((()=>{const t=new URLSearchParams(location.search),e={};t.forEach(((t,n)=>{e[n]=t})),O(e)}),[location.search]),a((()=>{w&&T(parseInt(_.page)||1,w)}),[T,_.page,w]);return p?e.createElement(D,null):v?e.createElement(V,{error:v}):e.createElement("div",{className:"list"},e.createElement(at,{listData:S,filtered:!(!w||!Object.keys(w).length),onFilterClick:()=>b(!0),customHeader:c}),e.createElement(j,{listData:S,data:m,onRemoveItem:async t=>{s&&alert({title:"Are you sure you want to delete this item?",message:"This action cannot be undone.",onConfirm:async()=>{await s(t),await T(d.page)}})}}),e.createElement("div",{className:"list-footer"},e.createElement(G,{pagination:d,onPageChange:T})),e.createElement(rt,{isOpen:E,activeFilters:w,onClose:()=>b(!1),onApplyFilters:t=>{O(t);const e=new URLSearchParams;Object.entries(t).forEach((([t,n])=>{null!=n&&""!==n&&e.append(t,String(n))}));const n=e.toString(),r=`${location.pathname}${n?`?${n}`:""}`;M(r),T(1,t)},listData:S}))}function it({htmlFor:t,label:n,fieldName:r}){return e.createElement("label",{htmlFor:t},n??r.charAt(0).toUpperCase()+r.slice(1))}const st=Object.freeze({BEFORE:"before",HOVER:"hover",AFTER:"after"});function ct(t){return e.createElement("div",null,e.createElement("img",{...t,style:{width:100}}),e.createElement("p",null,t.name," ",e.createElement("span",{style:{whiteSpace:"none"}},"(",(t=>{if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(2))+" "+["Bytes","KB","MB","GB","TB"][e]})(t.size),")")))}function lt(){const{register:t,formState:{errors:n},watch:r,setValue:o,clearErrors:i,setError:s}=d(),c=r("uploader");return a((()=>{t("uploader",{required:!0})}),[t]),e.createElement("div",null,e.createElement("span",{className:"form-error",style:{bottom:2,top:"unset"}},"required"===n.uploader?.type&&"At least 1 image is required!","custom"===n.uploader?.type&&n.uploader.message?.toString()),e.createElement(ut,{reset:c,onError:t=>{t?s("uploader",{type:"custom",message:t}):(o("uploader",{files:[]}),i("uploader"))},onClear:()=>{o("uploader",{files:[]}),i("uploader")},onFilesChange:t=>{o("uploader",{files:t})}}))}function ut(t){const[n,r]=e.useState(st.BEFORE),[a,o]=e.useState(t.value||[]),[i,s]=e.useState([]),[c,l]=e.useState(0);console.log("files",i);const u=e.useRef(null),p=e.useRef(null);e.useEffect((()=>{const e=u.current;if(!e)return;const n=t=>{t.preventDefault(),t.stopPropagation(),f()},a=t=>{t.preventDefault(),t.stopPropagation(),d()},o=t=>{t.preventDefault(),t.stopPropagation()},c=e=>{e.preventDefault(),e.stopPropagation(),l(0);const n=e.dataTransfer?.files;if(!n)return;s([]),r(st.AFTER);const a=[];for(let e=0;e<n.length;e++){const r=new FileReader;r.onload=r=>{if(!r.target)return;h([...i,{file:n[e],image:r.target.result}])&&(a.push(n[e]),p.current&&(p.current.files=n),s([])),t.onFilesChange&&t.onFilesChange(a)},r.readAsDataURL(n[e])}p.current&&(p.current.files=n)};return e.addEventListener("dragenter",n,!1),e.addEventListener("dragleave",a,!1),e.addEventListener("dragover",o,!1),e.addEventListener("drop",c,!1),()=>{e.removeEventListener("dragenter",n),e.removeEventListener("dragleave",a),e.removeEventListener("dragover",o),e.removeEventListener("drop",c)}}),[i]);const f=()=>{l((t=>t+1)),r(st.HOVER)},d=()=>{l((t=>t-1==0?(r(st.BEFORE),0):t-1))},h=e=>{const n=(t=>{if(!t)return null;if(t.length>=10)return"you can't send more than 10 images";for(let e=0;e<t.length;e++){const n=t[e].file,r=n.name.split(".");if(!["png","jpg","jpeg"].includes(r[r.length-1]))return'Extension of the file can only be "png", "jpg" or "jpeg" ';if(n&&n.size>1048576)return`Size of "${n.name}" can't be bigger than 1mb`}return null})(e);return n||s(e),t.onError?.(n),n};return e.createElement("div",{ref:u,className:"multi-image form-element dropzone "+n},e.createElement("input",{ref:p,type:"file",style:{display:"none"},className:"target",name:"file"}),e.createElement("div",{className:"container"},e.createElement("button",{className:"trash",onClick:()=>{s([]),p.current&&(p.current.value=""),t.onClear?.()},type:"button"},"Delete All"),(()=>{const t=[];if(i){console.log("----\x3e",i);for(let n=0;n<i.length;n++){let r="image";t.push(e.createElement("div",{key:n,className:"image-container"},e.createElement("div",{className:r},e.createElement(ct,{name:i[n].file.name,src:i[n].image,size:i[n].file.size}))))}}return t})(),e.createElement("div",null,e.createElement("button",{type:"button",onClick:()=>{const t=document.getElementById("file__");t&&t.click()},className:"plus"},e.createElement("span",null,"+ Add Image",e.createElement("p",null,"Drag image here or Select Image")))),e.createElement("input",{hidden:!0,id:"file__",multiple:!0,type:"file",onChange:t=>{const e=t.target.files;if(e){s([]),r(st.AFTER);for(let t=0;t<e.length;t++){const n=new FileReader;n.onload=n=>{n.target&&h([...i,{file:e[t],image:n.target.result}])},n.readAsDataURL(e[t])}p.current&&(p.current.files=e)}}})))}function pt({id:t,...n}){return e.createElement("input",{type:"checkbox",id:t,className:"checkbox",...n})}function ft({input:t,register:n}){const r=d(),a=r.getValues(t.name);return e.createElement("div",null,a?.map(((a,o)=>e.createElement("div",{key:o},t.nestedFields?.map((a=>e.createElement(dt,{key:a.name?.toString()??"",baseName:t.name+"["+o+"]",input:a,register:n,error:t.name?{message:r.formState.errors[t.name]?.message}:void 0})))))))}function dt({input:t,register:n,error:r,baseName:a}){const o=(a?a.toString()+".":"")+t.name||"";return e.createElement("div",{className:"form-field"},e.createElement(it,{htmlFor:o,label:t.label,fieldName:o}),(()=>{switch(t.type){case"textarea":return e.createElement("textarea",{...n(o),placeholder:t.placeholder,id:o});case"select":return e.createElement("select",{...n(o),id:o},e.createElement("option",{value:""},"Select ",o),t.options?.map((t=>e.createElement("option",{key:t.value,value:t.value},t.label))));case"input":return e.createElement("input",{type:t.inputType,...n(o),placeholder:t.placeholder,id:o});case"file-upload":return e.createElement(lt,null);case"checkbox":return e.createElement(pt,{...n(o),id:o});case"hidden":return e.createElement("input",{type:"hidden",...n(o),id:o});case"nested":return e.createElement(ft,{input:t,register:n})}})(),r&&e.createElement("span",{className:"error-message"},r.message))}function ht({formOptions:t,onSubmit:n,getDetailsData:r,redirectBackOnSuccess:o}){const i=l(),s=h({resolver:t.resolver}),c=u(),p=t.inputs;return a((()=>{r&&r(i).then((t=>{s.reset({...t})}))}),[i,s.reset]),e.createElement("div",{className:"form-wrapper"},e.createElement(m,{...s},e.createElement("form",{onSubmit:s.handleSubmit((async t=>{await n(t),o&&c(-1)}),((t,e)=>{console.log("error creating creation",t,e)}))},e.createElement("div",null,p?.map((t=>e.createElement(dt,{key:t.name||"",input:t,register:s.register,error:t.name?{message:s.formState.errors[t.name]?.message}:void 0}))),e.createElement("button",{type:"submit",className:"submit-button"},"Submit")))))}function mt({image:t,text:n,targetNumber:r,duration:i=2e3}){const[s,c]=o(0);return a((()=>{let t,e;const n=a=>{t||(t=a);const o=a-t,s=Math.min(o/i,1);c(Math.floor(s*r)),s<1&&(e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>{e&&cancelAnimationFrame(e)}}),[r,i]),e.createElement("div",{className:"counter-container"},e.createElement("div",{className:"counter-image"},t),e.createElement("div",{className:"counter-text"},n),e.createElement("div",{className:"counter-value"},s))}class yt extends s{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?e.createElement("div",{className:"error-boundary"},e.createElement("div",{className:"error-boundary__content"},e.createElement("div",{className:"error-boundary__icon"},e.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},e.createElement("circle",{cx:"12",cy:"12",r:"10"}),e.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),e.createElement("h1",null,"Oops! Something went wrong"),e.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),e.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&e.createElement("details",{className:"error-boundary__details"},e.createElement("summary",null,"Error Details"),e.createElement("pre",null,this.state.error?.toString()),e.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}const vt=Symbol("input");function gt(t){return(e,n)=>{const r=Reflect.getMetadata(vt,e)||[];if(Reflect.defineMetadata(vt,[...r,n.toString()],e),t){const r=`${vt.toString()}:${n.toString()}:options`;Reflect.defineMetadata(r,t,e)}}}function Et(t){const e=t.prototype;return(Reflect.getMetadata(vt,e)||[]).map((t=>{const n=Reflect.getMetadata(`${vt.toString()}:${t}:options`,e)||{},r=n?.inputType??(a=t,["password"].some((t=>a.toLowerCase().includes(t)))?"password":"text");var a;return{...n,editable:n.editable??!0,sensitive:n.sensitive,name:n?.name??t,label:n?.label??t,placeholder:n?.placeholder??t,inputType:r,type:n?.type??"input",selectOptions:n?.selectOptions??[],cancelPasswordValidationOnEdit:n?.cancelPasswordValidationOnEdit??"password"===r}}))}function bt(t){return Reflect.getMetadata("FormMetadata",t)}const wt=(t,e,n)=>{if(t&&"reportValidity"in t){const r=y(n,e);t.setCustomValidity(r&&r.message||""),t.reportValidity()}},Ot=(t,e)=>{for(const n in e.fields){const r=e.fields[n];r&&r.ref&&"reportValidity"in r.ref?wt(r.ref,n,t):r&&r.refs&&r.refs.forEach((e=>wt(e,n,t)))}},St=(t,e)=>{e.shouldUseNativeValidation&&Ot(t,e);const n={};for(const r in t){const a=y(e.fields,r),o=Object.assign(t[r]||{},{ref:a&&a.ref});if(_t(e.names||Object.keys(t),r)){const t=Object.assign({},y(n,r));v(t,"root",o),v(n,r,t)}else v(n,r,o)}return n},_t=(t,e)=>{const n=Mt(e);return t.some((t=>Mt(t).match(`^${n}\\.\\d+`)))};function Mt(t){return t.replace(/\]|\[/g,"")}var Tt;!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"}(Tt||(Tt={}));var Nt=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,n){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?n===Tt.CLASS_TO_CLASS||n===Tt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||n===Tt.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),n=e&&e.get(void 0),r=this._exposeMetadatas.get(t),a=r&&r.get(void 0);return n&&a||!n&&!a?"none":n?"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===Tt.CLASS_TO_CLASS||e===Tt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===Tt.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===Tt.CLASS_TO_CLASS||e===Tt.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===Tt.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 n,r=t.get(e);r&&(n=Array.from(r.values()).filter((function(t){return void 0!==t.propertyName})));for(var a=[],o=0,i=this.getAncestors(e);o<i.length;o++){var s=i[o],c=t.get(s);if(c){var l=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));a.push.apply(a,l)}}return a.concat(n||[])},t.prototype.findMetadata=function(t,e,n){var r=t.get(e);if(r){var a=r.get(n);if(a)return a}for(var o=0,i=this.getAncestors(e);o<i.length;o++){var s=i[o],c=t.get(s);if(c){var l=c.get(n);if(l)return l}}},t.prototype.findMetadatas=function(t,e,n){var r,a=t.get(e);a&&(r=a.get(n));for(var o=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],l=t.get(c);l&&l.has(n)&&o.push.apply(o,l.get(n))}return o.slice().reverse().concat((r||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],n=Object.getPrototypeOf(t.prototype.constructor);void 0!==n.prototype;n=Object.getPrototypeOf(n.prototype.constructor))e.push(n);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),xt=new Nt;var At=function(t,e,n){if(n||2===arguments.length)for(var r,a=0,o=e.length;a<o;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))};var Ct=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,n,r,a,o){var i,s=this;if(void 0===o&&(o=0),Array.isArray(e)||e instanceof Set){var c=r&&this.transformationType===Tt.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(r):[];return e.forEach((function(e,r){var a=t?t[r]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===Tt.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof n&&n&&n.options&&n.options.discriminator&&n.options.discriminator.property&&n.options.discriminator.subTypes){if(s.transformationType===Tt.PLAIN_TO_CLASS){i=n.options.discriminator.subTypes.find((function(t){return t.name===e[n.options.discriminator.property]}));var l={newObject:c,object:e,property:void 0},u=n.typeFunction(l);i=void 0===i?u:i.value,n.options.keepDiscriminatorProperty||delete e[n.options.discriminator.property]}s.transformationType===Tt.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===Tt.CLASS_TO_PLAIN&&(e[n.options.discriminator.property]=n.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=n;var p=s.transform(a,e,i,void 0,e instanceof Map,o+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(n!==String||a){if(n!==Number||a){if(n!==Boolean||a){if((n===Date||e instanceof Date)&&!a)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&&(n===Buffer||e instanceof Buffer)&&!a)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||a){if(a||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){n||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(n=e.constructor),!n&&t&&(n=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var l=this.getKeys(n,e,a),u=t||{};t||this.transformationType!==Tt.PLAIN_TO_CLASS&&this.transformationType!==Tt.CLASS_TO_CLASS||(u=a?new Map:n?new n:{});for(var p=function(r){if("__proto__"===r||"constructor"===r)return"continue";var i=r,s=r,c=r;if(!f.options.ignoreDecorators&&n)if(f.transformationType===Tt.PLAIN_TO_CLASS)(l=xt.findExposeMetadataByCustomName(n,r))&&(c=l.propertyName,s=l.propertyName);else if(f.transformationType===Tt.CLASS_TO_PLAIN||f.transformationType===Tt.CLASS_TO_CLASS){var l;(l=xt.findExposeMetadata(n,r))&&l.options&&l.options.name&&(s=l.options.name)}var p=void 0;p=f.transformationType===Tt.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(n&&a)d=n;else if(n){var m=xt.findTypeMetadata(n,c);if(m){var y={newObject:u,object:e,property:c},v=m.typeFunction?m.typeFunction(y):m.reflectedType;m.options&&m.options.discriminator&&m.options.discriminator.property&&m.options.discriminator.subTypes?e[i]instanceof Array?d=m:(f.transformationType===Tt.PLAIN_TO_CLASS&&(d=void 0===(d=m.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&m.options.discriminator.property in p)return t.name===p[m.options.discriminator.property]})))?v:d.value,m.options.keepDiscriminatorProperty||p&&p instanceof Object&&m.options.discriminator.property in p&&delete p[m.options.discriminator.property]),f.transformationType===Tt.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===Tt.CLASS_TO_PLAIN&&p&&(p[m.options.discriminator.property]=m.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=v,h=h||m.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===n&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===Tt.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",n.prototype,c);g&&(d=g)}}var E=Array.isArray(e[i])?f.getReflectedType(n,c):void 0,b=t?t[i]:void 0;if(u.constructor.prototype){var w=Object.getOwnPropertyDescriptor(u.constructor.prototype,s);if((f.transformationType===Tt.PLAIN_TO_CLASS||f.transformationType===Tt.CLASS_TO_CLASS)&&(w&&!w.set||u[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===Tt.CLASS_TO_CLASS){S=p;(void 0!==(S=f.applyCustomTransformations(S,n,r,e,f.transformationType))||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}}else{var O=f.transformationType===Tt.PLAIN_TO_CLASS?s:r,S=void 0;f.transformationType===Tt.CLASS_TO_PLAIN?(S=e[O],S=f.applyCustomTransformations(S,n,O,e,f.transformationType),S=e[O]===S?p:S,S=f.transform(b,S,d,E,h,o+1)):void 0===p&&f.options.exposeDefaultValues?S=u[s]:(S=f.transform(b,p,d,E,h,o+1),S=f.applyCustomTransformations(S,n,O,e,f.transformationType)),(void 0!==S||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,S):u[s]=S)}},f=this,d=0,h=l;d<h.length;d++){p(h[d])}return this.options.enableCircularCheck&&this.recursionStack.delete(e),u}return e}return e}return new Promise((function(t,r){e.then((function(e){return t(s.transform(void 0,e,n,void 0,void 0,o+1))}),r)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,n,r,a){var o=this,i=xt.findTransformMetadatas(e,n,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||o.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||o.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:n,obj:r,type:a,options:o.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var n=xt.findTypeMetadata(t,e);return n?n.reflectedType:void 0}},t.prototype.getKeys=function(t,e,n){var r=this,a=xt.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var o=[];if(("exposeAll"===a||n)&&(o=e instanceof Map?Array.from(e.keys()):Object.keys(e)),n)return o;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=xt.getExposedProperties(t,this.transformationType),s=xt.getExcludedProperties(t,this.transformationType);o=At(At([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=xt.getExposedProperties(t,this.transformationType);this.transformationType===Tt.PLAIN_TO_CLASS&&(i=i.map((function(e){var n=xt.findExposeMetadata(t,e);return n&&n.options&&n.options.name?n.options.name:e}))),o=this.options.excludeExtraneousValues?i:o.concat(i);var c=xt.getExcludedProperties(t,this.transformationType);c.length>0&&(o=o.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(o=o.filter((function(e){var n=xt.findExposeMetadata(t,e);return!n||!n.options||r.checkVersion(n.options.since,n.options.until)}))),o=this.options.groups&&this.options.groups.length?o.filter((function(e){var n=xt.findExposeMetadata(t,e);return!n||!n.options||r.checkGroups(n.options.groups)})):o.filter((function(e){var n=xt.findExposeMetadata(t,e);return!(n&&n.options&&n.options.groups&&n.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(o=o.filter((function(t){return r.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),o=o.filter((function(t,e,n){return n.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var n=!0;return n&&t&&(n=this.options.version>=t),n&&e&&(n=this.options.version<e),n},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),kt={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},Lt=function(){return Lt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},Lt.apply(this,arguments)},Pt=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new Ct(Tt.CLASS_TO_PLAIN,Lt(Lt({},kt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,n){return new Ct(Tt.CLASS_TO_PLAIN,Lt(Lt({},kt),n)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,n){return new Ct(Tt.PLAIN_TO_CLASS,Lt(Lt({},kt),n)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,n){return new Ct(Tt.PLAIN_TO_CLASS,Lt(Lt({},kt),n)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new Ct(Tt.CLASS_TO_CLASS,Lt(Lt({},kt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,n){return new Ct(Tt.CLASS_TO_CLASS,Lt(Lt({},kt),n)).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,n){var r=JSON.parse(e);return this.plainToInstance(t,r,n)},t.prototype.deserializeArray=function(t,e,n){var r=JSON.parse(e);return this.plainToInstance(t,r,n)},t}());var It=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)},jt=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(n){t.properties[n].forEach((function(r){var a={message:r.message,groups:r.groups,always:r.always,each:r.each},o={type:r.type,name:r.name,target:t.name,propertyName:n,constraints:r.constraints,validationTypeOptions:r.options,validationOptions:a};e.push(new It(o))}))})),e},t}();function Vt(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function Dt(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var Ft=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Rt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,o=n.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},zt=function(t,e,n){if(n||2===arguments.length)for(var r,a=0,o=e.length;a<o;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))},Bt=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 jt).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,n,r,a){var o,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&n},c=function(t){return!(!r||a&&a.length||!t.groups||!t.groups.length)},l=(this.validationMetadatas.get(t)||[]).filter((function(n){return(n.target===t||n.target===e)&&(!!s(n)||!c(n)&&(!(a&&a.length>0)||n.groups&&!!n.groups.find((function(t){return-1!==a.indexOf(t)}))))})),u=[];try{for(var p=Ft(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=Rt(f.value,2),h=d[0],m=d[1];t.prototype instanceof h&&u.push.apply(u,zt([],Rt(m),!1))}}catch(t){o={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.error}}var y=u.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!s(e)||!c(e)&&(!(a&&a.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==a.indexOf(t)}))))))})).filter((function(t){return!l.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return l.concat(y)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();var $t=function(){function t(){}return t.prototype.toString=function(t,e,n,r){var a=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===n&&(n=""),void 0===r&&(r=!1);var o=t?"[1m":"",i=t?"[22m":"",s=function(t){return" - property ".concat(o).concat(n).concat(t).concat(i," has failed the following constraints: ").concat(o).concat((r?Object.values:Object.keys)(null!==(e=a.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(n?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(n).concat(c),r)})).join(""):""}return"An instance of ".concat(o).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,a.property,r)})).join(""):"")},t}(),Ht=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 Ut=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var n;return t instanceof Function?n=t(e):"string"==typeof t&&(n=t),n&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){n=n.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))})),n&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(n=n.replace(/\$value/g,e.value)),n&&(n=n.replace(/\$property/g,e.property)),n&&(n=n.replace(/\$target/g,e.targetName)),n},t}(),Kt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,o=n.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},Wt=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=Vt();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new Bt),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,n){var r,a,o=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(r=this.validatorOptions)||void 0===r?void 0:r.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,l=void 0===(null===(a=this.validatorOptions)||void 0===a?void 0:a.forbidUnknownValues)||!1!==this.validatorOptions.forbidUnknownValues,u=this.metadataStorage.getTargetValidationMetadatas(t.constructor,e,c,s,i),p=this.metadataStorage.groupByPropertyName(u);if(this.validatorOptions&&l&&!u.length){var f=new $t;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 n.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,n),Object.keys(p).forEach((function(e){var r=t[e],a=p[e].filter((function(t){return t.type===Ht.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==Ht.IS_DEFINED&&t.type!==Ht.WHITELIST}));r instanceof Promise&&i.find((function(t){return t.type===Ht.PROMISE_VALIDATION}))?o.awaitingPromises.push(r.then((function(r){o.performValidations(t,r,e,a,i,n)}))):o.performValidations(t,r,e,a,i,n)}))},t.prototype.whitelist=function(t,e,n){var r=this,a=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||a.push(t)})),a.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?a.forEach((function(e){var a,o=r.generateValidationError(t,t[e],e);o.constraints=((a={})[Ht.WHITELIST]="property ".concat(e," should not exist"),a),o.children=void 0,n.push(o)})):a.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,n,r,a,o){var i=a.filter((function(t){return t.type===Ht.CUSTOM_VALIDATION})),s=a.filter((function(t){return t.type===Ht.NESTED_VALIDATION})),c=a.filter((function(t){return t.type===Ht.CONDITIONAL_VALIDATION})),l=this.generateValidationError(t,e,n);o.push(l),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,r,l),this.mapContexts(t,e,r,l),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,l),this.nestedValidations(e,s,l),this.mapContexts(t,e,a,l),this.mapContexts(t,e,i,l)))},t.prototype.generateValidationError=function(t,e,n){var r=new $t;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(r.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(r.value=e),r.property=n,r.children=[],r.constraints={},r},t.prototype.conditionalValidations=function(t,e,n){return n.map((function(n){return n.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,n,r){var a=this;n.forEach((function(n){a.metadataStorage.getTargetValidatorConstraints(n.constraintCls).forEach((function(o){if(!(o.async&&a.ignoreAsyncValidations||a.validatorOptions&&a.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:n.propertyName,object:t,value:e,constraints:n.constraints};if(n.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 o.instance.validate(t,i)}));if(c.some((function(t){return Dt(t)}))){var l=c.map((function(t){return Dt(t)?t:Promise.resolve(t)})),u=Promise.all(l).then((function(i){if(!i.every((function(t){return t}))){var s=Kt(a.createValidationError(t,e,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(u)}else{if(!c.every((function(t){return t}))){var p=Kt(a.createValidationError(t,e,n,o),2);m=p[0],y=p[1];r.constraints[m]=y}}}else{var f=o.instance.validate(e,i);if(Dt(f)){var d=f.then((function(i){if(!i){var s=Kt(a.createValidationError(t,e,n,o),2),c=s[0],l=s[1];r.constraints[c]=l,n.context&&(r.contexts||(r.contexts={}),r.contexts[c]=Object.assign(r.contexts[c]||{},n.context))}}));a.awaitingPromises.push(d)}else if(!f){var h=Kt(a.createValidationError(t,e,n,o),2),m=h[0],y=h[1];r.constraints[m]=y}}}}))}))},t.prototype.nestedValidations=function(t,e,n){var r=this;void 0!==t&&e.forEach((function(a){if((a.type===Ht.NESTED_VALIDATION||a.type===Ht.PROMISE_VALIDATION)&&!(r.validatorOptions&&r.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(a,o){r.performValidations(t,a,o.toString(),[],e,n.children)}));else if(t instanceof Object){var o="string"==typeof a.target?a.target:a.target.name;r.execute(t,o,n.children)}else{var i=Kt(r.createValidationError(a.target,t,a),2),s=i[0],c=i[1];n.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,n,r){var a=this;return n.forEach((function(t){if(t.context){var e=void 0;if(t.type===Ht.CUSTOM_VALIDATION)e=a.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var n=a.getConstraintType(t,e);r.constraints[n]&&(r.contexts||(r.contexts={}),r.contexts[n]=Object.assign(r.contexts[n]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,n,r){var a=t.constructor?t.constructor.name:void 0,o=this.getConstraintType(n,r),i={targetName:a,property:n.propertyName,object:t,value:e,constraints:n.constraints},s=n.message||"";return n.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||r&&r.instance.defaultMessage instanceof Function&&(s=r.instance.defaultMessage(i)),[o,Ut.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),Gt=function(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}c((r=r.apply(t,e||[])).next())}))},qt=function(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},Jt=function(){function t(){}return t.prototype.validate=function(t,e,n){return this.coreValidate(t,e,n)},t.prototype.validateOrReject=function(t,e,n){return Gt(this,void 0,void 0,(function(){var r;return qt(this,(function(a){switch(a.label){case 0:return[4,this.coreValidate(t,e,n)];case 1:return(r=a.sent()).length?[2,Promise.reject(r)]:[2]}}))}))},t.prototype.validateSync=function(t,e,n){var r="string"==typeof t?e:t,a="string"==typeof t?t:void 0,o=new Wt(this,"string"==typeof t?n:e);o.ignoreAsyncValidations=!0;var i=[];return o.execute(r,a,i),o.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,n){var r="string"==typeof t?e:t,a="string"==typeof t?t:void 0,o=new Wt(this,"string"==typeof t?n:e),i=[];return o.execute(r,a,i),Promise.all(o.awaitingPromises).then((function(){return o.stripEmptyErrors(i)}))},t}(),Yt=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 Qt(t){return Yt.get(t)}function Xt(t,e,n){return"string"==typeof t?Qt(Jt).validate(t,e,n):Qt(Jt).validate(t,e)}function Zt(t,e,n){return"string"==typeof t?Qt(Jt).validateSync(t,e,n):Qt(Jt).validateSync(t,e)}function te(t,e,n,r){return void 0===n&&(n={}),void 0===r&&(r=""),t.reduce((function(t,n){var a=r?r+"."+n.property:n.property;if(n.constraints){var o=Object.keys(n.constraints)[0];t[a]={type:o,message:n.constraints[o]};var i=t[a];e&&i&&Object.assign(i,{types:n.constraints})}return n.children&&n.children.length&&te(n.children,e,t,a),t}),n)}function ee(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),function(r,a,o){try{var i=e.validator,s=(c=t,l=r,u=e.transformer,Pt.plainToInstance(c,l,u));return Promise.resolve(("sync"===n.mode?Zt:Xt)(s,i)).then((function(t){return t.length?{values:{},errors:St(te(t,!o.shouldUseNativeValidation&&"all"===o.criteriaMode),o)}:(o.shouldUseNativeValidation&&Ot({},o),{values:n.raw?Object.assign({},r):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,l,u}}function ne(t){return{resolver:ee(t),form:bt(t),inputs:Et(t)}}function re({model:t,getDetailsData:n,onSubmit:a,redirect:o,redirectBackOnSuccess:i=!0,...s}){const c=r((()=>ne(t)),[t]);return e.createElement(ht,{getDetailsData:n,onSubmit:a,formOptions:c,redirectBackOnSuccess:i})}const ae=b()(g((t=>({screens:null,user:null,screenPaths:{}})),{name:"app-store-1",storage:E((()=>localStorage)),partialize:t=>({user:t.user})}),w);function oe({onLogin:t}){const{register:n,handleSubmit:r,formState:{errors:a}}=h(),o=u();return e.createElement("div",{className:"login-container"},e.createElement("div",{className:"login-panel"},e.createElement("div",{className:"login-header"},e.createElement("h1",null,"Welcome Back"),e.createElement("p",null,"Please sign in to continue")),e.createElement("form",{onSubmit:r((async e=>{t.login(e.username,e.password).then((t=>{const{user:e,token:n}=t;localStorage.setItem("token",n),ae.setState({user:e}),o("/")}))})),className:"login-form"},e.createElement(dt,{input:{name:"username",label:"Username",placeholder:"Enter your username",type:"input"},register:n,error:a.username}),e.createElement(dt,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password",type:"input"},register:n,error:a.password}),e.createElement("div",{className:"form-actions"},e.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))}function ie({menu:t,getIcons:n,onLogout:r}){const{screens:a,screenPaths:i}=ae((t=>({screens:t.screens??{},screenPaths:t.screenPaths??{}}))),[s,l]=o(!0),f=p(),d=u(),h=t=>{if("/"===t)return f.pathname===t;const e=t.replace(/^\/+|\/+$/g,""),n=f.pathname.replace(/^\/+|\/+$/g,"");return n===e||n.startsWith(`${e}/`)};return e.createElement("div",{className:"sidebar "+(s?"open":"closed")},e.createElement("button",{className:"toggle-button",onClick:()=>l(!s),"aria-label":s?"Collapse sidebar":"Expand sidebar","aria-expanded":s},s?"<":">"),e.createElement("nav",{className:"nav-links"},t?.(a).map(((t,r)=>e.createElement(c,{key:r,to:t.path,className:"nav-link "+(h(t.path)?"active":""),"aria-current":h(t.path)?"page":void 0},e.createElement("span",{className:"nav-links-icon"},n?.(t.iconType)),s?e.createElement("span",null,t.name):null)))),r&&e.createElement("div",{className:"sidebar-footer"},e.createElement("button",{className:"logout-button",onClick:()=>{r&&(r(),d(i.login))},"aria-label":"Logout"},e.createElement("span",{className:"nav-links-icon"},e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M6 12H2V4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{d:"M10 8L14 4M14 4L10 0M14 4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))),s?e.createElement("span",null,"Logout"):null)))}function se({children:t,menu:n,getIcons:r,logout:a}){const{user:o,screenPaths:i}=ae((t=>({user:t.user,screenPaths:t.screenPaths})));ae();const s=u();return o||s(i.login),e.createElement("div",{className:"layout"},e.createElement(ie,{onLogout:()=>{a&&a()},menu:n,getIcons:r}),e.createElement("main",{className:"content"},t))}function ce({children:t,init:n}){return a((()=>{!function({screenPaths:t}){ae.setState({screenPaths:t})}(n())}),[n]),e.createElement(yt,null,t)}function le(t){return K({...t,type:"image"})}function ue(t){return e=>{t&&Reflect.defineMetadata("Crud",t,e)}}export{K as Cell,mt as Counter,ue as Crud,re as FormPage,le as ImageCell,gt as Input,se as Layout,$ as List,ot as ListPage,oe as Login,ce as Panel,ne as getFormFields,Et as getInputFields};
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import { CellOptions } from
|
2
|
-
import { CrudOptions } from
|
3
|
-
import { InputOptions } from
|
4
|
-
import { ListOptions } from
|
1
|
+
import { CellOptions } from '../decorators/list/Cell';
|
2
|
+
import { CrudOptions } from '../decorators/Crud';
|
3
|
+
import { InputOptions } from '../decorators/form/Input';
|
4
|
+
import { ListOptions } from '../decorators/list/List';
|
5
5
|
export interface ScreenCreatorData {
|
6
6
|
resolver: any;
|
7
7
|
fields: string[];
|
8
8
|
inputs: InputOptions[];
|
9
9
|
crud?: CrudOptions;
|
10
10
|
path: string;
|
11
|
-
list?: ListOptions
|
11
|
+
list?: ListOptions<any>;
|
12
12
|
cells: CellOptions[];
|
13
13
|
}
|
package/package.json
CHANGED
@@ -9,15 +9,18 @@ import SearchIcon from '../../../assets/icons/svg/search.svg';
|
|
9
9
|
import PencilIcon from '../../../assets/icons/svg/pencil.svg';
|
10
10
|
import TrashIcon from '../../../assets/icons/svg/trash.svg';
|
11
11
|
|
12
|
-
interface DatagridProps<T
|
12
|
+
interface DatagridProps<T> {
|
13
13
|
data: T[];
|
14
|
-
listData: ListData
|
14
|
+
listData: ListData<T>;
|
15
15
|
onRemoveItem?: (item: T) => Promise<void>;
|
16
16
|
}
|
17
17
|
|
18
|
-
export function Datagrid<T
|
18
|
+
export function Datagrid<T>({ data, listData, onRemoveItem }: DatagridProps<T>) {
|
19
19
|
const cells = listData.cells;
|
20
|
-
const
|
20
|
+
const listGeneralCells =
|
21
|
+
typeof listData.list?.cells === 'function'
|
22
|
+
? listData.list?.cells?.(data[0])
|
23
|
+
: listData.list?.cells;
|
21
24
|
|
22
25
|
return (
|
23
26
|
<div className="datagrid">
|
@@ -30,9 +33,9 @@ export function Datagrid<T extends { id: string }>({ data, listData, onRemoveIte
|
|
30
33
|
{cells.map(cellOptions => (
|
31
34
|
<th key={cellOptions.name}>{cellOptions.title ?? cellOptions.name}</th>
|
32
35
|
))}
|
33
|
-
{
|
34
|
-
{
|
35
|
-
{
|
36
|
+
{listGeneralCells?.details && <th>Details</th>}
|
37
|
+
{listGeneralCells?.edit && <th>Edit</th>}
|
38
|
+
{listGeneralCells?.delete && <th>Delete</th>}
|
36
39
|
</tr>
|
37
40
|
</thead>
|
38
41
|
<tbody>
|
@@ -85,29 +88,32 @@ export function Datagrid<T extends { id: string }>({ data, listData, onRemoveIte
|
|
85
88
|
*/
|
86
89
|
return <td key={cellOptions.name}>{render}</td>;
|
87
90
|
})}
|
88
|
-
{
|
91
|
+
{listGeneralCells?.details && (
|
89
92
|
<td>
|
90
|
-
<Link to={
|
93
|
+
<Link to={listGeneralCells.details.path} className="util-cell-link">
|
91
94
|
<SearchIcon className="icon icon-search" />
|
92
|
-
<span className="util-cell-label">{
|
95
|
+
<span className="util-cell-label">{listGeneralCells.details.label}</span>
|
93
96
|
</Link>
|
94
97
|
</td>
|
95
98
|
)}
|
96
|
-
{
|
99
|
+
{listGeneralCells?.edit && (
|
97
100
|
<td>
|
98
|
-
<Link to={
|
101
|
+
<Link to={listGeneralCells.edit.path} className="util-cell-link">
|
99
102
|
<PencilIcon className="icon icon-pencil" />
|
100
|
-
<span className="util-cell-label">{
|
103
|
+
<span className="util-cell-label">{listGeneralCells.edit.label}</span>
|
101
104
|
</Link>
|
102
105
|
</td>
|
103
106
|
)}
|
104
|
-
{
|
107
|
+
{listGeneralCells?.delete && (
|
105
108
|
<td>
|
106
|
-
<a
|
107
|
-
|
108
|
-
|
109
|
+
<a
|
110
|
+
onClick={() => {
|
111
|
+
onRemoveItem?.(item);
|
112
|
+
}}
|
113
|
+
className="util-cell-link"
|
114
|
+
>
|
109
115
|
<TrashIcon className="icon icon-trash" />
|
110
|
-
<span className="util-cell-label">{
|
116
|
+
<span className="util-cell-label">{listGeneralCells.delete.label}</span>
|
111
117
|
</a>
|
112
118
|
</td>
|
113
119
|
)}
|
@@ -3,11 +3,11 @@ import { ListData } from '../../../decorators/list/ListData';
|
|
3
3
|
import { CellOptions, StaticSelectFilter } from '../../../decorators/list/Cell';
|
4
4
|
import Select from 'react-select';
|
5
5
|
|
6
|
-
interface FilterPopupProps {
|
6
|
+
interface FilterPopupProps<T> {
|
7
7
|
isOpen: boolean;
|
8
8
|
onClose: () => void;
|
9
9
|
onApplyFilters: (filters: Record<string, string>) => void;
|
10
|
-
listData: ListData
|
10
|
+
listData: ListData<T>;
|
11
11
|
activeFilters?: Record<string, string>;
|
12
12
|
}
|
13
13
|
|
@@ -126,13 +126,13 @@ function FilterField({ field, value, onChange }: FilterFieldProps): React.ReactE
|
|
126
126
|
}
|
127
127
|
}
|
128
128
|
|
129
|
-
export function FilterPopup({
|
129
|
+
export function FilterPopup<T>({
|
130
130
|
isOpen,
|
131
131
|
onClose,
|
132
132
|
onApplyFilters,
|
133
133
|
listData,
|
134
134
|
activeFilters,
|
135
|
-
}: FilterPopupProps): React.ReactElement | null {
|
135
|
+
}: FilterPopupProps<T>): React.ReactElement | null {
|
136
136
|
const [filters, setFilters] = React.useState<Record<string, any>>(activeFilters ?? {});
|
137
137
|
const popupRef = useRef<HTMLDivElement>(null);
|
138
138
|
const fields = useMemo(() => listData.cells.filter(cell => !!cell.filter), [listData.cells]);
|
@@ -26,13 +26,13 @@ export interface PaginatedResponse<T> {
|
|
26
26
|
|
27
27
|
export type GetDataForList<T> = (params: GetDataParams) => Promise<PaginatedResponse<T>>;
|
28
28
|
|
29
|
-
const ListHeader = ({
|
29
|
+
const ListHeader = <T extends AnyClass>({
|
30
30
|
listData,
|
31
31
|
filtered,
|
32
32
|
onFilterClick,
|
33
33
|
customHeader,
|
34
34
|
}: {
|
35
|
-
listData: ListData
|
35
|
+
listData: ListData<T>;
|
36
36
|
filtered: boolean;
|
37
37
|
onFilterClick: () => void;
|
38
38
|
customHeader?: React.ReactNode;
|
@@ -62,7 +62,7 @@ const ListHeader = ({
|
|
62
62
|
);
|
63
63
|
};
|
64
64
|
|
65
|
-
export function ListPage<T extends AnyClass
|
65
|
+
export function ListPage<T extends AnyClass>({
|
66
66
|
model,
|
67
67
|
getData,
|
68
68
|
onRemoveItem,
|
@@ -156,7 +156,7 @@ export function ListPage<T extends AnyClass & { id: string }>({
|
|
156
156
|
message: 'This action cannot be undone.',
|
157
157
|
onConfirm: async () => {
|
158
158
|
await onRemoveItem(item);
|
159
|
-
setData(data.filter((d: T) => d.id !== item.id));
|
159
|
+
//setData(data.filter((d: T) => d.id !== item.id));
|
160
160
|
await fetchData(pagination.page);
|
161
161
|
},
|
162
162
|
});
|
@@ -7,18 +7,18 @@ export interface ListHeaderOptions {
|
|
7
7
|
create?: { path: string; label: string };
|
8
8
|
}
|
9
9
|
|
10
|
-
export interface
|
10
|
+
export interface ListCellOptions<T> {
|
11
11
|
details?: { path: string; label: string };
|
12
12
|
edit?: { path: string; label: string };
|
13
|
-
delete?: {
|
13
|
+
delete?: { label: string };
|
14
14
|
}
|
15
15
|
|
16
|
-
export interface ListOptions {
|
16
|
+
export interface ListOptions<T> {
|
17
17
|
headers?: ListHeaderOptions;
|
18
|
-
|
18
|
+
cells?: ((item: T) => ListCellOptions<T>) | ListCellOptions<T>;
|
19
19
|
}
|
20
20
|
|
21
|
-
export function List(options?: ListOptions): ClassDecorator {
|
21
|
+
export function List<T>(options?: ListOptions<T> | ((item: T) => ListOptions<T>)): ClassDecorator {
|
22
22
|
return (target: Function) => {
|
23
23
|
if (options) {
|
24
24
|
Reflect.defineMetadata(LIST_KEY, options, target);
|
@@ -26,6 +26,7 @@ export function List(options?: ListOptions): ClassDecorator {
|
|
26
26
|
};
|
27
27
|
}
|
28
28
|
|
29
|
-
export function getClassListData(entityClass:
|
30
|
-
|
29
|
+
export function getClassListData<T>(entityClass: T): ListOptions<T> | undefined {
|
30
|
+
//TODO: try to remove any
|
31
|
+
return Reflect.getMetadata(LIST_KEY, entityClass as any);
|
31
32
|
}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { ListOptions } from
|
2
|
-
import { CellOptions } from
|
1
|
+
import { ListOptions } from './List';
|
2
|
+
import { CellOptions } from './Cell';
|
3
3
|
|
4
|
-
export interface ListData {
|
5
|
-
|
6
|
-
|
4
|
+
export interface ListData<T> {
|
5
|
+
list?: ListOptions<T>;
|
6
|
+
cells: CellOptions[];
|
7
7
|
}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { getClassListData } from
|
2
|
-
import { getCellFields } from
|
3
|
-
import { ListData } from
|
1
|
+
import { getClassListData } from './List';
|
2
|
+
import { getCellFields } from './GetCellFields';
|
3
|
+
import { ListData } from './ListData';
|
4
4
|
|
5
|
-
export function getListFields<T>(entityClass: T): ListData {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
export function getListFields<T>(entityClass: T): ListData<T> {
|
6
|
+
return {
|
7
|
+
list: getClassListData(entityClass),
|
8
|
+
cells: getCellFields(entityClass),
|
9
|
+
};
|
10
10
|
}
|
package/src/styles/index.scss
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
@
|
2
|
-
|
3
|
-
@
|
4
|
-
@
|
5
|
-
@
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@use './filter-popup';
|
1
|
+
@import './layout';
|
2
|
+
@import './sidebar';
|
3
|
+
@import './form';
|
4
|
+
@import './list';
|
5
|
+
@import './login';
|
6
|
+
@import './error-boundary';
|
7
|
+
@import './image-uploader';
|
8
|
+
@import './counter';
|
9
|
+
@import './loading-screen';
|
10
|
+
@import './pagination';
|
11
|
+
@import './filter-popup';
|
13
12
|
|
14
13
|
.layout {
|
15
14
|
display: flex;
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import { CellOptions } from
|
2
|
-
import { CrudOptions } from
|
3
|
-
import { InputOptions } from
|
4
|
-
import { ListOptions } from
|
5
|
-
|
1
|
+
import { CellOptions } from '../decorators/list/Cell';
|
2
|
+
import { CrudOptions } from '../decorators/Crud';
|
3
|
+
import { InputOptions } from '../decorators/form/Input';
|
4
|
+
import { ListOptions } from '../decorators/list/List';
|
5
|
+
//TODO: remove
|
6
6
|
export interface ScreenCreatorData {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
resolver: any;
|
8
|
+
fields: string[];
|
9
|
+
inputs: InputOptions[];
|
10
|
+
crud?: CrudOptions;
|
11
|
+
path: string;
|
12
|
+
list?: ListOptions<any>;
|
13
|
+
cells: CellOptions[];
|
14
14
|
}
|