diff --git a/frontend/css/flatpickr.min.css b/frontend/css/flatpickr.min.css new file mode 100644 index 0000000..a10acc6 --- /dev/null +++ b/frontend/css/flatpickr.min.css @@ -0,0 +1,13 @@ +.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08)}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1);animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9)}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{/* + /*rtl:begin:ignore*/left:0/* + /*rtl:end:ignore*/}/* + /*rtl:begin:ignore*/ +/* + /*rtl:end:ignore*/ +.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,.flatpickr-months .flatpickr-next-month.flatpickr-next-month{/* + /*rtl:begin:ignore*/right:0/* + /*rtl:end:ignore*/}/* + /*rtl:begin:ignore*/ +/* + /*rtl:end:ignore*/ +.flatpickr-months .flatpickr-prev-month:hover,.flatpickr-months .flatpickr-next-month:hover{color:#959ea9}.flatpickr-months .flatpickr-prev-month:hover svg,.flatpickr-months .flatpickr-next-month:hover svg{fill:#f64747}.flatpickr-months .flatpickr-prev-month svg,.flatpickr-months .flatpickr-next-month svg{width:14px;height:14px}.flatpickr-months .flatpickr-prev-month svg path,.flatpickr-months .flatpickr-next-month svg path{-webkit-transition:fill .1s;transition:fill .1s;fill:inherit}.numInputWrapper{position:relative;height:auto}.numInputWrapper input,.numInputWrapper span{display:inline-block}.numInputWrapper input{width:100%}.numInputWrapper input::-ms-clear{display:none}.numInputWrapper input::-webkit-outer-spin-button,.numInputWrapper input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none}.numInputWrapper span{position:absolute;right:0;width:14px;padding:0 4px 0 2px;height:50%;line-height:50%;opacity:0;cursor:pointer;border:1px solid rgba(57,57,57,0.15);-webkit-box-sizing:border-box;box-sizing:border-box}.numInputWrapper span:hover{background:rgba(0,0,0,0.1)}.numInputWrapper span:active{background:rgba(0,0,0,0.2)}.numInputWrapper span:after{display:block;content:"";position:absolute}.numInputWrapper span.arrowUp{top:0;border-bottom:0}.numInputWrapper span.arrowUp:after{border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:4px solid rgba(57,57,57,0.6);top:26%}.numInputWrapper span.arrowDown{top:50%}.numInputWrapper span.arrowDown:after{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(57,57,57,0.6);top:40%}.numInputWrapper span svg{width:inherit;height:auto}.numInputWrapper span svg path{fill:rgba(0,0,0,0.5)}.numInputWrapper:hover{background:rgba(0,0,0,0.05)}.numInputWrapper:hover span{opacity:1}.flatpickr-current-month{font-size:135%;line-height:inherit;font-weight:300;color:inherit;position:absolute;width:75%;left:12.5%;padding:7.48px 0 0 0;line-height:1;height:34px;display:inline-block;text-align:center;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.flatpickr-current-month span.cur-month{font-family:inherit;font-weight:700;color:inherit;display:inline-block;margin-left:.5ch;padding:0}.flatpickr-current-month span.cur-month:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .numInputWrapper{width:6ch;width:7ch\0;display:inline-block}.flatpickr-current-month .numInputWrapper span.arrowUp:after{border-bottom-color:rgba(0,0,0,0.9)}.flatpickr-current-month .numInputWrapper span.arrowDown:after{border-top-color:rgba(0,0,0,0.9)}.flatpickr-current-month input.cur-year{background:transparent;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:text;padding:0 0 0 .5ch;margin:0;display:inline-block;font-size:inherit;font-family:inherit;font-weight:300;line-height:inherit;height:auto;border:0;border-radius:0;vertical-align:initial;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-current-month input.cur-year:focus{outline:0}.flatpickr-current-month input.cur-year[disabled],.flatpickr-current-month input.cur-year[disabled]:hover{font-size:100%;color:rgba(0,0,0,0.5);background:transparent;pointer-events:none}.flatpickr-current-month .flatpickr-monthDropdown-months{appearance:menulist;background:transparent;border:none;border-radius:0;box-sizing:border-box;color:inherit;cursor:pointer;font-size:inherit;font-family:inherit;font-weight:300;height:auto;line-height:inherit;margin:-1px 0 0 0;outline:none;padding:0 0 0 .5ch;position:relative;vertical-align:initial;-webkit-box-sizing:border-box;-webkit-appearance:menulist;-moz-appearance:menulist;width:auto}.flatpickr-current-month .flatpickr-monthDropdown-months:focus,.flatpickr-current-month .flatpickr-monthDropdown-months:active{outline:none}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{background-color:transparent;outline:none;padding:0}.flatpickr-weekdays{background:transparent;text-align:center;overflow:hidden;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;height:28px}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}span.flatpickr-weekday{cursor:default;font-size:90%;background:transparent;color:rgba(0,0,0,0.54);line-height:1;margin:0;text-align:center;display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-weight:bolder}.dayContainer,.flatpickr-weeks{padding:1px 0 0 0}.flatpickr-days{position:relative;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;width:307.875px}.flatpickr-days:focus{outline:0}.dayContainer{padding:0;outline:0;text-align:left;width:307.875px;min-width:307.875px;max-width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-wrap:wrap;-ms-flex-pack:justify;-webkit-justify-content:space-around;justify-content:space-around;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);opacity:1}.dayContainer + .dayContainer{-webkit-box-shadow:-1px 0 0 #e6e6e6;box-shadow:-1px 0 0 #e6e6e6}.flatpickr-day{background:none;border:1px solid transparent;border-radius:150px;-webkit-box-sizing:border-box;box-sizing:border-box;color:#393939;cursor:pointer;font-weight:400;width:14.2857143%;-webkit-flex-basis:14.2857143%;-ms-flex-preferred-size:14.2857143%;flex-basis:14.2857143%;max-width:39px;height:39px;line-height:39px;margin:0;display:inline-block;position:relative;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center}.flatpickr-day.inRange,.flatpickr-day.prevMonthDay.inRange,.flatpickr-day.nextMonthDay.inRange,.flatpickr-day.today.inRange,.flatpickr-day.prevMonthDay.today.inRange,.flatpickr-day.nextMonthDay.today.inRange,.flatpickr-day:hover,.flatpickr-day.prevMonthDay:hover,.flatpickr-day.nextMonthDay:hover,.flatpickr-day:focus,.flatpickr-day.prevMonthDay:focus,.flatpickr-day.nextMonthDay:focus{cursor:pointer;outline:0;background:#e6e6e6;border-color:#e6e6e6}.flatpickr-day.today{border-color:#959ea9}.flatpickr-day.today:hover,.flatpickr-day.today:focus{border-color:#959ea9;background:#959ea9;color:#fff}.flatpickr-day.selected,.flatpickr-day.startRange,.flatpickr-day.endRange,.flatpickr-day.selected.inRange,.flatpickr-day.startRange.inRange,.flatpickr-day.endRange.inRange,.flatpickr-day.selected:focus,.flatpickr-day.startRange:focus,.flatpickr-day.endRange:focus,.flatpickr-day.selected:hover,.flatpickr-day.startRange:hover,.flatpickr-day.endRange:hover,.flatpickr-day.selected.prevMonthDay,.flatpickr-day.startRange.prevMonthDay,.flatpickr-day.endRange.prevMonthDay,.flatpickr-day.selected.nextMonthDay,.flatpickr-day.startRange.nextMonthDay,.flatpickr-day.endRange.nextMonthDay{background:#569ff7;-webkit-box-shadow:none;box-shadow:none;color:#fff;border-color:#569ff7}.flatpickr-day.selected.startRange,.flatpickr-day.startRange.startRange,.flatpickr-day.endRange.startRange{border-radius:50px 0 0 50px}.flatpickr-day.selected.endRange,.flatpickr-day.startRange.endRange,.flatpickr-day.endRange.endRange{border-radius:0 50px 50px 0}.flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n+1)),.flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n+1)),.flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n+1)){-webkit-box-shadow:-10px 0 0 #569ff7;box-shadow:-10px 0 0 #569ff7}.flatpickr-day.selected.startRange.endRange,.flatpickr-day.startRange.startRange.endRange,.flatpickr-day.endRange.startRange.endRange{border-radius:50px}.flatpickr-day.inRange{border-radius:0;-webkit-box-shadow:-5px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-5px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover,.flatpickr-day.prevMonthDay,.flatpickr-day.nextMonthDay,.flatpickr-day.notAllowed,.flatpickr-day.notAllowed.prevMonthDay,.flatpickr-day.notAllowed.nextMonthDay{color:rgba(57,57,57,0.3);background:transparent;border-color:transparent;cursor:default}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover{cursor:not-allowed;color:rgba(57,57,57,0.1)}.flatpickr-day.week.selected{border-radius:0;-webkit-box-shadow:-5px 0 0 #569ff7,5px 0 0 #569ff7;box-shadow:-5px 0 0 #569ff7,5px 0 0 #569ff7}.flatpickr-day.hidden{visibility:hidden}.rangeMode .flatpickr-day{margin-top:1px}.flatpickr-weekwrapper{float:left}.flatpickr-weekwrapper .flatpickr-weeks{padding:0 12px;-webkit-box-shadow:1px 0 0 #e6e6e6;box-shadow:1px 0 0 #e6e6e6}.flatpickr-weekwrapper .flatpickr-weekday{float:none;width:100%;line-height:28px}.flatpickr-weekwrapper span.flatpickr-day,.flatpickr-weekwrapper span.flatpickr-day:hover{display:block;width:100%;max-width:none;color:rgba(57,57,57,0.3);background:transparent;cursor:default;border:none}.flatpickr-innerContainer{display:block;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden}.flatpickr-rContainer{display:inline-block;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box}.flatpickr-time{text-align:center;outline:0;display:block;height:0;line-height:40px;max-height:40px;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-time:after{content:"";display:table;clear:both}.flatpickr-time .numInputWrapper{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;width:40%;height:40px;float:left}.flatpickr-time .numInputWrapper span.arrowUp:after{border-bottom-color:#393939}.flatpickr-time .numInputWrapper span.arrowDown:after{border-top-color:#393939}.flatpickr-time.hasSeconds .numInputWrapper{width:26%}.flatpickr-time.time24hr .numInputWrapper{width:49%}.flatpickr-time input{background:transparent;-webkit-box-shadow:none;box-shadow:none;border:0;border-radius:0;text-align:center;margin:0;padding:0;height:inherit;line-height:inherit;color:#393939;font-size:14px;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-time input.flatpickr-hour{font-weight:bold}.flatpickr-time input.flatpickr-minute,.flatpickr-time input.flatpickr-second{font-weight:400}.flatpickr-time input:focus{outline:0;border:0}.flatpickr-time .flatpickr-time-separator,.flatpickr-time .flatpickr-am-pm{height:inherit;float:left;line-height:inherit;color:#393939;font-weight:bold;width:2%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center}.flatpickr-time .flatpickr-am-pm{outline:0;width:18%;cursor:pointer;text-align:center;font-weight:400}.flatpickr-time input:hover,.flatpickr-time .flatpickr-am-pm:hover,.flatpickr-time input:focus,.flatpickr-time .flatpickr-am-pm:focus{background:#eee}.flatpickr-input[readonly]{cursor:pointer}@-webkit-keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}}@keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}} \ No newline at end of file diff --git a/frontend/input.css b/frontend/input.css index 58f6350..83ea72f 100644 --- a/frontend/input.css +++ b/frontend/input.css @@ -1,6 +1,6 @@ /* static/css/input.css */ @import "tailwindcss"; - +/* @import "./css/flatpickr.min.css"; */ /* =================================================================== */ /* [核心] 定义 shadcn/ui 的设计系统变量 */ /* =================================================================== */ @@ -97,6 +97,155 @@ focus-visible:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[(var(--ring))] disabled:cursor-not-allowed disabled:opacity-50; } + + /* ------------------------------------------------ */ + /* Custom Flatpickr Theme using shadcn/ui variables */ + /* ------------------------------------------------ */ + + .flatpickr-calendar { + /* --- 主题样式 --- */ + @apply bg-background text-foreground rounded-lg shadow-lg border border-border w-auto font-sans; + animation: var(--animation-panel-in); + width: 200px; + /* --- 核心结构样式 --- */ + display: none; + position: absolute; + visibility: hidden; + opacity: 0; + padding: 0; + z-index: 999; + box-sizing: border-box; + transition: opacity 0.15s ease-out, visibility 0.15s ease-out; + } + .flatpickr-calendar.open { + opacity: 1; + visibility: visible; + display: inline-block; + } + + .flatpickr-calendar.not-ready { + top: 0; + left: 0; + visibility: hidden; + } + .flatpickr-calendar.static { + position: relative; + top: auto; + left: auto; + display: block; + visibility: visible; + opacity: 1; + } + .flatpickr-calendar.static { position: relative; top: auto; left: auto; display: block; visibility: visible; opacity: 1; } + .flatpickr-calendar.not-ready { top: 0; left: 0; visibility: hidden; } + /* 月份导航区域 */ + .flatpickr-months { + @apply flex items-center bg-transparent p-0 border-b border-zinc-500/30; + } + .flatpickr-month { @apply h-auto pt-2 pb-1; } + .flatpickr-current-month { + @apply flex flex-1 items-center justify-center text-foreground font-semibold text-sm h-auto; + } + + .flatpickr-current-month .numInputWrapper { + @apply ml-0; + } + + .flatpickr-current-month .numInputWrapper input.numInput { + + @apply w-14 text-center font-semibold bg-transparent border-0 p-0 text-sm text-foreground; + + /* 移除默认的浏览器样式和聚焦时的轮廓 */ + @apply appearance-none focus:outline-none focus:ring-0; + -moz-appearance: textfield; + } + /* 强制移除数字输入框在 Chrome, Safari, Edge 等 Webkit 浏览器中的上下箭头 */ + .flatpickr-current-month .numInputWrapper input.numInput::-webkit-outer-spin-button, + .flatpickr-current-month .numInputWrapper input.numInput::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + .flatpickr-current-month .cur-month { @apply font-semibold; } + .flatpickr-current-month .flatpickr-monthDropdown-months { + + @apply w-[5.5rem] font-semibold bg-transparent border-0 p-0 text-sm text-foreground text-right; + + @apply appearance-none focus:outline-none focus:ring-0; + + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; /* 确保月份名不换行 */ + } + option.flatpickr-monthDropdown-month { + @apply bg-background text-foreground border-0; + @apply dark:bg-zinc-800 dark:text-zinc-200; + } + .flatpickr-current-month .flatpickr-monthDropdown-months, + .flatpickr-current-month .numInputWrapper input.numInput { + @apply text-sm pl-0 ; + } + /* 导航箭头 */ + .flatpickr-prev-month, + .flatpickr-next-month { + @apply inline-flex items-center justify-center whitespace-nowrap rounded-md pt-2 pb-1 text-sm font-medium transition-colors + focus-visible:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[(var(--ring))] + disabled:pointer-events-none disabled:opacity-50 + hover:text-accent-foreground + h-7 w-7 flex-shrink-0; + position: relative; + } + .flatpickr-prev-month svg, + .flatpickr-next-month svg { + @apply h-3 w-3 hover:h-4 hover:w-4 fill-zinc-500; + } + + /* 星期标题 */ + .flatpickr-weekdaycontainer { + @apply flex justify-around p-1; + } + span.flatpickr-weekday { + @apply flex-1 text-center text-muted-foreground font-medium; + font-size: 0.7rem; + } + /* 日期网格 */ + .dayContainer { + @apply flex flex-wrap p-1 pt-0; + box-sizing: border-box; + } + .flatpickr-day { + @apply w-4 h-6.5 flex items-center justify-center rounded-full border-0 text-foreground transition-colors flex-shrink-0; /* <--- 从 w-9 h-9 缩小 */ + flex-basis: 14.2857%; + line-height: 1; + cursor: pointer; + font-size: 0.7rem; /* 介于 text-xs 和 text-sm 之间 */ + } + .flatpickr-day:hover, + .flatpickr-day:focus { @apply bg-accent text-accent-foreground outline-none; } + .flatpickr-day.today { @apply border border-primary; } + .flatpickr-day.selected, + .flatpickr-day.startRange, + .flatpickr-day.endRange, + .flatpickr-day.selected:hover, + .flatpickr-day.startRange:hover, + .flatpickr-day.endRange:hover { + @apply bg-primary text-primary-foreground; + } + .flatpickr-day.inRange { @apply bg-accent rounded-none shadow-none; } + .flatpickr-day.startRange { @apply rounded-l-full; } + .flatpickr-day.endRange { @apply rounded-r-full; } + .flatpickr-day.disabled, + .flatpickr-day.disabled:hover { @apply bg-transparent text-muted-foreground/50 cursor-not-allowed; } + .flatpickr-day.nextMonthDay, .flatpickr-day.prevMonthDay { @apply text-muted-foreground/50; } + .flatpickr-day.nextMonthDay:hover, .flatpickr-day.prevMonthDay:hover { @apply bg-accent; } + + /* 清除按钮 */ + .flatpickr-calendar .flatpickr-clear-button { + @apply h-6 py-3 inline-flex items-center justify-center whitespace-nowrap rounded-md text-xs font-medium transition-colors + focus-visible:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[(var(--ring))] + disabled:pointer-events-none disabled:opacity-50 + text-primary underline-offset-4 hover:text-sm + w-full rounded-t-none border-t border-zinc-500/20; + } } @custom-variant dark (&:where(.dark, .dark *)); @@ -752,14 +901,18 @@ @apply text-4xl; } + +/* =================================================================== */ +/* 自定义 table 样式 (Custom SweetAlert2 Styles) */ +/* =================================================================== */ @layer components { - /* --- [新增] 可复用的表格组件样式 --- */ + /* --- 可复用的表格组件样式 --- */ .table { @apply w-full caption-bottom text-sm; } .table-header { /* 使用语义化颜色,自动适应暗色模式 */ - @apply sticky top-0 z-10 border-b border-border bg-muted/50; + @apply sticky top-0 z-10 border-b border-border bg-zinc-200 dark:bg-zinc-900; } .table-header .table-row { /* 表头的 hover 效果通常与数据行不同,或者没有 */ @@ -769,7 +922,7 @@ @apply [&_tr:last-child]:border-0; } .table-row { - @apply border-b border-border transition-colors hover:bg-muted/80; + @apply border-b border-border transition-colors hover:bg-muted; } .table-head-cell { @apply h-12 px-4 text-left align-middle font-medium text-muted-foreground; @@ -777,4 +930,5 @@ .table-cell { @apply p-4 align-middle; } -} \ No newline at end of file +} + diff --git a/frontend/js/pages/logs/batchActions.js b/frontend/js/pages/logs/batchActions.js new file mode 100644 index 0000000..3fd9ae1 --- /dev/null +++ b/frontend/js/pages/logs/batchActions.js @@ -0,0 +1,151 @@ +// Filename: frontend/js/components/BatchActions.js +import { apiFetchJson } from '../../services/api.js'; + +// 存储对 LogsPage 实例的引用 +let logsPageInstance = null; + +// 存储对 DOM 元素的引用 +const elements = { + batchActionsBtn: null, + batchActionsMenu: null, + deleteSelectedLogsBtn: null, + clearAllLogsBtn: null, +}; + +// 用于处理页面点击以关闭菜单的绑定函数 +const handleDocumentClick = (event) => { + if (!elements.batchActionsMenu.contains(event.target) && !elements.batchActionsBtn.contains(event.target)) { + closeBatchActionsMenu(); + } +}; + +// 关闭菜单的逻辑 +function closeBatchActionsMenu() { + if (elements.batchActionsMenu && !elements.batchActionsMenu.classList.contains('hidden')) { + elements.batchActionsMenu.classList.remove('opacity-100', 'scale-100'); + elements.batchActionsMenu.classList.add('opacity-0', 'scale-95'); + setTimeout(() => { + elements.batchActionsMenu.classList.add('hidden'); + }, 100); + document.removeEventListener('click', handleDocumentClick); + } +} + +// 切换菜单显示/隐藏 +function handleBatchActionsToggle(event) { + event.stopPropagation(); + const isHidden = elements.batchActionsMenu.classList.contains('hidden'); + if (isHidden) { + elements.batchActionsMenu.classList.remove('hidden', 'opacity-0', 'scale-95'); + elements.batchActionsMenu.classList.add('opacity-100', 'scale-100'); + document.addEventListener('click', handleDocumentClick); + } else { + closeBatchActionsMenu(); + } +} + +// 处理删除选中日志的逻辑 +async function handleDeleteSelectedLogs() { + closeBatchActionsMenu(); + const selectedIds = Array.from(logsPageInstance.state.selectedLogIds); + if (selectedIds.length === 0) return; + + Swal.fire({ + width: '20rem', + backdrop: `rgba(0,0,0,0.5)`, + heightAuto: false, + customClass: { popup: `swal2-custom-style ${document.documentElement.classList.contains('dark') ? 'swal2-dark' : ''}` }, + title: '确认删除', + text: `您确定要删除选定的 ${selectedIds.length} 条日志吗?此操作不可撤销。`, + icon: 'warning', + showCancelButton: true, + confirmButtonText: '确认删除', + cancelButtonText: '取消', + reverseButtons: false, + confirmButtonColor: '#ef4444', + cancelButtonColor: '#6b7280', + focusCancel: true, + target: '#main-content-wrapper', + }).then(async (result) => { + if (result.isConfirmed) { + try { + const idsQueryString = selectedIds.join(','); + const url = `/admin/logs?ids=${idsQueryString}`; + const { success, message } = await apiFetchJson(url, { method: 'DELETE' }); + if (success) { + Swal.fire({ toast: true, position: 'top-end', icon: 'success', title: '删除成功', showConfirmButton: false, timer: 2000, timerProgressBar: true }); + logsPageInstance.loadAndRenderLogs(); // 使用实例刷新列表 + } else { + throw new Error(message || '删除失败,请稍后重试。'); + } + } catch (error) { + Swal.fire({ icon: 'error', title: '操作失败', text: error.message, target: '#main-content-wrapper' }); + } + } + }); +} + +// [NEW] 处理清空所有日志的逻辑 +async function handleClearAllLogs() { + closeBatchActionsMenu(); + + Swal.fire({ + width: '20rem', + backdrop: `rgba(0,0,0,0.5)`, + heightAuto: false, + customClass: { popup: `swal2-custom-style ${document.documentElement.classList.contains('dark') ? 'swal2-dark' : ''}` }, + title: '危险操作确认', + html: `您确定要清空全部日志吗?
此操作不可撤销!`, + icon: 'warning', + showCancelButton: true, + confirmButtonText: '确认清空', + cancelButtonText: '取消', + reverseButtons: false, + confirmButtonColor: '#ef4444', + cancelButtonColor: '#6b7280', + focusCancel: true, + target: '#main-content-wrapper', + }).then(async (result) => { + if (result.isConfirmed) { + try { + const url = `/admin/logs/all`; // 后端清空所有日志的接口 + const { success, message } = await apiFetchJson(url, { method: 'DELETE' }); + if (success) { + Swal.fire({ toast: true, position: 'top-end', icon: 'success', title: '清空成功', showConfirmButton: false, timer: 2000, timerProgressBar: true }); + logsPageInstance.loadAndRenderLogs(); // 刷新列表 + } else { + throw new Error(message || '清空失败,请稍后重试。'); + } + } catch (error) { + Swal.fire({ icon: 'error', title: '操作失败', text: error.message, target: '#main-content-wrapper' }); + } + } + }); +} + + +/** + * 初始化批量操作模块 + * @param {object} logsPage - LogsPage 类的实例 + */ +export function initBatchActions(logsPage) { + logsPageInstance = logsPage; + + // 查询所有需要的 DOM 元素 + elements.batchActionsBtn = document.getElementById('batch-actions-btn'); + elements.batchActionsMenu = document.getElementById('batch-actions-menu'); + elements.deleteSelectedLogsBtn = document.getElementById('delete-selected-logs-btn'); + elements.clearAllLogsBtn = document.getElementById('clear-all-logs-btn'); // [NEW] 查询新按钮 + + if (!elements.batchActionsBtn) return; // 如果找不到主按钮,则不进行任何操作 + + // 绑定事件监听器 + elements.batchActionsBtn.addEventListener('click', handleBatchActionsToggle); + if (elements.deleteSelectedLogsBtn) { + elements.deleteSelectedLogsBtn.addEventListener('click', handleDeleteSelectedLogs); + } + if (elements.clearAllLogsBtn) { // [NEW] 绑定新按钮的事件 + elements.clearAllLogsBtn.addEventListener('click', handleClearAllLogs); + } +} +// [NEW] - END diff --git a/frontend/js/pages/logs/index.js b/frontend/js/pages/logs/index.js index c23d4fd..b82cdc4 100644 --- a/frontend/js/pages/logs/index.js +++ b/frontend/js/pages/logs/index.js @@ -6,12 +6,13 @@ import { debounce } from '../../utils/utils.js'; import FilterPopover from '../../components/filterPopover.js'; import { STATIC_ERROR_MAP, STATUS_CODE_MAP } from './logList.js'; import SystemLogTerminal from './systemLog.js'; +import { initBatchActions } from './batchActions.js'; +import flatpickr from '../../vendor/flatpickr.js'; const dataStore = { groups: new Map(), keys: new Map(), -}; - +}; class LogsPage { constructor() { this.state = { @@ -25,7 +26,9 @@ class LogsPage { key_ids: new Set(), group_ids: new Set(), error_types: new Set(), - status_codes: new Set(), + status_codes: new Set(), + start_date: null, + end_date: null, }, selectedLogIds: new Set(), currentView: 'error', @@ -43,6 +46,8 @@ class LogsPage { this.logList = null; this.systemLogTerminal = null; this.debouncedLoadAndRender = debounce(() => this.loadAndRenderLogs(), 300); + this.fp = null; + this.themeObserver = null; } } async init() { @@ -69,6 +74,16 @@ class LogsPage { this.systemLogTerminal.disconnect(); this.systemLogTerminal = null; } + if (this.fp) { + this.fp.destroy(); + this.fp = null; + } + + if (this.themeObserver) { + this.themeObserver.disconnect(); + this.themeObserver = null; + } + this.state.currentView = viewName; this.elements.contentContainer.innerHTML = ''; if (viewName === 'error') { @@ -100,13 +115,42 @@ class LogsPage { this.elements.searchInput = document.getElementById('log-search-input'); this.elements.errorTypeFilterBtn = document.getElementById('filter-error-type-btn'); this.elements.errorCodeFilterBtn = document.getElementById('filter-error-code-btn'); + this.elements.dateRangeFilterBtn = document.getElementById('filter-date-range-btn'); + this.logList = new LogList(this.elements.tableBody, dataStore); const selectContainer = document.querySelector('[data-component="custom-select-v2"]'); if (selectContainer) { new CustomSelectV2(selectContainer); } + this.initFilterPopovers(); + this.initDateRangePicker(); this.initEventListeners(); + this._observeThemeChanges(); + initBatchActions(this); this.loadAndRenderLogs(); } + + _observeThemeChanges() { + const applyTheme = () => { + if (!this.fp || !this.fp.calendarContainer) return; + if (document.documentElement.classList.contains('dark')) { + this.fp.calendarContainer.classList.add('dark'); + } else { + this.fp.calendarContainer.classList.remove('dark'); + } + }; + this.themeObserver = new MutationObserver((mutationsList) => { + for (const mutation of mutationsList) { + if (mutation.type === 'attributes' && mutation.attributeName === 'class') { + applyTheme(); + } + } + }); + this.themeObserver.observe(document.documentElement, { attributes: true }); + + // 确保初始状态正确 + applyTheme(); + } + _initSystemLogView() { this.systemLogTerminal = new SystemLogTerminal( this.elements.contentContainer, @@ -116,9 +160,7 @@ class LogsPage { width: '20rem', backdrop: `rgba(0,0,0,0.5)`, heightAuto: false, - customClass: { - popup: `swal2-custom-style ${document.documentElement.classList.contains('dark') ? 'swal2-dark' : ''}` - }, + customClass: { popup: `swal2-custom-style ${document.documentElement.classList.contains('dark') ? 'swal2-dark' : ''}` }, title: '系统终端日志', text: '您即将连接到实时系统日志流窗口。', showCancelButton: true, @@ -153,6 +195,83 @@ class LogsPage { new FilterPopover(this.elements.errorCodeFilterBtn, statusCodeOptions, '筛选状态码'); } } + initDateRangePicker() { + if (!this.elements.dateRangeFilterBtn) return; + const buttonTextSpan = this.elements.dateRangeFilterBtn.querySelector('span'); + const originalText = buttonTextSpan.textContent; + this.fp = flatpickr(this.elements.dateRangeFilterBtn, { + mode: 'range', + dateFormat: 'Y-m-d', + onClose: (selectedDates) => { + if (selectedDates.length === 2) { + const [start, end] = selectedDates; + end.setHours(23, 59, 59, 999); + this.state.filters.start_date = start.toISOString(); + this.state.filters.end_date = end.toISOString(); + const startDateStr = start.toISOString().split('T')[0]; + const endDateStr = end.toISOString().split('T')[0]; + + buttonTextSpan.textContent = `${startDateStr} ~ ${endDateStr}`; + this.elements.dateRangeFilterBtn.classList.add('!border-primary', '!text-primary'); + this.state.filters.page = 1; + this.loadAndRenderLogs(); + } + }, + onReady: (selectedDates, dateStr, instance) => { + // 暗黑模式和清除按钮的现有逻辑保持不变 + if (document.documentElement.classList.contains('dark')) { + instance.calendarContainer.classList.add('dark'); + } + const clearButton = document.createElement('button'); + clearButton.textContent = '清除'; + clearButton.className = 'button flatpickr-button flatpickr-clear-button'; + clearButton.addEventListener('click', (e) => { + e.preventDefault(); + instance.clear(); + + this.state.filters.start_date = null; + this.state.filters.end_date = null; + buttonTextSpan.textContent = originalText; + this.elements.dateRangeFilterBtn.classList.remove('!border-primary', '!text-primary'); + + this.state.filters.page = 1; + this.loadAndRenderLogs(); + instance.close(); + }); + instance.calendarContainer.appendChild(clearButton); + const nativeMonthSelect = instance.monthsDropdownContainer; + if (!nativeMonthSelect) return; + const monthYearContainer = nativeMonthSelect.parentElement; + const wrapper = document.createElement('div'); + wrapper.className = 'custom-select-v2-container relative inline-block text-left'; + + wrapper.innerHTML = ` + + `; + + const template = document.createElement('template'); + template.className = 'custom-select-panel-template'; + + template.innerHTML = ` + + `; + nativeMonthSelect.classList.add('hidden'); + wrapper.appendChild(nativeMonthSelect); + wrapper.appendChild(template); + monthYearContainer.prepend(wrapper); + const customSelect = new CustomSelectV2(wrapper); + instance.customMonthSelect = customSelect; + }, + onMonthChange: (selectedDates, dateStr, instance) => { + if (instance.customMonthSelect) { + instance.customMonthSelect.updateTriggerText(); + } + }, + }); + } initEventListeners() { if (this.elements.pageSizeSelect) { this.elements.pageSizeSelect.addEventListener('change', (e) => this.changePageSize(parseInt(e.target.value, 10))); @@ -191,16 +310,12 @@ class LogsPage { this.state.filters.page = 1; this.loadAndRenderLogs(); } - handleSearchInput(event) { const searchTerm = event.target.value.trim().toLowerCase(); - - // 重置分页和与本次搜索相关的筛选条件 this.state.filters.page = 1; this.state.filters.q = ''; this.state.filters.key_ids = new Set(); this.state.filters.group_ids = new Set(); - if (searchTerm === '') { this.debouncedLoadAndRender(); return; @@ -219,13 +334,11 @@ class LogsPage { }); if (matchedGroupIds.size > 0) this.state.filters.group_ids = matchedGroupIds; if (matchedKeyIds.size > 0) this.state.filters.key_ids = matchedKeyIds; - // 如果没有找到任何匹配的ID,则回退到原始的全局模糊搜索 if (matchedGroupIds.size === 0 && matchedKeyIds.size === 0) { this.state.filters.q = searchTerm; } this.debouncedLoadAndRender(); } - handleSelectionChange(checkbox) { const row = checkbox.closest('.table-row'); if (!row) return; @@ -238,7 +351,6 @@ class LogsPage { } this.syncSelectionUI(); } - handleSelectAllChange(event) { const isChecked = event.target.checked; this.state.logs.forEach(log => { @@ -251,36 +363,35 @@ class LogsPage { this.syncRowCheckboxes(); this.syncSelectionUI(); } - syncRowCheckboxes() { const isAllChecked = this.elements.selectAllCheckbox.checked; this.elements.tableBody.querySelectorAll('input[type="checkbox"]').forEach(cb => { cb.checked = isAllChecked; }); } - syncSelectionUI() { if (!this.elements.selectAllCheckbox || !this.elements.selectedCount) return; const selectedCount = this.state.selectedLogIds.size; const visibleLogsCount = this.state.logs.length; - // 1. 更新表头“全选”复选框的状态 + if (selectedCount === 0) { this.elements.selectAllCheckbox.checked = false; this.elements.selectAllCheckbox.indeterminate = false; } else if (selectedCount < visibleLogsCount) { this.elements.selectAllCheckbox.checked = false; - this.elements.selectAllCheckbox.indeterminate = true; // 半选状态 + this.elements.selectAllCheckbox.indeterminate = true; } else if (selectedCount === visibleLogsCount && visibleLogsCount > 0) { this.elements.selectAllCheckbox.checked = true; this.elements.selectAllCheckbox.indeterminate = false; } - // 2. 更新“已选择”计数 + this.elements.selectedCount.textContent = selectedCount; - // 3. (未来扩展) 更新批量操作按钮的状态 - // const batchButton = document.querySelector('.batch-action-button'); - // if (batchButton) batchButton.disabled = selectedCount === 0; + const hasSelection = selectedCount > 0; + const deleteSelectedBtn = document.getElementById('delete-selected-logs-btn'); + if (deleteSelectedBtn) { + deleteSelectedBtn.disabled = !hasSelection; + } } - changePageSize(newSize) { this.state.filters.page_size = newSize; this.state.filters.page = 1; @@ -291,18 +402,15 @@ class LogsPage { this.state.filters.page = page; this.loadAndRenderLogs(); } - updatePaginationUI() { const { page, pages, total } = this.state.pagination; - if (this.elements.pageInfo) { this.elements.pageInfo.textContent = `第 ${page} / ${pages} 页`; } - if (this.elements.totalCount) { this.elements.totalCount.textContent = total; } - + if (this.elements.paginationBtns.length >= 4) { const isFirstPage = page === 1; const isLastPage = page === pages || pages === 0; @@ -312,7 +420,6 @@ class LogsPage { this.elements.paginationBtns[3].disabled = isLastPage; } } - async loadGroupsOnce() { if (dataStore.groups.size > 0) return; try { @@ -324,7 +431,6 @@ class LogsPage { console.error("Failed to load key groups:", error); } } - async loadAndRenderLogs() { this.state.isLoading = true; this.state.selectedLogIds.clear(); @@ -332,19 +438,15 @@ class LogsPage { this.updatePaginationUI(); this.syncSelectionUI(); try { - // --- 查询参数准备阶段 --- const finalParams = {}; const { filters } = this.state; - - // 1. 复制所有非 Set 类型的参数 + Object.keys(filters).forEach(key => { if (!(filters[key] instanceof Set)) { finalParams[key] = filters[key]; } }); - // 2. 翻译 'error_types' const translatedErrorCodes = new Set(); - // 从用户直接选择的状态码开始初始化 const translatedStatusCodes = new Set(filters.status_codes); if (filters.error_types.size > 0) { filters.error_types.forEach(type => { @@ -356,19 +458,23 @@ class LogsPage { } }); } - // 3. 统一处理所有 Set 类型的参数,转换为字符串 + if (filters.key_ids.size > 0) finalParams.key_ids = [...filters.key_ids].join(','); if (filters.group_ids.size > 0) finalParams.group_ids = [...filters.group_ids].join(','); if (translatedErrorCodes.size > 0) finalParams.error_codes = [...translatedErrorCodes].join(','); if (translatedStatusCodes.size > 0) finalParams.status_codes = [...translatedStatusCodes].join(','); - // 4. 清理空值 + Object.keys(finalParams).forEach(key => { if (finalParams[key] === '' || finalParams[key] === null || finalParams[key] === undefined) { delete finalParams[key]; } }); const query = new URLSearchParams(finalParams); - const { success, data } = await apiFetchJson(`/admin/logs?${query.toString()}`); + + const { success, data } = await apiFetchJson( + `/admin/logs?${query.toString()}`, + { cache: 'no-cache', noCache: true } + ); if (success && typeof data === 'object' && data.items) { const { items, total, page, page_size } = data; this.state.logs = items; @@ -392,10 +498,9 @@ class LogsPage { this.syncSelectionUI(); } } - async enrichLogsWithKeyNames(logs) { const missingKeyIds = [...new Set( - logs.filter(log => log.KeyID && !dataStore.keys.has(log.KeyID)).map(log => log.KeyID) + logs.filter(log => log.KeyID && !dataStore.keys.has(log.KeyID)).map(log => log.ID) )]; if (missingKeyIds.length === 0) return; try { @@ -409,8 +514,7 @@ class LogsPage { } } } - export default function() { const page = new LogsPage(); page.init(); -} +} \ No newline at end of file diff --git a/frontend/js/vendor/flatpickr.js b/frontend/js/vendor/flatpickr.js new file mode 100644 index 0000000..b0f59ec --- /dev/null +++ b/frontend/js/vendor/flatpickr.js @@ -0,0 +1,2 @@ +/* flatpickr v4.6.13,, @license MIT */ +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).flatpickr=n()}(this,(function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var n,t=1,a=arguments.length;t",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1},i={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(e){var n=e%100;if(n>3&&n<21)return"th";switch(n%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",monthAriaLabel:"Month",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1},o=function(e,n){return void 0===n&&(n=2),("000"+e).slice(-1*n)},r=function(e){return!0===e?1:0};function l(e,n){var t;return function(){var a=this,i=arguments;clearTimeout(t),t=setTimeout((function(){return e.apply(a,i)}),n)}}var c=function(e){return e instanceof Array?e:[e]};function s(e,n,t){if(!0===t)return e.classList.add(n);e.classList.remove(n)}function d(e,n,t){var a=window.document.createElement(e);return n=n||"",t=t||"",a.className=n,void 0!==t&&(a.textContent=t),a}function u(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function f(e,n){return n(e)?e:e.parentNode?f(e.parentNode,n):void 0}function m(e,n){var t=d("div","numInputWrapper"),a=d("input","numInput "+e),i=d("span","arrowUp"),o=d("span","arrowDown");if(-1===navigator.userAgent.indexOf("MSIE 9.0")?a.type="number":(a.type="text",a.pattern="\\d*"),void 0!==n)for(var r in n)a.setAttribute(r,n[r]);return t.appendChild(a),t.appendChild(i),t.appendChild(o),t}function g(e){try{return"function"==typeof e.composedPath?e.composedPath()[0]:e.target}catch(n){return e.target}}var p=function(){},h=function(e,n,t){return t.months[n?"shorthand":"longhand"][e]},v={D:p,F:function(e,n,t){e.setMonth(t.months.longhand.indexOf(n))},G:function(e,n){e.setHours((e.getHours()>=12?12:0)+parseFloat(n))},H:function(e,n){e.setHours(parseFloat(n))},J:function(e,n){e.setDate(parseFloat(n))},K:function(e,n,t){e.setHours(e.getHours()%12+12*r(new RegExp(t.amPM[1],"i").test(n)))},M:function(e,n,t){e.setMonth(t.months.shorthand.indexOf(n))},S:function(e,n){e.setSeconds(parseFloat(n))},U:function(e,n){return new Date(1e3*parseFloat(n))},W:function(e,n,t){var a=parseInt(n),i=new Date(e.getFullYear(),0,2+7*(a-1),0,0,0,0);return i.setDate(i.getDate()-i.getDay()+t.firstDayOfWeek),i},Y:function(e,n){e.setFullYear(parseFloat(n))},Z:function(e,n){return new Date(n)},d:function(e,n){e.setDate(parseFloat(n))},h:function(e,n){e.setHours((e.getHours()>=12?12:0)+parseFloat(n))},i:function(e,n){e.setMinutes(parseFloat(n))},j:function(e,n){e.setDate(parseFloat(n))},l:p,m:function(e,n){e.setMonth(parseFloat(n)-1)},n:function(e,n){e.setMonth(parseFloat(n)-1)},s:function(e,n){e.setSeconds(parseFloat(n))},u:function(e,n){return new Date(parseFloat(n))},w:p,y:function(e,n){e.setFullYear(2e3+parseFloat(n))}},D={D:"",F:"",G:"(\\d\\d|\\d)",H:"(\\d\\d|\\d)",J:"(\\d\\d|\\d)\\w+",K:"",M:"",S:"(\\d\\d|\\d)",U:"(.+)",W:"(\\d\\d|\\d)",Y:"(\\d{4})",Z:"(.+)",d:"(\\d\\d|\\d)",h:"(\\d\\d|\\d)",i:"(\\d\\d|\\d)",j:"(\\d\\d|\\d)",l:"",m:"(\\d\\d|\\d)",n:"(\\d\\d|\\d)",s:"(\\d\\d|\\d)",u:"(.+)",w:"(\\d\\d|\\d)",y:"(\\d{2})"},w={Z:function(e){return e.toISOString()},D:function(e,n,t){return n.weekdays.shorthand[w.w(e,n,t)]},F:function(e,n,t){return h(w.n(e,n,t)-1,!1,n)},G:function(e,n,t){return o(w.h(e,n,t))},H:function(e){return o(e.getHours())},J:function(e,n){return void 0!==n.ordinal?e.getDate()+n.ordinal(e.getDate()):e.getDate()},K:function(e,n){return n.amPM[r(e.getHours()>11)]},M:function(e,n){return h(e.getMonth(),!0,n)},S:function(e){return o(e.getSeconds())},U:function(e){return e.getTime()/1e3},W:function(e,n,t){return t.getWeek(e)},Y:function(e){return o(e.getFullYear(),4)},d:function(e){return o(e.getDate())},h:function(e){return e.getHours()%12?e.getHours()%12:12},i:function(e){return o(e.getMinutes())},j:function(e){return e.getDate()},l:function(e,n){return n.weekdays.longhand[e.getDay()]},m:function(e){return o(e.getMonth()+1)},n:function(e){return e.getMonth()+1},s:function(e){return e.getSeconds()},u:function(e){return e.getTime()},w:function(e){return e.getDay()},y:function(e){return String(e.getFullYear()).substring(2)}},b=function(e){var n=e.config,t=void 0===n?a:n,o=e.l10n,r=void 0===o?i:o,l=e.isMobile,c=void 0!==l&&l;return function(e,n,a){var i=a||r;return void 0===t.formatDate||c?n.split("").map((function(n,a,o){return w[n]&&"\\"!==o[a-1]?w[n](e,i,t):"\\"!==n?n:""})).join(""):t.formatDate(e,n,i)}},C=function(e){var n=e.config,t=void 0===n?a:n,o=e.l10n,r=void 0===o?i:o;return function(e,n,i,o){if(0===e||e){var l,c=o||r,s=e;if(e instanceof Date)l=new Date(e.getTime());else if("string"!=typeof e&&void 0!==e.toFixed)l=new Date(e);else if("string"==typeof e){var d=n||(t||a).dateFormat,u=String(e).trim();if("today"===u)l=new Date,i=!0;else if(t&&t.parseDate)l=t.parseDate(e,d);else if(/Z$/.test(u)||/GMT$/.test(u))l=new Date(e);else{for(var f=void 0,m=[],g=0,p=0,h="";g=0?new Date:new Date(w.config.minDate.getTime()),t=E(w.config);n.setHours(t.hours,t.minutes,t.seconds,n.getMilliseconds()),w.selectedDates=[n],w.latestSelectedDateObj=n}void 0!==e&&"blur"!==e.type&&function(e){e.preventDefault();var n="keydown"===e.type,t=g(e),a=t;void 0!==w.amPM&&t===w.amPM&&(w.amPM.textContent=w.l10n.amPM[r(w.amPM.textContent===w.l10n.amPM[0])]);var i=parseFloat(a.getAttribute("min")),l=parseFloat(a.getAttribute("max")),c=parseFloat(a.getAttribute("step")),s=parseInt(a.value,10),d=e.delta||(n?38===e.which?1:-1:0),u=s+c*d;if(void 0!==a.value&&2===a.value.length){var f=a===w.hourElement,m=a===w.minuteElement;ul&&(u=a===w.hourElement?u-l-r(!w.amPM):i,m&&L(void 0,1,w.hourElement)),w.amPM&&f&&(1===c?u+s===23:Math.abs(u-s)>c)&&(w.amPM.textContent=w.l10n.amPM[r(w.amPM.textContent===w.l10n.amPM[0])]),a.value=o(u)}}(e);var a=w._input.value;O(),ye(),w._input.value!==a&&w._debouncedChange()}function O(){if(void 0!==w.hourElement&&void 0!==w.minuteElement){var e,n,t=(parseInt(w.hourElement.value.slice(-2),10)||0)%24,a=(parseInt(w.minuteElement.value,10)||0)%60,i=void 0!==w.secondElement?(parseInt(w.secondElement.value,10)||0)%60:0;void 0!==w.amPM&&(e=t,n=w.amPM.textContent,t=e%12+12*r(n===w.l10n.amPM[1]));var o=void 0!==w.config.minTime||w.config.minDate&&w.minDateHasTime&&w.latestSelectedDateObj&&0===M(w.latestSelectedDateObj,w.config.minDate,!0),l=void 0!==w.config.maxTime||w.config.maxDate&&w.maxDateHasTime&&w.latestSelectedDateObj&&0===M(w.latestSelectedDateObj,w.config.maxDate,!0);if(void 0!==w.config.maxTime&&void 0!==w.config.minTime&&w.config.minTime>w.config.maxTime){var c=y(w.config.minTime.getHours(),w.config.minTime.getMinutes(),w.config.minTime.getSeconds()),s=y(w.config.maxTime.getHours(),w.config.maxTime.getMinutes(),w.config.maxTime.getSeconds()),d=y(t,a,i);if(d>s&&d=12)]),void 0!==w.secondElement&&(w.secondElement.value=o(t)))}function N(e){var n=g(e),t=parseInt(n.value)+(e.delta||0);(t/1e3>1||"Enter"===e.key&&!/[^\d]/.test(t.toString()))&&ee(t)}function P(e,n,t,a){return n instanceof Array?n.forEach((function(n){return P(e,n,t,a)})):e instanceof Array?e.forEach((function(e){return P(e,n,t,a)})):(e.addEventListener(n,t,a),void w._handlers.push({remove:function(){return e.removeEventListener(n,t,a)}}))}function Y(){De("onChange")}function j(e,n){var t=void 0!==e?w.parseDate(e):w.latestSelectedDateObj||(w.config.minDate&&w.config.minDate>w.now?w.config.minDate:w.config.maxDate&&w.config.maxDate=0&&M(e,w.selectedDates[1])<=0)}(n)&&!be(n)&&o.classList.add("inRange"),w.weekNumbers&&1===w.config.showMonths&&"prevMonthDay"!==e&&a%7==6&&w.weekNumbers.insertAdjacentHTML("beforeend",""+w.config.getWeek(n)+""),De("onDayCreate",o),o}function W(e){e.focus(),"range"===w.config.mode&&oe(e)}function B(e){for(var n=e>0?0:w.config.showMonths-1,t=e>0?w.config.showMonths:-1,a=n;a!=t;a+=e)for(var i=w.daysContainer.children[a],o=e>0?0:i.children.length-1,r=e>0?i.children.length:-1,l=o;l!=r;l+=e){var c=i.children[l];if(-1===c.className.indexOf("hidden")&&ne(c.dateObj))return c}}function J(e,n){var t=k(),a=te(t||document.body),i=void 0!==e?e:a?t:void 0!==w.selectedDateElem&&te(w.selectedDateElem)?w.selectedDateElem:void 0!==w.todayDateElem&&te(w.todayDateElem)?w.todayDateElem:B(n>0?1:-1);void 0===i?w._input.focus():a?function(e,n){for(var t=-1===e.className.indexOf("Month")?e.dateObj.getMonth():w.currentMonth,a=n>0?w.config.showMonths:-1,i=n>0?1:-1,o=t-w.currentMonth;o!=a;o+=i)for(var r=w.daysContainer.children[o],l=t-w.currentMonth===o?e.$i+n:n<0?r.children.length-1:0,c=r.children.length,s=l;s>=0&&s0?c:-1);s+=i){var d=r.children[s];if(-1===d.className.indexOf("hidden")&&ne(d.dateObj)&&Math.abs(e.$i-s)>=Math.abs(n))return W(d)}w.changeMonth(i),J(B(i),0)}(i,n):W(i)}function K(e,n){for(var t=(new Date(e,n,1).getDay()-w.l10n.firstDayOfWeek+7)%7,a=w.utils.getDaysInMonth((n-1+12)%12,e),i=w.utils.getDaysInMonth(n,e),o=window.document.createDocumentFragment(),r=w.config.showMonths>1,l=r?"prevMonthDay hidden":"prevMonthDay",c=r?"nextMonthDay hidden":"nextMonthDay",s=a+1-t,u=0;s<=a;s++,u++)o.appendChild(R("flatpickr-day "+l,new Date(e,n-1,s),0,u));for(s=1;s<=i;s++,u++)o.appendChild(R("flatpickr-day",new Date(e,n,s),0,u));for(var f=i+1;f<=42-t&&(1===w.config.showMonths||u%7!=0);f++,u++)o.appendChild(R("flatpickr-day "+c,new Date(e,n+1,f%i),0,u));var m=d("div","dayContainer");return m.appendChild(o),m}function U(){if(void 0!==w.daysContainer){u(w.daysContainer),w.weekNumbers&&u(w.weekNumbers);for(var e=document.createDocumentFragment(),n=0;n1||"dropdown"!==w.config.monthSelectorType)){var e=function(e){return!(void 0!==w.config.minDate&&w.currentYear===w.config.minDate.getFullYear()&&ew.config.maxDate.getMonth())};w.monthsDropdownContainer.tabIndex=-1,w.monthsDropdownContainer.innerHTML="";for(var n=0;n<12;n++)if(e(n)){var t=d("option","flatpickr-monthDropdown-month");t.value=new Date(w.currentYear,n).getMonth().toString(),t.textContent=h(n,w.config.shorthandCurrentMonth,w.l10n),t.tabIndex=-1,w.currentMonth===n&&(t.selected=!0),w.monthsDropdownContainer.appendChild(t)}}}function $(){var e,n=d("div","flatpickr-month"),t=window.document.createDocumentFragment();w.config.showMonths>1||"static"===w.config.monthSelectorType?e=d("span","cur-month"):(w.monthsDropdownContainer=d("select","flatpickr-monthDropdown-months"),w.monthsDropdownContainer.setAttribute("aria-label",w.l10n.monthAriaLabel),P(w.monthsDropdownContainer,"change",(function(e){var n=g(e),t=parseInt(n.value,10);w.changeMonth(t-w.currentMonth),De("onMonthChange")})),q(),e=w.monthsDropdownContainer);var a=m("cur-year",{tabindex:"-1"}),i=a.getElementsByTagName("input")[0];i.setAttribute("aria-label",w.l10n.yearAriaLabel),w.config.minDate&&i.setAttribute("min",w.config.minDate.getFullYear().toString()),w.config.maxDate&&(i.setAttribute("max",w.config.maxDate.getFullYear().toString()),i.disabled=!!w.config.minDate&&w.config.minDate.getFullYear()===w.config.maxDate.getFullYear());var o=d("div","flatpickr-current-month");return o.appendChild(e),o.appendChild(a),t.appendChild(o),n.appendChild(t),{container:n,yearElement:i,monthElement:e}}function V(){u(w.monthNav),w.monthNav.appendChild(w.prevMonthNav),w.config.showMonths&&(w.yearElements=[],w.monthElements=[]);for(var e=w.config.showMonths;e--;){var n=$();w.yearElements.push(n.yearElement),w.monthElements.push(n.monthElement),w.monthNav.appendChild(n.container)}w.monthNav.appendChild(w.nextMonthNav)}function z(){w.weekdayContainer?u(w.weekdayContainer):w.weekdayContainer=d("div","flatpickr-weekdays");for(var e=w.config.showMonths;e--;){var n=d("div","flatpickr-weekdaycontainer");w.weekdayContainer.appendChild(n)}return G(),w.weekdayContainer}function G(){if(w.weekdayContainer){var e=w.l10n.firstDayOfWeek,t=n(w.l10n.weekdays.shorthand);e>0&&e\n "+t.join("")+"\n \n "}}function Z(e,n){void 0===n&&(n=!0);var t=n?e:e-w.currentMonth;t<0&&!0===w._hidePrevMonthArrow||t>0&&!0===w._hideNextMonthArrow||(w.currentMonth+=t,(w.currentMonth<0||w.currentMonth>11)&&(w.currentYear+=w.currentMonth>11?1:-1,w.currentMonth=(w.currentMonth+12)%12,De("onYearChange"),q()),U(),De("onMonthChange"),Ce())}function Q(e){return w.calendarContainer.contains(e)}function X(e){if(w.isOpen&&!w.config.inline){var n=g(e),t=Q(n),a=!(n===w.input||n===w.altInput||w.element.contains(n)||e.path&&e.path.indexOf&&(~e.path.indexOf(w.input)||~e.path.indexOf(w.altInput)))&&!t&&!Q(e.relatedTarget),i=!w.config.ignoredFocusElements.some((function(e){return e.contains(n)}));a&&i&&(w.config.allowInput&&w.setDate(w._input.value,!1,w.config.altInput?w.config.altFormat:w.config.dateFormat),void 0!==w.timeContainer&&void 0!==w.minuteElement&&void 0!==w.hourElement&&""!==w.input.value&&void 0!==w.input.value&&_(),w.close(),w.config&&"range"===w.config.mode&&1===w.selectedDates.length&&w.clear(!1))}}function ee(e){if(!(!e||w.config.minDate&&ew.config.maxDate.getFullYear())){var n=e,t=w.currentYear!==n;w.currentYear=n||w.currentYear,w.config.maxDate&&w.currentYear===w.config.maxDate.getFullYear()?w.currentMonth=Math.min(w.config.maxDate.getMonth(),w.currentMonth):w.config.minDate&&w.currentYear===w.config.minDate.getFullYear()&&(w.currentMonth=Math.max(w.config.minDate.getMonth(),w.currentMonth)),t&&(w.redraw(),De("onYearChange"),q())}}function ne(e,n){var t;void 0===n&&(n=!0);var a=w.parseDate(e,void 0,n);if(w.config.minDate&&a&&M(a,w.config.minDate,void 0!==n?n:!w.minDateHasTime)<0||w.config.maxDate&&a&&M(a,w.config.maxDate,void 0!==n?n:!w.maxDateHasTime)>0)return!1;if(!w.config.enable&&0===w.config.disable.length)return!0;if(void 0===a)return!1;for(var i=!!w.config.enable,o=null!==(t=w.config.enable)&&void 0!==t?t:w.config.disable,r=0,l=void 0;r=l.from.getTime()&&a.getTime()<=l.to.getTime())return i}return!i}function te(e){return void 0!==w.daysContainer&&(-1===e.className.indexOf("hidden")&&-1===e.className.indexOf("flatpickr-disabled")&&w.daysContainer.contains(e))}function ae(e){var n=e.target===w._input,t=w._input.value.trimEnd()!==Me();!n||!t||e.relatedTarget&&Q(e.relatedTarget)||w.setDate(w._input.value,!0,e.target===w.altInput?w.config.altFormat:w.config.dateFormat)}function ie(e){var n=g(e),t=w.config.wrap?p.contains(n):n===w._input,a=w.config.allowInput,i=w.isOpen&&(!a||!t),o=w.config.inline&&t&&!a;if(13===e.keyCode&&t){if(a)return w.setDate(w._input.value,!0,n===w.altInput?w.config.altFormat:w.config.dateFormat),w.close(),n.blur();w.open()}else if(Q(n)||i||o){var r=!!w.timeContainer&&w.timeContainer.contains(n);switch(e.keyCode){case 13:r?(e.preventDefault(),_(),fe()):me(e);break;case 27:e.preventDefault(),fe();break;case 8:case 46:t&&!w.config.allowInput&&(e.preventDefault(),w.clear());break;case 37:case 39:if(r||t)w.hourElement&&w.hourElement.focus();else{e.preventDefault();var l=k();if(void 0!==w.daysContainer&&(!1===a||l&&te(l))){var c=39===e.keyCode?1:-1;e.ctrlKey?(e.stopPropagation(),Z(c),J(B(1),0)):J(void 0,c)}}break;case 38:case 40:e.preventDefault();var s=40===e.keyCode?1:-1;w.daysContainer&&void 0!==n.$i||n===w.input||n===w.altInput?e.ctrlKey?(e.stopPropagation(),ee(w.currentYear-s),J(B(1),0)):r||J(void 0,7*s):n===w.currentYearElement?ee(w.currentYear-s):w.config.enableTime&&(!r&&w.hourElement&&w.hourElement.focus(),_(e),w._debouncedChange());break;case 9:if(r){var d=[w.hourElement,w.minuteElement,w.secondElement,w.amPM].concat(w.pluginElements).filter((function(e){return e})),u=d.indexOf(n);if(-1!==u){var f=d[u+(e.shiftKey?-1:1)];e.preventDefault(),(f||w._input).focus()}}else!w.config.noCalendar&&w.daysContainer&&w.daysContainer.contains(n)&&e.shiftKey&&(e.preventDefault(),w._input.focus())}}if(void 0!==w.amPM&&n===w.amPM)switch(e.key){case w.l10n.amPM[0].charAt(0):case w.l10n.amPM[0].charAt(0).toLowerCase():w.amPM.textContent=w.l10n.amPM[0],O(),ye();break;case w.l10n.amPM[1].charAt(0):case w.l10n.amPM[1].charAt(0).toLowerCase():w.amPM.textContent=w.l10n.amPM[1],O(),ye()}(t||Q(n))&&De("onKeyDown",e)}function oe(e,n){if(void 0===n&&(n="flatpickr-day"),1===w.selectedDates.length&&(!e||e.classList.contains(n)&&!e.classList.contains("flatpickr-disabled"))){for(var t=e?e.dateObj.getTime():w.days.firstElementChild.dateObj.getTime(),a=w.parseDate(w.selectedDates[0],void 0,!0).getTime(),i=Math.min(t,w.selectedDates[0].getTime()),o=Math.max(t,w.selectedDates[0].getTime()),r=!1,l=0,c=0,s=i;si&&sl)?l=s:s>a&&(!c||s ."+n)).forEach((function(n){var i,o,s,d=n.dateObj.getTime(),u=l>0&&d0&&d>c;if(u)return n.classList.add("notAllowed"),void["inRange","startRange","endRange"].forEach((function(e){n.classList.remove(e)}));r&&!u||(["startRange","inRange","endRange","notAllowed"].forEach((function(e){n.classList.remove(e)})),void 0!==e&&(e.classList.add(t<=w.selectedDates[0].getTime()?"startRange":"endRange"),at&&d===a&&n.classList.add("endRange"),d>=l&&(0===c||d<=c)&&(o=a,s=t,(i=d)>Math.min(o,s)&&i0||t.getMinutes()>0||t.getSeconds()>0),w.selectedDates&&(w.selectedDates=w.selectedDates.filter((function(e){return ne(e)})),w.selectedDates.length||"min"!==e||F(t),ye()),w.daysContainer&&(ue(),void 0!==t?w.currentYearElement[e]=t.getFullYear().toString():w.currentYearElement.removeAttribute(e),w.currentYearElement.disabled=!!a&&void 0!==t&&a.getFullYear()===t.getFullYear())}}function ce(){return w.config.wrap?p.querySelector("[data-input]"):p}function se(){"object"!=typeof w.config.locale&&void 0===I.l10ns[w.config.locale]&&w.config.errorHandler(new Error("flatpickr: invalid locale "+w.config.locale)),w.l10n=e(e({},I.l10ns.default),"object"==typeof w.config.locale?w.config.locale:"default"!==w.config.locale?I.l10ns[w.config.locale]:void 0),D.D="("+w.l10n.weekdays.shorthand.join("|")+")",D.l="("+w.l10n.weekdays.longhand.join("|")+")",D.M="("+w.l10n.months.shorthand.join("|")+")",D.F="("+w.l10n.months.longhand.join("|")+")",D.K="("+w.l10n.amPM[0]+"|"+w.l10n.amPM[1]+"|"+w.l10n.amPM[0].toLowerCase()+"|"+w.l10n.amPM[1].toLowerCase()+")",void 0===e(e({},v),JSON.parse(JSON.stringify(p.dataset||{}))).time_24hr&&void 0===I.defaultConfig.time_24hr&&(w.config.time_24hr=w.l10n.time_24hr),w.formatDate=b(w),w.parseDate=C({config:w.config,l10n:w.l10n})}function de(e){if("function"!=typeof w.config.position){if(void 0!==w.calendarContainer){De("onPreCalendarPosition");var n=e||w._positionElement,t=Array.prototype.reduce.call(w.calendarContainer.children,(function(e,n){return e+n.offsetHeight}),0),a=w.calendarContainer.offsetWidth,i=w.config.position.split(" "),o=i[0],r=i.length>1?i[1]:null,l=n.getBoundingClientRect(),c=window.innerHeight-l.bottom,d="above"===o||"below"!==o&&ct,u=window.pageYOffset+l.top+(d?-t-2:n.offsetHeight+2);if(s(w.calendarContainer,"arrowTop",!d),s(w.calendarContainer,"arrowBottom",d),!w.config.inline){var f=window.pageXOffset+l.left,m=!1,g=!1;"center"===r?(f-=(a-l.width)/2,m=!0):"right"===r&&(f-=a-l.width,g=!0),s(w.calendarContainer,"arrowLeft",!m&&!g),s(w.calendarContainer,"arrowCenter",m),s(w.calendarContainer,"arrowRight",g);var p=window.document.body.offsetWidth-(window.pageXOffset+l.right),h=f+a>window.document.body.offsetWidth,v=p+a>window.document.body.offsetWidth;if(s(w.calendarContainer,"rightMost",h),!w.config.static)if(w.calendarContainer.style.top=u+"px",h)if(v){var D=function(){for(var e=null,n=0;nw.currentMonth+w.config.showMonths-1)&&"range"!==w.config.mode;if(w.selectedDateElem=t,"single"===w.config.mode)w.selectedDates=[a];else if("multiple"===w.config.mode){var o=be(a);o?w.selectedDates.splice(parseInt(o),1):w.selectedDates.push(a)}else"range"===w.config.mode&&(2===w.selectedDates.length&&w.clear(!1,!1),w.latestSelectedDateObj=a,w.selectedDates.push(a),0!==M(a,w.selectedDates[0],!0)&&w.selectedDates.sort((function(e,n){return e.getTime()-n.getTime()})));if(O(),i){var r=w.currentYear!==a.getFullYear();w.currentYear=a.getFullYear(),w.currentMonth=a.getMonth(),r&&(De("onYearChange"),q()),De("onMonthChange")}if(Ce(),U(),ye(),i||"range"===w.config.mode||1!==w.config.showMonths?void 0!==w.selectedDateElem&&void 0===w.hourElement&&w.selectedDateElem&&w.selectedDateElem.focus():W(t),void 0!==w.hourElement&&void 0!==w.hourElement&&w.hourElement.focus(),w.config.closeOnSelect){var l="single"===w.config.mode&&!w.config.enableTime,c="range"===w.config.mode&&2===w.selectedDates.length&&!w.config.enableTime;(l||c)&&fe()}Y()}}w.parseDate=C({config:w.config,l10n:w.l10n}),w._handlers=[],w.pluginElements=[],w.loadedPlugins=[],w._bind=P,w._setHoursFromDate=F,w._positionCalendar=de,w.changeMonth=Z,w.changeYear=ee,w.clear=function(e,n){void 0===e&&(e=!0);void 0===n&&(n=!0);w.input.value="",void 0!==w.altInput&&(w.altInput.value="");void 0!==w.mobileInput&&(w.mobileInput.value="");w.selectedDates=[],w.latestSelectedDateObj=void 0,!0===n&&(w.currentYear=w._initialDate.getFullYear(),w.currentMonth=w._initialDate.getMonth());if(!0===w.config.enableTime){var t=E(w.config),a=t.hours,i=t.minutes,o=t.seconds;A(a,i,o)}w.redraw(),e&&De("onChange")},w.close=function(){w.isOpen=!1,w.isMobile||(void 0!==w.calendarContainer&&w.calendarContainer.classList.remove("open"),void 0!==w._input&&w._input.classList.remove("active"));De("onClose")},w.onMouseOver=oe,w._createElement=d,w.createDay=R,w.destroy=function(){void 0!==w.config&&De("onDestroy");for(var e=w._handlers.length;e--;)w._handlers[e].remove();if(w._handlers=[],w.mobileInput)w.mobileInput.parentNode&&w.mobileInput.parentNode.removeChild(w.mobileInput),w.mobileInput=void 0;else if(w.calendarContainer&&w.calendarContainer.parentNode)if(w.config.static&&w.calendarContainer.parentNode){var n=w.calendarContainer.parentNode;if(n.lastChild&&n.removeChild(n.lastChild),n.parentNode){for(;n.firstChild;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode.removeChild(n)}}else w.calendarContainer.parentNode.removeChild(w.calendarContainer);w.altInput&&(w.input.type="text",w.altInput.parentNode&&w.altInput.parentNode.removeChild(w.altInput),delete w.altInput);w.input&&(w.input.type=w.input._type,w.input.classList.remove("flatpickr-input"),w.input.removeAttribute("readonly"));["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","monthsDropdownContainer","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach((function(e){try{delete w[e]}catch(e){}}))},w.isEnabled=ne,w.jumpToDate=j,w.updateValue=ye,w.open=function(e,n){void 0===n&&(n=w._positionElement);if(!0===w.isMobile){if(e){e.preventDefault();var t=g(e);t&&t.blur()}return void 0!==w.mobileInput&&(w.mobileInput.focus(),w.mobileInput.click()),void De("onOpen")}if(w._input.disabled||w.config.inline)return;var a=w.isOpen;w.isOpen=!0,a||(w.calendarContainer.classList.add("open"),w._input.classList.add("active"),De("onOpen"),de(n));!0===w.config.enableTime&&!0===w.config.noCalendar&&(!1!==w.config.allowInput||void 0!==e&&w.timeContainer.contains(e.relatedTarget)||setTimeout((function(){return w.hourElement.select()}),50))},w.redraw=ue,w.set=function(e,n){if(null!==e&&"object"==typeof e)for(var a in Object.assign(w.config,e),e)void 0!==ge[a]&&ge[a].forEach((function(e){return e()}));else w.config[e]=n,void 0!==ge[e]?ge[e].forEach((function(e){return e()})):t.indexOf(e)>-1&&(w.config[e]=c(n));w.redraw(),ye(!0)},w.setDate=function(e,n,t){void 0===n&&(n=!1);void 0===t&&(t=w.config.dateFormat);if(0!==e&&!e||e instanceof Array&&0===e.length)return w.clear(n);pe(e,t),w.latestSelectedDateObj=w.selectedDates[w.selectedDates.length-1],w.redraw(),j(void 0,n),F(),0===w.selectedDates.length&&w.clear(!1);ye(n),n&&De("onChange")},w.toggle=function(e){if(!0===w.isOpen)return w.close();w.open(e)};var ge={locale:[se,G],showMonths:[V,S,z],minDate:[j],maxDate:[j],positionElement:[ve],clickOpens:[function(){!0===w.config.clickOpens?(P(w._input,"focus",w.open),P(w._input,"click",w.open)):(w._input.removeEventListener("focus",w.open),w._input.removeEventListener("click",w.open))}]};function pe(e,n){var t=[];if(e instanceof Array)t=e.map((function(e){return w.parseDate(e,n)}));else if(e instanceof Date||"number"==typeof e)t=[w.parseDate(e,n)];else if("string"==typeof e)switch(w.config.mode){case"single":case"time":t=[w.parseDate(e,n)];break;case"multiple":t=e.split(w.config.conjunction).map((function(e){return w.parseDate(e,n)}));break;case"range":t=e.split(w.l10n.rangeSeparator).map((function(e){return w.parseDate(e,n)}))}else w.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(e)));w.selectedDates=w.config.allowInvalidPreload?t:t.filter((function(e){return e instanceof Date&&ne(e,!1)})),"range"===w.config.mode&&w.selectedDates.sort((function(e,n){return e.getTime()-n.getTime()}))}function he(e){return e.slice().map((function(e){return"string"==typeof e||"number"==typeof e||e instanceof Date?w.parseDate(e,void 0,!0):e&&"object"==typeof e&&e.from&&e.to?{from:w.parseDate(e.from,void 0),to:w.parseDate(e.to,void 0)}:e})).filter((function(e){return e}))}function ve(){w._positionElement=w.config.positionElement||w._input}function De(e,n){if(void 0!==w.config){var t=w.config[e];if(void 0!==t&&t.length>0)for(var a=0;t[a]&&a1||"static"===w.config.monthSelectorType?w.monthElements[n].textContent=h(t.getMonth(),w.config.shorthandCurrentMonth,w.l10n)+" ":w.monthsDropdownContainer.value=t.getMonth().toString(),e.value=t.getFullYear().toString()})),w._hidePrevMonthArrow=void 0!==w.config.minDate&&(w.currentYear===w.config.minDate.getFullYear()?w.currentMonth<=w.config.minDate.getMonth():w.currentYearw.config.maxDate.getMonth():w.currentYear>w.config.maxDate.getFullYear()))}function Me(e){var n=e||(w.config.altInput?w.config.altFormat:w.config.dateFormat);return w.selectedDates.map((function(e){return w.formatDate(e,n)})).filter((function(e,n,t){return"range"!==w.config.mode||w.config.enableTime||t.indexOf(e)===n})).join("range"!==w.config.mode?w.config.conjunction:w.l10n.rangeSeparator)}function ye(e){void 0===e&&(e=!0),void 0!==w.mobileInput&&w.mobileFormatStr&&(w.mobileInput.value=void 0!==w.latestSelectedDateObj?w.formatDate(w.latestSelectedDateObj,w.mobileFormatStr):""),w.input.value=Me(w.config.dateFormat),void 0!==w.altInput&&(w.altInput.value=Me(w.config.altFormat)),!1!==e&&De("onValueUpdate")}function xe(e){var n=g(e),t=w.prevMonthNav.contains(n),a=w.nextMonthNav.contains(n);t||a?Z(t?-1:1):w.yearElements.indexOf(n)>=0?n.select():n.classList.contains("arrowUp")?w.changeYear(w.currentYear+1):n.classList.contains("arrowDown")&&w.changeYear(w.currentYear-1)}return function(){w.element=w.input=p,w.isOpen=!1,function(){var n=["wrap","weekNumbers","allowInput","allowInvalidPreload","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],i=e(e({},JSON.parse(JSON.stringify(p.dataset||{}))),v),o={};w.config.parseDate=i.parseDate,w.config.formatDate=i.formatDate,Object.defineProperty(w.config,"enable",{get:function(){return w.config._enable},set:function(e){w.config._enable=he(e)}}),Object.defineProperty(w.config,"disable",{get:function(){return w.config._disable},set:function(e){w.config._disable=he(e)}});var r="time"===i.mode;if(!i.dateFormat&&(i.enableTime||r)){var l=I.defaultConfig.dateFormat||a.dateFormat;o.dateFormat=i.noCalendar||r?"H:i"+(i.enableSeconds?":S":""):l+" H:i"+(i.enableSeconds?":S":"")}if(i.altInput&&(i.enableTime||r)&&!i.altFormat){var s=I.defaultConfig.altFormat||a.altFormat;o.altFormat=i.noCalendar||r?"h:i"+(i.enableSeconds?":S K":" K"):s+" h:i"+(i.enableSeconds?":S":"")+" K"}Object.defineProperty(w.config,"minDate",{get:function(){return w.config._minDate},set:le("min")}),Object.defineProperty(w.config,"maxDate",{get:function(){return w.config._maxDate},set:le("max")});var d=function(e){return function(n){w.config["min"===e?"_minTime":"_maxTime"]=w.parseDate(n,"H:i:S")}};Object.defineProperty(w.config,"minTime",{get:function(){return w.config._minTime},set:d("min")}),Object.defineProperty(w.config,"maxTime",{get:function(){return w.config._maxTime},set:d("max")}),"time"===i.mode&&(w.config.noCalendar=!0,w.config.enableTime=!0);Object.assign(w.config,o,i);for(var u=0;u-1?w.config[m]=c(f[m]).map(T).concat(w.config[m]):void 0===i[m]&&(w.config[m]=f[m])}i.altInputClass||(w.config.altInputClass=ce().className+" "+w.config.altInputClass);De("onParseConfig")}(),se(),function(){if(w.input=ce(),!w.input)return void w.config.errorHandler(new Error("Invalid input element specified"));w.input._type=w.input.type,w.input.type="text",w.input.classList.add("flatpickr-input"),w._input=w.input,w.config.altInput&&(w.altInput=d(w.input.nodeName,w.config.altInputClass),w._input=w.altInput,w.altInput.placeholder=w.input.placeholder,w.altInput.disabled=w.input.disabled,w.altInput.required=w.input.required,w.altInput.tabIndex=w.input.tabIndex,w.altInput.type="text",w.input.setAttribute("type","hidden"),!w.config.static&&w.input.parentNode&&w.input.parentNode.insertBefore(w.altInput,w.input.nextSibling));w.config.allowInput||w._input.setAttribute("readonly","readonly");ve()}(),function(){w.selectedDates=[],w.now=w.parseDate(w.config.now)||new Date;var e=w.config.defaultDate||("INPUT"!==w.input.nodeName&&"TEXTAREA"!==w.input.nodeName||!w.input.placeholder||w.input.value!==w.input.placeholder?w.input.value:null);e&&pe(e,w.config.dateFormat);w._initialDate=w.selectedDates.length>0?w.selectedDates[0]:w.config.minDate&&w.config.minDate.getTime()>w.now.getTime()?w.config.minDate:w.config.maxDate&&w.config.maxDate.getTime()0&&(w.latestSelectedDateObj=w.selectedDates[0]);void 0!==w.config.minTime&&(w.config.minTime=w.parseDate(w.config.minTime,"H:i"));void 0!==w.config.maxTime&&(w.config.maxTime=w.parseDate(w.config.maxTime,"H:i"));w.minDateHasTime=!!w.config.minDate&&(w.config.minDate.getHours()>0||w.config.minDate.getMinutes()>0||w.config.minDate.getSeconds()>0),w.maxDateHasTime=!!w.config.maxDate&&(w.config.maxDate.getHours()>0||w.config.maxDate.getMinutes()>0||w.config.maxDate.getSeconds()>0)}(),w.utils={getDaysInMonth:function(e,n){return void 0===e&&(e=w.currentMonth),void 0===n&&(n=w.currentYear),1===e&&(n%4==0&&n%100!=0||n%400==0)?29:w.l10n.daysInMonth[e]}},w.isMobile||function(){var e=window.document.createDocumentFragment();if(w.calendarContainer=d("div","flatpickr-calendar"),w.calendarContainer.tabIndex=-1,!w.config.noCalendar){if(e.appendChild((w.monthNav=d("div","flatpickr-months"),w.yearElements=[],w.monthElements=[],w.prevMonthNav=d("span","flatpickr-prev-month"),w.prevMonthNav.innerHTML=w.config.prevArrow,w.nextMonthNav=d("span","flatpickr-next-month"),w.nextMonthNav.innerHTML=w.config.nextArrow,V(),Object.defineProperty(w,"_hidePrevMonthArrow",{get:function(){return w.__hidePrevMonthArrow},set:function(e){w.__hidePrevMonthArrow!==e&&(s(w.prevMonthNav,"flatpickr-disabled",e),w.__hidePrevMonthArrow=e)}}),Object.defineProperty(w,"_hideNextMonthArrow",{get:function(){return w.__hideNextMonthArrow},set:function(e){w.__hideNextMonthArrow!==e&&(s(w.nextMonthNav,"flatpickr-disabled",e),w.__hideNextMonthArrow=e)}}),w.currentYearElement=w.yearElements[0],Ce(),w.monthNav)),w.innerContainer=d("div","flatpickr-innerContainer"),w.config.weekNumbers){var n=function(){w.calendarContainer.classList.add("hasWeeks");var e=d("div","flatpickr-weekwrapper");e.appendChild(d("span","flatpickr-weekday",w.l10n.weekAbbreviation));var n=d("div","flatpickr-weeks");return e.appendChild(n),{weekWrapper:e,weekNumbers:n}}(),t=n.weekWrapper,a=n.weekNumbers;w.innerContainer.appendChild(t),w.weekNumbers=a,w.weekWrapper=t}w.rContainer=d("div","flatpickr-rContainer"),w.rContainer.appendChild(z()),w.daysContainer||(w.daysContainer=d("div","flatpickr-days"),w.daysContainer.tabIndex=-1),U(),w.rContainer.appendChild(w.daysContainer),w.innerContainer.appendChild(w.rContainer),e.appendChild(w.innerContainer)}w.config.enableTime&&e.appendChild(function(){w.calendarContainer.classList.add("hasTime"),w.config.noCalendar&&w.calendarContainer.classList.add("noCalendar");var e=E(w.config);w.timeContainer=d("div","flatpickr-time"),w.timeContainer.tabIndex=-1;var n=d("span","flatpickr-time-separator",":"),t=m("flatpickr-hour",{"aria-label":w.l10n.hourAriaLabel});w.hourElement=t.getElementsByTagName("input")[0];var a=m("flatpickr-minute",{"aria-label":w.l10n.minuteAriaLabel});w.minuteElement=a.getElementsByTagName("input")[0],w.hourElement.tabIndex=w.minuteElement.tabIndex=-1,w.hourElement.value=o(w.latestSelectedDateObj?w.latestSelectedDateObj.getHours():w.config.time_24hr?e.hours:function(e){switch(e%24){case 0:case 12:return 12;default:return e%12}}(e.hours)),w.minuteElement.value=o(w.latestSelectedDateObj?w.latestSelectedDateObj.getMinutes():e.minutes),w.hourElement.setAttribute("step",w.config.hourIncrement.toString()),w.minuteElement.setAttribute("step",w.config.minuteIncrement.toString()),w.hourElement.setAttribute("min",w.config.time_24hr?"0":"1"),w.hourElement.setAttribute("max",w.config.time_24hr?"23":"12"),w.hourElement.setAttribute("maxlength","2"),w.minuteElement.setAttribute("min","0"),w.minuteElement.setAttribute("max","59"),w.minuteElement.setAttribute("maxlength","2"),w.timeContainer.appendChild(t),w.timeContainer.appendChild(n),w.timeContainer.appendChild(a),w.config.time_24hr&&w.timeContainer.classList.add("time24hr");if(w.config.enableSeconds){w.timeContainer.classList.add("hasSeconds");var i=m("flatpickr-second");w.secondElement=i.getElementsByTagName("input")[0],w.secondElement.value=o(w.latestSelectedDateObj?w.latestSelectedDateObj.getSeconds():e.seconds),w.secondElement.setAttribute("step",w.minuteElement.getAttribute("step")),w.secondElement.setAttribute("min","0"),w.secondElement.setAttribute("max","59"),w.secondElement.setAttribute("maxlength","2"),w.timeContainer.appendChild(d("span","flatpickr-time-separator",":")),w.timeContainer.appendChild(i)}w.config.time_24hr||(w.amPM=d("span","flatpickr-am-pm",w.l10n.amPM[r((w.latestSelectedDateObj?w.hourElement.value:w.config.defaultHour)>11)]),w.amPM.title=w.l10n.toggleTitle,w.amPM.tabIndex=-1,w.timeContainer.appendChild(w.amPM));return w.timeContainer}());s(w.calendarContainer,"rangeMode","range"===w.config.mode),s(w.calendarContainer,"animate",!0===w.config.animate),s(w.calendarContainer,"multiMonth",w.config.showMonths>1),w.calendarContainer.appendChild(e);var i=void 0!==w.config.appendTo&&void 0!==w.config.appendTo.nodeType;if((w.config.inline||w.config.static)&&(w.calendarContainer.classList.add(w.config.inline?"inline":"static"),w.config.inline&&(!i&&w.element.parentNode?w.element.parentNode.insertBefore(w.calendarContainer,w._input.nextSibling):void 0!==w.config.appendTo&&w.config.appendTo.appendChild(w.calendarContainer)),w.config.static)){var l=d("div","flatpickr-wrapper");w.element.parentNode&&w.element.parentNode.insertBefore(l,w.element),l.appendChild(w.element),w.altInput&&l.appendChild(w.altInput),l.appendChild(w.calendarContainer)}w.config.static||w.config.inline||(void 0!==w.config.appendTo?w.config.appendTo:window.document.body).appendChild(w.calendarContainer)}(),function(){w.config.wrap&&["open","close","toggle","clear"].forEach((function(e){Array.prototype.forEach.call(w.element.querySelectorAll("[data-"+e+"]"),(function(n){return P(n,"click",w[e])}))}));if(w.isMobile)return void function(){var e=w.config.enableTime?w.config.noCalendar?"time":"datetime-local":"date";w.mobileInput=d("input",w.input.className+" flatpickr-mobile"),w.mobileInput.tabIndex=1,w.mobileInput.type=e,w.mobileInput.disabled=w.input.disabled,w.mobileInput.required=w.input.required,w.mobileInput.placeholder=w.input.placeholder,w.mobileFormatStr="datetime-local"===e?"Y-m-d\\TH:i:S":"date"===e?"Y-m-d":"H:i:S",w.selectedDates.length>0&&(w.mobileInput.defaultValue=w.mobileInput.value=w.formatDate(w.selectedDates[0],w.mobileFormatStr));w.config.minDate&&(w.mobileInput.min=w.formatDate(w.config.minDate,"Y-m-d"));w.config.maxDate&&(w.mobileInput.max=w.formatDate(w.config.maxDate,"Y-m-d"));w.input.getAttribute("step")&&(w.mobileInput.step=String(w.input.getAttribute("step")));w.input.type="hidden",void 0!==w.altInput&&(w.altInput.type="hidden");try{w.input.parentNode&&w.input.parentNode.insertBefore(w.mobileInput,w.input.nextSibling)}catch(e){}P(w.mobileInput,"change",(function(e){w.setDate(g(e).value,!1,w.mobileFormatStr),De("onChange"),De("onClose")}))}();var e=l(re,50);w._debouncedChange=l(Y,300),w.daysContainer&&!/iPhone|iPad|iPod/i.test(navigator.userAgent)&&P(w.daysContainer,"mouseover",(function(e){"range"===w.config.mode&&oe(g(e))}));P(w._input,"keydown",ie),void 0!==w.calendarContainer&&P(w.calendarContainer,"keydown",ie);w.config.inline||w.config.static||P(window,"resize",e);void 0!==window.ontouchstart?P(window.document,"touchstart",X):P(window.document,"mousedown",X);P(window.document,"focus",X,{capture:!0}),!0===w.config.clickOpens&&(P(w._input,"focus",w.open),P(w._input,"click",w.open));void 0!==w.daysContainer&&(P(w.monthNav,"click",xe),P(w.monthNav,["keyup","increment"],N),P(w.daysContainer,"click",me));if(void 0!==w.timeContainer&&void 0!==w.minuteElement&&void 0!==w.hourElement){var n=function(e){return g(e).select()};P(w.timeContainer,["increment"],_),P(w.timeContainer,"blur",_,{capture:!0}),P(w.timeContainer,"click",H),P([w.hourElement,w.minuteElement],["focus","click"],n),void 0!==w.secondElement&&P(w.secondElement,"focus",(function(){return w.secondElement&&w.secondElement.select()})),void 0!==w.amPM&&P(w.amPM,"click",(function(e){_(e)}))}w.config.allowInput&&P(w._input,"blur",ae)}(),(w.selectedDates.length||w.config.noCalendar)&&(w.config.enableTime&&F(w.config.noCalendar?w.latestSelectedDateObj:void 0),ye(!1)),S();var n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);!w.isMobile&&n&&de(),De("onReady")}(),w}function T(e,n){for(var t=Array.prototype.slice.call(e).filter((function(e){return e instanceof HTMLElement})),a=[],i=0;i 0 && s(a2.width) / e2.offsetWidth || 1, p2 = e2.offsetHeight > 0 && s(a2.height) / e2.offsetHeight || 1); - var u2 = (n(e2) ? t(e2) : window).visualViewport, l2 = !c() && i2, d2 = (a2.left + (l2 && u2 ? u2.offsetLeft : 0)) / f2, h2 = (a2.top + (l2 && u2 ? u2.offsetTop : 0)) / p2, m2 = a2.width / f2, v2 = a2.height / p2; - return { width: m2, height: v2, top: h2, right: d2 + m2, bottom: h2 + v2, left: d2, x: d2, y: h2 }; - } - function u(e2) { - var n2 = t(e2); - return { scrollLeft: n2.pageXOffset, scrollTop: n2.pageYOffset }; - } - function l(e2) { - return e2 ? (e2.nodeName || "").toLowerCase() : null; - } - function d(e2) { - return ((n(e2) ? e2.ownerDocument : e2.document) || window.document).documentElement; - } - function h(e2) { - return p(d(e2)).left + u(e2).scrollLeft; - } - function m(e2) { - return t(e2).getComputedStyle(e2); - } - function v(e2) { - var t2 = m(e2), n2 = t2.overflow, r2 = t2.overflowX, o2 = t2.overflowY; - return /auto|scroll|overlay|hidden/.test(n2 + o2 + r2); - } - function y(e2, n2, o2) { - void 0 === o2 && (o2 = false); - var i2, a2, f2 = r(n2), c2 = r(n2) && (function(e3) { - var t2 = e3.getBoundingClientRect(), n3 = s(t2.width) / e3.offsetWidth || 1, r2 = s(t2.height) / e3.offsetHeight || 1; - return 1 !== n3 || 1 !== r2; - })(n2), m2 = d(n2), y2 = p(e2, c2, o2), g2 = { scrollLeft: 0, scrollTop: 0 }, b2 = { x: 0, y: 0 }; - return (f2 || !f2 && !o2) && (("body" !== l(n2) || v(m2)) && (g2 = (i2 = n2) !== t(i2) && r(i2) ? { scrollLeft: (a2 = i2).scrollLeft, scrollTop: a2.scrollTop } : u(i2)), r(n2) ? ((b2 = p(n2, true)).x += n2.clientLeft, b2.y += n2.clientTop) : m2 && (b2.x = h(m2))), { x: y2.left + g2.scrollLeft - b2.x, y: y2.top + g2.scrollTop - b2.y, width: y2.width, height: y2.height }; - } - function g(e2) { - var t2 = p(e2), n2 = e2.offsetWidth, r2 = e2.offsetHeight; - return Math.abs(t2.width - n2) <= 1 && (n2 = t2.width), Math.abs(t2.height - r2) <= 1 && (r2 = t2.height), { x: e2.offsetLeft, y: e2.offsetTop, width: n2, height: r2 }; - } - function b(e2) { - return "html" === l(e2) ? e2 : e2.assignedSlot || e2.parentNode || (o(e2) ? e2.host : null) || d(e2); - } - function x(e2) { - return ["html", "body", "#document"].indexOf(l(e2)) >= 0 ? e2.ownerDocument.body : r(e2) && v(e2) ? e2 : x(b(e2)); - } - function w(e2, n2) { - var r2; - void 0 === n2 && (n2 = []); - var o2 = x(e2), i2 = o2 === (null == (r2 = e2.ownerDocument) ? void 0 : r2.body), a2 = t(o2), s2 = i2 ? [a2].concat(a2.visualViewport || [], v(o2) ? o2 : []) : o2, f2 = n2.concat(s2); - return i2 ? f2 : f2.concat(w(b(s2))); - } - function O(e2) { - return ["table", "td", "th"].indexOf(l(e2)) >= 0; - } - function j(e2) { - return r(e2) && "fixed" !== m(e2).position ? e2.offsetParent : null; - } - function E(e2) { - for (var n2 = t(e2), i2 = j(e2); i2 && O(i2) && "static" === m(i2).position; ) i2 = j(i2); - return i2 && ("html" === l(i2) || "body" === l(i2) && "static" === m(i2).position) ? n2 : i2 || (function(e3) { - var t2 = /firefox/i.test(f()); - if (/Trident/i.test(f()) && r(e3) && "fixed" === m(e3).position) return null; - var n3 = b(e3); - for (o(n3) && (n3 = n3.host); r(n3) && ["html", "body"].indexOf(l(n3)) < 0; ) { - var i3 = m(n3); - if ("none" !== i3.transform || "none" !== i3.perspective || "paint" === i3.contain || -1 !== ["transform", "perspective"].indexOf(i3.willChange) || t2 && "filter" === i3.willChange || t2 && i3.filter && "none" !== i3.filter) return n3; - n3 = n3.parentNode; - } - return null; - })(e2) || n2; - } - var D = "top", A = "bottom", L = "right", P = "left", M = "auto", k = [D, A, L, P], W = "start", B = "end", H = "viewport", T = "popper", R = k.reduce((function(e2, t2) { - return e2.concat([t2 + "-" + W, t2 + "-" + B]); - }), []), S = [].concat(k, [M]).reduce((function(e2, t2) { - return e2.concat([t2, t2 + "-" + W, t2 + "-" + B]); - }), []), V = ["beforeRead", "read", "afterRead", "beforeMain", "main", "afterMain", "beforeWrite", "write", "afterWrite"]; - function q(e2) { - var t2 = /* @__PURE__ */ new Map(), n2 = /* @__PURE__ */ new Set(), r2 = []; - function o2(e3) { - n2.add(e3.name), [].concat(e3.requires || [], e3.requiresIfExists || []).forEach((function(e4) { - if (!n2.has(e4)) { - var r3 = t2.get(e4); - r3 && o2(r3); - } - })), r2.push(e3); - } - return e2.forEach((function(e3) { - t2.set(e3.name, e3); - })), e2.forEach((function(e3) { - n2.has(e3.name) || o2(e3); - })), r2; - } - function C(e2, t2) { - var n2 = t2.getRootNode && t2.getRootNode(); - if (e2.contains(t2)) return true; - if (n2 && o(n2)) { - var r2 = t2; - do { - if (r2 && e2.isSameNode(r2)) return true; - r2 = r2.parentNode || r2.host; - } while (r2); - } - return false; - } - function N(e2) { - return Object.assign({}, e2, { left: e2.x, top: e2.y, right: e2.x + e2.width, bottom: e2.y + e2.height }); - } - function I(e2, r2, o2) { - return r2 === H ? N((function(e3, n2) { - var r3 = t(e3), o3 = d(e3), i2 = r3.visualViewport, a2 = o3.clientWidth, s2 = o3.clientHeight, f2 = 0, p2 = 0; - if (i2) { - a2 = i2.width, s2 = i2.height; - var u2 = c(); - (u2 || !u2 && "fixed" === n2) && (f2 = i2.offsetLeft, p2 = i2.offsetTop); - } - return { width: a2, height: s2, x: f2 + h(e3), y: p2 }; - })(e2, o2)) : n(r2) ? (function(e3, t2) { - var n2 = p(e3, false, "fixed" === t2); - return n2.top = n2.top + e3.clientTop, n2.left = n2.left + e3.clientLeft, n2.bottom = n2.top + e3.clientHeight, n2.right = n2.left + e3.clientWidth, n2.width = e3.clientWidth, n2.height = e3.clientHeight, n2.x = n2.left, n2.y = n2.top, n2; - })(r2, o2) : N((function(e3) { - var t2, n2 = d(e3), r3 = u(e3), o3 = null == (t2 = e3.ownerDocument) ? void 0 : t2.body, a2 = i(n2.scrollWidth, n2.clientWidth, o3 ? o3.scrollWidth : 0, o3 ? o3.clientWidth : 0), s2 = i(n2.scrollHeight, n2.clientHeight, o3 ? o3.scrollHeight : 0, o3 ? o3.clientHeight : 0), f2 = -r3.scrollLeft + h(e3), c2 = -r3.scrollTop; - return "rtl" === m(o3 || n2).direction && (f2 += i(n2.clientWidth, o3 ? o3.clientWidth : 0) - a2), { width: a2, height: s2, x: f2, y: c2 }; - })(d(e2))); - } - function _(e2, t2, o2, s2) { - var f2 = "clippingParents" === t2 ? (function(e3) { - var t3 = w(b(e3)), o3 = ["absolute", "fixed"].indexOf(m(e3).position) >= 0 && r(e3) ? E(e3) : e3; - return n(o3) ? t3.filter((function(e4) { - return n(e4) && C(e4, o3) && "body" !== l(e4); - })) : []; - })(e2) : [].concat(t2), c2 = [].concat(f2, [o2]), p2 = c2[0], u2 = c2.reduce((function(t3, n2) { - var r2 = I(e2, n2, s2); - return t3.top = i(r2.top, t3.top), t3.right = a(r2.right, t3.right), t3.bottom = a(r2.bottom, t3.bottom), t3.left = i(r2.left, t3.left), t3; - }), I(e2, p2, s2)); - return u2.width = u2.right - u2.left, u2.height = u2.bottom - u2.top, u2.x = u2.left, u2.y = u2.top, u2; - } - function F(e2) { - return e2.split("-")[0]; - } - function U(e2) { - return e2.split("-")[1]; - } - function z(e2) { - return ["top", "bottom"].indexOf(e2) >= 0 ? "x" : "y"; - } - function X(e2) { - var t2, n2 = e2.reference, r2 = e2.element, o2 = e2.placement, i2 = o2 ? F(o2) : null, a2 = o2 ? U(o2) : null, s2 = n2.x + n2.width / 2 - r2.width / 2, f2 = n2.y + n2.height / 2 - r2.height / 2; - switch (i2) { - case D: - t2 = { x: s2, y: n2.y - r2.height }; - break; - case A: - t2 = { x: s2, y: n2.y + n2.height }; - break; - case L: - t2 = { x: n2.x + n2.width, y: f2 }; - break; - case P: - t2 = { x: n2.x - r2.width, y: f2 }; - break; - default: - t2 = { x: n2.x, y: n2.y }; - } - var c2 = i2 ? z(i2) : null; - if (null != c2) { - var p2 = "y" === c2 ? "height" : "width"; - switch (a2) { - case W: - t2[c2] = t2[c2] - (n2[p2] / 2 - r2[p2] / 2); - break; - case B: - t2[c2] = t2[c2] + (n2[p2] / 2 - r2[p2] / 2); - } - } - return t2; - } - function Y(e2) { - return Object.assign({}, { top: 0, right: 0, bottom: 0, left: 0 }, e2); - } - function G(e2, t2) { - return t2.reduce((function(t3, n2) { - return t3[n2] = e2, t3; - }), {}); - } - function J(e2, t2) { - void 0 === t2 && (t2 = {}); - var r2 = t2, o2 = r2.placement, i2 = void 0 === o2 ? e2.placement : o2, a2 = r2.strategy, s2 = void 0 === a2 ? e2.strategy : a2, f2 = r2.boundary, c2 = void 0 === f2 ? "clippingParents" : f2, u2 = r2.rootBoundary, l2 = void 0 === u2 ? H : u2, h2 = r2.elementContext, m2 = void 0 === h2 ? T : h2, v2 = r2.altBoundary, y2 = void 0 !== v2 && v2, g2 = r2.padding, b2 = void 0 === g2 ? 0 : g2, x2 = Y("number" != typeof b2 ? b2 : G(b2, k)), w2 = m2 === T ? "reference" : T, O2 = e2.rects.popper, j2 = e2.elements[y2 ? w2 : m2], E2 = _(n(j2) ? j2 : j2.contextElement || d(e2.elements.popper), c2, l2, s2), P2 = p(e2.elements.reference), M2 = X({ reference: P2, element: O2, strategy: "absolute", placement: i2 }), W2 = N(Object.assign({}, O2, M2)), B2 = m2 === T ? W2 : P2, R2 = { top: E2.top - B2.top + x2.top, bottom: B2.bottom - E2.bottom + x2.bottom, left: E2.left - B2.left + x2.left, right: B2.right - E2.right + x2.right }, S2 = e2.modifiersData.offset; - if (m2 === T && S2) { - var V2 = S2[i2]; - Object.keys(R2).forEach((function(e3) { - var t3 = [L, A].indexOf(e3) >= 0 ? 1 : -1, n2 = [D, A].indexOf(e3) >= 0 ? "y" : "x"; - R2[e3] += V2[n2] * t3; - })); - } - return R2; - } - var K = { placement: "bottom", modifiers: [], strategy: "absolute" }; - function Q() { - for (var e2 = arguments.length, t2 = new Array(e2), n2 = 0; n2 < e2; n2++) t2[n2] = arguments[n2]; - return !t2.some((function(e3) { - return !(e3 && "function" == typeof e3.getBoundingClientRect); - })); - } - function Z(e2) { - void 0 === e2 && (e2 = {}); - var t2 = e2, r2 = t2.defaultModifiers, o2 = void 0 === r2 ? [] : r2, i2 = t2.defaultOptions, a2 = void 0 === i2 ? K : i2; - return function(e3, t3, r3) { - void 0 === r3 && (r3 = a2); - var i3, s2, f2 = { placement: "bottom", orderedModifiers: [], options: Object.assign({}, K, a2), modifiersData: {}, elements: { reference: e3, popper: t3 }, attributes: {}, styles: {} }, c2 = [], p2 = false, u2 = { state: f2, setOptions: function(r4) { - var i4 = "function" == typeof r4 ? r4(f2.options) : r4; - l2(), f2.options = Object.assign({}, a2, f2.options, i4), f2.scrollParents = { reference: n(e3) ? w(e3) : e3.contextElement ? w(e3.contextElement) : [], popper: w(t3) }; - var s3, p3, d2 = (function(e4) { - var t4 = q(e4); - return V.reduce((function(e5, n2) { - return e5.concat(t4.filter((function(e6) { - return e6.phase === n2; - }))); - }), []); - })((s3 = [].concat(o2, f2.options.modifiers), p3 = s3.reduce((function(e4, t4) { - var n2 = e4[t4.name]; - return e4[t4.name] = n2 ? Object.assign({}, n2, t4, { options: Object.assign({}, n2.options, t4.options), data: Object.assign({}, n2.data, t4.data) }) : t4, e4; - }), {}), Object.keys(p3).map((function(e4) { - return p3[e4]; - })))); - return f2.orderedModifiers = d2.filter((function(e4) { - return e4.enabled; - })), f2.orderedModifiers.forEach((function(e4) { - var t4 = e4.name, n2 = e4.options, r5 = void 0 === n2 ? {} : n2, o3 = e4.effect; - if ("function" == typeof o3) { - var i5 = o3({ state: f2, name: t4, instance: u2, options: r5 }), a3 = function() { - }; - c2.push(i5 || a3); - } - })), u2.update(); - }, forceUpdate: function() { - if (!p2) { - var e4 = f2.elements, t4 = e4.reference, n2 = e4.popper; - if (Q(t4, n2)) { - f2.rects = { reference: y(t4, E(n2), "fixed" === f2.options.strategy), popper: g(n2) }, f2.reset = false, f2.placement = f2.options.placement, f2.orderedModifiers.forEach((function(e5) { - return f2.modifiersData[e5.name] = Object.assign({}, e5.data); - })); - for (var r4 = 0; r4 < f2.orderedModifiers.length; r4++) if (true !== f2.reset) { - var o3 = f2.orderedModifiers[r4], i4 = o3.fn, a3 = o3.options, s3 = void 0 === a3 ? {} : a3, c3 = o3.name; - "function" == typeof i4 && (f2 = i4({ state: f2, options: s3, name: c3, instance: u2 }) || f2); - } else f2.reset = false, r4 = -1; - } - } - }, update: (i3 = function() { - return new Promise((function(e4) { - u2.forceUpdate(), e4(f2); - })); - }, function() { - return s2 || (s2 = new Promise((function(e4) { - Promise.resolve().then((function() { - s2 = void 0, e4(i3()); - })); - }))), s2; - }), destroy: function() { - l2(), p2 = true; - } }; - if (!Q(e3, t3)) return u2; - function l2() { - c2.forEach((function(e4) { - return e4(); - })), c2 = []; - } - return u2.setOptions(r3).then((function(e4) { - !p2 && r3.onFirstUpdate && r3.onFirstUpdate(e4); - })), u2; - }; - } - var $ = { passive: true }; - var ee = { name: "eventListeners", enabled: true, phase: "write", fn: function() { - }, effect: function(e2) { - var n2 = e2.state, r2 = e2.instance, o2 = e2.options, i2 = o2.scroll, a2 = void 0 === i2 || i2, s2 = o2.resize, f2 = void 0 === s2 || s2, c2 = t(n2.elements.popper), p2 = [].concat(n2.scrollParents.reference, n2.scrollParents.popper); - return a2 && p2.forEach((function(e3) { - e3.addEventListener("scroll", r2.update, $); - })), f2 && c2.addEventListener("resize", r2.update, $), function() { - a2 && p2.forEach((function(e3) { - e3.removeEventListener("scroll", r2.update, $); - })), f2 && c2.removeEventListener("resize", r2.update, $); - }; - }, data: {} }; - var te = { name: "popperOffsets", enabled: true, phase: "read", fn: function(e2) { - var t2 = e2.state, n2 = e2.name; - t2.modifiersData[n2] = X({ reference: t2.rects.reference, element: t2.rects.popper, strategy: "absolute", placement: t2.placement }); - }, data: {} }, ne = { top: "auto", right: "auto", bottom: "auto", left: "auto" }; - function re(e2) { - var n2, r2 = e2.popper, o2 = e2.popperRect, i2 = e2.placement, a2 = e2.variation, f2 = e2.offsets, c2 = e2.position, p2 = e2.gpuAcceleration, u2 = e2.adaptive, l2 = e2.roundOffsets, h2 = e2.isFixed, v2 = f2.x, y2 = void 0 === v2 ? 0 : v2, g2 = f2.y, b2 = void 0 === g2 ? 0 : g2, x2 = "function" == typeof l2 ? l2({ x: y2, y: b2 }) : { x: y2, y: b2 }; - y2 = x2.x, b2 = x2.y; - var w2 = f2.hasOwnProperty("x"), O2 = f2.hasOwnProperty("y"), j2 = P, M2 = D, k2 = window; - if (u2) { - var W2 = E(r2), H2 = "clientHeight", T2 = "clientWidth"; - if (W2 === t(r2) && "static" !== m(W2 = d(r2)).position && "absolute" === c2 && (H2 = "scrollHeight", T2 = "scrollWidth"), W2 = W2, i2 === D || (i2 === P || i2 === L) && a2 === B) M2 = A, b2 -= (h2 && W2 === k2 && k2.visualViewport ? k2.visualViewport.height : W2[H2]) - o2.height, b2 *= p2 ? 1 : -1; - if (i2 === P || (i2 === D || i2 === A) && a2 === B) j2 = L, y2 -= (h2 && W2 === k2 && k2.visualViewport ? k2.visualViewport.width : W2[T2]) - o2.width, y2 *= p2 ? 1 : -1; - } - var R2, S2 = Object.assign({ position: c2 }, u2 && ne), V2 = true === l2 ? (function(e3, t2) { - var n3 = e3.x, r3 = e3.y, o3 = t2.devicePixelRatio || 1; - return { x: s(n3 * o3) / o3 || 0, y: s(r3 * o3) / o3 || 0 }; - })({ x: y2, y: b2 }, t(r2)) : { x: y2, y: b2 }; - return y2 = V2.x, b2 = V2.y, p2 ? Object.assign({}, S2, ((R2 = {})[M2] = O2 ? "0" : "", R2[j2] = w2 ? "0" : "", R2.transform = (k2.devicePixelRatio || 1) <= 1 ? "translate(" + y2 + "px, " + b2 + "px)" : "translate3d(" + y2 + "px, " + b2 + "px, 0)", R2)) : Object.assign({}, S2, ((n2 = {})[M2] = O2 ? b2 + "px" : "", n2[j2] = w2 ? y2 + "px" : "", n2.transform = "", n2)); - } - var oe = { name: "computeStyles", enabled: true, phase: "beforeWrite", fn: function(e2) { - var t2 = e2.state, n2 = e2.options, r2 = n2.gpuAcceleration, o2 = void 0 === r2 || r2, i2 = n2.adaptive, a2 = void 0 === i2 || i2, s2 = n2.roundOffsets, f2 = void 0 === s2 || s2, c2 = { placement: F(t2.placement), variation: U(t2.placement), popper: t2.elements.popper, popperRect: t2.rects.popper, gpuAcceleration: o2, isFixed: "fixed" === t2.options.strategy }; - null != t2.modifiersData.popperOffsets && (t2.styles.popper = Object.assign({}, t2.styles.popper, re(Object.assign({}, c2, { offsets: t2.modifiersData.popperOffsets, position: t2.options.strategy, adaptive: a2, roundOffsets: f2 })))), null != t2.modifiersData.arrow && (t2.styles.arrow = Object.assign({}, t2.styles.arrow, re(Object.assign({}, c2, { offsets: t2.modifiersData.arrow, position: "absolute", adaptive: false, roundOffsets: f2 })))), t2.attributes.popper = Object.assign({}, t2.attributes.popper, { "data-popper-placement": t2.placement }); - }, data: {} }; - var ie = { name: "applyStyles", enabled: true, phase: "write", fn: function(e2) { - var t2 = e2.state; - Object.keys(t2.elements).forEach((function(e3) { - var n2 = t2.styles[e3] || {}, o2 = t2.attributes[e3] || {}, i2 = t2.elements[e3]; - r(i2) && l(i2) && (Object.assign(i2.style, n2), Object.keys(o2).forEach((function(e4) { - var t3 = o2[e4]; - false === t3 ? i2.removeAttribute(e4) : i2.setAttribute(e4, true === t3 ? "" : t3); - }))); - })); - }, effect: function(e2) { - var t2 = e2.state, n2 = { popper: { position: t2.options.strategy, left: "0", top: "0", margin: "0" }, arrow: { position: "absolute" }, reference: {} }; - return Object.assign(t2.elements.popper.style, n2.popper), t2.styles = n2, t2.elements.arrow && Object.assign(t2.elements.arrow.style, n2.arrow), function() { - Object.keys(t2.elements).forEach((function(e3) { - var o2 = t2.elements[e3], i2 = t2.attributes[e3] || {}, a2 = Object.keys(t2.styles.hasOwnProperty(e3) ? t2.styles[e3] : n2[e3]).reduce((function(e4, t3) { - return e4[t3] = "", e4; - }), {}); - r(o2) && l(o2) && (Object.assign(o2.style, a2), Object.keys(i2).forEach((function(e4) { - o2.removeAttribute(e4); - }))); - })); - }; - }, requires: ["computeStyles"] }; - var ae = { name: "offset", enabled: true, phase: "main", requires: ["popperOffsets"], fn: function(e2) { - var t2 = e2.state, n2 = e2.options, r2 = e2.name, o2 = n2.offset, i2 = void 0 === o2 ? [0, 0] : o2, a2 = S.reduce((function(e3, n3) { - return e3[n3] = (function(e4, t3, n4) { - var r3 = F(e4), o3 = [P, D].indexOf(r3) >= 0 ? -1 : 1, i3 = "function" == typeof n4 ? n4(Object.assign({}, t3, { placement: e4 })) : n4, a3 = i3[0], s3 = i3[1]; - return a3 = a3 || 0, s3 = (s3 || 0) * o3, [P, L].indexOf(r3) >= 0 ? { x: s3, y: a3 } : { x: a3, y: s3 }; - })(n3, t2.rects, i2), e3; - }), {}), s2 = a2[t2.placement], f2 = s2.x, c2 = s2.y; - null != t2.modifiersData.popperOffsets && (t2.modifiersData.popperOffsets.x += f2, t2.modifiersData.popperOffsets.y += c2), t2.modifiersData[r2] = a2; - } }, se = { left: "right", right: "left", bottom: "top", top: "bottom" }; - function fe(e2) { - return e2.replace(/left|right|bottom|top/g, (function(e3) { - return se[e3]; - })); - } - var ce = { start: "end", end: "start" }; - function pe(e2) { - return e2.replace(/start|end/g, (function(e3) { - return ce[e3]; - })); - } - function ue(e2, t2) { - void 0 === t2 && (t2 = {}); - var n2 = t2, r2 = n2.placement, o2 = n2.boundary, i2 = n2.rootBoundary, a2 = n2.padding, s2 = n2.flipVariations, f2 = n2.allowedAutoPlacements, c2 = void 0 === f2 ? S : f2, p2 = U(r2), u2 = p2 ? s2 ? R : R.filter((function(e3) { - return U(e3) === p2; - })) : k, l2 = u2.filter((function(e3) { - return c2.indexOf(e3) >= 0; - })); - 0 === l2.length && (l2 = u2); - var d2 = l2.reduce((function(t3, n3) { - return t3[n3] = J(e2, { placement: n3, boundary: o2, rootBoundary: i2, padding: a2 })[F(n3)], t3; - }), {}); - return Object.keys(d2).sort((function(e3, t3) { - return d2[e3] - d2[t3]; - })); - } - var le = { name: "flip", enabled: true, phase: "main", fn: function(e2) { - var t2 = e2.state, n2 = e2.options, r2 = e2.name; - if (!t2.modifiersData[r2]._skip) { - for (var o2 = n2.mainAxis, i2 = void 0 === o2 || o2, a2 = n2.altAxis, s2 = void 0 === a2 || a2, f2 = n2.fallbackPlacements, c2 = n2.padding, p2 = n2.boundary, u2 = n2.rootBoundary, l2 = n2.altBoundary, d2 = n2.flipVariations, h2 = void 0 === d2 || d2, m2 = n2.allowedAutoPlacements, v2 = t2.options.placement, y2 = F(v2), g2 = f2 || (y2 === v2 || !h2 ? [fe(v2)] : (function(e3) { - if (F(e3) === M) return []; - var t3 = fe(e3); - return [pe(e3), t3, pe(t3)]; - })(v2)), b2 = [v2].concat(g2).reduce((function(e3, n3) { - return e3.concat(F(n3) === M ? ue(t2, { placement: n3, boundary: p2, rootBoundary: u2, padding: c2, flipVariations: h2, allowedAutoPlacements: m2 }) : n3); - }), []), x2 = t2.rects.reference, w2 = t2.rects.popper, O2 = /* @__PURE__ */ new Map(), j2 = true, E2 = b2[0], k2 = 0; k2 < b2.length; k2++) { - var B2 = b2[k2], H2 = F(B2), T2 = U(B2) === W, R2 = [D, A].indexOf(H2) >= 0, S2 = R2 ? "width" : "height", V2 = J(t2, { placement: B2, boundary: p2, rootBoundary: u2, altBoundary: l2, padding: c2 }), q2 = R2 ? T2 ? L : P : T2 ? A : D; - x2[S2] > w2[S2] && (q2 = fe(q2)); - var C2 = fe(q2), N2 = []; - if (i2 && N2.push(V2[H2] <= 0), s2 && N2.push(V2[q2] <= 0, V2[C2] <= 0), N2.every((function(e3) { - return e3; - }))) { - E2 = B2, j2 = false; - break; - } - O2.set(B2, N2); - } - if (j2) for (var I2 = function(e3) { - var t3 = b2.find((function(t4) { - var n3 = O2.get(t4); - if (n3) return n3.slice(0, e3).every((function(e4) { - return e4; - })); - })); - if (t3) return E2 = t3, "break"; - }, _2 = h2 ? 3 : 1; _2 > 0; _2--) { - if ("break" === I2(_2)) break; - } - t2.placement !== E2 && (t2.modifiersData[r2]._skip = true, t2.placement = E2, t2.reset = true); - } - }, requiresIfExists: ["offset"], data: { _skip: false } }; - function de(e2, t2, n2) { - return i(e2, a(t2, n2)); - } - var he = { name: "preventOverflow", enabled: true, phase: "main", fn: function(e2) { - var t2 = e2.state, n2 = e2.options, r2 = e2.name, o2 = n2.mainAxis, s2 = void 0 === o2 || o2, f2 = n2.altAxis, c2 = void 0 !== f2 && f2, p2 = n2.boundary, u2 = n2.rootBoundary, l2 = n2.altBoundary, d2 = n2.padding, h2 = n2.tether, m2 = void 0 === h2 || h2, v2 = n2.tetherOffset, y2 = void 0 === v2 ? 0 : v2, b2 = J(t2, { boundary: p2, rootBoundary: u2, padding: d2, altBoundary: l2 }), x2 = F(t2.placement), w2 = U(t2.placement), O2 = !w2, j2 = z(x2), M2 = "x" === j2 ? "y" : "x", k2 = t2.modifiersData.popperOffsets, B2 = t2.rects.reference, H2 = t2.rects.popper, T2 = "function" == typeof y2 ? y2(Object.assign({}, t2.rects, { placement: t2.placement })) : y2, R2 = "number" == typeof T2 ? { mainAxis: T2, altAxis: T2 } : Object.assign({ mainAxis: 0, altAxis: 0 }, T2), S2 = t2.modifiersData.offset ? t2.modifiersData.offset[t2.placement] : null, V2 = { x: 0, y: 0 }; - if (k2) { - if (s2) { - var q2, C2 = "y" === j2 ? D : P, N2 = "y" === j2 ? A : L, I2 = "y" === j2 ? "height" : "width", _2 = k2[j2], X2 = _2 + b2[C2], Y2 = _2 - b2[N2], G2 = m2 ? -H2[I2] / 2 : 0, K2 = w2 === W ? B2[I2] : H2[I2], Q2 = w2 === W ? -H2[I2] : -B2[I2], Z2 = t2.elements.arrow, $2 = m2 && Z2 ? g(Z2) : { width: 0, height: 0 }, ee2 = t2.modifiersData["arrow#persistent"] ? t2.modifiersData["arrow#persistent"].padding : { top: 0, right: 0, bottom: 0, left: 0 }, te2 = ee2[C2], ne2 = ee2[N2], re2 = de(0, B2[I2], $2[I2]), oe2 = O2 ? B2[I2] / 2 - G2 - re2 - te2 - R2.mainAxis : K2 - re2 - te2 - R2.mainAxis, ie2 = O2 ? -B2[I2] / 2 + G2 + re2 + ne2 + R2.mainAxis : Q2 + re2 + ne2 + R2.mainAxis, ae2 = t2.elements.arrow && E(t2.elements.arrow), se2 = ae2 ? "y" === j2 ? ae2.clientTop || 0 : ae2.clientLeft || 0 : 0, fe2 = null != (q2 = null == S2 ? void 0 : S2[j2]) ? q2 : 0, ce2 = _2 + ie2 - fe2, pe2 = de(m2 ? a(X2, _2 + oe2 - fe2 - se2) : X2, _2, m2 ? i(Y2, ce2) : Y2); - k2[j2] = pe2, V2[j2] = pe2 - _2; - } - if (c2) { - var ue2, le2 = "x" === j2 ? D : P, he2 = "x" === j2 ? A : L, me2 = k2[M2], ve2 = "y" === M2 ? "height" : "width", ye2 = me2 + b2[le2], ge2 = me2 - b2[he2], be2 = -1 !== [D, P].indexOf(x2), xe2 = null != (ue2 = null == S2 ? void 0 : S2[M2]) ? ue2 : 0, we2 = be2 ? ye2 : me2 - B2[ve2] - H2[ve2] - xe2 + R2.altAxis, Oe = be2 ? me2 + B2[ve2] + H2[ve2] - xe2 - R2.altAxis : ge2, je = m2 && be2 ? (function(e3, t3, n3) { - var r3 = de(e3, t3, n3); - return r3 > n3 ? n3 : r3; - })(we2, me2, Oe) : de(m2 ? we2 : ye2, me2, m2 ? Oe : ge2); - k2[M2] = je, V2[M2] = je - me2; - } - t2.modifiersData[r2] = V2; - } - }, requiresIfExists: ["offset"] }; - var me = { name: "arrow", enabled: true, phase: "main", fn: function(e2) { - var t2, n2 = e2.state, r2 = e2.name, o2 = e2.options, i2 = n2.elements.arrow, a2 = n2.modifiersData.popperOffsets, s2 = F(n2.placement), f2 = z(s2), c2 = [P, L].indexOf(s2) >= 0 ? "height" : "width"; - if (i2 && a2) { - var p2 = (function(e3, t3) { - return Y("number" != typeof (e3 = "function" == typeof e3 ? e3(Object.assign({}, t3.rects, { placement: t3.placement })) : e3) ? e3 : G(e3, k)); - })(o2.padding, n2), u2 = g(i2), l2 = "y" === f2 ? D : P, d2 = "y" === f2 ? A : L, h2 = n2.rects.reference[c2] + n2.rects.reference[f2] - a2[f2] - n2.rects.popper[c2], m2 = a2[f2] - n2.rects.reference[f2], v2 = E(i2), y2 = v2 ? "y" === f2 ? v2.clientHeight || 0 : v2.clientWidth || 0 : 0, b2 = h2 / 2 - m2 / 2, x2 = p2[l2], w2 = y2 - u2[c2] - p2[d2], O2 = y2 / 2 - u2[c2] / 2 + b2, j2 = de(x2, O2, w2), M2 = f2; - n2.modifiersData[r2] = ((t2 = {})[M2] = j2, t2.centerOffset = j2 - O2, t2); - } - }, effect: function(e2) { - var t2 = e2.state, n2 = e2.options.element, r2 = void 0 === n2 ? "[data-popper-arrow]" : n2; - null != r2 && ("string" != typeof r2 || (r2 = t2.elements.popper.querySelector(r2))) && C(t2.elements.popper, r2) && (t2.elements.arrow = r2); - }, requires: ["popperOffsets"], requiresIfExists: ["preventOverflow"] }; - function ve(e2, t2, n2) { - return void 0 === n2 && (n2 = { x: 0, y: 0 }), { top: e2.top - t2.height - n2.y, right: e2.right - t2.width + n2.x, bottom: e2.bottom - t2.height + n2.y, left: e2.left - t2.width - n2.x }; - } - function ye(e2) { - return [D, L, A, P].some((function(t2) { - return e2[t2] >= 0; - })); - } - var ge = { name: "hide", enabled: true, phase: "main", requiresIfExists: ["preventOverflow"], fn: function(e2) { - var t2 = e2.state, n2 = e2.name, r2 = t2.rects.reference, o2 = t2.rects.popper, i2 = t2.modifiersData.preventOverflow, a2 = J(t2, { elementContext: "reference" }), s2 = J(t2, { altBoundary: true }), f2 = ve(a2, r2), c2 = ve(s2, o2, i2), p2 = ye(f2), u2 = ye(c2); - t2.modifiersData[n2] = { referenceClippingOffsets: f2, popperEscapeOffsets: c2, isReferenceHidden: p2, hasPopperEscaped: u2 }, t2.attributes.popper = Object.assign({}, t2.attributes.popper, { "data-popper-reference-hidden": p2, "data-popper-escaped": u2 }); - } }, be = Z({ defaultModifiers: [ee, te, oe, ie] }), xe = [ee, te, oe, ie, ae, le, he, me, ge], we = Z({ defaultModifiers: xe }); - e.applyStyles = ie, e.arrow = me, e.computeStyles = oe, e.createPopper = we, e.createPopperLite = be, e.defaultModifiers = xe, e.detectOverflow = J, e.eventListeners = ee, e.flip = le, e.hide = ge, e.offset = ae, e.popperGenerator = Z, e.popperOffsets = te, e.preventOverflow = he, Object.defineProperty(e, "__esModule", { value: true }); - })); - } -}); - -// frontend/js/pages/logs/logList.js -var STATIC_ERROR_MAP = { - "API_KEY_INVALID": { type: "\u5BC6\u94A5\u65E0\u6548", style: "red" }, - "INVALID_ARGUMENT": { type: "\u53C2\u6570\u65E0\u6548", style: "red" }, - "PERMISSION_DENIED": { type: "\u6743\u9650\u4E0D\u8DB3", style: "red" }, - "NOT_FOUND": { type: "\u8D44\u6E90\u672A\u627E\u5230", style: "gray" }, - "RESOURCE_EXHAUSTED": { type: "\u8D44\u6E90\u8017\u5C3D", style: "orange" }, - "QUOTA_EXCEEDED": { type: "\u914D\u989D\u8017\u5C3D", style: "orange" }, - "DEADLINE_EXCEEDED": { type: "\u8BF7\u6C42\u8D85\u65F6", style: "yellow" }, - "CANCELLED": { type: "\u8BF7\u6C42\u5DF2\u53D6\u6D88", style: "gray" }, - "INTERNAL": { type: "Google\u5185\u90E8\u9519\u8BEF", style: "yellow" }, - "UNAVAILABLE": { type: "\u670D\u52A1\u4E0D\u53EF\u7528", style: "yellow" } -}; -var STATUS_CODE_MAP = { - 400: { type: "\u9519\u8BEF\u8BF7\u6C42", style: "red" }, - 401: { type: "\u8BA4\u8BC1\u5931\u8D25", style: "red" }, - 403: { type: "\u7981\u6B62\u8BBF\u95EE", style: "red" }, - 404: { type: "\u8D44\u6E90\u672A\u627E\u5230", style: "gray" }, - 413: { type: "\u8BF7\u6C42\u4F53\u8FC7\u5927", style: "orange" }, - 429: { type: "\u8BF7\u6C42\u9891\u7387\u8FC7\u9AD8", style: "orange" }, - 500: { type: "\u5185\u90E8\u670D\u52A1\u9519\u8BEF", style: "yellow" }, - 503: { type: "\u670D\u52A1\u4E0D\u53EF\u7528", style: "yellow" } -}; -var SPECIAL_CASE_MAP = [ - { code: 400, keyword: "api key not found", type: "\u65E0\u6548\u5BC6\u94A5", style: "red" }, - { code: 404, keyword: "call listmodels", type: "\u6A21\u578B\u914D\u7F6E\u9519\u8BEF", style: "orange" } -]; -var styleToClass = (style) => { - switch (style) { - case "red": - return "bg-red-500/10 text-red-600"; - case "orange": - return "bg-orange-500/10 text-orange-600"; - case "yellow": - return "bg-yellow-500/10 text-yellow-600"; - case "gray": - return "bg-zinc-500/10 text-zinc-600"; - default: - return "bg-destructive/10 text-destructive"; - } -}; -var errorCodeRegex = /(\d+)$/; -var LogList = class { - constructor(container, dataStore2) { - this.container = container; - this.dataStore = dataStore2; - if (!this.container) console.error("LogList: container element (tbody) not found."); - } - renderLoading() { - if (!this.container) return; - this.container.innerHTML = ` \u52A0\u8F7D\u65E5\u5FD7\u4E2D...`; - } - render(logs, pagination, selectedLogIds) { - if (!this.container) return; - if (!logs || logs.length === 0) { - this.container.innerHTML = `\u6CA1\u6709\u627E\u5230\u76F8\u5173\u7684\u65E5\u5FD7\u8BB0\u5F55\u3002`; - return; - } - const { page, page_size } = pagination; - const startIndex = (page - 1) * page_size; - const logsHtml = logs.map((log, index) => { - const isChecked = selectedLogIds.has(log.ID); - return this.createLogRowHtml(log, startIndex + index + 1, isChecked); - }).join(""); - this.container.innerHTML = logsHtml; - } - _interpretError(log) { - if (log.IsSuccess) { - return { - type: "N/A", - statusCodeHtml: `\u6210\u529F` - }; - } - const codeMatch = log.ErrorCode ? log.ErrorCode.match(errorCodeRegex) : null; - if (codeMatch && codeMatch[1] && log.ErrorMessage) { - const code = parseInt(codeMatch[1], 10); - const lowerCaseMsg = log.ErrorMessage.toLowerCase(); - for (const rule of SPECIAL_CASE_MAP) { - if (code === rule.code && lowerCaseMsg.includes(rule.keyword)) { - return { - type: rule.type, - statusCodeHtml: `${code}` - }; - } - } - } - if (log.ErrorCode && STATIC_ERROR_MAP[log.ErrorCode]) { - const mapping = STATIC_ERROR_MAP[log.ErrorCode]; - return { - type: mapping.type, - statusCodeHtml: `${log.ErrorCode}` - }; - } - if (codeMatch && codeMatch[1]) { - const code = parseInt(codeMatch[1], 10); - let mapping = STATUS_CODE_MAP[code]; - if (!mapping && code >= 500 && code < 600) { - mapping = STATUS_CODE_MAP[500]; - } - if (mapping) { - return { - type: mapping.type, - statusCodeHtml: `${code}` - }; - } - } - if (!log.ErrorCode && !log.ErrorMessage) { - return { type: "\u672A\u77E5", statusCodeHtml: `N/A` }; - } - return { type: "\u672A\u77E5\u9519\u8BEF", statusCodeHtml: `\u5931\u8D25` }; - } - _formatModelName(modelName) { - const styleClass = ""; - return `
${modelName}
`; - } - createLogRowHtml(log, index, isChecked) { - const group = this.dataStore.groups.get(log.GroupID); - const groupName = group ? group.display_name : log.GroupID ? `Group #${log.GroupID}` : "N/A"; - const key = this.dataStore.keys.get(log.KeyID); - let apiKeyDisplay; - if (key && key.APIKey && key.APIKey.length >= 8) { - const masked = `${key.APIKey.substring(0, 4)}......${key.APIKey.substring(key.APIKey.length - 4)}`; - apiKeyDisplay = escapeHTML(masked); - } else { - apiKeyDisplay = log.KeyID ? `Key #${log.KeyID}` : "N/A"; - } - const errorInfo = this._interpretError(log); - const modelNameFormatted = this._formatModelName(log.ModelName); - const errorMessageAttr = log.ErrorMessage ? `data-error-message="${escape(log.ErrorMessage)}"` : ""; - const requestTime = new Date(log.RequestTime).toLocaleString(); - const checkedAttr = isChecked ? "checked" : ""; - return ` - - - - - ${index} - ${apiKeyDisplay} - ${groupName} - ${errorInfo.type} - ${errorInfo.statusCodeHtml} - ${modelNameFormatted} - ${requestTime} - - - - - `; - } -}; -var logList_default = LogList; - -// frontend/js/components/customSelectV2.js -var import_popper_esm_min = __toESM(require_popper_esm_min()); -var CustomSelectV2 = class _CustomSelectV2 { - constructor(container) { - this.container = container; - this.trigger = this.container.querySelector(".custom-select-trigger"); - this.nativeSelect = this.container.querySelector("select"); - this.template = this.container.querySelector(".custom-select-panel-template"); - if (!this.trigger || !this.nativeSelect || !this.template) { - console.warn("CustomSelectV2 cannot initialize: missing required elements.", this.container); - return; - } - this.panel = null; - this.popperInstance = null; - this.isOpen = false; - this.triggerText = this.trigger.querySelector("span"); - if (typeof _CustomSelectV2.openInstance === "undefined") { - _CustomSelectV2.openInstance = null; - _CustomSelectV2.initGlobalListener(); - } - this.updateTriggerText(); - this.bindEvents(); - } - static initGlobalListener() { - document.addEventListener("click", (event) => { - const instance = _CustomSelectV2.openInstance; - if (instance && !instance.container.contains(event.target) && (!instance.panel || !instance.panel.contains(event.target))) { - instance.close(); - } - }); - } - createPanel() { - const panelFragment = this.template.content.cloneNode(true); - this.panel = panelFragment.querySelector(".custom-select-panel"); - document.body.appendChild(this.panel); - this.panel.innerHTML = ""; - Array.from(this.nativeSelect.options).forEach((option) => { - const item = document.createElement("a"); - item.href = "#"; - item.className = "custom-select-option block w-full text-left px-3 py-1.5 text-sm text-zinc-700 hover:bg-zinc-100 dark:text-zinc-200 dark:hover:bg-zinc-700"; - item.textContent = option.textContent; - item.dataset.value = option.value; - if (option.selected) { - item.classList.add("is-selected"); - } - this.panel.appendChild(item); - }); - this.panel.addEventListener("click", (event) => { - event.preventDefault(); - const optionEl = event.target.closest(".custom-select-option"); - if (optionEl) { - this.selectOption(optionEl); - } - }); - } - bindEvents() { - this.trigger.addEventListener("click", (event) => { - event.stopPropagation(); - if (_CustomSelectV2.openInstance && _CustomSelectV2.openInstance !== this) { - _CustomSelectV2.openInstance.close(); - } - this.toggle(); - }); - } - selectOption(optionEl) { - const selectedValue = optionEl.dataset.value; - if (this.nativeSelect.value !== selectedValue) { - this.nativeSelect.value = selectedValue; - this.nativeSelect.dispatchEvent(new Event("change", { bubbles: true })); - } - this.updateTriggerText(); - this.close(); - } - updateTriggerText() { - const selectedOption = this.nativeSelect.options[this.nativeSelect.selectedIndex]; - if (selectedOption) { - this.triggerText.textContent = selectedOption.textContent; - } - } - toggle() { - this.isOpen ? this.close() : this.open(); - } - open() { - if (this.isOpen) return; - this.isOpen = true; - if (!this.panel) { - this.createPanel(); - } - this.panel.style.display = "block"; - this.panel.offsetHeight; - this.popperInstance = (0, import_popper_esm_min.createPopper)(this.trigger, this.panel, { - placement: "top-start", - modifiers: [ - { name: "offset", options: { offset: [0, 8] } }, - { name: "flip", options: { fallbackPlacements: ["bottom-start"] } } - ] - }); - _CustomSelectV2.openInstance = this; - } - close() { - if (!this.isOpen) return; - this.isOpen = false; - if (this.popperInstance) { - this.popperInstance.destroy(); - this.popperInstance = null; - } - if (this.panel) { - this.panel.remove(); - this.panel = null; - } - if (_CustomSelectV2.openInstance === this) { - _CustomSelectV2.openInstance = null; - } - } -}; - -// frontend/js/components/filterPopover.js -var import_popper_esm_min2 = __toESM(require_popper_esm_min()); -var FilterPopover = class { - constructor(triggerElement, options, title) { - if (!triggerElement || typeof import_popper_esm_min2.createPopper !== "function") { - console.error("FilterPopover: Trigger element or Popper.js not found."); - return; - } - this.triggerElement = triggerElement; - this.options = options; - this.title = title; - this.selectedValues = /* @__PURE__ */ new Set(); - this._createPopoverHTML(); - this.popperInstance = (0, import_popper_esm_min2.createPopper)(this.triggerElement, this.popoverElement, { - placement: "bottom-start", - modifiers: [{ name: "offset", options: { offset: [0, 8] } }] - }); - this._bindEvents(); - } - _createPopoverHTML() { - this.popoverElement = document.createElement("div"); - this.popoverElement.className = "hidden z-50 min-w-[12rem] rounded-md border bg-popover bg-white dark:bg-zinc-800 p-2 text-popover-foreground shadow-md"; - this.popoverElement.innerHTML = ` -
${this.title}
-
- ${this.options.map((option) => ` - - `).join("")} -
-
- - -
- `; - document.body.appendChild(this.popoverElement); - } - _bindEvents() { - this.triggerElement.addEventListener("click", () => this.toggle()); - document.addEventListener("click", (event) => { - if (!this.popoverElement.contains(event.target) && !this.triggerElement.contains(event.target)) { - this.hide(); - } - }); - this.popoverElement.addEventListener("click", (event) => { - const target = event.target.closest("button"); - if (!target) return; - const action = target.dataset.action; - if (action === "clear") this._handleClear(); - if (action === "apply") this._handleApply(); - }); - } - _handleClear() { - this.popoverElement.querySelectorAll('input[type="checkbox"]').forEach((cb) => cb.checked = false); - this.selectedValues.clear(); - this._handleApply(); - } - _handleApply() { - this.selectedValues.clear(); - this.popoverElement.querySelectorAll("input:checked").forEach((cb) => { - this.selectedValues.add(cb.value); - }); - const filterChangeEvent = new CustomEvent("filter-change", { - detail: { - filterKey: this.triggerElement.id, - selected: this.selectedValues - } - }); - this.triggerElement.dispatchEvent(filterChangeEvent); - this.hide(); - } - toggle() { - this.popoverElement.classList.toggle("hidden"); - this.popperInstance.update(); - } - hide() { - this.popoverElement.classList.add("hidden"); - } -}; - -// frontend/js/pages/logs/systemLog.js -var SystemLogTerminal = class { - constructor(container, controlsContainer) { - this.container = container; - this.controlsContainer = controlsContainer; - this.ws = null; - this.isPaused = false; - this.shouldAutoScroll = true; - this.reconnectAttempts = 0; - this.maxReconnectAttempts = 5; - this.isConnected = false; - this.elements = { - output: this.container.querySelector("#log-terminal-output"), - statusIndicator: this.controlsContainer.querySelector("#terminal-status-indicator"), - clearBtn: this.controlsContainer.querySelector('[data-action="clear-terminal"]'), - pauseBtn: this.controlsContainer.querySelector('[data-action="toggle-pause-terminal"]'), - scrollBtn: this.controlsContainer.querySelector('[data-action="toggle-scroll-terminal"]'), - connectBtn: this.controlsContainer.querySelector('[data-action="toggle-connect-terminal"]'), - settingsBtn: this.controlsContainer.querySelector('[data-action="terminal-settings"]') - }; - this._initEventListeners(); - } - _initEventListeners() { - this.elements.clearBtn.addEventListener("click", () => this.clear()); - this.elements.pauseBtn.addEventListener("click", () => this.togglePause()); - this.elements.scrollBtn.addEventListener("click", () => this.toggleAutoScroll()); - this.elements.connectBtn.addEventListener("click", () => this.toggleConnect()); - this.elements.settingsBtn.addEventListener("click", () => this.openSettings()); - } - toggleConnect() { - if (this.isConnected) { - this.disconnect(); - } else { - this.connect(); - } - } - connect() { - this.clear(); - this._appendMessage("info", "\u6B63\u5728\u8FDE\u63A5\u5230\u5B9E\u65F6\u65E5\u5FD7\u6D41..."); - this._updateStatus("connecting", "\u8FDE\u63A5\u4E2D..."); - const protocol = window.location.protocol === "https:" ? "wss:" : "ws:"; - const wsUrl = `${protocol}//${window.location.host}/ws/system-logs`; - this.ws = new WebSocket(wsUrl); - this.ws.onopen = () => { - this._appendMessage("info", "\u2713 \u5DF2\u8FDE\u63A5\u5230\u7CFB\u7EDF\u65E5\u5FD7\u6D41"); - this._updateStatus("connected", "\u5DF2\u8FDE\u63A5"); - this.reconnectAttempts = 0; - this.isConnected = true; - this.elements.connectBtn.title = "\u65AD\u5F00"; - this.elements.connectBtn.querySelector("i").classList.replace("fa-plug", "fa-minus-circle"); - }; - this.ws.onmessage = (event) => { - if (this.isPaused) return; - try { - const data = JSON.parse(event.data); - const levelColors = { - "error": "text-red-500", - "warning": "text-yellow-400", - "info": "text-green-400", - "debug": "text-zinc-400" - }; - const color = levelColors[data.level] || "text-zinc-200"; - const timestamp = new Date(data.timestamp).toLocaleTimeString(); - const msg = `[${timestamp}] [${data.level.toUpperCase()}] ${data.message}`; - this._appendMessage(color, msg); - } catch (e) { - this._appendMessage("text-zinc-200", event.data); - } - }; - this.ws.onerror = (error) => { - this._appendMessage("error", `\u2717 WebSocket \u9519\u8BEF`); - this._updateStatus("error", "\u8FDE\u63A5\u9519\u8BEF"); - }; - this.ws.onclose = () => { - this._appendMessage("error", "\u2717 \u8FDE\u63A5\u5DF2\u65AD\u5F00"); - this._updateStatus("disconnected", "\u672A\u8FDE\u63A5"); - this.isConnected = false; - this.elements.connectBtn.title = "\u8FDE\u63A5"; - this.elements.connectBtn.querySelector("i").classList.replace("fa-minus-circle", "fa-plug"); - if (this.reconnectAttempts < this.maxReconnectAttempts) { - this.reconnectAttempts++; - setTimeout(() => { - this._appendMessage("info", `\u5C1D\u8BD5\u91CD\u65B0\u8FDE\u63A5 (${this.reconnectAttempts}/${this.maxReconnectAttempts})...`); - this.connect(); - }, 3e3); - } - }; - } - disconnect() { - if (this.ws) { - this.ws.close(); - this.ws = null; - } - this.reconnectAttempts = this.maxReconnectAttempts; - this.isConnected = false; - this._updateStatus("disconnected", "\u672A\u8FDE\u63A5"); - this.elements.connectBtn.title = "\u8FDE\u63A5"; - this.elements.connectBtn.querySelector("i").classList.replace("fa-minus-circle", "fa-plug"); - } - clear() { - if (this.elements.output) { - this.elements.output.innerHTML = ""; - } - } - togglePause() { - this.isPaused = !this.isPaused; - const icon = this.elements.pauseBtn.querySelector("i"); - if (this.isPaused) { - this.elements.pauseBtn.title = "\u7EE7\u7EED"; - icon.classList.replace("fa-pause", "fa-play"); - } else { - this.elements.pauseBtn.title = "\u6682\u505C"; - icon.classList.replace("fa-play", "fa-pause"); - } - } - toggleAutoScroll() { - this.shouldAutoScroll = !this.shouldAutoScroll; - this.elements.scrollBtn.title = this.shouldAutoScroll ? "\u81EA\u52A8\u6EDA\u52A8" : "\u624B\u52A8\u6EDA\u52A8"; - } - openSettings() { - console.log("\u6253\u5F00\u8BBE\u7F6E"); - } - _appendMessage(colorClass, text) { - if (!this.elements.output) return; - const p = document.createElement("p"); - p.className = colorClass; - p.textContent = text; - this.elements.output.appendChild(p); - if (this.shouldAutoScroll) { - this.elements.output.scrollTop = this.elements.output.scrollHeight; - } - } - _updateStatus(status, text) { - const indicator = this.elements.statusIndicator.querySelector("span.relative"); - const statusText = this.elements.statusIndicator.childNodes[2]; - const colors = { - "connecting": "bg-yellow-500", - "connected": "bg-green-500", - "disconnected": "bg-zinc-500", - "error": "bg-red-500" - }; - indicator.querySelectorAll("span").forEach((span) => { - span.className = span.className.replace(/bg-\w+-\d+/g, colors[status] || colors.disconnected); - }); - if (statusText) { - statusText.textContent = ` ${text}`; - } - } -}; - -// frontend/js/pages/logs/index.js -var dataStore = { - groups: /* @__PURE__ */ new Map(), - keys: /* @__PURE__ */ new Map() -}; -var LogsPage = class { - constructor() { - this.state = { - logs: [], - pagination: { page: 1, pages: 1, total: 0, page_size: 20 }, - isLoading: true, - filters: { - page: 1, - page_size: 20, - q: "", - key_ids: /* @__PURE__ */ new Set(), - group_ids: /* @__PURE__ */ new Set(), - error_types: /* @__PURE__ */ new Set(), - status_codes: /* @__PURE__ */ new Set() - }, - selectedLogIds: /* @__PURE__ */ new Set(), - currentView: "error" - }; - this.elements = { - tabsContainer: document.querySelector("[data-sliding-tabs-container]"), - contentContainer: document.getElementById("log-content-container"), - errorFilters: document.getElementById("error-logs-filters"), - systemControls: document.getElementById("system-logs-controls"), - errorTemplate: document.getElementById("error-logs-template"), - systemTemplate: document.getElementById("system-logs-template") - }; - this.initialized = !!this.elements.contentContainer; - if (this.initialized) { - this.logList = null; - this.systemLogTerminal = null; - this.debouncedLoadAndRender = debounce(() => this.loadAndRenderLogs(), 300); - } - } - async init() { - if (!this.initialized) return; - this._initPermanentEventListeners(); - await this.loadGroupsOnce(); - this.state.currentView = null; - this.switchToView("error"); - } - _initPermanentEventListeners() { - this.elements.tabsContainer.addEventListener("click", (event) => { - const tabItem = event.target.closest("[data-tab-target]"); - if (!tabItem) return; - event.preventDefault(); - const viewName = tabItem.dataset.tabTarget; - if (viewName) { - this.switchToView(viewName); - } - }); - } - switchToView(viewName) { - if (this.state.currentView === viewName && this.elements.contentContainer.innerHTML !== "") return; - if (this.systemLogTerminal) { - this.systemLogTerminal.disconnect(); - this.systemLogTerminal = null; - } - this.state.currentView = viewName; - this.elements.contentContainer.innerHTML = ""; - if (viewName === "error") { - this.elements.errorFilters.classList.remove("hidden"); - this.elements.systemControls.classList.add("hidden"); - const template = this.elements.errorTemplate.content.cloneNode(true); - this.elements.contentContainer.appendChild(template); - requestAnimationFrame(() => { - this._initErrorLogView(); - }); - } else if (viewName === "system") { - this.elements.errorFilters.classList.add("hidden"); - this.elements.systemControls.classList.remove("hidden"); - const template = this.elements.systemTemplate.content.cloneNode(true); - this.elements.contentContainer.appendChild(template); - requestAnimationFrame(() => { - this._initSystemLogView(); - }); - } - } - _initErrorLogView() { - this.elements.tableBody = document.getElementById("logs-table-body"); - this.elements.selectedCount = document.querySelector(".flex-1.text-sm span.font-semibold:nth-child(1)"); - this.elements.totalCount = document.querySelector(".flex-1.text-sm span:last-child"); - this.elements.pageSizeSelect = document.querySelector('[data-component="custom-select-v2"] select'); - this.elements.pageInfo = document.querySelector(".flex.w-\\[100px\\]"); - this.elements.paginationBtns = document.querySelectorAll("[data-pagination-controls] button"); - this.elements.selectAllCheckbox = document.querySelector('thead .table-head-cell input[type="checkbox"]'); - this.elements.searchInput = document.getElementById("log-search-input"); - this.elements.errorTypeFilterBtn = document.getElementById("filter-error-type-btn"); - this.elements.errorCodeFilterBtn = document.getElementById("filter-error-code-btn"); - this.logList = new logList_default(this.elements.tableBody, dataStore); - const selectContainer = document.querySelector('[data-component="custom-select-v2"]'); - if (selectContainer) { - new CustomSelectV2(selectContainer); - } - this.initFilterPopovers(); - this.initEventListeners(); - this.loadAndRenderLogs(); - } - _initSystemLogView() { - this.systemLogTerminal = new SystemLogTerminal( - this.elements.contentContainer, - this.elements.systemControls - ); - Swal.fire({ - width: "20rem", - backdrop: `rgba(0,0,0,0.5)`, - heightAuto: false, - customClass: { - popup: `swal2-custom-style ${document.documentElement.classList.contains("dark") ? "swal2-dark" : ""}` - }, - title: "\u7CFB\u7EDF\u7EC8\u7AEF\u65E5\u5FD7", - text: "\u60A8\u5373\u5C06\u8FDE\u63A5\u5230\u5B9E\u65F6\u7CFB\u7EDF\u65E5\u5FD7\u6D41\u7A97\u53E3\u3002", - showCancelButton: true, - confirmButtonText: "\u786E\u8BA4", - cancelButtonText: "\u53D6\u6D88", - reverseButtons: false, - confirmButtonColor: "rgba(31, 102, 255, 0.8)", - cancelButtonColor: "#6b7280", - focusConfirm: false, - focusCancel: false, - target: "#main-content-wrapper" - }).then((result) => { - if (result.isConfirmed) { - this.systemLogTerminal.connect(); - } else { - const errorLogTab = Array.from(this.elements.tabsContainer.querySelectorAll('[data-tab-target="error"]'))[0]; - if (errorLogTab) errorLogTab.click(); - } - }); - } - initFilterPopovers() { - const errorTypeOptions = [ - ...Object.values(STATUS_CODE_MAP).map((v) => ({ value: v.type, label: v.type })), - ...Object.values(STATIC_ERROR_MAP).map((v) => ({ value: v.type, label: v.type })) - ]; - const uniqueErrorTypeOptions = Array.from(new Map(errorTypeOptions.map((item) => [item.value, item])).values()); - if (this.elements.errorTypeFilterBtn) { - new FilterPopover(this.elements.errorTypeFilterBtn, uniqueErrorTypeOptions, "\u7B5B\u9009\u9519\u8BEF\u7C7B\u578B"); - } - const statusCodeOptions = Object.keys(STATUS_CODE_MAP).map((code) => ({ value: code, label: code })); - if (this.elements.errorCodeFilterBtn) { - new FilterPopover(this.elements.errorCodeFilterBtn, statusCodeOptions, "\u7B5B\u9009\u72B6\u6001\u7801"); - } - } - initEventListeners() { - if (this.elements.pageSizeSelect) { - this.elements.pageSizeSelect.addEventListener("change", (e) => this.changePageSize(parseInt(e.target.value, 10))); - } - if (this.elements.paginationBtns.length >= 4) { - this.elements.paginationBtns[0].addEventListener("click", () => this.goToPage(1)); - this.elements.paginationBtns[1].addEventListener("click", () => this.goToPage(this.state.pagination.page - 1)); - this.elements.paginationBtns[2].addEventListener("click", () => this.goToPage(this.state.pagination.page + 1)); - this.elements.paginationBtns[3].addEventListener("click", () => this.goToPage(this.state.pagination.pages)); - } - if (this.elements.selectAllCheckbox) { - this.elements.selectAllCheckbox.addEventListener("change", (event) => this.handleSelectAllChange(event)); - } - if (this.elements.tableBody) { - this.elements.tableBody.addEventListener("change", (event) => { - if (event.target.type === "checkbox") this.handleSelectionChange(event.target); - }); - } - if (this.elements.searchInput) { - this.elements.searchInput.addEventListener("input", (event) => this.handleSearchInput(event)); - } - if (this.elements.errorTypeFilterBtn) { - this.elements.errorTypeFilterBtn.addEventListener("filter-change", (e) => this.handleFilterChange(e)); - } - if (this.elements.errorCodeFilterBtn) { - this.elements.errorCodeFilterBtn.addEventListener("filter-change", (e) => this.handleFilterChange(e)); - } - } - handleFilterChange(event) { - const { filterKey, selected } = event.detail; - if (filterKey === "filter-error-type-btn") { - this.state.filters.error_types = selected; - } else if (filterKey === "filter-error-code-btn") { - this.state.filters.status_codes = selected; - } - this.state.filters.page = 1; - this.loadAndRenderLogs(); - } - handleSearchInput(event) { - const searchTerm = event.target.value.trim().toLowerCase(); - this.state.filters.page = 1; - this.state.filters.q = ""; - this.state.filters.key_ids = /* @__PURE__ */ new Set(); - this.state.filters.group_ids = /* @__PURE__ */ new Set(); - if (searchTerm === "") { - this.debouncedLoadAndRender(); - return; - } - const matchedGroupIds = /* @__PURE__ */ new Set(); - dataStore.groups.forEach((group) => { - if (group.display_name.toLowerCase().includes(searchTerm)) { - matchedGroupIds.add(group.id); - } - }); - const matchedKeyIds = /* @__PURE__ */ new Set(); - dataStore.keys.forEach((key) => { - if (key.APIKey && key.APIKey.toLowerCase().includes(searchTerm)) { - matchedKeyIds.add(key.ID); - } - }); - if (matchedGroupIds.size > 0) this.state.filters.group_ids = matchedGroupIds; - if (matchedKeyIds.size > 0) this.state.filters.key_ids = matchedKeyIds; - if (matchedGroupIds.size === 0 && matchedKeyIds.size === 0) { - this.state.filters.q = searchTerm; - } - this.debouncedLoadAndRender(); - } - handleSelectionChange(checkbox) { - const row = checkbox.closest(".table-row"); - if (!row) return; - const logId = parseInt(row.dataset.logId, 10); - if (isNaN(logId)) return; - if (checkbox.checked) { - this.state.selectedLogIds.add(logId); - } else { - this.state.selectedLogIds.delete(logId); - } - this.syncSelectionUI(); - } - handleSelectAllChange(event) { - const isChecked = event.target.checked; - this.state.logs.forEach((log) => { - if (isChecked) { - this.state.selectedLogIds.add(log.ID); - } else { - this.state.selectedLogIds.delete(log.ID); - } - }); - this.syncRowCheckboxes(); - this.syncSelectionUI(); - } - syncRowCheckboxes() { - const isAllChecked = this.elements.selectAllCheckbox.checked; - this.elements.tableBody.querySelectorAll('input[type="checkbox"]').forEach((cb) => { - cb.checked = isAllChecked; - }); - } - syncSelectionUI() { - if (!this.elements.selectAllCheckbox || !this.elements.selectedCount) return; - const selectedCount = this.state.selectedLogIds.size; - const visibleLogsCount = this.state.logs.length; - if (selectedCount === 0) { - this.elements.selectAllCheckbox.checked = false; - this.elements.selectAllCheckbox.indeterminate = false; - } else if (selectedCount < visibleLogsCount) { - this.elements.selectAllCheckbox.checked = false; - this.elements.selectAllCheckbox.indeterminate = true; - } else if (selectedCount === visibleLogsCount && visibleLogsCount > 0) { - this.elements.selectAllCheckbox.checked = true; - this.elements.selectAllCheckbox.indeterminate = false; - } - this.elements.selectedCount.textContent = selectedCount; - } - changePageSize(newSize) { - this.state.filters.page_size = newSize; - this.state.filters.page = 1; - this.loadAndRenderLogs(); - } - goToPage(page) { - if (page < 1 || page > this.state.pagination.pages || this.state.isLoading) return; - this.state.filters.page = page; - this.loadAndRenderLogs(); - } - updatePaginationUI() { - const { page, pages, total } = this.state.pagination; - if (this.elements.pageInfo) { - this.elements.pageInfo.textContent = `\u7B2C ${page} / ${pages} \u9875`; - } - if (this.elements.totalCount) { - this.elements.totalCount.textContent = total; - } - if (this.elements.paginationBtns.length >= 4) { - const isFirstPage = page === 1; - const isLastPage = page === pages || pages === 0; - this.elements.paginationBtns[0].disabled = isFirstPage; - this.elements.paginationBtns[1].disabled = isFirstPage; - this.elements.paginationBtns[2].disabled = isLastPage; - this.elements.paginationBtns[3].disabled = isLastPage; - } - } - async loadGroupsOnce() { - if (dataStore.groups.size > 0) return; - try { - const { success, data } = await apiFetchJson("/admin/keygroups"); - if (success && Array.isArray(data)) { - data.forEach((group) => dataStore.groups.set(group.id, group)); - } - } catch (error) { - console.error("Failed to load key groups:", error); - } - } - async loadAndRenderLogs() { - this.state.isLoading = true; - this.state.selectedLogIds.clear(); - this.logList.renderLoading(); - this.updatePaginationUI(); - this.syncSelectionUI(); - try { - const finalParams = {}; - const { filters } = this.state; - Object.keys(filters).forEach((key) => { - if (!(filters[key] instanceof Set)) { - finalParams[key] = filters[key]; - } - }); - const translatedErrorCodes = /* @__PURE__ */ new Set(); - const translatedStatusCodes = new Set(filters.status_codes); - if (filters.error_types.size > 0) { - filters.error_types.forEach((type) => { - for (const [code, obj] of Object.entries(STATUS_CODE_MAP)) { - if (obj.type === type) translatedStatusCodes.add(code); - } - for (const [code, obj] of Object.entries(STATIC_ERROR_MAP)) { - if (obj.type === type) translatedErrorCodes.add(code); - } - }); - } - if (filters.key_ids.size > 0) finalParams.key_ids = [...filters.key_ids].join(","); - if (filters.group_ids.size > 0) finalParams.group_ids = [...filters.group_ids].join(","); - if (translatedErrorCodes.size > 0) finalParams.error_codes = [...translatedErrorCodes].join(","); - if (translatedStatusCodes.size > 0) finalParams.status_codes = [...translatedStatusCodes].join(","); - Object.keys(finalParams).forEach((key) => { - if (finalParams[key] === "" || finalParams[key] === null || finalParams[key] === void 0) { - delete finalParams[key]; - } - }); - const query = new URLSearchParams(finalParams); - const { success, data } = await apiFetchJson(`/admin/logs?${query.toString()}`); - if (success && typeof data === "object" && data.items) { - const { items, total, page, page_size } = data; - this.state.logs = items; - const totalPages = Math.ceil(total / page_size); - this.state.pagination = { page, page_size, total, pages: totalPages > 0 ? totalPages : 1 }; - await this.enrichLogsWithKeyNames(items); - this.logList.render(this.state.logs, this.state.pagination, this.state.selectedLogIds); - } else { - this.state.logs = []; - this.state.pagination = { ...this.state.pagination, total: 0, pages: 1, page: 1 }; - this.logList.render([], this.state.pagination); - } - } catch (error) { - console.error("Failed to load logs:", error); - this.state.logs = []; - this.state.pagination = { ...this.state.pagination, total: 0, pages: 1, page: 1 }; - this.logList.render([], this.state.pagination); - } finally { - this.state.isLoading = false; - this.updatePaginationUI(); - this.syncSelectionUI(); - } - } - async enrichLogsWithKeyNames(logs) { - const missingKeyIds = [...new Set( - logs.filter((log) => log.KeyID && !dataStore.keys.has(log.KeyID)).map((log) => log.KeyID) - )]; - if (missingKeyIds.length === 0) return; - try { - const idsQuery = missingKeyIds.join(","); - const { success, data } = await apiFetchJson(`/admin/apikeys?ids=${idsQuery}`); - if (success && Array.isArray(data)) { - data.forEach((key) => dataStore.keys.set(key.ID, key)); - } - } catch (error) { - console.error(`Failed to fetch key details:`, error); - } - } -}; -function logs_default() { - const page = new LogsPage(); - page.init(); -} -export { - logs_default as default -}; diff --git a/web/static/js/logs-YPEOUZVC.js b/web/static/js/logs-YPEOUZVC.js new file mode 100644 index 0000000..1fe39f9 --- /dev/null +++ b/web/static/js/logs-YPEOUZVC.js @@ -0,0 +1,2598 @@ +import { + debounce, + escapeHTML +} from "./chunk-A4OOMLXK.js"; +import { + apiFetchJson +} from "./chunk-PLQL6WIO.js"; +import { + __commonJS, + __toESM +} from "./chunk-JSBRDJBE.js"; + +// frontend/js/vendor/popper.esm.min.js +var require_popper_esm_min = __commonJS({ + "frontend/js/vendor/popper.esm.min.js"(exports, module) { + !(function(e, t) { + "object" == typeof exports && "undefined" != typeof module ? t(exports) : "function" == typeof define && define.amd ? define(["exports"], t) : t((e = "undefined" != typeof globalThis ? globalThis : e || self).Popper = {}); + })(exports, (function(e) { + "use strict"; + function t(e2) { + if (null == e2) return window; + if ("[object Window]" !== e2.toString()) { + var t2 = e2.ownerDocument; + return t2 && t2.defaultView || window; + } + return e2; + } + function n(e2) { + return e2 instanceof t(e2).Element || e2 instanceof Element; + } + function r(e2) { + return e2 instanceof t(e2).HTMLElement || e2 instanceof HTMLElement; + } + function o(e2) { + return "undefined" != typeof ShadowRoot && (e2 instanceof t(e2).ShadowRoot || e2 instanceof ShadowRoot); + } + var i = Math.max, a = Math.min, s = Math.round; + function f() { + var e2 = navigator.userAgentData; + return null != e2 && e2.brands && Array.isArray(e2.brands) ? e2.brands.map((function(e3) { + return e3.brand + "/" + e3.version; + })).join(" ") : navigator.userAgent; + } + function c() { + return !/^((?!chrome|android).)*safari/i.test(f()); + } + function p(e2, o2, i2) { + void 0 === o2 && (o2 = false), void 0 === i2 && (i2 = false); + var a2 = e2.getBoundingClientRect(), f2 = 1, p2 = 1; + o2 && r(e2) && (f2 = e2.offsetWidth > 0 && s(a2.width) / e2.offsetWidth || 1, p2 = e2.offsetHeight > 0 && s(a2.height) / e2.offsetHeight || 1); + var u2 = (n(e2) ? t(e2) : window).visualViewport, l2 = !c() && i2, d2 = (a2.left + (l2 && u2 ? u2.offsetLeft : 0)) / f2, h2 = (a2.top + (l2 && u2 ? u2.offsetTop : 0)) / p2, m2 = a2.width / f2, v2 = a2.height / p2; + return { width: m2, height: v2, top: h2, right: d2 + m2, bottom: h2 + v2, left: d2, x: d2, y: h2 }; + } + function u(e2) { + var n2 = t(e2); + return { scrollLeft: n2.pageXOffset, scrollTop: n2.pageYOffset }; + } + function l(e2) { + return e2 ? (e2.nodeName || "").toLowerCase() : null; + } + function d(e2) { + return ((n(e2) ? e2.ownerDocument : e2.document) || window.document).documentElement; + } + function h(e2) { + return p(d(e2)).left + u(e2).scrollLeft; + } + function m(e2) { + return t(e2).getComputedStyle(e2); + } + function v(e2) { + var t2 = m(e2), n2 = t2.overflow, r2 = t2.overflowX, o2 = t2.overflowY; + return /auto|scroll|overlay|hidden/.test(n2 + o2 + r2); + } + function y(e2, n2, o2) { + void 0 === o2 && (o2 = false); + var i2, a2, f2 = r(n2), c2 = r(n2) && (function(e3) { + var t2 = e3.getBoundingClientRect(), n3 = s(t2.width) / e3.offsetWidth || 1, r2 = s(t2.height) / e3.offsetHeight || 1; + return 1 !== n3 || 1 !== r2; + })(n2), m2 = d(n2), y2 = p(e2, c2, o2), g2 = { scrollLeft: 0, scrollTop: 0 }, b2 = { x: 0, y: 0 }; + return (f2 || !f2 && !o2) && (("body" !== l(n2) || v(m2)) && (g2 = (i2 = n2) !== t(i2) && r(i2) ? { scrollLeft: (a2 = i2).scrollLeft, scrollTop: a2.scrollTop } : u(i2)), r(n2) ? ((b2 = p(n2, true)).x += n2.clientLeft, b2.y += n2.clientTop) : m2 && (b2.x = h(m2))), { x: y2.left + g2.scrollLeft - b2.x, y: y2.top + g2.scrollTop - b2.y, width: y2.width, height: y2.height }; + } + function g(e2) { + var t2 = p(e2), n2 = e2.offsetWidth, r2 = e2.offsetHeight; + return Math.abs(t2.width - n2) <= 1 && (n2 = t2.width), Math.abs(t2.height - r2) <= 1 && (r2 = t2.height), { x: e2.offsetLeft, y: e2.offsetTop, width: n2, height: r2 }; + } + function b(e2) { + return "html" === l(e2) ? e2 : e2.assignedSlot || e2.parentNode || (o(e2) ? e2.host : null) || d(e2); + } + function x(e2) { + return ["html", "body", "#document"].indexOf(l(e2)) >= 0 ? e2.ownerDocument.body : r(e2) && v(e2) ? e2 : x(b(e2)); + } + function w(e2, n2) { + var r2; + void 0 === n2 && (n2 = []); + var o2 = x(e2), i2 = o2 === (null == (r2 = e2.ownerDocument) ? void 0 : r2.body), a2 = t(o2), s2 = i2 ? [a2].concat(a2.visualViewport || [], v(o2) ? o2 : []) : o2, f2 = n2.concat(s2); + return i2 ? f2 : f2.concat(w(b(s2))); + } + function O(e2) { + return ["table", "td", "th"].indexOf(l(e2)) >= 0; + } + function j(e2) { + return r(e2) && "fixed" !== m(e2).position ? e2.offsetParent : null; + } + function E(e2) { + for (var n2 = t(e2), i2 = j(e2); i2 && O(i2) && "static" === m(i2).position; ) i2 = j(i2); + return i2 && ("html" === l(i2) || "body" === l(i2) && "static" === m(i2).position) ? n2 : i2 || (function(e3) { + var t2 = /firefox/i.test(f()); + if (/Trident/i.test(f()) && r(e3) && "fixed" === m(e3).position) return null; + var n3 = b(e3); + for (o(n3) && (n3 = n3.host); r(n3) && ["html", "body"].indexOf(l(n3)) < 0; ) { + var i3 = m(n3); + if ("none" !== i3.transform || "none" !== i3.perspective || "paint" === i3.contain || -1 !== ["transform", "perspective"].indexOf(i3.willChange) || t2 && "filter" === i3.willChange || t2 && i3.filter && "none" !== i3.filter) return n3; + n3 = n3.parentNode; + } + return null; + })(e2) || n2; + } + var D = "top", A = "bottom", L = "right", P = "left", M = "auto", k = [D, A, L, P], W = "start", B = "end", H = "viewport", T = "popper", R = k.reduce((function(e2, t2) { + return e2.concat([t2 + "-" + W, t2 + "-" + B]); + }), []), S = [].concat(k, [M]).reduce((function(e2, t2) { + return e2.concat([t2, t2 + "-" + W, t2 + "-" + B]); + }), []), V = ["beforeRead", "read", "afterRead", "beforeMain", "main", "afterMain", "beforeWrite", "write", "afterWrite"]; + function q(e2) { + var t2 = /* @__PURE__ */ new Map(), n2 = /* @__PURE__ */ new Set(), r2 = []; + function o2(e3) { + n2.add(e3.name), [].concat(e3.requires || [], e3.requiresIfExists || []).forEach((function(e4) { + if (!n2.has(e4)) { + var r3 = t2.get(e4); + r3 && o2(r3); + } + })), r2.push(e3); + } + return e2.forEach((function(e3) { + t2.set(e3.name, e3); + })), e2.forEach((function(e3) { + n2.has(e3.name) || o2(e3); + })), r2; + } + function C(e2, t2) { + var n2 = t2.getRootNode && t2.getRootNode(); + if (e2.contains(t2)) return true; + if (n2 && o(n2)) { + var r2 = t2; + do { + if (r2 && e2.isSameNode(r2)) return true; + r2 = r2.parentNode || r2.host; + } while (r2); + } + return false; + } + function N(e2) { + return Object.assign({}, e2, { left: e2.x, top: e2.y, right: e2.x + e2.width, bottom: e2.y + e2.height }); + } + function I(e2, r2, o2) { + return r2 === H ? N((function(e3, n2) { + var r3 = t(e3), o3 = d(e3), i2 = r3.visualViewport, a2 = o3.clientWidth, s2 = o3.clientHeight, f2 = 0, p2 = 0; + if (i2) { + a2 = i2.width, s2 = i2.height; + var u2 = c(); + (u2 || !u2 && "fixed" === n2) && (f2 = i2.offsetLeft, p2 = i2.offsetTop); + } + return { width: a2, height: s2, x: f2 + h(e3), y: p2 }; + })(e2, o2)) : n(r2) ? (function(e3, t2) { + var n2 = p(e3, false, "fixed" === t2); + return n2.top = n2.top + e3.clientTop, n2.left = n2.left + e3.clientLeft, n2.bottom = n2.top + e3.clientHeight, n2.right = n2.left + e3.clientWidth, n2.width = e3.clientWidth, n2.height = e3.clientHeight, n2.x = n2.left, n2.y = n2.top, n2; + })(r2, o2) : N((function(e3) { + var t2, n2 = d(e3), r3 = u(e3), o3 = null == (t2 = e3.ownerDocument) ? void 0 : t2.body, a2 = i(n2.scrollWidth, n2.clientWidth, o3 ? o3.scrollWidth : 0, o3 ? o3.clientWidth : 0), s2 = i(n2.scrollHeight, n2.clientHeight, o3 ? o3.scrollHeight : 0, o3 ? o3.clientHeight : 0), f2 = -r3.scrollLeft + h(e3), c2 = -r3.scrollTop; + return "rtl" === m(o3 || n2).direction && (f2 += i(n2.clientWidth, o3 ? o3.clientWidth : 0) - a2), { width: a2, height: s2, x: f2, y: c2 }; + })(d(e2))); + } + function _(e2, t2, o2, s2) { + var f2 = "clippingParents" === t2 ? (function(e3) { + var t3 = w(b(e3)), o3 = ["absolute", "fixed"].indexOf(m(e3).position) >= 0 && r(e3) ? E(e3) : e3; + return n(o3) ? t3.filter((function(e4) { + return n(e4) && C(e4, o3) && "body" !== l(e4); + })) : []; + })(e2) : [].concat(t2), c2 = [].concat(f2, [o2]), p2 = c2[0], u2 = c2.reduce((function(t3, n2) { + var r2 = I(e2, n2, s2); + return t3.top = i(r2.top, t3.top), t3.right = a(r2.right, t3.right), t3.bottom = a(r2.bottom, t3.bottom), t3.left = i(r2.left, t3.left), t3; + }), I(e2, p2, s2)); + return u2.width = u2.right - u2.left, u2.height = u2.bottom - u2.top, u2.x = u2.left, u2.y = u2.top, u2; + } + function F(e2) { + return e2.split("-")[0]; + } + function U(e2) { + return e2.split("-")[1]; + } + function z(e2) { + return ["top", "bottom"].indexOf(e2) >= 0 ? "x" : "y"; + } + function X(e2) { + var t2, n2 = e2.reference, r2 = e2.element, o2 = e2.placement, i2 = o2 ? F(o2) : null, a2 = o2 ? U(o2) : null, s2 = n2.x + n2.width / 2 - r2.width / 2, f2 = n2.y + n2.height / 2 - r2.height / 2; + switch (i2) { + case D: + t2 = { x: s2, y: n2.y - r2.height }; + break; + case A: + t2 = { x: s2, y: n2.y + n2.height }; + break; + case L: + t2 = { x: n2.x + n2.width, y: f2 }; + break; + case P: + t2 = { x: n2.x - r2.width, y: f2 }; + break; + default: + t2 = { x: n2.x, y: n2.y }; + } + var c2 = i2 ? z(i2) : null; + if (null != c2) { + var p2 = "y" === c2 ? "height" : "width"; + switch (a2) { + case W: + t2[c2] = t2[c2] - (n2[p2] / 2 - r2[p2] / 2); + break; + case B: + t2[c2] = t2[c2] + (n2[p2] / 2 - r2[p2] / 2); + } + } + return t2; + } + function Y(e2) { + return Object.assign({}, { top: 0, right: 0, bottom: 0, left: 0 }, e2); + } + function G(e2, t2) { + return t2.reduce((function(t3, n2) { + return t3[n2] = e2, t3; + }), {}); + } + function J(e2, t2) { + void 0 === t2 && (t2 = {}); + var r2 = t2, o2 = r2.placement, i2 = void 0 === o2 ? e2.placement : o2, a2 = r2.strategy, s2 = void 0 === a2 ? e2.strategy : a2, f2 = r2.boundary, c2 = void 0 === f2 ? "clippingParents" : f2, u2 = r2.rootBoundary, l2 = void 0 === u2 ? H : u2, h2 = r2.elementContext, m2 = void 0 === h2 ? T : h2, v2 = r2.altBoundary, y2 = void 0 !== v2 && v2, g2 = r2.padding, b2 = void 0 === g2 ? 0 : g2, x2 = Y("number" != typeof b2 ? b2 : G(b2, k)), w2 = m2 === T ? "reference" : T, O2 = e2.rects.popper, j2 = e2.elements[y2 ? w2 : m2], E2 = _(n(j2) ? j2 : j2.contextElement || d(e2.elements.popper), c2, l2, s2), P2 = p(e2.elements.reference), M2 = X({ reference: P2, element: O2, strategy: "absolute", placement: i2 }), W2 = N(Object.assign({}, O2, M2)), B2 = m2 === T ? W2 : P2, R2 = { top: E2.top - B2.top + x2.top, bottom: B2.bottom - E2.bottom + x2.bottom, left: E2.left - B2.left + x2.left, right: B2.right - E2.right + x2.right }, S2 = e2.modifiersData.offset; + if (m2 === T && S2) { + var V2 = S2[i2]; + Object.keys(R2).forEach((function(e3) { + var t3 = [L, A].indexOf(e3) >= 0 ? 1 : -1, n2 = [D, A].indexOf(e3) >= 0 ? "y" : "x"; + R2[e3] += V2[n2] * t3; + })); + } + return R2; + } + var K = { placement: "bottom", modifiers: [], strategy: "absolute" }; + function Q() { + for (var e2 = arguments.length, t2 = new Array(e2), n2 = 0; n2 < e2; n2++) t2[n2] = arguments[n2]; + return !t2.some((function(e3) { + return !(e3 && "function" == typeof e3.getBoundingClientRect); + })); + } + function Z(e2) { + void 0 === e2 && (e2 = {}); + var t2 = e2, r2 = t2.defaultModifiers, o2 = void 0 === r2 ? [] : r2, i2 = t2.defaultOptions, a2 = void 0 === i2 ? K : i2; + return function(e3, t3, r3) { + void 0 === r3 && (r3 = a2); + var i3, s2, f2 = { placement: "bottom", orderedModifiers: [], options: Object.assign({}, K, a2), modifiersData: {}, elements: { reference: e3, popper: t3 }, attributes: {}, styles: {} }, c2 = [], p2 = false, u2 = { state: f2, setOptions: function(r4) { + var i4 = "function" == typeof r4 ? r4(f2.options) : r4; + l2(), f2.options = Object.assign({}, a2, f2.options, i4), f2.scrollParents = { reference: n(e3) ? w(e3) : e3.contextElement ? w(e3.contextElement) : [], popper: w(t3) }; + var s3, p3, d2 = (function(e4) { + var t4 = q(e4); + return V.reduce((function(e5, n2) { + return e5.concat(t4.filter((function(e6) { + return e6.phase === n2; + }))); + }), []); + })((s3 = [].concat(o2, f2.options.modifiers), p3 = s3.reduce((function(e4, t4) { + var n2 = e4[t4.name]; + return e4[t4.name] = n2 ? Object.assign({}, n2, t4, { options: Object.assign({}, n2.options, t4.options), data: Object.assign({}, n2.data, t4.data) }) : t4, e4; + }), {}), Object.keys(p3).map((function(e4) { + return p3[e4]; + })))); + return f2.orderedModifiers = d2.filter((function(e4) { + return e4.enabled; + })), f2.orderedModifiers.forEach((function(e4) { + var t4 = e4.name, n2 = e4.options, r5 = void 0 === n2 ? {} : n2, o3 = e4.effect; + if ("function" == typeof o3) { + var i5 = o3({ state: f2, name: t4, instance: u2, options: r5 }), a3 = function() { + }; + c2.push(i5 || a3); + } + })), u2.update(); + }, forceUpdate: function() { + if (!p2) { + var e4 = f2.elements, t4 = e4.reference, n2 = e4.popper; + if (Q(t4, n2)) { + f2.rects = { reference: y(t4, E(n2), "fixed" === f2.options.strategy), popper: g(n2) }, f2.reset = false, f2.placement = f2.options.placement, f2.orderedModifiers.forEach((function(e5) { + return f2.modifiersData[e5.name] = Object.assign({}, e5.data); + })); + for (var r4 = 0; r4 < f2.orderedModifiers.length; r4++) if (true !== f2.reset) { + var o3 = f2.orderedModifiers[r4], i4 = o3.fn, a3 = o3.options, s3 = void 0 === a3 ? {} : a3, c3 = o3.name; + "function" == typeof i4 && (f2 = i4({ state: f2, options: s3, name: c3, instance: u2 }) || f2); + } else f2.reset = false, r4 = -1; + } + } + }, update: (i3 = function() { + return new Promise((function(e4) { + u2.forceUpdate(), e4(f2); + })); + }, function() { + return s2 || (s2 = new Promise((function(e4) { + Promise.resolve().then((function() { + s2 = void 0, e4(i3()); + })); + }))), s2; + }), destroy: function() { + l2(), p2 = true; + } }; + if (!Q(e3, t3)) return u2; + function l2() { + c2.forEach((function(e4) { + return e4(); + })), c2 = []; + } + return u2.setOptions(r3).then((function(e4) { + !p2 && r3.onFirstUpdate && r3.onFirstUpdate(e4); + })), u2; + }; + } + var $ = { passive: true }; + var ee = { name: "eventListeners", enabled: true, phase: "write", fn: function() { + }, effect: function(e2) { + var n2 = e2.state, r2 = e2.instance, o2 = e2.options, i2 = o2.scroll, a2 = void 0 === i2 || i2, s2 = o2.resize, f2 = void 0 === s2 || s2, c2 = t(n2.elements.popper), p2 = [].concat(n2.scrollParents.reference, n2.scrollParents.popper); + return a2 && p2.forEach((function(e3) { + e3.addEventListener("scroll", r2.update, $); + })), f2 && c2.addEventListener("resize", r2.update, $), function() { + a2 && p2.forEach((function(e3) { + e3.removeEventListener("scroll", r2.update, $); + })), f2 && c2.removeEventListener("resize", r2.update, $); + }; + }, data: {} }; + var te = { name: "popperOffsets", enabled: true, phase: "read", fn: function(e2) { + var t2 = e2.state, n2 = e2.name; + t2.modifiersData[n2] = X({ reference: t2.rects.reference, element: t2.rects.popper, strategy: "absolute", placement: t2.placement }); + }, data: {} }, ne = { top: "auto", right: "auto", bottom: "auto", left: "auto" }; + function re(e2) { + var n2, r2 = e2.popper, o2 = e2.popperRect, i2 = e2.placement, a2 = e2.variation, f2 = e2.offsets, c2 = e2.position, p2 = e2.gpuAcceleration, u2 = e2.adaptive, l2 = e2.roundOffsets, h2 = e2.isFixed, v2 = f2.x, y2 = void 0 === v2 ? 0 : v2, g2 = f2.y, b2 = void 0 === g2 ? 0 : g2, x2 = "function" == typeof l2 ? l2({ x: y2, y: b2 }) : { x: y2, y: b2 }; + y2 = x2.x, b2 = x2.y; + var w2 = f2.hasOwnProperty("x"), O2 = f2.hasOwnProperty("y"), j2 = P, M2 = D, k2 = window; + if (u2) { + var W2 = E(r2), H2 = "clientHeight", T2 = "clientWidth"; + if (W2 === t(r2) && "static" !== m(W2 = d(r2)).position && "absolute" === c2 && (H2 = "scrollHeight", T2 = "scrollWidth"), W2 = W2, i2 === D || (i2 === P || i2 === L) && a2 === B) M2 = A, b2 -= (h2 && W2 === k2 && k2.visualViewport ? k2.visualViewport.height : W2[H2]) - o2.height, b2 *= p2 ? 1 : -1; + if (i2 === P || (i2 === D || i2 === A) && a2 === B) j2 = L, y2 -= (h2 && W2 === k2 && k2.visualViewport ? k2.visualViewport.width : W2[T2]) - o2.width, y2 *= p2 ? 1 : -1; + } + var R2, S2 = Object.assign({ position: c2 }, u2 && ne), V2 = true === l2 ? (function(e3, t2) { + var n3 = e3.x, r3 = e3.y, o3 = t2.devicePixelRatio || 1; + return { x: s(n3 * o3) / o3 || 0, y: s(r3 * o3) / o3 || 0 }; + })({ x: y2, y: b2 }, t(r2)) : { x: y2, y: b2 }; + return y2 = V2.x, b2 = V2.y, p2 ? Object.assign({}, S2, ((R2 = {})[M2] = O2 ? "0" : "", R2[j2] = w2 ? "0" : "", R2.transform = (k2.devicePixelRatio || 1) <= 1 ? "translate(" + y2 + "px, " + b2 + "px)" : "translate3d(" + y2 + "px, " + b2 + "px, 0)", R2)) : Object.assign({}, S2, ((n2 = {})[M2] = O2 ? b2 + "px" : "", n2[j2] = w2 ? y2 + "px" : "", n2.transform = "", n2)); + } + var oe = { name: "computeStyles", enabled: true, phase: "beforeWrite", fn: function(e2) { + var t2 = e2.state, n2 = e2.options, r2 = n2.gpuAcceleration, o2 = void 0 === r2 || r2, i2 = n2.adaptive, a2 = void 0 === i2 || i2, s2 = n2.roundOffsets, f2 = void 0 === s2 || s2, c2 = { placement: F(t2.placement), variation: U(t2.placement), popper: t2.elements.popper, popperRect: t2.rects.popper, gpuAcceleration: o2, isFixed: "fixed" === t2.options.strategy }; + null != t2.modifiersData.popperOffsets && (t2.styles.popper = Object.assign({}, t2.styles.popper, re(Object.assign({}, c2, { offsets: t2.modifiersData.popperOffsets, position: t2.options.strategy, adaptive: a2, roundOffsets: f2 })))), null != t2.modifiersData.arrow && (t2.styles.arrow = Object.assign({}, t2.styles.arrow, re(Object.assign({}, c2, { offsets: t2.modifiersData.arrow, position: "absolute", adaptive: false, roundOffsets: f2 })))), t2.attributes.popper = Object.assign({}, t2.attributes.popper, { "data-popper-placement": t2.placement }); + }, data: {} }; + var ie = { name: "applyStyles", enabled: true, phase: "write", fn: function(e2) { + var t2 = e2.state; + Object.keys(t2.elements).forEach((function(e3) { + var n2 = t2.styles[e3] || {}, o2 = t2.attributes[e3] || {}, i2 = t2.elements[e3]; + r(i2) && l(i2) && (Object.assign(i2.style, n2), Object.keys(o2).forEach((function(e4) { + var t3 = o2[e4]; + false === t3 ? i2.removeAttribute(e4) : i2.setAttribute(e4, true === t3 ? "" : t3); + }))); + })); + }, effect: function(e2) { + var t2 = e2.state, n2 = { popper: { position: t2.options.strategy, left: "0", top: "0", margin: "0" }, arrow: { position: "absolute" }, reference: {} }; + return Object.assign(t2.elements.popper.style, n2.popper), t2.styles = n2, t2.elements.arrow && Object.assign(t2.elements.arrow.style, n2.arrow), function() { + Object.keys(t2.elements).forEach((function(e3) { + var o2 = t2.elements[e3], i2 = t2.attributes[e3] || {}, a2 = Object.keys(t2.styles.hasOwnProperty(e3) ? t2.styles[e3] : n2[e3]).reduce((function(e4, t3) { + return e4[t3] = "", e4; + }), {}); + r(o2) && l(o2) && (Object.assign(o2.style, a2), Object.keys(i2).forEach((function(e4) { + o2.removeAttribute(e4); + }))); + })); + }; + }, requires: ["computeStyles"] }; + var ae = { name: "offset", enabled: true, phase: "main", requires: ["popperOffsets"], fn: function(e2) { + var t2 = e2.state, n2 = e2.options, r2 = e2.name, o2 = n2.offset, i2 = void 0 === o2 ? [0, 0] : o2, a2 = S.reduce((function(e3, n3) { + return e3[n3] = (function(e4, t3, n4) { + var r3 = F(e4), o3 = [P, D].indexOf(r3) >= 0 ? -1 : 1, i3 = "function" == typeof n4 ? n4(Object.assign({}, t3, { placement: e4 })) : n4, a3 = i3[0], s3 = i3[1]; + return a3 = a3 || 0, s3 = (s3 || 0) * o3, [P, L].indexOf(r3) >= 0 ? { x: s3, y: a3 } : { x: a3, y: s3 }; + })(n3, t2.rects, i2), e3; + }), {}), s2 = a2[t2.placement], f2 = s2.x, c2 = s2.y; + null != t2.modifiersData.popperOffsets && (t2.modifiersData.popperOffsets.x += f2, t2.modifiersData.popperOffsets.y += c2), t2.modifiersData[r2] = a2; + } }, se = { left: "right", right: "left", bottom: "top", top: "bottom" }; + function fe(e2) { + return e2.replace(/left|right|bottom|top/g, (function(e3) { + return se[e3]; + })); + } + var ce = { start: "end", end: "start" }; + function pe(e2) { + return e2.replace(/start|end/g, (function(e3) { + return ce[e3]; + })); + } + function ue(e2, t2) { + void 0 === t2 && (t2 = {}); + var n2 = t2, r2 = n2.placement, o2 = n2.boundary, i2 = n2.rootBoundary, a2 = n2.padding, s2 = n2.flipVariations, f2 = n2.allowedAutoPlacements, c2 = void 0 === f2 ? S : f2, p2 = U(r2), u2 = p2 ? s2 ? R : R.filter((function(e3) { + return U(e3) === p2; + })) : k, l2 = u2.filter((function(e3) { + return c2.indexOf(e3) >= 0; + })); + 0 === l2.length && (l2 = u2); + var d2 = l2.reduce((function(t3, n3) { + return t3[n3] = J(e2, { placement: n3, boundary: o2, rootBoundary: i2, padding: a2 })[F(n3)], t3; + }), {}); + return Object.keys(d2).sort((function(e3, t3) { + return d2[e3] - d2[t3]; + })); + } + var le = { name: "flip", enabled: true, phase: "main", fn: function(e2) { + var t2 = e2.state, n2 = e2.options, r2 = e2.name; + if (!t2.modifiersData[r2]._skip) { + for (var o2 = n2.mainAxis, i2 = void 0 === o2 || o2, a2 = n2.altAxis, s2 = void 0 === a2 || a2, f2 = n2.fallbackPlacements, c2 = n2.padding, p2 = n2.boundary, u2 = n2.rootBoundary, l2 = n2.altBoundary, d2 = n2.flipVariations, h2 = void 0 === d2 || d2, m2 = n2.allowedAutoPlacements, v2 = t2.options.placement, y2 = F(v2), g2 = f2 || (y2 === v2 || !h2 ? [fe(v2)] : (function(e3) { + if (F(e3) === M) return []; + var t3 = fe(e3); + return [pe(e3), t3, pe(t3)]; + })(v2)), b2 = [v2].concat(g2).reduce((function(e3, n3) { + return e3.concat(F(n3) === M ? ue(t2, { placement: n3, boundary: p2, rootBoundary: u2, padding: c2, flipVariations: h2, allowedAutoPlacements: m2 }) : n3); + }), []), x2 = t2.rects.reference, w2 = t2.rects.popper, O2 = /* @__PURE__ */ new Map(), j2 = true, E2 = b2[0], k2 = 0; k2 < b2.length; k2++) { + var B2 = b2[k2], H2 = F(B2), T2 = U(B2) === W, R2 = [D, A].indexOf(H2) >= 0, S2 = R2 ? "width" : "height", V2 = J(t2, { placement: B2, boundary: p2, rootBoundary: u2, altBoundary: l2, padding: c2 }), q2 = R2 ? T2 ? L : P : T2 ? A : D; + x2[S2] > w2[S2] && (q2 = fe(q2)); + var C2 = fe(q2), N2 = []; + if (i2 && N2.push(V2[H2] <= 0), s2 && N2.push(V2[q2] <= 0, V2[C2] <= 0), N2.every((function(e3) { + return e3; + }))) { + E2 = B2, j2 = false; + break; + } + O2.set(B2, N2); + } + if (j2) for (var I2 = function(e3) { + var t3 = b2.find((function(t4) { + var n3 = O2.get(t4); + if (n3) return n3.slice(0, e3).every((function(e4) { + return e4; + })); + })); + if (t3) return E2 = t3, "break"; + }, _2 = h2 ? 3 : 1; _2 > 0; _2--) { + if ("break" === I2(_2)) break; + } + t2.placement !== E2 && (t2.modifiersData[r2]._skip = true, t2.placement = E2, t2.reset = true); + } + }, requiresIfExists: ["offset"], data: { _skip: false } }; + function de(e2, t2, n2) { + return i(e2, a(t2, n2)); + } + var he = { name: "preventOverflow", enabled: true, phase: "main", fn: function(e2) { + var t2 = e2.state, n2 = e2.options, r2 = e2.name, o2 = n2.mainAxis, s2 = void 0 === o2 || o2, f2 = n2.altAxis, c2 = void 0 !== f2 && f2, p2 = n2.boundary, u2 = n2.rootBoundary, l2 = n2.altBoundary, d2 = n2.padding, h2 = n2.tether, m2 = void 0 === h2 || h2, v2 = n2.tetherOffset, y2 = void 0 === v2 ? 0 : v2, b2 = J(t2, { boundary: p2, rootBoundary: u2, padding: d2, altBoundary: l2 }), x2 = F(t2.placement), w2 = U(t2.placement), O2 = !w2, j2 = z(x2), M2 = "x" === j2 ? "y" : "x", k2 = t2.modifiersData.popperOffsets, B2 = t2.rects.reference, H2 = t2.rects.popper, T2 = "function" == typeof y2 ? y2(Object.assign({}, t2.rects, { placement: t2.placement })) : y2, R2 = "number" == typeof T2 ? { mainAxis: T2, altAxis: T2 } : Object.assign({ mainAxis: 0, altAxis: 0 }, T2), S2 = t2.modifiersData.offset ? t2.modifiersData.offset[t2.placement] : null, V2 = { x: 0, y: 0 }; + if (k2) { + if (s2) { + var q2, C2 = "y" === j2 ? D : P, N2 = "y" === j2 ? A : L, I2 = "y" === j2 ? "height" : "width", _2 = k2[j2], X2 = _2 + b2[C2], Y2 = _2 - b2[N2], G2 = m2 ? -H2[I2] / 2 : 0, K2 = w2 === W ? B2[I2] : H2[I2], Q2 = w2 === W ? -H2[I2] : -B2[I2], Z2 = t2.elements.arrow, $2 = m2 && Z2 ? g(Z2) : { width: 0, height: 0 }, ee2 = t2.modifiersData["arrow#persistent"] ? t2.modifiersData["arrow#persistent"].padding : { top: 0, right: 0, bottom: 0, left: 0 }, te2 = ee2[C2], ne2 = ee2[N2], re2 = de(0, B2[I2], $2[I2]), oe2 = O2 ? B2[I2] / 2 - G2 - re2 - te2 - R2.mainAxis : K2 - re2 - te2 - R2.mainAxis, ie2 = O2 ? -B2[I2] / 2 + G2 + re2 + ne2 + R2.mainAxis : Q2 + re2 + ne2 + R2.mainAxis, ae2 = t2.elements.arrow && E(t2.elements.arrow), se2 = ae2 ? "y" === j2 ? ae2.clientTop || 0 : ae2.clientLeft || 0 : 0, fe2 = null != (q2 = null == S2 ? void 0 : S2[j2]) ? q2 : 0, ce2 = _2 + ie2 - fe2, pe2 = de(m2 ? a(X2, _2 + oe2 - fe2 - se2) : X2, _2, m2 ? i(Y2, ce2) : Y2); + k2[j2] = pe2, V2[j2] = pe2 - _2; + } + if (c2) { + var ue2, le2 = "x" === j2 ? D : P, he2 = "x" === j2 ? A : L, me2 = k2[M2], ve2 = "y" === M2 ? "height" : "width", ye2 = me2 + b2[le2], ge2 = me2 - b2[he2], be2 = -1 !== [D, P].indexOf(x2), xe2 = null != (ue2 = null == S2 ? void 0 : S2[M2]) ? ue2 : 0, we2 = be2 ? ye2 : me2 - B2[ve2] - H2[ve2] - xe2 + R2.altAxis, Oe = be2 ? me2 + B2[ve2] + H2[ve2] - xe2 - R2.altAxis : ge2, je = m2 && be2 ? (function(e3, t3, n3) { + var r3 = de(e3, t3, n3); + return r3 > n3 ? n3 : r3; + })(we2, me2, Oe) : de(m2 ? we2 : ye2, me2, m2 ? Oe : ge2); + k2[M2] = je, V2[M2] = je - me2; + } + t2.modifiersData[r2] = V2; + } + }, requiresIfExists: ["offset"] }; + var me = { name: "arrow", enabled: true, phase: "main", fn: function(e2) { + var t2, n2 = e2.state, r2 = e2.name, o2 = e2.options, i2 = n2.elements.arrow, a2 = n2.modifiersData.popperOffsets, s2 = F(n2.placement), f2 = z(s2), c2 = [P, L].indexOf(s2) >= 0 ? "height" : "width"; + if (i2 && a2) { + var p2 = (function(e3, t3) { + return Y("number" != typeof (e3 = "function" == typeof e3 ? e3(Object.assign({}, t3.rects, { placement: t3.placement })) : e3) ? e3 : G(e3, k)); + })(o2.padding, n2), u2 = g(i2), l2 = "y" === f2 ? D : P, d2 = "y" === f2 ? A : L, h2 = n2.rects.reference[c2] + n2.rects.reference[f2] - a2[f2] - n2.rects.popper[c2], m2 = a2[f2] - n2.rects.reference[f2], v2 = E(i2), y2 = v2 ? "y" === f2 ? v2.clientHeight || 0 : v2.clientWidth || 0 : 0, b2 = h2 / 2 - m2 / 2, x2 = p2[l2], w2 = y2 - u2[c2] - p2[d2], O2 = y2 / 2 - u2[c2] / 2 + b2, j2 = de(x2, O2, w2), M2 = f2; + n2.modifiersData[r2] = ((t2 = {})[M2] = j2, t2.centerOffset = j2 - O2, t2); + } + }, effect: function(e2) { + var t2 = e2.state, n2 = e2.options.element, r2 = void 0 === n2 ? "[data-popper-arrow]" : n2; + null != r2 && ("string" != typeof r2 || (r2 = t2.elements.popper.querySelector(r2))) && C(t2.elements.popper, r2) && (t2.elements.arrow = r2); + }, requires: ["popperOffsets"], requiresIfExists: ["preventOverflow"] }; + function ve(e2, t2, n2) { + return void 0 === n2 && (n2 = { x: 0, y: 0 }), { top: e2.top - t2.height - n2.y, right: e2.right - t2.width + n2.x, bottom: e2.bottom - t2.height + n2.y, left: e2.left - t2.width - n2.x }; + } + function ye(e2) { + return [D, L, A, P].some((function(t2) { + return e2[t2] >= 0; + })); + } + var ge = { name: "hide", enabled: true, phase: "main", requiresIfExists: ["preventOverflow"], fn: function(e2) { + var t2 = e2.state, n2 = e2.name, r2 = t2.rects.reference, o2 = t2.rects.popper, i2 = t2.modifiersData.preventOverflow, a2 = J(t2, { elementContext: "reference" }), s2 = J(t2, { altBoundary: true }), f2 = ve(a2, r2), c2 = ve(s2, o2, i2), p2 = ye(f2), u2 = ye(c2); + t2.modifiersData[n2] = { referenceClippingOffsets: f2, popperEscapeOffsets: c2, isReferenceHidden: p2, hasPopperEscaped: u2 }, t2.attributes.popper = Object.assign({}, t2.attributes.popper, { "data-popper-reference-hidden": p2, "data-popper-escaped": u2 }); + } }, be = Z({ defaultModifiers: [ee, te, oe, ie] }), xe = [ee, te, oe, ie, ae, le, he, me, ge], we = Z({ defaultModifiers: xe }); + e.applyStyles = ie, e.arrow = me, e.computeStyles = oe, e.createPopper = we, e.createPopperLite = be, e.defaultModifiers = xe, e.detectOverflow = J, e.eventListeners = ee, e.flip = le, e.hide = ge, e.offset = ae, e.popperGenerator = Z, e.popperOffsets = te, e.preventOverflow = he, Object.defineProperty(e, "__esModule", { value: true }); + })); + } +}); + +// frontend/js/vendor/flatpickr.js +var require_flatpickr = __commonJS({ + "frontend/js/vendor/flatpickr.js"(exports, module) { + !(function(e, n) { + "object" == typeof exports && "undefined" != typeof module ? module.exports = n() : "function" == typeof define && define.amd ? define(n) : (e = "undefined" != typeof globalThis ? globalThis : e || self).flatpickr = n(); + })(exports, (function() { + "use strict"; + var e = function() { + return (e = Object.assign || function(e2) { + for (var n2, t2 = 1, a2 = arguments.length; t2 < a2; t2++) for (var i2 in n2 = arguments[t2]) Object.prototype.hasOwnProperty.call(n2, i2) && (e2[i2] = n2[i2]); + return e2; + }).apply(this, arguments); + }; + function n() { + for (var e2 = 0, n2 = 0, t2 = arguments.length; n2 < t2; n2++) e2 += arguments[n2].length; + var a2 = Array(e2), i2 = 0; + for (n2 = 0; n2 < t2; n2++) for (var o2 = arguments[n2], r2 = 0, l2 = o2.length; r2 < l2; r2++, i2++) a2[i2] = o2[r2]; + return a2; + } + var t = ["onChange", "onClose", "onDayCreate", "onDestroy", "onKeyDown", "onMonthChange", "onOpen", "onParseConfig", "onReady", "onValueUpdate", "onYearChange", "onPreCalendarPosition"], a = { _disable: [], allowInput: false, allowInvalidPreload: false, altFormat: "F j, Y", altInput: false, altInputClass: "form-control input", animate: "object" == typeof window && -1 === window.navigator.userAgent.indexOf("MSIE"), ariaDateFormat: "F j, Y", autoFillDefaultTime: true, clickOpens: true, closeOnSelect: true, conjunction: ", ", dateFormat: "Y-m-d", defaultHour: 12, defaultMinute: 0, defaultSeconds: 0, disable: [], disableMobile: false, enableSeconds: false, enableTime: false, errorHandler: function(e2) { + return "undefined" != typeof console && console.warn(e2); + }, getWeek: function(e2) { + var n2 = new Date(e2.getTime()); + n2.setHours(0, 0, 0, 0), n2.setDate(n2.getDate() + 3 - (n2.getDay() + 6) % 7); + var t2 = new Date(n2.getFullYear(), 0, 4); + return 1 + Math.round(((n2.getTime() - t2.getTime()) / 864e5 - 3 + (t2.getDay() + 6) % 7) / 7); + }, hourIncrement: 1, ignoredFocusElements: [], inline: false, locale: "default", minuteIncrement: 5, mode: "single", monthSelectorType: "dropdown", nextArrow: "", noCalendar: false, now: /* @__PURE__ */ new Date(), onChange: [], onClose: [], onDayCreate: [], onDestroy: [], onKeyDown: [], onMonthChange: [], onOpen: [], onParseConfig: [], onReady: [], onValueUpdate: [], onYearChange: [], onPreCalendarPosition: [], plugins: [], position: "auto", positionElement: void 0, prevArrow: "", shorthandCurrentMonth: false, showMonths: 1, static: false, time_24hr: false, weekNumbers: false, wrap: false }, i = { weekdays: { shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], longhand: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] }, months: { shorthand: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], longhand: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] }, daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], firstDayOfWeek: 0, ordinal: function(e2) { + var n2 = e2 % 100; + if (n2 > 3 && n2 < 21) return "th"; + switch (n2 % 10) { + case 1: + return "st"; + case 2: + return "nd"; + case 3: + return "rd"; + default: + return "th"; + } + }, rangeSeparator: " to ", weekAbbreviation: "Wk", scrollTitle: "Scroll to increment", toggleTitle: "Click to toggle", amPM: ["AM", "PM"], yearAriaLabel: "Year", monthAriaLabel: "Month", hourAriaLabel: "Hour", minuteAriaLabel: "Minute", time_24hr: false }, o = function(e2, n2) { + return void 0 === n2 && (n2 = 2), ("000" + e2).slice(-1 * n2); + }, r = function(e2) { + return true === e2 ? 1 : 0; + }; + function l(e2, n2) { + var t2; + return function() { + var a2 = this, i2 = arguments; + clearTimeout(t2), t2 = setTimeout((function() { + return e2.apply(a2, i2); + }), n2); + }; + } + var c = function(e2) { + return e2 instanceof Array ? e2 : [e2]; + }; + function s(e2, n2, t2) { + if (true === t2) return e2.classList.add(n2); + e2.classList.remove(n2); + } + function d(e2, n2, t2) { + var a2 = window.document.createElement(e2); + return n2 = n2 || "", t2 = t2 || "", a2.className = n2, void 0 !== t2 && (a2.textContent = t2), a2; + } + function u(e2) { + for (; e2.firstChild; ) e2.removeChild(e2.firstChild); + } + function f(e2, n2) { + return n2(e2) ? e2 : e2.parentNode ? f(e2.parentNode, n2) : void 0; + } + function m(e2, n2) { + var t2 = d("div", "numInputWrapper"), a2 = d("input", "numInput " + e2), i2 = d("span", "arrowUp"), o2 = d("span", "arrowDown"); + if (-1 === navigator.userAgent.indexOf("MSIE 9.0") ? a2.type = "number" : (a2.type = "text", a2.pattern = "\\d*"), void 0 !== n2) for (var r2 in n2) a2.setAttribute(r2, n2[r2]); + return t2.appendChild(a2), t2.appendChild(i2), t2.appendChild(o2), t2; + } + function g(e2) { + try { + return "function" == typeof e2.composedPath ? e2.composedPath()[0] : e2.target; + } catch (n2) { + return e2.target; + } + } + var p = function() { + }, h = function(e2, n2, t2) { + return t2.months[n2 ? "shorthand" : "longhand"][e2]; + }, v = { D: p, F: function(e2, n2, t2) { + e2.setMonth(t2.months.longhand.indexOf(n2)); + }, G: function(e2, n2) { + e2.setHours((e2.getHours() >= 12 ? 12 : 0) + parseFloat(n2)); + }, H: function(e2, n2) { + e2.setHours(parseFloat(n2)); + }, J: function(e2, n2) { + e2.setDate(parseFloat(n2)); + }, K: function(e2, n2, t2) { + e2.setHours(e2.getHours() % 12 + 12 * r(new RegExp(t2.amPM[1], "i").test(n2))); + }, M: function(e2, n2, t2) { + e2.setMonth(t2.months.shorthand.indexOf(n2)); + }, S: function(e2, n2) { + e2.setSeconds(parseFloat(n2)); + }, U: function(e2, n2) { + return new Date(1e3 * parseFloat(n2)); + }, W: function(e2, n2, t2) { + var a2 = parseInt(n2), i2 = new Date(e2.getFullYear(), 0, 2 + 7 * (a2 - 1), 0, 0, 0, 0); + return i2.setDate(i2.getDate() - i2.getDay() + t2.firstDayOfWeek), i2; + }, Y: function(e2, n2) { + e2.setFullYear(parseFloat(n2)); + }, Z: function(e2, n2) { + return new Date(n2); + }, d: function(e2, n2) { + e2.setDate(parseFloat(n2)); + }, h: function(e2, n2) { + e2.setHours((e2.getHours() >= 12 ? 12 : 0) + parseFloat(n2)); + }, i: function(e2, n2) { + e2.setMinutes(parseFloat(n2)); + }, j: function(e2, n2) { + e2.setDate(parseFloat(n2)); + }, l: p, m: function(e2, n2) { + e2.setMonth(parseFloat(n2) - 1); + }, n: function(e2, n2) { + e2.setMonth(parseFloat(n2) - 1); + }, s: function(e2, n2) { + e2.setSeconds(parseFloat(n2)); + }, u: function(e2, n2) { + return new Date(parseFloat(n2)); + }, w: p, y: function(e2, n2) { + e2.setFullYear(2e3 + parseFloat(n2)); + } }, D = { D: "", F: "", G: "(\\d\\d|\\d)", H: "(\\d\\d|\\d)", J: "(\\d\\d|\\d)\\w+", K: "", M: "", S: "(\\d\\d|\\d)", U: "(.+)", W: "(\\d\\d|\\d)", Y: "(\\d{4})", Z: "(.+)", d: "(\\d\\d|\\d)", h: "(\\d\\d|\\d)", i: "(\\d\\d|\\d)", j: "(\\d\\d|\\d)", l: "", m: "(\\d\\d|\\d)", n: "(\\d\\d|\\d)", s: "(\\d\\d|\\d)", u: "(.+)", w: "(\\d\\d|\\d)", y: "(\\d{2})" }, w = { Z: function(e2) { + return e2.toISOString(); + }, D: function(e2, n2, t2) { + return n2.weekdays.shorthand[w.w(e2, n2, t2)]; + }, F: function(e2, n2, t2) { + return h(w.n(e2, n2, t2) - 1, false, n2); + }, G: function(e2, n2, t2) { + return o(w.h(e2, n2, t2)); + }, H: function(e2) { + return o(e2.getHours()); + }, J: function(e2, n2) { + return void 0 !== n2.ordinal ? e2.getDate() + n2.ordinal(e2.getDate()) : e2.getDate(); + }, K: function(e2, n2) { + return n2.amPM[r(e2.getHours() > 11)]; + }, M: function(e2, n2) { + return h(e2.getMonth(), true, n2); + }, S: function(e2) { + return o(e2.getSeconds()); + }, U: function(e2) { + return e2.getTime() / 1e3; + }, W: function(e2, n2, t2) { + return t2.getWeek(e2); + }, Y: function(e2) { + return o(e2.getFullYear(), 4); + }, d: function(e2) { + return o(e2.getDate()); + }, h: function(e2) { + return e2.getHours() % 12 ? e2.getHours() % 12 : 12; + }, i: function(e2) { + return o(e2.getMinutes()); + }, j: function(e2) { + return e2.getDate(); + }, l: function(e2, n2) { + return n2.weekdays.longhand[e2.getDay()]; + }, m: function(e2) { + return o(e2.getMonth() + 1); + }, n: function(e2) { + return e2.getMonth() + 1; + }, s: function(e2) { + return e2.getSeconds(); + }, u: function(e2) { + return e2.getTime(); + }, w: function(e2) { + return e2.getDay(); + }, y: function(e2) { + return String(e2.getFullYear()).substring(2); + } }, b = function(e2) { + var n2 = e2.config, t2 = void 0 === n2 ? a : n2, o2 = e2.l10n, r2 = void 0 === o2 ? i : o2, l2 = e2.isMobile, c2 = void 0 !== l2 && l2; + return function(e3, n3, a2) { + var i2 = a2 || r2; + return void 0 === t2.formatDate || c2 ? n3.split("").map((function(n4, a3, o3) { + return w[n4] && "\\" !== o3[a3 - 1] ? w[n4](e3, i2, t2) : "\\" !== n4 ? n4 : ""; + })).join("") : t2.formatDate(e3, n3, i2); + }; + }, C = function(e2) { + var n2 = e2.config, t2 = void 0 === n2 ? a : n2, o2 = e2.l10n, r2 = void 0 === o2 ? i : o2; + return function(e3, n3, i2, o3) { + if (0 === e3 || e3) { + var l2, c2 = o3 || r2, s2 = e3; + if (e3 instanceof Date) l2 = new Date(e3.getTime()); + else if ("string" != typeof e3 && void 0 !== e3.toFixed) l2 = new Date(e3); + else if ("string" == typeof e3) { + var d2 = n3 || (t2 || a).dateFormat, u2 = String(e3).trim(); + if ("today" === u2) l2 = /* @__PURE__ */ new Date(), i2 = true; + else if (t2 && t2.parseDate) l2 = t2.parseDate(e3, d2); + else if (/Z$/.test(u2) || /GMT$/.test(u2)) l2 = new Date(e3); + else { + for (var f2 = void 0, m2 = [], g2 = 0, p2 = 0, h2 = ""; g2 < d2.length; g2++) { + var w2 = d2[g2], b2 = "\\" === w2, C2 = "\\" === d2[g2 - 1] || b2; + if (D[w2] && !C2) { + h2 += D[w2]; + var M2 = new RegExp(h2).exec(e3); + M2 && (f2 = true) && m2["Y" !== w2 ? "push" : "unshift"]({ fn: v[w2], val: M2[++p2] }); + } else b2 || (h2 += "."); + } + l2 = t2 && t2.noCalendar ? new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)) : new Date((/* @__PURE__ */ new Date()).getFullYear(), 0, 1, 0, 0, 0, 0), m2.forEach((function(e4) { + var n4 = e4.fn, t3 = e4.val; + return l2 = n4(l2, t3, c2) || l2; + })), l2 = f2 ? l2 : void 0; + } + } + if (l2 instanceof Date && !isNaN(l2.getTime())) return true === i2 && l2.setHours(0, 0, 0, 0), l2; + t2.errorHandler(new Error("Invalid date provided: " + s2)); + } + }; + }; + function M(e2, n2, t2) { + return void 0 === t2 && (t2 = true), false !== t2 ? new Date(e2.getTime()).setHours(0, 0, 0, 0) - new Date(n2.getTime()).setHours(0, 0, 0, 0) : e2.getTime() - n2.getTime(); + } + var y = function(e2, n2, t2) { + return 3600 * e2 + 60 * n2 + t2; + }, x = 864e5; + function E(e2) { + var n2 = e2.defaultHour, t2 = e2.defaultMinute, a2 = e2.defaultSeconds; + if (void 0 !== e2.minDate) { + var i2 = e2.minDate.getHours(), o2 = e2.minDate.getMinutes(), r2 = e2.minDate.getSeconds(); + n2 < i2 && (n2 = i2), n2 === i2 && t2 < o2 && (t2 = o2), n2 === i2 && t2 === o2 && a2 < r2 && (a2 = e2.minDate.getSeconds()); + } + if (void 0 !== e2.maxDate) { + var l2 = e2.maxDate.getHours(), c2 = e2.maxDate.getMinutes(); + (n2 = Math.min(n2, l2)) === l2 && (t2 = Math.min(c2, t2)), n2 === l2 && t2 === c2 && (a2 = e2.maxDate.getSeconds()); + } + return { hours: n2, minutes: t2, seconds: a2 }; + } + "function" != typeof Object.assign && (Object.assign = function(e2) { + for (var n2 = [], t2 = 1; t2 < arguments.length; t2++) n2[t2 - 1] = arguments[t2]; + if (!e2) throw TypeError("Cannot convert undefined or null to object"); + for (var a2 = function(n3) { + n3 && Object.keys(n3).forEach((function(t3) { + return e2[t3] = n3[t3]; + })); + }, i2 = 0, o2 = n2; i2 < o2.length; i2++) { + var r2 = o2[i2]; + a2(r2); + } + return e2; + }); + function k(p2, v2) { + var w2 = { config: e(e({}, a), I.defaultConfig), l10n: i }; + function k2() { + var e2; + return (null === (e2 = w2.calendarContainer) || void 0 === e2 ? void 0 : e2.getRootNode()).activeElement || document.activeElement; + } + function T2(e2) { + return e2.bind(w2); + } + function S() { + var e2 = w2.config; + false === e2.weekNumbers && 1 === e2.showMonths || true !== e2.noCalendar && window.requestAnimationFrame((function() { + if (void 0 !== w2.calendarContainer && (w2.calendarContainer.style.visibility = "hidden", w2.calendarContainer.style.display = "block"), void 0 !== w2.daysContainer) { + var n2 = (w2.days.offsetWidth + 1) * e2.showMonths; + w2.daysContainer.style.width = n2 + "px", w2.calendarContainer.style.width = n2 + (void 0 !== w2.weekWrapper ? w2.weekWrapper.offsetWidth : 0) + "px", w2.calendarContainer.style.removeProperty("visibility"), w2.calendarContainer.style.removeProperty("display"); + } + })); + } + function _(e2) { + if (0 === w2.selectedDates.length) { + var n2 = void 0 === w2.config.minDate || M(/* @__PURE__ */ new Date(), w2.config.minDate) >= 0 ? /* @__PURE__ */ new Date() : new Date(w2.config.minDate.getTime()), t2 = E(w2.config); + n2.setHours(t2.hours, t2.minutes, t2.seconds, n2.getMilliseconds()), w2.selectedDates = [n2], w2.latestSelectedDateObj = n2; + } + void 0 !== e2 && "blur" !== e2.type && (function(e3) { + e3.preventDefault(); + var n3 = "keydown" === e3.type, t3 = g(e3), a3 = t3; + void 0 !== w2.amPM && t3 === w2.amPM && (w2.amPM.textContent = w2.l10n.amPM[r(w2.amPM.textContent === w2.l10n.amPM[0])]); + var i2 = parseFloat(a3.getAttribute("min")), l2 = parseFloat(a3.getAttribute("max")), c2 = parseFloat(a3.getAttribute("step")), s2 = parseInt(a3.value, 10), d2 = e3.delta || (n3 ? 38 === e3.which ? 1 : -1 : 0), u2 = s2 + c2 * d2; + if (void 0 !== a3.value && 2 === a3.value.length) { + var f2 = a3 === w2.hourElement, m2 = a3 === w2.minuteElement; + u2 < i2 ? (u2 = l2 + u2 + r(!f2) + (r(f2) && r(!w2.amPM)), m2 && L(void 0, -1, w2.hourElement)) : u2 > l2 && (u2 = a3 === w2.hourElement ? u2 - l2 - r(!w2.amPM) : i2, m2 && L(void 0, 1, w2.hourElement)), w2.amPM && f2 && (1 === c2 ? u2 + s2 === 23 : Math.abs(u2 - s2) > c2) && (w2.amPM.textContent = w2.l10n.amPM[r(w2.amPM.textContent === w2.l10n.amPM[0])]), a3.value = o(u2); + } + })(e2); + var a2 = w2._input.value; + O(), ye(), w2._input.value !== a2 && w2._debouncedChange(); + } + function O() { + if (void 0 !== w2.hourElement && void 0 !== w2.minuteElement) { + var e2, n2, t2 = (parseInt(w2.hourElement.value.slice(-2), 10) || 0) % 24, a2 = (parseInt(w2.minuteElement.value, 10) || 0) % 60, i2 = void 0 !== w2.secondElement ? (parseInt(w2.secondElement.value, 10) || 0) % 60 : 0; + void 0 !== w2.amPM && (e2 = t2, n2 = w2.amPM.textContent, t2 = e2 % 12 + 12 * r(n2 === w2.l10n.amPM[1])); + var o2 = void 0 !== w2.config.minTime || w2.config.minDate && w2.minDateHasTime && w2.latestSelectedDateObj && 0 === M(w2.latestSelectedDateObj, w2.config.minDate, true), l2 = void 0 !== w2.config.maxTime || w2.config.maxDate && w2.maxDateHasTime && w2.latestSelectedDateObj && 0 === M(w2.latestSelectedDateObj, w2.config.maxDate, true); + if (void 0 !== w2.config.maxTime && void 0 !== w2.config.minTime && w2.config.minTime > w2.config.maxTime) { + var c2 = y(w2.config.minTime.getHours(), w2.config.minTime.getMinutes(), w2.config.minTime.getSeconds()), s2 = y(w2.config.maxTime.getHours(), w2.config.maxTime.getMinutes(), w2.config.maxTime.getSeconds()), d2 = y(t2, a2, i2); + if (d2 > s2 && d2 < c2) { + var u2 = (function(e3) { + var n3 = Math.floor(e3 / 3600), t3 = (e3 - 3600 * n3) / 60; + return [n3, t3, e3 - 3600 * n3 - 60 * t3]; + })(c2); + t2 = u2[0], a2 = u2[1], i2 = u2[2]; + } + } else { + if (l2) { + var f2 = void 0 !== w2.config.maxTime ? w2.config.maxTime : w2.config.maxDate; + (t2 = Math.min(t2, f2.getHours())) === f2.getHours() && (a2 = Math.min(a2, f2.getMinutes())), a2 === f2.getMinutes() && (i2 = Math.min(i2, f2.getSeconds())); + } + if (o2) { + var m2 = void 0 !== w2.config.minTime ? w2.config.minTime : w2.config.minDate; + (t2 = Math.max(t2, m2.getHours())) === m2.getHours() && a2 < m2.getMinutes() && (a2 = m2.getMinutes()), a2 === m2.getMinutes() && (i2 = Math.max(i2, m2.getSeconds())); + } + } + A(t2, a2, i2); + } + } + function F(e2) { + var n2 = e2 || w2.latestSelectedDateObj; + n2 && n2 instanceof Date && A(n2.getHours(), n2.getMinutes(), n2.getSeconds()); + } + function A(e2, n2, t2) { + void 0 !== w2.latestSelectedDateObj && w2.latestSelectedDateObj.setHours(e2 % 24, n2, t2 || 0, 0), w2.hourElement && w2.minuteElement && !w2.isMobile && (w2.hourElement.value = o(w2.config.time_24hr ? e2 : (12 + e2) % 12 + 12 * r(e2 % 12 == 0)), w2.minuteElement.value = o(n2), void 0 !== w2.amPM && (w2.amPM.textContent = w2.l10n.amPM[r(e2 >= 12)]), void 0 !== w2.secondElement && (w2.secondElement.value = o(t2))); + } + function N(e2) { + var n2 = g(e2), t2 = parseInt(n2.value) + (e2.delta || 0); + (t2 / 1e3 > 1 || "Enter" === e2.key && !/[^\d]/.test(t2.toString())) && ee(t2); + } + function P(e2, n2, t2, a2) { + return n2 instanceof Array ? n2.forEach((function(n3) { + return P(e2, n3, t2, a2); + })) : e2 instanceof Array ? e2.forEach((function(e3) { + return P(e3, n2, t2, a2); + })) : (e2.addEventListener(n2, t2, a2), void w2._handlers.push({ remove: function() { + return e2.removeEventListener(n2, t2, a2); + } })); + } + function Y() { + De("onChange"); + } + function j(e2, n2) { + var t2 = void 0 !== e2 ? w2.parseDate(e2) : w2.latestSelectedDateObj || (w2.config.minDate && w2.config.minDate > w2.now ? w2.config.minDate : w2.config.maxDate && w2.config.maxDate < w2.now ? w2.config.maxDate : w2.now), a2 = w2.currentYear, i2 = w2.currentMonth; + try { + void 0 !== t2 && (w2.currentYear = t2.getFullYear(), w2.currentMonth = t2.getMonth()); + } catch (e3) { + e3.message = "Invalid date supplied: " + t2, w2.config.errorHandler(e3); + } + n2 && w2.currentYear !== a2 && (De("onYearChange"), q()), !n2 || w2.currentYear === a2 && w2.currentMonth === i2 || De("onMonthChange"), w2.redraw(); + } + function H(e2) { + var n2 = g(e2); + ~n2.className.indexOf("arrow") && L(e2, n2.classList.contains("arrowUp") ? 1 : -1); + } + function L(e2, n2, t2) { + var a2 = e2 && g(e2), i2 = t2 || a2 && a2.parentNode && a2.parentNode.firstChild, o2 = we("increment"); + o2.delta = n2, i2 && i2.dispatchEvent(o2); + } + function R(e2, n2, t2, a2) { + var i2 = ne(n2, true), o2 = d("span", e2, n2.getDate().toString()); + return o2.dateObj = n2, o2.$i = a2, o2.setAttribute("aria-label", w2.formatDate(n2, w2.config.ariaDateFormat)), -1 === e2.indexOf("hidden") && 0 === M(n2, w2.now) && (w2.todayDateElem = o2, o2.classList.add("today"), o2.setAttribute("aria-current", "date")), i2 ? (o2.tabIndex = -1, be(n2) && (o2.classList.add("selected"), w2.selectedDateElem = o2, "range" === w2.config.mode && (s(o2, "startRange", w2.selectedDates[0] && 0 === M(n2, w2.selectedDates[0], true)), s(o2, "endRange", w2.selectedDates[1] && 0 === M(n2, w2.selectedDates[1], true)), "nextMonthDay" === e2 && o2.classList.add("inRange")))) : o2.classList.add("flatpickr-disabled"), "range" === w2.config.mode && (function(e3) { + return !("range" !== w2.config.mode || w2.selectedDates.length < 2) && (M(e3, w2.selectedDates[0]) >= 0 && M(e3, w2.selectedDates[1]) <= 0); + })(n2) && !be(n2) && o2.classList.add("inRange"), w2.weekNumbers && 1 === w2.config.showMonths && "prevMonthDay" !== e2 && a2 % 7 == 6 && w2.weekNumbers.insertAdjacentHTML("beforeend", "" + w2.config.getWeek(n2) + ""), De("onDayCreate", o2), o2; + } + function W(e2) { + e2.focus(), "range" === w2.config.mode && oe(e2); + } + function B(e2) { + for (var n2 = e2 > 0 ? 0 : w2.config.showMonths - 1, t2 = e2 > 0 ? w2.config.showMonths : -1, a2 = n2; a2 != t2; a2 += e2) for (var i2 = w2.daysContainer.children[a2], o2 = e2 > 0 ? 0 : i2.children.length - 1, r2 = e2 > 0 ? i2.children.length : -1, l2 = o2; l2 != r2; l2 += e2) { + var c2 = i2.children[l2]; + if (-1 === c2.className.indexOf("hidden") && ne(c2.dateObj)) return c2; + } + } + function J(e2, n2) { + var t2 = k2(), a2 = te(t2 || document.body), i2 = void 0 !== e2 ? e2 : a2 ? t2 : void 0 !== w2.selectedDateElem && te(w2.selectedDateElem) ? w2.selectedDateElem : void 0 !== w2.todayDateElem && te(w2.todayDateElem) ? w2.todayDateElem : B(n2 > 0 ? 1 : -1); + void 0 === i2 ? w2._input.focus() : a2 ? (function(e3, n3) { + for (var t3 = -1 === e3.className.indexOf("Month") ? e3.dateObj.getMonth() : w2.currentMonth, a3 = n3 > 0 ? w2.config.showMonths : -1, i3 = n3 > 0 ? 1 : -1, o2 = t3 - w2.currentMonth; o2 != a3; o2 += i3) for (var r2 = w2.daysContainer.children[o2], l2 = t3 - w2.currentMonth === o2 ? e3.$i + n3 : n3 < 0 ? r2.children.length - 1 : 0, c2 = r2.children.length, s2 = l2; s2 >= 0 && s2 < c2 && s2 != (n3 > 0 ? c2 : -1); s2 += i3) { + var d2 = r2.children[s2]; + if (-1 === d2.className.indexOf("hidden") && ne(d2.dateObj) && Math.abs(e3.$i - s2) >= Math.abs(n3)) return W(d2); + } + w2.changeMonth(i3), J(B(i3), 0); + })(i2, n2) : W(i2); + } + function K(e2, n2) { + for (var t2 = (new Date(e2, n2, 1).getDay() - w2.l10n.firstDayOfWeek + 7) % 7, a2 = w2.utils.getDaysInMonth((n2 - 1 + 12) % 12, e2), i2 = w2.utils.getDaysInMonth(n2, e2), o2 = window.document.createDocumentFragment(), r2 = w2.config.showMonths > 1, l2 = r2 ? "prevMonthDay hidden" : "prevMonthDay", c2 = r2 ? "nextMonthDay hidden" : "nextMonthDay", s2 = a2 + 1 - t2, u2 = 0; s2 <= a2; s2++, u2++) o2.appendChild(R("flatpickr-day " + l2, new Date(e2, n2 - 1, s2), 0, u2)); + for (s2 = 1; s2 <= i2; s2++, u2++) o2.appendChild(R("flatpickr-day", new Date(e2, n2, s2), 0, u2)); + for (var f2 = i2 + 1; f2 <= 42 - t2 && (1 === w2.config.showMonths || u2 % 7 != 0); f2++, u2++) o2.appendChild(R("flatpickr-day " + c2, new Date(e2, n2 + 1, f2 % i2), 0, u2)); + var m2 = d("div", "dayContainer"); + return m2.appendChild(o2), m2; + } + function U() { + if (void 0 !== w2.daysContainer) { + u(w2.daysContainer), w2.weekNumbers && u(w2.weekNumbers); + for (var e2 = document.createDocumentFragment(), n2 = 0; n2 < w2.config.showMonths; n2++) { + var t2 = new Date(w2.currentYear, w2.currentMonth, 1); + t2.setMonth(w2.currentMonth + n2), e2.appendChild(K(t2.getFullYear(), t2.getMonth())); + } + w2.daysContainer.appendChild(e2), w2.days = w2.daysContainer.firstChild, "range" === w2.config.mode && 1 === w2.selectedDates.length && oe(); + } + } + function q() { + if (!(w2.config.showMonths > 1 || "dropdown" !== w2.config.monthSelectorType)) { + var e2 = function(e3) { + return !(void 0 !== w2.config.minDate && w2.currentYear === w2.config.minDate.getFullYear() && e3 < w2.config.minDate.getMonth()) && !(void 0 !== w2.config.maxDate && w2.currentYear === w2.config.maxDate.getFullYear() && e3 > w2.config.maxDate.getMonth()); + }; + w2.monthsDropdownContainer.tabIndex = -1, w2.monthsDropdownContainer.innerHTML = ""; + for (var n2 = 0; n2 < 12; n2++) if (e2(n2)) { + var t2 = d("option", "flatpickr-monthDropdown-month"); + t2.value = new Date(w2.currentYear, n2).getMonth().toString(), t2.textContent = h(n2, w2.config.shorthandCurrentMonth, w2.l10n), t2.tabIndex = -1, w2.currentMonth === n2 && (t2.selected = true), w2.monthsDropdownContainer.appendChild(t2); + } + } + } + function $() { + var e2, n2 = d("div", "flatpickr-month"), t2 = window.document.createDocumentFragment(); + w2.config.showMonths > 1 || "static" === w2.config.monthSelectorType ? e2 = d("span", "cur-month") : (w2.monthsDropdownContainer = d("select", "flatpickr-monthDropdown-months"), w2.monthsDropdownContainer.setAttribute("aria-label", w2.l10n.monthAriaLabel), P(w2.monthsDropdownContainer, "change", (function(e3) { + var n3 = g(e3), t3 = parseInt(n3.value, 10); + w2.changeMonth(t3 - w2.currentMonth), De("onMonthChange"); + })), q(), e2 = w2.monthsDropdownContainer); + var a2 = m("cur-year", { tabindex: "-1" }), i2 = a2.getElementsByTagName("input")[0]; + i2.setAttribute("aria-label", w2.l10n.yearAriaLabel), w2.config.minDate && i2.setAttribute("min", w2.config.minDate.getFullYear().toString()), w2.config.maxDate && (i2.setAttribute("max", w2.config.maxDate.getFullYear().toString()), i2.disabled = !!w2.config.minDate && w2.config.minDate.getFullYear() === w2.config.maxDate.getFullYear()); + var o2 = d("div", "flatpickr-current-month"); + return o2.appendChild(e2), o2.appendChild(a2), t2.appendChild(o2), n2.appendChild(t2), { container: n2, yearElement: i2, monthElement: e2 }; + } + function V() { + u(w2.monthNav), w2.monthNav.appendChild(w2.prevMonthNav), w2.config.showMonths && (w2.yearElements = [], w2.monthElements = []); + for (var e2 = w2.config.showMonths; e2--; ) { + var n2 = $(); + w2.yearElements.push(n2.yearElement), w2.monthElements.push(n2.monthElement), w2.monthNav.appendChild(n2.container); + } + w2.monthNav.appendChild(w2.nextMonthNav); + } + function z() { + w2.weekdayContainer ? u(w2.weekdayContainer) : w2.weekdayContainer = d("div", "flatpickr-weekdays"); + for (var e2 = w2.config.showMonths; e2--; ) { + var n2 = d("div", "flatpickr-weekdaycontainer"); + w2.weekdayContainer.appendChild(n2); + } + return G(), w2.weekdayContainer; + } + function G() { + if (w2.weekdayContainer) { + var e2 = w2.l10n.firstDayOfWeek, t2 = n(w2.l10n.weekdays.shorthand); + e2 > 0 && e2 < t2.length && (t2 = n(t2.splice(e2, t2.length), t2.splice(0, e2))); + for (var a2 = w2.config.showMonths; a2--; ) w2.weekdayContainer.children[a2].innerHTML = "\n \n " + t2.join("") + "\n \n "; + } + } + function Z(e2, n2) { + void 0 === n2 && (n2 = true); + var t2 = n2 ? e2 : e2 - w2.currentMonth; + t2 < 0 && true === w2._hidePrevMonthArrow || t2 > 0 && true === w2._hideNextMonthArrow || (w2.currentMonth += t2, (w2.currentMonth < 0 || w2.currentMonth > 11) && (w2.currentYear += w2.currentMonth > 11 ? 1 : -1, w2.currentMonth = (w2.currentMonth + 12) % 12, De("onYearChange"), q()), U(), De("onMonthChange"), Ce()); + } + function Q(e2) { + return w2.calendarContainer.contains(e2); + } + function X(e2) { + if (w2.isOpen && !w2.config.inline) { + var n2 = g(e2), t2 = Q(n2), a2 = !(n2 === w2.input || n2 === w2.altInput || w2.element.contains(n2) || e2.path && e2.path.indexOf && (~e2.path.indexOf(w2.input) || ~e2.path.indexOf(w2.altInput))) && !t2 && !Q(e2.relatedTarget), i2 = !w2.config.ignoredFocusElements.some((function(e3) { + return e3.contains(n2); + })); + a2 && i2 && (w2.config.allowInput && w2.setDate(w2._input.value, false, w2.config.altInput ? w2.config.altFormat : w2.config.dateFormat), void 0 !== w2.timeContainer && void 0 !== w2.minuteElement && void 0 !== w2.hourElement && "" !== w2.input.value && void 0 !== w2.input.value && _(), w2.close(), w2.config && "range" === w2.config.mode && 1 === w2.selectedDates.length && w2.clear(false)); + } + } + function ee(e2) { + if (!(!e2 || w2.config.minDate && e2 < w2.config.minDate.getFullYear() || w2.config.maxDate && e2 > w2.config.maxDate.getFullYear())) { + var n2 = e2, t2 = w2.currentYear !== n2; + w2.currentYear = n2 || w2.currentYear, w2.config.maxDate && w2.currentYear === w2.config.maxDate.getFullYear() ? w2.currentMonth = Math.min(w2.config.maxDate.getMonth(), w2.currentMonth) : w2.config.minDate && w2.currentYear === w2.config.minDate.getFullYear() && (w2.currentMonth = Math.max(w2.config.minDate.getMonth(), w2.currentMonth)), t2 && (w2.redraw(), De("onYearChange"), q()); + } + } + function ne(e2, n2) { + var t2; + void 0 === n2 && (n2 = true); + var a2 = w2.parseDate(e2, void 0, n2); + if (w2.config.minDate && a2 && M(a2, w2.config.minDate, void 0 !== n2 ? n2 : !w2.minDateHasTime) < 0 || w2.config.maxDate && a2 && M(a2, w2.config.maxDate, void 0 !== n2 ? n2 : !w2.maxDateHasTime) > 0) return false; + if (!w2.config.enable && 0 === w2.config.disable.length) return true; + if (void 0 === a2) return false; + for (var i2 = !!w2.config.enable, o2 = null !== (t2 = w2.config.enable) && void 0 !== t2 ? t2 : w2.config.disable, r2 = 0, l2 = void 0; r2 < o2.length; r2++) { + if ("function" == typeof (l2 = o2[r2]) && l2(a2)) return i2; + if (l2 instanceof Date && void 0 !== a2 && l2.getTime() === a2.getTime()) return i2; + if ("string" == typeof l2) { + var c2 = w2.parseDate(l2, void 0, true); + return c2 && c2.getTime() === a2.getTime() ? i2 : !i2; + } + if ("object" == typeof l2 && void 0 !== a2 && l2.from && l2.to && a2.getTime() >= l2.from.getTime() && a2.getTime() <= l2.to.getTime()) return i2; + } + return !i2; + } + function te(e2) { + return void 0 !== w2.daysContainer && (-1 === e2.className.indexOf("hidden") && -1 === e2.className.indexOf("flatpickr-disabled") && w2.daysContainer.contains(e2)); + } + function ae(e2) { + var n2 = e2.target === w2._input, t2 = w2._input.value.trimEnd() !== Me(); + !n2 || !t2 || e2.relatedTarget && Q(e2.relatedTarget) || w2.setDate(w2._input.value, true, e2.target === w2.altInput ? w2.config.altFormat : w2.config.dateFormat); + } + function ie(e2) { + var n2 = g(e2), t2 = w2.config.wrap ? p2.contains(n2) : n2 === w2._input, a2 = w2.config.allowInput, i2 = w2.isOpen && (!a2 || !t2), o2 = w2.config.inline && t2 && !a2; + if (13 === e2.keyCode && t2) { + if (a2) return w2.setDate(w2._input.value, true, n2 === w2.altInput ? w2.config.altFormat : w2.config.dateFormat), w2.close(), n2.blur(); + w2.open(); + } else if (Q(n2) || i2 || o2) { + var r2 = !!w2.timeContainer && w2.timeContainer.contains(n2); + switch (e2.keyCode) { + case 13: + r2 ? (e2.preventDefault(), _(), fe()) : me(e2); + break; + case 27: + e2.preventDefault(), fe(); + break; + case 8: + case 46: + t2 && !w2.config.allowInput && (e2.preventDefault(), w2.clear()); + break; + case 37: + case 39: + if (r2 || t2) w2.hourElement && w2.hourElement.focus(); + else { + e2.preventDefault(); + var l2 = k2(); + if (void 0 !== w2.daysContainer && (false === a2 || l2 && te(l2))) { + var c2 = 39 === e2.keyCode ? 1 : -1; + e2.ctrlKey ? (e2.stopPropagation(), Z(c2), J(B(1), 0)) : J(void 0, c2); + } + } + break; + case 38: + case 40: + e2.preventDefault(); + var s2 = 40 === e2.keyCode ? 1 : -1; + w2.daysContainer && void 0 !== n2.$i || n2 === w2.input || n2 === w2.altInput ? e2.ctrlKey ? (e2.stopPropagation(), ee(w2.currentYear - s2), J(B(1), 0)) : r2 || J(void 0, 7 * s2) : n2 === w2.currentYearElement ? ee(w2.currentYear - s2) : w2.config.enableTime && (!r2 && w2.hourElement && w2.hourElement.focus(), _(e2), w2._debouncedChange()); + break; + case 9: + if (r2) { + var d2 = [w2.hourElement, w2.minuteElement, w2.secondElement, w2.amPM].concat(w2.pluginElements).filter((function(e3) { + return e3; + })), u2 = d2.indexOf(n2); + if (-1 !== u2) { + var f2 = d2[u2 + (e2.shiftKey ? -1 : 1)]; + e2.preventDefault(), (f2 || w2._input).focus(); + } + } else !w2.config.noCalendar && w2.daysContainer && w2.daysContainer.contains(n2) && e2.shiftKey && (e2.preventDefault(), w2._input.focus()); + } + } + if (void 0 !== w2.amPM && n2 === w2.amPM) switch (e2.key) { + case w2.l10n.amPM[0].charAt(0): + case w2.l10n.amPM[0].charAt(0).toLowerCase(): + w2.amPM.textContent = w2.l10n.amPM[0], O(), ye(); + break; + case w2.l10n.amPM[1].charAt(0): + case w2.l10n.amPM[1].charAt(0).toLowerCase(): + w2.amPM.textContent = w2.l10n.amPM[1], O(), ye(); + } + (t2 || Q(n2)) && De("onKeyDown", e2); + } + function oe(e2, n2) { + if (void 0 === n2 && (n2 = "flatpickr-day"), 1 === w2.selectedDates.length && (!e2 || e2.classList.contains(n2) && !e2.classList.contains("flatpickr-disabled"))) { + for (var t2 = e2 ? e2.dateObj.getTime() : w2.days.firstElementChild.dateObj.getTime(), a2 = w2.parseDate(w2.selectedDates[0], void 0, true).getTime(), i2 = Math.min(t2, w2.selectedDates[0].getTime()), o2 = Math.max(t2, w2.selectedDates[0].getTime()), r2 = false, l2 = 0, c2 = 0, s2 = i2; s2 < o2; s2 += x) ne(new Date(s2), true) || (r2 = r2 || s2 > i2 && s2 < o2, s2 < a2 && (!l2 || s2 > l2) ? l2 = s2 : s2 > a2 && (!c2 || s2 < c2) && (c2 = s2)); + Array.from(w2.rContainer.querySelectorAll("*:nth-child(-n+" + w2.config.showMonths + ") > ." + n2)).forEach((function(n3) { + var i3, o3, s3, d2 = n3.dateObj.getTime(), u2 = l2 > 0 && d2 < l2 || c2 > 0 && d2 > c2; + if (u2) return n3.classList.add("notAllowed"), void ["inRange", "startRange", "endRange"].forEach((function(e3) { + n3.classList.remove(e3); + })); + r2 && !u2 || (["startRange", "inRange", "endRange", "notAllowed"].forEach((function(e3) { + n3.classList.remove(e3); + })), void 0 !== e2 && (e2.classList.add(t2 <= w2.selectedDates[0].getTime() ? "startRange" : "endRange"), a2 < t2 && d2 === a2 ? n3.classList.add("startRange") : a2 > t2 && d2 === a2 && n3.classList.add("endRange"), d2 >= l2 && (0 === c2 || d2 <= c2) && (o3 = a2, s3 = t2, (i3 = d2) > Math.min(o3, s3) && i3 < Math.max(o3, s3)) && n3.classList.add("inRange"))); + })); + } + } + function re() { + !w2.isOpen || w2.config.static || w2.config.inline || de(); + } + function le(e2) { + return function(n2) { + var t2 = w2.config["_" + e2 + "Date"] = w2.parseDate(n2, w2.config.dateFormat), a2 = w2.config["_" + ("min" === e2 ? "max" : "min") + "Date"]; + void 0 !== t2 && (w2["min" === e2 ? "minDateHasTime" : "maxDateHasTime"] = t2.getHours() > 0 || t2.getMinutes() > 0 || t2.getSeconds() > 0), w2.selectedDates && (w2.selectedDates = w2.selectedDates.filter((function(e3) { + return ne(e3); + })), w2.selectedDates.length || "min" !== e2 || F(t2), ye()), w2.daysContainer && (ue(), void 0 !== t2 ? w2.currentYearElement[e2] = t2.getFullYear().toString() : w2.currentYearElement.removeAttribute(e2), w2.currentYearElement.disabled = !!a2 && void 0 !== t2 && a2.getFullYear() === t2.getFullYear()); + }; + } + function ce() { + return w2.config.wrap ? p2.querySelector("[data-input]") : p2; + } + function se() { + "object" != typeof w2.config.locale && void 0 === I.l10ns[w2.config.locale] && w2.config.errorHandler(new Error("flatpickr: invalid locale " + w2.config.locale)), w2.l10n = e(e({}, I.l10ns.default), "object" == typeof w2.config.locale ? w2.config.locale : "default" !== w2.config.locale ? I.l10ns[w2.config.locale] : void 0), D.D = "(" + w2.l10n.weekdays.shorthand.join("|") + ")", D.l = "(" + w2.l10n.weekdays.longhand.join("|") + ")", D.M = "(" + w2.l10n.months.shorthand.join("|") + ")", D.F = "(" + w2.l10n.months.longhand.join("|") + ")", D.K = "(" + w2.l10n.amPM[0] + "|" + w2.l10n.amPM[1] + "|" + w2.l10n.amPM[0].toLowerCase() + "|" + w2.l10n.amPM[1].toLowerCase() + ")", void 0 === e(e({}, v2), JSON.parse(JSON.stringify(p2.dataset || {}))).time_24hr && void 0 === I.defaultConfig.time_24hr && (w2.config.time_24hr = w2.l10n.time_24hr), w2.formatDate = b(w2), w2.parseDate = C({ config: w2.config, l10n: w2.l10n }); + } + function de(e2) { + if ("function" != typeof w2.config.position) { + if (void 0 !== w2.calendarContainer) { + De("onPreCalendarPosition"); + var n2 = e2 || w2._positionElement, t2 = Array.prototype.reduce.call(w2.calendarContainer.children, (function(e3, n3) { + return e3 + n3.offsetHeight; + }), 0), a2 = w2.calendarContainer.offsetWidth, i2 = w2.config.position.split(" "), o2 = i2[0], r2 = i2.length > 1 ? i2[1] : null, l2 = n2.getBoundingClientRect(), c2 = window.innerHeight - l2.bottom, d2 = "above" === o2 || "below" !== o2 && c2 < t2 && l2.top > t2, u2 = window.pageYOffset + l2.top + (d2 ? -t2 - 2 : n2.offsetHeight + 2); + if (s(w2.calendarContainer, "arrowTop", !d2), s(w2.calendarContainer, "arrowBottom", d2), !w2.config.inline) { + var f2 = window.pageXOffset + l2.left, m2 = false, g2 = false; + "center" === r2 ? (f2 -= (a2 - l2.width) / 2, m2 = true) : "right" === r2 && (f2 -= a2 - l2.width, g2 = true), s(w2.calendarContainer, "arrowLeft", !m2 && !g2), s(w2.calendarContainer, "arrowCenter", m2), s(w2.calendarContainer, "arrowRight", g2); + var p3 = window.document.body.offsetWidth - (window.pageXOffset + l2.right), h2 = f2 + a2 > window.document.body.offsetWidth, v3 = p3 + a2 > window.document.body.offsetWidth; + if (s(w2.calendarContainer, "rightMost", h2), !w2.config.static) if (w2.calendarContainer.style.top = u2 + "px", h2) if (v3) { + var D2 = (function() { + for (var e3 = null, n3 = 0; n3 < document.styleSheets.length; n3++) { + var t3 = document.styleSheets[n3]; + if (t3.cssRules) { + try { + t3.cssRules; + } catch (e4) { + continue; + } + e3 = t3; + break; + } + } + return null != e3 ? e3 : (a3 = document.createElement("style"), document.head.appendChild(a3), a3.sheet); + var a3; + })(); + if (void 0 === D2) return; + var b2 = window.document.body.offsetWidth, C2 = Math.max(0, b2 / 2 - a2 / 2), M2 = D2.cssRules.length, y2 = "{left:" + l2.left + "px;right:auto;}"; + s(w2.calendarContainer, "rightMost", false), s(w2.calendarContainer, "centerMost", true), D2.insertRule(".flatpickr-calendar.centerMost:before,.flatpickr-calendar.centerMost:after" + y2, M2), w2.calendarContainer.style.left = C2 + "px", w2.calendarContainer.style.right = "auto"; + } else w2.calendarContainer.style.left = "auto", w2.calendarContainer.style.right = p3 + "px"; + else w2.calendarContainer.style.left = f2 + "px", w2.calendarContainer.style.right = "auto"; + } + } + } else w2.config.position(w2, e2); + } + function ue() { + w2.config.noCalendar || w2.isMobile || (q(), Ce(), U()); + } + function fe() { + w2._input.focus(), -1 !== window.navigator.userAgent.indexOf("MSIE") || void 0 !== navigator.msMaxTouchPoints ? setTimeout(w2.close, 0) : w2.close(); + } + function me(e2) { + e2.preventDefault(), e2.stopPropagation(); + var n2 = f(g(e2), (function(e3) { + return e3.classList && e3.classList.contains("flatpickr-day") && !e3.classList.contains("flatpickr-disabled") && !e3.classList.contains("notAllowed"); + })); + if (void 0 !== n2) { + var t2 = n2, a2 = w2.latestSelectedDateObj = new Date(t2.dateObj.getTime()), i2 = (a2.getMonth() < w2.currentMonth || a2.getMonth() > w2.currentMonth + w2.config.showMonths - 1) && "range" !== w2.config.mode; + if (w2.selectedDateElem = t2, "single" === w2.config.mode) w2.selectedDates = [a2]; + else if ("multiple" === w2.config.mode) { + var o2 = be(a2); + o2 ? w2.selectedDates.splice(parseInt(o2), 1) : w2.selectedDates.push(a2); + } else "range" === w2.config.mode && (2 === w2.selectedDates.length && w2.clear(false, false), w2.latestSelectedDateObj = a2, w2.selectedDates.push(a2), 0 !== M(a2, w2.selectedDates[0], true) && w2.selectedDates.sort((function(e3, n3) { + return e3.getTime() - n3.getTime(); + }))); + if (O(), i2) { + var r2 = w2.currentYear !== a2.getFullYear(); + w2.currentYear = a2.getFullYear(), w2.currentMonth = a2.getMonth(), r2 && (De("onYearChange"), q()), De("onMonthChange"); + } + if (Ce(), U(), ye(), i2 || "range" === w2.config.mode || 1 !== w2.config.showMonths ? void 0 !== w2.selectedDateElem && void 0 === w2.hourElement && w2.selectedDateElem && w2.selectedDateElem.focus() : W(t2), void 0 !== w2.hourElement && void 0 !== w2.hourElement && w2.hourElement.focus(), w2.config.closeOnSelect) { + var l2 = "single" === w2.config.mode && !w2.config.enableTime, c2 = "range" === w2.config.mode && 2 === w2.selectedDates.length && !w2.config.enableTime; + (l2 || c2) && fe(); + } + Y(); + } + } + w2.parseDate = C({ config: w2.config, l10n: w2.l10n }), w2._handlers = [], w2.pluginElements = [], w2.loadedPlugins = [], w2._bind = P, w2._setHoursFromDate = F, w2._positionCalendar = de, w2.changeMonth = Z, w2.changeYear = ee, w2.clear = function(e2, n2) { + void 0 === e2 && (e2 = true); + void 0 === n2 && (n2 = true); + w2.input.value = "", void 0 !== w2.altInput && (w2.altInput.value = ""); + void 0 !== w2.mobileInput && (w2.mobileInput.value = ""); + w2.selectedDates = [], w2.latestSelectedDateObj = void 0, true === n2 && (w2.currentYear = w2._initialDate.getFullYear(), w2.currentMonth = w2._initialDate.getMonth()); + if (true === w2.config.enableTime) { + var t2 = E(w2.config), a2 = t2.hours, i2 = t2.minutes, o2 = t2.seconds; + A(a2, i2, o2); + } + w2.redraw(), e2 && De("onChange"); + }, w2.close = function() { + w2.isOpen = false, w2.isMobile || (void 0 !== w2.calendarContainer && w2.calendarContainer.classList.remove("open"), void 0 !== w2._input && w2._input.classList.remove("active")); + De("onClose"); + }, w2.onMouseOver = oe, w2._createElement = d, w2.createDay = R, w2.destroy = function() { + void 0 !== w2.config && De("onDestroy"); + for (var e2 = w2._handlers.length; e2--; ) w2._handlers[e2].remove(); + if (w2._handlers = [], w2.mobileInput) w2.mobileInput.parentNode && w2.mobileInput.parentNode.removeChild(w2.mobileInput), w2.mobileInput = void 0; + else if (w2.calendarContainer && w2.calendarContainer.parentNode) if (w2.config.static && w2.calendarContainer.parentNode) { + var n2 = w2.calendarContainer.parentNode; + if (n2.lastChild && n2.removeChild(n2.lastChild), n2.parentNode) { + for (; n2.firstChild; ) n2.parentNode.insertBefore(n2.firstChild, n2); + n2.parentNode.removeChild(n2); + } + } else w2.calendarContainer.parentNode.removeChild(w2.calendarContainer); + w2.altInput && (w2.input.type = "text", w2.altInput.parentNode && w2.altInput.parentNode.removeChild(w2.altInput), delete w2.altInput); + w2.input && (w2.input.type = w2.input._type, w2.input.classList.remove("flatpickr-input"), w2.input.removeAttribute("readonly")); + ["_showTimeInput", "latestSelectedDateObj", "_hideNextMonthArrow", "_hidePrevMonthArrow", "__hideNextMonthArrow", "__hidePrevMonthArrow", "isMobile", "isOpen", "selectedDateElem", "minDateHasTime", "maxDateHasTime", "days", "daysContainer", "_input", "_positionElement", "innerContainer", "rContainer", "monthNav", "todayDateElem", "calendarContainer", "weekdayContainer", "prevMonthNav", "nextMonthNav", "monthsDropdownContainer", "currentMonthElement", "currentYearElement", "navigationCurrentMonth", "selectedDateElem", "config"].forEach((function(e3) { + try { + delete w2[e3]; + } catch (e4) { + } + })); + }, w2.isEnabled = ne, w2.jumpToDate = j, w2.updateValue = ye, w2.open = function(e2, n2) { + void 0 === n2 && (n2 = w2._positionElement); + if (true === w2.isMobile) { + if (e2) { + e2.preventDefault(); + var t2 = g(e2); + t2 && t2.blur(); + } + return void 0 !== w2.mobileInput && (w2.mobileInput.focus(), w2.mobileInput.click()), void De("onOpen"); + } + if (w2._input.disabled || w2.config.inline) return; + var a2 = w2.isOpen; + w2.isOpen = true, a2 || (w2.calendarContainer.classList.add("open"), w2._input.classList.add("active"), De("onOpen"), de(n2)); + true === w2.config.enableTime && true === w2.config.noCalendar && (false !== w2.config.allowInput || void 0 !== e2 && w2.timeContainer.contains(e2.relatedTarget) || setTimeout((function() { + return w2.hourElement.select(); + }), 50)); + }, w2.redraw = ue, w2.set = function(e2, n2) { + if (null !== e2 && "object" == typeof e2) for (var a2 in Object.assign(w2.config, e2), e2) void 0 !== ge[a2] && ge[a2].forEach((function(e3) { + return e3(); + })); + else w2.config[e2] = n2, void 0 !== ge[e2] ? ge[e2].forEach((function(e3) { + return e3(); + })) : t.indexOf(e2) > -1 && (w2.config[e2] = c(n2)); + w2.redraw(), ye(true); + }, w2.setDate = function(e2, n2, t2) { + void 0 === n2 && (n2 = false); + void 0 === t2 && (t2 = w2.config.dateFormat); + if (0 !== e2 && !e2 || e2 instanceof Array && 0 === e2.length) return w2.clear(n2); + pe(e2, t2), w2.latestSelectedDateObj = w2.selectedDates[w2.selectedDates.length - 1], w2.redraw(), j(void 0, n2), F(), 0 === w2.selectedDates.length && w2.clear(false); + ye(n2), n2 && De("onChange"); + }, w2.toggle = function(e2) { + if (true === w2.isOpen) return w2.close(); + w2.open(e2); + }; + var ge = { locale: [se, G], showMonths: [V, S, z], minDate: [j], maxDate: [j], positionElement: [ve], clickOpens: [function() { + true === w2.config.clickOpens ? (P(w2._input, "focus", w2.open), P(w2._input, "click", w2.open)) : (w2._input.removeEventListener("focus", w2.open), w2._input.removeEventListener("click", w2.open)); + }] }; + function pe(e2, n2) { + var t2 = []; + if (e2 instanceof Array) t2 = e2.map((function(e3) { + return w2.parseDate(e3, n2); + })); + else if (e2 instanceof Date || "number" == typeof e2) t2 = [w2.parseDate(e2, n2)]; + else if ("string" == typeof e2) switch (w2.config.mode) { + case "single": + case "time": + t2 = [w2.parseDate(e2, n2)]; + break; + case "multiple": + t2 = e2.split(w2.config.conjunction).map((function(e3) { + return w2.parseDate(e3, n2); + })); + break; + case "range": + t2 = e2.split(w2.l10n.rangeSeparator).map((function(e3) { + return w2.parseDate(e3, n2); + })); + } + else w2.config.errorHandler(new Error("Invalid date supplied: " + JSON.stringify(e2))); + w2.selectedDates = w2.config.allowInvalidPreload ? t2 : t2.filter((function(e3) { + return e3 instanceof Date && ne(e3, false); + })), "range" === w2.config.mode && w2.selectedDates.sort((function(e3, n3) { + return e3.getTime() - n3.getTime(); + })); + } + function he(e2) { + return e2.slice().map((function(e3) { + return "string" == typeof e3 || "number" == typeof e3 || e3 instanceof Date ? w2.parseDate(e3, void 0, true) : e3 && "object" == typeof e3 && e3.from && e3.to ? { from: w2.parseDate(e3.from, void 0), to: w2.parseDate(e3.to, void 0) } : e3; + })).filter((function(e3) { + return e3; + })); + } + function ve() { + w2._positionElement = w2.config.positionElement || w2._input; + } + function De(e2, n2) { + if (void 0 !== w2.config) { + var t2 = w2.config[e2]; + if (void 0 !== t2 && t2.length > 0) for (var a2 = 0; t2[a2] && a2 < t2.length; a2++) t2[a2](w2.selectedDates, w2.input.value, w2, n2); + "onChange" === e2 && (w2.input.dispatchEvent(we("change")), w2.input.dispatchEvent(we("input"))); + } + } + function we(e2) { + var n2 = document.createEvent("Event"); + return n2.initEvent(e2, true, true), n2; + } + function be(e2) { + for (var n2 = 0; n2 < w2.selectedDates.length; n2++) { + var t2 = w2.selectedDates[n2]; + if (t2 instanceof Date && 0 === M(t2, e2)) return "" + n2; + } + return false; + } + function Ce() { + w2.config.noCalendar || w2.isMobile || !w2.monthNav || (w2.yearElements.forEach((function(e2, n2) { + var t2 = new Date(w2.currentYear, w2.currentMonth, 1); + t2.setMonth(w2.currentMonth + n2), w2.config.showMonths > 1 || "static" === w2.config.monthSelectorType ? w2.monthElements[n2].textContent = h(t2.getMonth(), w2.config.shorthandCurrentMonth, w2.l10n) + " " : w2.monthsDropdownContainer.value = t2.getMonth().toString(), e2.value = t2.getFullYear().toString(); + })), w2._hidePrevMonthArrow = void 0 !== w2.config.minDate && (w2.currentYear === w2.config.minDate.getFullYear() ? w2.currentMonth <= w2.config.minDate.getMonth() : w2.currentYear < w2.config.minDate.getFullYear()), w2._hideNextMonthArrow = void 0 !== w2.config.maxDate && (w2.currentYear === w2.config.maxDate.getFullYear() ? w2.currentMonth + 1 > w2.config.maxDate.getMonth() : w2.currentYear > w2.config.maxDate.getFullYear())); + } + function Me(e2) { + var n2 = e2 || (w2.config.altInput ? w2.config.altFormat : w2.config.dateFormat); + return w2.selectedDates.map((function(e3) { + return w2.formatDate(e3, n2); + })).filter((function(e3, n3, t2) { + return "range" !== w2.config.mode || w2.config.enableTime || t2.indexOf(e3) === n3; + })).join("range" !== w2.config.mode ? w2.config.conjunction : w2.l10n.rangeSeparator); + } + function ye(e2) { + void 0 === e2 && (e2 = true), void 0 !== w2.mobileInput && w2.mobileFormatStr && (w2.mobileInput.value = void 0 !== w2.latestSelectedDateObj ? w2.formatDate(w2.latestSelectedDateObj, w2.mobileFormatStr) : ""), w2.input.value = Me(w2.config.dateFormat), void 0 !== w2.altInput && (w2.altInput.value = Me(w2.config.altFormat)), false !== e2 && De("onValueUpdate"); + } + function xe(e2) { + var n2 = g(e2), t2 = w2.prevMonthNav.contains(n2), a2 = w2.nextMonthNav.contains(n2); + t2 || a2 ? Z(t2 ? -1 : 1) : w2.yearElements.indexOf(n2) >= 0 ? n2.select() : n2.classList.contains("arrowUp") ? w2.changeYear(w2.currentYear + 1) : n2.classList.contains("arrowDown") && w2.changeYear(w2.currentYear - 1); + } + return (function() { + w2.element = w2.input = p2, w2.isOpen = false, (function() { + var n3 = ["wrap", "weekNumbers", "allowInput", "allowInvalidPreload", "clickOpens", "time_24hr", "enableTime", "noCalendar", "altInput", "shorthandCurrentMonth", "inline", "static", "enableSeconds", "disableMobile"], i2 = e(e({}, JSON.parse(JSON.stringify(p2.dataset || {}))), v2), o2 = {}; + w2.config.parseDate = i2.parseDate, w2.config.formatDate = i2.formatDate, Object.defineProperty(w2.config, "enable", { get: function() { + return w2.config._enable; + }, set: function(e2) { + w2.config._enable = he(e2); + } }), Object.defineProperty(w2.config, "disable", { get: function() { + return w2.config._disable; + }, set: function(e2) { + w2.config._disable = he(e2); + } }); + var r2 = "time" === i2.mode; + if (!i2.dateFormat && (i2.enableTime || r2)) { + var l2 = I.defaultConfig.dateFormat || a.dateFormat; + o2.dateFormat = i2.noCalendar || r2 ? "H:i" + (i2.enableSeconds ? ":S" : "") : l2 + " H:i" + (i2.enableSeconds ? ":S" : ""); + } + if (i2.altInput && (i2.enableTime || r2) && !i2.altFormat) { + var s2 = I.defaultConfig.altFormat || a.altFormat; + o2.altFormat = i2.noCalendar || r2 ? "h:i" + (i2.enableSeconds ? ":S K" : " K") : s2 + " h:i" + (i2.enableSeconds ? ":S" : "") + " K"; + } + Object.defineProperty(w2.config, "minDate", { get: function() { + return w2.config._minDate; + }, set: le("min") }), Object.defineProperty(w2.config, "maxDate", { get: function() { + return w2.config._maxDate; + }, set: le("max") }); + var d2 = function(e2) { + return function(n4) { + w2.config["min" === e2 ? "_minTime" : "_maxTime"] = w2.parseDate(n4, "H:i:S"); + }; + }; + Object.defineProperty(w2.config, "minTime", { get: function() { + return w2.config._minTime; + }, set: d2("min") }), Object.defineProperty(w2.config, "maxTime", { get: function() { + return w2.config._maxTime; + }, set: d2("max") }), "time" === i2.mode && (w2.config.noCalendar = true, w2.config.enableTime = true); + Object.assign(w2.config, o2, i2); + for (var u2 = 0; u2 < n3.length; u2++) w2.config[n3[u2]] = true === w2.config[n3[u2]] || "true" === w2.config[n3[u2]]; + t.filter((function(e2) { + return void 0 !== w2.config[e2]; + })).forEach((function(e2) { + w2.config[e2] = c(w2.config[e2] || []).map(T2); + })), w2.isMobile = !w2.config.disableMobile && !w2.config.inline && "single" === w2.config.mode && !w2.config.disable.length && !w2.config.enable && !w2.config.weekNumbers && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); + for (u2 = 0; u2 < w2.config.plugins.length; u2++) { + var f2 = w2.config.plugins[u2](w2) || {}; + for (var m2 in f2) t.indexOf(m2) > -1 ? w2.config[m2] = c(f2[m2]).map(T2).concat(w2.config[m2]) : void 0 === i2[m2] && (w2.config[m2] = f2[m2]); + } + i2.altInputClass || (w2.config.altInputClass = ce().className + " " + w2.config.altInputClass); + De("onParseConfig"); + })(), se(), (function() { + if (w2.input = ce(), !w2.input) return void w2.config.errorHandler(new Error("Invalid input element specified")); + w2.input._type = w2.input.type, w2.input.type = "text", w2.input.classList.add("flatpickr-input"), w2._input = w2.input, w2.config.altInput && (w2.altInput = d(w2.input.nodeName, w2.config.altInputClass), w2._input = w2.altInput, w2.altInput.placeholder = w2.input.placeholder, w2.altInput.disabled = w2.input.disabled, w2.altInput.required = w2.input.required, w2.altInput.tabIndex = w2.input.tabIndex, w2.altInput.type = "text", w2.input.setAttribute("type", "hidden"), !w2.config.static && w2.input.parentNode && w2.input.parentNode.insertBefore(w2.altInput, w2.input.nextSibling)); + w2.config.allowInput || w2._input.setAttribute("readonly", "readonly"); + ve(); + })(), (function() { + w2.selectedDates = [], w2.now = w2.parseDate(w2.config.now) || /* @__PURE__ */ new Date(); + var e2 = w2.config.defaultDate || ("INPUT" !== w2.input.nodeName && "TEXTAREA" !== w2.input.nodeName || !w2.input.placeholder || w2.input.value !== w2.input.placeholder ? w2.input.value : null); + e2 && pe(e2, w2.config.dateFormat); + w2._initialDate = w2.selectedDates.length > 0 ? w2.selectedDates[0] : w2.config.minDate && w2.config.minDate.getTime() > w2.now.getTime() ? w2.config.minDate : w2.config.maxDate && w2.config.maxDate.getTime() < w2.now.getTime() ? w2.config.maxDate : w2.now, w2.currentYear = w2._initialDate.getFullYear(), w2.currentMonth = w2._initialDate.getMonth(), w2.selectedDates.length > 0 && (w2.latestSelectedDateObj = w2.selectedDates[0]); + void 0 !== w2.config.minTime && (w2.config.minTime = w2.parseDate(w2.config.minTime, "H:i")); + void 0 !== w2.config.maxTime && (w2.config.maxTime = w2.parseDate(w2.config.maxTime, "H:i")); + w2.minDateHasTime = !!w2.config.minDate && (w2.config.minDate.getHours() > 0 || w2.config.minDate.getMinutes() > 0 || w2.config.minDate.getSeconds() > 0), w2.maxDateHasTime = !!w2.config.maxDate && (w2.config.maxDate.getHours() > 0 || w2.config.maxDate.getMinutes() > 0 || w2.config.maxDate.getSeconds() > 0); + })(), w2.utils = { getDaysInMonth: function(e2, n3) { + return void 0 === e2 && (e2 = w2.currentMonth), void 0 === n3 && (n3 = w2.currentYear), 1 === e2 && (n3 % 4 == 0 && n3 % 100 != 0 || n3 % 400 == 0) ? 29 : w2.l10n.daysInMonth[e2]; + } }, w2.isMobile || (function() { + var e2 = window.document.createDocumentFragment(); + if (w2.calendarContainer = d("div", "flatpickr-calendar"), w2.calendarContainer.tabIndex = -1, !w2.config.noCalendar) { + if (e2.appendChild((w2.monthNav = d("div", "flatpickr-months"), w2.yearElements = [], w2.monthElements = [], w2.prevMonthNav = d("span", "flatpickr-prev-month"), w2.prevMonthNav.innerHTML = w2.config.prevArrow, w2.nextMonthNav = d("span", "flatpickr-next-month"), w2.nextMonthNav.innerHTML = w2.config.nextArrow, V(), Object.defineProperty(w2, "_hidePrevMonthArrow", { get: function() { + return w2.__hidePrevMonthArrow; + }, set: function(e3) { + w2.__hidePrevMonthArrow !== e3 && (s(w2.prevMonthNav, "flatpickr-disabled", e3), w2.__hidePrevMonthArrow = e3); + } }), Object.defineProperty(w2, "_hideNextMonthArrow", { get: function() { + return w2.__hideNextMonthArrow; + }, set: function(e3) { + w2.__hideNextMonthArrow !== e3 && (s(w2.nextMonthNav, "flatpickr-disabled", e3), w2.__hideNextMonthArrow = e3); + } }), w2.currentYearElement = w2.yearElements[0], Ce(), w2.monthNav)), w2.innerContainer = d("div", "flatpickr-innerContainer"), w2.config.weekNumbers) { + var n3 = (function() { + w2.calendarContainer.classList.add("hasWeeks"); + var e3 = d("div", "flatpickr-weekwrapper"); + e3.appendChild(d("span", "flatpickr-weekday", w2.l10n.weekAbbreviation)); + var n4 = d("div", "flatpickr-weeks"); + return e3.appendChild(n4), { weekWrapper: e3, weekNumbers: n4 }; + })(), t2 = n3.weekWrapper, a2 = n3.weekNumbers; + w2.innerContainer.appendChild(t2), w2.weekNumbers = a2, w2.weekWrapper = t2; + } + w2.rContainer = d("div", "flatpickr-rContainer"), w2.rContainer.appendChild(z()), w2.daysContainer || (w2.daysContainer = d("div", "flatpickr-days"), w2.daysContainer.tabIndex = -1), U(), w2.rContainer.appendChild(w2.daysContainer), w2.innerContainer.appendChild(w2.rContainer), e2.appendChild(w2.innerContainer); + } + w2.config.enableTime && e2.appendChild((function() { + w2.calendarContainer.classList.add("hasTime"), w2.config.noCalendar && w2.calendarContainer.classList.add("noCalendar"); + var e3 = E(w2.config); + w2.timeContainer = d("div", "flatpickr-time"), w2.timeContainer.tabIndex = -1; + var n4 = d("span", "flatpickr-time-separator", ":"), t3 = m("flatpickr-hour", { "aria-label": w2.l10n.hourAriaLabel }); + w2.hourElement = t3.getElementsByTagName("input")[0]; + var a3 = m("flatpickr-minute", { "aria-label": w2.l10n.minuteAriaLabel }); + w2.minuteElement = a3.getElementsByTagName("input")[0], w2.hourElement.tabIndex = w2.minuteElement.tabIndex = -1, w2.hourElement.value = o(w2.latestSelectedDateObj ? w2.latestSelectedDateObj.getHours() : w2.config.time_24hr ? e3.hours : (function(e4) { + switch (e4 % 24) { + case 0: + case 12: + return 12; + default: + return e4 % 12; + } + })(e3.hours)), w2.minuteElement.value = o(w2.latestSelectedDateObj ? w2.latestSelectedDateObj.getMinutes() : e3.minutes), w2.hourElement.setAttribute("step", w2.config.hourIncrement.toString()), w2.minuteElement.setAttribute("step", w2.config.minuteIncrement.toString()), w2.hourElement.setAttribute("min", w2.config.time_24hr ? "0" : "1"), w2.hourElement.setAttribute("max", w2.config.time_24hr ? "23" : "12"), w2.hourElement.setAttribute("maxlength", "2"), w2.minuteElement.setAttribute("min", "0"), w2.minuteElement.setAttribute("max", "59"), w2.minuteElement.setAttribute("maxlength", "2"), w2.timeContainer.appendChild(t3), w2.timeContainer.appendChild(n4), w2.timeContainer.appendChild(a3), w2.config.time_24hr && w2.timeContainer.classList.add("time24hr"); + if (w2.config.enableSeconds) { + w2.timeContainer.classList.add("hasSeconds"); + var i3 = m("flatpickr-second"); + w2.secondElement = i3.getElementsByTagName("input")[0], w2.secondElement.value = o(w2.latestSelectedDateObj ? w2.latestSelectedDateObj.getSeconds() : e3.seconds), w2.secondElement.setAttribute("step", w2.minuteElement.getAttribute("step")), w2.secondElement.setAttribute("min", "0"), w2.secondElement.setAttribute("max", "59"), w2.secondElement.setAttribute("maxlength", "2"), w2.timeContainer.appendChild(d("span", "flatpickr-time-separator", ":")), w2.timeContainer.appendChild(i3); + } + w2.config.time_24hr || (w2.amPM = d("span", "flatpickr-am-pm", w2.l10n.amPM[r((w2.latestSelectedDateObj ? w2.hourElement.value : w2.config.defaultHour) > 11)]), w2.amPM.title = w2.l10n.toggleTitle, w2.amPM.tabIndex = -1, w2.timeContainer.appendChild(w2.amPM)); + return w2.timeContainer; + })()); + s(w2.calendarContainer, "rangeMode", "range" === w2.config.mode), s(w2.calendarContainer, "animate", true === w2.config.animate), s(w2.calendarContainer, "multiMonth", w2.config.showMonths > 1), w2.calendarContainer.appendChild(e2); + var i2 = void 0 !== w2.config.appendTo && void 0 !== w2.config.appendTo.nodeType; + if ((w2.config.inline || w2.config.static) && (w2.calendarContainer.classList.add(w2.config.inline ? "inline" : "static"), w2.config.inline && (!i2 && w2.element.parentNode ? w2.element.parentNode.insertBefore(w2.calendarContainer, w2._input.nextSibling) : void 0 !== w2.config.appendTo && w2.config.appendTo.appendChild(w2.calendarContainer)), w2.config.static)) { + var l2 = d("div", "flatpickr-wrapper"); + w2.element.parentNode && w2.element.parentNode.insertBefore(l2, w2.element), l2.appendChild(w2.element), w2.altInput && l2.appendChild(w2.altInput), l2.appendChild(w2.calendarContainer); + } + w2.config.static || w2.config.inline || (void 0 !== w2.config.appendTo ? w2.config.appendTo : window.document.body).appendChild(w2.calendarContainer); + })(), (function() { + w2.config.wrap && ["open", "close", "toggle", "clear"].forEach((function(e3) { + Array.prototype.forEach.call(w2.element.querySelectorAll("[data-" + e3 + "]"), (function(n4) { + return P(n4, "click", w2[e3]); + })); + })); + if (w2.isMobile) return void (function() { + var e3 = w2.config.enableTime ? w2.config.noCalendar ? "time" : "datetime-local" : "date"; + w2.mobileInput = d("input", w2.input.className + " flatpickr-mobile"), w2.mobileInput.tabIndex = 1, w2.mobileInput.type = e3, w2.mobileInput.disabled = w2.input.disabled, w2.mobileInput.required = w2.input.required, w2.mobileInput.placeholder = w2.input.placeholder, w2.mobileFormatStr = "datetime-local" === e3 ? "Y-m-d\\TH:i:S" : "date" === e3 ? "Y-m-d" : "H:i:S", w2.selectedDates.length > 0 && (w2.mobileInput.defaultValue = w2.mobileInput.value = w2.formatDate(w2.selectedDates[0], w2.mobileFormatStr)); + w2.config.minDate && (w2.mobileInput.min = w2.formatDate(w2.config.minDate, "Y-m-d")); + w2.config.maxDate && (w2.mobileInput.max = w2.formatDate(w2.config.maxDate, "Y-m-d")); + w2.input.getAttribute("step") && (w2.mobileInput.step = String(w2.input.getAttribute("step"))); + w2.input.type = "hidden", void 0 !== w2.altInput && (w2.altInput.type = "hidden"); + try { + w2.input.parentNode && w2.input.parentNode.insertBefore(w2.mobileInput, w2.input.nextSibling); + } catch (e4) { + } + P(w2.mobileInput, "change", (function(e4) { + w2.setDate(g(e4).value, false, w2.mobileFormatStr), De("onChange"), De("onClose"); + })); + })(); + var e2 = l(re, 50); + w2._debouncedChange = l(Y, 300), w2.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent) && P(w2.daysContainer, "mouseover", (function(e3) { + "range" === w2.config.mode && oe(g(e3)); + })); + P(w2._input, "keydown", ie), void 0 !== w2.calendarContainer && P(w2.calendarContainer, "keydown", ie); + w2.config.inline || w2.config.static || P(window, "resize", e2); + void 0 !== window.ontouchstart ? P(window.document, "touchstart", X) : P(window.document, "mousedown", X); + P(window.document, "focus", X, { capture: true }), true === w2.config.clickOpens && (P(w2._input, "focus", w2.open), P(w2._input, "click", w2.open)); + void 0 !== w2.daysContainer && (P(w2.monthNav, "click", xe), P(w2.monthNav, ["keyup", "increment"], N), P(w2.daysContainer, "click", me)); + if (void 0 !== w2.timeContainer && void 0 !== w2.minuteElement && void 0 !== w2.hourElement) { + var n3 = function(e3) { + return g(e3).select(); + }; + P(w2.timeContainer, ["increment"], _), P(w2.timeContainer, "blur", _, { capture: true }), P(w2.timeContainer, "click", H), P([w2.hourElement, w2.minuteElement], ["focus", "click"], n3), void 0 !== w2.secondElement && P(w2.secondElement, "focus", (function() { + return w2.secondElement && w2.secondElement.select(); + })), void 0 !== w2.amPM && P(w2.amPM, "click", (function(e3) { + _(e3); + })); + } + w2.config.allowInput && P(w2._input, "blur", ae); + })(), (w2.selectedDates.length || w2.config.noCalendar) && (w2.config.enableTime && F(w2.config.noCalendar ? w2.latestSelectedDateObj : void 0), ye(false)), S(); + var n2 = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); + !w2.isMobile && n2 && de(), De("onReady"); + })(), w2; + } + function T(e2, n2) { + for (var t2 = Array.prototype.slice.call(e2).filter((function(e3) { + return e3 instanceof HTMLElement; + })), a2 = [], i2 = 0; i2 < t2.length; i2++) { + var o2 = t2[i2]; + try { + if (null !== o2.getAttribute("data-fp-omit")) continue; + void 0 !== o2._flatpickr && (o2._flatpickr.destroy(), o2._flatpickr = void 0), o2._flatpickr = k(o2, n2 || {}), a2.push(o2._flatpickr); + } catch (e3) { + console.error(e3); + } + } + return 1 === a2.length ? a2[0] : a2; + } + "undefined" != typeof HTMLElement && "undefined" != typeof HTMLCollection && "undefined" != typeof NodeList && (HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function(e2) { + return T(this, e2); + }, HTMLElement.prototype.flatpickr = function(e2) { + return T([this], e2); + }); + var I = function(e2, n2) { + return "string" == typeof e2 ? T(window.document.querySelectorAll(e2), n2) : e2 instanceof Node ? T([e2], n2) : T(e2, n2); + }; + return I.defaultConfig = {}, I.l10ns = { en: e({}, i), default: e({}, i) }, I.localize = function(n2) { + I.l10ns.default = e(e({}, I.l10ns.default), n2); + }, I.setDefaults = function(n2) { + I.defaultConfig = e(e({}, I.defaultConfig), n2); + }, I.parseDate = C({}), I.formatDate = b({}), I.compareDates = M, "undefined" != typeof jQuery && void 0 !== jQuery.fn && (jQuery.fn.flatpickr = function(e2) { + return T(this, e2); + }), Date.prototype.fp_incr = function(e2) { + return new Date(this.getFullYear(), this.getMonth(), this.getDate() + ("string" == typeof e2 ? parseInt(e2, 10) : e2)); + }, "undefined" != typeof window && (window.flatpickr = I), I; + })); + } +}); + +// frontend/js/pages/logs/logList.js +var STATIC_ERROR_MAP = { + "API_KEY_INVALID": { type: "\u5BC6\u94A5\u65E0\u6548", style: "red" }, + "INVALID_ARGUMENT": { type: "\u53C2\u6570\u65E0\u6548", style: "red" }, + "PERMISSION_DENIED": { type: "\u6743\u9650\u4E0D\u8DB3", style: "red" }, + "NOT_FOUND": { type: "\u8D44\u6E90\u672A\u627E\u5230", style: "gray" }, + "RESOURCE_EXHAUSTED": { type: "\u8D44\u6E90\u8017\u5C3D", style: "orange" }, + "QUOTA_EXCEEDED": { type: "\u914D\u989D\u8017\u5C3D", style: "orange" }, + "DEADLINE_EXCEEDED": { type: "\u8BF7\u6C42\u8D85\u65F6", style: "yellow" }, + "CANCELLED": { type: "\u8BF7\u6C42\u5DF2\u53D6\u6D88", style: "gray" }, + "INTERNAL": { type: "Google\u5185\u90E8\u9519\u8BEF", style: "yellow" }, + "UNAVAILABLE": { type: "\u670D\u52A1\u4E0D\u53EF\u7528", style: "yellow" } +}; +var STATUS_CODE_MAP = { + 400: { type: "\u9519\u8BEF\u8BF7\u6C42", style: "red" }, + 401: { type: "\u8BA4\u8BC1\u5931\u8D25", style: "red" }, + 403: { type: "\u7981\u6B62\u8BBF\u95EE", style: "red" }, + 404: { type: "\u8D44\u6E90\u672A\u627E\u5230", style: "gray" }, + 413: { type: "\u8BF7\u6C42\u4F53\u8FC7\u5927", style: "orange" }, + 429: { type: "\u8BF7\u6C42\u9891\u7387\u8FC7\u9AD8", style: "orange" }, + 500: { type: "\u5185\u90E8\u670D\u52A1\u9519\u8BEF", style: "yellow" }, + 503: { type: "\u670D\u52A1\u4E0D\u53EF\u7528", style: "yellow" } +}; +var SPECIAL_CASE_MAP = [ + { code: 400, keyword: "api key not found", type: "\u65E0\u6548\u5BC6\u94A5", style: "red" }, + { code: 404, keyword: "call listmodels", type: "\u6A21\u578B\u914D\u7F6E\u9519\u8BEF", style: "orange" } +]; +var styleToClass = (style) => { + switch (style) { + case "red": + return "bg-red-500/10 text-red-600"; + case "orange": + return "bg-orange-500/10 text-orange-600"; + case "yellow": + return "bg-yellow-500/10 text-yellow-600"; + case "gray": + return "bg-zinc-500/10 text-zinc-600"; + default: + return "bg-destructive/10 text-destructive"; + } +}; +var errorCodeRegex = /(\d+)$/; +var LogList = class { + constructor(container, dataStore2) { + this.container = container; + this.dataStore = dataStore2; + if (!this.container) console.error("LogList: container element (tbody) not found."); + } + renderLoading() { + if (!this.container) return; + this.container.innerHTML = ` \u52A0\u8F7D\u65E5\u5FD7\u4E2D...`; + } + render(logs, pagination, selectedLogIds) { + if (!this.container) return; + if (!logs || logs.length === 0) { + this.container.innerHTML = `\u6CA1\u6709\u627E\u5230\u76F8\u5173\u7684\u65E5\u5FD7\u8BB0\u5F55\u3002`; + return; + } + const { page, page_size } = pagination; + const startIndex = (page - 1) * page_size; + const logsHtml = logs.map((log, index) => { + const isChecked = selectedLogIds.has(log.ID); + return this.createLogRowHtml(log, startIndex + index + 1, isChecked); + }).join(""); + this.container.innerHTML = logsHtml; + } + _interpretError(log) { + if (log.IsSuccess) { + return { + type: "N/A", + statusCodeHtml: `\u6210\u529F` + }; + } + const codeMatch = log.ErrorCode ? log.ErrorCode.match(errorCodeRegex) : null; + if (codeMatch && codeMatch[1] && log.ErrorMessage) { + const code = parseInt(codeMatch[1], 10); + const lowerCaseMsg = log.ErrorMessage.toLowerCase(); + for (const rule of SPECIAL_CASE_MAP) { + if (code === rule.code && lowerCaseMsg.includes(rule.keyword)) { + return { + type: rule.type, + statusCodeHtml: `${code}` + }; + } + } + } + if (log.ErrorCode && STATIC_ERROR_MAP[log.ErrorCode]) { + const mapping = STATIC_ERROR_MAP[log.ErrorCode]; + return { + type: mapping.type, + statusCodeHtml: `${log.ErrorCode}` + }; + } + if (codeMatch && codeMatch[1]) { + const code = parseInt(codeMatch[1], 10); + let mapping = STATUS_CODE_MAP[code]; + if (!mapping && code >= 500 && code < 600) { + mapping = STATUS_CODE_MAP[500]; + } + if (mapping) { + return { + type: mapping.type, + statusCodeHtml: `${code}` + }; + } + } + if (!log.ErrorCode && !log.ErrorMessage) { + return { type: "\u672A\u77E5", statusCodeHtml: `N/A` }; + } + return { type: "\u672A\u77E5\u9519\u8BEF", statusCodeHtml: `\u5931\u8D25` }; + } + _formatModelName(modelName) { + const styleClass = ""; + return `
${modelName}
`; + } + createLogRowHtml(log, index, isChecked) { + const group = this.dataStore.groups.get(log.GroupID); + const groupName = group ? group.display_name : log.GroupID ? `Group #${log.GroupID}` : "N/A"; + const key = this.dataStore.keys.get(log.KeyID); + let apiKeyDisplay; + if (key && key.APIKey && key.APIKey.length >= 8) { + const masked = `${key.APIKey.substring(0, 4)}......${key.APIKey.substring(key.APIKey.length - 4)}`; + apiKeyDisplay = escapeHTML(masked); + } else { + apiKeyDisplay = log.KeyID ? `Key #${log.KeyID}` : "N/A"; + } + const errorInfo = this._interpretError(log); + const modelNameFormatted = this._formatModelName(log.ModelName); + const errorMessageAttr = log.ErrorMessage ? `data-error-message="${escape(log.ErrorMessage)}"` : ""; + const requestTime = new Date(log.RequestTime).toLocaleString(); + const checkedAttr = isChecked ? "checked" : ""; + return ` + + + + + ${index} + ${apiKeyDisplay} + ${groupName} + ${errorInfo.type} + ${errorInfo.statusCodeHtml} + ${modelNameFormatted} + ${requestTime} + + + + + `; + } +}; +var logList_default = LogList; + +// frontend/js/components/customSelectV2.js +var import_popper_esm_min = __toESM(require_popper_esm_min()); +var CustomSelectV2 = class _CustomSelectV2 { + constructor(container) { + this.container = container; + this.trigger = this.container.querySelector(".custom-select-trigger"); + this.nativeSelect = this.container.querySelector("select"); + this.template = this.container.querySelector(".custom-select-panel-template"); + if (!this.trigger || !this.nativeSelect || !this.template) { + console.warn("CustomSelectV2 cannot initialize: missing required elements.", this.container); + return; + } + this.panel = null; + this.popperInstance = null; + this.isOpen = false; + this.triggerText = this.trigger.querySelector("span"); + if (typeof _CustomSelectV2.openInstance === "undefined") { + _CustomSelectV2.openInstance = null; + _CustomSelectV2.initGlobalListener(); + } + this.updateTriggerText(); + this.bindEvents(); + } + static initGlobalListener() { + document.addEventListener("click", (event) => { + const instance = _CustomSelectV2.openInstance; + if (instance && !instance.container.contains(event.target) && (!instance.panel || !instance.panel.contains(event.target))) { + instance.close(); + } + }); + } + createPanel() { + const panelFragment = this.template.content.cloneNode(true); + this.panel = panelFragment.querySelector(".custom-select-panel"); + document.body.appendChild(this.panel); + this.panel.innerHTML = ""; + Array.from(this.nativeSelect.options).forEach((option) => { + const item = document.createElement("a"); + item.href = "#"; + item.className = "custom-select-option block w-full text-left px-3 py-1.5 text-sm text-zinc-700 hover:bg-zinc-100 dark:text-zinc-200 dark:hover:bg-zinc-700"; + item.textContent = option.textContent; + item.dataset.value = option.value; + if (option.selected) { + item.classList.add("is-selected"); + } + this.panel.appendChild(item); + }); + this.panel.addEventListener("click", (event) => { + event.preventDefault(); + const optionEl = event.target.closest(".custom-select-option"); + if (optionEl) { + this.selectOption(optionEl); + } + }); + } + bindEvents() { + this.trigger.addEventListener("click", (event) => { + event.stopPropagation(); + if (_CustomSelectV2.openInstance && _CustomSelectV2.openInstance !== this) { + _CustomSelectV2.openInstance.close(); + } + this.toggle(); + }); + } + selectOption(optionEl) { + const selectedValue = optionEl.dataset.value; + if (this.nativeSelect.value !== selectedValue) { + this.nativeSelect.value = selectedValue; + this.nativeSelect.dispatchEvent(new Event("change", { bubbles: true })); + } + this.updateTriggerText(); + this.close(); + } + updateTriggerText() { + const selectedOption = this.nativeSelect.options[this.nativeSelect.selectedIndex]; + if (selectedOption) { + this.triggerText.textContent = selectedOption.textContent; + } + } + toggle() { + this.isOpen ? this.close() : this.open(); + } + open() { + if (this.isOpen) return; + this.isOpen = true; + if (!this.panel) { + this.createPanel(); + } + this.panel.style.display = "block"; + this.panel.offsetHeight; + this.popperInstance = (0, import_popper_esm_min.createPopper)(this.trigger, this.panel, { + placement: "top-start", + modifiers: [ + { name: "offset", options: { offset: [0, 8] } }, + { name: "flip", options: { fallbackPlacements: ["bottom-start"] } } + ] + }); + _CustomSelectV2.openInstance = this; + } + close() { + if (!this.isOpen) return; + this.isOpen = false; + if (this.popperInstance) { + this.popperInstance.destroy(); + this.popperInstance = null; + } + if (this.panel) { + this.panel.remove(); + this.panel = null; + } + if (_CustomSelectV2.openInstance === this) { + _CustomSelectV2.openInstance = null; + } + } +}; + +// frontend/js/components/filterPopover.js +var import_popper_esm_min2 = __toESM(require_popper_esm_min()); +var FilterPopover = class { + constructor(triggerElement, options, title) { + if (!triggerElement || typeof import_popper_esm_min2.createPopper !== "function") { + console.error("FilterPopover: Trigger element or Popper.js not found."); + return; + } + this.triggerElement = triggerElement; + this.options = options; + this.title = title; + this.selectedValues = /* @__PURE__ */ new Set(); + this._createPopoverHTML(); + this.popperInstance = (0, import_popper_esm_min2.createPopper)(this.triggerElement, this.popoverElement, { + placement: "bottom-start", + modifiers: [{ name: "offset", options: { offset: [0, 8] } }] + }); + this._bindEvents(); + } + _createPopoverHTML() { + this.popoverElement = document.createElement("div"); + this.popoverElement.className = "hidden z-50 min-w-[12rem] rounded-md border bg-popover bg-white dark:bg-zinc-800 p-2 text-popover-foreground shadow-md"; + this.popoverElement.innerHTML = ` +
${this.title}
+
+ ${this.options.map((option) => ` + + `).join("")} +
+
+ + +
+ `; + document.body.appendChild(this.popoverElement); + } + _bindEvents() { + this.triggerElement.addEventListener("click", () => this.toggle()); + document.addEventListener("click", (event) => { + if (!this.popoverElement.contains(event.target) && !this.triggerElement.contains(event.target)) { + this.hide(); + } + }); + this.popoverElement.addEventListener("click", (event) => { + const target = event.target.closest("button"); + if (!target) return; + const action = target.dataset.action; + if (action === "clear") this._handleClear(); + if (action === "apply") this._handleApply(); + }); + } + _handleClear() { + this.popoverElement.querySelectorAll('input[type="checkbox"]').forEach((cb) => cb.checked = false); + this.selectedValues.clear(); + this._handleApply(); + } + _handleApply() { + this.selectedValues.clear(); + this.popoverElement.querySelectorAll("input:checked").forEach((cb) => { + this.selectedValues.add(cb.value); + }); + const filterChangeEvent = new CustomEvent("filter-change", { + detail: { + filterKey: this.triggerElement.id, + selected: this.selectedValues + } + }); + this.triggerElement.dispatchEvent(filterChangeEvent); + this.hide(); + } + toggle() { + this.popoverElement.classList.toggle("hidden"); + this.popperInstance.update(); + } + hide() { + this.popoverElement.classList.add("hidden"); + } +}; + +// frontend/js/pages/logs/systemLog.js +var SystemLogTerminal = class { + constructor(container, controlsContainer) { + this.container = container; + this.controlsContainer = controlsContainer; + this.ws = null; + this.isPaused = false; + this.shouldAutoScroll = true; + this.reconnectAttempts = 0; + this.maxReconnectAttempts = 5; + this.isConnected = false; + this.elements = { + output: this.container.querySelector("#log-terminal-output"), + statusIndicator: this.controlsContainer.querySelector("#terminal-status-indicator"), + clearBtn: this.controlsContainer.querySelector('[data-action="clear-terminal"]'), + pauseBtn: this.controlsContainer.querySelector('[data-action="toggle-pause-terminal"]'), + scrollBtn: this.controlsContainer.querySelector('[data-action="toggle-scroll-terminal"]'), + connectBtn: this.controlsContainer.querySelector('[data-action="toggle-connect-terminal"]'), + settingsBtn: this.controlsContainer.querySelector('[data-action="terminal-settings"]') + }; + this._initEventListeners(); + } + _initEventListeners() { + this.elements.clearBtn.addEventListener("click", () => this.clear()); + this.elements.pauseBtn.addEventListener("click", () => this.togglePause()); + this.elements.scrollBtn.addEventListener("click", () => this.toggleAutoScroll()); + this.elements.connectBtn.addEventListener("click", () => this.toggleConnect()); + this.elements.settingsBtn.addEventListener("click", () => this.openSettings()); + } + toggleConnect() { + if (this.isConnected) { + this.disconnect(); + } else { + this.connect(); + } + } + connect() { + this.clear(); + this._appendMessage("info", "\u6B63\u5728\u8FDE\u63A5\u5230\u5B9E\u65F6\u65E5\u5FD7\u6D41..."); + this._updateStatus("connecting", "\u8FDE\u63A5\u4E2D..."); + const protocol = window.location.protocol === "https:" ? "wss:" : "ws:"; + const wsUrl = `${protocol}//${window.location.host}/ws/system-logs`; + this.ws = new WebSocket(wsUrl); + this.ws.onopen = () => { + this._appendMessage("info", "\u2713 \u5DF2\u8FDE\u63A5\u5230\u7CFB\u7EDF\u65E5\u5FD7\u6D41"); + this._updateStatus("connected", "\u5DF2\u8FDE\u63A5"); + this.reconnectAttempts = 0; + this.isConnected = true; + this.elements.connectBtn.title = "\u65AD\u5F00"; + this.elements.connectBtn.querySelector("i").classList.replace("fa-plug", "fa-minus-circle"); + }; + this.ws.onmessage = (event) => { + if (this.isPaused) return; + try { + const data = JSON.parse(event.data); + const levelColors = { + "error": "text-red-500", + "warning": "text-yellow-400", + "info": "text-green-400", + "debug": "text-zinc-400" + }; + const color = levelColors[data.level] || "text-zinc-200"; + const timestamp = new Date(data.timestamp).toLocaleTimeString(); + const msg = `[${timestamp}] [${data.level.toUpperCase()}] ${data.message}`; + this._appendMessage(color, msg); + } catch (e) { + this._appendMessage("text-zinc-200", event.data); + } + }; + this.ws.onerror = (error) => { + this._appendMessage("error", `\u2717 WebSocket \u9519\u8BEF`); + this._updateStatus("error", "\u8FDE\u63A5\u9519\u8BEF"); + }; + this.ws.onclose = () => { + this._appendMessage("error", "\u2717 \u8FDE\u63A5\u5DF2\u65AD\u5F00"); + this._updateStatus("disconnected", "\u672A\u8FDE\u63A5"); + this.isConnected = false; + this.elements.connectBtn.title = "\u8FDE\u63A5"; + this.elements.connectBtn.querySelector("i").classList.replace("fa-minus-circle", "fa-plug"); + if (this.reconnectAttempts < this.maxReconnectAttempts) { + this.reconnectAttempts++; + setTimeout(() => { + this._appendMessage("info", `\u5C1D\u8BD5\u91CD\u65B0\u8FDE\u63A5 (${this.reconnectAttempts}/${this.maxReconnectAttempts})...`); + this.connect(); + }, 3e3); + } + }; + } + disconnect() { + if (this.ws) { + this.ws.close(); + this.ws = null; + } + this.reconnectAttempts = this.maxReconnectAttempts; + this.isConnected = false; + this._updateStatus("disconnected", "\u672A\u8FDE\u63A5"); + this.elements.connectBtn.title = "\u8FDE\u63A5"; + this.elements.connectBtn.querySelector("i").classList.replace("fa-minus-circle", "fa-plug"); + } + clear() { + if (this.elements.output) { + this.elements.output.innerHTML = ""; + } + } + togglePause() { + this.isPaused = !this.isPaused; + const icon = this.elements.pauseBtn.querySelector("i"); + if (this.isPaused) { + this.elements.pauseBtn.title = "\u7EE7\u7EED"; + icon.classList.replace("fa-pause", "fa-play"); + } else { + this.elements.pauseBtn.title = "\u6682\u505C"; + icon.classList.replace("fa-play", "fa-pause"); + } + } + toggleAutoScroll() { + this.shouldAutoScroll = !this.shouldAutoScroll; + this.elements.scrollBtn.title = this.shouldAutoScroll ? "\u81EA\u52A8\u6EDA\u52A8" : "\u624B\u52A8\u6EDA\u52A8"; + } + openSettings() { + console.log("\u6253\u5F00\u8BBE\u7F6E"); + } + _appendMessage(colorClass, text) { + if (!this.elements.output) return; + const p = document.createElement("p"); + p.className = colorClass; + p.textContent = text; + this.elements.output.appendChild(p); + if (this.shouldAutoScroll) { + this.elements.output.scrollTop = this.elements.output.scrollHeight; + } + } + _updateStatus(status, text) { + const indicator = this.elements.statusIndicator.querySelector("span.relative"); + const statusText = this.elements.statusIndicator.childNodes[2]; + const colors = { + "connecting": "bg-yellow-500", + "connected": "bg-green-500", + "disconnected": "bg-zinc-500", + "error": "bg-red-500" + }; + indicator.querySelectorAll("span").forEach((span) => { + span.className = span.className.replace(/bg-\w+-\d+/g, colors[status] || colors.disconnected); + }); + if (statusText) { + statusText.textContent = ` ${text}`; + } + } +}; + +// frontend/js/pages/logs/batchActions.js +var logsPageInstance = null; +var elements = { + batchActionsBtn: null, + batchActionsMenu: null, + deleteSelectedLogsBtn: null, + clearAllLogsBtn: null +}; +var handleDocumentClick = (event) => { + if (!elements.batchActionsMenu.contains(event.target) && !elements.batchActionsBtn.contains(event.target)) { + closeBatchActionsMenu(); + } +}; +function closeBatchActionsMenu() { + if (elements.batchActionsMenu && !elements.batchActionsMenu.classList.contains("hidden")) { + elements.batchActionsMenu.classList.remove("opacity-100", "scale-100"); + elements.batchActionsMenu.classList.add("opacity-0", "scale-95"); + setTimeout(() => { + elements.batchActionsMenu.classList.add("hidden"); + }, 100); + document.removeEventListener("click", handleDocumentClick); + } +} +function handleBatchActionsToggle(event) { + event.stopPropagation(); + const isHidden = elements.batchActionsMenu.classList.contains("hidden"); + if (isHidden) { + elements.batchActionsMenu.classList.remove("hidden", "opacity-0", "scale-95"); + elements.batchActionsMenu.classList.add("opacity-100", "scale-100"); + document.addEventListener("click", handleDocumentClick); + } else { + closeBatchActionsMenu(); + } +} +async function handleDeleteSelectedLogs() { + closeBatchActionsMenu(); + const selectedIds = Array.from(logsPageInstance.state.selectedLogIds); + if (selectedIds.length === 0) return; + Swal.fire({ + width: "20rem", + backdrop: `rgba(0,0,0,0.5)`, + heightAuto: false, + customClass: { popup: `swal2-custom-style ${document.documentElement.classList.contains("dark") ? "swal2-dark" : ""}` }, + title: "\u786E\u8BA4\u5220\u9664", + text: `\u60A8\u786E\u5B9A\u8981\u5220\u9664\u9009\u5B9A\u7684 ${selectedIds.length} \u6761\u65E5\u5FD7\u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002`, + icon: "warning", + showCancelButton: true, + confirmButtonText: "\u786E\u8BA4\u5220\u9664", + cancelButtonText: "\u53D6\u6D88", + reverseButtons: false, + confirmButtonColor: "#ef4444", + cancelButtonColor: "#6b7280", + focusCancel: true, + target: "#main-content-wrapper" + }).then(async (result) => { + if (result.isConfirmed) { + try { + const idsQueryString = selectedIds.join(","); + const url = `/admin/logs?ids=${idsQueryString}`; + const { success, message } = await apiFetchJson(url, { method: "DELETE" }); + if (success) { + Swal.fire({ toast: true, position: "top-end", icon: "success", title: "\u5220\u9664\u6210\u529F", showConfirmButton: false, timer: 2e3, timerProgressBar: true }); + logsPageInstance.loadAndRenderLogs(); + } else { + throw new Error(message || "\u5220\u9664\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"); + } + } catch (error) { + Swal.fire({ icon: "error", title: "\u64CD\u4F5C\u5931\u8D25", text: error.message, target: "#main-content-wrapper" }); + } + } + }); +} +async function handleClearAllLogs() { + closeBatchActionsMenu(); + Swal.fire({ + width: "20rem", + backdrop: `rgba(0,0,0,0.5)`, + heightAuto: false, + customClass: { popup: `swal2-custom-style ${document.documentElement.classList.contains("dark") ? "swal2-dark" : ""}` }, + title: "\u5371\u9669\u64CD\u4F5C\u786E\u8BA4", + html: `\u60A8\u786E\u5B9A\u8981\u6E05\u7A7A\u5168\u90E8\u65E5\u5FD7\u5417\uFF1F
\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\uFF01`, + icon: "warning", + showCancelButton: true, + confirmButtonText: "\u786E\u8BA4\u6E05\u7A7A", + cancelButtonText: "\u53D6\u6D88", + reverseButtons: false, + confirmButtonColor: "#ef4444", + cancelButtonColor: "#6b7280", + focusCancel: true, + target: "#main-content-wrapper" + }).then(async (result) => { + if (result.isConfirmed) { + try { + const url = `/admin/logs/all`; + const { success, message } = await apiFetchJson(url, { method: "DELETE" }); + if (success) { + Swal.fire({ toast: true, position: "top-end", icon: "success", title: "\u6E05\u7A7A\u6210\u529F", showConfirmButton: false, timer: 2e3, timerProgressBar: true }); + logsPageInstance.loadAndRenderLogs(); + } else { + throw new Error(message || "\u6E05\u7A7A\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"); + } + } catch (error) { + Swal.fire({ icon: "error", title: "\u64CD\u4F5C\u5931\u8D25", text: error.message, target: "#main-content-wrapper" }); + } + } + }); +} +function initBatchActions(logsPage) { + logsPageInstance = logsPage; + elements.batchActionsBtn = document.getElementById("batch-actions-btn"); + elements.batchActionsMenu = document.getElementById("batch-actions-menu"); + elements.deleteSelectedLogsBtn = document.getElementById("delete-selected-logs-btn"); + elements.clearAllLogsBtn = document.getElementById("clear-all-logs-btn"); + if (!elements.batchActionsBtn) return; + elements.batchActionsBtn.addEventListener("click", handleBatchActionsToggle); + if (elements.deleteSelectedLogsBtn) { + elements.deleteSelectedLogsBtn.addEventListener("click", handleDeleteSelectedLogs); + } + if (elements.clearAllLogsBtn) { + elements.clearAllLogsBtn.addEventListener("click", handleClearAllLogs); + } +} + +// frontend/js/pages/logs/index.js +var import_flatpickr = __toESM(require_flatpickr()); +var dataStore = { + groups: /* @__PURE__ */ new Map(), + keys: /* @__PURE__ */ new Map() +}; +var LogsPage = class { + constructor() { + this.state = { + logs: [], + pagination: { page: 1, pages: 1, total: 0, page_size: 20 }, + isLoading: true, + filters: { + page: 1, + page_size: 20, + q: "", + key_ids: /* @__PURE__ */ new Set(), + group_ids: /* @__PURE__ */ new Set(), + error_types: /* @__PURE__ */ new Set(), + status_codes: /* @__PURE__ */ new Set(), + start_date: null, + end_date: null + }, + selectedLogIds: /* @__PURE__ */ new Set(), + currentView: "error" + }; + this.elements = { + tabsContainer: document.querySelector("[data-sliding-tabs-container]"), + contentContainer: document.getElementById("log-content-container"), + errorFilters: document.getElementById("error-logs-filters"), + systemControls: document.getElementById("system-logs-controls"), + errorTemplate: document.getElementById("error-logs-template"), + systemTemplate: document.getElementById("system-logs-template") + }; + this.initialized = !!this.elements.contentContainer; + if (this.initialized) { + this.logList = null; + this.systemLogTerminal = null; + this.debouncedLoadAndRender = debounce(() => this.loadAndRenderLogs(), 300); + this.fp = null; + this.themeObserver = null; + } + } + async init() { + if (!this.initialized) return; + this._initPermanentEventListeners(); + await this.loadGroupsOnce(); + this.state.currentView = null; + this.switchToView("error"); + } + _initPermanentEventListeners() { + this.elements.tabsContainer.addEventListener("click", (event) => { + const tabItem = event.target.closest("[data-tab-target]"); + if (!tabItem) return; + event.preventDefault(); + const viewName = tabItem.dataset.tabTarget; + if (viewName) { + this.switchToView(viewName); + } + }); + } + switchToView(viewName) { + if (this.state.currentView === viewName && this.elements.contentContainer.innerHTML !== "") return; + if (this.systemLogTerminal) { + this.systemLogTerminal.disconnect(); + this.systemLogTerminal = null; + } + if (this.fp) { + this.fp.destroy(); + this.fp = null; + } + if (this.themeObserver) { + this.themeObserver.disconnect(); + this.themeObserver = null; + } + this.state.currentView = viewName; + this.elements.contentContainer.innerHTML = ""; + if (viewName === "error") { + this.elements.errorFilters.classList.remove("hidden"); + this.elements.systemControls.classList.add("hidden"); + const template = this.elements.errorTemplate.content.cloneNode(true); + this.elements.contentContainer.appendChild(template); + requestAnimationFrame(() => { + this._initErrorLogView(); + }); + } else if (viewName === "system") { + this.elements.errorFilters.classList.add("hidden"); + this.elements.systemControls.classList.remove("hidden"); + const template = this.elements.systemTemplate.content.cloneNode(true); + this.elements.contentContainer.appendChild(template); + requestAnimationFrame(() => { + this._initSystemLogView(); + }); + } + } + _initErrorLogView() { + this.elements.tableBody = document.getElementById("logs-table-body"); + this.elements.selectedCount = document.querySelector(".flex-1.text-sm span.font-semibold:nth-child(1)"); + this.elements.totalCount = document.querySelector(".flex-1.text-sm span:last-child"); + this.elements.pageSizeSelect = document.querySelector('[data-component="custom-select-v2"] select'); + this.elements.pageInfo = document.querySelector(".flex.w-\\[100px\\]"); + this.elements.paginationBtns = document.querySelectorAll("[data-pagination-controls] button"); + this.elements.selectAllCheckbox = document.querySelector('thead .table-head-cell input[type="checkbox"]'); + this.elements.searchInput = document.getElementById("log-search-input"); + this.elements.errorTypeFilterBtn = document.getElementById("filter-error-type-btn"); + this.elements.errorCodeFilterBtn = document.getElementById("filter-error-code-btn"); + this.elements.dateRangeFilterBtn = document.getElementById("filter-date-range-btn"); + this.logList = new logList_default(this.elements.tableBody, dataStore); + const selectContainer = document.querySelector('[data-component="custom-select-v2"]'); + if (selectContainer) { + new CustomSelectV2(selectContainer); + } + this.initFilterPopovers(); + this.initDateRangePicker(); + this.initEventListeners(); + this._observeThemeChanges(); + initBatchActions(this); + this.loadAndRenderLogs(); + } + _observeThemeChanges() { + const applyTheme = () => { + if (!this.fp || !this.fp.calendarContainer) return; + if (document.documentElement.classList.contains("dark")) { + this.fp.calendarContainer.classList.add("dark"); + } else { + this.fp.calendarContainer.classList.remove("dark"); + } + }; + this.themeObserver = new MutationObserver((mutationsList) => { + for (const mutation of mutationsList) { + if (mutation.type === "attributes" && mutation.attributeName === "class") { + applyTheme(); + } + } + }); + this.themeObserver.observe(document.documentElement, { attributes: true }); + applyTheme(); + } + _initSystemLogView() { + this.systemLogTerminal = new SystemLogTerminal( + this.elements.contentContainer, + this.elements.systemControls + ); + Swal.fire({ + width: "20rem", + backdrop: `rgba(0,0,0,0.5)`, + heightAuto: false, + customClass: { popup: `swal2-custom-style ${document.documentElement.classList.contains("dark") ? "swal2-dark" : ""}` }, + title: "\u7CFB\u7EDF\u7EC8\u7AEF\u65E5\u5FD7", + text: "\u60A8\u5373\u5C06\u8FDE\u63A5\u5230\u5B9E\u65F6\u7CFB\u7EDF\u65E5\u5FD7\u6D41\u7A97\u53E3\u3002", + showCancelButton: true, + confirmButtonText: "\u786E\u8BA4", + cancelButtonText: "\u53D6\u6D88", + reverseButtons: false, + confirmButtonColor: "rgba(31, 102, 255, 0.8)", + cancelButtonColor: "#6b7280", + focusConfirm: false, + focusCancel: false, + target: "#main-content-wrapper" + }).then((result) => { + if (result.isConfirmed) { + this.systemLogTerminal.connect(); + } else { + const errorLogTab = Array.from(this.elements.tabsContainer.querySelectorAll('[data-tab-target="error"]'))[0]; + if (errorLogTab) errorLogTab.click(); + } + }); + } + initFilterPopovers() { + const errorTypeOptions = [ + ...Object.values(STATUS_CODE_MAP).map((v) => ({ value: v.type, label: v.type })), + ...Object.values(STATIC_ERROR_MAP).map((v) => ({ value: v.type, label: v.type })) + ]; + const uniqueErrorTypeOptions = Array.from(new Map(errorTypeOptions.map((item) => [item.value, item])).values()); + if (this.elements.errorTypeFilterBtn) { + new FilterPopover(this.elements.errorTypeFilterBtn, uniqueErrorTypeOptions, "\u7B5B\u9009\u9519\u8BEF\u7C7B\u578B"); + } + const statusCodeOptions = Object.keys(STATUS_CODE_MAP).map((code) => ({ value: code, label: code })); + if (this.elements.errorCodeFilterBtn) { + new FilterPopover(this.elements.errorCodeFilterBtn, statusCodeOptions, "\u7B5B\u9009\u72B6\u6001\u7801"); + } + } + initDateRangePicker() { + if (!this.elements.dateRangeFilterBtn) return; + const buttonTextSpan = this.elements.dateRangeFilterBtn.querySelector("span"); + const originalText = buttonTextSpan.textContent; + this.fp = (0, import_flatpickr.default)(this.elements.dateRangeFilterBtn, { + mode: "range", + dateFormat: "Y-m-d", + onClose: (selectedDates) => { + if (selectedDates.length === 2) { + const [start, end] = selectedDates; + end.setHours(23, 59, 59, 999); + this.state.filters.start_date = start.toISOString(); + this.state.filters.end_date = end.toISOString(); + const startDateStr = start.toISOString().split("T")[0]; + const endDateStr = end.toISOString().split("T")[0]; + buttonTextSpan.textContent = `${startDateStr} ~ ${endDateStr}`; + this.elements.dateRangeFilterBtn.classList.add("!border-primary", "!text-primary"); + this.state.filters.page = 1; + this.loadAndRenderLogs(); + } + }, + onReady: (selectedDates, dateStr, instance) => { + if (document.documentElement.classList.contains("dark")) { + instance.calendarContainer.classList.add("dark"); + } + const clearButton = document.createElement("button"); + clearButton.textContent = "\u6E05\u9664"; + clearButton.className = "button flatpickr-button flatpickr-clear-button"; + clearButton.addEventListener("click", (e) => { + e.preventDefault(); + instance.clear(); + this.state.filters.start_date = null; + this.state.filters.end_date = null; + buttonTextSpan.textContent = originalText; + this.elements.dateRangeFilterBtn.classList.remove("!border-primary", "!text-primary"); + this.state.filters.page = 1; + this.loadAndRenderLogs(); + instance.close(); + }); + instance.calendarContainer.appendChild(clearButton); + const nativeMonthSelect = instance.monthsDropdownContainer; + if (!nativeMonthSelect) return; + const monthYearContainer = nativeMonthSelect.parentElement; + const wrapper = document.createElement("div"); + wrapper.className = "custom-select-v2-container relative inline-block text-left"; + wrapper.innerHTML = ` + + `; + const template = document.createElement("template"); + template.className = "custom-select-panel-template"; + template.innerHTML = ` + + `; + nativeMonthSelect.classList.add("hidden"); + wrapper.appendChild(nativeMonthSelect); + wrapper.appendChild(template); + monthYearContainer.prepend(wrapper); + const customSelect = new CustomSelectV2(wrapper); + instance.customMonthSelect = customSelect; + }, + onMonthChange: (selectedDates, dateStr, instance) => { + if (instance.customMonthSelect) { + instance.customMonthSelect.updateTriggerText(); + } + } + }); + } + initEventListeners() { + if (this.elements.pageSizeSelect) { + this.elements.pageSizeSelect.addEventListener("change", (e) => this.changePageSize(parseInt(e.target.value, 10))); + } + if (this.elements.paginationBtns.length >= 4) { + this.elements.paginationBtns[0].addEventListener("click", () => this.goToPage(1)); + this.elements.paginationBtns[1].addEventListener("click", () => this.goToPage(this.state.pagination.page - 1)); + this.elements.paginationBtns[2].addEventListener("click", () => this.goToPage(this.state.pagination.page + 1)); + this.elements.paginationBtns[3].addEventListener("click", () => this.goToPage(this.state.pagination.pages)); + } + if (this.elements.selectAllCheckbox) { + this.elements.selectAllCheckbox.addEventListener("change", (event) => this.handleSelectAllChange(event)); + } + if (this.elements.tableBody) { + this.elements.tableBody.addEventListener("change", (event) => { + if (event.target.type === "checkbox") this.handleSelectionChange(event.target); + }); + } + if (this.elements.searchInput) { + this.elements.searchInput.addEventListener("input", (event) => this.handleSearchInput(event)); + } + if (this.elements.errorTypeFilterBtn) { + this.elements.errorTypeFilterBtn.addEventListener("filter-change", (e) => this.handleFilterChange(e)); + } + if (this.elements.errorCodeFilterBtn) { + this.elements.errorCodeFilterBtn.addEventListener("filter-change", (e) => this.handleFilterChange(e)); + } + } + handleFilterChange(event) { + const { filterKey, selected } = event.detail; + if (filterKey === "filter-error-type-btn") { + this.state.filters.error_types = selected; + } else if (filterKey === "filter-error-code-btn") { + this.state.filters.status_codes = selected; + } + this.state.filters.page = 1; + this.loadAndRenderLogs(); + } + handleSearchInput(event) { + const searchTerm = event.target.value.trim().toLowerCase(); + this.state.filters.page = 1; + this.state.filters.q = ""; + this.state.filters.key_ids = /* @__PURE__ */ new Set(); + this.state.filters.group_ids = /* @__PURE__ */ new Set(); + if (searchTerm === "") { + this.debouncedLoadAndRender(); + return; + } + const matchedGroupIds = /* @__PURE__ */ new Set(); + dataStore.groups.forEach((group) => { + if (group.display_name.toLowerCase().includes(searchTerm)) { + matchedGroupIds.add(group.id); + } + }); + const matchedKeyIds = /* @__PURE__ */ new Set(); + dataStore.keys.forEach((key) => { + if (key.APIKey && key.APIKey.toLowerCase().includes(searchTerm)) { + matchedKeyIds.add(key.ID); + } + }); + if (matchedGroupIds.size > 0) this.state.filters.group_ids = matchedGroupIds; + if (matchedKeyIds.size > 0) this.state.filters.key_ids = matchedKeyIds; + if (matchedGroupIds.size === 0 && matchedKeyIds.size === 0) { + this.state.filters.q = searchTerm; + } + this.debouncedLoadAndRender(); + } + handleSelectionChange(checkbox) { + const row = checkbox.closest(".table-row"); + if (!row) return; + const logId = parseInt(row.dataset.logId, 10); + if (isNaN(logId)) return; + if (checkbox.checked) { + this.state.selectedLogIds.add(logId); + } else { + this.state.selectedLogIds.delete(logId); + } + this.syncSelectionUI(); + } + handleSelectAllChange(event) { + const isChecked = event.target.checked; + this.state.logs.forEach((log) => { + if (isChecked) { + this.state.selectedLogIds.add(log.ID); + } else { + this.state.selectedLogIds.delete(log.ID); + } + }); + this.syncRowCheckboxes(); + this.syncSelectionUI(); + } + syncRowCheckboxes() { + const isAllChecked = this.elements.selectAllCheckbox.checked; + this.elements.tableBody.querySelectorAll('input[type="checkbox"]').forEach((cb) => { + cb.checked = isAllChecked; + }); + } + syncSelectionUI() { + if (!this.elements.selectAllCheckbox || !this.elements.selectedCount) return; + const selectedCount = this.state.selectedLogIds.size; + const visibleLogsCount = this.state.logs.length; + if (selectedCount === 0) { + this.elements.selectAllCheckbox.checked = false; + this.elements.selectAllCheckbox.indeterminate = false; + } else if (selectedCount < visibleLogsCount) { + this.elements.selectAllCheckbox.checked = false; + this.elements.selectAllCheckbox.indeterminate = true; + } else if (selectedCount === visibleLogsCount && visibleLogsCount > 0) { + this.elements.selectAllCheckbox.checked = true; + this.elements.selectAllCheckbox.indeterminate = false; + } + this.elements.selectedCount.textContent = selectedCount; + const hasSelection = selectedCount > 0; + const deleteSelectedBtn = document.getElementById("delete-selected-logs-btn"); + if (deleteSelectedBtn) { + deleteSelectedBtn.disabled = !hasSelection; + } + } + changePageSize(newSize) { + this.state.filters.page_size = newSize; + this.state.filters.page = 1; + this.loadAndRenderLogs(); + } + goToPage(page) { + if (page < 1 || page > this.state.pagination.pages || this.state.isLoading) return; + this.state.filters.page = page; + this.loadAndRenderLogs(); + } + updatePaginationUI() { + const { page, pages, total } = this.state.pagination; + if (this.elements.pageInfo) { + this.elements.pageInfo.textContent = `\u7B2C ${page} / ${pages} \u9875`; + } + if (this.elements.totalCount) { + this.elements.totalCount.textContent = total; + } + if (this.elements.paginationBtns.length >= 4) { + const isFirstPage = page === 1; + const isLastPage = page === pages || pages === 0; + this.elements.paginationBtns[0].disabled = isFirstPage; + this.elements.paginationBtns[1].disabled = isFirstPage; + this.elements.paginationBtns[2].disabled = isLastPage; + this.elements.paginationBtns[3].disabled = isLastPage; + } + } + async loadGroupsOnce() { + if (dataStore.groups.size > 0) return; + try { + const { success, data } = await apiFetchJson("/admin/keygroups"); + if (success && Array.isArray(data)) { + data.forEach((group) => dataStore.groups.set(group.id, group)); + } + } catch (error) { + console.error("Failed to load key groups:", error); + } + } + async loadAndRenderLogs() { + this.state.isLoading = true; + this.state.selectedLogIds.clear(); + this.logList.renderLoading(); + this.updatePaginationUI(); + this.syncSelectionUI(); + try { + const finalParams = {}; + const { filters } = this.state; + Object.keys(filters).forEach((key) => { + if (!(filters[key] instanceof Set)) { + finalParams[key] = filters[key]; + } + }); + const translatedErrorCodes = /* @__PURE__ */ new Set(); + const translatedStatusCodes = new Set(filters.status_codes); + if (filters.error_types.size > 0) { + filters.error_types.forEach((type) => { + for (const [code, obj] of Object.entries(STATUS_CODE_MAP)) { + if (obj.type === type) translatedStatusCodes.add(code); + } + for (const [code, obj] of Object.entries(STATIC_ERROR_MAP)) { + if (obj.type === type) translatedErrorCodes.add(code); + } + }); + } + if (filters.key_ids.size > 0) finalParams.key_ids = [...filters.key_ids].join(","); + if (filters.group_ids.size > 0) finalParams.group_ids = [...filters.group_ids].join(","); + if (translatedErrorCodes.size > 0) finalParams.error_codes = [...translatedErrorCodes].join(","); + if (translatedStatusCodes.size > 0) finalParams.status_codes = [...translatedStatusCodes].join(","); + Object.keys(finalParams).forEach((key) => { + if (finalParams[key] === "" || finalParams[key] === null || finalParams[key] === void 0) { + delete finalParams[key]; + } + }); + const query = new URLSearchParams(finalParams); + const { success, data } = await apiFetchJson( + `/admin/logs?${query.toString()}`, + { cache: "no-cache", noCache: true } + ); + if (success && typeof data === "object" && data.items) { + const { items, total, page, page_size } = data; + this.state.logs = items; + const totalPages = Math.ceil(total / page_size); + this.state.pagination = { page, page_size, total, pages: totalPages > 0 ? totalPages : 1 }; + await this.enrichLogsWithKeyNames(items); + this.logList.render(this.state.logs, this.state.pagination, this.state.selectedLogIds); + } else { + this.state.logs = []; + this.state.pagination = { ...this.state.pagination, total: 0, pages: 1, page: 1 }; + this.logList.render([], this.state.pagination); + } + } catch (error) { + console.error("Failed to load logs:", error); + this.state.logs = []; + this.state.pagination = { ...this.state.pagination, total: 0, pages: 1, page: 1 }; + this.logList.render([], this.state.pagination); + } finally { + this.state.isLoading = false; + this.updatePaginationUI(); + this.syncSelectionUI(); + } + } + async enrichLogsWithKeyNames(logs) { + const missingKeyIds = [...new Set( + logs.filter((log) => log.KeyID && !dataStore.keys.has(log.KeyID)).map((log) => log.ID) + )]; + if (missingKeyIds.length === 0) return; + try { + const idsQuery = missingKeyIds.join(","); + const { success, data } = await apiFetchJson(`/admin/apikeys?ids=${idsQuery}`); + if (success && Array.isArray(data)) { + data.forEach((key) => dataStore.keys.set(key.ID, key)); + } + } catch (error) { + console.error(`Failed to fetch key details:`, error); + } + } +}; +function logs_default() { + const page = new LogsPage(); + page.init(); +} +export { + logs_default as default +}; +/* flatpickr v4.6.13,, @license MIT */ diff --git a/web/static/js/main.js b/web/static/js/main.js index 98d88ad..5ff4b58 100644 --- a/web/static/js/main.js +++ b/web/static/js/main.js @@ -182,7 +182,7 @@ var pageModules = { // esbuild 看到这个 import() 语法,就会自动将 dashboard.js 及其依赖打包成一个独立的 chunk 文件 "dashboard": () => import("./dashboard-XFUWX3IN.js"), "keys": () => import("./keys-2IUHJHHE.js"), - "logs": () => import("./logs-MNVRT6ND.js") + "logs": () => import("./logs-YPEOUZVC.js") // 'settings': () => import('./pages/settings.js'), // 未来启用 settings 页面 // 未来新增的页面,只需在这里添加一行映射,esbuild会自动处理 }; diff --git a/web/templates/logs.html b/web/templates/logs.html index 0c07cec..cf1f20b 100644 --- a/web/templates/logs.html +++ b/web/templates/logs.html @@ -55,19 +55,41 @@ 错误码 - - +
+
+ +
+ + +
+