proje-react-panel 1.0.15 → 1.0.17-test1

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.
Files changed (52) hide show
  1. package/.vscode/launch.json +10 -0
  2. package/dist/components/components/FormField.d.ts +2 -1
  3. package/dist/components/components/InnerForm.d.ts +2 -2
  4. package/dist/components/components/list/Datagrid.d.ts +9 -0
  5. package/dist/components/components/list/EmptyList.d.ts +2 -0
  6. package/dist/components/components/list/FilterPopup.d.ts +11 -0
  7. package/dist/components/components/list/ListPage.d.ts +20 -0
  8. package/dist/components/components/list/Pagination.d.ts +11 -0
  9. package/dist/components/components/list/index.d.ts +0 -0
  10. package/dist/components/list/Datagrid.d.ts +8 -4
  11. package/dist/components/list/EmptyList.d.ts +2 -0
  12. package/dist/components/list/FilterPopup.d.ts +10 -0
  13. package/dist/components/pages/FormPage.d.ts +3 -2
  14. package/dist/components/pages/ListPage.d.ts +2 -1
  15. package/dist/decorators/form/Input.d.ts +7 -3
  16. package/dist/decorators/list/Cell.d.ts +14 -2
  17. package/dist/decorators/list/List.d.ts +26 -4
  18. package/dist/decorators/list/ListData.d.ts +4 -4
  19. package/dist/decorators/list/getListFields.d.ts +2 -2
  20. package/dist/index.cjs.js +1 -1
  21. package/dist/index.d.ts +4 -3
  22. package/dist/index.esm.js +1 -1
  23. package/dist/types/ScreenCreatorData.d.ts +5 -5
  24. package/package.json +9 -3
  25. package/src/assets/icons/svg/create.svg +9 -0
  26. package/src/assets/icons/svg/filter.svg +3 -0
  27. package/src/assets/icons/svg/pencil.svg +8 -0
  28. package/src/assets/icons/svg/search.svg +8 -0
  29. package/src/assets/icons/svg/trash.svg +8 -0
  30. package/src/components/components/FormField.tsx +41 -7
  31. package/src/components/components/InnerForm.tsx +8 -9
  32. package/src/components/components/list/Datagrid.tsx +127 -0
  33. package/src/components/components/list/EmptyList.tsx +26 -0
  34. package/src/components/components/list/FilterPopup.tsx +202 -0
  35. package/src/components/components/list/ListPage.tsx +178 -0
  36. package/src/components/pages/FormPage.tsx +4 -2
  37. package/src/decorators/form/Input.ts +4 -3
  38. package/src/decorators/list/Cell.ts +24 -14
  39. package/src/decorators/list/List.ts +26 -11
  40. package/src/decorators/list/ListData.ts +5 -5
  41. package/src/decorators/list/getListFields.ts +8 -8
  42. package/src/index.ts +8 -3
  43. package/src/styles/filter-popup.scss +134 -0
  44. package/src/styles/index.scss +8 -13
  45. package/src/styles/list.scss +149 -8
  46. package/src/types/ScreenCreatorData.ts +12 -12
  47. package/src/types/svg.d.ts +5 -0
  48. package/src/components/list/Datagrid.tsx +0 -101
  49. package/src/components/pages/ListPage.tsx +0 -85
  50. /package/src/components/{list → components/list}/Pagination.tsx +0 -0
  51. /package/src/components/{list → components/list}/index.ts +0 -0
  52. /package/src/styles/{_scrollbar.scss → utils/scrollbar.scss} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  export type { OnSubmitFN, GetDetailsDataFN } from './components/pages/FormPage';
2
- export type { GetDataForList } from './components/pages/ListPage';
3
- export type { PaginatedResponse, PaginationParams } from './components/pages/ListPage';
4
2
  export type { InitPanelOptions } from './types/initPanelOptions';
5
3
  export type { ScreenCreatorData } from './types/ScreenCreatorData';
6
4
  export type { OnLogin } from './components/pages/Login';
7
5
  export type { AnyClass } from './types/AnyClass';
8
- export { ListPage } from './components/pages/ListPage';
6
+ export type { GetDataForList, PaginatedResponse, GetDataParams, } from './components/components/list/ListPage';
7
+ export { ListPage } from './components/components/list/ListPage';
9
8
  export { FormPage } from './components/pages/FormPage';
10
9
  export type { FormPageProps } from './components/pages/FormPage';
11
10
  export { Login } from './components/pages/Login';
@@ -17,3 +16,5 @@ export { ImageCell } from './decorators/list/ImageCell';
17
16
  export { Crud } from './decorators/Crud';
18
17
  export { Cell } from './decorators/list/Cell';
19
18
  export { Input } from './decorators/form/Input';
19
+ export { getFormFields } from './decorators/form/getFormFields';
20
+ export { getInputFields } from './decorators/form/Input';
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import t,{useState as e,useMemo as r,useCallback as n,useEffect as o,Component as a}from"react";import{Link as i,useParams as s,useNavigate as c,useLocation as l}from"react-router";import{useFormContext as u,useForm as p,FormProvider as f,get as d,set as h}from"react-hook-form";import{persist as y,createJSONStorage as m}from"zustand/middleware";import{createWithEqualityFn as v}from"zustand/traditional";import{shallow as g}from"zustand/vanilla/shallow";function E({data:e,cells:r}){return e&&0!==e.length?t.createElement("div",{className:"datagrid"},t.createElement("table",{className:"datagrid-table"},t.createElement("thead",null,t.createElement("tr",null,r.map((e=>t.createElement("th",{key:e.name},e.title??e.name))),t.createElement("th",null),t.createElement("th",null,"Delete"))),t.createElement("tbody",null,e.map(((e,n)=>t.createElement("tr",{key:n},r.map((r=>{const n=e[r.name];let o=n??"-";switch(r.type){case"date":if(n){const t=new Date(n);o=`${t.getDate().toString().padStart(2,"0")}/${(t.getMonth()+1).toString().padStart(2,"0")}/${t.getFullYear()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}break;case"image":{const e=r;o=t.createElement("img",{width:100,height:100,src:e.baseUrl+n,style:{objectFit:"contain"}});break}default:o=n?n.toString():r?.placeHolder??"-"}return t.createElement("td",{key:r.name},o)})),t.createElement("td",null,t.createElement(i,{to:"edit/"+(e?.id??"-")},"Edit"),t.createElement(i,{to:"details/"+(e?.id??"-")},"Details")),t.createElement("td",null,t.createElement("button",{onClick:()=>{}},"Delete")))))))):t.createElement("div",null,"No items available")}function b({error:e}){return t.createElement("div",{className:"error-container"},t.createElement("div",{className:"error-icon"},t.createElement("i",{className:"fa fa-exclamation-circle"})),t.createElement("div",{className:"error-content"},t.createElement("h3",null,"Error Occurred"),t.createElement("p",null,(t=>{if(t instanceof Response)switch(t.status){case 400:return"Bad Request: The request was invalid or malformed.";case 401:return"Unauthorized: Please log in to access this resource.";case 404:return"Not Found: The requested resource could not be found.";case 403:return"Forbidden: You don't have permission to access this resource.";case 500:return"Internal Server Error: Something went wrong on our end.";default:return`Error ${t.status}: ${t.statusText||"Something went wrong."}`}return t?.message||"Something went wrong. Please try again later."})(e))))}function w(){return t.createElement("div",{className:"loading-screen"},t.createElement("div",{className:"loading-container"},t.createElement("div",{className:"loading-spinner"}),t.createElement("div",{className:"loading-text"},"Loading...")))}var _,O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},S={};!function(){return _||(_=1,function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof O?O:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=n(t);function n(t,e){return function(r,n){Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0!==e.Reflect&&(r=n(e.Reflect,r)),function(t,e){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,o=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",a=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,c=!i&&!s,l={create:i?function(){return pt(Object.create(null))}:s?function(){return pt({__proto__:null})}:function(){return pt({})},has:c?function(t,e){return r.call(t,e)}:function(t,e){return e in t},get:c?function(t,e){return r.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},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=n?Symbol.for("@reflect-metadata:registry"):void 0,y=ot(),m=at(y);function v(t,e,r,n){if(D(r)){if(!W(t))throw new TypeError;if(!q(e))throw new TypeError;return A(t,e)}if(!W(t))throw new TypeError;if(!B(e))throw new TypeError;if(!B(n)&&!D(n)&&!R(n))throw new TypeError;return R(n)&&(n=void 0),x(t,e,r=H(r),n)}function g(t,e){function r(r,n){if(!B(r))throw new TypeError;if(!D(n)&&!J(n))throw new TypeError;P(t,e,r,n)}return r}function E(t,e,r,n){if(!B(r))throw new TypeError;return D(n)||(n=H(n)),P(t,e,r,n)}function b(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=H(r)),N(t,e,r)}function w(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=H(r)),C(t,e,r)}function _(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=H(r)),k(t,e,r)}function O(t,e,r){if(!B(e))throw new TypeError;return D(r)||(r=H(r)),L(t,e,r)}function S(t,e){if(!B(t))throw new TypeError;return D(e)||(e=H(e)),I(t,e)}function M(t,e){if(!B(t))throw new TypeError;return D(e)||(e=H(e)),V(t,e)}function T(t,e,r){if(!B(e))throw new TypeError;if(D(r)||(r=H(r)),!B(e))throw new TypeError;D(r)||(r=H(r));var n=st(e,r,!1);return!D(n)&&n.OrdinaryDeleteMetadata(t,e,r)}function A(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!D(n)&&!R(n)){if(!q(n))throw new TypeError;e=n}}return e}function x(t,e,r,n){for(var o=t.length-1;o>=0;--o){var a=(0,t[o])(e,r,n);if(!D(a)&&!R(a)){if(!B(a))throw new TypeError;n=a}}return n}function N(t,e,r){if(C(t,e,r))return!0;var n=rt(e);return!R(n)&&N(t,n,r)}function C(t,e,r){var n=st(e,r,!1);return!D(n)&&U(n.OrdinaryHasOwnMetadata(t,e,r))}function k(t,e,r){if(C(t,e,r))return L(t,e,r);var n=rt(e);return R(n)?void 0:k(t,n,r)}function L(t,e,r){var n=st(e,r,!1);if(!D(n))return n.OrdinaryGetOwnMetadata(t,e,r)}function P(t,e,r,n){st(r,n,!0).OrdinaryDefineOwnMetadata(t,e,r,n)}function I(t,e){var r=V(t,e),n=rt(t);if(null===n)return r;var o=I(n,e);if(o.length<=0)return r;if(r.length<=0)return o;for(var a=new f,i=[],s=0,c=r;s<c.length;s++){var l=c[s];a.has(l)||(a.add(l),i.push(l))}for(var u=0,p=o;u<p.length;u++){l=p[u];a.has(l)||(a.add(l),i.push(l))}return i}function V(t,e){var r=st(t,e,!1);return r?r.OrdinaryOwnMetadataKeys(t,e):[]}function j(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function D(t){return void 0===t}function R(t){return null===t}function F(t){return"symbol"==typeof t}function B(t){return"object"==typeof t?null!==t:"function"==typeof t}function $(t,e){switch(j(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r="string",n=Q(t,o);if(void 0!==n){var a=n.call(t,r);if(B(a))throw new TypeError;return a}return z(t)}function z(t,e){var r,n,o=t.toString;if(G(o)&&!B(n=o.call(t)))return n;if(G(r=t.valueOf)&&!B(n=r.call(t)))return n;throw new TypeError}function U(t){return!!t}function K(t){return""+t}function H(t){var e=$(t);return F(e)?e:K(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(j(t)){case 3:case 4:return!0;default:return!1}}function Y(t,e){return t===e||t!=t&&e!=e}function Q(t,e){var r=t[e];if(null!=r){if(!G(r))throw new TypeError;return r}}function X(t){var e=Q(t,a);if(!G(e))throw new TypeError;var r=e.call(t);if(!B(r))throw new TypeError;return r}function Z(t){return t.value}function tt(t){var e=t.next();return!e.done&&e}function et(t){var e=t.return;e&&e.call(t)}function rt(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===u)return e;if(e!==u)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var o=n.constructor;return"function"!=typeof o||o===t?e:o}function nt(){var t,r,n,o;D(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=it(e.Reflect));var a=new d,i={registerProvider:s,getProvider:l,setProvider:y};return i;function s(e){if(!Object.isExtensible(i))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case D(r):r=e;break;case r===e:break;case D(n):n=e;break;case n===e:break;default:void 0===o&&(o=new f),o.add(e)}}function c(e,a){if(!D(r)){if(r.isProviderFor(e,a))return r;if(!D(n)){if(n.isProviderFor(e,a))return r;if(!D(o))for(var i=X(o);;){var s=tt(i);if(!s)return;var c=Z(s);if(c.isProviderFor(e,a))return et(i),c}}}if(!D(t)&&t.isProviderFor(e,a))return t}function l(t,e){var r,n=a.get(t);return D(n)||(r=n.get(e)),D(r)?(D(r=c(t,e))||(D(n)&&(n=new p,a.set(t,n)),n.set(e,r)),r):r}function u(t){if(D(t))throw new TypeError;return r===t||n===t||!D(o)&&o.has(t)}function y(t,e,r){if(!u(r))throw new Error("Metadata provider not registered.");var n=l(t,e);if(n!==r){if(!D(n))return!1;var o=a.get(t);D(o)&&(o=new p,a.set(t,o)),o.set(e,r)}return!0}}function ot(){var t;return!D(h)&&B(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),D(t)&&(t=nt()),!D(h)&&B(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}function at(t){var e=new d,r={isProviderFor:function(t,r){var n=e.get(t);return!D(n)&&n.has(r)},OrdinaryDefineOwnMetadata:i,OrdinaryHasOwnMetadata:o,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return y.registerProvider(r),r;function n(n,o,a){var i=e.get(n),s=!1;if(D(i)){if(!a)return;i=new p,e.set(n,i),s=!0}var c=i.get(o);if(D(c)){if(!a)return;if(c=new p,i.set(o,c),!t.setProvider(n,o,r))throw i.delete(o),s&&e.delete(n),new Error("Wrong provider for target.")}return c}function o(t,e,r){var o=n(e,r,!1);return!D(o)&&U(o.has(t))}function a(t,e,r){var o=n(e,r,!1);if(!D(o))return o.get(t)}function i(t,e,r,o){n(r,o,!0).set(t,e)}function s(t,e){var r=[],o=n(t,e,!1);if(D(o))return r;for(var a=X(o.keys()),i=0;;){var s=tt(a);if(!s)return r.length=i,r;var c=Z(s);try{r[i]=c}catch(t){try{et(a)}finally{throw t}}i++}}function c(t,r,o){var a=n(r,o,!1);if(D(a))return!1;if(!a.delete(t))return!1;if(0===a.size){var i=e.get(r);D(i)||(i.delete(o),0===i.size&&e.delete(i))}return!0}}function it(t){var e=t.defineMetadata,r=t.hasOwnMetadata,n=t.getOwnMetadata,o=t.getOwnMetadataKeys,a=t.deleteMetadata,i=new d;return{isProviderFor:function(t,e){var r=i.get(t);return!(D(r)||!r.has(e))||!!o(t,e).length&&(D(r)&&(r=new f,i.set(t,r)),r.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:o,OrdinaryDeleteMetadata:a}}function st(t,e,r){var n=y.getProvider(t,e);if(!D(n))return n;if(r){if(y.setProvider(t,e,m))return m;throw new Error("Illegal state.")}}function ct(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[a]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}(),n=function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,Y(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,o)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[a]=function(){return this.entries()},e.prototype._find=function(t,e){if(!Y(this._cacheKey,t)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Y(this._keys[r],t)){this._cacheIndex=r;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();return n;function o(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function 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[a]=function(){return this.keys()},t}()}function ut(){var t=16,e=l.create(),n=o();return function(){function t(){this._key=o()}return t.prototype.has=function(t){var e=a(t,!1);return void 0!==e&&l.has(e,this._key)},t.prototype.get=function(t){var e=a(t,!1);return void 0!==e?l.get(e,this._key):void 0},t.prototype.set=function(t,e){return a(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=a(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=o()},t}();function o(){var t;do{t="@@WeakMap@@"+c()}while(l.has(e,t));return e[t]=!0,t}function a(t,e){if(!r.call(t,n)){if(!e)return;Object.defineProperty(t,n,{value:l.create()})}return t[n]}function i(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function s(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):i(e,t),e}return i(new Array(t),t)}function c(){var e=s(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var r="",n=0;n<t;++n){var o=e[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function pt(t){return t.__=void 0,delete t.__,t}t("decorate",v),t("metadata",g),t("defineMetadata",E),t("hasMetadata",b),t("hasOwnMetadata",w),t("getMetadata",_),t("getOwnMetadata",O),t("getMetadataKeys",S),t("getOwnMetadataKeys",M),t("deleteMetadata",T)}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))),S;var t}();const M="List";function T(t){return e=>{t&&Reflect.defineMetadata(M,t,e)}}function A(t){return Reflect.getMetadata(M,t)}const x=Symbol("cell");function N(t){return(e,r)=>{const n=Reflect.getMetadata(x,e)||[];if(Reflect.defineMetadata(x,[...n,r.toString()],e),t){const n=`${x.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function C(t){const e=t.prototype;return(Reflect.getMetadata(x,e)||[]).map((t=>{const r=Reflect.getMetadata(`${x.toString()}:${t}:options`,e)||{};return{...r,name:r?.name??t}}))}function k({pagination:e,onPageChange:r}){const{total:n,page:o,limit:a}=e,i=Math.floor(n/a);if(i<=1)return null;return t.createElement("div",{className:"pagination"},t.createElement("button",{onClick:()=>r(o-1),className:"pagination-item "+(1===o?"disabled":""),disabled:1===o,"aria-disabled":1===o},"Previous"),(()=>{const e=[];for(let n=1;n<=Math.min(2,i);n++)e.push(t.createElement("button",{key:n,onClick:()=>r(n),className:"pagination-item "+(o===n?"active":""),disabled:o===n},n));o-2>3&&e.push(t.createElement("span",{key:"ellipsis1",className:"pagination-ellipsis"},"..."));for(let n=Math.max(3,o-2);n<=Math.min(i-2,o+2);n++)n>2&&n<i-1&&e.push(t.createElement("button",{key:n,onClick:()=>r(n),className:"pagination-item "+(o===n?"active":""),disabled:o===n},n));o+2<i-2&&e.push(t.createElement("span",{key:"ellipsis2",className:"pagination-ellipsis"},"..."));for(let n=Math.max(i-1,3);n<=i;n++)n>2&&e.push(t.createElement("button",{key:n,onClick:()=>r(n),className:"pagination-item "+(o===n?"active":""),disabled:o===n},n));return e})(),t.createElement("button",{onClick:()=>r(o+1),className:"pagination-item "+(o===i?"disabled":""),disabled:o===i,"aria-disabled":o===i},"Next"))}function L({model:a,getData:c}){const[l,u]=e(!0),[p,f]=e({total:0,page:0,limit:0}),[d,h]=e(null),[y,m]=e(null),v=r((()=>{return{list:A(t=a),cells:C(t)};var t}),[a]),g=s(),_=n((async t=>{u(!0);try{const e=await c({page:t});h(e.data),f({total:e.total,page:e.page,limit:e.limit})}catch(t){m(t),console.error(t)}finally{u(!1)}}),[c]);return o((()=>{_(parseInt(g.page)||1)}),[_,g.page]),l?t.createElement(w,null):y?t.createElement(b,{error:y}):t.createElement("div",{className:"list"},t.createElement("div",{className:"list-header"},t.createElement(i,{to:"create"},"Create")),t.createElement(E,{cells:v.cells,data:d}),t.createElement("div",{className:"list-footer"},t.createElement(k,{pagination:p,onPageChange:t=>{_(t)}})))}function P({htmlFor:e,label:r,fieldName:n}){return t.createElement("label",{htmlFor:e},r??n.charAt(0).toUpperCase()+n.slice(1))}const I=Object.freeze({BEFORE:"before",HOVER:"hover",AFTER:"after"});function V(e){return t.createElement("div",null,t.createElement("img",{...e,style:{width:100}}),t.createElement("p",null,e.name," ",t.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]})(e.size),")")))}function j(){const{register:e,formState:{errors:r},watch:n,setValue:a,clearErrors:i,setError:s}=u(),c=n("uploader");return o((()=>{e("uploader",{required:!0})}),[e]),t.createElement("div",null,t.createElement("span",{className:"form-error",style:{bottom:2,top:"unset"}},"required"===r.uploader?.type&&"At least 1 image is required!","custom"===r.uploader?.type&&r.uploader.message?.toString()),t.createElement(D,{reset:c,onError:t=>{t?s("uploader",{type:"custom",message:t}):(a("uploader",{files:[]}),i("uploader"))},onClear:()=>{a("uploader",{files:[]}),i("uploader")},onFilesChange:t=>{a("uploader",{files:t})}}))}function D(e){const[r,n]=t.useState(I.BEFORE),[o,a]=t.useState(e.value||[]),[i,s]=t.useState([]),[c,l]=t.useState(0);console.log("files",i);const u=t.useRef(null),p=t.useRef(null);t.useEffect((()=>{const t=u.current;if(!t)return;const r=t=>{t.preventDefault(),t.stopPropagation(),f()},o=t=>{t.preventDefault(),t.stopPropagation(),d()},a=t=>{t.preventDefault(),t.stopPropagation()},c=t=>{t.preventDefault(),t.stopPropagation(),l(0);const r=t.dataTransfer?.files;if(!r)return;s([]),n(I.AFTER);const o=[];for(let t=0;t<r.length;t++){const n=new FileReader;n.onload=n=>{if(!n.target)return;h([...i,{file:r[t],image:n.target.result}])&&(o.push(r[t]),p.current&&(p.current.files=r),s([])),e.onFilesChange&&e.onFilesChange(o)},n.readAsDataURL(r[t])}p.current&&(p.current.files=r)};return t.addEventListener("dragenter",r,!1),t.addEventListener("dragleave",o,!1),t.addEventListener("dragover",a,!1),t.addEventListener("drop",c,!1),()=>{t.removeEventListener("dragenter",r),t.removeEventListener("dragleave",o),t.removeEventListener("dragover",a),t.removeEventListener("drop",c)}}),[i]);const f=()=>{l((t=>t+1)),n(I.HOVER)},d=()=>{l((t=>t-1==0?(n(I.BEFORE),0):t-1))},h=t=>{const r=(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 r=t[e].file,n=r.name.split(".");if(!["png","jpg","jpeg"].includes(n[n.length-1]))return'Extension of the file can only be "png", "jpg" or "jpeg" ';if(r&&r.size>1048576)return`Size of "${r.name}" can't be bigger than 1mb`}return null})(t);return r||s(t),e.onError?.(r),r};return t.createElement("div",{ref:u,className:"multi-image form-element dropzone "+r},t.createElement("input",{ref:p,type:"file",style:{display:"none"},className:"target",name:"file"}),t.createElement("div",{className:"container"},t.createElement("button",{className:"trash",onClick:()=>{s([]),p.current&&(p.current.value=""),e.onClear?.()},type:"button"},"Delete All"),(()=>{const e=[];if(i){console.log("----\x3e",i);for(let r=0;r<i.length;r++){let n="image";e.push(t.createElement("div",{key:r,className:"image-container"},t.createElement("div",{className:n},t.createElement(V,{name:i[r].file.name,src:i[r].image,size:i[r].file.size}))))}}return e})(),t.createElement("div",null,t.createElement("button",{type:"button",onClick:()=>{const t=document.getElementById("file__");t&&t.click()},className:"plus"},t.createElement("span",null,"+ Add Image",t.createElement("p",null,"Drag image here or Select Image")))),t.createElement("input",{hidden:!0,id:"file__",multiple:!0,type:"file",onChange:t=>{const e=t.target.files;if(e){s([]),n(I.AFTER);for(let t=0;t<e.length;t++){const r=new FileReader;r.onload=r=>{r.target&&h([...i,{file:e[t],image:r.target.result}])},r.readAsDataURL(e[t])}p.current&&(p.current.files=e)}}})))}function R({id:e,...r}){return t.createElement("input",{type:"checkbox",id:e,className:"checkbox",...r})}function F({input:e,register:r,error:n}){const o=e.name||"";return t.createElement("div",{className:"form-field"},t.createElement(P,{htmlFor:o,label:e.label,fieldName:o}),(()=>{switch(e.type){case"textarea":return t.createElement("textarea",{...r(o),placeholder:e.placeholder,id:o});case"select":return t.createElement("select",{...r(o),id:o},t.createElement("option",{value:""},"Select ",o),e.selectOptions?.map((e=>t.createElement("option",{key:e,value:e},e))));case"input":return t.createElement("input",{type:e.inputType,...r(o),placeholder:e.placeholder,id:o});case"file-upload":return t.createElement(j,null);case"checkbox":return t.createElement(R,{...r(o),id:o});case"hidden":return t.createElement("input",{type:"hidden",...r(o),id:o})}})(),n&&t.createElement("span",{className:"error-message"},n.message))}function B({formOptions:e,onSubmit:r,redirect:n,getDetailsData:a}){const i=s(),c=p({resolver:e.resolver}),l=e.inputs;return o((()=>{a&&a(i.id).then((t=>{c.reset({...t})}))}),[,c.reset]),t.createElement("div",{className:"form-wrapper"},t.createElement(f,{...c},t.createElement("form",{onSubmit:c.handleSubmit((async t=>{await r(t),n&&(window.location.href=n)}),((t,e)=>{console.log("error creating creation",t,e)}))},t.createElement("div",null,l?.map((e=>t.createElement(F,{key:e.name||"",input:e,register:c.register,error:e.name?{message:c.formState.errors[e.name]?.message}:void 0}))),t.createElement("button",{type:"submit",className:"submit-button"},"Submit")))))}function $({image:r,text:n,targetNumber:a,duration:i=2e3}){const[s,c]=e(0);return o((()=>{let t,e;const r=n=>{t||(t=n);const o=n-t,s=Math.min(o/i,1);c(Math.floor(s*a)),s<1&&(e=requestAnimationFrame(r))};return e=requestAnimationFrame(r),()=>{e&&cancelAnimationFrame(e)}}),[a,i]),t.createElement("div",{className:"counter-container"},t.createElement("div",{className:"counter-image"},r),t.createElement("div",{className:"counter-text"},n),t.createElement("div",{className:"counter-value"},s))}class z extends a{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(t){return{hasError:!0,error:t,errorInfo:null}}componentDidCatch(t,e){this.setState({error:t,errorInfo:e})}render(){return this.state.hasError?t.createElement("div",{className:"error-boundary"},t.createElement("div",{className:"error-boundary__content"},t.createElement("div",{className:"error-boundary__icon"},t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},t.createElement("circle",{cx:"12",cy:"12",r:"10"}),t.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.createElement("line",{x1:"12",y1:"16",x2:"12",y2:"16"}))),t.createElement("h1",null,"Oops! Something went wrong"),t.createElement("p",{className:"error-boundary__message"},this.state.error?.message||"An unexpected error occurred"),t.createElement("button",{className:"error-boundary__button",onClick:()=>window.location.reload()},"Refresh Page"),"development"===process.env.NODE_ENV&&t.createElement("details",{className:"error-boundary__details"},t.createElement("summary",null,"Error Details"),t.createElement("pre",null,this.state.error?.toString()),t.createElement("pre",null,this.state.errorInfo?.componentStack)))):this.props.children}}const U=Symbol("input");function K(t){return(e,r)=>{const n=Reflect.getMetadata(U,e)||[];if(Reflect.defineMetadata(U,[...n,r.toString()],e),t){const n=`${U.toString()}:${r.toString()}:options`;Reflect.defineMetadata(n,t,e)}}}function H(t){const e=t.prototype;return(Reflect.getMetadata(U,e)||[]).map((t=>{const r=Reflect.getMetadata(`${U.toString()}:${t}:options`,e)||{},n=r?.inputType??(o=t,["password"].some((t=>o.toLowerCase().includes(t)))?"password":"text");var o;return{...r,editable:r.editable??!0,sensitive:r.sensitive,name:r?.name??t,label:r?.label??t,placeholder:r?.placeholder??t,inputType:n,type:r?.type??"input",selectOptions:r?.selectOptions??[],cancelPasswordValidationOnEdit:r?.cancelPasswordValidationOnEdit??"password"===n}}))}function W(t){return Reflect.getMetadata("FormMetadata",t)}const G=(t,e,r)=>{if(t&&"reportValidity"in t){const n=d(r,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},q=(t,e)=>{for(const r in e.fields){const n=e.fields[r];n&&n.ref&&"reportValidity"in n.ref?G(n.ref,r,t):n&&n.refs&&n.refs.forEach((e=>G(e,r,t)))}},J=(t,e)=>{e.shouldUseNativeValidation&&q(t,e);const r={};for(const n in t){const o=d(e.fields,n),a=Object.assign(t[n]||{},{ref:o&&o.ref});if(Y(e.names||Object.keys(t),n)){const t=Object.assign({},d(r,n));h(t,"root",a),h(r,n,t)}else h(r,n,a)}return r},Y=(t,e)=>{const r=Q(e);return t.some((t=>Q(t).match(`^${r}\\.\\d+`)))};function Q(t){return t.replace(/\]|\[/g,"")}var X;!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"}(X||(X={}));var Z=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,r){return this.findMetadatas(this._transformMetadatas,t,e).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?r===X.CLASS_TO_CLASS||r===X.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===X.CLASS_TO_PLAIN))}))},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find((function(t){return t.options&&t.options.name===e}))},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),n=this._exposeMetadatas.get(t),o=n&&n.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter((function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===X.CLASS_TO_CLASS||e===X.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===X.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===X.CLASS_TO_CLASS||e===X.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===X.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,n=t.get(e);n&&(r=Array.from(n.values()).filter((function(t){return void 0!==t.propertyName})));for(var o=[],a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var l=Array.from(c.values()).filter((function(t){return void 0!==t.propertyName}));o.push.apply(o,l)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var n=t.get(e);if(n){var o=n.get(r);if(o)return o}for(var a=0,i=this.getAncestors(e);a<i.length;a++){var s=i[a],c=t.get(s);if(c){var l=c.get(r);if(l)return l}}},t.prototype.findMetadatas=function(t,e,r){var n,o=t.get(e);o&&(n=o.get(r));for(var a=[],i=0,s=this.getAncestors(e);i<s.length;i++){var c=s[i],l=t.get(c);l&&l.has(r)&&a.push.apply(a,l.get(r))}return a.slice().reverse().concat((n||[]).slice().reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),tt=new Z;var et=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var rt=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,r,n,o,a){var i,s=this;if(void 0===a&&(a=0),Array.isArray(e)||e instanceof Set){var c=n&&this.transformationType===X.PLAIN_TO_CLASS?function(t){var e=new t;return e instanceof Set||"push"in e?e:[]}(n):[];return e.forEach((function(e,n){var o=t?t[n]:void 0;if(s.options.enableCircularCheck&&s.isCircular(e))s.transformationType===X.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var i=void 0;if("function"!=typeof r&&r&&r.options&&r.options.discriminator&&r.options.discriminator.property&&r.options.discriminator.subTypes){if(s.transformationType===X.PLAIN_TO_CLASS){i=r.options.discriminator.subTypes.find((function(t){return t.name===e[r.options.discriminator.property]}));var l={newObject:c,object:e,property:void 0},u=r.typeFunction(l);i=void 0===i?u:i.value,r.options.keepDiscriminatorProperty||delete e[r.options.discriminator.property]}s.transformationType===X.CLASS_TO_CLASS&&(i=e.constructor),s.transformationType===X.CLASS_TO_PLAIN&&(e[r.options.discriminator.property]=r.options.discriminator.subTypes.find((function(t){return t.value===e.constructor})).name)}else i=r;var p=s.transform(o,e,i,void 0,e instanceof Map,a+1);c instanceof Set?c.add(p):c.push(p)}})),c}if(r!==String||o){if(r!==Number||o){if(r!==Boolean||o){if((r===Date||e instanceof Date)&&!o)return e instanceof Date?new Date(e.valueOf()):null==e?e:new Date(e);if(("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0).Buffer&&(r===Buffer||e instanceof Buffer)&&!o)return null==e?e:Buffer.from(e);if(null===(i=e)||"object"!=typeof i||"function"!=typeof i.then||o){if(o||null===e||"object"!=typeof e||"function"!=typeof e.then){if("object"==typeof e&&null!==e){r||e.constructor===Object||(Array.isArray(e)||e.constructor!==Array)&&(r=e.constructor),!r&&t&&(r=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var l=this.getKeys(r,e,o),u=t||{};t||this.transformationType!==X.PLAIN_TO_CLASS&&this.transformationType!==X.CLASS_TO_CLASS||(u=o?new Map:r?new r:{});for(var p=function(n){if("__proto__"===n||"constructor"===n)return"continue";var i=n,s=n,c=n;if(!f.options.ignoreDecorators&&r)if(f.transformationType===X.PLAIN_TO_CLASS)(l=tt.findExposeMetadataByCustomName(r,n))&&(c=l.propertyName,s=l.propertyName);else if(f.transformationType===X.CLASS_TO_PLAIN||f.transformationType===X.CLASS_TO_CLASS){var l;(l=tt.findExposeMetadata(r,n))&&l.options&&l.options.name&&(s=l.options.name)}var p=void 0;p=f.transformationType===X.PLAIN_TO_CLASS?e[i]:e instanceof Map?e.get(i):e[i]instanceof Function?e[i]():e[i];var d=void 0,h=p instanceof Map;if(r&&o)d=r;else if(r){var y=tt.findTypeMetadata(r,c);if(y){var m={newObject:u,object:e,property:c},v=y.typeFunction?y.typeFunction(m):y.reflectedType;y.options&&y.options.discriminator&&y.options.discriminator.property&&y.options.discriminator.subTypes?e[i]instanceof Array?d=y:(f.transformationType===X.PLAIN_TO_CLASS&&(d=void 0===(d=y.options.discriminator.subTypes.find((function(t){if(p&&p instanceof Object&&y.options.discriminator.property in p)return t.name===p[y.options.discriminator.property]})))?v:d.value,y.options.keepDiscriminatorProperty||p&&p instanceof Object&&y.options.discriminator.property in p&&delete p[y.options.discriminator.property]),f.transformationType===X.CLASS_TO_CLASS&&(d=p.constructor),f.transformationType===X.CLASS_TO_PLAIN&&p&&(p[y.options.discriminator.property]=y.options.discriminator.subTypes.find((function(t){return t.value===p.constructor})).name)):d=v,h=h||y.reflectedType===Map}else if(f.options.targetMaps)f.options.targetMaps.filter((function(t){return t.target===r&&!!t.properties[c]})).forEach((function(t){return d=t.properties[c]}));else if(f.options.enableImplicitConversion&&f.transformationType===X.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",r.prototype,c);g&&(d=g)}}var E=Array.isArray(e[i])?f.getReflectedType(r,c):void 0,b=t?t[i]:void 0;if(u.constructor.prototype){var w=Object.getOwnPropertyDescriptor(u.constructor.prototype,s);if((f.transformationType===X.PLAIN_TO_CLASS||f.transformationType===X.CLASS_TO_CLASS)&&(w&&!w.set||u[s]instanceof Function))return"continue"}if(f.options.enableCircularCheck&&f.isCircular(p)){if(f.transformationType===X.CLASS_TO_CLASS){O=p;(void 0!==(O=f.applyCustomTransformations(O,r,n,e,f.transformationType))||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,O):u[s]=O)}}else{var _=f.transformationType===X.PLAIN_TO_CLASS?s:n,O=void 0;f.transformationType===X.CLASS_TO_PLAIN?(O=e[_],O=f.applyCustomTransformations(O,r,_,e,f.transformationType),O=e[_]===O?p:O,O=f.transform(b,O,d,E,h,a+1)):void 0===p&&f.options.exposeDefaultValues?O=u[s]:(O=f.transform(b,p,d,E,h,a+1),O=f.applyCustomTransformations(O,r,_,e,f.transformationType)),(void 0!==O||f.options.exposeUnsetFields)&&(u instanceof Map?u.set(s,O):u[s]=O)}},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,n){e.then((function(e){return t(s.transform(void 0,e,r,void 0,void 0,a+1))}),n)}))}return null==e?e:Boolean(e)}return null==e?e:Number(e)}return null==e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,r,n,o){var a=this,i=tt.findTransformMetadatas(e,r,this.transformationType);return void 0!==this.options.version&&(i=i.filter((function(t){return!t.options||a.checkVersion(t.options.since,t.options.until)}))),(i=this.options.groups&&this.options.groups.length?i.filter((function(t){return!t.options||a.checkGroups(t.options.groups)})):i.filter((function(t){return!t.options||!t.options.groups||!t.options.groups.length}))).forEach((function(e){t=e.transformFn({value:t,key:r,obj:n,type:o,options:a.options})})),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=tt.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e,r){var n=this,o=tt.getStrategy(t);"none"===o&&(o=this.options.strategy||"exposeAll");var a=[];if(("exposeAll"===o||r)&&(a=e instanceof Map?Array.from(e.keys()):Object.keys(e)),r)return a;if(this.options.ignoreDecorators&&this.options.excludeExtraneousValues&&t){var i=tt.getExposedProperties(t,this.transformationType),s=tt.getExcludedProperties(t,this.transformationType);a=et(et([],i,!0),s,!0)}if(!this.options.ignoreDecorators&&t){i=tt.getExposedProperties(t,this.transformationType);this.transformationType===X.PLAIN_TO_CLASS&&(i=i.map((function(e){var r=tt.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e}))),a=this.options.excludeExtraneousValues?i:a.concat(i);var c=tt.getExcludedProperties(t,this.transformationType);c.length>0&&(a=a.filter((function(t){return!c.includes(t)}))),void 0!==this.options.version&&(a=a.filter((function(e){var r=tt.findExposeMetadata(t,e);return!r||!r.options||n.checkVersion(r.options.since,r.options.until)}))),a=this.options.groups&&this.options.groups.length?a.filter((function(e){var r=tt.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)})):a.filter((function(e){var r=tt.findExposeMetadata(t,e);return!(r&&r.options&&r.options.groups&&r.options.groups.length)}))}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(a=a.filter((function(t){return n.options.excludePrefixes.every((function(e){return t.substr(0,e.length)!==e}))}))),a=a.filter((function(t,e,r){return r.indexOf(t)===e}))},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some((function(e){return t.includes(e)}))},t}(),nt={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},ot=function(){return ot=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ot.apply(this,arguments)},at=new(function(){function t(){}return t.prototype.instanceToPlain=function(t,e){return new rt(X.CLASS_TO_PLAIN,ot(ot({},nt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new rt(X.CLASS_TO_PLAIN,ot(ot({},nt),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToInstance=function(t,e,r){return new rt(X.PLAIN_TO_CLASS,ot(ot({},nt),r)).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new rt(X.PLAIN_TO_CLASS,ot(ot({},nt),r)).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.instanceToInstance=function(t,e){return new rt(X.CLASS_TO_CLASS,ot(ot({},nt),e)).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new rt(X.CLASS_TO_CLASS,ot(ot({},nt),r)).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.instanceToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t.prototype.deserializeArray=function(t,e,r){var n=JSON.parse(e);return this.plainToInstance(t,n,r)},t}());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)},st=function(){function t(){}return t.prototype.transform=function(t){var e=[];return Object.keys(t.properties).forEach((function(r){t.properties[r].forEach((function(n){var o={message:n.message,groups:n.groups,always:n.always,each:n.each},a={type:n.type,name:n.name,target:t.name,propertyName:r,constraints:n.constraints,validationTypeOptions:n.options,validationOptions:o};e.push(new it(a))}))})),e},t}();function ct(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function lt(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var ut=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},pt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},ft=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},dt=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 st).transform(t).forEach((function(t){return e.addValidationMetadata(t)}))},t.prototype.addValidationMetadata=function(t){var e=this.validationMetadatas.get(t.target);e?e.push(t):this.validationMetadatas.set(t.target,[t])},t.prototype.addConstraintMetadata=function(t){var e=this.constraintMetadatas.get(t.target);e?e.push(t):this.constraintMetadatas.set(t.target,[t])},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach((function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)})),e},t.prototype.getTargetValidationMetadatas=function(t,e,r,n,o){var a,i,s=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&r},c=function(t){return!(!n||o&&o.length||!t.groups||!t.groups.length)},l=(this.validationMetadatas.get(t)||[]).filter((function(r){return(r.target===t||r.target===e)&&(!!s(r)||!c(r)&&(!(o&&o.length>0)||r.groups&&!!r.groups.find((function(t){return-1!==o.indexOf(t)}))))})),u=[];try{for(var p=ut(this.validationMetadatas.entries()),f=p.next();!f.done;f=p.next()){var d=pt(f.value,2),h=d[0],y=d[1];t.prototype instanceof h&&u.push.apply(u,ft([],pt(y),!1))}}catch(t){a={error:t}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}var m=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)&&(!(o&&o.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==o.indexOf(t)}))))))})).filter((function(t){return!l.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return l.concat(m)},t.prototype.getTargetValidatorConstraints=function(t){return this.constraintMetadatas.get(t)||[]},t}();var ht=function(){function t(){}return t.prototype.toString=function(t,e,r,n){var o=this;void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===r&&(r=""),void 0===n&&(n=!1);var a=t?"":"",i=t?"":"",s=function(t){return" - property ".concat(a).concat(r).concat(t).concat(i," has failed the following constraints: ").concat(a).concat((n?Object.values:Object.keys)(null!==(e=o.constraints)&&void 0!==e?e:{}).join(", ")).concat(i," \n");var e};if(e){var c=Number.isInteger(+this.property)?"[".concat(this.property,"]"):"".concat(r?".":"").concat(this.property);return this.constraints?s(c):this.children?this.children.map((function(e){return e.toString(t,!0,"".concat(r).concat(c),n)})).join(""):""}return"An instance of ".concat(a).concat(this.target?this.target.constructor.name:"an object").concat(i," has failed the validation:\n")+(this.constraints?s(this.property):"")+(this.children?this.children.map((function(e){return e.toString(t,!0,o.property,n)})).join(""):"")},t}(),yt=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 mt=function(){function t(){}return t.replaceMessageSpecialTokens=function(t,e){var r;return t instanceof Function?r=t(e):"string"==typeof t&&(r=t),r&&Array.isArray(e.constraints)&&e.constraints.forEach((function(t,e){r=r.replace(new RegExp("\\$constraint".concat(e+1),"g"),function(t){return Array.isArray(t)?t.join(", "):("symbol"==typeof t&&(t=t.description),"".concat(t))}(t))})),r&&void 0!==e.value&&null!==e.value&&["string","boolean","number"].includes(typeof e.value)&&(r=r.replace(/\$value/g,e.value)),r&&(r=r.replace(/\$property/g,e.property)),r&&(r=r.replace(/\$target/g,e.targetName)),r},t}(),vt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},gt=function(){function t(t,e){this.validator=t,this.validatorOptions=e,this.awaitingPromises=[],this.ignoreAsyncValidations=!1,this.metadataStorage=function(){var t=ct();return t.classValidatorMetadataStorage||(t.classValidatorMetadataStorage=new dt),t.classValidatorMetadataStorage}()}return t.prototype.execute=function(t,e,r){var n,o,a=this;this.metadataStorage.hasValidationMetaData||!0!==(null===(n=this.validatorOptions)||void 0===n?void 0:n.enableDebugMessages)||console.warn("No validation metadata found. No validation will be performed. There are multiple possible reasons:\n - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n - This validation runs before any file with validation decorator was parsed by NodeJS.");var i=this.validatorOptions?this.validatorOptions.groups:void 0,s=this.validatorOptions&&this.validatorOptions.strictGroups||!1,c=this.validatorOptions&&this.validatorOptions.always||!1,l=void 0===(null===(o=this.validatorOptions)||void 0===o?void 0:o.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 ht;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(f.target=t),f.value=void 0,f.property=void 0,f.children=[],f.constraints={unknownValue:"an unknown value was passed to the validate function"},void r.push(f)}this.validatorOptions&&this.validatorOptions.whitelist&&this.whitelist(t,p,r),Object.keys(p).forEach((function(e){var n=t[e],o=p[e].filter((function(t){return t.type===yt.IS_DEFINED})),i=p[e].filter((function(t){return t.type!==yt.IS_DEFINED&&t.type!==yt.WHITELIST}));n instanceof Promise&&i.find((function(t){return t.type===yt.PROMISE_VALIDATION}))?a.awaitingPromises.push(n.then((function(n){a.performValidations(t,n,e,o,i,r)}))):a.performValidations(t,n,e,o,i,r)}))},t.prototype.whitelist=function(t,e,r){var n=this,o=[];Object.keys(t).forEach((function(t){e[t]&&0!==e[t].length||o.push(t)})),o.length>0&&(this.validatorOptions&&this.validatorOptions.forbidNonWhitelisted?o.forEach((function(e){var o,a=n.generateValidationError(t,t[e],e);a.constraints=((o={})[yt.WHITELIST]="property ".concat(e," should not exist"),o),a.children=void 0,r.push(a)})):o.forEach((function(e){return delete t[e]})))},t.prototype.stripEmptyErrors=function(t){var e=this;return t.filter((function(t){if(t.children&&(t.children=e.stripEmptyErrors(t.children)),0===Object.keys(t.constraints).length){if(0===t.children.length)return!1;delete t.constraints}return!0}))},t.prototype.performValidations=function(t,e,r,n,o,a){var i=o.filter((function(t){return t.type===yt.CUSTOM_VALIDATION})),s=o.filter((function(t){return t.type===yt.NESTED_VALIDATION})),c=o.filter((function(t){return t.type===yt.CONDITIONAL_VALIDATION})),l=this.generateValidationError(t,e,r);a.push(l),this.conditionalValidations(t,e,c)&&(this.customValidations(t,e,n,l),this.mapContexts(t,e,n,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,o,l),this.mapContexts(t,e,i,l)))},t.prototype.generateValidationError=function(t,e,r){var n=new ht;return this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.target&&!0!==this.validatorOptions.validationError.target||(n.target=t),this.validatorOptions&&this.validatorOptions.validationError&&void 0!==this.validatorOptions.validationError.value&&!0!==this.validatorOptions.validationError.value||(n.value=e),n.property=r,n.children=[],n.constraints={},n},t.prototype.conditionalValidations=function(t,e,r){return r.map((function(r){return r.constraints[0](t,e)})).reduce((function(t,e){return t&&e}),!0)},t.prototype.customValidations=function(t,e,r,n){var o=this;r.forEach((function(r){o.metadataStorage.getTargetValidatorConstraints(r.constraintCls).forEach((function(a){if(!(a.async&&o.ignoreAsyncValidations||o.validatorOptions&&o.validatorOptions.stopAtFirstError&&Object.keys(n.constraints||{}).length>0)){var i={targetName:t.constructor?t.constructor.name:void 0,property:r.propertyName,object:t,value:e,constraints:r.constraints};if(r.each&&(Array.isArray(e)||e instanceof Set||e instanceof Map)){var s,c=((s=e)instanceof Map?Array.from(s.values()):Array.isArray(s)?s:Array.from(s)).map((function(t){return a.instance.validate(t,i)}));if(c.some((function(t){return lt(t)}))){var l=c.map((function(t){return lt(t)?t:Promise.resolve(t)})),u=Promise.all(l).then((function(i){if(!i.every((function(t){return t}))){var s=vt(o.createValidationError(t,e,r,a),2),c=s[0],l=s[1];n.constraints[c]=l,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(u)}else{if(!c.every((function(t){return t}))){var p=vt(o.createValidationError(t,e,r,a),2);y=p[0],m=p[1];n.constraints[y]=m}}}else{var f=a.instance.validate(e,i);if(lt(f)){var d=f.then((function(i){if(!i){var s=vt(o.createValidationError(t,e,r,a),2),c=s[0],l=s[1];n.constraints[c]=l,r.context&&(n.contexts||(n.contexts={}),n.contexts[c]=Object.assign(n.contexts[c]||{},r.context))}}));o.awaitingPromises.push(d)}else if(!f){var h=vt(o.createValidationError(t,e,r,a),2),y=h[0],m=h[1];n.constraints[y]=m}}}}))}))},t.prototype.nestedValidations=function(t,e,r){var n=this;void 0!==t&&e.forEach((function(o){if((o.type===yt.NESTED_VALIDATION||o.type===yt.PROMISE_VALIDATION)&&!(n.validatorOptions&&n.validatorOptions.stopAtFirstError&&Object.keys(r.constraints||{}).length>0))if(Array.isArray(t)||t instanceof Set||t instanceof Map)(t instanceof Set?Array.from(t):t).forEach((function(o,a){n.performValidations(t,o,a.toString(),[],e,r.children)}));else if(t instanceof Object){var a="string"==typeof o.target?o.target:o.target.name;n.execute(t,a,r.children)}else{var i=vt(n.createValidationError(o.target,t,o),2),s=i[0],c=i[1];r.constraints[s]=c}}))},t.prototype.mapContexts=function(t,e,r,n){var o=this;return r.forEach((function(t){if(t.context){var e=void 0;if(t.type===yt.CUSTOM_VALIDATION)e=o.metadataStorage.getTargetValidatorConstraints(t.constraintCls)[0];var r=o.getConstraintType(t,e);n.constraints[r]&&(n.contexts||(n.contexts={}),n.contexts[r]=Object.assign(n.contexts[r]||{},t.context))}}))},t.prototype.createValidationError=function(t,e,r,n){var o=t.constructor?t.constructor.name:void 0,a=this.getConstraintType(r,n),i={targetName:o,property:r.propertyName,object:t,value:e,constraints:r.constraints},s=r.message||"";return r.message||this.validatorOptions&&(!this.validatorOptions||this.validatorOptions.dismissDefaultMessages)||n&&n.instance.defaultMessage instanceof Function&&(s=n.instance.defaultMessage(i)),[a,mt.replaceMessageSpecialTokens(s,i)]},t.prototype.getConstraintType=function(t,e){return e&&e.name?e.name:t.type},t}(),Et=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{c(n.next(t))}catch(t){a(t)}}function s(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,s)}c((n=n.apply(t,e||[])).next())}))},bt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},wt=function(){function t(){}return t.prototype.validate=function(t,e,r){return this.coreValidate(t,e,r)},t.prototype.validateOrReject=function(t,e,r){return Et(this,void 0,void 0,(function(){var n;return bt(this,(function(o){switch(o.label){case 0:return[4,this.coreValidate(t,e,r)];case 1:return(n=o.sent()).length?[2,Promise.reject(n)]:[2]}}))}))},t.prototype.validateSync=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new gt(this,"string"==typeof t?r:e);a.ignoreAsyncValidations=!0;var i=[];return a.execute(n,o,i),a.stripEmptyErrors(i)},t.prototype.coreValidate=function(t,e,r){var n="string"==typeof t?e:t,o="string"==typeof t?t:void 0,a=new gt(this,"string"==typeof t?r:e),i=[];return a.execute(n,o,i),Promise.all(a.awaitingPromises).then((function(){return a.stripEmptyErrors(i)}))},t}(),_t=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 Ot(t){return _t.get(t)}function St(t,e,r){return"string"==typeof t?Ot(wt).validate(t,e,r):Ot(wt).validate(t,e)}function Mt(t,e,r){return"string"==typeof t?Ot(wt).validateSync(t,e,r):Ot(wt).validateSync(t,e)}function Tt(t,e,r,n){return void 0===r&&(r={}),void 0===n&&(n=""),t.reduce((function(t,r){var o=n?n+"."+r.property:r.property;if(r.constraints){var a=Object.keys(r.constraints)[0];t[o]={type:a,message:r.constraints[a]};var i=t[o];e&&i&&Object.assign(i,{types:r.constraints})}return r.children&&r.children.length&&Tt(r.children,e,t,o),t}),r)}function At(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),function(n,o,a){try{var i=e.validator,s=(c=t,l=n,u=e.transformer,at.plainToInstance(c,l,u));return Promise.resolve(("sync"===r.mode?Mt:St)(s,i)).then((function(t){return t.length?{values:{},errors:J(Tt(t,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&q({},a),{values:r.raw?Object.assign({},n):s,errors:{}})}))}catch(t){return Promise.reject(t)}var c,l,u}}function xt({model:e,getDetailsData:n,onSubmit:o,redirect:a,...i}){const s=r((()=>{return{resolver:At(t=e),form:W(t),inputs:H(t)};var t}),[e]);return t.createElement(B,{getDetailsData:n,redirect:a,onSubmit:o,formOptions:s})}const Nt=v()(y((t=>({screens:null,user:null,screenPaths:{}})),{name:"app-store-1",storage:m((()=>localStorage)),partialize:t=>({user:t.user})}),g);function Ct({onLogin:e}){const{register:r,handleSubmit:n,formState:{errors:o}}=p(),a=c();return t.createElement("div",{className:"login-container"},t.createElement("div",{className:"login-panel"},t.createElement("div",{className:"login-header"},t.createElement("h1",null,"Welcome Back"),t.createElement("p",null,"Please sign in to continue")),t.createElement("form",{onSubmit:n((async t=>{e.login(t.username,t.password).then((t=>{const{user:e,token:r}=t;localStorage.setItem("token",r),Nt.setState({user:e}),a("/")}))})),className:"login-form"},t.createElement(F,{input:{name:"username",label:"Username",placeholder:"Enter your username",type:"input"},register:r,error:o.username}),t.createElement(F,{input:{name:"password",label:"Password",inputType:"password",placeholder:"Enter your password",type:"input"},register:r,error:o.password}),t.createElement("div",{className:"form-actions"},t.createElement("button",{type:"submit",className:"submit-button"},"Sign In")))))}function kt({menu:r,getIcons:n,onLogout:o}){const{screens:a,screenPaths:s}=Nt((t=>({screens:t.screens??{},screenPaths:t.screenPaths??{}}))),[u,p]=e(!0),f=l(),d=c(),h=t=>{if("/"===t)return f.pathname===t;const e=t.replace(/^\/+|\/+$/g,""),r=f.pathname.replace(/^\/+|\/+$/g,"");return r===e||r.startsWith(`${e}/`)};return t.createElement("div",{className:"sidebar "+(u?"open":"closed")},t.createElement("button",{className:"toggle-button",onClick:()=>p(!u),"aria-label":u?"Collapse sidebar":"Expand sidebar","aria-expanded":u},u?"<":">"),t.createElement("nav",{className:"nav-links"},r?.(a).map(((e,r)=>t.createElement(i,{key:r,to:e.path,className:"nav-link "+(h(e.path)?"active":""),"aria-current":h(e.path)?"page":void 0},t.createElement("span",{className:"nav-links-icon"},n?.(e.iconType)),u?t.createElement("span",null,e.name):null)))),o&&t.createElement("div",{className:"sidebar-footer"},t.createElement("button",{className:"logout-button",onClick:()=>{o&&(o(),d(s.login))},"aria-label":"Logout"},t.createElement("span",{className:"nav-links-icon"},t.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t.createElement("path",{d:"M6 12H2V4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M10 8L14 4M14 4L10 0M14 4H6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))),u?t.createElement("span",null,"Logout"):null)))}function Lt({children:e,menu:r,getIcons:n,logout:o}){const{user:a,screenPaths:i}=Nt((t=>({user:t.user,screenPaths:t.screenPaths})));Nt();const s=c();return a||s(i.login),t.createElement("div",{className:"layout"},t.createElement(kt,{onLogout:()=>{o&&o()},menu:r,getIcons:n}),t.createElement("main",{className:"content"},e))}function Pt({children:e,init:r}){return o((()=>{!function({screenPaths:t}){Nt.setState({screenPaths:t})}(r())}),[r]),t.createElement(z,null,e)}function It(t){return N({...t,type:"image"})}function Vt(t){return e=>{t&&Reflect.defineMetadata("Crud",t,e)}}export{N as Cell,$ as Counter,Vt as Crud,xt as FormPage,It as ImageCell,K as Input,Lt as Layout,T as List,L as ListPage,Ct as Login,Pt as Panel};
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?"":"",i=t?"":"",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 "../decorators/list/Cell";
2
- import { CrudOptions } from "../decorators/Crud";
3
- import { InputOptions } from "../decorators/form/Input";
4
- import { ListOptions } from "../decorators/list/List";
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
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "proje-react-panel",
3
- "version": "1.0.15",
3
+ "version": "1.0.17-test1",
4
+ "type": "module",
4
5
  "description": "",
5
6
  "author": "SEFA DEMİR",
6
7
  "license": "ISC",
@@ -10,8 +11,9 @@
10
11
  "types": "dist/index.d.ts",
11
12
  "scripts": {
12
13
  "test": "echo \"Error: no test specified\" && exit 1",
13
- "build": "rollup -c ",
14
- "lint": "eslint src --ext .ts,.tsx"
14
+ "build": "rollup -c",
15
+ "lint": "eslint src --ext .ts,.tsx",
16
+ "generate-font": "node src/scripts/svg-to-font.js"
15
17
  },
16
18
  "repository": {
17
19
  "type": "git",
@@ -27,6 +29,7 @@
27
29
  "@hookform/resolvers": "^4.1.3",
28
30
  "@rollup/plugin-commonjs": "^28.0.3",
29
31
  "@rollup/plugin-node-resolve": "^16.0.1",
32
+ "@svgr/rollup": "^8.1.0",
30
33
  "@types/react": "^19.0.10",
31
34
  "@typescript-eslint/eslint-plugin": "^8.26.1",
32
35
  "@typescript-eslint/parser": "^8.29.1",
@@ -39,12 +42,14 @@
39
42
  "react": "^19.0.0",
40
43
  "react-hook-form": "^7.54.2",
41
44
  "react-router": "^7.3.0",
45
+ "react-select": "^5.10.1",
42
46
  "reflect-metadata": "^0.2.2",
43
47
  "rollup": "^4.35.0",
44
48
  "rollup-plugin-peer-deps-external": "^2.2.4",
45
49
  "rollup-plugin-serve": "^3.0.0",
46
50
  "rollup-plugin-terser": "^7.0.2",
47
51
  "rollup-plugin-typescript2": "^0.36.0",
52
+ "svgicons2svgfont": "^15.0.1",
48
53
  "typescript": "^5.8.3",
49
54
  "use-sync-external-store": "^1.4.0",
50
55
  "zustand": "^5.0.3"
@@ -53,6 +58,7 @@
53
58
  "react": ">=19.0.0",
54
59
  "react-hook-form": ">=7.54.2",
55
60
  "react-router": "7.3.0",
61
+ "react-select": "^5.10.1",
56
62
  "use-sync-external-store": ">=1.4.0",
57
63
  "zustand": ">=5.0.3"
58
64
  }
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
4
+
5
+
6
+
7
+
8
+
9
+
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" preserveAspectRatio="xMidYMid meet">
2
+ <polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/>
3
+ </svg>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
4
+
5
+
6
+
7
+
8
+
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
4
+
5
+
6
+
7
+
8
+
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
4
+
5
+
6
+
7
+
8
+
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { InputOptions } from '../../decorators/form/Input';
3
3
  import { Label } from './Label';
4
- import { UseFormRegister } from 'react-hook-form';
4
+ import { useFormContext, UseFormRegister } from 'react-hook-form';
5
5
  import { ImageUploader } from './ImageUploader';
6
6
  import { Checkbox } from './Checkbox';
7
7
 
@@ -9,11 +9,43 @@ interface FormFieldProps {
9
9
  input: InputOptions;
10
10
  register: UseFormRegister<any>;
11
11
  error?: { message?: string };
12
+ baseName?: string;
12
13
  }
13
14
 
14
- export function FormField({ input, register, error }: FormFieldProps) {
15
- const fieldName = input.name || '';
15
+ interface NestedFormFieldsProps {
16
+ input: InputOptions;
17
+ register: UseFormRegister<any>;
18
+ }
19
+
20
+ function NestedFormFields({ input, register }: NestedFormFieldsProps) {
21
+ const form = useFormContext();
22
+ //TODO: inputOptions İnputResult seperate
23
+ const data = form.getValues(input.name!);
24
+ return (
25
+ <div>
26
+ {data?.map((value: any, index: number) => (
27
+ <div key={index}>
28
+ {input.nestedFields?.map((nestedInput: InputOptions) => (
29
+ <FormField
30
+ key={nestedInput.name?.toString() ?? ''}
31
+ baseName={input.name + '[' + index + ']'}
32
+ input={nestedInput}
33
+ register={register}
34
+ error={
35
+ input.name
36
+ ? { message: (form.formState.errors[input.name] as any)?.message }
37
+ : undefined
38
+ }
39
+ />
40
+ ))}
41
+ </div>
42
+ ))}
43
+ </div>
44
+ );
45
+ }
16
46
 
47
+ export function FormField({ input, register, error, baseName }: FormFieldProps) {
48
+ const fieldName = (baseName ? baseName.toString() + '.' : '') + input.name || '';
17
49
  const renderField = () => {
18
50
  switch (input.type) {
19
51
  case 'textarea':
@@ -22,14 +54,14 @@ export function FormField({ input, register, error }: FormFieldProps) {
22
54
  return (
23
55
  <select {...register(fieldName)} id={fieldName}>
24
56
  <option value="">Select {fieldName}</option>
25
- {input.selectOptions?.map(option => (
26
- <option key={option} value={option}>
27
- {option}
57
+ {input.options?.map(option => (
58
+ <option key={option.value} value={option.value}>
59
+ {option.label}
28
60
  </option>
29
61
  ))}
30
62
  </select>
31
63
  );
32
- case 'input': {
64
+ case 'input': {
33
65
  return (
34
66
  <input
35
67
  type={input.inputType}
@@ -45,6 +77,8 @@ export function FormField({ input, register, error }: FormFieldProps) {
45
77
  return <Checkbox {...register(fieldName)} id={fieldName} />;
46
78
  case 'hidden':
47
79
  return <input type="hidden" {...register(fieldName)} id={fieldName} />;
80
+ case 'nested':
81
+ return <NestedFormFields input={input} register={register} />;
48
82
  default:
49
83
  null;
50
84
  }
@@ -5,35 +5,34 @@ import { FormField } from './FormField';
5
5
  import { FormOptions } from '../../decorators/form/FormOptions';
6
6
  import { AnyClass } from '../../types/AnyClass';
7
7
  import { OnSubmitFN, GetDetailsDataFN } from '../pages/FormPage';
8
- import { DefaultValues } from 'react-hook-form';
9
- import { useParams } from 'react-router';
8
+ import { useParams, useNavigate } from 'react-router';
10
9
 
11
10
  interface InnerFormProps<T extends AnyClass> {
12
11
  formOptions: FormOptions;
13
12
  onSubmit: OnSubmitFN<T>;
14
- redirect?: string;
15
13
  getDetailsData?: GetDetailsDataFN<T>;
14
+ redirectBackOnSuccess?: boolean;
16
15
  }
17
16
 
18
17
  export function InnerForm<T extends AnyClass>({
19
18
  formOptions,
20
19
  onSubmit,
21
- redirect,
22
20
  getDetailsData,
21
+ redirectBackOnSuccess,
23
22
  }: InnerFormProps<T>) {
24
23
  const params = useParams();
25
24
  const form = useForm<T>({
26
25
  resolver: formOptions.resolver,
27
26
  });
28
-
27
+ const navigate = useNavigate();
29
28
  const inputs = formOptions.inputs;
30
29
  useEffect(() => {
31
30
  if (getDetailsData) {
32
- getDetailsData(params.id as string).then(data => {
31
+ getDetailsData(params as Record<string, string>).then(data => {
33
32
  form.reset({ ...data });
34
33
  });
35
34
  }
36
- }, [, form.reset]);
35
+ }, [params, form.reset]);
37
36
 
38
37
  return (
39
38
  <div className="form-wrapper">
@@ -42,8 +41,8 @@ export function InnerForm<T extends AnyClass>({
42
41
  onSubmit={form.handleSubmit(
43
42
  async dataForm => {
44
43
  await onSubmit(dataForm);
45
- if (redirect) {
46
- window.location.href = redirect;
44
+ if (redirectBackOnSuccess) {
45
+ navigate(-1);
47
46
  }
48
47
  },
49
48
  (errors, event) => {