cotomy 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +28 -2
- package/dist/form.d.ts +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/page.d.ts +1 -0
- package/dist/view.d.ts +5 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
import { CotomyElement } from "./view";
|
|
2
|
+
export declare class CotomyRestApiException extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly response: CotomyRestApiResponse;
|
|
6
|
+
readonly bodyText: string;
|
|
7
|
+
constructor(status: number, message: string, response: CotomyRestApiResponse, bodyText?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class CotomyHttpClientError extends CotomyRestApiException {
|
|
10
|
+
constructor(status: number, message: string, response: CotomyRestApiResponse, body?: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class CotomyUnauthorizedException extends CotomyHttpClientError {
|
|
13
|
+
constructor(status: number, message: string, response: CotomyRestApiResponse, body?: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class CotomyForbiddenException extends CotomyHttpClientError {
|
|
16
|
+
constructor(status: number, message: string, response: CotomyRestApiResponse, body?: string);
|
|
17
|
+
}
|
|
18
|
+
export declare class CotomyNotFoundException extends CotomyHttpClientError {
|
|
19
|
+
constructor(status: number, message: string, response: CotomyRestApiResponse, body?: string);
|
|
20
|
+
}
|
|
21
|
+
export declare class CotomyConflictException extends CotomyHttpClientError {
|
|
22
|
+
constructor(status: number, message: string, response: CotomyRestApiResponse, body?: string);
|
|
23
|
+
}
|
|
24
|
+
export declare class CotomyValidationException extends CotomyHttpClientError {
|
|
25
|
+
constructor(status: number, message: string, response: CotomyRestApiResponse, body?: string);
|
|
26
|
+
}
|
|
27
|
+
export declare class CotomyHttpServerError extends CotomyRestApiException {
|
|
28
|
+
constructor(status: number, message: string, response: CotomyRestApiResponse, body?: string);
|
|
29
|
+
}
|
|
2
30
|
export declare class CotomyResponseJsonParseException extends Error {
|
|
3
31
|
constructor(message?: string);
|
|
4
32
|
}
|
|
@@ -44,7 +72,6 @@ export interface ICotomyRestApiOptions {
|
|
|
44
72
|
mode?: RequestMode | null;
|
|
45
73
|
keepalive?: boolean | null;
|
|
46
74
|
integrity?: string | null;
|
|
47
|
-
unauthorizedHandler?: ((response: CotomyRestApiResponse) => void) | null;
|
|
48
75
|
}
|
|
49
76
|
export interface ICotomyRestSubmitForm {
|
|
50
77
|
method: string;
|
|
@@ -65,7 +92,6 @@ export declare class CotomyRestApi {
|
|
|
65
92
|
get keepalive(): boolean;
|
|
66
93
|
get integrity(): string;
|
|
67
94
|
get abortController(): AbortController;
|
|
68
|
-
get unauthorizedHandler(): (response: CotomyRestApiResponse) => void;
|
|
69
95
|
private requestAsync;
|
|
70
96
|
getAsync(path: string, parameters?: globalThis.FormData | Record<string, string | number>): Promise<CotomyRestApiResponse>;
|
|
71
97
|
postAsync(path: string, body: globalThis.FormData | Record<string, string | number> | any): Promise<CotomyRestApiResponse>;
|
package/dist/form.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export declare abstract class CotomyForm extends CotomyElement {
|
|
|
15
15
|
get autoComplete(): boolean;
|
|
16
16
|
set autoComplete(value: boolean);
|
|
17
17
|
reload(): void;
|
|
18
|
+
get autoRestore(): boolean;
|
|
19
|
+
set autoRestore(value: boolean);
|
|
20
|
+
restore(): void;
|
|
18
21
|
get initialized(): boolean;
|
|
19
22
|
initialize(): this;
|
|
20
23
|
submit(): void;
|
|
@@ -30,8 +33,6 @@ export declare class CotomyQueryForm extends CotomyForm {
|
|
|
30
33
|
protected submitAsync(e: Event): Promise<void>;
|
|
31
34
|
}
|
|
32
35
|
export declare class CotomyApiForm extends CotomyForm {
|
|
33
|
-
private _apiClient;
|
|
34
|
-
private _unauthorizedHandler;
|
|
35
36
|
constructor(element: HTMLElement | {
|
|
36
37
|
html: string;
|
|
37
38
|
css?: string | null;
|
|
@@ -47,7 +48,6 @@ export declare class CotomyApiForm extends CotomyForm {
|
|
|
47
48
|
formData(): globalThis.FormData;
|
|
48
49
|
protected submitAsync(e: Event): Promise<void>;
|
|
49
50
|
protected submitToApiAsync(formData: globalThis.FormData): Promise<CotomyRestApiResponse>;
|
|
50
|
-
unauthorized(handle: (response: CotomyRestApiResponse) => void): this;
|
|
51
51
|
}
|
|
52
52
|
export declare class CotomyFillApiForm extends CotomyApiForm {
|
|
53
53
|
private _fillers;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CotomyInvalidFormDataBodyException, CotomyResponseJsonParseException, CotomyRestApi, CotomyRestApiResponse, CotomyViewRenderer } from "./api";
|
|
1
|
+
export { CotomyConflictException, CotomyForbiddenException, CotomyHttpClientError, CotomyHttpServerError, CotomyInvalidFormDataBodyException, CotomyNotFoundException, CotomyResponseJsonParseException, CotomyRestApi, CotomyRestApiException, CotomyRestApiResponse, CotomyUnauthorizedException, CotomyValidationException, CotomyViewRenderer } from "./api";
|
|
2
2
|
export { CotomyDebugFeature, CotomyDebugSettings } from "./debug";
|
|
3
3
|
export { CotomyActionEvent, CotomyApiForm, CotomyFillApiForm, CotomyForm, CotomyQueryForm } from "./form";
|
|
4
4
|
export { CotomyPageController, CotomyUrl } from "./page";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Cotomy=t():e.Cotomy=t()}(this,()=>(()=>{var e={48:e=>{var t,n="undefined"!=typeof window&&(window.crypto||window.msCrypto)||"undefined"!=typeof self&&self.crypto;if(n){var r=Math.pow(2,32)-1;t=function(){return Math.abs(n.getRandomValues(new Uint32Array(1))[0]/r)}}else t=Math.random;e.exports=t},146:(e,t,n)=>{var r=n(473),i="object"==typeof window?window:self,s=Object.keys(i).length,a=r(((navigator.mimeTypes?navigator.mimeTypes.length:0)+navigator.userAgent.length).toString(36)+s.toString(36),4);e.exports=function(){return a}},353:function(e){e.exports=function(){"use strict";var e=6e4,t=36e5,n="millisecond",r="second",i="minute",s="hour",a="day",o="week",l="month",u="quarter",c="year",h="date",d="Invalid Date",E=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},p=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},T={s:p,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+p(r,2,"0")+":"+p(i,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),s=n-i<0,a=t.clone().add(r+(s?-1:1),l);return+(-(r+(n-i)/(s?i-a:a-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:c,w:o,d:a,D:h,h:s,m:i,s:r,ms:n,Q:u}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},f="en",y={};y[f]=g;var A="$isDayjsObject",_=function(e){return e instanceof O||!(!e||!e[A])},R=function e(t,n,r){var i;if(!t)return f;if("string"==typeof t){var s=t.toLowerCase();y[s]&&(i=s),n&&(y[s]=n,i=s);var a=t.split("-");if(!i&&a.length>1)return e(a[0])}else{var o=t.name;y[o]=t,i=o}return!r&&i&&(f=i),i||!r&&f},S=function(e,t){if(_(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new O(n)},D=T;D.l=R,D.i=_,D.w=function(e,t){return S(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var O=function(){function g(e){this.$L=R(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[A]=!0}var p=g.prototype;return p.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(D.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(E);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(t)}(e),this.init()},p.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},p.$utils=function(){return D},p.isValid=function(){return!(this.$d.toString()===d)},p.isSame=function(e,t){var n=S(e);return this.startOf(t)<=n&&n<=this.endOf(t)},p.isAfter=function(e,t){return S(e)<this.startOf(t)},p.isBefore=function(e,t){return this.endOf(t)<S(e)},p.$g=function(e,t,n){return D.u(e)?this[t]:this.set(n,e)},p.unix=function(){return Math.floor(this.valueOf()/1e3)},p.valueOf=function(){return this.$d.getTime()},p.startOf=function(e,t){var n=this,u=!!D.u(t)||t,d=D.p(e),E=function(e,t){var r=D.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return u?r:r.endOf(a)},m=function(e,t){return D.w(n.toDate()[e].apply(n.toDate("s"),(u?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},g=this.$W,p=this.$M,T=this.$D,f="set"+(this.$u?"UTC":"");switch(d){case c:return u?E(1,0):E(31,11);case l:return u?E(1,p):E(0,p+1);case o:var y=this.$locale().weekStart||0,A=(g<y?g+7:g)-y;return E(u?T-A:T+(6-A),p);case a:case h:return m(f+"Hours",0);case s:return m(f+"Minutes",1);case i:return m(f+"Seconds",2);case r:return m(f+"Milliseconds",3);default:return this.clone()}},p.endOf=function(e){return this.startOf(e,!1)},p.$set=function(e,t){var o,u=D.p(e),d="set"+(this.$u?"UTC":""),E=(o={},o[a]=d+"Date",o[h]=d+"Date",o[l]=d+"Month",o[c]=d+"FullYear",o[s]=d+"Hours",o[i]=d+"Minutes",o[r]=d+"Seconds",o[n]=d+"Milliseconds",o)[u],m=u===a?this.$D+(t-this.$W):t;if(u===l||u===c){var g=this.clone().set(h,1);g.$d[E](m),g.init(),this.$d=g.set(h,Math.min(this.$D,g.daysInMonth())).$d}else E&&this.$d[E](m);return this.init(),this},p.set=function(e,t){return this.clone().$set(e,t)},p.get=function(e){return this[D.p(e)]()},p.add=function(n,u){var h,d=this;n=Number(n);var E=D.p(u),m=function(e){var t=S(d);return D.w(t.date(t.date()+Math.round(e*n)),d)};if(E===l)return this.set(l,this.$M+n);if(E===c)return this.set(c,this.$y+n);if(E===a)return m(1);if(E===o)return m(7);var g=(h={},h[i]=e,h[s]=t,h[r]=1e3,h)[E]||1,p=this.$d.getTime()+n*g;return D.w(p,this)},p.subtract=function(e,t){return this.add(-1*e,t)},p.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||d;var r=e||"YYYY-MM-DDTHH:mm:ssZ",i=D.z(this),s=this.$H,a=this.$m,o=this.$M,l=n.weekdays,u=n.months,c=n.meridiem,h=function(e,n,i,s){return e&&(e[n]||e(t,r))||i[n].slice(0,s)},E=function(e){return D.s(s%12||12,e,"0")},g=c||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(m,function(e,r){return r||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return D.s(t.$y,4,"0");case"M":return o+1;case"MM":return D.s(o+1,2,"0");case"MMM":return h(n.monthsShort,o,u,3);case"MMMM":return h(u,o);case"D":return t.$D;case"DD":return D.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return h(n.weekdaysMin,t.$W,l,2);case"ddd":return h(n.weekdaysShort,t.$W,l,3);case"dddd":return l[t.$W];case"H":return String(s);case"HH":return D.s(s,2,"0");case"h":return E(1);case"hh":return E(2);case"a":return g(s,a,!0);case"A":return g(s,a,!1);case"m":return String(a);case"mm":return D.s(a,2,"0");case"s":return String(t.$s);case"ss":return D.s(t.$s,2,"0");case"SSS":return D.s(t.$ms,3,"0");case"Z":return i}return null}(e)||i.replace(":","")})},p.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},p.diff=function(n,h,d){var E,m=this,g=D.p(h),p=S(n),T=(p.utcOffset()-this.utcOffset())*e,f=this-p,y=function(){return D.m(m,p)};switch(g){case c:E=y()/12;break;case l:E=y();break;case u:E=y()/3;break;case o:E=(f-T)/6048e5;break;case a:E=(f-T)/864e5;break;case s:E=f/t;break;case i:E=f/e;break;case r:E=f/1e3;break;default:E=f}return d?E:D.a(E)},p.daysInMonth=function(){return this.endOf(l).$D},p.$locale=function(){return y[this.$L]},p.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=R(e,t,!0);return r&&(n.$L=r),n},p.clone=function(){return D.w(this.$d,this)},p.toDate=function(){return new Date(this.valueOf())},p.toJSON=function(){return this.isValid()?this.toISOString():null},p.toISOString=function(){return this.$d.toISOString()},p.toString=function(){return this.$d.toUTCString()},g}(),v=O.prototype;return S.prototype=v,[["$ms",n],["$s",r],["$m",i],["$H",s],["$W",a],["$M",l],["$y",c],["$D",h]].forEach(function(e){v[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),S.extend=function(e,t){return e.$i||(e(t,O,S),e.$i=!0),S},S.locale=R,S.isDayjs=_,S.unix=function(e){return S(1e3*e)},S.en=y[f],S.Ls=y,S.p={},S}()},473:e=>{e.exports=function(e,t){var n="000000000"+e;return n.substr(n.length-t)}},584:(e,t,n)=>{var r=n(146),i=n(473),s=n(48),a=0,o=Math.pow(36,4);function l(){return i((s()*o|0).toString(36),4)}function u(){return a=a<o?a:0,++a-1}function c(){return"c"+(new Date).getTime().toString(36)+i(u().toString(36),4)+r()+(l()+l())}c.slug=function(){var e=(new Date).getTime().toString(36),t=u().toString(36).slice(-4),n=r().slice(0,1)+r().slice(-1),i=l().slice(-2);return e.slice(-2)+t+n+i},c.isCuid=function(e){return"string"==typeof e&&!!e.startsWith("c")},c.isSlug=function(e){if("string"!=typeof e)return!1;var t=e.length;return t>=7&&t<=10},c.fingerprint=r,e.exports=c},831:e=>{e.exports={AD:"EUR",AE:"AED",AF:"AFN",AG:"XCD",AI:"XCD",AL:"ALL",AM:"AMD",AO:"AOA",AQ:"EUR",AR:"ARS",AS:"USD",AT:"EUR",AU:"AUD",AW:"AWG",AX:"EUR",AZ:"AZN",BA:"BAM",BB:"BBD",BD:"BDT",BE:"EUR",BF:"XOF",BG:"BGN",BH:"BHD",BI:"BIF",BJ:"XOF",BL:"EUR",BM:"BMD",BN:"BND",BO:"BOB",BQ:"USD",BR:"BRL",BS:"BSD",BT:"BTN",BV:"NOK",BW:"BWP",BY:"BYN",BZ:"BZD",CA:"CAD",CC:"AUD",CD:"CDF",CF:"XAF",CG:"XAF",CH:"CHF",CI:"XOF",CK:"NZD",CL:"CLP",CM:"XAF",CN:"CNY",CO:"COP",CR:"CRC",CU:"CUP",CV:"CVE",CW:"ANG",CX:"AUD",CY:"EUR",CZ:"CZK",DE:"EUR",DJ:"DJF",DK:"DKK",DM:"XCD",DO:"DOP",DZ:"DZD",EC:"USD",EE:"EUR",EG:"EGP",EH:"MAD",ER:"ERN",ES:"EUR",ET:"ETB",FI:"EUR",FJ:"FJD",FK:"FKP",FM:"USD",FO:"DKK",FR:"EUR",GA:"XAF",GB:"GBP",GD:"XCD",GE:"GEL",GF:"EUR",GG:"GBP",GH:"GHS",GI:"GIP",GL:"DKK",GM:"GMD",GN:"GNF",GP:"EUR",GQ:"XAF",GR:"EUR",GS:"GBP",GT:"GTQ",GU:"USD",GW:"XOF",GY:"GYD",HK:"HKD",HM:"AUD",HN:"HNL",HR:"EUR",HT:"HTG",HU:"HUF",ID:"IDR",IE:"EUR",IL:"ILS",IM:"GBP",IN:"INR",IO:"USD",IQ:"IQD",IR:"IRR",IS:"ISK",IT:"EUR",JE:"GBP",JM:"JMD",JO:"JOD",JP:"JPY",KE:"KES",KG:"KGS",KH:"KHR",KI:"AUD",KM:"KMF",KN:"XCD",KP:"KPW",KR:"KRW",KW:"KWD",KY:"KYD",KZ:"KZT",LA:"LAK",LB:"LBP",LC:"XCD",LI:"CHF",LK:"LKR",LR:"LRD",LS:"LSL",LT:"EUR",LU:"EUR",LV:"EUR",LY:"LYD",MA:"MAD",MC:"EUR",MD:"MDL",ME:"EUR",MF:"EUR",MG:"MGA",MH:"USD",MK:"MKD",ML:"XOF",MM:"MMK",MN:"MNT",MO:"MOP",MP:"USD",MQ:"EUR",MR:"MRU",MS:"XCD",MT:"EUR",MU:"MUR",MV:"MVR",MW:"MWK",MX:"MXN",MY:"MYR",MZ:"MZN",NA:"NAD",NC:"XPF",NE:"XOF",NF:"AUD",NG:"NGN",NI:"NIO",NL:"EUR",NO:"NOK",NP:"NPR",NR:"AUD",NU:"NZD",NZ:"NZD",OM:"OMR",PA:"PAB",PE:"PEN",PF:"XPF",PG:"PGK",PH:"PHP",PK:"PKR",PL:"PLN",PM:"EUR",PN:"NZD",PR:"USD",PS:"ILS",PT:"EUR",PW:"USD",PY:"PYG",QA:"QAR",RE:"EUR",RO:"RON",RS:"RSD",RU:"RUB",RW:"RWF",SA:"SAR",SB:"SBD",SC:"SCR",SD:"SDG",SE:"SEK",SG:"SGD",SH:"SHP",SI:"EUR",SJ:"NOK",SK:"EUR",SL:"SLE",SM:"EUR",SN:"XOF",SO:"SOS",SR:"SRD",SS:"SSP",ST:"STN",SV:"SVC",SX:"ANG",SY:"SYP",SZ:"SZL",TC:"USD",TD:"XAF",TF:"EUR",TG:"XOF",TH:"THB",TJ:"TJS",TK:"NZD",TL:"USD",TM:"TMT",TN:"TND",TO:"TOP",TR:"TRY",TT:"TTD",TV:"AUD",TW:"TWD",TZ:"TZS",UA:"UAH",UG:"UGX",UM:"USD",US:"USD",UY:"UYU",UZ:"UZS",VA:"EUR",VC:"XCD",VE:"VED",VG:"USD",VI:"USD",VN:"VND",VU:"VUV",WF:"XPF",WS:"WST",YE:"YER",YT:"EUR",ZA:"ZAR",ZM:"ZMW",ZW:"ZWG"}},869:(e,t,n)=>{var r=n(831);t.getCurrency=function(e){var t,n,i=(t=e,n=t.split("_"),2==n.length||2==(n=t.split("-")).length?n.pop():t).toUpperCase();return i in r?r[i]:null},t.getLocales=function(e){e=e.toUpperCase();var t=[];for(var n in r)r[n]===e&&t.push(n);return t}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{CotomyActionEvent:()=>A,CotomyApiForm:()=>S,CotomyDebugFeature:()=>s,CotomyDebugSettings:()=>o,CotomyElement:()=>c,CotomyFillApiForm:()=>D,CotomyForm:()=>_,CotomyInvalidFormDataBodyException:()=>m,CotomyMetaElement:()=>h,CotomyPageController:()=>v,CotomyQueryForm:()=>R,CotomyResponseJsonParseException:()=>E,CotomyRestApi:()=>y,CotomyRestApiResponse:()=>T,CotomyUrl:()=>O,CotomyViewRenderer:()=>f,CotomyWindow:()=>d});var e,t=n(353),i=n.n(t);!function(e){e[e.CONTINUE=100]="CONTINUE",e[e.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",e[e.PROCESSING=102]="PROCESSING",e[e.EARLY_HINTS=103]="EARLY_HINTS",e[e.OK=200]="OK",e[e.CREATED=201]="CREATED",e[e.ACCEPTED=202]="ACCEPTED",e[e.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",e[e.NO_CONTENT=204]="NO_CONTENT",e[e.RESET_CONTENT=205]="RESET_CONTENT",e[e.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",e[e.MULTI_STATUS=207]="MULTI_STATUS",e[e.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",e[e.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",e[e.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",e[e.SEE_OTHER=303]="SEE_OTHER",e[e.NOT_MODIFIED=304]="NOT_MODIFIED",e[e.USE_PROXY=305]="USE_PROXY",e[e.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",e[e.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",e[e.BAD_REQUEST=400]="BAD_REQUEST",e[e.UNAUTHORIZED=401]="UNAUTHORIZED",e[e.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",e[e.FORBIDDEN=403]="FORBIDDEN",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",e[e.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",e[e.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",e[e.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",e[e.CONFLICT=409]="CONFLICT",e[e.GONE=410]="GONE",e[e.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",e[e.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",e[e.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",e[e.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",e[e.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",e[e.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",e[e.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",e[e.IM_A_TEAPOT=418]="IM_A_TEAPOT",e[e.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",e[e.METHOD_FAILURE=420]="METHOD_FAILURE",e[e.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",e[e.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",e[e.LOCKED=423]="LOCKED",e[e.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",e[e.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",e[e.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",e[e.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",e[e.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",e[e.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",e[e.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",e[e.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",e[e.BAD_GATEWAY=502]="BAD_GATEWAY",e[e.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",e[e.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",e[e.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",e[e.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",e[e.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"}(e||(e={}));var s,a=n(869);!function(e){e.Api="api",e.Fill="fill",e.Bind="bind",e.FormData="formdata",e.Html="html",e.Page="page"}(s||(s={}));class o{static isEnabled(e){const t=localStorage.getItem(this.PREFIX);return e&&"true"===localStorage.getItem(`${this.PREFIX}:${String(e)}`)||"true"===t}static enable(e){localStorage.setItem(`${this.PREFIX}:${String(e)}`,"true")}static disable(e){localStorage.setItem(`${this.PREFIX}:${String(e)}`,"false")}static enableAll(){localStorage.setItem(this.PREFIX,"true")}static disableAll(){localStorage.setItem(this.PREFIX,"false")}static clear(e){e?localStorage.removeItem(`${this.PREFIX}:${String(e)}`):localStorage.removeItem(this.PREFIX)}}o.PREFIX="cotomy:debug";var l=n(584),u=n.n(l);class c{static createHTMLElement(e){const t=(new DOMParser).parseFromString(e,"text/html");if(0===t.body.childNodes.length)throw new Error("Invalid HTML string provided.");return t.body.firstChild}static first(e,t){const n=document.querySelector(e);if(n)return new(t??c)(n)}static find(e,t){const n=document.querySelectorAll(e),r=t??c;return Array.from(n).map(e=>new r(e))}static byId(e,t){return this.first(`#${e}`,t)}static contains(e){return null!==document.querySelector(e)}static empty(e){return new(e??c)(document.createElement("div")).setAttribute("data-empty","").setElementStyle("display","none")}constructor(e){this._parentElement=null,this._removed=!1,this._scopeId=null,e instanceof HTMLElement?this._element=e:"string"==typeof e?this._element=c.createHTMLElement(e):(this._element=c.createHTMLElement(e.html),e.css&&this.useScopedCss(e.css),o.isEnabled(s.Html)&&(console.debug(`CotomyElement {html: "${e.html}" } is created`),e.css&&console.debug(`CotomyElement {css: "${e.css}" } is applied`))),this.removed(()=>{this._element=document.createElement("div")})}get scopeId(){return this._scopeId||(this._scopeId=`_${u()()}`,this.setAttribute(this._scopeId,"")),this._scopeId}get scopedSelector(){return`[${this.scopeId}]`}get stylable(){return!["script","style","link","meta"].includes(this.tagname)}useScopedCss(e){if(e&&this.stylable){const t=`css-${this.scopeId}`;c.find(`#${t}`).forEach(e=>e.remove());const n=document.createElement("style"),r=e.replace(/\[scope\]/g,`[${this.scopeId}]`),i=document.createTextNode(r);n.appendChild(i),n.id=t,(c.first("head")||new c({html:"<head></head>"}).prependTo(new c(document.documentElement))).append(new c(n)),this.removed(()=>{c.find(`#${t}`).forEach(e=>e.remove())})}return this}listenLayoutEvents(){return this.setAttribute(c.LISTEN_LAYOUT_EVENTS_ATTRIBUTE,""),this}get id(){return this.attribute("id")}setId(e){return this.setAttribute("id",e),this}get element(){return this.empty?c.createHTMLElement('<div data-empty style="display: none;"></div>'):this._element}get tagname(){return this.element.tagName.toLowerCase()}is(e){const t=e.split(/\s+(?![^\[]*\])|(?<=\>)\s+/);let n=this.element;for(let e=t.length-1;e>=0;e--){let r=t[e].trim(),i=!1;if(r.startsWith(">")&&(i=!0,r=r.slice(1).trim()),!n||!n.matches(r))return!1;if(i)n=n.parentElement;else if(e>0)for(;n&&!n.matches(t[e-1].trim());)n=n.parentElement}return!0}get empty(){return this._element.hasAttribute("data-empty")}get attached(){return document.contains(this.element)}get readonly(){return"readOnly"in this.element?this.element.readOnly:this.element.hasAttribute("readonly")}set readonly(e){"readOnly"in this.element?this.element.readOnly=e:e?this.setAttribute("readonly","readonly"):this.removeAttribute("readonly")}get value(){return"value"in this.element?this.element.value:this.attribute("data-value")??""}set value(e){"value"in this.element?this.element.value=e:this.setAttribute("data-value",e)}get text(){return this.element.textContent??""}set text(e){this.element.textContent=e??""}get html(){return this.element.innerHTML}set html(e){this.element.innerHTML=e}convertUtcToLocal(e="YYYY-MM-DD HH:mm",t=!0){if(this.hasClass("utc")){if(""===this.text.trim())return this;const t=/[+-]\d{2}:\d{2}$/.test(this.text),n=new Date(this.text+(t?"":"Z"));this.text=isNaN(n.getTime())?"":i()(n).format(e),this.removeClass("utc")}if("datetime-local"===this.attribute("type")){const t=/[+-]\d{2}:\d{2}$/.test(this.value),n=new Date(this.value+(t?"":"Z"));this.value=isNaN(n.getTime())?"":i()(n).format(e)}return t&&this.find(".utc").forEach(n=>{n.convertUtcToLocal(e,t)}),this}setFocus(){this.element.focus()}get visible(){if(!this.attached)return!1;if(!this.element.offsetParent&&!document.contains(this.element))return!1;const e=this.element.getBoundingClientRect();if(e.width>0&&e.height>0){const e=this.computedStyle;return"none"!==e.display&&"hidden"!==e.visibility&&"collapse"!==e.visibility}return!1}get enabled(){return!(this.element.hasAttribute("disabled")&&null!==this.element.getAttribute("disabled"))}set enabled(e){e?this.element.removeAttribute("disabled"):this.element.setAttribute("disabled","disabled")}remove(){this._removed||(this._element.remove(),this._element=document.createElement("div"))}clone(){return new c(document.createElement(this.tagname))}clean(){this.find("*").forEach(e=>e.remove())}get width(){return this.element.offsetWidth}set width(e){let t=e.toString()+"px";this.setElementStyle("width",t)}get height(){return this.element.offsetHeight}set height(e){let t=e.toString()+"px";this.setElementStyle("height",t)}get innerWidth(){return this.element.clientWidth}get innerHeight(){return this.element.clientHeight}get outerWidth(){const e=parseFloat(this.computedStyle.marginLeft)+parseFloat(this.computedStyle.marginRight);return this.element.offsetWidth+e}get outerHeight(){const e=this.computedStyle,t=parseFloat(e.marginTop)+parseFloat(e.marginBottom);return this.element.offsetHeight+t}get scrollHeight(){return this.element.scrollHeight}get scrollWidth(){return this.element.scrollWidth}get scrollTop(){return this.element.scrollTop}get position(){const e=this.element.getBoundingClientRect();return{top:e.top,left:e.left}}get absolutePosition(){const e=this.element.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX}}get screenPosition(){const e=this.element.getBoundingClientRect();return{top:e.top,left:e.left}}get rect(){const e=this.element.getBoundingClientRect();return{top:e.top,left:e.left,width:e.width,height:e.height}}get innerRect(){const e=this.element.getBoundingClientRect(),t=this.computedStyle,n=parseFloat(t.paddingTop),r=parseFloat(t.paddingRight),i=parseFloat(t.paddingBottom),s=parseFloat(t.paddingLeft);return{top:e.top+n,left:e.left+s,width:e.width-s-r,height:e.height-n-i}}get outerRect(){const e=this.element.getBoundingClientRect(),t=this.computedStyle,n=parseFloat(t.marginTop),r=parseFloat(t.marginRight),i=parseFloat(t.marginBottom),s=parseFloat(t.marginLeft);return{top:e.top-n,left:e.left-s,width:e.width+s+r,height:e.height+n+i}}get padding(){const e=this.computedStyle;return{top:parseFloat(e.paddingTop),right:parseFloat(e.paddingRight),bottom:parseFloat(e.paddingBottom),left:parseFloat(e.paddingLeft)}}get margin(){const e=this.computedStyle;return{top:parseFloat(e.marginTop),right:parseFloat(e.marginRight),bottom:parseFloat(e.marginBottom),left:parseFloat(e.marginLeft)}}get inViewport(){const e=this.element.getBoundingClientRect();return e.top<window.innerHeight&&e.bottom>0}get isAboveViewport(){return this.element.getBoundingClientRect().bottom<0}get isBelowViewport(){return this.element.getBoundingClientRect().top>window.innerHeight}get isLeftViewport(){return this.element.getBoundingClientRect().right<0}get isRightViewport(){return this.element.getBoundingClientRect().left>window.innerWidth}hasAttribute(e){return this.element.hasAttribute(e)}attribute(e){return this.element.hasAttribute(e)?this.element.getAttribute(e):void 0}setAttribute(e,t=void 0){return this.element.setAttribute(e,t?.toString()??""),this}removeAttribute(e){this.element.removeAttribute(e)}hasClass(e){return this.element.classList.contains(e)}addClass(e){return this.element.classList.add(e),this}removeClass(e){return this.element.classList.remove(e),this}setElementStyle(e,t){return this.element.style.setProperty(e,t),this}removeElementStyle(e){return this.element.style.removeProperty(e),this}get computedStyle(){return window.getComputedStyle(this.element)}style(e){return this.computedStyle.getPropertyValue(e)}get parent(){return null==this._parentElement&&null!==this.element.parentElement&&(this._parentElement=new c(this.element.parentElement)),this._parentElement??c.empty()}get parents(){let e=[],t=this.element.parentElement;for(;null!==t;)e.push(new c(t)),t=t.parentElement;return e}hasChildren(e="*"){return null!==this.element.querySelector(e)}children(e="*",t){const n=Array.from(this.element.querySelectorAll(e)).filter(e=>e.parentElement===this.element),r=t??c;return n.filter(e=>e instanceof HTMLElement).map(e=>new r(e))}firstChild(e="*",t){return this.children(e,t).shift()??void 0}lastChild(e="*",t){return this.children(e,t).pop()??void 0}closest(e,t){const n=this.element.closest(e);if(null!==n&&n instanceof HTMLElement)return new(t??c)(n)}find(e,t){return Array.from(this.element.querySelectorAll(e)).map(e=>new(t??c)(e))}first(e="*",t){return this.find(e,t).shift()??void 0}prepend(e){return this._element.prepend(e.element),this}append(e){return this.element.append(e.element),this}appendAll(e){return e.forEach(e=>this.append(e)),this}insertBefore(e){return this.element.before(e.element),this}insertAfter(e){return this.element.after(e.element),this}appendTo(e){return e.element.append(this.element),this}prependTo(e){return e.element.prepend(this.element),this}trigger(e,t=null){return this.element.dispatchEvent(t??new Event(e)),this}on(e,t){return this.element.addEventListener(e,t),this}once(e,t){return this.element.addEventListener(e,t,{once:!0}),this}off(e,t){return this.element.removeEventListener(e,t),this}click(e=null){return e?this.element.addEventListener("click",async t=>await e(t)):this.trigger("click"),this}dblclick(e=null){return e?this.element.addEventListener("dblclick",async t=>await e(t)):this.trigger("dblclick"),this}mouseover(e=null){return e?this.element.addEventListener("mouseover",async t=>await e(t)):this.trigger("mouseover"),this}mouseout(e=null){return e?this.element.addEventListener("mouseout",async t=>await e(t)):this.trigger("mouseout"),this}mousedown(e=null){return e?this.element.addEventListener("mousedown",async t=>await e(t)):this.trigger("mousedown"),this}mouseup(e=null){return e?this.element.addEventListener("mouseup",async t=>await e(t)):this.trigger("mouseup"),this}mousemove(e=null){return e?this.element.addEventListener("mousemove",async t=>await e(t)):this.trigger("mousemove"),this}mouseenter(e=null){return e?this.element.addEventListener("mouseenter",async t=>await e(t)):this.trigger("mouseenter"),this}mouseleave(e=null){return e?this.element.addEventListener("mouseleave",async t=>await e(t)):this.trigger("mouseleave"),this}dragstart(e=null){return e?this.element.addEventListener("dragstart",async t=>await e(t)):this.trigger("dragstart"),this}dragend(e=null){return e?this.element.addEventListener("dragend",async t=>await e(t)):this.trigger("dragend"),this}dragover(e=null){return e?this.element.addEventListener("dragover",async t=>await e(t)):this.trigger("dragover"),this}dragenter(e=null){return e?this.element.addEventListener("dragenter",async t=>await e(t)):this.trigger("dragenter"),this}dragleave(e=null){return e?this.element.addEventListener("dragleave",async t=>await e(t)):this.trigger("dragleave"),this}drop(e=null){return e?this.element.addEventListener("drop",async t=>await e(t)):this.trigger("drop"),this}drag(e=null){return e?this.element.addEventListener("drag",async t=>await e(t)):this.trigger("drag"),this}removed(e){return this.element.addEventListener("removed",async t=>await e(t)),this}keydown(e=null){return e?this.element.addEventListener("keydown",async t=>await e(t)):this.trigger("keydown"),this}keyup(e=null){return e?this.element.addEventListener("keyup",async t=>await e(t)):this.trigger("keyup"),this}keypress(e=null){return e?this.element.addEventListener("keypress",async t=>await e(t)):this.trigger("keypress"),this}change(e=null){return e?this.element.addEventListener("change",async t=>await e(t)):this.trigger("change"),this}input(e=null){return e?this.element.addEventListener("input",async t=>await e(t)):this.trigger("input"),this}static get intersectionObserver(){return c._intersectionObserver=c._intersectionObserver??new IntersectionObserver(e=>{e.filter(e=>e.isIntersecting).forEach(e=>e.target.dispatchEvent(new Event("inview"))),e.filter(e=>!e.isIntersecting).forEach(e=>e.target.dispatchEvent(new Event("outview")))})}inview(e=null){return e?(c.intersectionObserver.observe(this.element),this.element.addEventListener("inview",async t=>await e(t))):this.trigger("inview"),this}outview(e=null){return e?(c.intersectionObserver.observe(this.element),this.element.addEventListener("outview",async t=>await e(t))):this.trigger("outview"),this}focus(e=null){return e?this.element.addEventListener("focus",async t=>await e(t)):this.trigger("focus"),this}blur(e=null){return e?this.element.addEventListener("blur",async t=>await e(t)):this.trigger("blur"),this}focusin(e=null){return e?this.element.addEventListener("focusin",async t=>await e(t)):this.trigger("focusin"),this}focusout(e=null){return e?this.element.addEventListener("focusout",async t=>await e(t)):this.trigger("focusout"),this}filedrop(e){return this.element.addEventListener("drop",async t=>{t.preventDefault();const n=t.dataTransfer;n&&n.files&&await e(Array.from(n.files))}),this}resize(e=null){return this.listenLayoutEvents(),e?this.element.addEventListener("cotomy:resize",async t=>await e(t)):this.trigger("cotomy:resize"),this}scroll(e=null){return this.listenLayoutEvents(),e?this.element.addEventListener("cotomy:scroll",async t=>await e(t)):this.trigger("cotomy:scroll"),this}changelayout(e=null){return this.listenLayoutEvents(),e?this.element.addEventListener("cotomy:changelayout",async t=>await e(t)):this.trigger("cotomy:changelayout"),this}}c.LISTEN_LAYOUT_EVENTS_ATTRIBUTE="data-layout",c._intersectionObserver=null;class h extends c{static get(e){return c.first(`meta[name="${e}" i]`)??c.empty()}get content(){return this.attribute("content")??""}}class d{constructor(){this._body=c.empty(),this._mutationObserver=null}static get instance(){return d._instance??(d._instance=new d)}get initialized(){return this._body.attached}initialize(){if(!this.initialized){if(!document.body)throw new Error("<body> element not found. DOM may not be ready.");this._body=c.first("body"),["resize","scroll","orientationchange","fullscreenchange","cotomy:ready"].forEach(e=>{window.addEventListener(e,()=>{const e=new CustomEvent("cotomy:changelayout");window.dispatchEvent(e)},{passive:!0})}),document.addEventListener("dragover",e=>{e.stopPropagation(),e.preventDefault()}),document.addEventListener("dragover",e=>{e.stopPropagation(),e.preventDefault()}),this.resize(()=>{document.querySelectorAll(`[${c.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(e=>{e.dispatchEvent(new CustomEvent("cotomy:resize"))})}),this.scroll(()=>{document.querySelectorAll(`[${c.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(e=>{e.dispatchEvent(new CustomEvent("cotomy:scroll"))})}),this.changeLayout(()=>{document.querySelectorAll(`[${c.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(e=>{e.dispatchEvent(new CustomEvent("cotomy:changelayout"))})}),this._mutationObserver=new MutationObserver(e=>{e.forEach(e=>{e.removedNodes.forEach(e=>{e instanceof HTMLElement&&new c(e).trigger("removed")})})}),this._mutationObserver.observe(this.body.element,{childList:!0,subtree:!0})}}get body(){return this._body}append(e){this._body.append(e)}moveNext(e,t=!1){const n=Array.from(this.body.element.querySelectorAll("input, a, select, button, textarea")).map(e=>new c(e)).filter(e=>e.width>0&&e.height>0&&e.visible&&e.enabled&&!e.hasAttribute("readonly"));let r=n.map(e=>e.element).indexOf(e.element)+(t?-1:1);r>=n.length?r=0:r<0&&(r=n.length-1),n[r]&&n[r].setFocus()}trigger(e){window.dispatchEvent(new Event(e))}load(e){window.addEventListener("load",async t=>await e(t))}ready(e){window.addEventListener("cotomy:ready",async t=>await e(t))}on(e,t){window.addEventListener(e,async e=>await t(e))}resize(e=null){e?window.addEventListener("resize",async t=>await e(t)):this.trigger("resize")}scroll(e=null){e?window.addEventListener("scroll",async t=>await e(t)):this.trigger("scroll")}changeLayout(e=null){e?window.addEventListener("cotomy:changelayout",async t=>await e(t)):this.trigger("cotomy:changelayout")}pageshow(e=null){e?window.addEventListener("pageshow",async t=>await e(t)):this.trigger("pageshow")}get scrollTop(){return window.scrollY||document.documentElement.scrollTop}get scrollLeft(){return window.scrollX||document.documentElement.scrollLeft}get width(){return window.innerWidth}get height(){return window.innerHeight}get documentWidth(){return document.documentElement.scrollWidth}get documentHeight(){return document.documentElement.scrollHeight}}d._instance=null;class E extends Error{constructor(e="Failed to parse JSON response."){super(e),this.name="ResponseJsonParseException"}}class m extends Error{constructor(e="Body must be an instance of FormData."){super(e),this.name="InvalidFormDataBodyException"}}class g{}g.GET="GET",g.POST="POST",g.PUT="PUT",g.PATCH="PATCH",g.DELETE="DELETE",g.HEAD="HEAD",g.OPTIONS="OPTIONS",g.TRACE="TRACE",g.CONNECT="CONNECT";class p{static getMessage(e){return this._responseMessages[e]||`Unexpected error: ${e}`}}p._responseMessages={[e.BAD_REQUEST]:"There is an error in the input. Please check and try again.",[e.UNAUTHORIZED]:"You are not authenticated. Please log in again.",[e.FORBIDDEN]:"You do not have permission to use this feature. If necessary, please contact the administrator.",[e.NOT_FOUND]:"The specified information could not be found. It may have been deleted. Please start over or contact the administrator.",[e.METHOD_NOT_ALLOWED]:"This operation is currently prohibited on the server.",[e.NOT_ACCEPTABLE]:"The request cannot be accepted. Processing has been stopped.",[e.PROXY_AUTHENTICATION_REQUIRED]:"Proxy authentication is required for internet access.",[e.REQUEST_TIMEOUT]:"The request timed out. Please try again.",[e.CONFLICT]:"The identifier you are trying to register already exists. Please check the content and try again.",[e.PAYMENT_REQUIRED]:"Payment is required for this operation. Please check.",[e.GONE]:"The requested resource is no longer available.",[e.LENGTH_REQUIRED]:"The Content-Length header field is required for the request.",[e.PRECONDITION_FAILED]:"The request failed because the precondition was not met.",[e.UNSUPPORTED_MEDIA_TYPE]:"The requested media type is not supported.",[e.EXPECTATION_FAILED]:"The server cannot meet the Expect header of the request.",[e.MISDIRECTED_REQUEST]:"The server cannot appropriately process this request.",[e.UNPROCESSABLE_ENTITY]:"There is an error in the request content.",[e.LOCKED]:"The requested resource is locked.",[e.FAILED_DEPENDENCY]:"The request failed due to dependency on a previous failed request.",[e.UPGRADE_REQUIRED]:"A protocol upgrade is required to perform this operation.",[e.PRECONDITION_REQUIRED]:"This request requires a precondition.",[e.TOO_MANY_REQUESTS]:"Too many requests have been sent in a short time. Please wait and try again.",[e.REQUEST_HEADER_FIELDS_TOO_LARGE]:"The request headers are too large.",[e.INTERNAL_SERVER_ERROR]:"An unexpected error occurred. Please try again later.",[e.BAD_GATEWAY]:"The server is currently overloaded. Please wait and try again later.",[e.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[e.GATEWAY_TIMEOUT]:"The communication timed out. Please try again.",[e.HTTP_VERSION_NOT_SUPPORTED]:"The current communication method is not supported.",[e.NOT_IMPLEMENTED]:"The server does not support the requested functionality.",[e.INSUFFICIENT_STORAGE]:"The server has insufficient storage.",[e.NETWORK_AUTHENTICATION_REQUIRED]:"Network authentication is required.",413:"The payload of the request is too large. Please check the size.",414:"The request URI is too long.",416:"The requested range is invalid.",508:"The server detected a loop.",510:"The request does not include the required extensions."};class T{constructor(e){this._response=e,this._json=null,this._map=null}get available(){return!!this._response}get empty(){return!this._response||0===this._response.status}get ok(){return this._response?.ok??!1}get status(){return this._response?.status??0}get statusText(){return this._response?.statusText??""}get headers(){return this._response?.headers??new Headers}async textAsync(){return await(this._response?.text())||""}async blobAsync(){return await(this._response?.blob())||new Blob}async objectAsync(e={}){if(this._response&&!this._json)try{const t=await this._response.text();if(!t)return e;this._json=JSON.parse(t)}catch(e){throw new E(`Failed to parse JSON response: ${e instanceof Error?e.message:String(e)}`)}return this._json}}class f{constructor(e){this.element=e,this._locale=null,this._currency=null,this._renderers={},this._builded=!1}get locale(){return this._locale=this._locale||navigator.language||"en-US"}get currency(){return this._currency=this._currency||a.getCurrency(this.locale)||"USD"}renderer(e,t){return this._renderers[e]=t,this}get initialized(){return this._builded}initialize(){return this.initialized||(this.renderer("mail",(e,t)=>{new c(`<a href="mailto:${t}">${t}</a>`).appendTo(e)}),this.renderer("tel",(e,t)=>{new c(`<a href="tel:${t}">${t}</a>`).appendTo(e)}),this.renderer("url",(e,t)=>{new c(`<a href="${t}" target="_blank">${t}</a>`).appendTo(e)}),this.renderer("number",(e,t)=>{e.text=new Intl.NumberFormat(navigator.language||this.locale).format(t)}),this.renderer("currency",(e,t)=>{e.text=new Intl.NumberFormat(navigator.language||this.locale,{style:"currency",currency:this.currency}).format(t)}),this.renderer("utc",(e,t)=>{const n=/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(`${t}Z`);if(isNaN(n.getTime()))e.text="";else{const t=e.attribute("data-format")??"YYYY/MM/DD HH:mm";e.text=i()(n).format(t)}})),this}async applyAsync(e){if(this.initialized||this.initialize(),!e.available)throw new Error("Response is not available.");for(const[t,n]of Object.entries(await e.objectAsync()))this.element.find(`[data-bind="${t}" i]`).forEach(e=>{o.isEnabled(s.Bind)&&console.debug(`Binding data to element [data-bind="${t}"]:`,n);const r=e.attribute("data-type")?.toLowerCase();r&&this._renderers[r]?this._renderers[r](e,n):e.text=String(n)});return this}}class y{constructor(e={baseUrl:null,headers:null,credentials:null,redirect:null,cache:null,referrerPolicy:null,mode:null,keepalive:!0,integrity:"",unauthorizedHandler:null}){this._options=e,this._abortController=new AbortController}get baseUrl(){return this._options.baseUrl||""}get headers(){return this._options.headers||{}}get credentials(){return this._options.credentials||"same-origin"}get redirect(){return this._options.redirect||"follow"}get cache(){return this._options.cache||"no-cache"}get referrerPolicy(){return this._options.referrerPolicy||"no-referrer"}get mode(){return this._options.mode||"cors"}get keepalive(){return this._options.keepalive||!0}get integrity(){return this._options.integrity||""}get abortController(){return this._abortController}get unauthorizedHandler(){return this._options.unauthorizedHandler||(()=>location.reload())}async requestAsync(t,n,r,i,s){const a={"application/json":e=>JSON.stringify(e),"application/x-www-form-urlencoded":e=>{if(e instanceof globalThis.FormData){let t=new URLSearchParams;return e.forEach((e,n)=>{t.append(n,String(e))}),t.toString()}return new URLSearchParams(e).toString()},"multipart/form-data":e=>{if(!(e instanceof globalThis.FormData))throw new m("Body must be an instance of FormData for multipart/form-data.");return e}},o=/^[a-zA-Z]/.test(n)?n:`${(this.baseUrl||"").replace(/\/$/,"")}/${n.replace(/^\//,"")}`,l=new Headers(this.headers);l.has("Content-Type")&&"multipart/form-data"===l.get("Content-Type")&&l.delete("Content-Type");const u=l.get("Content-Type")||"multipart/form-data",c=new(s??T)(await fetch(o,{method:t,headers:l,credentials:this.credentials,body:r?a[u]?a[u](r):r:void 0,signal:i??this._abortController.signal,redirect:this.redirect,cache:this.cache,referrerPolicy:this.referrerPolicy,mode:this.mode,keepalive:this.keepalive,integrity:this.integrity}));switch(c.status){case e.UNAUTHORIZED:case e.FORBIDDEN:this.unauthorizedHandler(c);break;case e.BAD_REQUEST:case e.NOT_FOUND:case e.UNPROCESSABLE_ENTITY:case e.GONE:break;default:if(c.status>=400&&c.status<600){const e=await c.textAsync().catch(()=>"No response body available"),t=c.statusText||p.getMessage(c.status)||`Unexpected error: ${c.status}`;throw new Error(`${t}\nDetails: ${e}`)}}return c}async getAsync(e,t){let n="";if(t instanceof globalThis.FormData){let e=new URLSearchParams;t.forEach((t,n)=>{e.append(n,String(t))}),n=e.toString()}else t&&(n=new URLSearchParams(Object.fromEntries(Object.entries(t).map(([e,t])=>[e,String(t)]))).toString());const r=n?`${e}?${n}`:e;return o.isEnabled(s.Api)&&console.debug(`GET request to: ${r}`),this.requestAsync(g.GET,r)}async postAsync(e,t){return o.isEnabled(s.Api)&&console.debug(`POST request to: ${e}`),this.requestAsync(g.POST,e,t)}async putAsync(e,t){return o.isEnabled(s.Api)&&console.debug(`PUT request to: ${e}`),this.requestAsync(g.PUT,e,t)}async patchAsync(e,t){return o.isEnabled(s.Api)&&console.debug(`PATCH request to: ${e}`),this.requestAsync(g.PATCH,e,t)}async deleteAsync(e){return o.isEnabled(s.Api)&&console.debug(`DELETE request to: ${e}`),this.requestAsync(g.DELETE,e)}async headAsync(e){return o.isEnabled(s.Api)&&console.debug(`HEAD request to: ${e}`),this.requestAsync(g.HEAD,e)}async optionsAsync(e){return o.isEnabled(s.Api)&&console.debug(`OPTIONS request to: ${e}`),this.requestAsync(g.OPTIONS,e)}async traceAsync(e){return o.isEnabled(s.Api)&&console.debug(`TRACE request to: ${e}`),this.requestAsync(g.TRACE,e)}async connectAsync(e){return o.isEnabled(s.Api)&&console.debug(`CONNECT request to: ${e}`),this.requestAsync(g.CONNECT,e)}async submitAsync(e){return e.method.toUpperCase()===g.GET?this.getAsync(e.action,e.body):this.requestAsync(e.method.toUpperCase(),e.action,e.body)}}class A extends Event{constructor(e){super("cotomy:action",{bubbles:!0,cancelable:!0}),this.action=e}}class _ extends c{constructor(e){super(e)}get formId(){return this.hasAttribute("id")||this.setAttribute("id",this.scopeId),this.attribute("id")}method(){return this.attribute("method")??"get"}actionUri(){return this.attribute("action")??location.pathname+location.search}get autoComplete(){return"on"===this.attribute("autocomplete")}set autoComplete(e){this.setAttribute("autocomplete",e?"on":"off")}reload(){location.reload()}get initialized(){return this.hasAttribute("data-builded")}initialize(){return this.initialized||(this.on("submit",async e=>{await this.submitAsync(e)}),d.instance.pageshow(e=>{e.persisted&&this.reload()}),this.find("button[type=button][data-action]").forEach(e=>{e.click(()=>{this.trigger("cotomy:action",new A(e.attribute("data-action")))})}),this.setAttribute("data-builded")),this}submit(){this.trigger("submit")}action(e){return"string"==typeof e?this.trigger("cotomy:action",new A(e)):this.element.addEventListener("cotomy:action",async t=>{await e(t)}),this}}class R extends _{constructor(e){super(e),this.autoComplete=!0}method(){return"get"}async submitAsync(e){e.preventDefault(),e.stopPropagation();const t=this.actionUri(),n={},r=t.split("?")[1];r&&r.split("&").forEach(e=>{const[t,r]=e.split("=");t&&r&&(n[t]=decodeURIComponent(r))}),this.find("[name]").forEach(e=>{const t=e.attribute("name");if(t){const r=e.value;r?n[t]=encodeURIComponent(r):delete n[t]}});const i=Object.entries(n).map(([e,t])=>`${e}=${t}`).join("&");location.href=`${t.split("?")[0]}?${i}`}}class S extends _{constructor(e){super(e),this._apiClient=null,this._unauthorizedHandler=null}apiClient(){return this._apiClient??(this._apiClient=new y({unauthorizedHandler:e=>{this._unauthorizedHandler?this._unauthorizedHandler(e):this._apiClient?.unauthorizedHandler(e)}}))}actionUri(){return`${this.attribute("action")}/${this.autoIncrement?this.attribute("data-id")||"":this.identifierString}`}get identifier(){return this.attribute("data-id")||void 0}setIncrementedId(e){const t=e.headers.get("Location")?.split("/").pop();this.setAttribute("data-id",t)}get identifierInputs(){return this.find("[data-keyindex]").sort((e,t)=>parseInt(e.attribute("data-keyindex")??"0")-parseInt(t.attribute("data-keyindex")??"0"))}get identifierString(){return this.identifier??this.identifierInputs.map(e=>e.value).join("/")}get autoIncrement(){return!this.identifier&&0==this.identifierInputs.length}method(){return this.autoIncrement||!this.identifierInputs.every(e=>e.readonly)?"post":"put"}formData(){const e=this.element,t=new globalThis.FormData(e);return this.find("input[type=datetime-local][name]:not([disabled])").forEach(e=>{const n=e.value;if(n){const r=new Date(n);isNaN(r.getTime())||t.set(e.attribute("name"),i()(r).format("YYYY-MM-DDTHH:mmZ"))}}),o.isEnabled(s.FormData)&&console.debug("FormData:",Array.from(t.entries())),t}async submitAsync(e){e.preventDefault(),e.stopPropagation();const t=this.formData();await this.submitToApiAsync(t)}async submitToApiAsync(t){const n=this.apiClient(),r=await n.submitAsync({method:this.method(),action:this.actionUri(),body:t});this.autoIncrement&&r.status===e.CREATED&&this.setIncrementedId(r);const i=r.headers.get("Location");return i?(location.href=i,r):r}unauthorized(e){return this._unauthorizedHandler=e,this}}class D extends S{constructor(e){super(e),this._fillers={}}filler(e,t){return this._fillers[e]=t,this}initialize(){return this.initialized||(super.initialize(),this.filler("datetime-local",(e,t)=>{const n=/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(`${t}Z`);isNaN(n.getTime())?e.value="":e.value=i()(n).format("YYYY-MM-DDTHH:mm")}),this.filler("checkbox",(e,t)=>{e.removeAttribute("checked"),t&&e.setAttribute("checked")}),this.filler("radio",(e,t)=>{e.removeAttribute("checked"),e.value===t&&e.setAttribute("checked")}),d.instance.ready(async()=>{await this.loadAsync()})),this}async submitToApiAsync(e){const t=await super.submitToApiAsync(e);return t.ok&&this.renderer().applyAsync(t),t}reload(){this.loadAsync()}loadActionUri(){return this.actionUri()}renderer(){return new f(this)}async loadAsync(){if(this.autoIncrement||!this.identifierInputs.every(e=>e.value))return new T;const t=this.apiClient(),n=await t.getAsync(this.loadActionUri());if(!n.ok){if(n.status===e.NOT_FOUND)return n;throw new Error(`Failed to load data: ${n.status} ${n.statusText}`)}return await this.fillAsync(n),n}async fillAsync(e){if(e.ok&&e.available){for(const[t,n]of Object.entries(await e.objectAsync()))t.endsWith("[]")||this.find(`input[name="${t}" i]:not([data-fill="false"]):not([multiple]),\n textarea[name="${t}" i]:not([data-fill="false"]), \n select[name="${t}" i]:not([data-fill="false"]):not([multiple])`).forEach(e=>{o.isEnabled(s.Fill)&&console.debug(`Filling input[name="${t}"] with value:`,n);const r=e.attribute("type")?.toLowerCase();r&&this._fillers[r]?this._fillers[r](e,n):e.value=String(n||"")});await this.renderer().applyAsync(e)}this.identifierInputs.forEach(e=>e.setElementStyle("background-color","#f0f0f0")),this.identifierInputs.forEach(e=>e.setAttribute("readonly")),this.find("textarea").forEach(e=>e.input())}}class O{static location(){return new O}constructor(e=null){this._url=e??this.current()}current(){const{pathname:e,search:t}=location;return`${e}${t}`}get url(){return this._url}get path(){return this._url.split("?")[0]}get segments(){return this.path.split("/").filter(e=>e.length>0).filter(e=>e.length>0)}get query(){return this._url.split("?")[1]??""}get parameters(){const e=(this._url.split("?")[1]??"").split("&").map(e=>e.split("=")),t={};return e.forEach(([e,n])=>t[e]=n),t}redirect(){window.location.href=this.url}}class v{constructor(){this._forms={}}static set(e){if(this._instance)throw new Error("PageController is already initialized.");return this._instance=new e,d.instance.load(async()=>{o.isEnabled(s.Page)&&console.debug("CotomyPageController initialize."),d.instance.initialize(),await v._instance.initializeAsync(),d.instance.trigger("cotomy:ready")}),this._instance}setForm(e){return this._forms[e.formId]=e,e.removed(()=>{delete this._forms[e.formId]}),e.initialize()}getForm(e,t){const n=this._forms[e];if(n){if(t&&!(n instanceof t))throw new Error(`Form "${e}" is not instance of expected type.`);return n}}forms(){return Object.values(this._forms)}async initializeAsync(){this.body.convertUtcToLocal()}get body(){return d.instance.body}get uri(){return new O}}v._instance=null})(),r})());
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cotomy=e():t.Cotomy=e()}(this,()=>(()=>{var t={48:t=>{var e,n="undefined"!=typeof window&&(window.crypto||window.msCrypto)||"undefined"!=typeof self&&self.crypto;if(n){var r=Math.pow(2,32)-1;e=function(){return Math.abs(n.getRandomValues(new Uint32Array(1))[0]/r)}}else e=Math.random;t.exports=e},146:(t,e,n)=>{var r=n(473),i="object"==typeof window?window:self,s=Object.keys(i).length,o=r(((navigator.mimeTypes?navigator.mimeTypes.length:0)+navigator.userAgent.length).toString(36)+s.toString(36),4);t.exports=function(){return o}},353:function(t){t.exports=function(){"use strict";var t=6e4,e=36e5,n="millisecond",r="second",i="minute",s="hour",o="day",a="week",l="month",c="quarter",u="year",h="date",d="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,E=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},p=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},y={s:p,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+p(r,2,"0")+":"+p(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,l),s=n-i<0,o=e.clone().add(r+(s?-1:1),l);return+(-(r+(n-i)/(s?i-o:o-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:l,y:u,w:a,d:o,D:h,h:s,m:i,s:r,ms:n,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},T="en",f={};f[T]=g;var A="$isDayjsObject",R=function(t){return t instanceof O||!(!t||!t[A])},_=function t(e,n,r){var i;if(!e)return T;if("string"==typeof e){var s=e.toLowerCase();f[s]&&(i=s),n&&(f[s]=n,i=s);var o=e.split("-");if(!i&&o.length>1)return t(o[0])}else{var a=e.name;f[a]=e,i=a}return!r&&i&&(T=i),i||!r&&T},S=function(t,e){if(R(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new O(n)},D=y;D.l=_,D.i=R,D.w=function(t,e){return S(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var O=function(){function g(t){this.$L=_(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[A]=!0}var p=g.prototype;return p.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(D.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(m);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},p.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},p.$utils=function(){return D},p.isValid=function(){return!(this.$d.toString()===d)},p.isSame=function(t,e){var n=S(t);return this.startOf(e)<=n&&n<=this.endOf(e)},p.isAfter=function(t,e){return S(t)<this.startOf(e)},p.isBefore=function(t,e){return this.endOf(e)<S(t)},p.$g=function(t,e,n){return D.u(t)?this[e]:this.set(n,t)},p.unix=function(){return Math.floor(this.valueOf()/1e3)},p.valueOf=function(){return this.$d.getTime()},p.startOf=function(t,e){var n=this,c=!!D.u(e)||e,d=D.p(t),m=function(t,e){var r=D.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return c?r:r.endOf(o)},E=function(t,e){return D.w(n.toDate()[t].apply(n.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},g=this.$W,p=this.$M,y=this.$D,T="set"+(this.$u?"UTC":"");switch(d){case u:return c?m(1,0):m(31,11);case l:return c?m(1,p):m(0,p+1);case a:var f=this.$locale().weekStart||0,A=(g<f?g+7:g)-f;return m(c?y-A:y+(6-A),p);case o:case h:return E(T+"Hours",0);case s:return E(T+"Minutes",1);case i:return E(T+"Seconds",2);case r:return E(T+"Milliseconds",3);default:return this.clone()}},p.endOf=function(t){return this.startOf(t,!1)},p.$set=function(t,e){var a,c=D.p(t),d="set"+(this.$u?"UTC":""),m=(a={},a[o]=d+"Date",a[h]=d+"Date",a[l]=d+"Month",a[u]=d+"FullYear",a[s]=d+"Hours",a[i]=d+"Minutes",a[r]=d+"Seconds",a[n]=d+"Milliseconds",a)[c],E=c===o?this.$D+(e-this.$W):e;if(c===l||c===u){var g=this.clone().set(h,1);g.$d[m](E),g.init(),this.$d=g.set(h,Math.min(this.$D,g.daysInMonth())).$d}else m&&this.$d[m](E);return this.init(),this},p.set=function(t,e){return this.clone().$set(t,e)},p.get=function(t){return this[D.p(t)]()},p.add=function(n,c){var h,d=this;n=Number(n);var m=D.p(c),E=function(t){var e=S(d);return D.w(e.date(e.date()+Math.round(t*n)),d)};if(m===l)return this.set(l,this.$M+n);if(m===u)return this.set(u,this.$y+n);if(m===o)return E(1);if(m===a)return E(7);var g=(h={},h[i]=t,h[s]=e,h[r]=1e3,h)[m]||1,p=this.$d.getTime()+n*g;return D.w(p,this)},p.subtract=function(t,e){return this.add(-1*t,e)},p.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||d;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=D.z(this),s=this.$H,o=this.$m,a=this.$M,l=n.weekdays,c=n.months,u=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},m=function(t){return D.s(s%12||12,t,"0")},g=u||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(E,function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return D.s(e.$y,4,"0");case"M":return a+1;case"MM":return D.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return D.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,l,2);case"ddd":return h(n.weekdaysShort,e.$W,l,3);case"dddd":return l[e.$W];case"H":return String(s);case"HH":return D.s(s,2,"0");case"h":return m(1);case"hh":return m(2);case"a":return g(s,o,!0);case"A":return g(s,o,!1);case"m":return String(o);case"mm":return D.s(o,2,"0");case"s":return String(e.$s);case"ss":return D.s(e.$s,2,"0");case"SSS":return D.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")})},p.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},p.diff=function(n,h,d){var m,E=this,g=D.p(h),p=S(n),y=(p.utcOffset()-this.utcOffset())*t,T=this-p,f=function(){return D.m(E,p)};switch(g){case u:m=f()/12;break;case l:m=f();break;case c:m=f()/3;break;case a:m=(T-y)/6048e5;break;case o:m=(T-y)/864e5;break;case s:m=T/e;break;case i:m=T/t;break;case r:m=T/1e3;break;default:m=T}return d?m:D.a(m)},p.daysInMonth=function(){return this.endOf(l).$D},p.$locale=function(){return f[this.$L]},p.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=_(t,e,!0);return r&&(n.$L=r),n},p.clone=function(){return D.w(this.$d,this)},p.toDate=function(){return new Date(this.valueOf())},p.toJSON=function(){return this.isValid()?this.toISOString():null},p.toISOString=function(){return this.$d.toISOString()},p.toString=function(){return this.$d.toUTCString()},g}(),v=O.prototype;return S.prototype=v,[["$ms",n],["$s",r],["$m",i],["$H",s],["$W",o],["$M",l],["$y",u],["$D",h]].forEach(function(t){v[t[1]]=function(e){return this.$g(e,t[0],t[1])}}),S.extend=function(t,e){return t.$i||(t(e,O,S),t.$i=!0),S},S.locale=_,S.isDayjs=R,S.unix=function(t){return S(1e3*t)},S.en=f[T],S.Ls=f,S.p={},S}()},473:t=>{t.exports=function(t,e){var n="000000000"+t;return n.substr(n.length-e)}},584:(t,e,n)=>{var r=n(146),i=n(473),s=n(48),o=0,a=Math.pow(36,4);function l(){return i((s()*a|0).toString(36),4)}function c(){return o=o<a?o:0,++o-1}function u(){return"c"+(new Date).getTime().toString(36)+i(c().toString(36),4)+r()+(l()+l())}u.slug=function(){var t=(new Date).getTime().toString(36),e=c().toString(36).slice(-4),n=r().slice(0,1)+r().slice(-1),i=l().slice(-2);return t.slice(-2)+e+n+i},u.isCuid=function(t){return"string"==typeof t&&!!t.startsWith("c")},u.isSlug=function(t){if("string"!=typeof t)return!1;var e=t.length;return e>=7&&e<=10},u.fingerprint=r,t.exports=u},831:t=>{t.exports={AD:"EUR",AE:"AED",AF:"AFN",AG:"XCD",AI:"XCD",AL:"ALL",AM:"AMD",AO:"AOA",AQ:"EUR",AR:"ARS",AS:"USD",AT:"EUR",AU:"AUD",AW:"AWG",AX:"EUR",AZ:"AZN",BA:"BAM",BB:"BBD",BD:"BDT",BE:"EUR",BF:"XOF",BG:"BGN",BH:"BHD",BI:"BIF",BJ:"XOF",BL:"EUR",BM:"BMD",BN:"BND",BO:"BOB",BQ:"USD",BR:"BRL",BS:"BSD",BT:"BTN",BV:"NOK",BW:"BWP",BY:"BYN",BZ:"BZD",CA:"CAD",CC:"AUD",CD:"CDF",CF:"XAF",CG:"XAF",CH:"CHF",CI:"XOF",CK:"NZD",CL:"CLP",CM:"XAF",CN:"CNY",CO:"COP",CR:"CRC",CU:"CUP",CV:"CVE",CW:"ANG",CX:"AUD",CY:"EUR",CZ:"CZK",DE:"EUR",DJ:"DJF",DK:"DKK",DM:"XCD",DO:"DOP",DZ:"DZD",EC:"USD",EE:"EUR",EG:"EGP",EH:"MAD",ER:"ERN",ES:"EUR",ET:"ETB",FI:"EUR",FJ:"FJD",FK:"FKP",FM:"USD",FO:"DKK",FR:"EUR",GA:"XAF",GB:"GBP",GD:"XCD",GE:"GEL",GF:"EUR",GG:"GBP",GH:"GHS",GI:"GIP",GL:"DKK",GM:"GMD",GN:"GNF",GP:"EUR",GQ:"XAF",GR:"EUR",GS:"GBP",GT:"GTQ",GU:"USD",GW:"XOF",GY:"GYD",HK:"HKD",HM:"AUD",HN:"HNL",HR:"EUR",HT:"HTG",HU:"HUF",ID:"IDR",IE:"EUR",IL:"ILS",IM:"GBP",IN:"INR",IO:"USD",IQ:"IQD",IR:"IRR",IS:"ISK",IT:"EUR",JE:"GBP",JM:"JMD",JO:"JOD",JP:"JPY",KE:"KES",KG:"KGS",KH:"KHR",KI:"AUD",KM:"KMF",KN:"XCD",KP:"KPW",KR:"KRW",KW:"KWD",KY:"KYD",KZ:"KZT",LA:"LAK",LB:"LBP",LC:"XCD",LI:"CHF",LK:"LKR",LR:"LRD",LS:"LSL",LT:"EUR",LU:"EUR",LV:"EUR",LY:"LYD",MA:"MAD",MC:"EUR",MD:"MDL",ME:"EUR",MF:"EUR",MG:"MGA",MH:"USD",MK:"MKD",ML:"XOF",MM:"MMK",MN:"MNT",MO:"MOP",MP:"USD",MQ:"EUR",MR:"MRU",MS:"XCD",MT:"EUR",MU:"MUR",MV:"MVR",MW:"MWK",MX:"MXN",MY:"MYR",MZ:"MZN",NA:"NAD",NC:"XPF",NE:"XOF",NF:"AUD",NG:"NGN",NI:"NIO",NL:"EUR",NO:"NOK",NP:"NPR",NR:"AUD",NU:"NZD",NZ:"NZD",OM:"OMR",PA:"PAB",PE:"PEN",PF:"XPF",PG:"PGK",PH:"PHP",PK:"PKR",PL:"PLN",PM:"EUR",PN:"NZD",PR:"USD",PS:"ILS",PT:"EUR",PW:"USD",PY:"PYG",QA:"QAR",RE:"EUR",RO:"RON",RS:"RSD",RU:"RUB",RW:"RWF",SA:"SAR",SB:"SBD",SC:"SCR",SD:"SDG",SE:"SEK",SG:"SGD",SH:"SHP",SI:"EUR",SJ:"NOK",SK:"EUR",SL:"SLE",SM:"EUR",SN:"XOF",SO:"SOS",SR:"SRD",SS:"SSP",ST:"STN",SV:"SVC",SX:"ANG",SY:"SYP",SZ:"SZL",TC:"USD",TD:"XAF",TF:"EUR",TG:"XOF",TH:"THB",TJ:"TJS",TK:"NZD",TL:"USD",TM:"TMT",TN:"TND",TO:"TOP",TR:"TRY",TT:"TTD",TV:"AUD",TW:"TWD",TZ:"TZS",UA:"UAH",UG:"UGX",UM:"USD",US:"USD",UY:"UYU",UZ:"UZS",VA:"EUR",VC:"XCD",VE:"VED",VG:"USD",VI:"USD",VN:"VND",VU:"VUV",WF:"XPF",WS:"WST",YE:"YER",YT:"EUR",ZA:"ZAR",ZM:"ZMW",ZW:"ZWG"}},869:(t,e,n)=>{var r=n(831);e.getCurrency=function(t){var e,n,i=(e=t,n=e.split("_"),2==n.length||2==(n=e.split("-")).length?n.pop():e).toUpperCase();return i in r?r[i]:null},e.getLocales=function(t){t=t.toUpperCase();var e=[];for(var n in r)r[n]===t&&e.push(n);return e}}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{CotomyActionEvent:()=>w,CotomyApiForm:()=>C,CotomyConflictException:()=>T,CotomyDebugFeature:()=>s,CotomyDebugSettings:()=>a,CotomyElement:()=>u,CotomyFillApiForm:()=>U,CotomyForbiddenException:()=>p,CotomyForm:()=>I,CotomyHttpClientError:()=>E,CotomyHttpServerError:()=>A,CotomyInvalidFormDataBodyException:()=>_,CotomyMetaElement:()=>h,CotomyNotFoundException:()=>y,CotomyPageController:()=>P,CotomyQueryForm:()=>b,CotomyResponseJsonParseException:()=>R,CotomyRestApi:()=>N,CotomyRestApiException:()=>m,CotomyRestApiResponse:()=>O,CotomyUnauthorizedException:()=>g,CotomyUrl:()=>L,CotomyValidationException:()=>f,CotomyViewRenderer:()=>v,CotomyWindow:()=>d});var t,e=n(353),i=n.n(e);!function(t){t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.EARLY_HINTS=103]="EARLY_HINTS",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.MULTI_STATUS=207]="MULTI_STATUS",t[t.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.USE_PROXY=305]="USE_PROXY",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",t[t.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.IM_A_TEAPOT=418]="IM_A_TEAPOT",t[t.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",t[t.METHOD_FAILURE=420]="METHOD_FAILURE",t[t.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.LOCKED=423]="LOCKED",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",t[t.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t[t.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",t[t.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"}(t||(t={}));var s,o=n(869);!function(t){t.Api="api",t.Fill="fill",t.Bind="bind",t.FormData="formdata",t.Html="html",t.Page="page"}(s||(s={}));class a{static isEnabled(t){const e=localStorage.getItem(this.PREFIX);return t&&"true"===localStorage.getItem(`${this.PREFIX}:${String(t)}`)||"true"===e}static enable(t){localStorage.setItem(`${this.PREFIX}:${String(t)}`,"true")}static disable(t){localStorage.setItem(`${this.PREFIX}:${String(t)}`,"false")}static enableAll(){localStorage.setItem(this.PREFIX,"true")}static disableAll(){localStorage.setItem(this.PREFIX,"false")}static clear(t){t?localStorage.removeItem(`${this.PREFIX}:${String(t)}`):localStorage.removeItem(this.PREFIX)}}a.PREFIX="cotomy:debug";var l=n(584),c=n.n(l);class u{static createHTMLElement(t){const e=(new DOMParser).parseFromString(t,"text/html");if(0===e.body.childNodes.length)throw new Error("Invalid HTML string provided.");return e.body.firstChild}static first(t,e){const n=document.querySelector(t);if(n)return new(e??u)(n)}static find(t,e){const n=document.querySelectorAll(t),r=e??u;return Array.from(n).map(t=>new r(t))}static byId(t,e){return this.first(`#${t}`,e)}static contains(t){return null!==document.querySelector(t)}static empty(t){return new(t??u)(document.createElement("div")).setAttribute("data-cotomy-empty","").setElementStyle("display","none")}constructor(t){this._parentElement=null,this._scopeId=null,t instanceof HTMLElement?this._element=t:"string"==typeof t?this._element=u.createHTMLElement(t):(this._element=u.createHTMLElement(t.html),t.css&&this.useScopedCss(t.css),a.isEnabled(s.Html)&&(console.debug(`CotomyElement {html: "${t.html}" } is created`),t.css&&console.debug(`CotomyElement {css: "${t.css}" } is applied`))),this.removed(()=>{this.empty||(this._element=u.createHTMLElement('<div data-cotomy-invalid style="display: none;"></div>'))})}get scopeId(){return this._scopeId||(this._scopeId=`_${c()()}`,this.setAttribute(this._scopeId,"")),this._scopeId}get scopedSelector(){return`[${this.scopeId}]`}get stylable(){return!["script","style","link","meta"].includes(this.tagname)}useScopedCss(t){if(t&&this.stylable){const e=`css-${this.scopeId}`;u.find(`#${e}`).forEach(t=>t.remove());const n=document.createElement("style"),r=t.replace(/\[scope\]/g,`[${this.scopeId}]`),i=document.createTextNode(r);n.appendChild(i),n.id=e,(u.first("head")||new u({html:"<head></head>"}).prependTo(new u(document.documentElement))).append(new u(n)),this.removed(()=>{u.find(`#${e}`).forEach(t=>t.remove())})}return this}listenLayoutEvents(){return this.setAttribute(u.LISTEN_LAYOUT_EVENTS_ATTRIBUTE,""),this}get id(){return this.attribute("id")}setId(t){return this.setAttribute("id",t),this}get element(){return this.empty?u.createHTMLElement('<div data-empty style="display: none;"></div>'):this._element}get tagname(){return this.element.tagName.toLowerCase()}is(t){const e=t.split(/\s+(?![^\[]*\])|(?<=\>)\s+/);let n=this.element;for(let t=e.length-1;t>=0;t--){let r=e[t].trim(),i=!1;if(r.startsWith(">")&&(i=!0,r=r.slice(1).trim()),!n||!n.matches(r))return!1;if(i)n=n.parentElement;else if(t>0)for(;n&&!n.matches(e[t-1].trim());)n=n.parentElement}return!0}get empty(){return this._element.hasAttribute("data-cotomy-empty")}get attached(){return document.contains(this.element)}get readonly(){return"readOnly"in this.element?this.element.readOnly:this.element.hasAttribute("readonly")}set readonly(t){"readOnly"in this.element?this.element.readOnly=t:t?this.setAttribute("readonly","readonly"):this.removeAttribute("readonly")}get value(){return"value"in this.element?this.element.value:this.attribute("data-cotomy-value")??""}set value(t){"value"in this.element?this.element.value=t:this.setAttribute("data-cotomy-value",t)}get text(){return this.element.textContent??""}set text(t){this.element.textContent=t??""}get html(){return this.element.innerHTML}set html(t){this.element.innerHTML=t}convertUtcToLocal(t="YYYY-MM-DD HH:mm",e=!0){if(this.hasClass("utc")){if(""===this.text.trim())return this;const e=/[+-]\d{2}:\d{2}$/.test(this.text),n=new Date(this.text+(e?"":"Z"));this.text=isNaN(n.getTime())?"":i()(n).format(t),this.removeClass("utc")}if("datetime-local"===this.attribute("type")){const e=/[+-]\d{2}:\d{2}$/.test(this.value),n=new Date(this.value+(e?"":"Z"));this.value=isNaN(n.getTime())?"":i()(n).format(t)}return e&&this.find(".utc").forEach(n=>{n.convertUtcToLocal(t,e)}),this}setFocus(){this.element.focus()}get visible(){if(!this.attached)return!1;if(!this.element.offsetParent&&!document.contains(this.element))return!1;const t=this.element.getBoundingClientRect();if(t.width>0&&t.height>0){const t=this.computedStyle;return"none"!==t.display&&"hidden"!==t.visibility&&"collapse"!==t.visibility}return!1}get enabled(){return!(this.element.hasAttribute("disabled")&&null!==this.element.getAttribute("disabled"))}set enabled(t){t?this.element.removeAttribute("disabled"):this.element.setAttribute("disabled","disabled")}get valid(){return!this.element.hasAttribute("data-cotomy-invalid")}remove(){this.valid&&this._element.remove()}clone(){return new u(document.createElement(this.tagname))}clean(){this.find("*").forEach(t=>t.remove())}get width(){return this.element.offsetWidth}set width(t){let e=t.toString()+"px";this.setElementStyle("width",e)}get height(){return this.element.offsetHeight}set height(t){let e=t.toString()+"px";this.setElementStyle("height",e)}get innerWidth(){return this.element.clientWidth}get innerHeight(){return this.element.clientHeight}get outerWidth(){const t=parseFloat(this.computedStyle.marginLeft)+parseFloat(this.computedStyle.marginRight);return this.element.offsetWidth+t}get outerHeight(){const t=this.computedStyle,e=parseFloat(t.marginTop)+parseFloat(t.marginBottom);return this.element.offsetHeight+e}get scrollHeight(){return this.element.scrollHeight}get scrollWidth(){return this.element.scrollWidth}get scrollTop(){return this.element.scrollTop}get position(){const t=this.element.getBoundingClientRect();return{top:t.top,left:t.left}}get absolutePosition(){const t=this.element.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}get screenPosition(){const t=this.element.getBoundingClientRect();return{top:t.top,left:t.left}}get rect(){const t=this.element.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}get innerRect(){const t=this.element.getBoundingClientRect(),e=this.computedStyle,n=parseFloat(e.paddingTop),r=parseFloat(e.paddingRight),i=parseFloat(e.paddingBottom),s=parseFloat(e.paddingLeft);return{top:t.top+n,left:t.left+s,width:t.width-s-r,height:t.height-n-i}}get outerRect(){const t=this.element.getBoundingClientRect(),e=this.computedStyle,n=parseFloat(e.marginTop),r=parseFloat(e.marginRight),i=parseFloat(e.marginBottom),s=parseFloat(e.marginLeft);return{top:t.top-n,left:t.left-s,width:t.width+s+r,height:t.height+n+i}}get padding(){const t=this.computedStyle;return{top:parseFloat(t.paddingTop),right:parseFloat(t.paddingRight),bottom:parseFloat(t.paddingBottom),left:parseFloat(t.paddingLeft)}}get margin(){const t=this.computedStyle;return{top:parseFloat(t.marginTop),right:parseFloat(t.marginRight),bottom:parseFloat(t.marginBottom),left:parseFloat(t.marginLeft)}}get inViewport(){const t=this.element.getBoundingClientRect();return t.top<window.innerHeight&&t.bottom>0}get isAboveViewport(){return this.element.getBoundingClientRect().bottom<0}get isBelowViewport(){return this.element.getBoundingClientRect().top>window.innerHeight}get isLeftViewport(){return this.element.getBoundingClientRect().right<0}get isRightViewport(){return this.element.getBoundingClientRect().left>window.innerWidth}hasAttribute(t){return this.element.hasAttribute(t)}attribute(t){return this.element.hasAttribute(t)?this.element.getAttribute(t):void 0}setAttribute(t,e=void 0){return this.element.setAttribute(t,e?.toString()??""),this}removeAttribute(t){this.element.removeAttribute(t)}hasClass(t){return this.element.classList.contains(t)}addClass(t){return this.element.classList.add(t),this}removeClass(t){return this.element.classList.remove(t),this}setElementStyle(t,e){return this.element.style.setProperty(t,e),this}removeElementStyle(t){return this.element.style.removeProperty(t),this}get computedStyle(){return window.getComputedStyle(this.element)}style(t){return this.computedStyle.getPropertyValue(t)}get parent(){return null==this._parentElement&&null!==this.element.parentElement&&(this._parentElement=new u(this.element.parentElement)),this._parentElement??u.empty()}get parents(){let t=[],e=this.element.parentElement;for(;null!==e;)t.push(new u(e)),e=e.parentElement;return t}hasChildren(t="*"){return null!==this.element.querySelector(t)}children(t="*",e){const n=Array.from(this.element.querySelectorAll(t)).filter(t=>t.parentElement===this.element),r=e??u;return n.filter(t=>t instanceof HTMLElement).map(t=>new r(t))}firstChild(t="*",e){return this.children(t,e).shift()??void 0}lastChild(t="*",e){return this.children(t,e).pop()??void 0}closest(t,e){const n=this.element.closest(t);if(null!==n&&n instanceof HTMLElement)return new(e??u)(n)}find(t,e){return Array.from(this.element.querySelectorAll(t)).map(t=>new(e??u)(t))}first(t="*",e){return this.find(t,e).shift()??void 0}prepend(t){return this._element.prepend(t.element),this}append(t){return this.element.append(t.element),this}appendAll(t){return t.forEach(t=>this.append(t)),this}insertBefore(t){return this.element.before(t.element),this}insertAfter(t){return this.element.after(t.element),this}appendTo(t){return t.element.append(this.element),this}prependTo(t){return t.element.prepend(this.element),this}trigger(t,e=null){return this.element.dispatchEvent(e??new Event(t)),this}on(t,e){return this.element.addEventListener(t,e),this}onChild(t,e,n){return this.element.addEventListener(t,t=>{if(t.target instanceof HTMLElement){const r=new u(t.target).closest(e);r&&n(t,r.element)}}),this}once(t,e){return this.element.addEventListener(t,e,{once:!0}),this}off(t,e){return this.element.removeEventListener(t,e),this}click(t=null){return t?this.element.addEventListener("click",async e=>await t(e)):this.trigger("click"),this}dblclick(t=null){return t?this.element.addEventListener("dblclick",async e=>await t(e)):this.trigger("dblclick"),this}mouseover(t=null){return t?this.element.addEventListener("mouseover",async e=>await t(e)):this.trigger("mouseover"),this}mouseout(t=null){return t?this.element.addEventListener("mouseout",async e=>await t(e)):this.trigger("mouseout"),this}mousedown(t=null){return t?this.element.addEventListener("mousedown",async e=>await t(e)):this.trigger("mousedown"),this}mouseup(t=null){return t?this.element.addEventListener("mouseup",async e=>await t(e)):this.trigger("mouseup"),this}mousemove(t=null){return t?this.element.addEventListener("mousemove",async e=>await t(e)):this.trigger("mousemove"),this}mouseenter(t=null){return t?this.element.addEventListener("mouseenter",async e=>await t(e)):this.trigger("mouseenter"),this}mouseleave(t=null){return t?this.element.addEventListener("mouseleave",async e=>await t(e)):this.trigger("mouseleave"),this}dragstart(t=null){return t?this.element.addEventListener("dragstart",async e=>await t(e)):this.trigger("dragstart"),this}dragend(t=null){return t?this.element.addEventListener("dragend",async e=>await t(e)):this.trigger("dragend"),this}dragover(t=null){return t?this.element.addEventListener("dragover",async e=>await t(e)):this.trigger("dragover"),this}dragenter(t=null){return t?this.element.addEventListener("dragenter",async e=>await t(e)):this.trigger("dragenter"),this}dragleave(t=null){return t?this.element.addEventListener("dragleave",async e=>await t(e)):this.trigger("dragleave"),this}drop(t=null){return t?this.element.addEventListener("drop",async e=>await t(e)):this.trigger("drop"),this}drag(t=null){return t?this.element.addEventListener("drag",async e=>await t(e)):this.trigger("drag"),this}removed(t){return this.element.addEventListener("removed",async e=>await t(e)),this}keydown(t=null){return t?this.element.addEventListener("keydown",async e=>await t(e)):this.trigger("keydown"),this}keyup(t=null){return t?this.element.addEventListener("keyup",async e=>await t(e)):this.trigger("keyup"),this}keypress(t=null){return t?this.element.addEventListener("keypress",async e=>await t(e)):this.trigger("keypress"),this}change(t=null){return t?this.element.addEventListener("change",async e=>await t(e)):this.trigger("change"),this}input(t=null){return t?this.element.addEventListener("input",async e=>await t(e)):this.trigger("input"),this}static get intersectionObserver(){return u._intersectionObserver=u._intersectionObserver??new IntersectionObserver(t=>{t.filter(t=>t.isIntersecting).forEach(t=>t.target.dispatchEvent(new Event("inview"))),t.filter(t=>!t.isIntersecting).forEach(t=>t.target.dispatchEvent(new Event("outview")))})}inview(t=null){return t?(u.intersectionObserver.observe(this.element),this.element.addEventListener("inview",async e=>await t(e))):this.trigger("inview"),this}outview(t=null){return t?(u.intersectionObserver.observe(this.element),this.element.addEventListener("outview",async e=>await t(e))):this.trigger("outview"),this}focus(t=null){return t?this.element.addEventListener("focus",async e=>await t(e)):this.trigger("focus"),this}blur(t=null){return t?this.element.addEventListener("blur",async e=>await t(e)):this.trigger("blur"),this}focusin(t=null){return t?this.element.addEventListener("focusin",async e=>await t(e)):this.trigger("focusin"),this}focusout(t=null){return t?this.element.addEventListener("focusout",async e=>await t(e)):this.trigger("focusout"),this}filedrop(t){return this.element.addEventListener("drop",async e=>{e.preventDefault();const n=e.dataTransfer;n&&n.files&&await t(Array.from(n.files))}),this}resize(t=null){return this.listenLayoutEvents(),t?this.element.addEventListener("cotomy:resize",async e=>await t(e)):this.trigger("cotomy:resize"),this}scroll(t=null){return this.listenLayoutEvents(),t?this.element.addEventListener("cotomy:scroll",async e=>await t(e)):this.trigger("cotomy:scroll"),this}changelayout(t=null){return this.listenLayoutEvents(),t?this.element.addEventListener("cotomy:changelayout",async e=>await t(e)):this.trigger("cotomy:changelayout"),this}}u.LISTEN_LAYOUT_EVENTS_ATTRIBUTE="data-cotomy-layout",u._intersectionObserver=null;class h extends u{static get(t){return u.first(`meta[name="${t}" i]`)??u.empty()}get content(){return this.attribute("content")??""}}class d{constructor(){this._body=u.empty(),this._mutationObserver=null,this._reloading=!1}static get instance(){return d._instance??(d._instance=new d)}get initialized(){return this._body.attached}initialize(){if(!this.initialized){if(!document.body)throw new Error("<body> element not found. DOM may not be ready.");this._body=u.first("body"),["resize","scroll","orientationchange","fullscreenchange","cotomy:ready"].forEach(t=>{window.addEventListener(t,()=>{const t=new CustomEvent("cotomy:changelayout");window.dispatchEvent(t)},{passive:!0})}),document.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault()}),document.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault()}),this.resize(()=>{document.querySelectorAll(`[${u.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(t=>{t.dispatchEvent(new CustomEvent("cotomy:resize"))})}),this.scroll(()=>{document.querySelectorAll(`[${u.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(t=>{t.dispatchEvent(new CustomEvent("cotomy:scroll"))})}),this.changeLayout(()=>{document.querySelectorAll(`[${u.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(t=>{t.dispatchEvent(new CustomEvent("cotomy:changelayout"))})}),this._mutationObserver=new MutationObserver(t=>{t.forEach(t=>{t.removedNodes.forEach(t=>{t instanceof HTMLElement&&new u(t).trigger("removed")})})}),this._mutationObserver.observe(this.body.element,{childList:!0,subtree:!0})}}get reloading(){return this._reloading}reload(){this._reloading=!0,location.reload()}get body(){return this._body}append(t){this._body.append(t)}moveNext(t,e=!1){const n=Array.from(this.body.element.querySelectorAll("input, a, select, button, textarea")).map(t=>new u(t)).filter(t=>t.width>0&&t.height>0&&t.visible&&t.enabled&&!t.hasAttribute("readonly"));let r=n.map(t=>t.element).indexOf(t.element)+(e?-1:1);r>=n.length?r=0:r<0&&(r=n.length-1),n[r]&&n[r].setFocus()}trigger(t){window.dispatchEvent(new Event(t))}load(t){window.addEventListener("load",async e=>await t(e))}ready(t){window.addEventListener("cotomy:ready",async e=>await t(e))}on(t,e){window.addEventListener(t,async t=>await e(t))}resize(t=null){t?window.addEventListener("resize",async e=>await t(e)):this.trigger("resize")}scroll(t=null){t?window.addEventListener("scroll",async e=>await t(e)):this.trigger("scroll")}changeLayout(t=null){t?window.addEventListener("cotomy:changelayout",async e=>await t(e)):this.trigger("cotomy:changelayout")}pageshow(t=null){t?window.addEventListener("pageshow",async e=>await t(e)):this.trigger("pageshow")}get scrollTop(){return window.scrollY||document.documentElement.scrollTop}get scrollLeft(){return window.scrollX||document.documentElement.scrollLeft}get width(){return window.innerWidth}get height(){return window.innerHeight}get documentWidth(){return document.documentElement.scrollWidth}get documentHeight(){return document.documentElement.scrollHeight}}d._instance=null;class m extends Error{constructor(t,e,n,r=""){super(e),this.status=t,this.message=e,this.response=n,this.bodyText=r,this.name="CotomyRestApiException"}}class E extends m{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyHttpClientError"}}class g extends E{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyUnauthorizedException"}}class p extends E{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyForbiddenException"}}class y extends E{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyNotFoundException"}}class T extends E{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyConflictException"}}class f extends E{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyValidationException"}}class A extends m{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyHttpServerError"}}class R extends Error{constructor(t="Failed to parse JSON response."){super(t),this.name="ResponseJsonParseException"}}class _ extends Error{constructor(t="Body must be an instance of FormData."){super(t),this.name="InvalidFormDataBodyException"}}class S{}S.GET="GET",S.POST="POST",S.PUT="PUT",S.PATCH="PATCH",S.DELETE="DELETE",S.HEAD="HEAD",S.OPTIONS="OPTIONS",S.TRACE="TRACE",S.CONNECT="CONNECT";class D{static getMessage(t){return this._responseMessages[t]||`Unexpected error: ${t}`}}D._responseMessages={[t.BAD_REQUEST]:"There is an error in the input. Please check and try again.",[t.UNAUTHORIZED]:"You are not authenticated. Please log in again.",[t.FORBIDDEN]:"You do not have permission to use this feature. If necessary, please contact the administrator.",[t.NOT_FOUND]:"The specified information could not be found. It may have been deleted. Please start over or contact the administrator.",[t.METHOD_NOT_ALLOWED]:"This operation is currently prohibited on the server.",[t.NOT_ACCEPTABLE]:"The request cannot be accepted. Processing has been stopped.",[t.PROXY_AUTHENTICATION_REQUIRED]:"Proxy authentication is required for internet access.",[t.REQUEST_TIMEOUT]:"The request timed out. Please try again.",[t.CONFLICT]:"The identifier you are trying to register already exists. Please check the content and try again.",[t.PAYMENT_REQUIRED]:"Payment is required for this operation. Please check.",[t.GONE]:"The requested resource is no longer available.",[t.LENGTH_REQUIRED]:"The Content-Length header field is required for the request.",[t.PRECONDITION_FAILED]:"The request failed because the precondition was not met.",[t.UNSUPPORTED_MEDIA_TYPE]:"The requested media type is not supported.",[t.EXPECTATION_FAILED]:"The server cannot meet the Expect header of the request.",[t.MISDIRECTED_REQUEST]:"The server cannot appropriately process this request.",[t.UNPROCESSABLE_ENTITY]:"There is an error in the request content.",[t.LOCKED]:"The requested resource is locked.",[t.FAILED_DEPENDENCY]:"The request failed due to dependency on a previous failed request.",[t.UPGRADE_REQUIRED]:"A protocol upgrade is required to perform this operation.",[t.PRECONDITION_REQUIRED]:"This request requires a precondition.",[t.TOO_MANY_REQUESTS]:"Too many requests have been sent in a short time. Please wait and try again.",[t.REQUEST_HEADER_FIELDS_TOO_LARGE]:"The request headers are too large.",[t.INTERNAL_SERVER_ERROR]:"An unexpected error occurred. Please try again later.",[t.BAD_GATEWAY]:"The server is currently overloaded. Please wait and try again later.",[t.SERVICE_UNAVAILABLE]:"The service is temporarily unavailable. Please try again later.",[t.GATEWAY_TIMEOUT]:"The communication timed out. Please try again.",[t.HTTP_VERSION_NOT_SUPPORTED]:"The current communication method is not supported.",[t.NOT_IMPLEMENTED]:"The server does not support the requested functionality.",[t.INSUFFICIENT_STORAGE]:"The server has insufficient storage.",[t.NETWORK_AUTHENTICATION_REQUIRED]:"Network authentication is required.",413:"The payload of the request is too large. Please check the size.",414:"The request URI is too long.",416:"The requested range is invalid.",508:"The server detected a loop.",510:"The request does not include the required extensions."};class O{constructor(t){this._response=t,this._json=null,this._map=null}get available(){return!!this._response}get empty(){return!this._response||0===this._response.status}get ok(){return this._response?.ok??!1}get status(){return this._response?.status??0}get statusText(){return this._response?.statusText??""}get headers(){return this._response?.headers??new Headers}async textAsync(){return await(this._response?.text())||""}async blobAsync(){return await(this._response?.blob())||new Blob}async objectAsync(t={}){if(this._response&&!this._json)try{const e=await this._response.text();if(!e)return t;this._json=JSON.parse(e)}catch(t){throw new R(`Failed to parse JSON response: ${t instanceof Error?t.message:String(t)}`)}return this._json}}class v{constructor(t){this.element=t,this._locale=null,this._currency=null,this._renderers={},this._builded=!1}get locale(){return this._locale=this._locale||navigator.language||"en-US"}get currency(){return this._currency=this._currency||o.getCurrency(this.locale)||"USD"}renderer(t,e){return this._renderers[t]=e,this}get initialized(){return this._builded}initialize(){return this.initialized||(this.renderer("mail",(t,e)=>{new u(`<a href="mailto:${e}">${e}</a>`).appendTo(t)}),this.renderer("tel",(t,e)=>{new u(`<a href="tel:${e}">${e}</a>`).appendTo(t)}),this.renderer("url",(t,e)=>{new u(`<a href="${e}" target="_blank">${e}</a>`).appendTo(t)}),this.renderer("number",(t,e)=>{t.text=new Intl.NumberFormat(navigator.language||this.locale).format(e)}),this.renderer("currency",(t,e)=>{t.text=new Intl.NumberFormat(navigator.language||this.locale,{style:"currency",currency:this.currency}).format(e)}),this.renderer("utc",(t,e)=>{const n=/[+-]\d{2}:\d{2}$/.test(e)?new Date(e):new Date(`${e}Z`);if(isNaN(n.getTime()))t.text="";else{const e=t.attribute("data-cotomy-format")??"YYYY/MM/DD HH:mm";t.text=i()(n).format(e)}})),this}async applyAsync(t){if(this.initialized||this.initialize(),!t.available)throw new Error("Response is not available.");for(const[e,n]of Object.entries(await t.objectAsync()))this.element.find(`[data-cotomy-bind="${e}" i]`).forEach(t=>{a.isEnabled(s.Bind)&&console.debug(`Binding data to element [data-cotomy-bind="${e}"]:`,n);const r=t.attribute("data-cotomy-type")?.toLowerCase();r&&this._renderers[r]?this._renderers[r](t,n):t.text=String(n)});return this}}class N{constructor(t={baseUrl:null,headers:null,credentials:null,redirect:null,cache:null,referrerPolicy:null,mode:null,keepalive:!0,integrity:""}){this._options=t,this._abortController=new AbortController}get baseUrl(){return this._options.baseUrl||""}get headers(){return this._options.headers||{}}get credentials(){return this._options.credentials||"same-origin"}get redirect(){return this._options.redirect||"follow"}get cache(){return this._options.cache||"no-cache"}get referrerPolicy(){return this._options.referrerPolicy||"no-referrer"}get mode(){return this._options.mode||"cors"}get keepalive(){return this._options.keepalive||!0}get integrity(){return this._options.integrity||""}get abortController(){return this._abortController}async requestAsync(e,n,r,i,s){const o={"application/json":t=>JSON.stringify(t),"application/x-www-form-urlencoded":t=>{if(t instanceof globalThis.FormData){let e=new URLSearchParams;return t.forEach((t,n)=>{e.append(n,String(t))}),e.toString()}return new URLSearchParams(t).toString()},"multipart/form-data":t=>{if(!(t instanceof globalThis.FormData))throw new _("Body must be an instance of FormData for multipart/form-data.");return t}},a=/^[a-zA-Z]/.test(n)?n:`${(this.baseUrl||"").replace(/\/$/,"")}/${n.replace(/^\//,"")}`,l=new Headers(this.headers);l.has("Content-Type")&&"multipart/form-data"===l.get("Content-Type")&&l.delete("Content-Type");const c=l.get("Content-Type")||"multipart/form-data",u=new(s??O)(await fetch(a,{method:e,headers:l,credentials:this.credentials,body:r?o[c]?o[c](r):r:void 0,signal:i??this._abortController.signal,redirect:this.redirect,cache:this.cache,referrerPolicy:this.referrerPolicy,mode:this.mode,keepalive:this.keepalive,integrity:this.integrity}));if(u.status>=400&&u.status<600){const e=await u.textAsync().catch(()=>"No response body available"),n=u.statusText||D.getMessage(u.status)||`Unexpected error: ${u.status}`;switch(u.status){case t.BAD_REQUEST:case t.UNPROCESSABLE_ENTITY:throw new f(u.status,n,u,e);case t.UNAUTHORIZED:throw new g(u.status,n,u,e);case t.FORBIDDEN:throw new p(u.status,n,u,e);case t.NOT_FOUND:throw new y(u.status,n,u,e);case t.CONFLICT:case t.GONE:throw new T(u.status,n,u,e);default:throw u.status<500?new E(u.status,n,u,e):new A(u.status,n,u,e)}}return u}async getAsync(t,e){let n="";if(e instanceof globalThis.FormData){let t=new URLSearchParams;e.forEach((e,n)=>{t.append(n,String(e))}),n=t.toString()}else e&&(n=new URLSearchParams(Object.fromEntries(Object.entries(e).map(([t,e])=>[t,String(e)]))).toString());const r=n?`${t}?${n}`:t;return a.isEnabled(s.Api)&&console.debug(`GET request to: ${r}`),this.requestAsync(S.GET,r)}async postAsync(t,e){return a.isEnabled(s.Api)&&console.debug(`POST request to: ${t}`),this.requestAsync(S.POST,t,e)}async putAsync(t,e){return a.isEnabled(s.Api)&&console.debug(`PUT request to: ${t}`),this.requestAsync(S.PUT,t,e)}async patchAsync(t,e){return a.isEnabled(s.Api)&&console.debug(`PATCH request to: ${t}`),this.requestAsync(S.PATCH,t,e)}async deleteAsync(t){return a.isEnabled(s.Api)&&console.debug(`DELETE request to: ${t}`),this.requestAsync(S.DELETE,t)}async headAsync(t){return a.isEnabled(s.Api)&&console.debug(`HEAD request to: ${t}`),this.requestAsync(S.HEAD,t)}async optionsAsync(t){return a.isEnabled(s.Api)&&console.debug(`OPTIONS request to: ${t}`),this.requestAsync(S.OPTIONS,t)}async traceAsync(t){return a.isEnabled(s.Api)&&console.debug(`TRACE request to: ${t}`),this.requestAsync(S.TRACE,t)}async connectAsync(t){return a.isEnabled(s.Api)&&console.debug(`CONNECT request to: ${t}`),this.requestAsync(S.CONNECT,t)}async submitAsync(t){return t.method.toUpperCase()===S.GET?this.getAsync(t.action,t.body):this.requestAsync(t.method.toUpperCase(),t.action,t.body)}}class w extends Event{constructor(t){super("cotomy:action",{bubbles:!0,cancelable:!0}),this.action=t}}class I extends u{constructor(t){super(t)}get formId(){return this.hasAttribute("id")||this.setAttribute("id",this.scopeId),this.attribute("id")}method(){return this.attribute("method")??"get"}actionUri(){return this.attribute("action")??location.pathname+location.search}get autoComplete(){return"on"===this.attribute("autocomplete")}set autoComplete(t){this.setAttribute("autocomplete",t?"on":"off")}reload(){d.instance.reload()}get autoRestore(){return"false"!==this.attribute("data-cotomy-restore")}set autoRestore(t){t?this.removeAttribute("data-cotomy-restore"):this.setAttribute("data-cotomy-restore","false")}restore(){this.autoRestore&&this.reload()}get initialized(){return this.hasAttribute("data-cotomy-builded")}initialize(){return this.initialized||(this.on("submit",async t=>{await this.submitAsync(t)}),d.instance.pageshow(t=>{t.persisted&&!d.instance.reloading&&this.restore()}),this.find("button[type=button][data-cotomy-action]").forEach(t=>{t.click(()=>{this.trigger("cotomy:action",new w(t.attribute("data-cotomy-action")))})}),this.setAttribute("data-cotomy-builded")),this}submit(){this.trigger("submit")}action(t){return"string"==typeof t?this.trigger("cotomy:action",new w(t)):this.element.addEventListener("cotomy:action",async e=>{await t(e)}),this}}class b extends I{constructor(t){super(t),this.autoComplete=!0}method(){return"get"}async submitAsync(t){t.preventDefault(),t.stopPropagation();const e=this.actionUri(),n={},r=e.split("?")[1];r&&r.split("&").forEach(t=>{const[e,r]=t.split("=");e&&r&&(n[e]=decodeURIComponent(r))}),this.find("[name]").forEach(t=>{const e=t.attribute("name");if(e){const r=t.value;r?n[e]=encodeURIComponent(r):delete n[e]}});const i=Object.entries(n).map(([t,e])=>`${t}=${e}`).join("&");location.href=`${e.split("?")[0]}?${i}`}}class C extends I{constructor(t){super(t)}apiClient(){return new N}actionUri(){return`${this.attribute("action")}/${this.autoIncrement?this.attribute("data-cotomy-key")||"":this.identifierString}`}get identifier(){return this.attribute("data-cotomy-key")||void 0}setIncrementedId(t){const e=t.headers.get("Location")?.split("/").pop();this.setAttribute("data-cotomy-key",e)}get identifierInputs(){return this.find("[data-cotomy-keyindex]").sort((t,e)=>parseInt(t.attribute("data-cotomy-keyindex")??"0")-parseInt(e.attribute("data-cotomy-keyindex")??"0"))}get identifierString(){return this.identifier??this.identifierInputs.map(t=>t.value).join("/")}get autoIncrement(){return!this.identifier&&0==this.identifierInputs.length}method(){return this.autoIncrement||!this.identifierInputs.every(t=>t.readonly)?"post":"put"}formData(){const t=this.element,e=new globalThis.FormData(t);return this.find("input[type=datetime-local][name]:not([disabled])").forEach(t=>{const n=t.value;if(n){const r=new Date(n);isNaN(r.getTime())||e.set(t.attribute("name"),i()(r).format("YYYY-MM-DDTHH:mmZ"))}}),a.isEnabled(s.FormData)&&console.debug("FormData:",Array.from(e.entries())),e}async submitAsync(t){t.preventDefault(),t.stopPropagation();const e=this.formData();await this.submitToApiAsync(e)}async submitToApiAsync(e){const n=this.apiClient(),r=await n.submitAsync({method:this.method(),action:this.actionUri(),body:e});this.autoIncrement&&r.status===t.CREATED&&this.setIncrementedId(r);const i=r.headers.get("Location");return i?(location.href=i,r):r}}class U extends C{constructor(t){super(t),this._fillers={}}filler(t,e){return this._fillers[t]=e,this}initialize(){return this.initialized||(super.initialize(),this.filler("datetime-local",(t,e)=>{const n=/[+-]\d{2}:\d{2}$/.test(e)?new Date(e):new Date(`${e}Z`);isNaN(n.getTime())?t.value="":t.value=i()(n).format("YYYY-MM-DDTHH:mm")}),this.filler("checkbox",(t,e)=>{t.removeAttribute("checked"),e&&t.setAttribute("checked")}),this.filler("radio",(t,e)=>{t.removeAttribute("checked"),t.value===e&&t.setAttribute("checked")}),d.instance.ready(async()=>{await this.loadAsync()})),this}async submitToApiAsync(t){const e=await super.submitToApiAsync(t);return e.ok&&this.renderer().applyAsync(e),e}reload(){this.loadAsync()}loadActionUri(){return this.actionUri()}renderer(){return new v(this)}async loadAsync(){if(this.autoIncrement||!this.identifierInputs.every(t=>t.value))return new O;const t=this.apiClient();try{const e=await t.getAsync(this.loadActionUri());return await this.fillAsync(e),e}catch(t){if(t instanceof y)return t.response;throw t}}async fillAsync(t){if(t.ok&&t.available){for(const[e,n]of Object.entries(await t.objectAsync()))e.endsWith("[]")||this.find(`input[name="${e}" i]:not([data-cotomy-fill="false"]):not([multiple]),\n textarea[name="${e}" i]:not([data-cotomy-fill="false"]), \n select[name="${e}" i]:not([data-cotomy-fill="false"]):not([multiple])`).forEach(t=>{a.isEnabled(s.Fill)&&console.debug(`Filling input[name="${e}"] with value:`,n);const r=t.attribute("type")?.toLowerCase();r&&this._fillers[r]?this._fillers[r](t,n):t.value=String(n||"")});await this.renderer().applyAsync(t)}this.identifierInputs.forEach(t=>t.setElementStyle("background-color","#f0f0f0")),this.identifierInputs.forEach(t=>t.setAttribute("readonly")),this.find("textarea").forEach(t=>t.input())}}class L{static location(){return new L}constructor(t=null){this._url=t??this.current()}current(){const{pathname:t,search:e}=location;return`${t}${e}`}get url(){return this._url}get path(){return this._url.split("?")[0]}get segments(){return this.path.split("/").filter(t=>t.length>0).filter(t=>t.length>0)}get query(){return this._url.split("?")[1]??""}get parameters(){const t=(this._url.split("?")[1]??"").split("&").map(t=>t.split("=")),e={};return t.forEach(([t,n])=>e[t]=n),e}redirect(){window.location.href=this.url}}class P{constructor(){this._forms={}}static set(t){if(this._instance)throw new Error("PageController is already initialized.");return this._instance=new t,d.instance.load(async()=>{a.isEnabled(s.Page)&&console.debug("CotomyPageController initialize."),d.instance.initialize(),await P._instance.initializeAsync(),d.instance.trigger("cotomy:ready")}),this._instance}static get(){if(!(this._instance instanceof P))throw new Error("PageController is not initialized. Use CotomyPageController.set() to initialize it.");return this._instance}setForm(t){return this._forms[t.formId]=t,t.removed(()=>{delete this._forms[t.formId]}),t.initialize()}getForm(t,e){const n=this._forms[t];if(n){if(e&&!(n instanceof e))throw new Error(`Form "${t}" is not instance of expected type.`);return n}}forms(){return Object.values(this._forms)}async initializeAsync(){this.body.convertUtcToLocal()}get body(){return d.instance.body}get uri(){return new L}}P._instance=null})(),r})());
|
package/dist/page.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class CotomyUrl {
|
|
|
17
17
|
export declare class CotomyPageController {
|
|
18
18
|
private static _instance;
|
|
19
19
|
static set<T extends CotomyPageController = CotomyPageController>(type: new () => T): T;
|
|
20
|
+
static get<T extends CotomyPageController = CotomyPageController>(): T;
|
|
20
21
|
private _forms;
|
|
21
22
|
protected setForm<T extends CotomyForm = CotomyForm>(form: T): T;
|
|
22
23
|
protected getForm<T extends CotomyForm = CotomyForm>(id: string, type?: {
|
package/dist/view.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export declare class CotomyElement {
|
|
|
7
7
|
static empty<T extends CotomyElement = CotomyElement>(type?: new (el: HTMLElement) => T): T;
|
|
8
8
|
private _element;
|
|
9
9
|
private _parentElement;
|
|
10
|
-
private _removed;
|
|
11
10
|
constructor(element: HTMLElement | {
|
|
12
11
|
html: string;
|
|
13
12
|
css?: string | null;
|
|
@@ -39,6 +38,7 @@ export declare class CotomyElement {
|
|
|
39
38
|
get visible(): boolean;
|
|
40
39
|
get enabled(): boolean;
|
|
41
40
|
set enabled(value: boolean);
|
|
41
|
+
get valid(): boolean;
|
|
42
42
|
remove(): void;
|
|
43
43
|
clone(): CotomyElement;
|
|
44
44
|
clean(): void;
|
|
@@ -129,6 +129,7 @@ export declare class CotomyElement {
|
|
|
129
129
|
prependTo(target: CotomyElement): this;
|
|
130
130
|
trigger(event: string, e?: Event | null): this;
|
|
131
131
|
on(event: string, handle: (e: Event) => void | Promise<void>): this;
|
|
132
|
+
onChild(event: string, selector: string, handle: (e: Event, matched: HTMLElement) => void | Promise<void>): this;
|
|
132
133
|
once(event: string, handle: (e: Event) => void | Promise<void>): this;
|
|
133
134
|
off(event: string, handle: (e: Event) => void | Promise<void>): this;
|
|
134
135
|
click(handle?: ((e: MouseEvent) => void | Promise<void>) | null): this;
|
|
@@ -175,8 +176,11 @@ export declare class CotomyWindow {
|
|
|
175
176
|
static get instance(): CotomyWindow;
|
|
176
177
|
private _body;
|
|
177
178
|
private _mutationObserver;
|
|
179
|
+
private _reloading;
|
|
178
180
|
get initialized(): boolean;
|
|
179
181
|
initialize(): void;
|
|
182
|
+
get reloading(): boolean;
|
|
183
|
+
reload(): void;
|
|
180
184
|
get body(): CotomyElement;
|
|
181
185
|
append(e: CotomyElement): void;
|
|
182
186
|
moveNext(focused: CotomyElement, shift?: boolean): void;
|