iobroker.time-tracker 0.7.6 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -11
- package/io-package.json +14 -14
- package/package.json +1 -1
- package/www/assets/{index-Bof0lCQZ.js → index-hqZFDQvU.js} +2 -2
- package/www/assets/index-hqZFDQvU.js.map +1 -0
- package/www/index.html +1 -1
- package/www/sw.js +1 -1
- package/www/sw.js.map +1 -1
- package/www/assets/index-Bof0lCQZ.js.map +0 -1
package/README.md
CHANGED
|
@@ -415,6 +415,11 @@ local SQLite file, access is role-based, and every correction is written to an a
|
|
|
415
415
|
|
|
416
416
|
### **WORK IN PROGRESS**
|
|
417
417
|
|
|
418
|
+
### 0.7.7 (2026-09-25)
|
|
419
|
+
|
|
420
|
+
- (Alex) change: the rule dialog keeps “Aktiv” beside “Wiederholung”, and the validity dates (“Gültig ab”/“Gültig
|
|
421
|
+
bis”) stand in a row of their own below it — the two date fields no longer wrap around the button
|
|
422
|
+
|
|
418
423
|
### 0.7.6 (2026-09-25)
|
|
419
424
|
|
|
420
425
|
- (Alex) new: an automatic rule can be limited to a period. The rule dialog knows “Valid from” and “Valid until” as
|
|
@@ -453,17 +458,6 @@ local SQLite file, access is role-based, and every correction is written to an a
|
|
|
453
458
|
one of those already needs `time.edit_other`. The setting `edit_window_days` stays and now has exactly one job — it
|
|
454
459
|
tells the **offline queue** how far back it may hand in a punch on its own (`too_old`); README and D6 say that
|
|
455
460
|
|
|
456
|
-
### 0.7.2 (2026-09-24)
|
|
457
|
-
|
|
458
|
-
- (Alex) security: the administration cannot lock itself out any more. Deactivating or taking the admin role away from
|
|
459
|
-
the **last active administrator** is refused (problem `last_administrator`, 409), and the web app warns before it is
|
|
460
|
-
tried on the **own** account: the own switch explains why an account cannot deactivate itself, and the role dialog
|
|
461
|
-
names the last administrator and keeps saving locked
|
|
462
|
-
- (Alex) fix: the PDF statement writes the **absences** left aligned on lines of their own. They started where the last
|
|
463
|
-
cell of the day table was drawn, so every line was squeezed into the rest of that row
|
|
464
|
-
- (Alex) fix: the list of the absence types shows “visible for everybody” on a line of its own, so the long facts
|
|
465
|
-
(`reduces vacation`) cannot push it out of the row any more
|
|
466
|
-
|
|
467
461
|
Older entries are kept in [`CHANGELOG_OLD.md`](CHANGELOG_OLD.md).
|
|
468
462
|
|
|
469
463
|
## Provenance
|
package/io-package.json
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "time-tracker",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.7",
|
|
5
5
|
"nogit": true,
|
|
6
6
|
"news": {
|
|
7
|
+
"0.7.7": {
|
|
8
|
+
"en": "change: the rule dialog keeps “Aktiv” beside “Wiederholung”, and the validity dates (“Gültig ab” and “Gültig bis”) stand in a row of their own below it — the two date fields no longer wrap around the button.",
|
|
9
|
+
"de": "change: Im Regel-Dialog bleibt „Aktiv“ neben „Wiederholung“, und die Gültigkeitsfelder „Gültig ab“ und „Gültig bis“ stehen in einer eigenen Zeile darunter – die beiden Datumsfelder umfließen den Knopf nicht mehr.",
|
|
10
|
+
"ru": "изменение: в диалоге правила «Aktiv» остаётся рядом с «Wiederholung», а поля срока действия «Gültig ab» и «Gültig bis» стоят в отдельной строке под ним — два поля даты больше не обтекают кнопку.",
|
|
11
|
+
"pt": "alteração: no diálogo da regra «Aktiv» fica ao lado de «Wiederholung», e os campos de validade «Gültig ab» e «Gültig bis» ficam numa linha própria abaixo dele — as duas datas deixam de contornar o botão.",
|
|
12
|
+
"nl": "wijziging: in het regeldialoog blijft ‘Aktiv’ naast ‘Wiederholung’ staan, en de geldigheidsvelden ‘Gültig ab’ en ‘Gültig bis’ staan in een eigen regel daaronder — de twee datumvelden lopen niet meer om de knop heen.",
|
|
13
|
+
"fr": "changement : dans la boîte de dialogue, « Aktiv » reste à côté de « Wiederholung » et les champs de validité « Gültig ab » et « Gültig bis » occupent une ligne à part en dessous — les deux dates ne s'enroulent plus autour du bouton.",
|
|
14
|
+
"it": "modifica: nella finestra della regola «Aktiv» resta accanto a «Wiederholung», mentre i campi di validità «Gültig ab» e «Gültig bis» stanno su una riga propria sotto di esso — le due date non si avvolgono più attorno al pulsante.",
|
|
15
|
+
"es": "cambio: en el diálogo de la regla «Aktiv» se queda junto a «Wiederholung», y los campos de validez «Gültig ab» y «Gültig bis» ocupan una fila propia debajo — las dos fechas ya no rodean el botón.",
|
|
16
|
+
"pl": "zmiana: w oknie reguły „Aktiv” pozostaje obok „Wiederholung”, a pola ważności „Gültig ab” i „Gültig bis” stoją w osobnym wierszu pod nim — dwa pola daty nie opływają już przycisku.",
|
|
17
|
+
"uk": "зміна: у вікні правила «Aktiv» залишається поруч із «Wiederholung», а поля терміну дії «Gültig ab» і «Gültig bis» стоять в окремому рядку під ним — два поля дати більше не обтікають кнопку.",
|
|
18
|
+
"zh-cn": "变更:规则对话框中“Aktiv”仍与“Wiederholung”同一行,而有效期字段“Gültig ab”和“Gültig bis”单独位于下一行——两个日期字段不再围绕按钮换行。"
|
|
19
|
+
},
|
|
7
20
|
"0.7.6": {
|
|
8
21
|
"en": "new: an automatic rule can be limited to a period. The rule dialog knows “Valid from” and “Valid until” as dates — an empty field means “from now on” or “without an end” — and the adapter compares the period with the local calendar day of the employee, exactly like the weekdays: a holiday stand-in, a seasonal worker or a project phase therefore ends by itself. An expired period is not an error and the rule still fires at most once per period; the list of the last runs below the rules now shows the five most recent entries.",
|
|
9
22
|
"de": "neu: Eine Automatikregel kann auf einen Zeitraum begrenzt werden. Der Regel-Dialog kennt „Gültig ab“ und „Gültig bis“ als Datum – ein leeres Feld bedeutet „ab sofort“ bzw. „unbegrenzt“ – und der Adapter vergleicht den Zeitraum mit dem lokalen Kalendertag des Mitarbeiters, genau wie die Wochentage: eine Ferienvertretung, eine Saisonkraft oder ein Projektzeitraum endet damit von selbst. Ein abgelaufener Zeitraum ist kein Fehler, und die Regel feuert weiterhin höchstens einmal pro Zeitraum; die Liste der letzten Ausführungen zeigt jetzt die fünf jüngsten Einträge.",
|
|
@@ -81,19 +94,6 @@
|
|
|
81
94
|
"pl": "poprawka i zmiana: okno dnia w miesiącu pracownika pokazuje i zmienia jego stemple — wcześniej działało na własnym koncie, więc dodany tam stempel trafiał do niewłaściwej osoby. Czasy należą do administracji: pracownik nie zmienia już własnych czasów, lecz zostawia notatkę do dnia („zapomniałem się zastemplować”), którą administracja księguje i oznacza jako załatwioną. Konto administratora nie należy do nikogo i nie stempluje. Lista rodzajów nieobecności zapisuje „widoczne dla wszystkich” tylko przy tych rodzajach, które pracownicy naprawdę mogą wybrać.",
|
|
82
95
|
"uk": "виправлення та зміна: вікно дня в місяці працівника показує та змінює його відмітки — раніше воно працювало з власним обліковим записом, тож додана там відмітка потрапляла не тій людині. Час належить адміністрації: працівник більше не змінює власний час, а залишає нотатку до дня («забув відмітитися»), яку адміністрація проводить і позначає як опрацьовану. Обліковий запис адміністратора нікому не належить і більше не відмічається. Список видів відсутності пише «видно всім» лише для тих видів, які працівники справді можуть обрати.",
|
|
83
96
|
"zh-cn": "修复与变更:员工月份中的当日窗口现在显示并修改该员工的打卡记录——此前它作用于自己的账户,因此在那里补的打卡会记到错误的人名下。时间归管理层负责:员工不再修改自己的时间,而是为当天留下备注(“忘记打卡”),由管理层入账并标记为已处理。管理员账户不属于任何人,不再打卡。缺勤类型列表只在员工真正可以选择的类型上写出「所有人可见」。"
|
|
84
|
-
},
|
|
85
|
-
"0.7.0": {
|
|
86
|
-
"en": "new: an absence type can carry a colour, and the calendar paints a day with it — vacation and sickness are told apart at a glance. The editor offers a colour picker and “remove the colour”, the list shows a dot per type, and the seeded types come with colours (vacation green, sickness red, accident orange, military slate, internal blue, training violet, external brown). An open request keeps its colour but is drawn faded",
|
|
87
|
-
"de": "neu: eine Abwesenheitsart kann eine Farbe tragen, und der Kalender malt den Tag damit — Urlaub und Krankheit sind auf einen Blick zu unterscheiden. Der Editor bietet eine Farbwahl und „Farbe entfernen“, die Liste zeigt einen Punkt je Art, und die Standardarten bringen Farben mit (Ferien grün, Krankheit rot, Unfall orange, Militär blaugrau, Intern blau, Weiterbildung violett, Extern braun). Ein offener Antrag behält seine Farbe, wird aber blasser gezeichnet",
|
|
88
|
-
"ru": "новое: вид отсутствия может нести цвет, и календарь окрашивает им день — отпуск и болезнь различаются сразу. Редактор предлагает выбор цвета и «убрать цвет», список показывает точку для каждого вида, а стандартные виды идут с цветами (отпуск зелёный, болезнь красная, несчастный случай оранжевый, служба синевато-серая, внутреннее синее, обучение фиолетовое, внешнее коричневое). Открытая заявка сохраняет цвет, но рисуется бледнее",
|
|
89
|
-
"pt": "novo: um tipo de ausência pode ter uma cor e o calendário pinta o dia com ela — férias e doença distinguem-se de imediato. O editor oferece um seletor de cor e «remover a cor», a lista mostra um ponto por tipo e os tipos padrão trazem cores (férias verde, doença vermelho, acidente laranja, serviço militar cinza-azulado, interno azul, formação violeta, externo castanho). Um pedido aberto mantém a cor mas é desenhado mais claro",
|
|
90
|
-
"nl": "nieuw: een afwezigheidstype kan een kleur dragen en de agenda schildert de dag ermee — vakantie en ziekte zijn in één oogopslag te onderscheiden. De editor biedt een kleurkiezer en “kleur verwijderen”, de lijst toont een stip per type en de standaardtypes krijgen kleuren (vakantie groen, ziekte rood, ongeval oranje, militaire dienst leigrijs, intern blauw, opleiding violet, extern bruin). Een openstaande aanvraag houdt zijn kleur maar wordt lichter getekend",
|
|
91
|
-
"fr": "nouveau : un type d'absence peut porter une couleur et le calendrier peint le jour avec elle — vacances et maladie se distinguent d'un coup d'œil. L'éditeur propose un sélecteur de couleur et « supprimer la couleur », la liste affiche un point par type et les types par défaut ont des couleurs (vacances vert, maladie rouge, accident orange, service militaire gris ardoise, interne bleu, formation violet, externe brun). Une demande ouverte garde sa couleur mais est dessinée plus claire",
|
|
92
|
-
"it": "novità: un tipo di assenza può portare un colore e il calendario dipinge il giorno con esso — ferie e malattia si distinguono a colpo d'occhio. L'editor offre un selettore di colore e «rimuovere il colore», l'elenco mostra un punto per tipo e i tipi predefiniti hanno colori (ferie verde, malattia rosso, infortunio arancione, servizio militare grigio ardesia, interno blu, formazione viola, esterno marrone). Una richiesta aperta mantiene il colore ma è disegnata più chiara",
|
|
93
|
-
"es": "novedad: un tipo de ausencia puede llevar un color y el calendario pinta el día con él — vacaciones y enfermedad se distinguen de un vistazo. El editor ofrece un selector de color y «quitar el color», la lista muestra un punto por tipo y los tipos por defecto traen colores (vacaciones verde, enfermedad rojo, accidente naranja, servicio militar gris pizarra, interno azul, formación violeta, externo marrón). Una solicitud abierta mantiene su color pero se dibuja más clara",
|
|
94
|
-
"pl": "nowość: rodzaj nieobecności może mieć kolor, a kalendarz maluje nim dzień — urlop i choroba są rozróżnialne od razu. Edytor oferuje wybór koloru i „usuń kolor”, lista pokazuje kropkę dla każdego rodzaju, a domyślne rodzaje mają kolory (urlop zielony, choroba czerwony, wypadek pomarańczowy, służba wojskowa szaroniebieski, wewnętrzne niebieski, szkolenie fioletowy, zewnętrzne brązowy). Otwarty wniosek zachowuje kolor, ale jest rysowany bledszy",
|
|
95
|
-
"uk": "новинка: вид відсутності може мати колір, і календар зафарбовує ним день — відпустка й хвороба розрізняються одразу. Редактор пропонує вибір кольору та «прибрати колір», список показує точку для кожного виду, а стандартні види мають кольори (відпустка зелений, хвороба червоний, нещасний випадок оранжевий, військова служба сіро-синій, внутрішнє синій, навчання фіолетовий, зовнішнє коричневий). Відкрита заявка зберігає колір, але малюється блідіше",
|
|
96
|
-
"zh-cn": "新功能:缺勤类型可以带颜色,日历会用该颜色绘制日期 —— 休假与疾病一眼即可区分。编辑器提供取色器和「移除颜色」,列表中每种类型显示一个圆点,默认类型自带颜色(休假绿色、疾病红色、事故橙色、兵役蓝灰、内部蓝色、培训紫色、外部棕色)。待处理的申请保留颜色但绘制得更浅"
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
"titleLang": {
|
package/package.json
CHANGED
|
@@ -115,5 +115,5 @@ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.expo
|
|
|
115
115
|
The chosen QR Code version cannot contain this amount of data.
|
|
116
116
|
Minimum version required to store current data is: `+c+`.
|
|
117
117
|
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),zO=s((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||(e.color={});let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),BO=s((e=>{var t=zO();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),VO=s((e=>{var t=zO();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
118
|
-
`;return typeof a==`function`&&a(null,p),p}})),HO=u(s((e=>{var t=hO(),n=RO(),r=BO(),i=VO();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function UO(e){let t=new Intl.DateTimeFormat(e,{weekday:`short`});return[1,2,3,4,5,6,7].map(e=>({value:e,label:t.format(new Date(Date.UTC(2024,0,e)))}))}function WO(e,t,n){let r=n?[...e,t]:e.filter(e=>e!==t);return[...new Set(r)].sort((e,t)=>e-t)}function GO(e,t){return new Intl.NumberFormat(t,{style:`unit`,unit:`kilobyte`,maximumFractionDigits:0}).format(Math.max(1,Math.round(e/1024)))}function KO({onClose:e,onCreated:t}){let{t:n}=wE(),r=Kl({queryKey:[`admin`,`roles`],queryFn:()=>$.roles()}),[i,a]=(0,y.useState)({login:``,displayName:``,password:``,roleKeys:[`employee`]}),o=ql({mutationFn:e=>$.createUser(e),onSuccess:t}),s=e=>({value:String(i[e]),onChange:t=>a(n=>({...n,[e]:t.target.value}))});return(0,F.jsxs)(hb,{open:!0,onClose:e,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:n(`admin.user.create`)}),(0,F.jsxs)(Db,{children:[(0,F.jsx)(OD,{error:o.error??r.error}),(0,F.jsxs)(Z,{sx:{mt:1},children:[(0,F.jsx)(Q,{autoFocus:!0,fullWidth:!0,label:n(`admin.user.login`),...s(`login`)}),(0,F.jsx)(Q,{fullWidth:!0,label:n(`admin.user.name`),sx:{mt:2},...s(`displayName`)}),(0,F.jsx)(Q,{fullWidth:!0,type:`password`,label:n(`admin.user.password`),helperText:n(`admin.user.passwordHint`),sx:{mt:2},...s(`password`)}),(0,F.jsx)(Q,{select:!0,fullWidth:!0,label:n(`admin.user.roles`),sx:{mt:2},value:i.roleKeys[0]??`employee`,onChange:e=>a(t=>({...t,roleKeys:[e.target.value]})),children:(r.data??[]).map(e=>(0,F.jsx)(iC,{value:e.key,children:n(`role.${e.key}`,e.name)},e.key))})]})]}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:e,children:n(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:o.isPending||i.login.trim()===``||i.displayName.trim()===``||i.password.length<8,onClick:()=>o.mutate(i),children:n(`common.save`)})]})]})}function qO(e,t){return new Intl.DateTimeFormat(t,{dateStyle:`short`,timeStyle:`short`}).format(new Date(e*1e3))}function JO({rules:e,disabled:t,saving:n,onChange:r,onSave:i}){let{t:a}=wE(),o=(t,n)=>r(e.map((e,r)=>r===t?{...e,...n}:e));return(0,F.jsxs)(Z,{spacing:1,children:[e.map((n,i)=>(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(Q,{size:`small`,type:`number`,label:a(`admin.settings.pauseFrom`),value:String(n.fromMin),onChange:e=>o(i,{fromMin:Number(e.target.value)}),disabled:t}),(0,F.jsx)(Q,{size:`small`,type:`number`,label:a(`admin.settings.pauseTo`),value:n.toMin===null?``:String(n.toMin),onChange:e=>o(i,{toMin:e.target.value===``?null:Number(e.target.value)}),disabled:t}),(0,F.jsx)(Q,{size:`small`,type:`number`,label:a(`admin.settings.pauseMinutes`),value:String(n.pauseMin),onChange:e=>o(i,{pauseMin:Number(e.target.value)}),disabled:t}),(0,F.jsx)(dw,{checked:n.isActive!==!1,title:a(`admin.settings.pauseActive`),onChange:()=>o(i,{isActive:n.isActive===!1}),disabled:t}),(0,F.jsx)(vm,{size:`small`,title:a(`admin.backup.delete`),disabled:t,onClick:()=>r(e.filter((e,t)=>t!==i)),children:(0,F.jsx)(zD,{fontSize:`small`})})]},n.id??`new-${i}`)),(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(UD,{}),disabled:t,onClick:()=>r([...e,{fromMin:360,toMin:null,pauseMin:30,isActive:!0}]),children:a(`admin.settings.pauseAdd`)}),(0,F.jsx)(X,{size:`small`,variant:`contained`,disabled:t||n,onClick:i,children:a(`admin.settings.pauseSave`)})]})]})}function YO({user:e,onClose:t}){let{t:n,i18n:r}=wE(),i=Tc(),a=e?.id??0,o=Kl({queryKey:[`admin`,`profile`,a],queryFn:()=>$.workProfile(a),enabled:e!==null}),[s,c]=(0,y.useState)({}),l=ql({mutationFn:e=>$.saveWorkProfile(a,e),onSuccess:async()=>{c({}),await i.invalidateQueries({queryKey:[`admin`,`profile`,a]}),t()}}),u=Kl({queryKey:[`admin`,`pauseRules`,a],queryFn:()=>$.userPauseRules(a),enabled:e!==null}),[d,f]=(0,y.useState)(null),p=d??u.data??[],m=ql({mutationFn:e=>$.saveUserPauseRules(a,e),onSuccess:async()=>{f(null),await i.invalidateQueries({queryKey:[`admin`,`pauseRules`,a]}),t()}}),h=e=>c(t=>({...t,...e})),g=o.data?{...o.data,...s}:null,_=e=>Math.round(e/60*100)/100,v=Array.from({length:7},(e,t)=>new Intl.DateTimeFormat(r.language,{weekday:`narrow`}).format(new Date(Date.UTC(2026,0,4+t)))),b=(g?.workdays??`0;1;1;1;1;1;0`).split(`;`),x=(e,t,n)=>(0,F.jsx)(Q,{fullWidth:!0,size:`small`,type:`number`,label:t,value:String(g?.[e]??0),onChange:t=>h({[e]:Number(t.target.value)}),inputProps:n?{step:n}:void 0});return(0,F.jsxs)(hb,{open:e!==null,onClose:t,fullWidth:!0,maxWidth:`sm`,children:[(0,F.jsx)(Ib,{children:n(`admin.user.profileTitle`,{name:e?.displayName??``})}),(0,F.jsxs)(Db,{children:[(0,F.jsx)(OD,{error:o.error??l.error??u.error??m.error}),o.isLoading?(0,F.jsx)(kD,{}):(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:2,children:[x(`percent`,n(`admin.profile.percent`)),x(`weeklyHours`,n(`admin.profile.weeklyHours`),`0.5`)]}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n(`admin.profile.workdays`)}),(0,F.jsx)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`,flexWrap:`wrap`},children:v.map((e,t)=>(0,F.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`},children:[(0,F.jsx)(_y,{size:`small`,checked:b[t]===`1`,onChange:()=>{let e=b.slice();e[t]=e[t]===`1`?`0`:`1`,h({workdays:e.join(`;`)})}}),(0,F.jsx)(Y,{variant:`body2`,children:e})]},`${e}-${t}`))})]}),(0,F.jsx)(Q,{select:!0,fullWidth:!0,size:`small`,label:n(`admin.profile.overtimeModel`),value:g?.overtimeModel??`monthly`,onChange:e=>h({overtimeModel:e.target.value}),children:[`monthly`,`yearly`,`cumulative`].map(e=>(0,F.jsx)(iC,{value:e,children:n(`admin.profile.model.${e}`)},e))}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(ex,{control:(0,F.jsx)(dw,{checked:g?.showWorkedTime===!0,onChange:e=>h({showWorkedTime:e.target.checked})}),label:n(`admin.user.workedTime`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n(`admin.user.workedTimeHint`)})]}),(0,F.jsxs)(Z,{direction:`row`,spacing:2,children:[x(`vacationPerYear`,n(`admin.profile.vacationPerYear`),`0.5`),x(`vacationCarryover`,n(`admin.profile.vacationCarryover`),`0.5`)]}),(0,F.jsxs)(Z,{direction:`row`,spacing:2,children:[(0,F.jsx)(Q,{fullWidth:!0,size:`small`,type:`number`,label:n(`admin.profile.overtimeCarryover`),value:String(_(g?.overtimeCarryover??0)),onChange:e=>h({overtimeCarryover:Math.round(Number(e.target.value)*60)})}),(0,F.jsx)(Q,{fullWidth:!0,size:`small`,type:`number`,label:n(`admin.profile.vorholzeitPerYear`),value:String(_(g?.vorholzeitPerYear??0)),onChange:e=>h({vorholzeitPerYear:Math.round(Number(e.target.value)*60)})})]}),(0,F.jsx)(Q,{fullWidth:!0,size:`small`,type:`number`,label:n(`admin.profile.pausePaid`),helperText:n(`admin.profile.pausePaidHint`),value:String(g?.pausePaidMinutes??0),onChange:e=>h({pausePaidMinutes:Math.max(0,Math.round(Number(e.target.value)))})}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n(`admin.profile.pauseRules`)}),(0,F.jsx)(Y,{variant:`caption`,color:`text.secondary`,display:`block`,sx:{mb:1},children:n(`admin.profile.pauseRulesHint`)}),(0,F.jsx)(JO,{rules:p,disabled:!1,saving:m.isPending,onChange:f,onSave:()=>m.mutate(p)})]})]})]}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:t,children:n(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:l.isPending||Object.keys(s).length===0,onClick:()=>l.mutate(s),children:n(`common.save`)})]})]})}function XO({language:e}){let{t}=wE(),{session:n,permissions:r}=pD(),i=Tc(),a=mD(r,`user.edit`),o=mD(r,`user.create`),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(null),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(!1),w=mD(r,`user.manage_roles`),T=n?.user.id??0,E=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users(!0)}),D=(E.data??[]).filter(e=>e.isActive&&e.roles.includes(`admin`)),O=async()=>{await i.invalidateQueries({queryKey:[`admin`,`users`]})},k=ql({mutationFn:({id:e,patch:t})=>$.updateUser(e,t),onSuccess:O}),A=ql({mutationFn:({id:e,value:t})=>$.setPin(e,t),onSuccess:async()=>{u(null),f(``),await O()}}),j=ql({mutationFn:({id:e,value:t})=>$.updateUser(e,{avatar:t}),onSuccess:async()=>{m(null),g(null),await O()}});return E.isLoading?(0,F.jsx)(kD,{}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:E.error??k.error??A.error??j.error}),o&&(0,F.jsx)(Ev,{sx:{mb:2},children:(0,F.jsx)(X,{variant:`contained`,startIcon:(0,F.jsx)(pO,{}),onClick:()=>c(!0),children:t(`admin.user.create`)})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(E.data??[]).map(e=>(0,F.jsx)(ED,{primary:`${e.displayName} (${e.login})`,secondary:(0,F.jsxs)(Z,{direction:`row`,spacing:.5,sx:{mt:.5},children:[e.roles.map(e=>(0,F.jsx)(u_,{size:`small`,label:t(`role.${e}`,e)},e)),!e.isActive&&(0,F.jsx)(u_,{size:`small`,color:`default`,label:t(`admin.user.inactive`)})]}),children:a&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(fO,{}),onClick:()=>{u(e),f(``)},children:t(`admin.user.pin`)}),(0,F.jsx)(X,{size:`small`,onClick:()=>{m(e),g(null)},children:t(`admin.user.photo`)}),(0,F.jsx)(X,{size:`small`,onClick:()=>x(e),children:t(`admin.user.profile`)}),w&&(0,F.jsx)(X,{size:`small`,onClick:()=>v(e),children:t(`admin.user.roles`)}),(0,F.jsx)(dw,{checked:e.isActive,title:t(e.isActive?`admin.user.active`:`admin.user.inactive`),onChange:()=>{if(e.id===T&&e.isActive){C(!0);return}k.mutate({id:e.id,patch:{isActive:!e.isActive}})}})]})},e.id)),(E.data??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.user.empty`)})})]})}),(0,F.jsx)(YO,{user:b,onClose:()=>x(null)}),(0,F.jsxs)(hb,{open:l!==null,onClose:()=>u(null),children:[(0,F.jsx)(Ib,{children:t(`admin.user.pinTitle`,{name:l?.displayName??``})}),(0,F.jsx)(Db,{children:(0,F.jsx)(Q,{autoFocus:!0,fullWidth:!0,inputMode:`numeric`,label:t(`admin.user.newPin`),helperText:t(`admin.user.pinHint`),value:d,onChange:e=>f(e.target.value.replace(/\D/g,``).slice(0,8)),sx:{mt:1}})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>u(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:d.length<4||A.isPending,onClick:()=>l&&A.mutate({id:l.id,value:d}),children:t(`common.save`)})]})]}),(0,F.jsxs)(hb,{open:p!==null,onClose:()=>m(null),children:[(0,F.jsx)(Ib,{children:t(`admin.user.photoTitle`,{name:p?.displayName??``})}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(`img`,{src:h??p?.avatarUrl??`/person.png`,alt:``,width:96,height:96,style:{objectFit:`cover`,borderRadius:8}}),(0,F.jsx)(ck,{label:t(`admin.user.photoChoose`),maxBytes:MD,hint:t(`admin.user.photoHint`),onChange:e=>g(e)})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>m(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{disabled:p?.avatarUrl===null||p?.avatarUrl===void 0,onClick:()=>p&&j.mutate({id:p.id,value:null}),children:t(`admin.user.photoRemove`)}),(0,F.jsx)(X,{variant:`contained`,disabled:h===null||j.isPending,onClick:()=>p&&j.mutate({id:p.id,value:h}),children:t(`common.save`)})]})]}),_&&(0,F.jsx)(tk,{user:_,isSelf:_.id===T,lastAdministrator:D.length===1&&_.roles.includes(`admin`),onClose:()=>v(null),onSaved:e=>{k.mutate({id:_.id,patch:{roleKeys:e}}),v(null)}}),(0,F.jsxs)(hb,{open:S,onClose:()=>C(!1),children:[(0,F.jsx)(Ib,{children:t(`admin.user.selfTitle`)}),(0,F.jsx)(Db,{children:(0,F.jsx)(Mb,{children:t(`admin.user.selfDeactivate`)})}),(0,F.jsx)(bb,{children:(0,F.jsx)(X,{variant:`contained`,onClick:()=>C(!1),children:t(`common.close`)})})]}),s&&(0,F.jsx)(KO,{language:e,onClose:()=>c(!1),onCreated:async()=>{c(!1),await O()}})]})}function ZO({onClose:e,onCreated:t}){let{t:n}=wE(),r=Kl({queryKey:[`admin`,`users`,`active`],queryFn:()=>$.users(!1)}),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)([]),f=ql({mutationFn:()=>$.createTerminal({name:i.trim(),...o.trim()?{location:o.trim()}:{},pinRequired:c,userIds:u}),onSuccess:t});return(0,F.jsxs)(hb,{open:!0,onClose:e,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:n(`admin.terminal.create`)}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(Q,{label:n(`admin.terminal.name`),value:i,onChange:e=>a(e.target.value),fullWidth:!0,autoFocus:!0}),(0,F.jsx)(Q,{label:n(`admin.terminal.location`),value:o,onChange:e=>s(e.target.value),fullWidth:!0}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,children:[(0,F.jsx)(dw,{checked:c,onChange:(e,t)=>l(t)}),(0,F.jsx)(Y,{children:n(`admin.terminal.pinRequired`)})]}),(0,F.jsx)(Y,{variant:`subtitle2`,children:n(`admin.terminal.users`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n(`admin.terminal.usersHint`)}),(0,F.jsx)(QO,{users:r.data??[],chosen:u,onChange:d}),(0,F.jsx)(OD,{error:f.error})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:e,children:n(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:i.trim().length===0||f.isPending,onClick:()=>f.mutate(),children:n(`admin.terminal.create`)})]})]})}function QO({users:e,chosen:t,onChange:n}){return(0,F.jsx)(Ev,{sx:{maxHeight:240,overflowY:`auto`},children:(0,F.jsx)(Z,{spacing:.5,children:e.map(e=>(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,F.jsx)(dw,{checked:t.includes(e.id),inputProps:{"aria-label":e.displayName},onChange:(r,i)=>n(i?[...new Set([...t,e.id])]:t.filter(t=>t!==e.id))}),(0,F.jsx)(Y,{children:e.displayName})]},e.id))})})}function $O({terminal:e,onClose:t,onSaved:n}){let{t:r}=wE(),i=Kl({queryKey:[`admin`,`users`,`active`],queryFn:()=>$.users(!1)}),[a,o]=(0,y.useState)(e.userIds),s=ql({mutationFn:()=>$.setTerminalUsers(e.id,a),onSuccess:n});return(0,F.jsxs)(hb,{open:!0,onClose:t,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:`${r(`admin.terminal.users`)} · ${e.name}`}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:1,sx:{mt:1},children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:r(`admin.terminal.usersHint`)}),(0,F.jsx)(QO,{users:i.data??[],chosen:a,onChange:o}),(0,F.jsx)(OD,{error:i.error??s.error})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:t,children:r(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:s.isPending,onClick:()=>s.mutate(),children:r(`common.save`)})]})]})}function ek({language:e}){let{t}=wE(),n=Tc(),r=Kl({queryKey:[`admin`,`terminals`],queryFn:()=>$.terminals()}),i=Kl({queryKey:[`admin`,`users`,`active`],queryFn:()=>$.users(!1)}),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),p=ql({mutationFn:e=>$.revokeTerminal(e),onSuccess:async()=>{c(null),await n.invalidateQueries({queryKey:[`admin`,`terminals`]})}}),m=d?`${window.location.origin}/terminal?token=${encodeURIComponent(d.deviceToken)}`:``,h=d?`${window.location.origin}/presence?token=${encodeURIComponent(d.deviceToken)}`:``,g=`${t(`common.none`)}`,_=n=>{let r=n.userIds.length===0?t(`admin.terminal.usersAll`):(i.data??[]).filter(e=>n.userIds.includes(e.id)).map(e=>e.displayName).join(`, `)||t(`admin.terminal.usersAll`);return[n.location||g,qO(n.createdAt,e),r].join(` · `)};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:r.error??p.error}),d&&(0,F.jsxs)(jm,{severity:`success`,sx:{mb:2},children:[(0,F.jsx)(Y,{variant:`body2`,gutterBottom:!0,children:t(`admin.terminal.tokenOnce`)}),(0,F.jsx)(Y,{variant:`body2`,sx:{fontFamily:`monospace`,wordBreak:`break-all`},gutterBottom:!0,children:d.deviceToken}),(0,F.jsx)(Y,{variant:`body2`,gutterBottom:!0,children:t(`admin.terminal.url`)}),(0,F.jsx)(Y,{variant:`body2`,sx:{fontFamily:`monospace`,wordBreak:`break-all`},children:m}),(0,F.jsxs)(Y,{variant:`body2`,sx:{mt:1},children:[t(`presence.title`),`:`]}),(0,F.jsx)(Y,{variant:`body2`,sx:{fontFamily:`monospace`,wordBreak:`break-all`},children:h})]}),(0,F.jsx)(Ev,{sx:{mb:2},children:(0,F.jsx)(X,{variant:`contained`,startIcon:(0,F.jsx)(mO,{}),disabled:a,onClick:()=>o(!0),children:t(`admin.terminal.create`)})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(r.data??[]).map(e=>(0,F.jsx)(ED,{primary:(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,sx:{flexWrap:`wrap`,gap:1},children:[(0,F.jsx)(Y,{children:e.name}),e.pinRequired&&(0,F.jsx)(u_,{size:`small`,label:t(`admin.terminal.pinRequired`)}),!e.isActive&&(0,F.jsx)(u_,{size:`small`,variant:`outlined`,label:t(`admin.terminal.revoked`)})]}),secondary:_(e),children:e.isActive&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(X,{size:`small`,onClick:()=>u(e),children:t(`admin.terminal.users`)}),(0,F.jsx)(X,{size:`small`,color:`error`,onClick:()=>c(e),children:t(`admin.terminal.revoke`)})]})},e.id)),r.isLoading&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`common.loading`)})}),!r.isLoading&&(r.data??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.terminal.empty`)})})]})}),l&&(0,F.jsx)($O,{terminal:l,onClose:()=>u(null),onSaved:async()=>{u(null),await n.invalidateQueries({queryKey:[`admin`,`terminals`]})}}),a&&(0,F.jsx)(ZO,{onClose:()=>o(!1),onCreated:async e=>{o(!1),f(e),await n.invalidateQueries({queryKey:[`admin`,`terminals`]})}}),s&&(0,F.jsxs)(hb,{open:!0,onClose:()=>c(null),children:[(0,F.jsx)(Ib,{children:t(`admin.terminal.revoke`)}),(0,F.jsx)(Db,{children:t(`admin.terminal.confirmRevoke`,{name:s.name})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>c(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{color:`error`,variant:`contained`,disabled:p.isPending,onClick:()=>p.mutate(s.id),children:t(`admin.terminal.revoke`)})]})]})]})}function tk({user:e,isSelf:t,lastAdministrator:n,onClose:r,onSaved:i}){let{t:a}=wE(),o=Kl({queryKey:[`admin`,`roles`],queryFn:()=>$.roles()}),[s,c]=(0,y.useState)(e.roles),l=e.roles.includes(`admin`)&&!s.includes(`admin`),u=(e,t)=>c(n=>t?[...new Set([...n,e])]:n.filter(t=>t!==e));return(0,F.jsxs)(hb,{open:!0,onClose:r,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:a(`admin.user.roles`)}),(0,F.jsxs)(Db,{children:[t&&l&&(0,F.jsx)(jm,{"data-testid":`roles-warning`,severity:n?`info`:`warning`,sx:{mt:1},children:a(n?`admin.user.lastAdminRoles`:`admin.user.selfRoles`)}),(0,F.jsx)(Z,{spacing:1,sx:{mt:1},children:(o.data??[]).map(e=>(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,children:[(0,F.jsx)(dw,{checked:s.includes(e.key),inputProps:{"aria-label":a(`role.${e.key}`,e.name)},onChange:(t,n)=>u(e.key,n)}),(0,F.jsx)(Y,{children:a(`role.${e.key}`,e.name)})]},e.key))})]}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:r,children:a(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:s.length===0||n&&l,onClick:()=>i(s),children:a(`common.save`)})]})]})}function nk({language:e}){let{t}=wE(),n=Tc(),[r,i]=(0,y.useState)(String(new Date().getFullYear())),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(``),d=Kl({queryKey:[`admin`,`holidays`,r],queryFn:()=>$.holidays(Number(r))}),f=async()=>{await n.invalidateQueries({queryKey:[`admin`,`holidays`,r]})},p=ql({mutationFn:()=>$.createHoliday({date:a.trim(),name:s.trim(),...l.trim()?{region:l.trim()}:{}}),onSuccess:async()=>{o(``),c(``),u(``),await f()}}),m=ql({mutationFn:e=>$.deleteHoliday(e),onSuccess:f}),h=/^\d{4}-\d{2}-\d{2}$/.test(a.trim())&&s.trim().length>0;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:d.error??p.error??m.error}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,sx:{mt:1},children:[(0,F.jsx)(Q,{label:t(`admin.holiday.year`),value:r,onChange:e=>i(e.target.value.replace(/\D/g,``).slice(0,4)),sx:{width:140}}),(0,F.jsx)(Q,{label:t(`admin.holiday.date`),value:a,onChange:e=>o(e.target.value)}),(0,F.jsx)(Q,{label:t(`admin.holiday.name`),value:s,onChange:e=>c(e.target.value),fullWidth:!0}),(0,F.jsx)(Q,{label:t(`admin.holiday.region`),value:l,onChange:e=>u(e.target.value),sx:{width:200}})]}),(0,F.jsx)(Ev,{sx:{mt:2},children:(0,F.jsx)(X,{variant:`contained`,disabled:!h||p.isPending,onClick:()=>p.mutate(),children:t(`admin.holiday.add`)})})]})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(d.data??[]).map(n=>(0,F.jsx)(ED,{primary:`${ME(n.date,e)} · ${n.key?t(`holiday.${n.key}`,{defaultValue:n.name}):n.name}`,secondary:n.region??t(`common.none`),children:(0,F.jsx)(X,{size:`small`,color:`error`,onClick:()=>m.mutate(n.id),children:t(`admin.tag.delete`)})},n.id)),!d.isLoading&&(d.data??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.holiday.empty`)})})]})})]})}function rk({tag:e,onClose:t,onSaved:n}){let{t:r}=wE(),i=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users()}),[a,o]=(0,y.useState)(e.userId===null?``:String(e.userId)),[s,c]=(0,y.useState)(e.label??``),[l,u]=(0,y.useState)(``),d=l.trim()===``?void 0:Number(l),f=!a||d!==void 0&&(!Number.isInteger(d)||d<=0),p=ql({mutationFn:()=>$.updateTag(e.id,{userId:Number(a),label:s.trim()?s.trim():null,...d===void 0?{}:{ttlDays:d}}),onSuccess:n}),m=ql({mutationFn:()=>$.reissueTagLink(e.id),onSuccess:n});return(0,F.jsxs)(hb,{open:!0,onClose:t,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:`${r(`admin.tag.editTitle`)} · ${e.label??e.uid}`}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:r(`admin.tag.editHint`)}),(0,F.jsx)(Q,{select:!0,label:r(`admin.tag.user`),value:a,onChange:e=>o(e.target.value),children:(i.data??[]).map(e=>(0,F.jsx)(iC,{value:String(e.id),children:`${e.displayName} (${e.login})`},e.id))}),(0,F.jsx)(Q,{label:r(`admin.tag.label`),value:s,onChange:e=>c(e.target.value)}),(0,F.jsx)(Q,{label:r(`admin.tag.validityDays`),type:`number`,value:l,onChange:e=>u(e.target.value)}),(0,F.jsx)(OD,{error:i.error??p.error??m.error})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>m.mutate(),disabled:m.isPending,sx:{mr:`auto`},children:r(`admin.tag.reissue`)}),(0,F.jsx)(X,{onClick:t,children:r(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:f||p.isPending,onClick:()=>p.mutate(),children:r(`common.save`)})]})]})}function ik({language:e}){let{t}=wE(),n=Tc(),r=Kl({queryKey:[`admin`,`tags`],queryFn:()=>$.rfidTags()}),i=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users()}),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),h=async()=>{await n.invalidateQueries({queryKey:[`admin`,`tags`]})},g=e=>`${window.location.origin}/?tag=${e}`,_=(e,t)=>{u({token:e,url:g(e),reissued:t})};(0,y.useEffect)(()=>{if(!l){f(null);return}let e=!1;return HO.toDataURL(l.url,{margin:1,width:240}).then(t=>{e||f(t)}).catch(()=>{e||f(null)}),()=>{e=!0}},[l]);let v=ql({mutationFn:()=>$.createTag({userId:Number(a),...s.trim()?{label:s.trim()}:{}}),onSuccess:async e=>{_(e.token,!1),c(``),await h()}}),b=ql({mutationFn:e=>$.deleteTag(e),onSuccess:h}),x=ql({mutationFn:e=>$.deleteTagPermanently(e),onSuccess:h}),S=e=>(i.data??[]).find(t=>t.id===e)?.displayName??`#${e}`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:r.error??v.error??b.error??x.error}),l&&(0,F.jsxs)(jm,{severity:`success`,sx:{mb:2},children:[(0,F.jsx)(Y,{variant:`body2`,gutterBottom:!0,children:t(`admin.tag.linkOnce`)}),(0,F.jsx)(Y,{variant:`body2`,sx:{fontFamily:`monospace`,wordBreak:`break-all`},children:l.url}),d&&(0,F.jsx)(Ev,{sx:{mt:1.5},children:(0,F.jsx)(`img`,{src:d,alt:t(`admin.tag.qrAlt`),width:200,height:200,style:{display:`block`,borderRadius:4}})}),l.reissued&&(0,F.jsx)(Y,{variant:`body2`,sx:{mt:1},children:t(`admin.tag.oldLinkDead`)})]}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsx)($v,{children:(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,sx:{mt:1},children:[(0,F.jsx)(Q,{select:!0,label:t(`admin.tag.user`),value:a,onChange:e=>o(e.target.value),sx:{minWidth:220},children:(i.data??[]).map(e=>(0,F.jsx)(iC,{value:String(e.id),children:`${e.displayName} (${e.login})`},e.id))}),(0,F.jsx)(Q,{label:t(`admin.tag.label`),value:s,onChange:e=>c(e.target.value),fullWidth:!0}),(0,F.jsx)(X,{variant:`contained`,disabled:!a||v.isPending,onClick:()=>v.mutate(),children:t(`admin.tag.create`)})]})})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(r.data??[]).map(n=>{let r=n.expiresAt!==null&&n.expiresAt*1e3<Date.now(),i=n.isActive===!1?t(`admin.tag.revoked`):t(r?`admin.tag.expired`:`admin.tag.active`),a=n.expiresAt?qO(n.expiresAt,e):t(`common.none`),o=n.lastUsedAt?qO(n.lastUsedAt,e):t(`common.none`);return(0,F.jsxs)(ED,{primary:`${n.label??n.uid??`#${n.id}`} · ${S(n.userId)}`,secondary:`${i} · ${t(`admin.tag.lastUsed`)}: ${o} · ${n.uid??t(`common.none`)} · ${a}`,children:[(0,F.jsx)(X,{size:`small`,onClick:()=>m(n),children:t(`admin.tag.edit`)}),n.isActive!==!1&&(0,F.jsx)(X,{size:`small`,color:`error`,onClick:()=>b.mutate(n.id),children:t(`admin.tag.delete`)}),n.isActive===!1&&(0,F.jsx)(X,{size:`small`,color:`error`,onClick:()=>x.mutate(n.id),children:t(`admin.tag.remove`)})]},n.id)}),!r.isLoading&&(r.data??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.tag.empty`)})})]})}),p&&(0,F.jsx)(rk,{tag:p,onClose:()=>m(null),onSaved:async e=>{m(null),e.token&&_(e.token,!0),await h()}})]})}function ak({language:e}){let{t}=wE(),{permissions:n}=pD(),r=mD(n,`settings.edit`),i=Tc(),a=Kl({queryKey:[`admin`,`triggerRules`],queryFn:()=>$.triggerRules()}),o=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users()}),[s,c]=(0,y.useState)(null),l=s??a.data??[],u=ql({mutationFn:e=>$.saveTriggerRules(e),onSuccess:async()=>{c(null),await i.invalidateQueries({queryKey:[`admin`,`triggerRules`]})}}),d=(e,t)=>c(l.map((n,r)=>r===e?{...n,...t}:n)),f=n=>n.lastFiredAt?`${t(`admin.trigger.lastFired`)}: ${qO(n.lastFiredAt,e)}`:t(`common.none`);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:a.error??u.error}),u.isSuccess&&(0,F.jsx)(jm,{severity:`success`,sx:{mb:2},children:t(`admin.settings.saved`)}),(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:t(`admin.triggers`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:t(`admin.triggersHint`)}),(0,F.jsxs)(Z,{spacing:2,children:[l.map((e,n)=>(0,F.jsxs)(Z,{spacing:1,sx:{border:1,borderColor:`divider`,borderRadius:1,p:1},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(Q,{size:`small`,label:t(`admin.trigger.label`),value:e.label??``,onChange:e=>d(n,{label:e.target.value}),disabled:!r,sx:{minWidth:160}}),(0,F.jsx)(Q,{size:`small`,label:t(`admin.trigger.sourceState`),value:e.sourceState,onChange:e=>d(n,{sourceState:e.target.value}),disabled:!r,sx:{minWidth:260}}),(0,F.jsxs)(Q,{select:!0,size:`small`,label:t(`admin.trigger.mode`),value:e.mode??`condition`,onChange:e=>d(n,{mode:e.target.value}),disabled:!r,sx:{minWidth:200},children:[(0,F.jsx)(iC,{value:`condition`,children:t(`admin.trigger.modeCondition`)}),(0,F.jsx)(iC,{value:`user`,children:t(`admin.trigger.modeUser`)})]}),(e.mode??`condition`)===`condition`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Q,{size:`small`,label:t(`admin.trigger.condition`),helperText:t(`admin.trigger.conditionHint`),value:e.condition??``,onChange:e=>d(n,{condition:e.target.value}),disabled:!r,sx:{minWidth:170}}),(0,F.jsx)(Q,{select:!0,size:`small`,label:t(`admin.trigger.user`),value:e.userId===null||e.userId===void 0?``:String(e.userId),onChange:e=>d(n,{userId:e.target.value===``?null:Number(e.target.value)}),disabled:!r,sx:{minWidth:190},children:(o.data??[]).map(e=>(0,F.jsx)(iC,{value:String(e.id),children:e.displayName},e.id))})]}),(0,F.jsxs)(Q,{select:!0,size:`small`,label:t(`admin.trigger.action`),value:e.action??`punch`,onChange:e=>d(n,{action:e.target.value}),disabled:!r,sx:{minWidth:230},children:[(0,F.jsx)(iC,{value:`punch`,children:t(`admin.trigger.actionPunch`)}),(0,F.jsx)(iC,{value:`quickPunch`,children:t(`admin.trigger.actionQuickPunch`)}),(0,F.jsx)(iC,{value:`present`,children:t(`admin.trigger.actionPresent`)}),(0,F.jsx)(iC,{value:`absent`,children:t(`admin.trigger.actionAbsent`)})]}),(0,F.jsx)(Q,{size:`small`,type:`number`,label:t(`admin.trigger.cooldown`),value:String(e.cooldownSec??0),onChange:e=>d(n,{cooldownSec:Number(e.target.value)}),disabled:!r,sx:{maxWidth:140}}),(0,F.jsx)(dw,{checked:e.isActive!==!1,title:t(`admin.trigger.active`),onChange:()=>d(n,{isActive:e.isActive===!1}),disabled:!r}),(0,F.jsx)(vm,{size:`small`,title:t(`admin.tag.delete`),disabled:!r,onClick:()=>c(l.filter((e,t)=>t!==n)),children:(0,F.jsx)(zD,{fontSize:`small`})})]}),(0,F.jsx)(Y,{variant:`caption`,color:`text.secondary`,children:f(e)})]},e.id??`new-${n}`)),(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(UD,{}),disabled:!r,onClick:()=>c([...l,{sourceState:``,mode:`condition`,condition:`true`,action:`punch`,isActive:!0,cooldownSec:0}]),children:t(`admin.trigger.add`)}),(0,F.jsx)(X,{size:`small`,variant:`contained`,disabled:!r||u.isPending||s===null,onClick:()=>u.mutate(l),children:t(`common.save`)})]}),!a.isLoading&&l.length===0&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:t(`admin.trigger.empty`)})]})]})})]})}function ok({rules:e,runs:t,people:n,disabled:r,saving:i,onChange:a,onSave:o,language:s}){let{t:c}=wE(),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(!1),h=(t,n)=>{f(n?{...n}:{...e[t]}),m(n!==void 0),u(t)},g=e=>c(`admin.automation.kind${e.charAt(0).toUpperCase()}${e.slice(1)}`),_=e=>{let t=UO(s);return e.length>=7?c(`admin.automation.repeatDay`):e.map(e=>t.find(t=>t.value===e)?.label??String(e)).join(`, `)},v=e=>{let t=e.activeFrom?ME(e.activeFrom,s):``,n=e.activeUntil?ME(e.activeUntil,s):``;return t&&n?c(`admin.automation.validityRange`,{from:t,until:n}):t?c(`admin.automation.validityFrom`,{date:t}):n?c(`admin.automation.validityUntil`,{date:n}):``},b=(t,n)=>a(e.map((e,r)=>r===t?{...e,...n}:e)),x=()=>{l!==null&&d&&b(l,d),u(null),f(null)},S=e=>{let t=e??0;return`${String(Math.floor(t/60)).padStart(2,`0`)}:${String(t%60).padStart(2,`0`)}`},C=e=>{let t=/^(\d{1,2}):(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n>=0&&n<=23&&r>=0&&r<=59?n*60+r:null},w=e=>n.find(t=>t.id===e)?.displayName??`#${e}`;return(0,F.jsx)(Vv,{sx:{mb:2},"data-testid":`automation-rules`,children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:c(`admin.settings.automations`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:c(`admin.settings.automationsHint`)}),(0,F.jsxs)(Z,{spacing:1,children:[e.map((t,n)=>(0,F.jsxs)(ED,{primary:t.label?.trim()?t.label:g(t.kind),secondary:[g(t.kind),t.kind===`breakReminder`?`${c(`admin.automation.after`)} ${t.afterMinutes??360}`:S(t.atMinute),t.userId===null||t.userId===void 0?c(`admin.automation.allUsers`):w(t.userId),_(t.weekdays??[1,2,3,4,5,6,7]),c(t.repeat===`week`?`admin.automation.repeatWeek`:`admin.automation.repeatDay`),v(t)].filter(e=>e!==``).join(` · `),children:[(0,F.jsx)(X,{size:`small`,disabled:r,color:t.isActive===!1?`inherit`:`primary`,onClick:()=>b(n,{isActive:t.isActive===!1}),children:c(`admin.trigger.active`)}),(0,F.jsx)(X,{size:`small`,disabled:r,onClick:()=>h(n),children:c(`admin.automation.edit`)}),(0,F.jsx)(vm,{size:`small`,title:c(`admin.tag.delete`),disabled:r,onClick:()=>a(e.filter((e,t)=>t!==n)),children:(0,F.jsx)(zD,{fontSize:`small`})})]},t.id??`new-${n}`)),(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(UD,{}),disabled:r,onClick:()=>{let t={kind:`clockOut`,atMinute:1200,userId:null,weekdays:[1,2,3,4,5,6,7],repeat:`day`,isActive:!0,activeFrom:null,activeUntil:null};a([...e,t]),h(e.length,t)},children:c(`admin.automation.add`)}),(0,F.jsx)(X,{size:`small`,variant:`contained`,disabled:r||i,onClick:o,children:c(`admin.automation.save`)})]}),e.length===0&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:c(`admin.automation.empty`)})]}),(0,F.jsxs)(hb,{open:d!==null,onClose:()=>{u(null),f(null)},fullWidth:!0,maxWidth:`sm`,children:[(0,F.jsx)(Ib,{children:c(p?`admin.automation.newTitle`:`admin.automation.editTitle`)}),(0,F.jsx)(Db,{children:d&&(0,F.jsxs)(Z,{spacing:1.5,sx:{mt:1},children:[(0,F.jsx)(Q,{size:`small`,label:c(`admin.trigger.label`),value:d.label??``,onChange:e=>f({...d,label:e.target.value}),disabled:r,fullWidth:!0}),(0,F.jsxs)(Q,{select:!0,size:`small`,label:c(`admin.automation.kind`),value:d.kind,onChange:e=>f({...d,kind:e.target.value}),disabled:r,fullWidth:!0,children:[(0,F.jsx)(iC,{value:`clockIn`,children:c(`admin.automation.kindClockIn`)}),(0,F.jsx)(iC,{value:`clockOut`,children:c(`admin.automation.kindClockOut`)}),(0,F.jsx)(iC,{value:`missingPunch`,children:c(`admin.automation.kindMissingPunch`)}),(0,F.jsx)(iC,{value:`breakReminder`,children:c(`admin.automation.kindBreakReminder`)})]}),d.kind===`breakReminder`?(0,F.jsx)(Q,{size:`small`,type:`number`,label:c(`admin.automation.after`),value:String(d.afterMinutes??360),onChange:e=>f({...d,afterMinutes:Number(e.target.value)}),disabled:r,fullWidth:!0}):(0,F.jsx)(Q,{size:`small`,label:c(`admin.automation.at`),helperText:c(`admin.automation.atHint`),value:S(d.atMinute),onChange:e=>{let t=C(e.target.value);t!==null&&f({...d,atMinute:t})},disabled:r,fullWidth:!0}),(0,F.jsxs)(Q,{select:!0,size:`small`,label:c(`admin.automation.user`),value:d.userId===null||d.userId===void 0?``:String(d.userId),onChange:e=>f({...d,userId:e.target.value===``?null:Number(e.target.value)}),disabled:r,fullWidth:!0,children:[(0,F.jsx)(iC,{value:``,children:c(`admin.automation.allUsers`)}),n.map(e=>(0,F.jsx)(iC,{value:String(e.id),children:e.displayName},e.id))]}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:c(`admin.automation.weekdays`)}),(0,F.jsx)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:UO(s).map(e=>(0,F.jsx)(ex,{control:(0,F.jsx)(_y,{size:`small`,checked:d.weekdays?.includes(e.value)??!0,onChange:t=>f({...d,weekdays:WO(d.weekdays??[1,2,3,4,5,6,7],e.value,t.target.checked)}),disabled:r}),label:e.label},e.value))})]}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsxs)(Q,{select:!0,size:`small`,label:c(`admin.automation.repeat`),value:d.repeat??`day`,onChange:e=>f({...d,repeat:e.target.value}),disabled:r,sx:{minWidth:190},children:[(0,F.jsx)(iC,{value:`day`,children:c(`admin.automation.repeatDay`)}),(0,F.jsx)(iC,{value:`week`,children:c(`admin.automation.repeatWeek`)})]}),(0,F.jsx)(Q,{size:`small`,type:`date`,label:c(`admin.automation.validFrom`),helperText:c(`admin.automation.validFromHint`),value:d.activeFrom??``,onChange:e=>f({...d,activeFrom:e.target.value||null}),disabled:r,sx:{minWidth:200},InputLabelProps:{shrink:!0}}),(0,F.jsx)(Q,{size:`small`,type:`date`,label:c(`admin.automation.validUntil`),helperText:c(`admin.automation.validUntilHint`),value:d.activeUntil??``,onChange:e=>f({...d,activeUntil:e.target.value||null}),disabled:r,sx:{minWidth:200},InputLabelProps:{shrink:!0}}),(0,F.jsx)(X,{size:`small`,color:d.isActive===!1?`inherit`:`primary`,onClick:()=>f({...d,isActive:d.isActive===!1}),disabled:r,children:c(`admin.trigger.active`)})]})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>{u(null),f(null)},children:c(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,onClick:x,disabled:d===null,children:c(`common.save`)})]})]}),t.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Y,{variant:`subtitle2`,sx:{mt:2},children:c(`admin.automation.runs`)}),(0,F.jsx)(eS,{dense:!0,children:t.map((e,t)=>(0,F.jsx)(hS,{disableGutters:!0,children:(0,F.jsx)(SS,{primary:`${qO(e.firedAt,s)} · ${w(e.userId)}`,secondary:e.action})},`${e.ruleId}-${e.userId}-${e.period}-${t}`))})]})]})})}function sk(e){return e===`type`?`admin.brand.imageType`:e===`tooLarge`?`admin.brand.imageTooLarge`:`admin.brand.imageUnreadable`}function ck({label:e,maxBytes:t,hint:n,onChange:r,disabled:i}){let{t:a,i18n:o}=wE(),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(``);return(0,F.jsxs)(Z,{spacing:1,children:[(0,F.jsxs)(X,{variant:`outlined`,component:`label`,disabled:i===!0,sx:{alignSelf:`flex-start`},children:[e,(0,F.jsx)(`input`,{hidden:!0,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,onChange:e=>{let n=e.target.files?.[0];e.target.value=``,n&&(c(null),u(``),RD(n,t).then(e=>{if(!e.ok){c(e.problem);return}r(e.image.dataUrl),e.image.resized&&u(a(`admin.brand.imageResized`,{size:GO(e.image.bytes,o.language)}))}))}})]}),n&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n}),l&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:l}),s&&(0,F.jsx)(jm,{severity:`warning`,children:a(sk(s))})]})}function lk({label:e,value:t,maxBytes:n,onChange:r,disabled:i}){let{t:a}=wE();return(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,sx:{alignItems:{sm:`center`}},children:[(0,F.jsx)(ck,{label:e,maxBytes:n,onChange:r,disabled:i}),t!==``&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Ev,{component:`img`,src:t,alt:``,sx:{height:40,maxWidth:160,objectFit:`contain`,border:1,borderColor:`divider`}}),(0,F.jsx)(X,{color:`inherit`,title:a(`admin.settings.brandImageRemove`),disabled:i,onClick:()=>r(``),children:a(`admin.settings.brandImageRemove`)})]})]})}var uk={pause_mode:`admin.settings.pauseModeTitle`};function dk({settingKey:e,value:t,disabled:n,onChange:r,fullLine:i=!1}){let{t:a}=wE(),o=uk[e]??`admin.settings.setting.${e}`;return(0,F.jsx)(Q,{label:a(o,{defaultValue:e}),helperText:e,value:t,onChange:e=>r(e.target.value),disabled:n,size:`small`,fullWidth:!0,...i?{sx:{gridColumn:{xs:`auto`,md:`1 / -1`}}}:{}})}function fk({types:e,disabled:t,onSaved:n}){let{t:r}=wE(),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(null),f=ql({mutationFn:e=>$.saveAbsenceType({code:e.code.trim(),name:e.name.trim(),paid:e.paid,factor:e.factor,reduceVacation:e.reduceVacation,isActive:e.isActive,color:e.color??null}),onSuccess:()=>{a(null),n()},onError:e=>d(e.message)}),p=ql({mutationFn:e=>$.deleteAbsenceType(e.id),onSuccess:()=>{l(null),n()},onError:e=>d(e.message)}),m=e=>{d(null),s(e===void 0),a(e?{...e}:{id:0,userId:null,code:``,name:``,paid:!0,factor:100,reduceVacation:!1,isActive:!0})},h=e=>{let t=[e.paid?r(`admin.absenceTypes.paid`):`– ${r(`admin.absenceTypes.paid`)}`,`${r(`admin.absenceTypes.factor`)}: ${e.factor}`];return e.reduceVacation&&t.push(r(`admin.absenceTypes.reduceVacation`)),t.join(` · `)},g=(e,t)=>({...e,...t});return(0,F.jsxs)(Vv,{sx:{mb:2},children:[(0,F.jsxs)($v,{children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,F.jsx)(Y,{variant:`subtitle1`,sx:{flexGrow:1},children:r(`admin.absenceTypes.title`)}),(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(UD,{}),disabled:t,onClick:()=>m(),children:r(`admin.absenceTypes.add`)})]}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{mb:1},children:r(`admin.absenceTypes.hint`)}),(0,F.jsx)(eS,{dense:!0,"data-testid":`absence-types`,children:e.map(e=>(0,F.jsxs)(ED,{primary:`${e.code} – ${e.name}${e.reduceVacation?` (${r(`absences.vacationTag`)})`:``}`,secondary:(0,F.jsxs)(F.Fragment,{children:[h(e),e.isActive&&(0,F.jsx)(Y,{component:`span`,variant:`caption`,sx:{display:`block`},children:r(`admin.absenceTypes.active`)})]}),children:[(0,F.jsx)(`span`,{"data-testid":`absence-type-color-${e.id}`,style:{width:14,height:14,borderRadius:`50%`,marginRight:6,display:`inline-block`,background:e.color??`transparent`,border:e.color?`none`:`1px solid rgba(128,128,128,0.6)`}}),(0,F.jsx)(vm,{size:`small`,disabled:t,"aria-label":r(`admin.absenceTypes.edit`),onClick:()=>m(e),children:(0,F.jsx)(BD,{fontSize:`small`})}),(0,F.jsx)(vm,{size:`small`,disabled:t,"aria-label":r(`admin.absenceTypes.remove`),"data-testid":`absence-type-remove-${e.id}`,onClick:()=>{d(null),l(e)},children:(0,F.jsx)(zD,{fontSize:`small`})})]},e.id))}),e.length===0&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:r(`admin.absenceTypes.empty`)}),(0,F.jsx)(Y,{variant:`caption`,color:`text.secondary`,children:r(`admin.absenceTypes.note`)})]}),(0,F.jsxs)(hb,{open:i!==null,onClose:()=>a(null),fullWidth:!0,maxWidth:`xs`,children:[(0,F.jsx)(Ib,{children:r(o?`admin.absenceTypes.newTitle`:`admin.absenceTypes.editTitle`)}),(0,F.jsx)(Db,{children:i&&(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(OD,{error:u}),(0,F.jsx)(Q,{label:r(`admin.absenceTypes.code`),value:i.code,size:`small`,inputProps:{maxLength:8},onChange:e=>a(g(i,{code:e.target.value}))}),(0,F.jsx)(Q,{label:r(`admin.absenceTypes.name`),value:i.name,size:`small`,onChange:e=>a(g(i,{name:e.target.value}))}),(0,F.jsx)(Q,{label:r(`admin.absenceTypes.factor`),value:String(i.factor),size:`small`,type:`number`,inputProps:{min:0,max:100,step:10},onChange:e=>a(g(i,{factor:Number(e.target.value)}))}),(0,F.jsx)(ex,{control:(0,F.jsx)(dw,{checked:i.paid,onChange:e=>a(g(i,{paid:e.target.checked}))}),label:r(`admin.absenceTypes.paid`)}),(0,F.jsx)(ex,{control:(0,F.jsx)(dw,{checked:i.reduceVacation,onChange:e=>a(g(i,{reduceVacation:e.target.checked}))}),label:r(`admin.absenceTypes.reduceVacation`)}),(0,F.jsx)(ex,{control:(0,F.jsx)(dw,{checked:i.isActive,onChange:e=>a(g(i,{isActive:e.target.checked}))}),label:r(`admin.absenceTypes.active`)}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,F.jsx)(Y,{variant:`body2`,sx:{flexGrow:1},children:r(`admin.absenceTypes.color`)}),(0,F.jsx)(`input`,{type:`color`,"data-testid":`absence-type-color`,value:i.color??`#607d8b`,onChange:e=>a(g(i,{color:e.target.value}))}),(0,F.jsx)(X,{size:`small`,"data-testid":`absence-type-color-clear`,disabled:i.color===null,onClick:()=>a(g(i,{color:null})),children:r(`admin.absenceTypes.colorClear`)})]})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>a(null),children:r(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,"data-testid":`absence-type-save`,disabled:f.isPending||!i||i.code.trim()===``||i.name.trim()===``,onClick:()=>i&&f.mutate(i),children:r(`common.save`)})]})]}),(0,F.jsxs)(hb,{open:c!==null,onClose:()=>l(null),fullWidth:!0,maxWidth:`xs`,children:[(0,F.jsx)(Ib,{children:r(`admin.absenceTypes.removeTitle`)}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(OD,{error:u}),(0,F.jsx)(Mb,{children:c?r(`admin.absenceTypes.removeConfirm`,{name:`${c.code} – ${c.name}`}):``})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>l(null),children:r(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,color:`error`,"data-testid":`absence-type-remove-save`,disabled:p.isPending,onClick:()=>c&&p.mutate(c),children:r(`admin.absenceTypes.remove`)})]})]})]})}function pk(){let{t:e,i18n:t}=wE(),{permissions:n}=pD(),r=mD(n,`settings.edit`),i=Tc(),a=Kl({queryKey:[`admin`,`settings`],queryFn:()=>$.settings()}),o=Kl({queryKey:[`admin`,`pauseRules`],queryFn:()=>$.pauseRules()}),s=Kl({queryKey:[`branding`],queryFn:()=>$.branding()}),[c,l]=(0,y.useState)({}),[u,d]=(0,y.useState)(null),f=u??o.data??[],p=ql({mutationFn:e=>$.savePauseRules(e),onSuccess:async()=>{d(null),await i.invalidateQueries({queryKey:[`admin`,`pauseRules`]})}}),m=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users()}),h=Kl({queryKey:[`admin`,`automations`],queryFn:()=>$.automationRules()}),g=Kl({queryKey:[`admin`,`automationRuns`],queryFn:()=>$.automationRuns()}),_=Kl({queryKey:[`absence-types`,`all`],queryFn:()=>$.absenceTypes(!0)}),[v,b]=(0,y.useState)(null),x=v??h.data??[],S=ql({mutationFn:e=>$.saveAutomationRules(e),onSuccess:async()=>{b(null),await i.invalidateQueries({queryKey:[`admin`,`automations`]}),await i.invalidateQueries({queryKey:[`admin`,`automationRuns`]})}}),C=ql({mutationFn:e=>$.updateSettings(e),onSuccess:async()=>{l({}),await i.invalidateQueries({queryKey:[`admin`,`settings`]}),await i.invalidateQueries({queryKey:[`branding`]})}});if(a.isLoading)return(0,F.jsx)(kD,{});let w=a.data??{},T=c.brand_logo??s.data?.logoUrl??``,E=c.brand_background??s.data?.backgroundUrl??``,D=(e,t)=>l(n=>({...n,[e]:t}));return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:a.error??s.error??C.error??o.error??p.error}),C.isSuccess&&(0,F.jsx)(jm,{severity:`success`,sx:{mb:2},children:e(`admin.settings.saved`)}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`admin.settings.branding`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:e(`admin.settings.brandingHint`)}),(0,F.jsxs)(Z,{spacing:2,children:[(0,F.jsx)(lk,{label:e(`admin.settings.brandLogo`),value:T,maxBytes:jD,onChange:e=>D(`brand_logo`,e),disabled:!r}),(0,F.jsx)(lk,{label:e(`admin.settings.brandBackground`),value:E,maxBytes:jD,onChange:e=>D(`brand_background`,e),disabled:!r}),(0,F.jsxs)(Z,{direction:`row`,spacing:2,sx:{alignItems:`center`},children:[(0,F.jsx)(Q,{label:e(`admin.settings.brandColor`),helperText:e(`admin.settings.brandColorHint`),value:c.brand_color??w.brand_color??``,onChange:e=>D(`brand_color`,e.target.value),disabled:!r,sx:{maxWidth:260}}),(c.brand_color??w.brand_color??``)!==``&&(0,F.jsx)(Ev,{sx:{width:32,height:32,borderRadius:1,border:1,borderColor:`divider`,bgcolor:c.brand_color??w.brand_color??`transparent`}})]}),(0,F.jsxs)(Z,{spacing:1,children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`admin.settings.brandColorPresets`)}),(0,F.jsxs)(Z,{direction:`row`,sx:{flexWrap:`wrap`,gap:1,alignItems:`center`},children:[FE.map(e=>(0,F.jsx)(X,{"aria-label":e,title:e,disabled:!r,onClick:()=>D(`brand_color`,e),sx:{minWidth:40,width:40,height:40,p:0,borderRadius:1,border:2,borderColor:(c.brand_color??w.brand_color??``).toLowerCase()===e?`primary.main`:`divider`,bgcolor:e,"&:hover":{bgcolor:e}}},e)),(0,F.jsx)(X,{color:`inherit`,title:e(`admin.settings.brandColorDefaultHint`),disabled:!r,onClick:()=>{D(`brand_color`,``),D(`brand_background`,``)},children:e(`admin.settings.brandColorDefault`)})]})]})]})]})}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsx)($v,{children:(0,F.jsx)(Q,{label:e(`admin.settings.fontPath`),helperText:e(`admin.settings.fontPathHint`),value:c.report_font_path??w.report_font_path??``,onChange:e=>D(`report_font_path`,e.target.value),disabled:!r,fullWidth:!0})})}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`admin.settings.advanced`)}),(0,F.jsxs)(Ev,{sx:{display:`grid`,gap:2,gridTemplateColumns:{xs:`1fr`,sm:`repeat(2, minmax(0, 1fr))`,md:`repeat(3, minmax(0, 1fr))`}},children:[Object.keys(w).filter(e=>!e.startsWith(`brand_`)&&!e.endsWith(`timezone`)).sort().map(e=>(0,F.jsx)(dk,{settingKey:e,value:c[e]??w[e]??``,disabled:!r,onChange:t=>D(e,t)},e)),Object.keys(w).filter(e=>e.endsWith(`timezone`)).map(e=>(0,F.jsx)(dk,{settingKey:e,value:c[e]??w[e]??``,disabled:!r,onChange:t=>D(e,t),fullLine:!0},e))]})]})}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`admin.settings.pauseRules`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:e(`admin.settings.pauseRulesHint`)}),(0,F.jsx)(JO,{rules:f,disabled:!r,saving:p.isPending,onChange:d,onSave:()=>p.mutate(f)})]})}),(0,F.jsx)(ok,{rules:x,runs:g.data??[],people:m.data??[],disabled:!r,saving:S.isPending,onChange:b,onSave:()=>S.mutate(x),language:t.language}),(0,F.jsx)(fk,{types:_.data??[],disabled:!mD(n,`absence.manage_types`),onSaved:()=>void i.invalidateQueries({queryKey:[`absence-types`]})}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`admin.settings.pauseMode`)}),(0,F.jsx)(Q,{select:!0,fullWidth:!0,label:e(`admin.settings.pauseModeTitle`),helperText:e(`admin.settings.pauseModeHint`),value:c.pause_mode??w.pause_mode??`auto`,onChange:e=>D(`pause_mode`,e.target.value),disabled:!r,children:[`auto`,`punched`,`staffel`].map(t=>(0,F.jsx)(iC,{value:t,children:e(`admin.settings.pauseMode.${t}`)},t))})]})}),(0,F.jsx)(X,{variant:`contained`,disabled:!r||Object.keys(c).length===0||C.isPending,onClick:()=>C.mutate(c),children:e(`common.save`)})]})}function mk({language:e}){let{t}=wE(),n=Tc(),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(``),l=(0,y.useRef)(null),u=Kl({queryKey:[`admin`,`backups`],queryFn:()=>$.backups()}),d=ql({mutationFn:()=>$.createBackup(),onSuccess:async()=>{await n.invalidateQueries({queryKey:[`admin`,`backups`]})}}),f=ql({mutationFn:e=>$.restoreBackup(e,s.trim()||void 0),onSuccess:async()=>{i(null),c(``),await n.invalidateQueries({queryKey:[`admin`,`backups`]})}}),p=ql({mutationFn:e=>$.downloadBackup(e),onSuccess:e=>XD(e.blob,e.fileName)}),m=ql({mutationFn:e=>$.uploadBackup(e),onSuccess:async()=>{await n.invalidateQueries({queryKey:[`admin`,`backups`]})}}),h=ql({mutationFn:e=>$.deleteBackup(e),onSuccess:async()=>{o(null),await n.invalidateQueries({queryKey:[`admin`,`backups`]})}});if(u.isLoading)return(0,F.jsx)(kD,{});let g=u.data?.pending??null;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:u.error??d.error??f.error??p.error??m.error??h.error}),g&&(0,F.jsx)(jm,{severity:`warning`,sx:{mb:2},children:t(`admin.backup.pendingHint`,{name:g.name,users:g.users,entries:g.entries})}),d.isSuccess&&(0,F.jsx)(jm,{severity:`success`,sx:{mb:2},children:t(`admin.backup.done`,{name:d.data.backup.name,removed:d.data.removed.length})}),(0,F.jsxs)(Ev,{sx:{mb:2},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,flexWrap:`wrap`,useFlexGap:!0,children:[(0,F.jsx)(X,{variant:`contained`,startIcon:d.isPending?(0,F.jsx)(My,{size:18}):(0,F.jsx)(cO,{}),disabled:d.isPending,onClick:()=>d.mutate(),children:t(`admin.backup.create`)}),(0,F.jsx)(X,{variant:`outlined`,startIcon:m.isPending?(0,F.jsx)(My,{size:18}):(0,F.jsx)(dO,{}),disabled:m.isPending,onClick:()=>l.current?.click(),children:t(`admin.backup.upload`)}),(0,F.jsx)(`input`,{ref:l,type:`file`,accept:`.sqlite,application/octet-stream`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&m.mutate(t)}})]}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:t(`admin.backup.uploadHint`)})]}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(u.data?.backups??[]).map(n=>(0,F.jsxs)(hS,{children:[(0,F.jsx)(SS,{primary:n.name,secondary:`${qO(n.createdAt,e)} · ${GO(n.sizeBytes,e)}`}),(0,F.jsxs)(Z,{direction:`row`,spacing:.5,alignItems:`center`,children:[p.isPending&&p.variables===n.name&&(0,F.jsx)(My,{size:16}),(0,F.jsx)(vm,{size:`small`,title:t(`admin.backup.download`),disabled:p.isPending,onClick:()=>p.mutate(n.name),children:(0,F.jsx)(lO,{fontSize:`small`})}),(0,F.jsx)(vm,{size:`small`,title:t(`admin.backup.restore`),disabled:f.isPending,onClick:()=>i(n.name),children:(0,F.jsx)(uO,{fontSize:`small`})}),(0,F.jsx)(vm,{size:`small`,title:t(`admin.backup.delete`),disabled:h.isPending,onClick:()=>o(n.name),children:(0,F.jsx)(zD,{fontSize:`small`})})]})]},n.name)),(u.data?.backups??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.backup.empty`)})})]})}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{mt:2},children:t(`admin.backup.retention`,{days:u.data?.retentionDays??0})}),(0,F.jsxs)(hb,{open:r!==null,onClose:()=>i(null),children:[(0,F.jsx)(Ib,{children:t(`admin.backup.restoreTitle`)}),(0,F.jsxs)(Db,{children:[(0,F.jsx)(Mb,{sx:{mb:2},children:t(`admin.backup.restoreConfirm`,{name:r??``})}),(0,F.jsx)(Q,{fullWidth:!0,label:t(`corrections.reason`),helperText:t(`corrections.reasonHint`),value:s,onChange:e=>c(e.target.value)})]}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>i(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:f.isPending,onClick:()=>r&&f.mutate(r),children:t(`admin.backup.restore`)})]})]}),(0,F.jsxs)(hb,{open:a!==null,onClose:()=>o(null),children:[(0,F.jsx)(Ib,{children:t(`admin.backup.deleteTitle`)}),(0,F.jsx)(Db,{children:(0,F.jsx)(Mb,{children:t(`admin.backup.deleteConfirm`,{name:a??``})})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>o(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,color:`error`,disabled:h.isPending,onClick:()=>a&&h.mutate(a),children:t(`admin.backup.delete`)})]})]})]})}function hk(){let{t:e,i18n:t}=wE(),{permissions:n}=pD(),[r,i]=(0,y.useState)(0),a=[];if(mD(n,`user.view`)&&a.push({label:e(`admin.users`),render:()=>(0,F.jsx)(XO,{language:t.language})}),mD(n,`time.edit_other`)&&a.push({label:e(`admin.corrections`),render:()=>(0,F.jsx)(iO,{language:t.language})}),mD(n,`absence.approve`)&&a.push({label:e(`admin.absences.title`),render:()=>(0,F.jsx)(sO,{language:t.language})}),mD(n,`terminal.manage`)&&a.push({label:e(`admin.terminals`),render:()=>(0,F.jsx)(ek,{language:t.language})}),mD(n,`settings.view`)&&a.push({label:e(`admin.settings`),render:()=>(0,F.jsx)(pk,{})}),mD(n,`holiday.manage`)&&a.push({label:e(`admin.holidays`),render:()=>(0,F.jsx)(nk,{language:t.language})}),mD(n,`rfid.manage`)&&a.push({label:e(`admin.tags`),render:()=>(0,F.jsx)(ik,{language:t.language})}),mD(n,`settings.view`)&&a.push({label:e(`admin.triggers`),render:()=>(0,F.jsx)(ak,{language:t.language})}),mD(n,`backup.run`)&&a.push({label:e(`admin.backup`),render:()=>(0,F.jsx)(mk,{language:t.language})}),a.length===0)return(0,F.jsx)(TD,{title:e(`admin.title`),children:(0,F.jsx)(jm,{severity:`info`,children:e(`admin.forbidden`)})});let o=Math.min(r,a.length-1);return(0,F.jsxs)(TD,{title:e(`admin.title`),children:[(0,F.jsx)(Yw,{value:o,onChange:(e,t)=>i(t),variant:`scrollable`,scrollButtons:`auto`,allowScrollButtonsMobile:!0,sx:{mb:2},children:a.map(e=>(0,F.jsx)(_w,{label:e.label},e.label))}),a[o]?.render()]})}var gk=ep((0,F.jsx)(`path`,{d:`M11 7 9.6 8.4l2.6 2.6H2v2h10.2l-2.6 2.6L11 17l5-5zm9 12h-8v2h8c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-8v2h8z`}),`Login`),_k=ep((0,F.jsx)(`path`,{d:`m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z`}),`Logout`);function vk(){let{t:e,i18n:t}=wE(),{session:n,permissions:r}=pD(),{pending:i,record:a,outcome:o}=xD(),s=Tc(),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(!1),f=mD(r,`time.punch`),p=n?.user.timezone??`UTC`,m=Kl({queryKey:[`status`],queryFn:()=>$.status(),enabled:f});(0,y.useEffect)(()=>{o&&s.invalidateQueries({queryKey:[`status`]})},[o,s]);function h(e){a({tsUtc:Math.floor(Date.now()/1e3),...c?{note:c}:{},quick:e}),l(``),d(!0)}let g=m.data,_=g?.hasOpenEntry??!1;return f?(0,F.jsxs)(TD,{title:e(`nav.dashboard`),children:[(0,F.jsx)(OD,{error:m.error}),u&&i.length>0&&(0,F.jsx)(jm,{severity:`warning`,children:e(`punch.queued`)}),(0,F.jsx)(Vv,{sx:{mb:3},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,component:`p`,gutterBottom:!0,children:_?e(`punch.open`,{time:jE(g?.lastEntry?.tsUtc??null,p,t.language)}):e(`punch.closed`)}),g?.lastEntry&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:e(`punch.last`,{time:jE(g.lastEntry.tsUtc,p,t.language)})}),(0,F.jsxs)(Z,{spacing:2,sx:{mt:2},children:[(0,F.jsx)(Q,{label:e(`punch.note`),value:c,size:`small`,onChange:e=>l(e.target.value)}),(0,F.jsx)(X,{variant:`contained`,size:`large`,startIcon:g?.nextDirection===`out`?(0,F.jsx)(_k,{}):(0,F.jsx)(gk,{}),disabled:m.isLoading,onClick:()=>h(!1),children:g?.nextDirection===`out`?e(`punch.out`):e(`punch.in`)}),(0,F.jsx)(X,{variant:`outlined`,onClick:()=>h(!0),disabled:m.isLoading,children:e(`punch.quick`)})]})]})}),(0,F.jsxs)(Nx,{container:!0,spacing:2,children:[(0,F.jsx)(Nx,{item:!0,xs:12,sm:4,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`punch.worked`)}),(0,F.jsx)(Y,{variant:`h5`,children:AE(g?.day.workedMin??0)})]})})}),(0,F.jsx)(Nx,{item:!0,xs:12,sm:4,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`punch.target`)}),(0,F.jsx)(Y,{variant:`h5`,children:AE(g?.day.targetMin??0)})]})})}),(0,F.jsx)(Nx,{item:!0,xs:12,sm:4,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`punch.balance`)}),(0,F.jsx)(Y,{variant:`h5`,color:(g?.day.balanceMin??0)<0?`error`:`text.primary`,children:AE(g?.day.balanceMin??0)})]})})})]}),(0,F.jsx)(Ev,{sx:{mt:2},children:(0,F.jsx)(X,{variant:`text`,onClick:()=>void m.refetch(),disabled:m.isFetching,children:e(`common.refresh`)})})]}):(0,F.jsx)(TD,{title:e(`nav.dashboard`),children:(0,F.jsx)(Vv,{children:(0,F.jsx)($v,{children:(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`dashboard.adminOnly`)})})})})}function yk(){let{t:e}=wE(),{signIn:t}=pD(),n=zE(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1);async function d(e){e.preventDefault(),u(!0),c(null);try{await t(r.trim(),a)}catch(e){c(e)}finally{u(!1)}}return(0,F.jsx)(Ev,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,minHeight:`100vh`,p:2},children:(0,F.jsx)(Vv,{sx:{width:`100%`,maxWidth:420},children:(0,F.jsxs)($v,{children:[n.logoUrl&&(0,F.jsx)(Ev,{component:`img`,src:n.logoUrl,alt:``,sx:{display:`block`,maxHeight:64,maxWidth:`100%`,mb:2}}),(0,F.jsx)(Y,{variant:`h5`,component:`h1`,gutterBottom:!0,children:e(`app.title`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:e(`login.title`)}),(0,F.jsx)(Ev,{component:`form`,onSubmit:e=>void d(e),sx:{mt:2},children:(0,F.jsxs)(Z,{spacing:2,children:[(0,F.jsx)(Q,{label:e(`login.login`),value:r,autoComplete:`username`,autoFocus:!0,required:!0,onChange:e=>i(e.target.value)}),(0,F.jsx)(Q,{label:e(`login.password`),type:`password`,value:a,autoComplete:`current-password`,required:!0,onChange:e=>o(e.target.value)}),l?(0,F.jsx)(jm,{severity:`info`,children:e(`login.failed`)}):(0,F.jsx)(OD,{error:s}),(0,F.jsx)(X,{type:`submit`,variant:`contained`,size:`large`,disabled:l,children:e(`login.submit`)})]})})]})})})}function bk(){let{t:e}=wE(),{session:t,signOut:n}=pD(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1);async function d(){o(!0),c(null);try{await $.changePassword(r),u(!0);try{await n()}catch{}}catch(e){c(e)}finally{o(!1)}}return(0,F.jsx)(Ev,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,minHeight:`100vh`,p:2},children:(0,F.jsx)(Vv,{sx:{maxWidth:420,width:`100%`},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`profile.changePassword`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:t?.user.login}),l?(0,F.jsx)(jm,{severity:`success`,children:e(`profile.changed`)}):(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(Q,{type:`password`,label:e(`profile.newPassword`),helperText:e(`admin.user.passwordHint`),value:r,onChange:e=>i(e.target.value),autoComplete:`new-password`,fullWidth:!0}),(0,F.jsx)(OD,{error:s}),(0,F.jsx)(X,{variant:`contained`,disabled:a||r.length===0,onClick:()=>void d(),children:e(`profile.changePassword`)})]})]})})})}var xk=ep((0,F.jsx)(`path`,{d:`M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z`}),`Refresh`),Sk=ep([(0,F.jsx)(`path`,{d:`M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8`},`0`),(0,F.jsx)(`path`,{d:`M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z`},`1`)],`Schedule`);function Ck(e){return e instanceof DE&&e.status===401&&(e.code===`no_session`||e.code===`invalid_credentials`)}function wk(e){return $.terminalSession(e)}async function Tk(e){try{return await e.call(e.session)}catch(t){if(!Ck(t))throw t;let n=await wk(e.deviceToken);return e.onRenewed?.(n),e.call(n)}}var Ek=ep((0,F.jsx)(`path`,{d:`M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16H7.07L2.4 12l4.66-7H22zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z`}),`BackspaceOutlined`),Dk=[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,``,`0`];function Ok({onDigit:e,onBackspace:t,disabled:n=!1}){let{t:r}=wE(),i=e=>e.preventDefault();return(0,F.jsxs)(Ev,{sx:{display:`grid`,gridTemplateColumns:`repeat(3, 1fr)`,gap:1,width:`100%`,maxWidth:260},children:[Dk.map(t=>t===``?(0,F.jsx)(Ev,{},`blank`):(0,F.jsx)(X,{variant:`outlined`,size:`large`,disabled:n,"aria-label":t,onMouseDown:i,onClick:()=>e(t),sx:{minHeight:56,fontSize:`1.4rem`},children:t},t)),(0,F.jsx)(X,{variant:`outlined`,size:`large`,disabled:n,"aria-label":r(`keypad.backspace`),onMouseDown:i,onClick:t,sx:{minHeight:56},children:(0,F.jsx)(Ek,{})})]})}var kk=`time-tracker.presence`,Ak=2e4,jk=3e5,Mk=8e3;function Nk(){let e=new URLSearchParams(window.location.search).get(`token`);if(e?.trim()){try{window.localStorage.setItem(kk,e.trim())}catch{}return e.trim()}try{return window.localStorage.getItem(kk)}catch{return null}}function Pk(){let{t:e,i18n:t}=wE(),[n,r]=(0,y.useState)(()=>Nk()),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(`UTC`),[T,E]=(0,y.useState)(Math.floor(Date.now()/1e3)),D=(0,y.useRef)(0),O=zE(),k=(0,y.useCallback)(()=>{try{window.localStorage.removeItem(kk)}catch{}r(null)},[]);(0,y.useEffect)(()=>{(async()=>{try{let e=await $.terminalStatus();b(e.enabled),w(e.timezone),D.current=e.serverTime-Math.floor(Date.now()/1e3)}catch(e){_(e)}})()},[]),(0,y.useEffect)(()=>{let e=window.setInterval(()=>E(Math.floor(Date.now()/1e3)+D.current),1e3);return()=>window.clearInterval(e)},[]),(0,y.useEffect)(()=>{if(!n){s(null);return}(async()=>{try{let e=await $.terminalSession(n);s(e),_(null)}catch(e){s(null),_(e)}})()},[n]);let A=(0,y.useCallback)(async()=>{if(o&&n)try{let e=await Tk({deviceToken:n,session:o,call:e=>$.terminalUsers(e.terminalSession),onRenewed:s});l(e.users),_(null)}catch(e){_(e)}},[o,n]);(0,y.useEffect)(()=>{A();let e=window.setInterval(()=>void A(),Ak);return()=>window.clearInterval(e)},[A]),(0,y.useEffect)(()=>{if(!o||!n)return;let e=window.setInterval(()=>{$.terminalHeartbeat(o.terminalSession).catch(async()=>{try{s(await wk(n))}catch(e){_(e),k()}})},jk);return()=>window.clearInterval(e)},[o,n,k]),(0,y.useEffect)(()=>{if(!m)return;let e=window.setTimeout(()=>h(null),Mk);return()=>window.clearTimeout(e)},[m]);let j=(0,y.useCallback)(async()=>{let e=o?.terminal.pinRequired===!0;if(o&&n&&u&&(!e||f.length!==0)){S(!0);try{let e=await Tk({deviceToken:n,session:o,call:e=>$.terminalPunch({terminalSession:e.terminalSession,userId:u.id,...f?{pin:f}:{}}),onRenewed:s});h(e),l(t=>t.map(t=>t.id===e.user.id?{...t,present:e.day.hasOpenEntry,workedMin:e.day.workedMin??t.workedMin}:t)),d(null),p(``),_(null)}catch(e){_(e)}finally{S(!1)}}},[f,u,o,n]);return n?(0,F.jsxs)(Ev,{sx:{p:2},children:[(0,F.jsxs)(Z,{direction:`row`,justifyContent:`space-between`,alignItems:`baseline`,sx:{mb:2},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[O.logoUrl&&(0,F.jsx)(Ev,{component:`img`,src:O.logoUrl,alt:``,sx:{height:28,maxWidth:120,objectFit:`contain`}}),(0,F.jsx)(Y,{variant:`h5`,children:e(`presence.title`)})]}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,children:[(0,F.jsx)(Y,{variant:`h5`,children:jE(T,C,t.language)}),(0,F.jsx)(Y,{variant:`body1`,children:o?.terminal.name??``}),(0,F.jsx)(vm,{size:`small`,title:e(`common.refresh`),"aria-label":e(`common.refresh`),onClick:()=>void A(),children:(0,F.jsx)(xk,{fontSize:`small`})})]})]}),v===!1&&(0,F.jsx)(jm,{severity:`warning`,sx:{mb:2},children:e(`presence.disabled`)}),(0,F.jsx)(OD,{error:g}),m&&(0,F.jsx)(jm,{severity:`success`,sx:{mb:2},children:e(`presence.updated`,{name:m.user.displayName,state:e(m.day.hasOpenEntry?`presence.present`:`presence.absent`)})}),(0,F.jsx)(Ev,{sx:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(240px, 1fr))`,gap:1.5},children:c.map(t=>(0,F.jsx)(Vv,{variant:`outlined`,sx:{borderWidth:t.present?2:1,borderColor:t.present?`success.main`:`divider`,bgcolor:t.present?`success.light`:`background.paper`},children:(0,F.jsx)(Jv,{onClick:()=>{d(t),p(``)},children:(0,F.jsxs)(Z,{direction:`row`,spacing:1.5,alignItems:`center`,sx:{px:1.5,py:.5},children:[(0,F.jsx)(J_,{src:t.avatarUrl??`/person.png`,sx:{width:56,height:56,bgcolor:t.present?`success.main`:`grey.500`},children:Fk(t.displayName)}),(0,F.jsxs)(Ev,{sx:{minWidth:0,flexGrow:1},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:.5,sx:{alignItems:`center`},children:[(0,F.jsx)(u_,{size:`small`,color:t.present?`success`:`default`,label:e(t.present?`presence.present`:`presence.absent`)}),t.workedMin!==void 0&&(0,F.jsx)(u_,{size:`small`,variant:`outlined`,icon:(0,F.jsx)(Sk,{fontSize:`small`}),label:AE(t.workedMin),title:e(`presence.workedToday`)})]}),(0,F.jsx)(Y,{variant:`subtitle1`,noWrap:!0,sx:{lineHeight:1.3},children:t.displayName})]})]})})},t.id))}),u&&(0,F.jsx)(Vv,{sx:{mt:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:u.displayName}),(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,children:[o?.terminal.pinRequired===!1?(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{alignSelf:`center`},children:e(`terminal.noPin`)}):(0,F.jsx)(Q,{label:e(`terminal.pin`),type:`password`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()},helperText:e(`presence.tapPin`),autoFocus:!0,fullWidth:!0}),o?.terminal.pinRequired===!1?null:(0,F.jsx)(Ok,{onDigit:e=>p(t=>t+e),onBackspace:()=>p(e=>e.slice(0,-1)),disabled:x}),(0,F.jsx)(X,{variant:`contained`,size:`large`,disabled:x||o?.terminal.pinRequired===!0&&f.length===0,onClick:()=>void j(),children:e(`punch.now`)}),(0,F.jsx)(X,{variant:`text`,size:`large`,onClick:()=>{d(null),p(``)},children:e(`presence.cancel`)})]})]})})]}):(0,F.jsxs)(Ev,{sx:{p:2,maxWidth:480,mx:`auto`},children:[(0,F.jsx)(Y,{variant:`h5`,gutterBottom:!0,children:e(`presence.title`)}),(0,F.jsx)(OD,{error:g}),(0,F.jsx)(Q,{label:e(`terminal.deviceToken`),value:i,onChange:e=>a(e.target.value),fullWidth:!0,sx:{mt:1}}),(0,F.jsx)(X,{variant:`contained`,size:`large`,sx:{mt:2},disabled:i.trim().length===0,onClick:()=>r(i.trim()),children:e(`terminal.connect`)})]})}function Fk(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[t.length-1][0]}`.toUpperCase()}function Ik(){let{t:e,i18n:t}=wE(),{session:n,permissions:r}=pD(),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null);async function u(e){e.preventDefault(),l(null);try{await $.changePassword(i),s(!0),a(``)}catch(e){l(e)}}return(0,F.jsxs)(TD,{title:e(`profile.title`),children:[(0,F.jsx)(Vv,{sx:{mb:3},children:(0,F.jsx)($v,{children:(0,F.jsxs)(Z,{spacing:1,children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`profile.user`)}),(0,F.jsx)(Y,{variant:`h6`,children:n?.user.displayName??n?.user.login}),(0,F.jsxs)(Y,{variant:`body2`,color:`text.secondary`,children:[n?.user.login,` · `,n?.user.timezone]}),(0,F.jsx)(Q,{select:!0,label:e(`profile.language`),size:`small`,value:t.language,onChange:e=>void t.changeLanguage(e.target.value),sx:{maxWidth:240,mt:1},children:oD.map(e=>(0,F.jsx)(iC,{value:e,children:e},e))}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`profile.roles`)}),(0,F.jsx)(Y,{variant:`body2`,children:r.join(`, `)||e(`common.none`)})]})]})})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`profile.changePassword`)}),o&&(0,F.jsx)(jm,{severity:`success`,children:e(`profile.changed`)}),(0,F.jsx)(OD,{error:c}),(0,F.jsx)(Ev,{component:`form`,onSubmit:e=>void u(e),children:(0,F.jsxs)(Z,{spacing:2,children:[(0,F.jsx)(Q,{label:e(`profile.newPassword`),type:`password`,value:i,autoComplete:`new-password`,required:!0,size:`small`,onChange:e=>a(e.target.value)}),(0,F.jsx)(X,{type:`submit`,variant:`contained`,children:e(`profile.changePassword`)})]})})]})})]})}function Lk(){let{t:e,i18n:t}=wE(),[n,r]=(0,y.useState)(()=>new Date().getFullYear()),[i,a]=(0,y.useState)(void 0),{permissions:o,session:s}=pD(),c=mD(o,`payout.view`),l=mD(o,`report.view_other`)&&mD(o,`user.view`),u=Kl({queryKey:[`employees`],queryFn:()=>$.users(),enabled:l}),d=Kl({queryKey:[`months`,n,i],queryFn:()=>$.months(n,i)}),f=Kl({queryKey:[`payouts`,n],queryFn:()=>$.payouts(n),enabled:c&&i===void 0,retry:!1}),p=d.data?.months??[],m=i===void 0?``:(u.data??[]).find(e=>e.id===i)?.displayName??``,h=e=>new Intl.DateTimeFormat(t.language,{month:`long`,timeZone:`UTC`}).format(new Date(Date.UTC(n,e-1,15)));return(0,F.jsxs)(TD,{title:e(`reports.title`),children:[(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)(Z,{direction:`row`,alignItems:`center`,justifyContent:`space-between`,sx:{p:1},children:[(0,F.jsx)(vm,{onClick:()=>r(e=>e-1),title:e(`month.previous`),children:(0,F.jsx)(tT,{})}),(0,F.jsxs)(Y,{variant:`h6`,children:[e(`reports.year`),` `,n]}),(0,F.jsx)(vm,{onClick:()=>r(e=>e+1),title:e(`month.next`),children:(0,F.jsx)(nT,{})})]})}),l&&(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsx)($v,{children:(0,F.jsxs)(Q,{select:!0,fullWidth:!0,size:`small`,label:e(`statistics.employee`),value:i??``,onChange:e=>a(e.target.value===``?void 0:Number(e.target.value)),children:[(0,F.jsx)(iC,{value:``,children:s?.user.displayName??e(`profile.user`)}),(u.data??[]).filter(e=>e.isActive).map(e=>(0,F.jsx)(iC,{value:e.id,children:e.displayName},e.id))]})})}),(0,F.jsx)(OD,{error:d.error}),d.isLoading?(0,F.jsx)(kD,{}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(Nx,{container:!0,spacing:2,sx:{mb:2},children:[(0,F.jsx)(Nx,{item:!0,xs:6,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.yearTotals`)}),(0,F.jsx)(Y,{variant:`h5`,children:AE(d.data?.year.workedMin??0)}),(0,F.jsxs)(Y,{variant:`body2`,color:`text.secondary`,children:[e(`month.target`),`: `,AE(d.data?.year.targetMin??0)]})]})})}),(0,F.jsx)(Nx,{item:!0,xs:6,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.overtime`)}),(0,F.jsx)(Y,{variant:`h5`,color:(d.data?.year.overtimeMin??0)<0?`error`:`text.primary`,children:AE(d.data?.year.overtimeMin??0)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.vacation`,{used:d.data?.year.vacationUsed??0,total:(d.data?.year.vacationCarryover??0)+(d.data?.year.vacationDays??0)})}),c&&i===void 0&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.paidOut`,{minutes:AE(f.data?.totalMinutes??0)})})]})})})]}),(0,F.jsxs)(Vv,{children:[(0,F.jsx)(eS,{dense:!0,children:p.map((t,r)=>(0,F.jsxs)(hS,{sx:{"& .MuiListItemText-root":{minWidth:0}},children:[(0,F.jsx)(SS,{primary:i===void 0?h(r+1):(0,F.jsx)(Y,{component:Lf,to:`/month?year=${n}&month=${r+1}&userId=${i}&name=${encodeURIComponent(m)}`,title:e(`month.title`),sx:{color:`primary.main`,textDecoration:`none`,"&:hover":{textDecoration:`underline`}},children:h(r+1)}),secondary:t?`${e(`month.worked`)} ${AE(t.workedMin)} · ${e(`month.target`)} ${AE(t.targetMin)}`:e(`reports.empty`)}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,sx:{flexShrink:0},children:[(0,F.jsx)(Y,{variant:`body2`,color:(t?.balanceMin??0)<0?`error`:`text.secondary`,children:AE(t?.balanceMin??0)}),t&&(0,F.jsx)(ZD,{year:n,month:r+1,userId:i,compact:!0})]})]},r))}),p.length===0&&(0,F.jsx)(Ev,{sx:{p:2},children:(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.empty`)})})]})]})]})}function Rk(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-01`}function zk(){let e=new Date,t=new Date(e.getFullYear(),e.getMonth()+1,0);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Bk(e,t){return new Intl.NumberFormat(t,{style:`unit`,unit:`hour`,maximumFractionDigits:2}).format(e/60)}function Vk(){let{t:e,i18n:t}=wE(),[n,r]=(0,y.useState)(Rk),[i,a]=(0,y.useState)(zk),o=/^\d{4}-\d{2}-\d{2}$/.test(n)&&/^\d{4}-\d{2}-\d{2}$/.test(i)&&n<=i,s=Kl({queryKey:[`statistics`,n,i],queryFn:()=>$.statistics(n,i),enabled:o});if(s.isLoading)return(0,F.jsx)(TD,{title:e(`nav.statistics`),children:(0,F.jsx)(kD,{})});let c=(n,r,i,a)=>`${e(`statistics.worked`)} ${Bk(n,t.language)} · ${e(`statistics.target`)} ${Bk(r,t.language)} · ${e(`statistics.balance`)} ${Bk(i,t.language)} · ${e(`statistics.openDays`)} ${a}`,l=s.data?.totals;return(0,F.jsxs)(TD,{title:e(`nav.statistics`),children:[(0,F.jsx)(OD,{error:s.error}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsx)($v,{children:(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,children:[(0,F.jsx)(Q,{label:e(`statistics.from`),value:n,onChange:e=>r(e.target.value)}),(0,F.jsx)(Q,{label:e(`statistics.to`),value:i,onChange:e=>a(e.target.value)})]})})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(s.data?.users??[]).map(e=>(0,F.jsx)(hS,{divider:!0,children:(0,F.jsx)(SS,{primary:e.displayName,secondary:c(e.workedMin,e.targetMin,e.balanceMin,e.openDays)})},e.userId)),l&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{primary:(0,F.jsx)(Y,{variant:`body1`,sx:{fontWeight:600},children:e(`statistics.totals`)}),secondary:c(l.workedMin,l.targetMin,l.balanceMin,l.openDays)})})]})})]})}function Hk(){let{t:e,i18n:t}=wE(),{session:n,permissions:r}=pD(),{pending:i,flush:a,busy:o,outcome:s}=xD(),c=Tc(),l=n?.user.timezone??`UTC`,u=mD(r,`time.resolve_conflict`),d=Kl({queryKey:[`conflicts`],queryFn:()=>$.conflicts(),enabled:u,retry:!1}),f=ql({mutationFn:e=>$.resolve(e.entryId,e.action),onSuccess:()=>void c.invalidateQueries({queryKey:[`conflicts`]})});return(0,F.jsxs)(TD,{title:e(`sync.title`),children:[(0,F.jsx)(Vv,{sx:{mb:3},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:i.length>0?e(`sync.pending`,{count:i.length}):e(`sync.none`)}),s&&(0,F.jsx)(jm,{severity:`success`,sx:{mt:1},children:e(`sync.done`,{accepted:s.accepted,duplicates:s.duplicates,conflicts:s.conflicts})}),(0,F.jsx)(Z,{spacing:2,sx:{mt:2},children:(0,F.jsx)(X,{variant:`contained`,disabled:o||i.length===0,onClick:()=>void a(),children:e(`sync.flush`)})}),i.length>0&&(0,F.jsx)(eS,{dense:!0,children:i.map(e=>(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{primary:jE(e.tsUtc,l,t.language),secondary:e.note??void 0})},e.idempotencyKey))})]})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`sync.conflicts`)}),u?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:d.error}),f.error&&(0,F.jsx)(OD,{error:f.error}),(d.data??[]).length===0?(0,F.jsx)(Ev,{children:(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`sync.empty`)})}):(0,F.jsx)(eS,{dense:!0,children:(d.data??[]).map(n=>(0,F.jsxs)(ED,{primary:e(`sync.conflictOf`,{date:n.localDate,time:jE(n.tsUtc,l,t.language)}),secondary:n.note??void 0,children:[(0,F.jsx)(X,{size:`small`,onClick:()=>f.mutate({entryId:n.entryId??n.id,action:`accept`}),children:e(`sync.accept`)}),(0,F.jsx)(X,{size:`small`,color:`warning`,onClick:()=>f.mutate({entryId:n.entryId??n.id,action:`dismiss`}),children:e(`sync.dismiss`)})]},n.id))})]}):(0,F.jsx)(jm,{severity:`info`,children:e(`sync.permission`)})]})})]})}var Uk=`time-tracker.scan`;function Wk(){let e=new URLSearchParams(window.location.search),t=e.get(`tag`);if(t?.trim()){try{window.sessionStorage.setItem(Uk,t.trim())}catch{}e.delete(`tag`);let n=e.toString();return window.history.replaceState(null,``,`${window.location.pathname}${n?`?${n}`:``}`),t.trim()}try{return window.sessionStorage.getItem(Uk)}catch{return null}}function Gk(){let{t:e,i18n:t}=wE(),n=(0,y.useRef)(Wk()),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(!1);(0,y.useEffect)(()=>{s||(c(!0),(async()=>{try{i(await $.scanTag(n.current??``))}catch(e){o(e)}})())},[s]);let l=Intl.DateTimeFormat().resolvedOptions().timeZone;return(0,F.jsx)(Ev,{sx:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,p:2},children:(0,F.jsx)(Vv,{sx:{maxWidth:520,width:`100%`},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`scan.title`)}),!r&&!a&&(0,F.jsxs)(Ev,{sx:{display:`flex`,gap:2,alignItems:`center`},children:[(0,F.jsx)(My,{size:20}),(0,F.jsx)(Y,{children:e(`common.loading`)})]}),r&&(0,F.jsx)(jm,{severity:`success`,children:e(`scan.done`,{name:r.user?.displayName??``,time:jE(r.entry?.tsUtc??null,l,t.language)})}),a?(0,F.jsx)(jm,{severity:`error`,children:e(`scan.failed`,{reason:e(DD(a))})}):null,(0,F.jsx)(X,{sx:{mt:2},variant:`contained`,href:`/`,children:e(`nav.dashboard`)})]})})})}var Kk=`time-tracker.terminal`,qk=8e3,Jk=3e5;function Yk(){let e=new URLSearchParams(window.location.search).get(`token`);if(e?.trim()){try{window.localStorage.setItem(Kk,e.trim())}catch{}return e.trim()}try{return window.localStorage.getItem(Kk)}catch{return null}}function Xk(){let{t:e,i18n:t}=wE(),[n,r]=(0,y.useState)(()=>Yk()),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(``),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(null),[C,w]=(0,y.useState)(`UTC`),[T,E]=(0,y.useState)(Math.floor(Date.now()/1e3)),D=(0,y.useRef)(0),O=zE(),k=(0,y.useCallback)(()=>{try{window.localStorage.removeItem(Kk)}catch{}r(null)},[]);(0,y.useEffect)(()=>{(async()=>{try{let e=await $.terminalStatus();S(e.enabled),w(e.timezone),D.current=e.serverTime-Math.floor(Date.now()/1e3)}catch(e){b(e),S(!1)}})()},[]),(0,y.useEffect)(()=>{let e=window.setInterval(()=>E(Math.floor(Date.now()/1e3)+D.current),1e3);return()=>window.clearInterval(e)},[]),(0,y.useEffect)(()=>{n&&x===!0&&(async()=>{try{let e=await $.terminalSession(n);s(e);let t=await $.terminalUsers(e.terminalSession);l(t.users)}catch(e){b(e),k()}})()},[n,x,k]),(0,y.useEffect)(()=>{if(!o||!n)return;let e=window.setInterval(()=>{$.terminalHeartbeat(o.terminalSession).catch(async()=>{try{s(await wk(n))}catch{k()}})},Jk);return()=>window.clearInterval(e)},[o,n,k]);let A=(0,y.useCallback)(async e=>{if(o&&n){b(null);try{let t=await Tk({deviceToken:n,session:o,call:t=>$.terminalPunch({terminalSession:t.terminalSession,...e}),onRenewed:s});_(t),d(null),p(``),h(``),window.setTimeout(()=>_(null),qk)}catch(e){b(e)}}},[o,n]);return x===null?(0,F.jsx)(Ev,{sx:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`},children:(0,F.jsx)(Y,{children:e(`common.loading`)})}):x===!0?n?o?g?(0,F.jsx)(Ev,{sx:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,p:2},children:(0,F.jsx)(Vv,{sx:{maxWidth:560,width:`100%`},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h4`,gutterBottom:!0,children:g.user.displayName}),(0,F.jsx)(jm,{severity:`success`,children:`${e(g.entry.direction===`out`?`punch.out`:`punch.in`)} — ${e(`punch.sent`,{time:jE(g.entry.tsUtc,C,t.language)})}`}),(0,F.jsxs)(Z,{spacing:.5,sx:{mt:2},children:[(0,F.jsxs)(Y,{variant:`body1`,children:[e(`punch.worked`),`: `,g.day.workedMin,` min`]}),(0,F.jsxs)(Y,{variant:`body1`,children:[e(`punch.target`),`: `,g.day.targetMin,` min`]}),(0,F.jsxs)(Y,{variant:`body1`,children:[e(`punch.balance`),`: `,g.day.balanceMin,` min`]}),!g.day.hasOpenEntry&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`punch.closed`)})]})]})})}):(0,F.jsxs)(Ev,{sx:{p:2},children:[(0,F.jsxs)(Z,{direction:`row`,justifyContent:`space-between`,alignItems:`baseline`,sx:{mb:2},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`,minWidth:0},children:[O.logoUrl&&(0,F.jsx)(Ev,{component:`img`,src:O.logoUrl,alt:``,sx:{height:28,maxWidth:120,objectFit:`contain`}}),(0,F.jsx)(Y,{variant:`h5`,children:o.terminal.name})]}),(0,F.jsx)(Y,{variant:`h5`,children:jE(T,C,t.language)})]}),(0,F.jsx)(OD,{error:v}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,children:[(0,F.jsx)(Q,{label:e(`terminal.badge`),value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f.trim()&&A({badge:f.trim()})},autoFocus:!0,fullWidth:!0}),(0,F.jsx)(X,{variant:`contained`,size:`large`,disabled:f.trim().length===0,onClick:()=>void A({badge:f.trim()}),children:e(`punch.now`)})]}),(0,F.jsx)(Ok,{onDigit:e=>p(t=>t+e),onBackspace:()=>p(e=>e.slice(0,-1))})]})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`terminal.select`)}),(0,F.jsx)(Z,{direction:`row`,spacing:1,sx:{flexWrap:`wrap`,gap:1},children:c.map(e=>(0,F.jsx)(X,{variant:u?.id===e.id?`contained`:`outlined`,startIcon:(0,F.jsx)(J_,{src:e.avatarUrl??`/person.png`,alt:``,sx:{width:24,height:24}}),onClick:()=>d(e),children:e.displayName},e.id))}),(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,sx:{mt:2},children:[o.terminal.pinRequired?(0,F.jsx)(Q,{label:e(`terminal.pin`),type:`password`,value:m,onChange:e=>h(e.target.value),helperText:e(`admin.user.pinHint`),fullWidth:!0}):(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{alignSelf:`center`},children:e(`terminal.noPin`)}),(0,F.jsx)(X,{variant:`contained`,size:`large`,disabled:!u||o.terminal.pinRequired&&m.length===0,onClick:()=>u&&void A(o.terminal.pinRequired?{userId:u.id,pin:m}:{userId:u.id}),children:e(`punch.now`)})]}),o.terminal.pinRequired&&(0,F.jsx)(Ok,{onDigit:e=>h(t=>t+e),onBackspace:()=>h(e=>e.slice(0,-1))})]})})]}):(0,F.jsxs)(Ev,{sx:{p:3},children:[(0,F.jsx)(Y,{children:e(`common.loading`)}),(0,F.jsx)(OD,{error:v})]}):(0,F.jsx)(Ev,{sx:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,p:2},children:(0,F.jsx)(Vv,{sx:{maxWidth:480,width:`100%`},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`terminal.title`)}),(0,F.jsxs)(Z,{spacing:2,children:[(0,F.jsx)(Q,{label:e(`terminal.deviceToken`),value:i,onChange:e=>a(e.target.value),fullWidth:!0,autoFocus:!0}),(0,F.jsx)(OD,{error:v}),(0,F.jsx)(X,{variant:`contained`,disabled:i.trim().length===0,onClick:()=>r(i.trim()),children:e(`terminal.connect`)})]})]})})}):(0,F.jsxs)(Ev,{sx:{p:3},children:[(0,F.jsx)(jm,{severity:`warning`,children:e(`terminal.disabled`)}),(0,F.jsx)(OD,{error:v})]})}var Zk=cc({palette:{mode:`light`,primary:{main:`#1976d2`},secondary:{main:`#00897b`}},shape:{borderRadius:10},components:{MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{textTransform:`none`,minHeight:44}}},MuiCard:{styleOverrides:{root:{border:`1px solid rgba(0,0,0,0.08)`}}}}}),Qk=new Nl({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!0,staleTime:3e4}}});function $k(){let{session:e,checking:t}=pD();return t&&!e?(0,F.jsx)(Ev,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,minHeight:`100vh`},children:(0,F.jsx)(My,{})}):e?e.user.mustChangePw?(0,F.jsx)(Yd,{children:(0,F.jsx)(qd,{path:`*`,element:(0,F.jsx)(bk,{})})}):(0,F.jsxs)(Yd,{children:[(0,F.jsx)(qd,{path:`/`,element:(0,F.jsx)(vk,{})}),(0,F.jsx)(qd,{path:`/month`,element:(0,F.jsx)($D,{})}),(0,F.jsx)(qd,{path:`/reports`,element:(0,F.jsx)(Lk,{})}),(0,F.jsx)(qd,{path:`/statistics`,element:(0,F.jsx)(Vk,{})}),(0,F.jsx)(qd,{path:`/absences`,element:(0,F.jsx)(AD,{})}),(0,F.jsx)(qd,{path:`/sync`,element:(0,F.jsx)(Hk,{})}),(0,F.jsx)(qd,{path:`/profile`,element:(0,F.jsx)(Ik,{})}),(0,F.jsx)(qd,{path:`/admin`,element:(0,F.jsx)(hk,{})}),(0,F.jsx)(qd,{path:`*`,element:(0,F.jsx)(Kd,{to:`/`,replace:!0})})]}):(0,F.jsx)(Yd,{children:(0,F.jsx)(qd,{path:`*`,element:(0,F.jsx)(yk,{})})})}function eA(){let[e]=(0,y.useState)(()=>new URLSearchParams(window.location.search).has(`tag`));return e?(0,F.jsx)(Gk,{}):(0,F.jsxs)(Yd,{children:[(0,F.jsx)(qd,{path:`/terminal`,element:(0,F.jsx)(Xk,{})}),(0,F.jsx)(qd,{path:`/presence`,element:(0,F.jsx)(Pk,{})}),(0,F.jsx)(qd,{path:`*`,element:(0,F.jsx)($k,{})})]})}function tA(){let e=zE();return(0,F.jsx)(Ev,{sx:{minHeight:`100vh`,...BE(e)},children:(0,F.jsx)(eA,{})})}function nA(){return(0,F.jsxs)(Sc,{theme:Zk,children:[(0,F.jsx)(hc,{}),(0,F.jsx)(Ec,{client:Qk,children:(0,F.jsx)(fD,{children:(0,F.jsx)(bD,{children:(0,F.jsx)(If,{children:(0,F.jsx)(RE,{children:(0,F.jsx)(tA,{})})})})})})]})}k({immediate:!0});var rA=document.getElementById(`root`);if(!rA)throw Error(`index.html does not contain #root`);(0,b.createRoot)(rA).render((0,F.jsx)(y.StrictMode,{children:(0,F.jsx)(nA,{})}));
|
|
119
|
-
//# sourceMappingURL=index-
|
|
118
|
+
`;return typeof a==`function`&&a(null,p),p}})),HO=u(s((e=>{var t=hO(),n=RO(),r=BO(),i=VO();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function UO(e){let t=new Intl.DateTimeFormat(e,{weekday:`short`});return[1,2,3,4,5,6,7].map(e=>({value:e,label:t.format(new Date(Date.UTC(2024,0,e)))}))}function WO(e,t,n){let r=n?[...e,t]:e.filter(e=>e!==t);return[...new Set(r)].sort((e,t)=>e-t)}function GO(e,t){return new Intl.NumberFormat(t,{style:`unit`,unit:`kilobyte`,maximumFractionDigits:0}).format(Math.max(1,Math.round(e/1024)))}function KO({onClose:e,onCreated:t}){let{t:n}=wE(),r=Kl({queryKey:[`admin`,`roles`],queryFn:()=>$.roles()}),[i,a]=(0,y.useState)({login:``,displayName:``,password:``,roleKeys:[`employee`]}),o=ql({mutationFn:e=>$.createUser(e),onSuccess:t}),s=e=>({value:String(i[e]),onChange:t=>a(n=>({...n,[e]:t.target.value}))});return(0,F.jsxs)(hb,{open:!0,onClose:e,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:n(`admin.user.create`)}),(0,F.jsxs)(Db,{children:[(0,F.jsx)(OD,{error:o.error??r.error}),(0,F.jsxs)(Z,{sx:{mt:1},children:[(0,F.jsx)(Q,{autoFocus:!0,fullWidth:!0,label:n(`admin.user.login`),...s(`login`)}),(0,F.jsx)(Q,{fullWidth:!0,label:n(`admin.user.name`),sx:{mt:2},...s(`displayName`)}),(0,F.jsx)(Q,{fullWidth:!0,type:`password`,label:n(`admin.user.password`),helperText:n(`admin.user.passwordHint`),sx:{mt:2},...s(`password`)}),(0,F.jsx)(Q,{select:!0,fullWidth:!0,label:n(`admin.user.roles`),sx:{mt:2},value:i.roleKeys[0]??`employee`,onChange:e=>a(t=>({...t,roleKeys:[e.target.value]})),children:(r.data??[]).map(e=>(0,F.jsx)(iC,{value:e.key,children:n(`role.${e.key}`,e.name)},e.key))})]})]}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:e,children:n(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:o.isPending||i.login.trim()===``||i.displayName.trim()===``||i.password.length<8,onClick:()=>o.mutate(i),children:n(`common.save`)})]})]})}function qO(e,t){return new Intl.DateTimeFormat(t,{dateStyle:`short`,timeStyle:`short`}).format(new Date(e*1e3))}function JO({rules:e,disabled:t,saving:n,onChange:r,onSave:i}){let{t:a}=wE(),o=(t,n)=>r(e.map((e,r)=>r===t?{...e,...n}:e));return(0,F.jsxs)(Z,{spacing:1,children:[e.map((n,i)=>(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(Q,{size:`small`,type:`number`,label:a(`admin.settings.pauseFrom`),value:String(n.fromMin),onChange:e=>o(i,{fromMin:Number(e.target.value)}),disabled:t}),(0,F.jsx)(Q,{size:`small`,type:`number`,label:a(`admin.settings.pauseTo`),value:n.toMin===null?``:String(n.toMin),onChange:e=>o(i,{toMin:e.target.value===``?null:Number(e.target.value)}),disabled:t}),(0,F.jsx)(Q,{size:`small`,type:`number`,label:a(`admin.settings.pauseMinutes`),value:String(n.pauseMin),onChange:e=>o(i,{pauseMin:Number(e.target.value)}),disabled:t}),(0,F.jsx)(dw,{checked:n.isActive!==!1,title:a(`admin.settings.pauseActive`),onChange:()=>o(i,{isActive:n.isActive===!1}),disabled:t}),(0,F.jsx)(vm,{size:`small`,title:a(`admin.backup.delete`),disabled:t,onClick:()=>r(e.filter((e,t)=>t!==i)),children:(0,F.jsx)(zD,{fontSize:`small`})})]},n.id??`new-${i}`)),(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(UD,{}),disabled:t,onClick:()=>r([...e,{fromMin:360,toMin:null,pauseMin:30,isActive:!0}]),children:a(`admin.settings.pauseAdd`)}),(0,F.jsx)(X,{size:`small`,variant:`contained`,disabled:t||n,onClick:i,children:a(`admin.settings.pauseSave`)})]})]})}function YO({user:e,onClose:t}){let{t:n,i18n:r}=wE(),i=Tc(),a=e?.id??0,o=Kl({queryKey:[`admin`,`profile`,a],queryFn:()=>$.workProfile(a),enabled:e!==null}),[s,c]=(0,y.useState)({}),l=ql({mutationFn:e=>$.saveWorkProfile(a,e),onSuccess:async()=>{c({}),await i.invalidateQueries({queryKey:[`admin`,`profile`,a]}),t()}}),u=Kl({queryKey:[`admin`,`pauseRules`,a],queryFn:()=>$.userPauseRules(a),enabled:e!==null}),[d,f]=(0,y.useState)(null),p=d??u.data??[],m=ql({mutationFn:e=>$.saveUserPauseRules(a,e),onSuccess:async()=>{f(null),await i.invalidateQueries({queryKey:[`admin`,`pauseRules`,a]}),t()}}),h=e=>c(t=>({...t,...e})),g=o.data?{...o.data,...s}:null,_=e=>Math.round(e/60*100)/100,v=Array.from({length:7},(e,t)=>new Intl.DateTimeFormat(r.language,{weekday:`narrow`}).format(new Date(Date.UTC(2026,0,4+t)))),b=(g?.workdays??`0;1;1;1;1;1;0`).split(`;`),x=(e,t,n)=>(0,F.jsx)(Q,{fullWidth:!0,size:`small`,type:`number`,label:t,value:String(g?.[e]??0),onChange:t=>h({[e]:Number(t.target.value)}),inputProps:n?{step:n}:void 0});return(0,F.jsxs)(hb,{open:e!==null,onClose:t,fullWidth:!0,maxWidth:`sm`,children:[(0,F.jsx)(Ib,{children:n(`admin.user.profileTitle`,{name:e?.displayName??``})}),(0,F.jsxs)(Db,{children:[(0,F.jsx)(OD,{error:o.error??l.error??u.error??m.error}),o.isLoading?(0,F.jsx)(kD,{}):(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:2,children:[x(`percent`,n(`admin.profile.percent`)),x(`weeklyHours`,n(`admin.profile.weeklyHours`),`0.5`)]}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n(`admin.profile.workdays`)}),(0,F.jsx)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`,flexWrap:`wrap`},children:v.map((e,t)=>(0,F.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`},children:[(0,F.jsx)(_y,{size:`small`,checked:b[t]===`1`,onChange:()=>{let e=b.slice();e[t]=e[t]===`1`?`0`:`1`,h({workdays:e.join(`;`)})}}),(0,F.jsx)(Y,{variant:`body2`,children:e})]},`${e}-${t}`))})]}),(0,F.jsx)(Q,{select:!0,fullWidth:!0,size:`small`,label:n(`admin.profile.overtimeModel`),value:g?.overtimeModel??`monthly`,onChange:e=>h({overtimeModel:e.target.value}),children:[`monthly`,`yearly`,`cumulative`].map(e=>(0,F.jsx)(iC,{value:e,children:n(`admin.profile.model.${e}`)},e))}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(ex,{control:(0,F.jsx)(dw,{checked:g?.showWorkedTime===!0,onChange:e=>h({showWorkedTime:e.target.checked})}),label:n(`admin.user.workedTime`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n(`admin.user.workedTimeHint`)})]}),(0,F.jsxs)(Z,{direction:`row`,spacing:2,children:[x(`vacationPerYear`,n(`admin.profile.vacationPerYear`),`0.5`),x(`vacationCarryover`,n(`admin.profile.vacationCarryover`),`0.5`)]}),(0,F.jsxs)(Z,{direction:`row`,spacing:2,children:[(0,F.jsx)(Q,{fullWidth:!0,size:`small`,type:`number`,label:n(`admin.profile.overtimeCarryover`),value:String(_(g?.overtimeCarryover??0)),onChange:e=>h({overtimeCarryover:Math.round(Number(e.target.value)*60)})}),(0,F.jsx)(Q,{fullWidth:!0,size:`small`,type:`number`,label:n(`admin.profile.vorholzeitPerYear`),value:String(_(g?.vorholzeitPerYear??0)),onChange:e=>h({vorholzeitPerYear:Math.round(Number(e.target.value)*60)})})]}),(0,F.jsx)(Q,{fullWidth:!0,size:`small`,type:`number`,label:n(`admin.profile.pausePaid`),helperText:n(`admin.profile.pausePaidHint`),value:String(g?.pausePaidMinutes??0),onChange:e=>h({pausePaidMinutes:Math.max(0,Math.round(Number(e.target.value)))})}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n(`admin.profile.pauseRules`)}),(0,F.jsx)(Y,{variant:`caption`,color:`text.secondary`,display:`block`,sx:{mb:1},children:n(`admin.profile.pauseRulesHint`)}),(0,F.jsx)(JO,{rules:p,disabled:!1,saving:m.isPending,onChange:f,onSave:()=>m.mutate(p)})]})]})]}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:t,children:n(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:l.isPending||Object.keys(s).length===0,onClick:()=>l.mutate(s),children:n(`common.save`)})]})]})}function XO({language:e}){let{t}=wE(),{session:n,permissions:r}=pD(),i=Tc(),a=mD(r,`user.edit`),o=mD(r,`user.create`),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(null),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(!1),w=mD(r,`user.manage_roles`),T=n?.user.id??0,E=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users(!0)}),D=(E.data??[]).filter(e=>e.isActive&&e.roles.includes(`admin`)),O=async()=>{await i.invalidateQueries({queryKey:[`admin`,`users`]})},k=ql({mutationFn:({id:e,patch:t})=>$.updateUser(e,t),onSuccess:O}),A=ql({mutationFn:({id:e,value:t})=>$.setPin(e,t),onSuccess:async()=>{u(null),f(``),await O()}}),j=ql({mutationFn:({id:e,value:t})=>$.updateUser(e,{avatar:t}),onSuccess:async()=>{m(null),g(null),await O()}});return E.isLoading?(0,F.jsx)(kD,{}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:E.error??k.error??A.error??j.error}),o&&(0,F.jsx)(Ev,{sx:{mb:2},children:(0,F.jsx)(X,{variant:`contained`,startIcon:(0,F.jsx)(pO,{}),onClick:()=>c(!0),children:t(`admin.user.create`)})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(E.data??[]).map(e=>(0,F.jsx)(ED,{primary:`${e.displayName} (${e.login})`,secondary:(0,F.jsxs)(Z,{direction:`row`,spacing:.5,sx:{mt:.5},children:[e.roles.map(e=>(0,F.jsx)(u_,{size:`small`,label:t(`role.${e}`,e)},e)),!e.isActive&&(0,F.jsx)(u_,{size:`small`,color:`default`,label:t(`admin.user.inactive`)})]}),children:a&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(fO,{}),onClick:()=>{u(e),f(``)},children:t(`admin.user.pin`)}),(0,F.jsx)(X,{size:`small`,onClick:()=>{m(e),g(null)},children:t(`admin.user.photo`)}),(0,F.jsx)(X,{size:`small`,onClick:()=>x(e),children:t(`admin.user.profile`)}),w&&(0,F.jsx)(X,{size:`small`,onClick:()=>v(e),children:t(`admin.user.roles`)}),(0,F.jsx)(dw,{checked:e.isActive,title:t(e.isActive?`admin.user.active`:`admin.user.inactive`),onChange:()=>{if(e.id===T&&e.isActive){C(!0);return}k.mutate({id:e.id,patch:{isActive:!e.isActive}})}})]})},e.id)),(E.data??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.user.empty`)})})]})}),(0,F.jsx)(YO,{user:b,onClose:()=>x(null)}),(0,F.jsxs)(hb,{open:l!==null,onClose:()=>u(null),children:[(0,F.jsx)(Ib,{children:t(`admin.user.pinTitle`,{name:l?.displayName??``})}),(0,F.jsx)(Db,{children:(0,F.jsx)(Q,{autoFocus:!0,fullWidth:!0,inputMode:`numeric`,label:t(`admin.user.newPin`),helperText:t(`admin.user.pinHint`),value:d,onChange:e=>f(e.target.value.replace(/\D/g,``).slice(0,8)),sx:{mt:1}})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>u(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:d.length<4||A.isPending,onClick:()=>l&&A.mutate({id:l.id,value:d}),children:t(`common.save`)})]})]}),(0,F.jsxs)(hb,{open:p!==null,onClose:()=>m(null),children:[(0,F.jsx)(Ib,{children:t(`admin.user.photoTitle`,{name:p?.displayName??``})}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(`img`,{src:h??p?.avatarUrl??`/person.png`,alt:``,width:96,height:96,style:{objectFit:`cover`,borderRadius:8}}),(0,F.jsx)(ck,{label:t(`admin.user.photoChoose`),maxBytes:MD,hint:t(`admin.user.photoHint`),onChange:e=>g(e)})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>m(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{disabled:p?.avatarUrl===null||p?.avatarUrl===void 0,onClick:()=>p&&j.mutate({id:p.id,value:null}),children:t(`admin.user.photoRemove`)}),(0,F.jsx)(X,{variant:`contained`,disabled:h===null||j.isPending,onClick:()=>p&&j.mutate({id:p.id,value:h}),children:t(`common.save`)})]})]}),_&&(0,F.jsx)(tk,{user:_,isSelf:_.id===T,lastAdministrator:D.length===1&&_.roles.includes(`admin`),onClose:()=>v(null),onSaved:e=>{k.mutate({id:_.id,patch:{roleKeys:e}}),v(null)}}),(0,F.jsxs)(hb,{open:S,onClose:()=>C(!1),children:[(0,F.jsx)(Ib,{children:t(`admin.user.selfTitle`)}),(0,F.jsx)(Db,{children:(0,F.jsx)(Mb,{children:t(`admin.user.selfDeactivate`)})}),(0,F.jsx)(bb,{children:(0,F.jsx)(X,{variant:`contained`,onClick:()=>C(!1),children:t(`common.close`)})})]}),s&&(0,F.jsx)(KO,{language:e,onClose:()=>c(!1),onCreated:async()=>{c(!1),await O()}})]})}function ZO({onClose:e,onCreated:t}){let{t:n}=wE(),r=Kl({queryKey:[`admin`,`users`,`active`],queryFn:()=>$.users(!1)}),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)([]),f=ql({mutationFn:()=>$.createTerminal({name:i.trim(),...o.trim()?{location:o.trim()}:{},pinRequired:c,userIds:u}),onSuccess:t});return(0,F.jsxs)(hb,{open:!0,onClose:e,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:n(`admin.terminal.create`)}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(Q,{label:n(`admin.terminal.name`),value:i,onChange:e=>a(e.target.value),fullWidth:!0,autoFocus:!0}),(0,F.jsx)(Q,{label:n(`admin.terminal.location`),value:o,onChange:e=>s(e.target.value),fullWidth:!0}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,children:[(0,F.jsx)(dw,{checked:c,onChange:(e,t)=>l(t)}),(0,F.jsx)(Y,{children:n(`admin.terminal.pinRequired`)})]}),(0,F.jsx)(Y,{variant:`subtitle2`,children:n(`admin.terminal.users`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n(`admin.terminal.usersHint`)}),(0,F.jsx)(QO,{users:r.data??[],chosen:u,onChange:d}),(0,F.jsx)(OD,{error:f.error})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:e,children:n(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:i.trim().length===0||f.isPending,onClick:()=>f.mutate(),children:n(`admin.terminal.create`)})]})]})}function QO({users:e,chosen:t,onChange:n}){return(0,F.jsx)(Ev,{sx:{maxHeight:240,overflowY:`auto`},children:(0,F.jsx)(Z,{spacing:.5,children:e.map(e=>(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,F.jsx)(dw,{checked:t.includes(e.id),inputProps:{"aria-label":e.displayName},onChange:(r,i)=>n(i?[...new Set([...t,e.id])]:t.filter(t=>t!==e.id))}),(0,F.jsx)(Y,{children:e.displayName})]},e.id))})})}function $O({terminal:e,onClose:t,onSaved:n}){let{t:r}=wE(),i=Kl({queryKey:[`admin`,`users`,`active`],queryFn:()=>$.users(!1)}),[a,o]=(0,y.useState)(e.userIds),s=ql({mutationFn:()=>$.setTerminalUsers(e.id,a),onSuccess:n});return(0,F.jsxs)(hb,{open:!0,onClose:t,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:`${r(`admin.terminal.users`)} · ${e.name}`}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:1,sx:{mt:1},children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:r(`admin.terminal.usersHint`)}),(0,F.jsx)(QO,{users:i.data??[],chosen:a,onChange:o}),(0,F.jsx)(OD,{error:i.error??s.error})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:t,children:r(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:s.isPending,onClick:()=>s.mutate(),children:r(`common.save`)})]})]})}function ek({language:e}){let{t}=wE(),n=Tc(),r=Kl({queryKey:[`admin`,`terminals`],queryFn:()=>$.terminals()}),i=Kl({queryKey:[`admin`,`users`,`active`],queryFn:()=>$.users(!1)}),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),p=ql({mutationFn:e=>$.revokeTerminal(e),onSuccess:async()=>{c(null),await n.invalidateQueries({queryKey:[`admin`,`terminals`]})}}),m=d?`${window.location.origin}/terminal?token=${encodeURIComponent(d.deviceToken)}`:``,h=d?`${window.location.origin}/presence?token=${encodeURIComponent(d.deviceToken)}`:``,g=`${t(`common.none`)}`,_=n=>{let r=n.userIds.length===0?t(`admin.terminal.usersAll`):(i.data??[]).filter(e=>n.userIds.includes(e.id)).map(e=>e.displayName).join(`, `)||t(`admin.terminal.usersAll`);return[n.location||g,qO(n.createdAt,e),r].join(` · `)};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:r.error??p.error}),d&&(0,F.jsxs)(jm,{severity:`success`,sx:{mb:2},children:[(0,F.jsx)(Y,{variant:`body2`,gutterBottom:!0,children:t(`admin.terminal.tokenOnce`)}),(0,F.jsx)(Y,{variant:`body2`,sx:{fontFamily:`monospace`,wordBreak:`break-all`},gutterBottom:!0,children:d.deviceToken}),(0,F.jsx)(Y,{variant:`body2`,gutterBottom:!0,children:t(`admin.terminal.url`)}),(0,F.jsx)(Y,{variant:`body2`,sx:{fontFamily:`monospace`,wordBreak:`break-all`},children:m}),(0,F.jsxs)(Y,{variant:`body2`,sx:{mt:1},children:[t(`presence.title`),`:`]}),(0,F.jsx)(Y,{variant:`body2`,sx:{fontFamily:`monospace`,wordBreak:`break-all`},children:h})]}),(0,F.jsx)(Ev,{sx:{mb:2},children:(0,F.jsx)(X,{variant:`contained`,startIcon:(0,F.jsx)(mO,{}),disabled:a,onClick:()=>o(!0),children:t(`admin.terminal.create`)})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(r.data??[]).map(e=>(0,F.jsx)(ED,{primary:(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,sx:{flexWrap:`wrap`,gap:1},children:[(0,F.jsx)(Y,{children:e.name}),e.pinRequired&&(0,F.jsx)(u_,{size:`small`,label:t(`admin.terminal.pinRequired`)}),!e.isActive&&(0,F.jsx)(u_,{size:`small`,variant:`outlined`,label:t(`admin.terminal.revoked`)})]}),secondary:_(e),children:e.isActive&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(X,{size:`small`,onClick:()=>u(e),children:t(`admin.terminal.users`)}),(0,F.jsx)(X,{size:`small`,color:`error`,onClick:()=>c(e),children:t(`admin.terminal.revoke`)})]})},e.id)),r.isLoading&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`common.loading`)})}),!r.isLoading&&(r.data??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.terminal.empty`)})})]})}),l&&(0,F.jsx)($O,{terminal:l,onClose:()=>u(null),onSaved:async()=>{u(null),await n.invalidateQueries({queryKey:[`admin`,`terminals`]})}}),a&&(0,F.jsx)(ZO,{onClose:()=>o(!1),onCreated:async e=>{o(!1),f(e),await n.invalidateQueries({queryKey:[`admin`,`terminals`]})}}),s&&(0,F.jsxs)(hb,{open:!0,onClose:()=>c(null),children:[(0,F.jsx)(Ib,{children:t(`admin.terminal.revoke`)}),(0,F.jsx)(Db,{children:t(`admin.terminal.confirmRevoke`,{name:s.name})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>c(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{color:`error`,variant:`contained`,disabled:p.isPending,onClick:()=>p.mutate(s.id),children:t(`admin.terminal.revoke`)})]})]})]})}function tk({user:e,isSelf:t,lastAdministrator:n,onClose:r,onSaved:i}){let{t:a}=wE(),o=Kl({queryKey:[`admin`,`roles`],queryFn:()=>$.roles()}),[s,c]=(0,y.useState)(e.roles),l=e.roles.includes(`admin`)&&!s.includes(`admin`),u=(e,t)=>c(n=>t?[...new Set([...n,e])]:n.filter(t=>t!==e));return(0,F.jsxs)(hb,{open:!0,onClose:r,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:a(`admin.user.roles`)}),(0,F.jsxs)(Db,{children:[t&&l&&(0,F.jsx)(jm,{"data-testid":`roles-warning`,severity:n?`info`:`warning`,sx:{mt:1},children:a(n?`admin.user.lastAdminRoles`:`admin.user.selfRoles`)}),(0,F.jsx)(Z,{spacing:1,sx:{mt:1},children:(o.data??[]).map(e=>(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,children:[(0,F.jsx)(dw,{checked:s.includes(e.key),inputProps:{"aria-label":a(`role.${e.key}`,e.name)},onChange:(t,n)=>u(e.key,n)}),(0,F.jsx)(Y,{children:a(`role.${e.key}`,e.name)})]},e.key))})]}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:r,children:a(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:s.length===0||n&&l,onClick:()=>i(s),children:a(`common.save`)})]})]})}function nk({language:e}){let{t}=wE(),n=Tc(),[r,i]=(0,y.useState)(String(new Date().getFullYear())),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(``),d=Kl({queryKey:[`admin`,`holidays`,r],queryFn:()=>$.holidays(Number(r))}),f=async()=>{await n.invalidateQueries({queryKey:[`admin`,`holidays`,r]})},p=ql({mutationFn:()=>$.createHoliday({date:a.trim(),name:s.trim(),...l.trim()?{region:l.trim()}:{}}),onSuccess:async()=>{o(``),c(``),u(``),await f()}}),m=ql({mutationFn:e=>$.deleteHoliday(e),onSuccess:f}),h=/^\d{4}-\d{2}-\d{2}$/.test(a.trim())&&s.trim().length>0;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:d.error??p.error??m.error}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,sx:{mt:1},children:[(0,F.jsx)(Q,{label:t(`admin.holiday.year`),value:r,onChange:e=>i(e.target.value.replace(/\D/g,``).slice(0,4)),sx:{width:140}}),(0,F.jsx)(Q,{label:t(`admin.holiday.date`),value:a,onChange:e=>o(e.target.value)}),(0,F.jsx)(Q,{label:t(`admin.holiday.name`),value:s,onChange:e=>c(e.target.value),fullWidth:!0}),(0,F.jsx)(Q,{label:t(`admin.holiday.region`),value:l,onChange:e=>u(e.target.value),sx:{width:200}})]}),(0,F.jsx)(Ev,{sx:{mt:2},children:(0,F.jsx)(X,{variant:`contained`,disabled:!h||p.isPending,onClick:()=>p.mutate(),children:t(`admin.holiday.add`)})})]})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(d.data??[]).map(n=>(0,F.jsx)(ED,{primary:`${ME(n.date,e)} · ${n.key?t(`holiday.${n.key}`,{defaultValue:n.name}):n.name}`,secondary:n.region??t(`common.none`),children:(0,F.jsx)(X,{size:`small`,color:`error`,onClick:()=>m.mutate(n.id),children:t(`admin.tag.delete`)})},n.id)),!d.isLoading&&(d.data??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.holiday.empty`)})})]})})]})}function rk({tag:e,onClose:t,onSaved:n}){let{t:r}=wE(),i=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users()}),[a,o]=(0,y.useState)(e.userId===null?``:String(e.userId)),[s,c]=(0,y.useState)(e.label??``),[l,u]=(0,y.useState)(``),d=l.trim()===``?void 0:Number(l),f=!a||d!==void 0&&(!Number.isInteger(d)||d<=0),p=ql({mutationFn:()=>$.updateTag(e.id,{userId:Number(a),label:s.trim()?s.trim():null,...d===void 0?{}:{ttlDays:d}}),onSuccess:n}),m=ql({mutationFn:()=>$.reissueTagLink(e.id),onSuccess:n});return(0,F.jsxs)(hb,{open:!0,onClose:t,fullWidth:!0,children:[(0,F.jsx)(Ib,{children:`${r(`admin.tag.editTitle`)} · ${e.label??e.uid}`}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:r(`admin.tag.editHint`)}),(0,F.jsx)(Q,{select:!0,label:r(`admin.tag.user`),value:a,onChange:e=>o(e.target.value),children:(i.data??[]).map(e=>(0,F.jsx)(iC,{value:String(e.id),children:`${e.displayName} (${e.login})`},e.id))}),(0,F.jsx)(Q,{label:r(`admin.tag.label`),value:s,onChange:e=>c(e.target.value)}),(0,F.jsx)(Q,{label:r(`admin.tag.validityDays`),type:`number`,value:l,onChange:e=>u(e.target.value)}),(0,F.jsx)(OD,{error:i.error??p.error??m.error})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>m.mutate(),disabled:m.isPending,sx:{mr:`auto`},children:r(`admin.tag.reissue`)}),(0,F.jsx)(X,{onClick:t,children:r(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:f||p.isPending,onClick:()=>p.mutate(),children:r(`common.save`)})]})]})}function ik({language:e}){let{t}=wE(),n=Tc(),r=Kl({queryKey:[`admin`,`tags`],queryFn:()=>$.rfidTags()}),i=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users()}),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),h=async()=>{await n.invalidateQueries({queryKey:[`admin`,`tags`]})},g=e=>`${window.location.origin}/?tag=${e}`,_=(e,t)=>{u({token:e,url:g(e),reissued:t})};(0,y.useEffect)(()=>{if(!l){f(null);return}let e=!1;return HO.toDataURL(l.url,{margin:1,width:240}).then(t=>{e||f(t)}).catch(()=>{e||f(null)}),()=>{e=!0}},[l]);let v=ql({mutationFn:()=>$.createTag({userId:Number(a),...s.trim()?{label:s.trim()}:{}}),onSuccess:async e=>{_(e.token,!1),c(``),await h()}}),b=ql({mutationFn:e=>$.deleteTag(e),onSuccess:h}),x=ql({mutationFn:e=>$.deleteTagPermanently(e),onSuccess:h}),S=e=>(i.data??[]).find(t=>t.id===e)?.displayName??`#${e}`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:r.error??v.error??b.error??x.error}),l&&(0,F.jsxs)(jm,{severity:`success`,sx:{mb:2},children:[(0,F.jsx)(Y,{variant:`body2`,gutterBottom:!0,children:t(`admin.tag.linkOnce`)}),(0,F.jsx)(Y,{variant:`body2`,sx:{fontFamily:`monospace`,wordBreak:`break-all`},children:l.url}),d&&(0,F.jsx)(Ev,{sx:{mt:1.5},children:(0,F.jsx)(`img`,{src:d,alt:t(`admin.tag.qrAlt`),width:200,height:200,style:{display:`block`,borderRadius:4}})}),l.reissued&&(0,F.jsx)(Y,{variant:`body2`,sx:{mt:1},children:t(`admin.tag.oldLinkDead`)})]}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsx)($v,{children:(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,sx:{mt:1},children:[(0,F.jsx)(Q,{select:!0,label:t(`admin.tag.user`),value:a,onChange:e=>o(e.target.value),sx:{minWidth:220},children:(i.data??[]).map(e=>(0,F.jsx)(iC,{value:String(e.id),children:`${e.displayName} (${e.login})`},e.id))}),(0,F.jsx)(Q,{label:t(`admin.tag.label`),value:s,onChange:e=>c(e.target.value),fullWidth:!0}),(0,F.jsx)(X,{variant:`contained`,disabled:!a||v.isPending,onClick:()=>v.mutate(),children:t(`admin.tag.create`)})]})})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(r.data??[]).map(n=>{let r=n.expiresAt!==null&&n.expiresAt*1e3<Date.now(),i=n.isActive===!1?t(`admin.tag.revoked`):t(r?`admin.tag.expired`:`admin.tag.active`),a=n.expiresAt?qO(n.expiresAt,e):t(`common.none`),o=n.lastUsedAt?qO(n.lastUsedAt,e):t(`common.none`);return(0,F.jsxs)(ED,{primary:`${n.label??n.uid??`#${n.id}`} · ${S(n.userId)}`,secondary:`${i} · ${t(`admin.tag.lastUsed`)}: ${o} · ${n.uid??t(`common.none`)} · ${a}`,children:[(0,F.jsx)(X,{size:`small`,onClick:()=>m(n),children:t(`admin.tag.edit`)}),n.isActive!==!1&&(0,F.jsx)(X,{size:`small`,color:`error`,onClick:()=>b.mutate(n.id),children:t(`admin.tag.delete`)}),n.isActive===!1&&(0,F.jsx)(X,{size:`small`,color:`error`,onClick:()=>x.mutate(n.id),children:t(`admin.tag.remove`)})]},n.id)}),!r.isLoading&&(r.data??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.tag.empty`)})})]})}),p&&(0,F.jsx)(rk,{tag:p,onClose:()=>m(null),onSaved:async e=>{m(null),e.token&&_(e.token,!0),await h()}})]})}function ak({language:e}){let{t}=wE(),{permissions:n}=pD(),r=mD(n,`settings.edit`),i=Tc(),a=Kl({queryKey:[`admin`,`triggerRules`],queryFn:()=>$.triggerRules()}),o=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users()}),[s,c]=(0,y.useState)(null),l=s??a.data??[],u=ql({mutationFn:e=>$.saveTriggerRules(e),onSuccess:async()=>{c(null),await i.invalidateQueries({queryKey:[`admin`,`triggerRules`]})}}),d=(e,t)=>c(l.map((n,r)=>r===e?{...n,...t}:n)),f=n=>n.lastFiredAt?`${t(`admin.trigger.lastFired`)}: ${qO(n.lastFiredAt,e)}`:t(`common.none`);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:a.error??u.error}),u.isSuccess&&(0,F.jsx)(jm,{severity:`success`,sx:{mb:2},children:t(`admin.settings.saved`)}),(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:t(`admin.triggers`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:t(`admin.triggersHint`)}),(0,F.jsxs)(Z,{spacing:2,children:[l.map((e,n)=>(0,F.jsxs)(Z,{spacing:1,sx:{border:1,borderColor:`divider`,borderRadius:1,p:1},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(Q,{size:`small`,label:t(`admin.trigger.label`),value:e.label??``,onChange:e=>d(n,{label:e.target.value}),disabled:!r,sx:{minWidth:160}}),(0,F.jsx)(Q,{size:`small`,label:t(`admin.trigger.sourceState`),value:e.sourceState,onChange:e=>d(n,{sourceState:e.target.value}),disabled:!r,sx:{minWidth:260}}),(0,F.jsxs)(Q,{select:!0,size:`small`,label:t(`admin.trigger.mode`),value:e.mode??`condition`,onChange:e=>d(n,{mode:e.target.value}),disabled:!r,sx:{minWidth:200},children:[(0,F.jsx)(iC,{value:`condition`,children:t(`admin.trigger.modeCondition`)}),(0,F.jsx)(iC,{value:`user`,children:t(`admin.trigger.modeUser`)})]}),(e.mode??`condition`)===`condition`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Q,{size:`small`,label:t(`admin.trigger.condition`),helperText:t(`admin.trigger.conditionHint`),value:e.condition??``,onChange:e=>d(n,{condition:e.target.value}),disabled:!r,sx:{minWidth:170}}),(0,F.jsx)(Q,{select:!0,size:`small`,label:t(`admin.trigger.user`),value:e.userId===null||e.userId===void 0?``:String(e.userId),onChange:e=>d(n,{userId:e.target.value===``?null:Number(e.target.value)}),disabled:!r,sx:{minWidth:190},children:(o.data??[]).map(e=>(0,F.jsx)(iC,{value:String(e.id),children:e.displayName},e.id))})]}),(0,F.jsxs)(Q,{select:!0,size:`small`,label:t(`admin.trigger.action`),value:e.action??`punch`,onChange:e=>d(n,{action:e.target.value}),disabled:!r,sx:{minWidth:230},children:[(0,F.jsx)(iC,{value:`punch`,children:t(`admin.trigger.actionPunch`)}),(0,F.jsx)(iC,{value:`quickPunch`,children:t(`admin.trigger.actionQuickPunch`)}),(0,F.jsx)(iC,{value:`present`,children:t(`admin.trigger.actionPresent`)}),(0,F.jsx)(iC,{value:`absent`,children:t(`admin.trigger.actionAbsent`)})]}),(0,F.jsx)(Q,{size:`small`,type:`number`,label:t(`admin.trigger.cooldown`),value:String(e.cooldownSec??0),onChange:e=>d(n,{cooldownSec:Number(e.target.value)}),disabled:!r,sx:{maxWidth:140}}),(0,F.jsx)(dw,{checked:e.isActive!==!1,title:t(`admin.trigger.active`),onChange:()=>d(n,{isActive:e.isActive===!1}),disabled:!r}),(0,F.jsx)(vm,{size:`small`,title:t(`admin.tag.delete`),disabled:!r,onClick:()=>c(l.filter((e,t)=>t!==n)),children:(0,F.jsx)(zD,{fontSize:`small`})})]}),(0,F.jsx)(Y,{variant:`caption`,color:`text.secondary`,children:f(e)})]},e.id??`new-${n}`)),(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(UD,{}),disabled:!r,onClick:()=>c([...l,{sourceState:``,mode:`condition`,condition:`true`,action:`punch`,isActive:!0,cooldownSec:0}]),children:t(`admin.trigger.add`)}),(0,F.jsx)(X,{size:`small`,variant:`contained`,disabled:!r||u.isPending||s===null,onClick:()=>u.mutate(l),children:t(`common.save`)})]}),!a.isLoading&&l.length===0&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:t(`admin.trigger.empty`)})]})]})})]})}function ok({rules:e,runs:t,people:n,disabled:r,saving:i,onChange:a,onSave:o,language:s}){let{t:c}=wE(),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(!1),h=(t,n)=>{f(n?{...n}:{...e[t]}),m(n!==void 0),u(t)},g=e=>c(`admin.automation.kind${e.charAt(0).toUpperCase()}${e.slice(1)}`),_=e=>{let t=UO(s);return e.length>=7?c(`admin.automation.repeatDay`):e.map(e=>t.find(t=>t.value===e)?.label??String(e)).join(`, `)},v=e=>{let t=e.activeFrom?ME(e.activeFrom,s):``,n=e.activeUntil?ME(e.activeUntil,s):``;return t&&n?c(`admin.automation.validityRange`,{from:t,until:n}):t?c(`admin.automation.validityFrom`,{date:t}):n?c(`admin.automation.validityUntil`,{date:n}):``},b=(t,n)=>a(e.map((e,r)=>r===t?{...e,...n}:e)),x=()=>{l!==null&&d&&b(l,d),u(null),f(null)},S=e=>{let t=e??0;return`${String(Math.floor(t/60)).padStart(2,`0`)}:${String(t%60).padStart(2,`0`)}`},C=e=>{let t=/^(\d{1,2}):(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n>=0&&n<=23&&r>=0&&r<=59?n*60+r:null},w=e=>n.find(t=>t.id===e)?.displayName??`#${e}`;return(0,F.jsx)(Vv,{sx:{mb:2},"data-testid":`automation-rules`,children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:c(`admin.settings.automations`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:c(`admin.settings.automationsHint`)}),(0,F.jsxs)(Z,{spacing:1,children:[e.map((t,n)=>(0,F.jsxs)(ED,{primary:t.label?.trim()?t.label:g(t.kind),secondary:[g(t.kind),t.kind===`breakReminder`?`${c(`admin.automation.after`)} ${t.afterMinutes??360}`:S(t.atMinute),t.userId===null||t.userId===void 0?c(`admin.automation.allUsers`):w(t.userId),_(t.weekdays??[1,2,3,4,5,6,7]),c(t.repeat===`week`?`admin.automation.repeatWeek`:`admin.automation.repeatDay`),v(t)].filter(e=>e!==``).join(` · `),children:[(0,F.jsx)(X,{size:`small`,disabled:r,color:t.isActive===!1?`inherit`:`primary`,onClick:()=>b(n,{isActive:t.isActive===!1}),children:c(`admin.trigger.active`)}),(0,F.jsx)(X,{size:`small`,disabled:r,onClick:()=>h(n),children:c(`admin.automation.edit`)}),(0,F.jsx)(vm,{size:`small`,title:c(`admin.tag.delete`),disabled:r,onClick:()=>a(e.filter((e,t)=>t!==n)),children:(0,F.jsx)(zD,{fontSize:`small`})})]},t.id??`new-${n}`)),(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(UD,{}),disabled:r,onClick:()=>{let t={kind:`clockOut`,atMinute:1200,userId:null,weekdays:[1,2,3,4,5,6,7],repeat:`day`,isActive:!0,activeFrom:null,activeUntil:null};a([...e,t]),h(e.length,t)},children:c(`admin.automation.add`)}),(0,F.jsx)(X,{size:`small`,variant:`contained`,disabled:r||i,onClick:o,children:c(`admin.automation.save`)})]}),e.length===0&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:c(`admin.automation.empty`)})]}),(0,F.jsxs)(hb,{open:d!==null,onClose:()=>{u(null),f(null)},fullWidth:!0,maxWidth:`sm`,children:[(0,F.jsx)(Ib,{children:c(p?`admin.automation.newTitle`:`admin.automation.editTitle`)}),(0,F.jsx)(Db,{children:d&&(0,F.jsxs)(Z,{spacing:1.5,sx:{mt:1},children:[(0,F.jsx)(Q,{size:`small`,label:c(`admin.trigger.label`),value:d.label??``,onChange:e=>f({...d,label:e.target.value}),disabled:r,fullWidth:!0}),(0,F.jsxs)(Q,{select:!0,size:`small`,label:c(`admin.automation.kind`),value:d.kind,onChange:e=>f({...d,kind:e.target.value}),disabled:r,fullWidth:!0,children:[(0,F.jsx)(iC,{value:`clockIn`,children:c(`admin.automation.kindClockIn`)}),(0,F.jsx)(iC,{value:`clockOut`,children:c(`admin.automation.kindClockOut`)}),(0,F.jsx)(iC,{value:`missingPunch`,children:c(`admin.automation.kindMissingPunch`)}),(0,F.jsx)(iC,{value:`breakReminder`,children:c(`admin.automation.kindBreakReminder`)})]}),d.kind===`breakReminder`?(0,F.jsx)(Q,{size:`small`,type:`number`,label:c(`admin.automation.after`),value:String(d.afterMinutes??360),onChange:e=>f({...d,afterMinutes:Number(e.target.value)}),disabled:r,fullWidth:!0}):(0,F.jsx)(Q,{size:`small`,label:c(`admin.automation.at`),helperText:c(`admin.automation.atHint`),value:S(d.atMinute),onChange:e=>{let t=C(e.target.value);t!==null&&f({...d,atMinute:t})},disabled:r,fullWidth:!0}),(0,F.jsxs)(Q,{select:!0,size:`small`,label:c(`admin.automation.user`),value:d.userId===null||d.userId===void 0?``:String(d.userId),onChange:e=>f({...d,userId:e.target.value===``?null:Number(e.target.value)}),disabled:r,fullWidth:!0,children:[(0,F.jsx)(iC,{value:``,children:c(`admin.automation.allUsers`)}),n.map(e=>(0,F.jsx)(iC,{value:String(e.id),children:e.displayName},e.id))]}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:c(`admin.automation.weekdays`)}),(0,F.jsx)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:UO(s).map(e=>(0,F.jsx)(ex,{control:(0,F.jsx)(_y,{size:`small`,checked:d.weekdays?.includes(e.value)??!0,onChange:t=>f({...d,weekdays:WO(d.weekdays??[1,2,3,4,5,6,7],e.value,t.target.checked)}),disabled:r}),label:e.label},e.value))})]}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`center`,flexWrap:`wrap`},children:[(0,F.jsxs)(Q,{select:!0,size:`small`,label:c(`admin.automation.repeat`),value:d.repeat??`day`,onChange:e=>f({...d,repeat:e.target.value}),disabled:r,sx:{minWidth:190},children:[(0,F.jsx)(iC,{value:`day`,children:c(`admin.automation.repeatDay`)}),(0,F.jsx)(iC,{value:`week`,children:c(`admin.automation.repeatWeek`)})]}),(0,F.jsx)(X,{size:`small`,color:d.isActive===!1?`inherit`:`primary`,onClick:()=>f({...d,isActive:d.isActive===!1}),disabled:r,children:c(`admin.trigger.active`)})]}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,useFlexGap:!0,sx:{alignItems:`flex-start`,flexWrap:`wrap`},children:[(0,F.jsx)(Q,{size:`small`,type:`date`,label:c(`admin.automation.validFrom`),helperText:c(`admin.automation.validFromHint`),value:d.activeFrom??``,onChange:e=>f({...d,activeFrom:e.target.value||null}),disabled:r,sx:{minWidth:200},InputLabelProps:{shrink:!0}}),(0,F.jsx)(Q,{size:`small`,type:`date`,label:c(`admin.automation.validUntil`),helperText:c(`admin.automation.validUntilHint`),value:d.activeUntil??``,onChange:e=>f({...d,activeUntil:e.target.value||null}),disabled:r,sx:{minWidth:200},InputLabelProps:{shrink:!0}})]})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>{u(null),f(null)},children:c(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,onClick:x,disabled:d===null,children:c(`common.save`)})]})]}),t.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Y,{variant:`subtitle2`,sx:{mt:2},children:c(`admin.automation.runs`)}),(0,F.jsx)(eS,{dense:!0,children:t.map((e,t)=>(0,F.jsx)(hS,{disableGutters:!0,children:(0,F.jsx)(SS,{primary:`${qO(e.firedAt,s)} · ${w(e.userId)}`,secondary:e.action})},`${e.ruleId}-${e.userId}-${e.period}-${t}`))})]})]})})}function sk(e){return e===`type`?`admin.brand.imageType`:e===`tooLarge`?`admin.brand.imageTooLarge`:`admin.brand.imageUnreadable`}function ck({label:e,maxBytes:t,hint:n,onChange:r,disabled:i}){let{t:a,i18n:o}=wE(),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(``);return(0,F.jsxs)(Z,{spacing:1,children:[(0,F.jsxs)(X,{variant:`outlined`,component:`label`,disabled:i===!0,sx:{alignSelf:`flex-start`},children:[e,(0,F.jsx)(`input`,{hidden:!0,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,onChange:e=>{let n=e.target.files?.[0];e.target.value=``,n&&(c(null),u(``),RD(n,t).then(e=>{if(!e.ok){c(e.problem);return}r(e.image.dataUrl),e.image.resized&&u(a(`admin.brand.imageResized`,{size:GO(e.image.bytes,o.language)}))}))}})]}),n&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:n}),l&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:l}),s&&(0,F.jsx)(jm,{severity:`warning`,children:a(sk(s))})]})}function lk({label:e,value:t,maxBytes:n,onChange:r,disabled:i}){let{t:a}=wE();return(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,sx:{alignItems:{sm:`center`}},children:[(0,F.jsx)(ck,{label:e,maxBytes:n,onChange:r,disabled:i}),t!==``&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Ev,{component:`img`,src:t,alt:``,sx:{height:40,maxWidth:160,objectFit:`contain`,border:1,borderColor:`divider`}}),(0,F.jsx)(X,{color:`inherit`,title:a(`admin.settings.brandImageRemove`),disabled:i,onClick:()=>r(``),children:a(`admin.settings.brandImageRemove`)})]})]})}var uk={pause_mode:`admin.settings.pauseModeTitle`};function dk({settingKey:e,value:t,disabled:n,onChange:r,fullLine:i=!1}){let{t:a}=wE(),o=uk[e]??`admin.settings.setting.${e}`;return(0,F.jsx)(Q,{label:a(o,{defaultValue:e}),helperText:e,value:t,onChange:e=>r(e.target.value),disabled:n,size:`small`,fullWidth:!0,...i?{sx:{gridColumn:{xs:`auto`,md:`1 / -1`}}}:{}})}function fk({types:e,disabled:t,onSaved:n}){let{t:r}=wE(),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(null),f=ql({mutationFn:e=>$.saveAbsenceType({code:e.code.trim(),name:e.name.trim(),paid:e.paid,factor:e.factor,reduceVacation:e.reduceVacation,isActive:e.isActive,color:e.color??null}),onSuccess:()=>{a(null),n()},onError:e=>d(e.message)}),p=ql({mutationFn:e=>$.deleteAbsenceType(e.id),onSuccess:()=>{l(null),n()},onError:e=>d(e.message)}),m=e=>{d(null),s(e===void 0),a(e?{...e}:{id:0,userId:null,code:``,name:``,paid:!0,factor:100,reduceVacation:!1,isActive:!0})},h=e=>{let t=[e.paid?r(`admin.absenceTypes.paid`):`– ${r(`admin.absenceTypes.paid`)}`,`${r(`admin.absenceTypes.factor`)}: ${e.factor}`];return e.reduceVacation&&t.push(r(`admin.absenceTypes.reduceVacation`)),t.join(` · `)},g=(e,t)=>({...e,...t});return(0,F.jsxs)(Vv,{sx:{mb:2},children:[(0,F.jsxs)($v,{children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,F.jsx)(Y,{variant:`subtitle1`,sx:{flexGrow:1},children:r(`admin.absenceTypes.title`)}),(0,F.jsx)(X,{size:`small`,startIcon:(0,F.jsx)(UD,{}),disabled:t,onClick:()=>m(),children:r(`admin.absenceTypes.add`)})]}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{mb:1},children:r(`admin.absenceTypes.hint`)}),(0,F.jsx)(eS,{dense:!0,"data-testid":`absence-types`,children:e.map(e=>(0,F.jsxs)(ED,{primary:`${e.code} – ${e.name}${e.reduceVacation?` (${r(`absences.vacationTag`)})`:``}`,secondary:(0,F.jsxs)(F.Fragment,{children:[h(e),e.isActive&&(0,F.jsx)(Y,{component:`span`,variant:`caption`,sx:{display:`block`},children:r(`admin.absenceTypes.active`)})]}),children:[(0,F.jsx)(`span`,{"data-testid":`absence-type-color-${e.id}`,style:{width:14,height:14,borderRadius:`50%`,marginRight:6,display:`inline-block`,background:e.color??`transparent`,border:e.color?`none`:`1px solid rgba(128,128,128,0.6)`}}),(0,F.jsx)(vm,{size:`small`,disabled:t,"aria-label":r(`admin.absenceTypes.edit`),onClick:()=>m(e),children:(0,F.jsx)(BD,{fontSize:`small`})}),(0,F.jsx)(vm,{size:`small`,disabled:t,"aria-label":r(`admin.absenceTypes.remove`),"data-testid":`absence-type-remove-${e.id}`,onClick:()=>{d(null),l(e)},children:(0,F.jsx)(zD,{fontSize:`small`})})]},e.id))}),e.length===0&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:r(`admin.absenceTypes.empty`)}),(0,F.jsx)(Y,{variant:`caption`,color:`text.secondary`,children:r(`admin.absenceTypes.note`)})]}),(0,F.jsxs)(hb,{open:i!==null,onClose:()=>a(null),fullWidth:!0,maxWidth:`xs`,children:[(0,F.jsx)(Ib,{children:r(o?`admin.absenceTypes.newTitle`:`admin.absenceTypes.editTitle`)}),(0,F.jsx)(Db,{children:i&&(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(OD,{error:u}),(0,F.jsx)(Q,{label:r(`admin.absenceTypes.code`),value:i.code,size:`small`,inputProps:{maxLength:8},onChange:e=>a(g(i,{code:e.target.value}))}),(0,F.jsx)(Q,{label:r(`admin.absenceTypes.name`),value:i.name,size:`small`,onChange:e=>a(g(i,{name:e.target.value}))}),(0,F.jsx)(Q,{label:r(`admin.absenceTypes.factor`),value:String(i.factor),size:`small`,type:`number`,inputProps:{min:0,max:100,step:10},onChange:e=>a(g(i,{factor:Number(e.target.value)}))}),(0,F.jsx)(ex,{control:(0,F.jsx)(dw,{checked:i.paid,onChange:e=>a(g(i,{paid:e.target.checked}))}),label:r(`admin.absenceTypes.paid`)}),(0,F.jsx)(ex,{control:(0,F.jsx)(dw,{checked:i.reduceVacation,onChange:e=>a(g(i,{reduceVacation:e.target.checked}))}),label:r(`admin.absenceTypes.reduceVacation`)}),(0,F.jsx)(ex,{control:(0,F.jsx)(dw,{checked:i.isActive,onChange:e=>a(g(i,{isActive:e.target.checked}))}),label:r(`admin.absenceTypes.active`)}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,F.jsx)(Y,{variant:`body2`,sx:{flexGrow:1},children:r(`admin.absenceTypes.color`)}),(0,F.jsx)(`input`,{type:`color`,"data-testid":`absence-type-color`,value:i.color??`#607d8b`,onChange:e=>a(g(i,{color:e.target.value}))}),(0,F.jsx)(X,{size:`small`,"data-testid":`absence-type-color-clear`,disabled:i.color===null,onClick:()=>a(g(i,{color:null})),children:r(`admin.absenceTypes.colorClear`)})]})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>a(null),children:r(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,"data-testid":`absence-type-save`,disabled:f.isPending||!i||i.code.trim()===``||i.name.trim()===``,onClick:()=>i&&f.mutate(i),children:r(`common.save`)})]})]}),(0,F.jsxs)(hb,{open:c!==null,onClose:()=>l(null),fullWidth:!0,maxWidth:`xs`,children:[(0,F.jsx)(Ib,{children:r(`admin.absenceTypes.removeTitle`)}),(0,F.jsx)(Db,{children:(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(OD,{error:u}),(0,F.jsx)(Mb,{children:c?r(`admin.absenceTypes.removeConfirm`,{name:`${c.code} – ${c.name}`}):``})]})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>l(null),children:r(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,color:`error`,"data-testid":`absence-type-remove-save`,disabled:p.isPending,onClick:()=>c&&p.mutate(c),children:r(`admin.absenceTypes.remove`)})]})]})]})}function pk(){let{t:e,i18n:t}=wE(),{permissions:n}=pD(),r=mD(n,`settings.edit`),i=Tc(),a=Kl({queryKey:[`admin`,`settings`],queryFn:()=>$.settings()}),o=Kl({queryKey:[`admin`,`pauseRules`],queryFn:()=>$.pauseRules()}),s=Kl({queryKey:[`branding`],queryFn:()=>$.branding()}),[c,l]=(0,y.useState)({}),[u,d]=(0,y.useState)(null),f=u??o.data??[],p=ql({mutationFn:e=>$.savePauseRules(e),onSuccess:async()=>{d(null),await i.invalidateQueries({queryKey:[`admin`,`pauseRules`]})}}),m=Kl({queryKey:[`admin`,`users`],queryFn:()=>$.users()}),h=Kl({queryKey:[`admin`,`automations`],queryFn:()=>$.automationRules()}),g=Kl({queryKey:[`admin`,`automationRuns`],queryFn:()=>$.automationRuns()}),_=Kl({queryKey:[`absence-types`,`all`],queryFn:()=>$.absenceTypes(!0)}),[v,b]=(0,y.useState)(null),x=v??h.data??[],S=ql({mutationFn:e=>$.saveAutomationRules(e),onSuccess:async()=>{b(null),await i.invalidateQueries({queryKey:[`admin`,`automations`]}),await i.invalidateQueries({queryKey:[`admin`,`automationRuns`]})}}),C=ql({mutationFn:e=>$.updateSettings(e),onSuccess:async()=>{l({}),await i.invalidateQueries({queryKey:[`admin`,`settings`]}),await i.invalidateQueries({queryKey:[`branding`]})}});if(a.isLoading)return(0,F.jsx)(kD,{});let w=a.data??{},T=c.brand_logo??s.data?.logoUrl??``,E=c.brand_background??s.data?.backgroundUrl??``,D=(e,t)=>l(n=>({...n,[e]:t}));return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:a.error??s.error??C.error??o.error??p.error}),C.isSuccess&&(0,F.jsx)(jm,{severity:`success`,sx:{mb:2},children:e(`admin.settings.saved`)}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`admin.settings.branding`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:e(`admin.settings.brandingHint`)}),(0,F.jsxs)(Z,{spacing:2,children:[(0,F.jsx)(lk,{label:e(`admin.settings.brandLogo`),value:T,maxBytes:jD,onChange:e=>D(`brand_logo`,e),disabled:!r}),(0,F.jsx)(lk,{label:e(`admin.settings.brandBackground`),value:E,maxBytes:jD,onChange:e=>D(`brand_background`,e),disabled:!r}),(0,F.jsxs)(Z,{direction:`row`,spacing:2,sx:{alignItems:`center`},children:[(0,F.jsx)(Q,{label:e(`admin.settings.brandColor`),helperText:e(`admin.settings.brandColorHint`),value:c.brand_color??w.brand_color??``,onChange:e=>D(`brand_color`,e.target.value),disabled:!r,sx:{maxWidth:260}}),(c.brand_color??w.brand_color??``)!==``&&(0,F.jsx)(Ev,{sx:{width:32,height:32,borderRadius:1,border:1,borderColor:`divider`,bgcolor:c.brand_color??w.brand_color??`transparent`}})]}),(0,F.jsxs)(Z,{spacing:1,children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`admin.settings.brandColorPresets`)}),(0,F.jsxs)(Z,{direction:`row`,sx:{flexWrap:`wrap`,gap:1,alignItems:`center`},children:[FE.map(e=>(0,F.jsx)(X,{"aria-label":e,title:e,disabled:!r,onClick:()=>D(`brand_color`,e),sx:{minWidth:40,width:40,height:40,p:0,borderRadius:1,border:2,borderColor:(c.brand_color??w.brand_color??``).toLowerCase()===e?`primary.main`:`divider`,bgcolor:e,"&:hover":{bgcolor:e}}},e)),(0,F.jsx)(X,{color:`inherit`,title:e(`admin.settings.brandColorDefaultHint`),disabled:!r,onClick:()=>{D(`brand_color`,``),D(`brand_background`,``)},children:e(`admin.settings.brandColorDefault`)})]})]})]})]})}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsx)($v,{children:(0,F.jsx)(Q,{label:e(`admin.settings.fontPath`),helperText:e(`admin.settings.fontPathHint`),value:c.report_font_path??w.report_font_path??``,onChange:e=>D(`report_font_path`,e.target.value),disabled:!r,fullWidth:!0})})}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`admin.settings.advanced`)}),(0,F.jsxs)(Ev,{sx:{display:`grid`,gap:2,gridTemplateColumns:{xs:`1fr`,sm:`repeat(2, minmax(0, 1fr))`,md:`repeat(3, minmax(0, 1fr))`}},children:[Object.keys(w).filter(e=>!e.startsWith(`brand_`)&&!e.endsWith(`timezone`)).sort().map(e=>(0,F.jsx)(dk,{settingKey:e,value:c[e]??w[e]??``,disabled:!r,onChange:t=>D(e,t)},e)),Object.keys(w).filter(e=>e.endsWith(`timezone`)).map(e=>(0,F.jsx)(dk,{settingKey:e,value:c[e]??w[e]??``,disabled:!r,onChange:t=>D(e,t),fullLine:!0},e))]})]})}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`admin.settings.pauseRules`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:e(`admin.settings.pauseRulesHint`)}),(0,F.jsx)(JO,{rules:f,disabled:!r,saving:p.isPending,onChange:d,onSave:()=>p.mutate(f)})]})}),(0,F.jsx)(ok,{rules:x,runs:g.data??[],people:m.data??[],disabled:!r,saving:S.isPending,onChange:b,onSave:()=>S.mutate(x),language:t.language}),(0,F.jsx)(fk,{types:_.data??[],disabled:!mD(n,`absence.manage_types`),onSaved:()=>void i.invalidateQueries({queryKey:[`absence-types`]})}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`admin.settings.pauseMode`)}),(0,F.jsx)(Q,{select:!0,fullWidth:!0,label:e(`admin.settings.pauseModeTitle`),helperText:e(`admin.settings.pauseModeHint`),value:c.pause_mode??w.pause_mode??`auto`,onChange:e=>D(`pause_mode`,e.target.value),disabled:!r,children:[`auto`,`punched`,`staffel`].map(t=>(0,F.jsx)(iC,{value:t,children:e(`admin.settings.pauseMode.${t}`)},t))})]})}),(0,F.jsx)(X,{variant:`contained`,disabled:!r||Object.keys(c).length===0||C.isPending,onClick:()=>C.mutate(c),children:e(`common.save`)})]})}function mk({language:e}){let{t}=wE(),n=Tc(),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(``),l=(0,y.useRef)(null),u=Kl({queryKey:[`admin`,`backups`],queryFn:()=>$.backups()}),d=ql({mutationFn:()=>$.createBackup(),onSuccess:async()=>{await n.invalidateQueries({queryKey:[`admin`,`backups`]})}}),f=ql({mutationFn:e=>$.restoreBackup(e,s.trim()||void 0),onSuccess:async()=>{i(null),c(``),await n.invalidateQueries({queryKey:[`admin`,`backups`]})}}),p=ql({mutationFn:e=>$.downloadBackup(e),onSuccess:e=>XD(e.blob,e.fileName)}),m=ql({mutationFn:e=>$.uploadBackup(e),onSuccess:async()=>{await n.invalidateQueries({queryKey:[`admin`,`backups`]})}}),h=ql({mutationFn:e=>$.deleteBackup(e),onSuccess:async()=>{o(null),await n.invalidateQueries({queryKey:[`admin`,`backups`]})}});if(u.isLoading)return(0,F.jsx)(kD,{});let g=u.data?.pending??null;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:u.error??d.error??f.error??p.error??m.error??h.error}),g&&(0,F.jsx)(jm,{severity:`warning`,sx:{mb:2},children:t(`admin.backup.pendingHint`,{name:g.name,users:g.users,entries:g.entries})}),d.isSuccess&&(0,F.jsx)(jm,{severity:`success`,sx:{mb:2},children:t(`admin.backup.done`,{name:d.data.backup.name,removed:d.data.removed.length})}),(0,F.jsxs)(Ev,{sx:{mb:2},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,flexWrap:`wrap`,useFlexGap:!0,children:[(0,F.jsx)(X,{variant:`contained`,startIcon:d.isPending?(0,F.jsx)(My,{size:18}):(0,F.jsx)(cO,{}),disabled:d.isPending,onClick:()=>d.mutate(),children:t(`admin.backup.create`)}),(0,F.jsx)(X,{variant:`outlined`,startIcon:m.isPending?(0,F.jsx)(My,{size:18}):(0,F.jsx)(dO,{}),disabled:m.isPending,onClick:()=>l.current?.click(),children:t(`admin.backup.upload`)}),(0,F.jsx)(`input`,{ref:l,type:`file`,accept:`.sqlite,application/octet-stream`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&m.mutate(t)}})]}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:t(`admin.backup.uploadHint`)})]}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(u.data?.backups??[]).map(n=>(0,F.jsxs)(hS,{children:[(0,F.jsx)(SS,{primary:n.name,secondary:`${qO(n.createdAt,e)} · ${GO(n.sizeBytes,e)}`}),(0,F.jsxs)(Z,{direction:`row`,spacing:.5,alignItems:`center`,children:[p.isPending&&p.variables===n.name&&(0,F.jsx)(My,{size:16}),(0,F.jsx)(vm,{size:`small`,title:t(`admin.backup.download`),disabled:p.isPending,onClick:()=>p.mutate(n.name),children:(0,F.jsx)(lO,{fontSize:`small`})}),(0,F.jsx)(vm,{size:`small`,title:t(`admin.backup.restore`),disabled:f.isPending,onClick:()=>i(n.name),children:(0,F.jsx)(uO,{fontSize:`small`})}),(0,F.jsx)(vm,{size:`small`,title:t(`admin.backup.delete`),disabled:h.isPending,onClick:()=>o(n.name),children:(0,F.jsx)(zD,{fontSize:`small`})})]})]},n.name)),(u.data?.backups??[]).length===0&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{secondary:t(`admin.backup.empty`)})})]})}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{mt:2},children:t(`admin.backup.retention`,{days:u.data?.retentionDays??0})}),(0,F.jsxs)(hb,{open:r!==null,onClose:()=>i(null),children:[(0,F.jsx)(Ib,{children:t(`admin.backup.restoreTitle`)}),(0,F.jsxs)(Db,{children:[(0,F.jsx)(Mb,{sx:{mb:2},children:t(`admin.backup.restoreConfirm`,{name:r??``})}),(0,F.jsx)(Q,{fullWidth:!0,label:t(`corrections.reason`),helperText:t(`corrections.reasonHint`),value:s,onChange:e=>c(e.target.value)})]}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>i(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,disabled:f.isPending,onClick:()=>r&&f.mutate(r),children:t(`admin.backup.restore`)})]})]}),(0,F.jsxs)(hb,{open:a!==null,onClose:()=>o(null),children:[(0,F.jsx)(Ib,{children:t(`admin.backup.deleteTitle`)}),(0,F.jsx)(Db,{children:(0,F.jsx)(Mb,{children:t(`admin.backup.deleteConfirm`,{name:a??``})})}),(0,F.jsxs)(bb,{children:[(0,F.jsx)(X,{onClick:()=>o(null),children:t(`common.cancel`)}),(0,F.jsx)(X,{variant:`contained`,color:`error`,disabled:h.isPending,onClick:()=>a&&h.mutate(a),children:t(`admin.backup.delete`)})]})]})]})}function hk(){let{t:e,i18n:t}=wE(),{permissions:n}=pD(),[r,i]=(0,y.useState)(0),a=[];if(mD(n,`user.view`)&&a.push({label:e(`admin.users`),render:()=>(0,F.jsx)(XO,{language:t.language})}),mD(n,`time.edit_other`)&&a.push({label:e(`admin.corrections`),render:()=>(0,F.jsx)(iO,{language:t.language})}),mD(n,`absence.approve`)&&a.push({label:e(`admin.absences.title`),render:()=>(0,F.jsx)(sO,{language:t.language})}),mD(n,`terminal.manage`)&&a.push({label:e(`admin.terminals`),render:()=>(0,F.jsx)(ek,{language:t.language})}),mD(n,`settings.view`)&&a.push({label:e(`admin.settings`),render:()=>(0,F.jsx)(pk,{})}),mD(n,`holiday.manage`)&&a.push({label:e(`admin.holidays`),render:()=>(0,F.jsx)(nk,{language:t.language})}),mD(n,`rfid.manage`)&&a.push({label:e(`admin.tags`),render:()=>(0,F.jsx)(ik,{language:t.language})}),mD(n,`settings.view`)&&a.push({label:e(`admin.triggers`),render:()=>(0,F.jsx)(ak,{language:t.language})}),mD(n,`backup.run`)&&a.push({label:e(`admin.backup`),render:()=>(0,F.jsx)(mk,{language:t.language})}),a.length===0)return(0,F.jsx)(TD,{title:e(`admin.title`),children:(0,F.jsx)(jm,{severity:`info`,children:e(`admin.forbidden`)})});let o=Math.min(r,a.length-1);return(0,F.jsxs)(TD,{title:e(`admin.title`),children:[(0,F.jsx)(Yw,{value:o,onChange:(e,t)=>i(t),variant:`scrollable`,scrollButtons:`auto`,allowScrollButtonsMobile:!0,sx:{mb:2},children:a.map(e=>(0,F.jsx)(_w,{label:e.label},e.label))}),a[o]?.render()]})}var gk=ep((0,F.jsx)(`path`,{d:`M11 7 9.6 8.4l2.6 2.6H2v2h10.2l-2.6 2.6L11 17l5-5zm9 12h-8v2h8c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-8v2h8z`}),`Login`),_k=ep((0,F.jsx)(`path`,{d:`m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z`}),`Logout`);function vk(){let{t:e,i18n:t}=wE(),{session:n,permissions:r}=pD(),{pending:i,record:a,outcome:o}=xD(),s=Tc(),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(!1),f=mD(r,`time.punch`),p=n?.user.timezone??`UTC`,m=Kl({queryKey:[`status`],queryFn:()=>$.status(),enabled:f});(0,y.useEffect)(()=>{o&&s.invalidateQueries({queryKey:[`status`]})},[o,s]);function h(e){a({tsUtc:Math.floor(Date.now()/1e3),...c?{note:c}:{},quick:e}),l(``),d(!0)}let g=m.data,_=g?.hasOpenEntry??!1;return f?(0,F.jsxs)(TD,{title:e(`nav.dashboard`),children:[(0,F.jsx)(OD,{error:m.error}),u&&i.length>0&&(0,F.jsx)(jm,{severity:`warning`,children:e(`punch.queued`)}),(0,F.jsx)(Vv,{sx:{mb:3},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,component:`p`,gutterBottom:!0,children:_?e(`punch.open`,{time:jE(g?.lastEntry?.tsUtc??null,p,t.language)}):e(`punch.closed`)}),g?.lastEntry&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:e(`punch.last`,{time:jE(g.lastEntry.tsUtc,p,t.language)})}),(0,F.jsxs)(Z,{spacing:2,sx:{mt:2},children:[(0,F.jsx)(Q,{label:e(`punch.note`),value:c,size:`small`,onChange:e=>l(e.target.value)}),(0,F.jsx)(X,{variant:`contained`,size:`large`,startIcon:g?.nextDirection===`out`?(0,F.jsx)(_k,{}):(0,F.jsx)(gk,{}),disabled:m.isLoading,onClick:()=>h(!1),children:g?.nextDirection===`out`?e(`punch.out`):e(`punch.in`)}),(0,F.jsx)(X,{variant:`outlined`,onClick:()=>h(!0),disabled:m.isLoading,children:e(`punch.quick`)})]})]})}),(0,F.jsxs)(Nx,{container:!0,spacing:2,children:[(0,F.jsx)(Nx,{item:!0,xs:12,sm:4,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`punch.worked`)}),(0,F.jsx)(Y,{variant:`h5`,children:AE(g?.day.workedMin??0)})]})})}),(0,F.jsx)(Nx,{item:!0,xs:12,sm:4,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`punch.target`)}),(0,F.jsx)(Y,{variant:`h5`,children:AE(g?.day.targetMin??0)})]})})}),(0,F.jsx)(Nx,{item:!0,xs:12,sm:4,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`punch.balance`)}),(0,F.jsx)(Y,{variant:`h5`,color:(g?.day.balanceMin??0)<0?`error`:`text.primary`,children:AE(g?.day.balanceMin??0)})]})})})]}),(0,F.jsx)(Ev,{sx:{mt:2},children:(0,F.jsx)(X,{variant:`text`,onClick:()=>void m.refetch(),disabled:m.isFetching,children:e(`common.refresh`)})})]}):(0,F.jsx)(TD,{title:e(`nav.dashboard`),children:(0,F.jsx)(Vv,{children:(0,F.jsx)($v,{children:(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`dashboard.adminOnly`)})})})})}function yk(){let{t:e}=wE(),{signIn:t}=pD(),n=zE(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1);async function d(e){e.preventDefault(),u(!0),c(null);try{await t(r.trim(),a)}catch(e){c(e)}finally{u(!1)}}return(0,F.jsx)(Ev,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,minHeight:`100vh`,p:2},children:(0,F.jsx)(Vv,{sx:{width:`100%`,maxWidth:420},children:(0,F.jsxs)($v,{children:[n.logoUrl&&(0,F.jsx)(Ev,{component:`img`,src:n.logoUrl,alt:``,sx:{display:`block`,maxHeight:64,maxWidth:`100%`,mb:2}}),(0,F.jsx)(Y,{variant:`h5`,component:`h1`,gutterBottom:!0,children:e(`app.title`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:e(`login.title`)}),(0,F.jsx)(Ev,{component:`form`,onSubmit:e=>void d(e),sx:{mt:2},children:(0,F.jsxs)(Z,{spacing:2,children:[(0,F.jsx)(Q,{label:e(`login.login`),value:r,autoComplete:`username`,autoFocus:!0,required:!0,onChange:e=>i(e.target.value)}),(0,F.jsx)(Q,{label:e(`login.password`),type:`password`,value:a,autoComplete:`current-password`,required:!0,onChange:e=>o(e.target.value)}),l?(0,F.jsx)(jm,{severity:`info`,children:e(`login.failed`)}):(0,F.jsx)(OD,{error:s}),(0,F.jsx)(X,{type:`submit`,variant:`contained`,size:`large`,disabled:l,children:e(`login.submit`)})]})})]})})})}function bk(){let{t:e}=wE(),{session:t,signOut:n}=pD(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1);async function d(){o(!0),c(null);try{await $.changePassword(r),u(!0);try{await n()}catch{}}catch(e){c(e)}finally{o(!1)}}return(0,F.jsx)(Ev,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,minHeight:`100vh`,p:2},children:(0,F.jsx)(Vv,{sx:{maxWidth:420,width:`100%`},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`profile.changePassword`)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,gutterBottom:!0,children:t?.user.login}),l?(0,F.jsx)(jm,{severity:`success`,children:e(`profile.changed`)}):(0,F.jsxs)(Z,{spacing:2,sx:{mt:1},children:[(0,F.jsx)(Q,{type:`password`,label:e(`profile.newPassword`),helperText:e(`admin.user.passwordHint`),value:r,onChange:e=>i(e.target.value),autoComplete:`new-password`,fullWidth:!0}),(0,F.jsx)(OD,{error:s}),(0,F.jsx)(X,{variant:`contained`,disabled:a||r.length===0,onClick:()=>void d(),children:e(`profile.changePassword`)})]})]})})})}var xk=ep((0,F.jsx)(`path`,{d:`M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z`}),`Refresh`),Sk=ep([(0,F.jsx)(`path`,{d:`M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8`},`0`),(0,F.jsx)(`path`,{d:`M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z`},`1`)],`Schedule`);function Ck(e){return e instanceof DE&&e.status===401&&(e.code===`no_session`||e.code===`invalid_credentials`)}function wk(e){return $.terminalSession(e)}async function Tk(e){try{return await e.call(e.session)}catch(t){if(!Ck(t))throw t;let n=await wk(e.deviceToken);return e.onRenewed?.(n),e.call(n)}}var Ek=ep((0,F.jsx)(`path`,{d:`M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16H7.07L2.4 12l4.66-7H22zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z`}),`BackspaceOutlined`),Dk=[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,``,`0`];function Ok({onDigit:e,onBackspace:t,disabled:n=!1}){let{t:r}=wE(),i=e=>e.preventDefault();return(0,F.jsxs)(Ev,{sx:{display:`grid`,gridTemplateColumns:`repeat(3, 1fr)`,gap:1,width:`100%`,maxWidth:260},children:[Dk.map(t=>t===``?(0,F.jsx)(Ev,{},`blank`):(0,F.jsx)(X,{variant:`outlined`,size:`large`,disabled:n,"aria-label":t,onMouseDown:i,onClick:()=>e(t),sx:{minHeight:56,fontSize:`1.4rem`},children:t},t)),(0,F.jsx)(X,{variant:`outlined`,size:`large`,disabled:n,"aria-label":r(`keypad.backspace`),onMouseDown:i,onClick:t,sx:{minHeight:56},children:(0,F.jsx)(Ek,{})})]})}var kk=`time-tracker.presence`,Ak=2e4,jk=3e5,Mk=8e3;function Nk(){let e=new URLSearchParams(window.location.search).get(`token`);if(e?.trim()){try{window.localStorage.setItem(kk,e.trim())}catch{}return e.trim()}try{return window.localStorage.getItem(kk)}catch{return null}}function Pk(){let{t:e,i18n:t}=wE(),[n,r]=(0,y.useState)(()=>Nk()),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(`UTC`),[T,E]=(0,y.useState)(Math.floor(Date.now()/1e3)),D=(0,y.useRef)(0),O=zE(),k=(0,y.useCallback)(()=>{try{window.localStorage.removeItem(kk)}catch{}r(null)},[]);(0,y.useEffect)(()=>{(async()=>{try{let e=await $.terminalStatus();b(e.enabled),w(e.timezone),D.current=e.serverTime-Math.floor(Date.now()/1e3)}catch(e){_(e)}})()},[]),(0,y.useEffect)(()=>{let e=window.setInterval(()=>E(Math.floor(Date.now()/1e3)+D.current),1e3);return()=>window.clearInterval(e)},[]),(0,y.useEffect)(()=>{if(!n){s(null);return}(async()=>{try{let e=await $.terminalSession(n);s(e),_(null)}catch(e){s(null),_(e)}})()},[n]);let A=(0,y.useCallback)(async()=>{if(o&&n)try{let e=await Tk({deviceToken:n,session:o,call:e=>$.terminalUsers(e.terminalSession),onRenewed:s});l(e.users),_(null)}catch(e){_(e)}},[o,n]);(0,y.useEffect)(()=>{A();let e=window.setInterval(()=>void A(),Ak);return()=>window.clearInterval(e)},[A]),(0,y.useEffect)(()=>{if(!o||!n)return;let e=window.setInterval(()=>{$.terminalHeartbeat(o.terminalSession).catch(async()=>{try{s(await wk(n))}catch(e){_(e),k()}})},jk);return()=>window.clearInterval(e)},[o,n,k]),(0,y.useEffect)(()=>{if(!m)return;let e=window.setTimeout(()=>h(null),Mk);return()=>window.clearTimeout(e)},[m]);let j=(0,y.useCallback)(async()=>{let e=o?.terminal.pinRequired===!0;if(o&&n&&u&&(!e||f.length!==0)){S(!0);try{let e=await Tk({deviceToken:n,session:o,call:e=>$.terminalPunch({terminalSession:e.terminalSession,userId:u.id,...f?{pin:f}:{}}),onRenewed:s});h(e),l(t=>t.map(t=>t.id===e.user.id?{...t,present:e.day.hasOpenEntry,workedMin:e.day.workedMin??t.workedMin}:t)),d(null),p(``),_(null)}catch(e){_(e)}finally{S(!1)}}},[f,u,o,n]);return n?(0,F.jsxs)(Ev,{sx:{p:2},children:[(0,F.jsxs)(Z,{direction:`row`,justifyContent:`space-between`,alignItems:`baseline`,sx:{mb:2},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[O.logoUrl&&(0,F.jsx)(Ev,{component:`img`,src:O.logoUrl,alt:``,sx:{height:28,maxWidth:120,objectFit:`contain`}}),(0,F.jsx)(Y,{variant:`h5`,children:e(`presence.title`)})]}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,children:[(0,F.jsx)(Y,{variant:`h5`,children:jE(T,C,t.language)}),(0,F.jsx)(Y,{variant:`body1`,children:o?.terminal.name??``}),(0,F.jsx)(vm,{size:`small`,title:e(`common.refresh`),"aria-label":e(`common.refresh`),onClick:()=>void A(),children:(0,F.jsx)(xk,{fontSize:`small`})})]})]}),v===!1&&(0,F.jsx)(jm,{severity:`warning`,sx:{mb:2},children:e(`presence.disabled`)}),(0,F.jsx)(OD,{error:g}),m&&(0,F.jsx)(jm,{severity:`success`,sx:{mb:2},children:e(`presence.updated`,{name:m.user.displayName,state:e(m.day.hasOpenEntry?`presence.present`:`presence.absent`)})}),(0,F.jsx)(Ev,{sx:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(240px, 1fr))`,gap:1.5},children:c.map(t=>(0,F.jsx)(Vv,{variant:`outlined`,sx:{borderWidth:t.present?2:1,borderColor:t.present?`success.main`:`divider`,bgcolor:t.present?`success.light`:`background.paper`},children:(0,F.jsx)(Jv,{onClick:()=>{d(t),p(``)},children:(0,F.jsxs)(Z,{direction:`row`,spacing:1.5,alignItems:`center`,sx:{px:1.5,py:.5},children:[(0,F.jsx)(J_,{src:t.avatarUrl??`/person.png`,sx:{width:56,height:56,bgcolor:t.present?`success.main`:`grey.500`},children:Fk(t.displayName)}),(0,F.jsxs)(Ev,{sx:{minWidth:0,flexGrow:1},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:.5,sx:{alignItems:`center`},children:[(0,F.jsx)(u_,{size:`small`,color:t.present?`success`:`default`,label:e(t.present?`presence.present`:`presence.absent`)}),t.workedMin!==void 0&&(0,F.jsx)(u_,{size:`small`,variant:`outlined`,icon:(0,F.jsx)(Sk,{fontSize:`small`}),label:AE(t.workedMin),title:e(`presence.workedToday`)})]}),(0,F.jsx)(Y,{variant:`subtitle1`,noWrap:!0,sx:{lineHeight:1.3},children:t.displayName})]})]})})},t.id))}),u&&(0,F.jsx)(Vv,{sx:{mt:2},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:u.displayName}),(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,children:[o?.terminal.pinRequired===!1?(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{alignSelf:`center`},children:e(`terminal.noPin`)}):(0,F.jsx)(Q,{label:e(`terminal.pin`),type:`password`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()},helperText:e(`presence.tapPin`),autoFocus:!0,fullWidth:!0}),o?.terminal.pinRequired===!1?null:(0,F.jsx)(Ok,{onDigit:e=>p(t=>t+e),onBackspace:()=>p(e=>e.slice(0,-1)),disabled:x}),(0,F.jsx)(X,{variant:`contained`,size:`large`,disabled:x||o?.terminal.pinRequired===!0&&f.length===0,onClick:()=>void j(),children:e(`punch.now`)}),(0,F.jsx)(X,{variant:`text`,size:`large`,onClick:()=>{d(null),p(``)},children:e(`presence.cancel`)})]})]})})]}):(0,F.jsxs)(Ev,{sx:{p:2,maxWidth:480,mx:`auto`},children:[(0,F.jsx)(Y,{variant:`h5`,gutterBottom:!0,children:e(`presence.title`)}),(0,F.jsx)(OD,{error:g}),(0,F.jsx)(Q,{label:e(`terminal.deviceToken`),value:i,onChange:e=>a(e.target.value),fullWidth:!0,sx:{mt:1}}),(0,F.jsx)(X,{variant:`contained`,size:`large`,sx:{mt:2},disabled:i.trim().length===0,onClick:()=>r(i.trim()),children:e(`terminal.connect`)})]})}function Fk(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[t.length-1][0]}`.toUpperCase()}function Ik(){let{t:e,i18n:t}=wE(),{session:n,permissions:r}=pD(),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null);async function u(e){e.preventDefault(),l(null);try{await $.changePassword(i),s(!0),a(``)}catch(e){l(e)}}return(0,F.jsxs)(TD,{title:e(`profile.title`),children:[(0,F.jsx)(Vv,{sx:{mb:3},children:(0,F.jsx)($v,{children:(0,F.jsxs)(Z,{spacing:1,children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`profile.user`)}),(0,F.jsx)(Y,{variant:`h6`,children:n?.user.displayName??n?.user.login}),(0,F.jsxs)(Y,{variant:`body2`,color:`text.secondary`,children:[n?.user.login,` · `,n?.user.timezone]}),(0,F.jsx)(Q,{select:!0,label:e(`profile.language`),size:`small`,value:t.language,onChange:e=>void t.changeLanguage(e.target.value),sx:{maxWidth:240,mt:1},children:oD.map(e=>(0,F.jsx)(iC,{value:e,children:e},e))}),(0,F.jsxs)(Ev,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`profile.roles`)}),(0,F.jsx)(Y,{variant:`body2`,children:r.join(`, `)||e(`common.none`)})]})]})})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`profile.changePassword`)}),o&&(0,F.jsx)(jm,{severity:`success`,children:e(`profile.changed`)}),(0,F.jsx)(OD,{error:c}),(0,F.jsx)(Ev,{component:`form`,onSubmit:e=>void u(e),children:(0,F.jsxs)(Z,{spacing:2,children:[(0,F.jsx)(Q,{label:e(`profile.newPassword`),type:`password`,value:i,autoComplete:`new-password`,required:!0,size:`small`,onChange:e=>a(e.target.value)}),(0,F.jsx)(X,{type:`submit`,variant:`contained`,children:e(`profile.changePassword`)})]})})]})})]})}function Lk(){let{t:e,i18n:t}=wE(),[n,r]=(0,y.useState)(()=>new Date().getFullYear()),[i,a]=(0,y.useState)(void 0),{permissions:o,session:s}=pD(),c=mD(o,`payout.view`),l=mD(o,`report.view_other`)&&mD(o,`user.view`),u=Kl({queryKey:[`employees`],queryFn:()=>$.users(),enabled:l}),d=Kl({queryKey:[`months`,n,i],queryFn:()=>$.months(n,i)}),f=Kl({queryKey:[`payouts`,n],queryFn:()=>$.payouts(n),enabled:c&&i===void 0,retry:!1}),p=d.data?.months??[],m=i===void 0?``:(u.data??[]).find(e=>e.id===i)?.displayName??``,h=e=>new Intl.DateTimeFormat(t.language,{month:`long`,timeZone:`UTC`}).format(new Date(Date.UTC(n,e-1,15)));return(0,F.jsxs)(TD,{title:e(`reports.title`),children:[(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)(Z,{direction:`row`,alignItems:`center`,justifyContent:`space-between`,sx:{p:1},children:[(0,F.jsx)(vm,{onClick:()=>r(e=>e-1),title:e(`month.previous`),children:(0,F.jsx)(tT,{})}),(0,F.jsxs)(Y,{variant:`h6`,children:[e(`reports.year`),` `,n]}),(0,F.jsx)(vm,{onClick:()=>r(e=>e+1),title:e(`month.next`),children:(0,F.jsx)(nT,{})})]})}),l&&(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsx)($v,{children:(0,F.jsxs)(Q,{select:!0,fullWidth:!0,size:`small`,label:e(`statistics.employee`),value:i??``,onChange:e=>a(e.target.value===``?void 0:Number(e.target.value)),children:[(0,F.jsx)(iC,{value:``,children:s?.user.displayName??e(`profile.user`)}),(u.data??[]).filter(e=>e.isActive).map(e=>(0,F.jsx)(iC,{value:e.id,children:e.displayName},e.id))]})})}),(0,F.jsx)(OD,{error:d.error}),d.isLoading?(0,F.jsx)(kD,{}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(Nx,{container:!0,spacing:2,sx:{mb:2},children:[(0,F.jsx)(Nx,{item:!0,xs:6,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.yearTotals`)}),(0,F.jsx)(Y,{variant:`h5`,children:AE(d.data?.year.workedMin??0)}),(0,F.jsxs)(Y,{variant:`body2`,color:`text.secondary`,children:[e(`month.target`),`: `,AE(d.data?.year.targetMin??0)]})]})})}),(0,F.jsx)(Nx,{item:!0,xs:6,children:(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.overtime`)}),(0,F.jsx)(Y,{variant:`h5`,color:(d.data?.year.overtimeMin??0)<0?`error`:`text.primary`,children:AE(d.data?.year.overtimeMin??0)}),(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.vacation`,{used:d.data?.year.vacationUsed??0,total:(d.data?.year.vacationCarryover??0)+(d.data?.year.vacationDays??0)})}),c&&i===void 0&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.paidOut`,{minutes:AE(f.data?.totalMinutes??0)})})]})})})]}),(0,F.jsxs)(Vv,{children:[(0,F.jsx)(eS,{dense:!0,children:p.map((t,r)=>(0,F.jsxs)(hS,{sx:{"& .MuiListItemText-root":{minWidth:0}},children:[(0,F.jsx)(SS,{primary:i===void 0?h(r+1):(0,F.jsx)(Y,{component:Lf,to:`/month?year=${n}&month=${r+1}&userId=${i}&name=${encodeURIComponent(m)}`,title:e(`month.title`),sx:{color:`primary.main`,textDecoration:`none`,"&:hover":{textDecoration:`underline`}},children:h(r+1)}),secondary:t?`${e(`month.worked`)} ${AE(t.workedMin)} · ${e(`month.target`)} ${AE(t.targetMin)}`:e(`reports.empty`)}),(0,F.jsxs)(Z,{direction:`row`,spacing:1,alignItems:`center`,sx:{flexShrink:0},children:[(0,F.jsx)(Y,{variant:`body2`,color:(t?.balanceMin??0)<0?`error`:`text.secondary`,children:AE(t?.balanceMin??0)}),t&&(0,F.jsx)(ZD,{year:n,month:r+1,userId:i,compact:!0})]})]},r))}),p.length===0&&(0,F.jsx)(Ev,{sx:{p:2},children:(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`reports.empty`)})})]})]})]})}function Rk(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-01`}function zk(){let e=new Date,t=new Date(e.getFullYear(),e.getMonth()+1,0);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Bk(e,t){return new Intl.NumberFormat(t,{style:`unit`,unit:`hour`,maximumFractionDigits:2}).format(e/60)}function Vk(){let{t:e,i18n:t}=wE(),[n,r]=(0,y.useState)(Rk),[i,a]=(0,y.useState)(zk),o=/^\d{4}-\d{2}-\d{2}$/.test(n)&&/^\d{4}-\d{2}-\d{2}$/.test(i)&&n<=i,s=Kl({queryKey:[`statistics`,n,i],queryFn:()=>$.statistics(n,i),enabled:o});if(s.isLoading)return(0,F.jsx)(TD,{title:e(`nav.statistics`),children:(0,F.jsx)(kD,{})});let c=(n,r,i,a)=>`${e(`statistics.worked`)} ${Bk(n,t.language)} · ${e(`statistics.target`)} ${Bk(r,t.language)} · ${e(`statistics.balance`)} ${Bk(i,t.language)} · ${e(`statistics.openDays`)} ${a}`,l=s.data?.totals;return(0,F.jsxs)(TD,{title:e(`nav.statistics`),children:[(0,F.jsx)(OD,{error:s.error}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsx)($v,{children:(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,children:[(0,F.jsx)(Q,{label:e(`statistics.from`),value:n,onChange:e=>r(e.target.value)}),(0,F.jsx)(Q,{label:e(`statistics.to`),value:i,onChange:e=>a(e.target.value)})]})})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)(eS,{dense:!0,children:[(s.data?.users??[]).map(e=>(0,F.jsx)(hS,{divider:!0,children:(0,F.jsx)(SS,{primary:e.displayName,secondary:c(e.workedMin,e.targetMin,e.balanceMin,e.openDays)})},e.userId)),l&&(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{primary:(0,F.jsx)(Y,{variant:`body1`,sx:{fontWeight:600},children:e(`statistics.totals`)}),secondary:c(l.workedMin,l.targetMin,l.balanceMin,l.openDays)})})]})})]})}function Hk(){let{t:e,i18n:t}=wE(),{session:n,permissions:r}=pD(),{pending:i,flush:a,busy:o,outcome:s}=xD(),c=Tc(),l=n?.user.timezone??`UTC`,u=mD(r,`time.resolve_conflict`),d=Kl({queryKey:[`conflicts`],queryFn:()=>$.conflicts(),enabled:u,retry:!1}),f=ql({mutationFn:e=>$.resolve(e.entryId,e.action),onSuccess:()=>void c.invalidateQueries({queryKey:[`conflicts`]})});return(0,F.jsxs)(TD,{title:e(`sync.title`),children:[(0,F.jsx)(Vv,{sx:{mb:3},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:i.length>0?e(`sync.pending`,{count:i.length}):e(`sync.none`)}),s&&(0,F.jsx)(jm,{severity:`success`,sx:{mt:1},children:e(`sync.done`,{accepted:s.accepted,duplicates:s.duplicates,conflicts:s.conflicts})}),(0,F.jsx)(Z,{spacing:2,sx:{mt:2},children:(0,F.jsx)(X,{variant:`contained`,disabled:o||i.length===0,onClick:()=>void a(),children:e(`sync.flush`)})}),i.length>0&&(0,F.jsx)(eS,{dense:!0,children:i.map(e=>(0,F.jsx)(hS,{children:(0,F.jsx)(SS,{primary:jE(e.tsUtc,l,t.language),secondary:e.note??void 0})},e.idempotencyKey))})]})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`sync.conflicts`)}),u?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(OD,{error:d.error}),f.error&&(0,F.jsx)(OD,{error:f.error}),(d.data??[]).length===0?(0,F.jsx)(Ev,{children:(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`sync.empty`)})}):(0,F.jsx)(eS,{dense:!0,children:(d.data??[]).map(n=>(0,F.jsxs)(ED,{primary:e(`sync.conflictOf`,{date:n.localDate,time:jE(n.tsUtc,l,t.language)}),secondary:n.note??void 0,children:[(0,F.jsx)(X,{size:`small`,onClick:()=>f.mutate({entryId:n.entryId??n.id,action:`accept`}),children:e(`sync.accept`)}),(0,F.jsx)(X,{size:`small`,color:`warning`,onClick:()=>f.mutate({entryId:n.entryId??n.id,action:`dismiss`}),children:e(`sync.dismiss`)})]},n.id))})]}):(0,F.jsx)(jm,{severity:`info`,children:e(`sync.permission`)})]})})]})}var Uk=`time-tracker.scan`;function Wk(){let e=new URLSearchParams(window.location.search),t=e.get(`tag`);if(t?.trim()){try{window.sessionStorage.setItem(Uk,t.trim())}catch{}e.delete(`tag`);let n=e.toString();return window.history.replaceState(null,``,`${window.location.pathname}${n?`?${n}`:``}`),t.trim()}try{return window.sessionStorage.getItem(Uk)}catch{return null}}function Gk(){let{t:e,i18n:t}=wE(),n=(0,y.useRef)(Wk()),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(!1);(0,y.useEffect)(()=>{s||(c(!0),(async()=>{try{i(await $.scanTag(n.current??``))}catch(e){o(e)}})())},[s]);let l=Intl.DateTimeFormat().resolvedOptions().timeZone;return(0,F.jsx)(Ev,{sx:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,p:2},children:(0,F.jsx)(Vv,{sx:{maxWidth:520,width:`100%`},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`scan.title`)}),!r&&!a&&(0,F.jsxs)(Ev,{sx:{display:`flex`,gap:2,alignItems:`center`},children:[(0,F.jsx)(My,{size:20}),(0,F.jsx)(Y,{children:e(`common.loading`)})]}),r&&(0,F.jsx)(jm,{severity:`success`,children:e(`scan.done`,{name:r.user?.displayName??``,time:jE(r.entry?.tsUtc??null,l,t.language)})}),a?(0,F.jsx)(jm,{severity:`error`,children:e(`scan.failed`,{reason:e(DD(a))})}):null,(0,F.jsx)(X,{sx:{mt:2},variant:`contained`,href:`/`,children:e(`nav.dashboard`)})]})})})}var Kk=`time-tracker.terminal`,qk=8e3,Jk=3e5;function Yk(){let e=new URLSearchParams(window.location.search).get(`token`);if(e?.trim()){try{window.localStorage.setItem(Kk,e.trim())}catch{}return e.trim()}try{return window.localStorage.getItem(Kk)}catch{return null}}function Xk(){let{t:e,i18n:t}=wE(),[n,r]=(0,y.useState)(()=>Yk()),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(``),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(null),[C,w]=(0,y.useState)(`UTC`),[T,E]=(0,y.useState)(Math.floor(Date.now()/1e3)),D=(0,y.useRef)(0),O=zE(),k=(0,y.useCallback)(()=>{try{window.localStorage.removeItem(Kk)}catch{}r(null)},[]);(0,y.useEffect)(()=>{(async()=>{try{let e=await $.terminalStatus();S(e.enabled),w(e.timezone),D.current=e.serverTime-Math.floor(Date.now()/1e3)}catch(e){b(e),S(!1)}})()},[]),(0,y.useEffect)(()=>{let e=window.setInterval(()=>E(Math.floor(Date.now()/1e3)+D.current),1e3);return()=>window.clearInterval(e)},[]),(0,y.useEffect)(()=>{n&&x===!0&&(async()=>{try{let e=await $.terminalSession(n);s(e);let t=await $.terminalUsers(e.terminalSession);l(t.users)}catch(e){b(e),k()}})()},[n,x,k]),(0,y.useEffect)(()=>{if(!o||!n)return;let e=window.setInterval(()=>{$.terminalHeartbeat(o.terminalSession).catch(async()=>{try{s(await wk(n))}catch{k()}})},Jk);return()=>window.clearInterval(e)},[o,n,k]);let A=(0,y.useCallback)(async e=>{if(o&&n){b(null);try{let t=await Tk({deviceToken:n,session:o,call:t=>$.terminalPunch({terminalSession:t.terminalSession,...e}),onRenewed:s});_(t),d(null),p(``),h(``),window.setTimeout(()=>_(null),qk)}catch(e){b(e)}}},[o,n]);return x===null?(0,F.jsx)(Ev,{sx:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`},children:(0,F.jsx)(Y,{children:e(`common.loading`)})}):x===!0?n?o?g?(0,F.jsx)(Ev,{sx:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,p:2},children:(0,F.jsx)(Vv,{sx:{maxWidth:560,width:`100%`},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h4`,gutterBottom:!0,children:g.user.displayName}),(0,F.jsx)(jm,{severity:`success`,children:`${e(g.entry.direction===`out`?`punch.out`:`punch.in`)} — ${e(`punch.sent`,{time:jE(g.entry.tsUtc,C,t.language)})}`}),(0,F.jsxs)(Z,{spacing:.5,sx:{mt:2},children:[(0,F.jsxs)(Y,{variant:`body1`,children:[e(`punch.worked`),`: `,g.day.workedMin,` min`]}),(0,F.jsxs)(Y,{variant:`body1`,children:[e(`punch.target`),`: `,g.day.targetMin,` min`]}),(0,F.jsxs)(Y,{variant:`body1`,children:[e(`punch.balance`),`: `,g.day.balanceMin,` min`]}),!g.day.hasOpenEntry&&(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,children:e(`punch.closed`)})]})]})})}):(0,F.jsxs)(Ev,{sx:{p:2},children:[(0,F.jsxs)(Z,{direction:`row`,justifyContent:`space-between`,alignItems:`baseline`,sx:{mb:2},children:[(0,F.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`,minWidth:0},children:[O.logoUrl&&(0,F.jsx)(Ev,{component:`img`,src:O.logoUrl,alt:``,sx:{height:28,maxWidth:120,objectFit:`contain`}}),(0,F.jsx)(Y,{variant:`h5`,children:o.terminal.name})]}),(0,F.jsx)(Y,{variant:`h5`,children:jE(T,C,t.language)})]}),(0,F.jsx)(OD,{error:v}),(0,F.jsx)(Vv,{sx:{mb:2},children:(0,F.jsxs)($v,{children:[(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,children:[(0,F.jsx)(Q,{label:e(`terminal.badge`),value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f.trim()&&A({badge:f.trim()})},autoFocus:!0,fullWidth:!0}),(0,F.jsx)(X,{variant:`contained`,size:`large`,disabled:f.trim().length===0,onClick:()=>void A({badge:f.trim()}),children:e(`punch.now`)})]}),(0,F.jsx)(Ok,{onDigit:e=>p(t=>t+e),onBackspace:()=>p(e=>e.slice(0,-1))})]})}),(0,F.jsx)(Vv,{children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`subtitle1`,gutterBottom:!0,children:e(`terminal.select`)}),(0,F.jsx)(Z,{direction:`row`,spacing:1,sx:{flexWrap:`wrap`,gap:1},children:c.map(e=>(0,F.jsx)(X,{variant:u?.id===e.id?`contained`:`outlined`,startIcon:(0,F.jsx)(J_,{src:e.avatarUrl??`/person.png`,alt:``,sx:{width:24,height:24}}),onClick:()=>d(e),children:e.displayName},e.id))}),(0,F.jsxs)(Z,{direction:{xs:`column`,sm:`row`},spacing:2,sx:{mt:2},children:[o.terminal.pinRequired?(0,F.jsx)(Q,{label:e(`terminal.pin`),type:`password`,value:m,onChange:e=>h(e.target.value),helperText:e(`admin.user.pinHint`),fullWidth:!0}):(0,F.jsx)(Y,{variant:`body2`,color:`text.secondary`,sx:{alignSelf:`center`},children:e(`terminal.noPin`)}),(0,F.jsx)(X,{variant:`contained`,size:`large`,disabled:!u||o.terminal.pinRequired&&m.length===0,onClick:()=>u&&void A(o.terminal.pinRequired?{userId:u.id,pin:m}:{userId:u.id}),children:e(`punch.now`)})]}),o.terminal.pinRequired&&(0,F.jsx)(Ok,{onDigit:e=>h(t=>t+e),onBackspace:()=>h(e=>e.slice(0,-1))})]})})]}):(0,F.jsxs)(Ev,{sx:{p:3},children:[(0,F.jsx)(Y,{children:e(`common.loading`)}),(0,F.jsx)(OD,{error:v})]}):(0,F.jsx)(Ev,{sx:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,p:2},children:(0,F.jsx)(Vv,{sx:{maxWidth:480,width:`100%`},children:(0,F.jsxs)($v,{children:[(0,F.jsx)(Y,{variant:`h6`,gutterBottom:!0,children:e(`terminal.title`)}),(0,F.jsxs)(Z,{spacing:2,children:[(0,F.jsx)(Q,{label:e(`terminal.deviceToken`),value:i,onChange:e=>a(e.target.value),fullWidth:!0,autoFocus:!0}),(0,F.jsx)(OD,{error:v}),(0,F.jsx)(X,{variant:`contained`,disabled:i.trim().length===0,onClick:()=>r(i.trim()),children:e(`terminal.connect`)})]})]})})}):(0,F.jsxs)(Ev,{sx:{p:3},children:[(0,F.jsx)(jm,{severity:`warning`,children:e(`terminal.disabled`)}),(0,F.jsx)(OD,{error:v})]})}var Zk=cc({palette:{mode:`light`,primary:{main:`#1976d2`},secondary:{main:`#00897b`}},shape:{borderRadius:10},components:{MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{textTransform:`none`,minHeight:44}}},MuiCard:{styleOverrides:{root:{border:`1px solid rgba(0,0,0,0.08)`}}}}}),Qk=new Nl({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!0,staleTime:3e4}}});function $k(){let{session:e,checking:t}=pD();return t&&!e?(0,F.jsx)(Ev,{sx:{display:`flex`,justifyContent:`center`,alignItems:`center`,minHeight:`100vh`},children:(0,F.jsx)(My,{})}):e?e.user.mustChangePw?(0,F.jsx)(Yd,{children:(0,F.jsx)(qd,{path:`*`,element:(0,F.jsx)(bk,{})})}):(0,F.jsxs)(Yd,{children:[(0,F.jsx)(qd,{path:`/`,element:(0,F.jsx)(vk,{})}),(0,F.jsx)(qd,{path:`/month`,element:(0,F.jsx)($D,{})}),(0,F.jsx)(qd,{path:`/reports`,element:(0,F.jsx)(Lk,{})}),(0,F.jsx)(qd,{path:`/statistics`,element:(0,F.jsx)(Vk,{})}),(0,F.jsx)(qd,{path:`/absences`,element:(0,F.jsx)(AD,{})}),(0,F.jsx)(qd,{path:`/sync`,element:(0,F.jsx)(Hk,{})}),(0,F.jsx)(qd,{path:`/profile`,element:(0,F.jsx)(Ik,{})}),(0,F.jsx)(qd,{path:`/admin`,element:(0,F.jsx)(hk,{})}),(0,F.jsx)(qd,{path:`*`,element:(0,F.jsx)(Kd,{to:`/`,replace:!0})})]}):(0,F.jsx)(Yd,{children:(0,F.jsx)(qd,{path:`*`,element:(0,F.jsx)(yk,{})})})}function eA(){let[e]=(0,y.useState)(()=>new URLSearchParams(window.location.search).has(`tag`));return e?(0,F.jsx)(Gk,{}):(0,F.jsxs)(Yd,{children:[(0,F.jsx)(qd,{path:`/terminal`,element:(0,F.jsx)(Xk,{})}),(0,F.jsx)(qd,{path:`/presence`,element:(0,F.jsx)(Pk,{})}),(0,F.jsx)(qd,{path:`*`,element:(0,F.jsx)($k,{})})]})}function tA(){let e=zE();return(0,F.jsx)(Ev,{sx:{minHeight:`100vh`,...BE(e)},children:(0,F.jsx)(eA,{})})}function nA(){return(0,F.jsxs)(Sc,{theme:Zk,children:[(0,F.jsx)(hc,{}),(0,F.jsx)(Ec,{client:Qk,children:(0,F.jsx)(fD,{children:(0,F.jsx)(bD,{children:(0,F.jsx)(If,{children:(0,F.jsx)(RE,{children:(0,F.jsx)(tA,{})})})})})})]})}k({immediate:!0});var rA=document.getElementById(`root`);if(!rA)throw Error(`index.html does not contain #root`);(0,b.createRoot)(rA).render((0,F.jsx)(y.StrictMode,{children:(0,F.jsx)(nA,{})}));
|
|
119
|
+
//# sourceMappingURL=index-hqZFDQvU.js.map
|