cotomy 0.1.22 → 0.1.23

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/form.d.ts CHANGED
@@ -44,11 +44,6 @@ export declare class CotomyApiForm extends CotomyForm {
44
44
  } | string);
45
45
  apiClient(): CotomyApi;
46
46
  actionUri(): string;
47
- get identifier(): string | undefined;
48
- protected setIncrementedId(response: CotomyApiResponse): void;
49
- get identifierInputs(): CotomyElement[];
50
- get identifierString(): string;
51
- get autoIncrement(): boolean;
52
47
  apiFailed(handle: ((event: CotomyApiFailedEvent) => void | Promise<void>)): this;
53
48
  protected triggerApiFailedEvent(response: CotomyApiResponse): void;
54
49
  submitFailed(handle: ((event: CotomyApiFailedEvent) => void | Promise<void>)): this;
@@ -58,7 +53,17 @@ export declare class CotomyApiForm extends CotomyForm {
58
53
  protected submitAsync(e: Event): Promise<void>;
59
54
  protected submitToApiAsync(formData: FormData): Promise<CotomyApiResponse>;
60
55
  }
61
- export declare class CotomyFillApiForm extends CotomyApiForm {
56
+ export declare class CotomyIdentifiedApiForm extends CotomyApiForm {
57
+ actionUri(): string;
58
+ method(): string;
59
+ get keyInputs(): CotomyElement[];
60
+ get serverGeneratedKey(): string | undefined;
61
+ protected setServerGeneratedKey(response: CotomyApiResponse): void;
62
+ get isServerGeneratedKey(): boolean;
63
+ get keyString(): string;
64
+ protected submitToApiAsync(formData: FormData): Promise<CotomyApiResponse>;
65
+ }
66
+ export declare class CotomyFillApiForm extends CotomyIdentifiedApiForm {
62
67
  private _fillers;
63
68
  constructor(element: HTMLElement | {
64
69
  html: string;
package/dist/index.js CHANGED
@@ -1 +1 @@
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}},f="en",T={};T[f]=g;var A="$isDayjsObject",_=function(t){return t instanceof v||!(!t||!t[A])},R=function t(e,n,r){var i;if(!e)return f;if("string"==typeof e){var s=e.toLowerCase();T[s]&&(i=s),n&&(T[s]=n,i=s);var o=e.split("-");if(!i&&o.length>1)return t(o[0])}else{var a=e.name;T[a]=e,i=a}return!r&&i&&(f=i),i||!r&&f},S=function(t,e){if(_(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new v(n)},D=y;D.l=R,D.i=_,D.w=function(t,e){return S(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var v=function(){function g(t){this.$L=R(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,f="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 T=this.$locale().weekStart||0,A=(g<T?g+7:g)-T;return m(c?y-A:y+(6-A),p);case o:case h:return E(f+"Hours",0);case s:return E(f+"Minutes",1);case i:return E(f+"Seconds",2);case r:return E(f+"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,f=this-p,T=function(){return D.m(E,p)};switch(g){case u:m=T()/12;break;case l:m=T();break;case c:m=T()/3;break;case a:m=(f-y)/6048e5;break;case o:m=(f-y)/864e5;break;case s:m=f/e;break;case i:m=f/t;break;case r:m=f/1e3;break;default:m=f}return d?m:D.a(m)},p.daysInMonth=function(){return this.endOf(l).$D},p.$locale=function(){return T[this.$L]},p.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=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}(),O=v.prototype;return S.prototype=O,[["$ms",n],["$s",r],["$m",i],["$H",s],["$W",o],["$M",l],["$y",u],["$D",h]].forEach(function(t){O[t[1]]=function(e){return this.$g(e,t[0],t[1])}}),S.extend=function(t,e){return t.$i||(t(e,v,S),t.$i=!0),S},S.locale=R,S.isDayjs=_,S.unix=function(t){return S(1e3*t)},S.en=T[f],S.Ls=T,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:()=>I,CotomyApi:()=>w,CotomyApiException:()=>m,CotomyApiFailedEvent:()=>C,CotomyApiForm:()=>U,CotomyApiResponse:()=>v,CotomyConflictException:()=>f,CotomyDebugFeature:()=>s,CotomyDebugSettings:()=>a,CotomyElement:()=>u,CotomyFillApiForm:()=>L,CotomyForbiddenException:()=>p,CotomyForm:()=>N,CotomyHttpClientError:()=>E,CotomyHttpServerError:()=>A,CotomyInvalidFormDataBodyException:()=>R,CotomyMetaElement:()=>h,CotomyNotFoundException:()=>y,CotomyPageController:()=>M,CotomyQueryForm:()=>b,CotomyResponseJsonParseException:()=>_,CotomyUnauthorizedException:()=>g,CotomyUrl:()=>P,CotomyValidationException:()=>T,CotomyViewRenderer:()=>O,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 contains(t){return null!==document.querySelector(t)}static byId(t,e){return this.first(`#${t}`,e)}static containsById(t){return null!==document.getElementById(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._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._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 new Set(["input","select","textarea","img","video","audio","br","hr","iframe","embed","canvas","object","svg","source","track","col","link","meta","base"]).has(this.tagname)||this._element.hasAttribute("data-cotomy-empty")||""===this._element.innerHTML.trim()}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()),this.text=""}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]`,h)??u.empty(h)}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="CotomyApiException"}}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 f extends E{constructor(t,e,n,r=""){super(t,e,n,r),this.name="CotomyConflictException"}}class T 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 _ extends Error{constructor(t="Failed to parse JSON response."){super(t),this.name="ResponseJsonParseException"}}class R 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 v{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 _(`Failed to parse JSON response: ${t instanceof Error?t.message:String(t)}`)}return this._json}}class O{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)=>{t.clean(),e&&new u(`<a href="mailto:${e}">${e}</a>`).appendTo(t)}),this.renderer("tel",(t,e)=>{t.clean(),e&&new u(`<a href="tel:${e}">${e}</a>`).appendTo(t)}),this.renderer("url",(t,e)=>{t.clean(),e&&new u(`<a href="${e}" target="_blank">${e}</a>`).appendTo(t)}),this.renderer("number",(t,e)=>{t.clean(),e&&(t.text=new Intl.NumberFormat(navigator.language||this.locale).format(e))}),this.renderer("currency",(t,e)=>{t.clean(),e&&(t.text=new Intl.NumberFormat(navigator.language||this.locale,{style:"currency",currency:this.currency}).format(e))}),this.renderer("utc",(t,e)=>{if(t.clean(),e){const n=/[+-]\d{2}:\d{2}$/.test(e)?new Date(e):new Date(`${e}Z`);if(!isNaN(n.getTime())){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-bindtype")?.toLowerCase();r&&this._renderers[r]?this._renderers[r](t,n):t.text=String(n??"")});return this}}class w{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,o){a.isEnabled(s.Api)&&console.debug(`API request: ${e} ${n}`,{body:r,headers:this.headers});const l={"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)return t;const e=new globalThis.FormData;for(const[n,r]of Object.entries(t))e.append(n,String(r));return e}},c=/^[a-zA-Z]/.test(n)?n:`${(this.baseUrl||"").replace(/\/$/,"")}/${n.replace(/^\//,"")}`,u=new Headers(this.headers);u.has("Content-Type")&&"multipart/form-data"===u.get("Content-Type")&&u.delete("Content-Type");const h=u.get("Content-Type")||"multipart/form-data",d=new(o??v)(await fetch(c,{method:e,headers:u,credentials:this.credentials,body:r?l[h]?l[h](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(d.status>=400&&d.status<600){const e=await d.textAsync().catch(()=>"No response body available"),n=d.statusText||D.getMessage(d.status)||`Unexpected error: ${d.status}`;switch(a.isEnabled(s.Api)&&console.error(`API request failed: ${n}`,d,e),d.status){case t.BAD_REQUEST:case t.UNPROCESSABLE_ENTITY:throw new T(d.status,n,d,e);case t.UNAUTHORIZED:throw new g(d.status,n,d,e);case t.FORBIDDEN:throw new p(d.status,n,d,e);case t.NOT_FOUND:throw new y(d.status,n,d,e);case t.CONFLICT:case t.GONE:throw new f(d.status,n,d,e);default:throw d.status<500?new E(d.status,n,d,e):new A(d.status,n,d,e)}}return d}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 this.requestAsync(S.POST,t,e)}async putAsync(t,e){return this.requestAsync(S.PUT,t,e)}async patchAsync(t,e){return this.requestAsync(S.PATCH,t,e)}async deleteAsync(t){return this.requestAsync(S.DELETE,t)}async headAsync(t){return this.requestAsync(S.HEAD,t)}async optionsAsync(t){return this.requestAsync(S.OPTIONS,t)}async traceAsync(t){return this.requestAsync(S.TRACE,t)}async connectAsync(t){return 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 I extends Event{constructor(t){super("cotomy:action",{bubbles:!0,cancelable:!0}),this.action=t}}class N 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 I(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 I(t)):this.element.addEventListener("cotomy:action",async e=>{await t(e)}),this}}class b extends N{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 Event{constructor(t,e="cotomy:apifailed"){super(e,{bubbles:!0,cancelable:!0}),this._response=t}get response(){return this._response}}class U extends N{constructor(t){super(t)}apiClient(){return new w}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}apiFailed(t){return this.on("cotomy:apifailed",async e=>{await t(e)}),this}triggerApiFailedEvent(t){this.trigger("cotomy:apifailed",new C(t)),a.isEnabled(s.Api)&&console.error("API request failed:",t)}submitFailed(t){return this.on("cotomy:submitfailed",async e=>{await t(e)}),this}triggerSubmitFailedEvent(t){this.trigger("cotomy:submitfailed",new C(t,"cotomy:submitfailed")),a.isEnabled(s.Api)&&console.error("Submit failed:",t)}method(){return this.autoIncrement||!this.identifierInputs.every(t=>t.readonly)?"post":"put"}formData(){const t=this.element,e=new 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();try{const 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}catch(t){throw t instanceof m&&(this.triggerApiFailedEvent(t.response),this.triggerSubmitFailedEvent(t.response)),t}}}class L extends U{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&&await this.fillAsync(e),e}reload(){this.loadAsync()}loadActionUri(){return this.actionUri()}renderer(){return new O(this)}async loadAsync(){if(this.autoIncrement||!this.identifierInputs.every(t=>t.value))return new v;const t=this.apiClient();try{const e=await t.getAsync(this.loadActionUri());return await this.fillAsync(e),e}catch(t){if(t instanceof m&&this.triggerApiFailedEvent(t.response),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 P{static location(){return new P}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 M{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 M._instance.initializeAsync(),d.instance.trigger("cotomy:ready")}),this._instance}static get(){if(!(this._instance instanceof M))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 P}}M._instance=null})(),r})());
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",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(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},y={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:u,w:o,d:a,D:h,h:s,m:i,s:r,ms:n,Q:c}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},f="en",T={};T[f]=g;var A="$isDayjsObject",_=function(e){return e instanceof D||!(!e||!e[A])},R=function e(t,n,r){var i;if(!t)return f;if("string"==typeof t){var s=t.toLowerCase();T[s]&&(i=s),n&&(T[s]=n,i=s);var a=t.split("-");if(!i&&a.length>1)return e(a[0])}else{var o=t.name;T[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 D(n)},v=y;v.l=R,v.i=_,v.w=function(e,t){return S(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var D=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(v.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(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(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 v},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 v.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,c=!!v.u(t)||t,d=v.p(e),m=function(e,t){var r=v.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return c?r:r.endOf(a)},E=function(e,t){return v.w(n.toDate()[e].apply(n.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},g=this.$W,p=this.$M,y=this.$D,f="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 o:var T=this.$locale().weekStart||0,A=(g<T?g+7:g)-T;return m(c?y-A:y+(6-A),p);case a:case h:return E(f+"Hours",0);case s:return E(f+"Minutes",1);case i:return E(f+"Seconds",2);case r:return E(f+"Milliseconds",3);default:return this.clone()}},p.endOf=function(e){return this.startOf(e,!1)},p.$set=function(e,t){var o,c=v.p(e),d="set"+(this.$u?"UTC":""),m=(o={},o[a]=d+"Date",o[h]=d+"Date",o[l]=d+"Month",o[u]=d+"FullYear",o[s]=d+"Hours",o[i]=d+"Minutes",o[r]=d+"Seconds",o[n]=d+"Milliseconds",o)[c],E=c===a?this.$D+(t-this.$W):t;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(e,t){return this.clone().$set(e,t)},p.get=function(e){return this[v.p(e)]()},p.add=function(n,c){var h,d=this;n=Number(n);var m=v.p(c),E=function(e){var t=S(d);return v.w(t.date(t.date()+Math.round(e*n)),d)};if(m===l)return this.set(l,this.$M+n);if(m===u)return this.set(u,this.$y+n);if(m===a)return E(1);if(m===o)return E(7);var g=(h={},h[i]=e,h[s]=t,h[r]=1e3,h)[m]||1,p=this.$d.getTime()+n*g;return v.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=v.z(this),s=this.$H,a=this.$m,o=this.$M,l=n.weekdays,c=n.months,u=n.meridiem,h=function(e,n,i,s){return e&&(e[n]||e(t,r))||i[n].slice(0,s)},m=function(e){return v.s(s%12||12,e,"0")},g=u||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(E,function(e,r){return r||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return v.s(t.$y,4,"0");case"M":return o+1;case"MM":return v.s(o+1,2,"0");case"MMM":return h(n.monthsShort,o,c,3);case"MMMM":return h(c,o);case"D":return t.$D;case"DD":return v.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 v.s(s,2,"0");case"h":return m(1);case"hh":return m(2);case"a":return g(s,a,!0);case"A":return g(s,a,!1);case"m":return String(a);case"mm":return v.s(a,2,"0");case"s":return String(t.$s);case"ss":return v.s(t.$s,2,"0");case"SSS":return v.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 m,E=this,g=v.p(h),p=S(n),y=(p.utcOffset()-this.utcOffset())*e,f=this-p,T=function(){return v.m(E,p)};switch(g){case u:m=T()/12;break;case l:m=T();break;case c:m=T()/3;break;case o:m=(f-y)/6048e5;break;case a:m=(f-y)/864e5;break;case s:m=f/t;break;case i:m=f/e;break;case r:m=f/1e3;break;default:m=f}return d?m:v.a(m)},p.daysInMonth=function(){return this.endOf(l).$D},p.$locale=function(){return T[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 v.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}(),O=D.prototype;return S.prototype=O,[["$ms",n],["$s",r],["$m",i],["$H",s],["$W",a],["$M",l],["$y",u],["$D",h]].forEach(function(e){O[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),S.extend=function(e,t){return e.$i||(e(t,D,S),e.$i=!0),S},S.locale=R,S.isDayjs=_,S.unix=function(e){return S(1e3*e)},S.en=T[f],S.Ls=T,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 c(){return a=a<o?a:0,++a-1}function u(){return"c"+(new Date).getTime().toString(36)+i(c().toString(36),4)+r()+(l()+l())}u.slug=function(){var e=(new Date).getTime().toString(36),t=c().toString(36).slice(-4),n=r().slice(0,1)+r().slice(-1),i=l().slice(-2);return e.slice(-2)+t+n+i},u.isCuid=function(e){return"string"==typeof e&&!!e.startsWith("c")},u.isSlug=function(e){if("string"!=typeof e)return!1;var t=e.length;return t>=7&&t<=10},u.fingerprint=r,e.exports=u},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:()=>b,CotomyApi:()=>w,CotomyApiException:()=>m,CotomyApiFailedEvent:()=>C,CotomyApiForm:()=>U,CotomyApiResponse:()=>D,CotomyConflictException:()=>f,CotomyDebugFeature:()=>s,CotomyDebugSettings:()=>o,CotomyElement:()=>u,CotomyFillApiForm:()=>P,CotomyForbiddenException:()=>p,CotomyForm:()=>N,CotomyHttpClientError:()=>E,CotomyHttpServerError:()=>A,CotomyInvalidFormDataBodyException:()=>R,CotomyMetaElement:()=>h,CotomyNotFoundException:()=>y,CotomyPageController:()=>F,CotomyQueryForm:()=>I,CotomyResponseJsonParseException:()=>_,CotomyUnauthorizedException:()=>g,CotomyUrl:()=>M,CotomyValidationException:()=>T,CotomyViewRenderer:()=>O,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),c=n.n(l);class u{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??u)(n)}static find(e,t){const n=document.querySelectorAll(e),r=t??u;return Array.from(n).map(e=>new r(e))}static contains(e){return null!==document.querySelector(e)}static byId(e,t){return this.first(`#${e}`,t)}static containsById(e){return null!==document.getElementById(e)}static empty(e){return new(e??u)(document.createElement("div")).setAttribute("data-cotomy-empty","").setElementStyle("display","none")}constructor(e){this._parentElement=null,this._scopeId=null,e instanceof HTMLElement?this._element=e:"string"==typeof e?this._element=u.createHTMLElement(e):(this._element=u.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=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(e){if(e&&this.stylable){const t=`css-${this.scopeId}`;u.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,(u.first("head")||new u({html:"<head></head>"}).prependTo(new u(document.documentElement))).append(new u(n)),this.removed(()=>{u.find(`#${t}`).forEach(e=>e.remove())})}return this}listenLayoutEvents(){return this.setAttribute(u.LISTEN_LAYOUT_EVENTS_ATTRIBUTE,""),this}get id(){return this.attribute("id")}setId(e){return this.setAttribute("id",e),this}get element(){return 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 new Set(["input","select","textarea","img","video","audio","br","hr","iframe","embed","canvas","object","svg","source","track","col","link","meta","base"]).has(this.tagname)||this._element.hasAttribute("data-cotomy-empty")||""===this._element.innerHTML.trim()}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-cotomy-value")??""}set value(e){"value"in this.element?this.element.value=e:this.setAttribute("data-cotomy-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")}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(e=>e.remove()),this.text=""}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 u(this.element.parentElement)),this._parentElement??u.empty()}get parents(){let e=[],t=this.element.parentElement;for(;null!==t;)e.push(new u(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??u;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??u)(n)}find(e,t){return Array.from(this.element.querySelectorAll(e)).map(e=>new(t??u)(e))}first(e="*",t){return this.find(e,t).shift()??void 0}contains(e){return this.find(e).length>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}onChild(e,t,n){return this.element.addEventListener(e,e=>{if(e.target instanceof HTMLElement){const r=new u(e.target).closest(t);r&&n(e,r.element)}}),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 u._intersectionObserver=u._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?(u.intersectionObserver.observe(this.element),this.element.addEventListener("inview",async t=>await e(t))):this.trigger("inview"),this}outview(e=null){return e?(u.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}}u.LISTEN_LAYOUT_EVENTS_ATTRIBUTE="data-cotomy-layout",u._intersectionObserver=null;class h extends u{static get(e){return u.first(`meta[name="${e}" i]`,h)??u.empty(h)}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(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(`[${u.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(e=>{e.dispatchEvent(new CustomEvent("cotomy:resize"))})}),this.scroll(()=>{document.querySelectorAll(`[${u.LISTEN_LAYOUT_EVENTS_ATTRIBUTE}]`).forEach(e=>{e.dispatchEvent(new CustomEvent("cotomy:scroll"))})}),this.changeLayout(()=>{document.querySelectorAll(`[${u.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 u(e).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(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 u(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 m extends Error{constructor(e,t,n,r=""){super(t),this.status=e,this.message=t,this.response=n,this.bodyText=r,this.name="CotomyApiException"}}class E extends m{constructor(e,t,n,r=""){super(e,t,n,r),this.name="CotomyHttpClientError"}}class g extends E{constructor(e,t,n,r=""){super(e,t,n,r),this.name="CotomyUnauthorizedException"}}class p extends E{constructor(e,t,n,r=""){super(e,t,n,r),this.name="CotomyForbiddenException"}}class y extends E{constructor(e,t,n,r=""){super(e,t,n,r),this.name="CotomyNotFoundException"}}class f extends E{constructor(e,t,n,r=""){super(e,t,n,r),this.name="CotomyConflictException"}}class T extends E{constructor(e,t,n,r=""){super(e,t,n,r),this.name="CotomyValidationException"}}class A extends m{constructor(e,t,n,r=""){super(e,t,n,r),this.name="CotomyHttpServerError"}}class _ extends Error{constructor(e="Failed to parse JSON response."){super(e),this.name="ResponseJsonParseException"}}class R extends Error{constructor(e="Body must be an instance of FormData."){super(e),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 v{static getMessage(e){return this._responseMessages[e]||`Unexpected error: ${e}`}}v._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 D{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 _(`Failed to parse JSON response: ${e instanceof Error?e.message:String(e)}`)}return this._json}}class O{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)=>{e.clean(),t&&new u(`<a href="mailto:${t}">${t}</a>`).appendTo(e)}),this.renderer("tel",(e,t)=>{e.clean(),t&&new u(`<a href="tel:${t}">${t}</a>`).appendTo(e)}),this.renderer("url",(e,t)=>{e.clean(),t&&new u(`<a href="${t}" target="_blank">${t}</a>`).appendTo(e)}),this.renderer("number",(e,t)=>{e.clean(),t&&(e.text=new Intl.NumberFormat(navigator.language||this.locale).format(t))}),this.renderer("currency",(e,t)=>{e.clean(),t&&(e.text=new Intl.NumberFormat(navigator.language||this.locale,{style:"currency",currency:this.currency}).format(t))}),this.renderer("utc",(e,t)=>{if(e.clean(),t){const n=/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(`${t}Z`);if(!isNaN(n.getTime())){const t=e.attribute("data-cotomy-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-cotomy-bind="${t}" i]`).forEach(e=>{o.isEnabled(s.Bind)&&console.debug(`Binding data to element [data-cotomy-bind="${t}"]:`,n);const r=e.attribute("data-cotomy-bindtype")?.toLowerCase();r&&this._renderers[r]?this._renderers[r](e,n):e.text=String(n??"")});return this}}class w{constructor(e={baseUrl:null,headers:null,credentials:null,redirect:null,cache:null,referrerPolicy:null,mode:null,keepalive:!0,integrity:""}){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}async requestAsync(t,n,r,i,a){o.isEnabled(s.Api)&&console.debug(`API request: ${t} ${n}`,{body:r,headers:this.headers});const l={"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)return e;const t=new globalThis.FormData;for(const[n,r]of Object.entries(e))t.append(n,String(r));return t}},c=/^[a-zA-Z]/.test(n)?n:`${(this.baseUrl||"").replace(/\/$/,"")}/${n.replace(/^\//,"")}`,u=new Headers(this.headers);u.has("Content-Type")&&"multipart/form-data"===u.get("Content-Type")&&u.delete("Content-Type");const h=u.get("Content-Type")||"multipart/form-data",d=new(a??D)(await fetch(c,{method:t,headers:u,credentials:this.credentials,body:r?l[h]?l[h](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(d.status>=400&&d.status<600){const t=await d.textAsync().catch(()=>"No response body available"),n=d.statusText||v.getMessage(d.status)||`Unexpected error: ${d.status}`;switch(o.isEnabled(s.Api)&&console.error(`API request failed: ${n}`,d,t),d.status){case e.BAD_REQUEST:case e.UNPROCESSABLE_ENTITY:throw new T(d.status,n,d,t);case e.UNAUTHORIZED:throw new g(d.status,n,d,t);case e.FORBIDDEN:throw new p(d.status,n,d,t);case e.NOT_FOUND:throw new y(d.status,n,d,t);case e.CONFLICT:case e.GONE:throw new f(d.status,n,d,t);default:throw d.status<500?new E(d.status,n,d,t):new A(d.status,n,d,t)}}return d}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(S.GET,r)}async postAsync(e,t){return this.requestAsync(S.POST,e,t)}async putAsync(e,t){return this.requestAsync(S.PUT,e,t)}async patchAsync(e,t){return this.requestAsync(S.PATCH,e,t)}async deleteAsync(e){return this.requestAsync(S.DELETE,e)}async headAsync(e){return this.requestAsync(S.HEAD,e)}async optionsAsync(e){return this.requestAsync(S.OPTIONS,e)}async traceAsync(e){return this.requestAsync(S.TRACE,e)}async connectAsync(e){return this.requestAsync(S.CONNECT,e)}async submitAsync(e){return e.method.toUpperCase()===S.GET?this.getAsync(e.action,e.body):this.requestAsync(e.method.toUpperCase(),e.action,e.body)}}class b extends Event{constructor(e){super("cotomy:action",{bubbles:!0,cancelable:!0}),this.action=e}}class N extends u{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(){d.instance.reload()}get autoRestore(){return"false"!==this.attribute("data-cotomy-restore")}set autoRestore(e){e?this.removeAttribute("data-cotomy-restore"):this.setAttribute("data-cotomy-restore","false")}restore(){this.autoRestore&&this.reload()}get initialized(){return this.hasAttribute("data-cotomy-initialized")}initialize(){return this.initialized||(this.on("submit",async e=>{await this.submitAsync(e)}),d.instance.pageshow(e=>{e.persisted&&!d.instance.reloading&&this.restore()}),this.find("button[type=button][data-cotomy-action]").forEach(e=>{e.click(()=>{this.trigger("cotomy:action",new b(e.attribute("data-cotomy-action")))})}),this.setAttribute("data-cotomy-initialized")),this}submit(){this.trigger("submit")}action(e){return"string"==typeof e?this.trigger("cotomy:action",new b(e)):this.element.addEventListener("cotomy:action",async t=>{await e(t)}),this}}class I extends N{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 C extends Event{constructor(e,t="cotomy:apifailed"){super(t,{bubbles:!0,cancelable:!0}),this._response=e}get response(){return this._response}}class U extends N{constructor(e){super(e)}apiClient(){return new w}actionUri(){return this.attribute("action")}apiFailed(e){return this.on("cotomy:apifailed",async t=>{await e(t)}),this}triggerApiFailedEvent(e){this.trigger("cotomy:apifailed",new C(e)),o.isEnabled(s.Api)&&console.error("API request failed:",e)}submitFailed(e){return this.on("cotomy:submitfailed",async t=>{await e(t)}),this}triggerSubmitFailedEvent(e){this.trigger("cotomy:submitfailed",new C(e,"cotomy:submitfailed")),o.isEnabled(s.Api)&&console.error("Submit failed:",e)}method(){return this.attribute("method")??"post"}formData(){const e=this.element,t=new 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(e){const t=this.apiClient();try{const n=await t.submitAsync({method:this.method(),action:this.actionUri(),body:e}),r=n.headers.get("Location");return r?(location.href=r,n):n}catch(e){throw e instanceof m&&(this.triggerApiFailedEvent(e.response),this.triggerSubmitFailedEvent(e.response)),e}}}class L extends U{actionUri(){return`${this.attribute("action")}/${this.isServerGeneratedKey?this.attribute("data-cotomy-key")||"":this.keyString}`}method(){return this.isServerGeneratedKey||!this.keyInputs.every(e=>e.readonly)?"post":"put"}get keyInputs(){return this.find("[data-cotomy-keyindex]").sort((e,t)=>parseInt(e.attribute("data-cotomy-keyindex")??"0")-parseInt(t.attribute("data-cotomy-keyindex")??"0"))}get serverGeneratedKey(){return this.attribute("data-cotomy-key")||void 0}setServerGeneratedKey(e){const t=e.headers.get("Location")?.split("/").pop();this.setAttribute("data-cotomy-key",t)}get isServerGeneratedKey(){return!this.serverGeneratedKey&&0==this.keyInputs.length}get keyString(){return this.serverGeneratedKey??this.keyInputs.map(e=>e.value).join("/")}async submitToApiAsync(t){const n=await super.submitToApiAsync(t);return this.isServerGeneratedKey&&n.status===e.CREATED&&this.setServerGeneratedKey(n),n}}class P extends L{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&&await this.fillAsync(t),t}reload(){this.loadAsync()}loadActionUri(){return this.actionUri()}renderer(){return new O(this)}async loadAsync(){if(this.isServerGeneratedKey||!this.keyInputs.every(e=>e.value))return new D;const e=this.apiClient();try{const t=await e.getAsync(this.loadActionUri());return await this.fillAsync(t),t}catch(e){if(e instanceof m&&this.triggerApiFailedEvent(e.response),e instanceof y)return e.response;throw e}}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-cotomy-fill="false"]):not([multiple]),\n textarea[name="${t}" i]:not([data-cotomy-fill="false"]), \n select[name="${t}" i]:not([data-cotomy-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.keyInputs.forEach(e=>e.setElementStyle("background-color","#f0f0f0")),this.keyInputs.forEach(e=>e.setAttribute("readonly")),this.find("textarea").forEach(e=>e.input())}}class M{static location(){return new M}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 F{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 F._instance.initializeAsync(),d.instance.trigger("cotomy:ready")}),this._instance}static get(){if(!(this._instance instanceof F))throw new Error("PageController is not initialized. Use CotomyPageController.set() to initialize it.");return 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 M}}F._instance=null})(),r})());
package/dist/view.d.ts CHANGED
@@ -121,6 +121,7 @@ export declare class CotomyElement {
121
121
  closest<T extends CotomyElement = CotomyElement>(selector: string, type?: new (el: HTMLElement) => T): T | undefined;
122
122
  find<T extends CotomyElement = CotomyElement>(selector: string, type?: new (el: HTMLElement) => T): T[];
123
123
  first<T extends CotomyElement = CotomyElement>(selector?: string, type?: new (el: HTMLElement) => T): T | undefined;
124
+ contains(selector: string): boolean;
124
125
  prepend(prepend: CotomyElement): this;
125
126
  append(target: CotomyElement): this;
126
127
  appendAll(targets: CotomyElement[]): this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cotomy",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [