From 9bfd14a082efd9b1093c77dcd96ef317e8fe113a Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Wed, 22 Jul 2026 18:25:02 +0000 Subject: [PATCH] Add timesheet sync: pull actual hours, daily cron, per-cell source indicators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fetchTimesheetShifts: hits /api/v2/shifts, subtracts breaks, carries PENDING/APPROVED status - syncJobs.js: shared runRotaSync/runTimesheetSync logic used by routes and cron - Rota sync now skips dates already marked source='timesheet' - POST /api/workforce/sync-timesheets: on-demand pull of last 7 days actual hours - Daily 6am cron: rota sync then timesheet sync, each logged independently - upsertWorkforceShifts now writes source per row (workforce or timesheet) - Frontend: Pull timesheets button alongside Sync rota button - Clock icon on timesheet cells — amber for PENDING, green for APPROVED - Both buttons disabled while either sync is in progress Co-Authored-By: Claude Sonnet 4.6 --- backend/package-lock.json | 723 +++++++++++++++++++++++++ backend/package.json | 1 + backend/src/db.js | 6 +- backend/src/index.js | 19 + backend/src/lib/syncJobs.js | 94 ++++ backend/src/lib/workforce.js | 48 ++ backend/src/routes/workforce.js | 87 +-- frontend/dist/assets/index-C1fxqzme.js | 127 ----- frontend/dist/assets/index-C9TVzZ7i.js | 132 +++++ frontend/dist/index.html | 2 +- frontend/dist/sw.js | 2 +- frontend/src/api.js | 3 + frontend/src/api.ts | 4 + frontend/src/pages/Planner.js | 37 +- frontend/src/pages/Planner.tsx | 53 +- frontend/src/types.ts | 3 +- 16 files changed, 1129 insertions(+), 212 deletions(-) create mode 100644 backend/package-lock.json create mode 100644 backend/src/lib/syncJobs.js delete mode 100644 frontend/dist/assets/index-C1fxqzme.js create mode 100644 frontend/dist/assets/index-C9TVzZ7i.js diff --git a/backend/package-lock.json b/backend/package-lock.json new file mode 100644 index 0000000..a15ada7 --- /dev/null +++ b/backend/package-lock.json @@ -0,0 +1,723 @@ +{ + "name": "hnf-hk-planner-backend", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "hnf-hk-planner-backend", + "version": "1.0.0", + "dependencies": { + "@fastify/cookie": "^9.4.0", + "@fastify/cors": "^9.0.1", + "fastify": "^4.28.1", + "jose": "^5.9.6", + "node-cron": "^4.6.0", + "pg": "^8.13.1" + } + }, + "node_modules/@fastify/ajv-compiler": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@fastify/ajv-compiler/-/ajv-compiler-3.6.0.tgz", + "integrity": "sha512-LwdXQJjmMD+GwLOkP7TVC68qa+pSSogeWWmznRJ/coyTcfe9qA05AHFSe1eZFwK6q+xVRpChnvFUkf1iYaSZsQ==", + "license": "MIT", + "dependencies": { + "ajv": "^8.11.0", + "ajv-formats": "^2.1.1", + "fast-uri": "^2.0.0" + } + }, + "node_modules/@fastify/cookie": { + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/@fastify/cookie/-/cookie-9.4.0.tgz", + "integrity": "sha512-Th+pt3kEkh4MQD/Q2q1bMuJIB5NX/D5SwSpOKu3G/tjoGbwfpurIMJsWSPS0SJJ4eyjtmQ8OipDQspf8RbUOlg==", + "license": "MIT", + "dependencies": { + "cookie-signature": "^1.1.0", + "fastify-plugin": "^4.0.0" + } + }, + "node_modules/@fastify/cors": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/@fastify/cors/-/cors-9.0.1.tgz", + "integrity": "sha512-YY9Ho3ovI+QHIL2hW+9X4XqQjXLjJqsU+sMV/xFsxZkE8p3GNnYVFpoOxF7SsP5ZL76gwvbo3V9L+FIekBGU4Q==", + "license": "MIT", + "dependencies": { + "fastify-plugin": "^4.0.0", + "mnemonist": "0.39.6" + } + }, + "node_modules/@fastify/error": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@fastify/error/-/error-3.4.1.tgz", + "integrity": "sha512-wWSvph+29GR783IhmvdwWnN4bUxTD01Vm5Xad4i7i1VuAOItLvbPAb69sb0IQ2N57yprvhNIwAP5B6xfKTmjmQ==", + "license": "MIT" + }, + "node_modules/@fastify/fast-json-stringify-compiler": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@fastify/fast-json-stringify-compiler/-/fast-json-stringify-compiler-4.3.0.tgz", + "integrity": "sha512-aZAXGYo6m22Fk1zZzEUKBvut/CIIQe/BapEORnxiD5Qr0kPHqqI69NtEMCme74h+at72sPhbkb4ZrLd1W3KRLA==", + "license": "MIT", + "dependencies": { + "fast-json-stringify": "^5.7.0" + } + }, + "node_modules/@fastify/merge-json-schemas": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@fastify/merge-json-schemas/-/merge-json-schemas-0.1.1.tgz", + "integrity": "sha512-fERDVz7topgNjtXsJTTW1JKLy0rhuLRcquYqNR9rF7OcVpCa2OVW49ZPDIhaRRCaUuvVxI+N416xUoF76HNSXA==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3" + } + }, + "node_modules/@pinojs/redact": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz", + "integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==", + "license": "MIT" + }, + "node_modules/abstract-logging": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz", + "integrity": "sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==", + "license": "MIT" + }, + "node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/ajv/node_modules/fast-uri": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.4.tgz", + "integrity": "sha512-8JnbkQ4juDyvYs4mgFGQqg4yCYtFDtUtmp2QIQq11ZZe5CFQ5wcqm1rqDgAh/QdMySuBnPzMUiJUNZG5N/AiQw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/avvio": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/avvio/-/avvio-8.4.0.tgz", + "integrity": "sha512-CDSwaxINFy59iNwhYnkvALBwZiTydGkOecZyPkqBpABYR1KqGEsET0VOOYDwtleZSUIdeY36DC2bSZ24CO1igA==", + "license": "MIT", + "dependencies": { + "@fastify/error": "^3.3.0", + "fastq": "^1.17.1" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/fast-content-type-parse": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-1.1.0.tgz", + "integrity": "sha512-fBHHqSTFLVnR61C+gltJuE5GkVQMV0S2nqUO8TJ+5Z3qAKG8vAx4FKai1s5jq/inV1+sREynIWSuQ6HgoSXpDQ==", + "license": "MIT" + }, + "node_modules/fast-decode-uri-component": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", + "integrity": "sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==", + "license": "MIT" + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, + "node_modules/fast-json-stringify": { + "version": "5.16.1", + "resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-5.16.1.tgz", + "integrity": "sha512-KAdnLvy1yu/XrRtP+LJnxbBGrhN+xXu+gt3EUvZhYGKCr3lFHq/7UFJHHFgmJKoqlh6B40bZLEv7w46B0mqn1g==", + "license": "MIT", + "dependencies": { + "@fastify/merge-json-schemas": "^0.1.0", + "ajv": "^8.10.0", + "ajv-formats": "^3.0.1", + "fast-deep-equal": "^3.1.3", + "fast-uri": "^2.1.0", + "json-schema-ref-resolver": "^1.0.1", + "rfdc": "^1.2.0" + } + }, + "node_modules/fast-json-stringify/node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/fast-querystring": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fast-querystring/-/fast-querystring-1.1.2.tgz", + "integrity": "sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==", + "license": "MIT", + "dependencies": { + "fast-decode-uri-component": "^1.0.1" + } + }, + "node_modules/fast-uri": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-2.4.3.tgz", + "integrity": "sha512-8V8UrSDUkYpi4AXM7Na0G6hctXSaRHBGMuANOotuFdHEFtTdqDTRNfcDczA9WkKODI17o7o10iQvzdMIxXb8eA==", + "license": "MIT" + }, + "node_modules/fastify": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.29.1.tgz", + "integrity": "sha512-m2kMNHIG92tSNWv+Z3UeTR9AWLLuo7KctC7mlFPtMEVrfjIhmQhkQnT9v15qA/BfVq3vvj134Y0jl9SBje3jXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT", + "dependencies": { + "@fastify/ajv-compiler": "^3.5.0", + "@fastify/error": "^3.4.0", + "@fastify/fast-json-stringify-compiler": "^4.3.0", + "abstract-logging": "^2.0.1", + "avvio": "^8.3.0", + "fast-content-type-parse": "^1.1.0", + "fast-json-stringify": "^5.8.0", + "find-my-way": "^8.0.0", + "light-my-request": "^5.11.0", + "pino": "^9.0.0", + "process-warning": "^3.0.0", + "proxy-addr": "^2.0.7", + "rfdc": "^1.3.0", + "secure-json-parse": "^2.7.0", + "semver": "^7.5.4", + "toad-cache": "^3.3.0" + } + }, + "node_modules/fastify-plugin": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-4.5.1.tgz", + "integrity": "sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==", + "license": "MIT" + }, + "node_modules/fastq": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", + "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==", + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/find-my-way": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-8.2.2.tgz", + "integrity": "sha512-Dobi7gcTEq8yszimcfp/R7+owiT4WncAJ7VTTgFH1jYJ5GaG1FbhjwDG820hptN0QDFvzVY3RfCzdInvGPGzjA==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-querystring": "^1.0.0", + "safe-regex2": "^3.1.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/jose": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/jose/-/jose-5.10.0.tgz", + "integrity": "sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/json-schema-ref-resolver": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-schema-ref-resolver/-/json-schema-ref-resolver-1.0.1.tgz", + "integrity": "sha512-EJAj1pgHc1hxF6vo2Z3s69fMjO1INq6eGHXZ8Z6wCQeldCuwxGK9Sxf4/cScGn3FZubCVUehfWtcDM/PLteCQw==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3" + } + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" + }, + "node_modules/light-my-request": { + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-5.14.0.tgz", + "integrity": "sha512-aORPWntbpH5esaYpGOOmri0OHDOe3wC5M2MQxZ9dvMLZm6DnaAn0kJlcbU9hwsQgLzmZyReKwFwwPkR+nHu5kA==", + "license": "BSD-3-Clause", + "dependencies": { + "cookie": "^0.7.0", + "process-warning": "^3.0.0", + "set-cookie-parser": "^2.4.1" + } + }, + "node_modules/mnemonist": { + "version": "0.39.6", + "resolved": "https://registry.npmjs.org/mnemonist/-/mnemonist-0.39.6.tgz", + "integrity": "sha512-A/0v5Z59y63US00cRSLiloEIw3t5G+MiKz4BhX21FI+YBJXBOGW0ohFxTxO08dsOYlzxo87T7vGfZKYp2bcAWA==", + "license": "MIT", + "dependencies": { + "obliterator": "^2.0.1" + } + }, + "node_modules/node-cron": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-4.6.0.tgz", + "integrity": "sha512-Si/bzYiKRHOB8/a99T2+SDGN582ONDMSTlJr5oCkT6GtnqPjZ2s10eoQRYkW9ZHwjVxONL+W8Fb+qR0AHMQsdg==", + "license": "ISC", + "engines": { + "node": ">=20" + } + }, + "node_modules/obliterator": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/obliterator/-/obliterator-2.0.5.tgz", + "integrity": "sha512-42CPE9AhahZRsMNslczq0ctAEtqk8Eka26QofnqC346BZdHDySk3LWka23LI7ULIw11NmltpiLagIq8gBozxTw==", + "license": "MIT" + }, + "node_modules/on-exit-leak-free": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", + "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/pg": { + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.22.0.tgz", + "integrity": "sha512-8wih1vVIBMxoUM2oB4soJsD9tDnDpLv4OXBJ+EJzFsvycD+lfyIreC2gGHq78f8jbLLt+bvlPTFdFZfJkOuzAA==", + "license": "MIT", + "dependencies": { + "pg-connection-string": "^2.14.0", + "pg-pool": "^3.14.0", + "pg-protocol": "^1.15.0", + "pg-types": "2.2.0", + "pgpass": "1.0.5" + }, + "engines": { + "node": ">= 16.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.4.0" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.4.0.tgz", + "integrity": "sha512-Vo7z/6rrQYxpNRylp4Tlob2elzbh+N/MOQbxFVWCxS7oEx6jF53GTJFxK2WWpKuBRkmiin4Mt+xofFDjx09R0A==", + "license": "MIT", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.14.0.tgz", + "integrity": "sha512-XwWDGcLRGCXAR8F/AM5bG7Q+A3Wm2s6QeEjlOKZLlH3UYcguiqCWKyWXVag5TLTIjR7oOJUY8kcADaZgWPyLeg==", + "license": "MIT" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "license": "ISC", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.14.0.tgz", + "integrity": "sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==", + "license": "MIT", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.15.0.tgz", + "integrity": "sha512-cq9sECI5s0+uPUXjbz8ioyPJni6RzsRib0US67i5IoTZKw8fNeYlVE7u8F4dG7vEJJtc5wdD1K189lCCUwqWTQ==", + "license": "MIT" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "license": "MIT", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "license": "MIT", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/pino": { + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-9.14.0.tgz", + "integrity": "sha512-8OEwKp5juEvb/MjpIc4hjqfgCNysrS94RIOMXYvpYCdm/jglrKEiAYmiumbmGhCvs+IcInsphYDFwqrjr7398w==", + "license": "MIT", + "dependencies": { + "@pinojs/redact": "^0.4.0", + "atomic-sleep": "^1.0.0", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^2.0.0", + "pino-std-serializers": "^7.0.0", + "process-warning": "^5.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.2.0", + "safe-stable-stringify": "^2.3.1", + "sonic-boom": "^4.0.1", + "thread-stream": "^3.0.0" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/pino-abstract-transport": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-2.0.0.tgz", + "integrity": "sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==", + "license": "MIT", + "dependencies": { + "split2": "^4.0.0" + } + }, + "node_modules/pino-std-serializers": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz", + "integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==", + "license": "MIT" + }, + "node_modules/pino/node_modules/process-warning": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.0.0.tgz", + "integrity": "sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.1.tgz", + "integrity": "sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "license": "MIT", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/process-warning": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-3.0.0.tgz", + "integrity": "sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==", + "license": "MIT" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", + "license": "MIT" + }, + "node_modules/real-require": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", + "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", + "license": "MIT", + "engines": { + "node": ">= 12.13.0" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ret": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.4.3.tgz", + "integrity": "sha512-0f4Memo5QP7WQyUEAYUO3esD/XjOc3Zjjg5CPsAq1p8sIu0XPeMbHJemKA0BO7tV0X7+A0FoEpbmHXWxPyD3wQ==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rfdc": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", + "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", + "license": "MIT" + }, + "node_modules/safe-regex2": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-3.1.0.tgz", + "integrity": "sha512-RAAZAGbap2kBfbVhvmnTFv73NWLMvDGOITFYTZBAaY8eR+Ir4ef7Up/e7amo+y1+AH+3PtLkrt9mvcTsG9LXug==", + "license": "MIT", + "dependencies": { + "ret": "~0.4.0" + } + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/secure-json-parse": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.7.0.tgz", + "integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==", + "license": "BSD-3-Clause" + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-cookie-parser": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz", + "integrity": "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==", + "license": "MIT" + }, + "node_modules/sonic-boom": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz", + "integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/thread-stream": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.2.0.tgz", + "integrity": "sha512-zLBvqpwr4Esa0kRjcrzGU6zL25lePWaCLMx0RQFrmteozIfeNdaMLpG5U7PeHzvlFkAWaRKA9/KVW4F60iB+qw==", + "license": "MIT", + "dependencies": { + "real-require": "^0.2.0" + } + }, + "node_modules/toad-cache": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/toad-cache/-/toad-cache-3.7.4.tgz", + "integrity": "sha512-m1TdR/rvT7kgGJZhspNtXdsdYk0fddFpJJFlG5s+UkPFo6lkLoZ3YLOaovPYjq1R75NP5JfeTlSHaOsE09peCg==", + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/backend/package.json b/backend/package.json index 7e404b3..443705b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -11,6 +11,7 @@ "@fastify/cors": "^9.0.1", "fastify": "^4.28.1", "jose": "^5.9.6", + "node-cron": "^4.6.0", "pg": "^8.13.1" } } diff --git a/backend/src/db.js b/backend/src/db.js index dfe1993..0feb27e 100644 --- a/backend/src/db.js +++ b/backend/src/db.js @@ -54,9 +54,9 @@ export async function upsertWorkforceShifts(dailyRows) { for (const row of dailyRows) { await client.query( `INSERT INTO workforce_daily_shifts (date, synced_at, source, staff) - VALUES ($1, now(), 'workforce', $2::jsonb) - ON CONFLICT (date) DO UPDATE SET synced_at = now(), staff = EXCLUDED.staff`, - [row.date, JSON.stringify(row.staff)] + VALUES ($1, now(), $2, $3::jsonb) + ON CONFLICT (date) DO UPDATE SET synced_at = now(), source = EXCLUDED.source, staff = EXCLUDED.staff`, + [row.date, row.source || 'workforce', JSON.stringify(row.staff)] ) } await client.query('COMMIT') diff --git a/backend/src/index.js b/backend/src/index.js index bbfb25a..9371e5d 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -1,10 +1,12 @@ import Fastify from 'fastify' import cookie from '@fastify/cookie' import cors from '@fastify/cors' +import cron from 'node-cron' import { initDb } from './db.js' import { bookingRoutes } from './routes/bookings.js' import { configRoutes } from './routes/config.js' import { workforceRoutes } from './routes/workforce.js' +import { runRotaSync, runTimesheetSync } from './lib/syncJobs.js' const app = Fastify({ logger: true, trustProxy: true }) const startedAt = Date.now() @@ -25,3 +27,20 @@ try { app.log.error(err) process.exit(1) } + +// Daily 6am: rota sync (today-7 → today+28) then timesheet sync (last 7 days) +cron.schedule('0 6 * * *', async () => { + app.log.info('cron: starting daily workforce sync') + try { + const r = await runRotaSync() + app.log.info({ dates_synced: r.dates_synced }, 'cron: rota sync complete') + } catch (err) { + app.log.error({ err: err.message }, 'cron: rota sync failed') + } + try { + const r = await runTimesheetSync() + app.log.info({ dates_synced: r.dates_synced }, 'cron: timesheet sync complete') + } catch (err) { + app.log.error({ err: err.message }, 'cron: timesheet sync failed') + } +}) diff --git a/backend/src/lib/syncJobs.js b/backend/src/lib/syncJobs.js new file mode 100644 index 0000000..688412b --- /dev/null +++ b/backend/src/lib/syncJobs.js @@ -0,0 +1,94 @@ +import { getConfig, getWorkforceShifts, upsertWorkforceShifts } from '../db.js' +import { fetchShifts, fetchTimesheetShifts } from './workforce.js' + +function fmtDate(d) { + return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}` +} + +export async function runRotaSync() { + const deptIds = (await getConfig('workforce_departments', [])) || [] + if (!deptIds.length) throw new Error('No HK departments selected — configure in Category Settings') + + const today = new Date() + const fromDate = new Date(today); fromDate.setDate(fromDate.getDate() - 7) + const toDate = new Date(today); toDate.setDate(toDate.getDate() + 28) + const from = fmtDate(fromDate) + const to = fmtDate(toDate) + + // API limit: max 7 days per request — split into weekly chunks + const chunks = [] + const cur = new Date(fromDate) + while (cur <= toDate) { + const chunkFrom = fmtDate(cur) + const chunkToDate = new Date(cur) + chunkToDate.setDate(chunkToDate.getDate() + 6) + if (chunkToDate > toDate) chunkToDate.setTime(toDate.getTime()) + chunks.push({ from: chunkFrom, to: fmtDate(chunkToDate) }) + cur.setDate(cur.getDate() + 7) + } + + const staffMap = {} + for (const chunk of chunks) { + const chunkStaff = await fetchShifts(chunk.from, chunk.to, deptIds) + for (const member of chunkStaff) { + if (!staffMap[member.id]) staffMap[member.id] = { id: member.id, name: member.name, days: {} } + Object.assign(staffMap[member.id].days, member.days) + } + } + + const byDate = {} + for (const member of Object.values(staffMap)) { + for (const [date, shift] of Object.entries(member.days)) { + if (!byDate[date]) byDate[date] = [] + byDate[date].push({ id: member.id, name: member.name, hours: shift.hours, times: shift.times }) + } + } + + // Skip dates already replaced with timesheet actuals + const existing = await getWorkforceShifts(from, to) + const timesheetDates = new Set( + Object.entries(existing).filter(([, d]) => d.source === 'timesheet').map(([date]) => date) + ) + + const dailyRows = [] + const day = new Date(fromDate) + while (day <= toDate) { + const d = fmtDate(day) + if (!timesheetDates.has(d)) dailyRows.push({ date: d, staff: byDate[d] || [], source: 'workforce' }) + day.setDate(day.getDate() + 1) + } + + await upsertWorkforceShifts(dailyRows) + return { ok: true, from, to, dates_synced: dailyRows.length } +} + +export async function runTimesheetSync(days = 7) { + const deptIds = (await getConfig('workforce_departments', [])) || [] + if (!deptIds.length) throw new Error('No HK departments selected — configure in Category Settings') + + const today = new Date() + const fromDate = new Date(today); fromDate.setDate(fromDate.getDate() - days) + const from = fmtDate(fromDate) + const to = fmtDate(today) + + const staffList = await fetchTimesheetShifts(from, to, deptIds) + + const byDate = {} + for (const member of staffList) { + for (const [date, shift] of Object.entries(member.days)) { + if (!byDate[date]) byDate[date] = [] + byDate[date].push({ id: member.id, name: member.name, hours: shift.hours, times: shift.times, status: shift.status }) + } + } + + const dailyRows = [] + const day = new Date(fromDate) + while (day <= today) { + const d = fmtDate(day) + dailyRows.push({ date: d, staff: byDate[d] || [], source: 'timesheet' }) + day.setDate(day.getDate() + 1) + } + + await upsertWorkforceShifts(dailyRows) + return { ok: true, from, to, dates_synced: dailyRows.length } +} diff --git a/backend/src/lib/workforce.js b/backend/src/lib/workforce.js index 090685a..8faf987 100644 --- a/backend/src/lib/workforce.js +++ b/backend/src/lib/workforce.js @@ -72,6 +72,54 @@ export async function fetchStaff(deptIds) { .map(u => ({ id: String(u.id), name: u.name })) } +export async function fetchTimesheetShifts(from, to, deptIds) { + const creds = await getWorkforceCreds() + const locationId = creds.location_id + + const staffList = await fetchStaff(deptIds) + const nameMap = Object.fromEntries(staffList.map(s => [s.id, s.name])) + + let path = `/api/v2/shifts?from=${from}&to=${to}` + if (locationId) path += `&report_location_id=${locationId}` + const shifts = await wfFetchPaged(path) + + const filtered = shifts.filter(s => deptIds.includes(String(s.department_id))) + + const byUser = {} + for (const s of filtered) { + const uid = String(s.user_id) + if (!nameMap[uid]) continue + const date = s.date // already 'YYYY-MM-DD' + const hrs = (s.finish && s.start) + ? Math.max(0, (s.finish - s.start) / 3600 - (s.break_length || 0) / 60) + : 0 + + if (!byUser[uid]) byUser[uid] = {} + if (!byUser[uid][date]) byUser[uid][date] = { hours: 0, shifts: [], status: s.status } + byUser[uid][date].hours += hrs + byUser[uid][date].shifts.push({ start: s.start, finish: s.finish }) + if (s.status === 'APPROVED') byUser[uid][date].status = 'APPROVED' + } + + return Object.entries(byUser).map(([uid, days]) => ({ + id: uid, + name: nameMap[uid], + days: Object.fromEntries( + Object.entries(days).map(([date, data]) => { + const sorted = data.shifts.sort((a, b) => a.start - b.start) + const firstStart = sorted[0]?.start + const lastFinish = sorted[sorted.length - 1]?.finish + const times = firstStart && lastFinish + ? sorted.length > 1 + ? `${fmtTime(firstStart)}–${fmtTime(lastFinish)} (${sorted.length} shifts)` + : `${fmtTime(firstStart)}–${fmtTime(lastFinish)}` + : '?' + return [date, { hours: parseFloat(data.hours.toFixed(2)), times, status: data.status }] + }) + ), + })) +} + export async function fetchShifts(from, to, deptIds) { const creds = await getWorkforceCreds() const locationId = creds.location_id diff --git a/backend/src/routes/workforce.js b/backend/src/routes/workforce.js index 8404e29..2a819ed 100644 --- a/backend/src/routes/workforce.js +++ b/backend/src/routes/workforce.js @@ -1,9 +1,10 @@ import { requireAuth, requireCap } from '../auth.js' -import { getConfig, setConfig, getWorkforceShifts, upsertWorkforceShifts } from '../db.js' -import { fetchDepartments, fetchStaff, fetchShifts } from '../lib/workforce.js' +import { getConfig, setConfig, getWorkforceShifts } from '../db.js' +import { fetchDepartments, fetchStaff } from '../lib/workforce.js' +import { runRotaSync, runTimesheetSync } from '../lib/syncJobs.js' -function fmtDate(d) { - return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}` +function errStatus(msg) { + return msg.includes('not configured') ? 503 : 502 } export async function workforceRoutes(app) { @@ -15,72 +16,29 @@ export async function workforceRoutes(app) { try { return await fetchDepartments() } catch (err) { - const status = err.message.includes('not configured') ? 503 : 502 - return reply.status(status).send({ error: err.message }) + return reply.status(errStatus(err.message)).send({ error: err.message }) } }) - // ── POST /api/workforce/sync — rolling window: today-7 → today+28 ─────────── + // ── POST /api/workforce/sync — rolling rota window: today-7 → today+28 ────── app.post('/api/workforce/sync', { preHandler: requireCap('planner') }, async (req, reply) => { - const deptIds = (await getConfig('workforce_departments', [])) || [] - if (!deptIds.length) { - return reply.status(400).send({ error: 'No HK departments selected — configure in Category Settings' }) - } - - const today = new Date() - const fromDate = new Date(today); fromDate.setDate(fromDate.getDate() - 7) - const toDate = new Date(today); toDate.setDate(toDate.getDate() + 28) - const from = fmtDate(fromDate) - const to = fmtDate(toDate) - try { - // API limit: max 7 days per request — split window into weekly chunks - const chunks = [] - const cur = new Date(fromDate) - while (cur <= toDate) { - const chunkFrom = fmtDate(cur) - const chunkToDate = new Date(cur) - chunkToDate.setDate(chunkToDate.getDate() + 6) - if (chunkToDate > toDate) chunkToDate.setTime(toDate.getTime()) - chunks.push({ from: chunkFrom, to: fmtDate(chunkToDate) }) - cur.setDate(cur.getDate() + 7) - } - - const staffMap = {} - for (const chunk of chunks) { - const chunkStaff = await fetchShifts(chunk.from, chunk.to, deptIds) - for (const member of chunkStaff) { - if (!staffMap[member.id]) staffMap[member.id] = { id: member.id, name: member.name, days: {} } - Object.assign(staffMap[member.id].days, member.days) - } - } - const staffList = Object.values(staffMap) - - // Pivot per-member → per-date - const byDate = {} - for (const member of staffList) { - for (const [date, shift] of Object.entries(member.days)) { - if (!byDate[date]) byDate[date] = [] - byDate[date].push({ id: member.id, name: member.name, hours: shift.hours, times: shift.times }) - } - } - - // Build a row for every date in the window (empty staff = no one scheduled) - const dailyRows = [] - const day = new Date(fromDate) - while (day <= toDate) { - const d = fmtDate(day) - dailyRows.push({ date: d, staff: byDate[d] || [] }) - day.setDate(day.getDate() + 1) - } - - await upsertWorkforceShifts(dailyRows) - return { ok: true, from, to, dates_synced: dailyRows.length } + return await runRotaSync() } catch (err) { - req.log.error({ err: err.message }, 'workforce sync failed') - const status = err.message.includes('not configured') ? 503 : 502 - return reply.status(status).send({ error: err.message }) + req.log.error({ err: err.message }, 'rota sync failed') + return reply.status(errStatus(err.message)).send({ error: err.message }) + } + }) + + // ── POST /api/workforce/sync-timesheets — last 7 days of actual hours ──────── + + app.post('/api/workforce/sync-timesheets', { preHandler: requireCap('planner') }, async (req, reply) => { + try { + return await runTimesheetSync() + } catch (err) { + req.log.error({ err: err.message }, 'timesheet sync failed') + return reply.status(errStatus(err.message)).send({ error: err.message }) } }) @@ -108,8 +66,7 @@ export async function workforceRoutes(app) { await setConfig('workforce_staff_cache', { fetched_at: new Date().toISOString(), staff }) return staff } catch (err) { - const status = err.message.includes('not configured') ? 503 : 502 - return reply.status(status).send({ error: err.message }) + return reply.status(errStatus(err.message)).send({ error: err.message }) } }) } diff --git a/frontend/dist/assets/index-C1fxqzme.js b/frontend/dist/assets/index-C1fxqzme.js deleted file mode 100644 index 868480a..0000000 --- a/frontend/dist/assets/index-C1fxqzme.js +++ /dev/null @@ -1,127 +0,0 @@ -function Zf(i,u){for(var s=0;sd[p]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}(function(){const u=document.createElement("link").relList;if(u&&u.supports&&u.supports("modulepreload"))return;for(const p of document.querySelectorAll('link[rel="modulepreload"]'))d(p);new MutationObserver(p=>{for(const h of p)if(h.type==="childList")for(const g of h.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&d(g)}).observe(document,{childList:!0,subtree:!0});function s(p){const h={};return p.integrity&&(h.integrity=p.integrity),p.referrerPolicy&&(h.referrerPolicy=p.referrerPolicy),p.crossOrigin==="use-credentials"?h.credentials="include":p.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function d(p){if(p.ep)return;p.ep=!0;const h=s(p);fetch(p.href,h)}})();function qf(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var hs={exports:{}},ll={},ms={exports:{}},ue={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var mc;function bf(){if(mc)return ue;mc=1;var i=Symbol.for("react.element"),u=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),g=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),_=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),N=Symbol.iterator;function M(y){return y===null||typeof y!="object"?null:(y=N&&y[N]||y["@@iterator"],typeof y=="function"?y:null)}var H={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},K=Object.assign,T={};function E(y,R,ee){this.props=y,this.context=R,this.refs=T,this.updater=ee||H}E.prototype.isReactComponent={},E.prototype.setState=function(y,R){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,R,"setState")},E.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function A(){}A.prototype=E.prototype;function $(y,R,ee){this.props=y,this.context=R,this.refs=T,this.updater=ee||H}var J=$.prototype=new A;J.constructor=$,K(J,E.prototype),J.isPureReactComponent=!0;var U=Array.isArray,ce=Object.prototype.hasOwnProperty,de={current:null},Ce={key:!0,ref:!0,__self:!0,__source:!0};function xe(y,R,ee){var re,le={},oe=null,ae=null;if(R!=null)for(re in R.ref!==void 0&&(ae=R.ref),R.key!==void 0&&(oe=""+R.key),R)ce.call(R,re)&&!Ce.hasOwnProperty(re)&&(le[re]=R[re]);var se=arguments.length-2;if(se===1)le.children=ee;else if(1>>1,R=W[y];if(0>>1;yp(le,F))oep(ae,le)?(W[y]=ae,W[oe]=F,y=oe):(W[y]=le,W[re]=F,y=re);else if(oep(ae,F))W[y]=ae,W[oe]=F,y=oe;else break e}}return X}function p(W,X){var F=W.sortIndex-X.sortIndex;return F!==0?F:W.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var h=performance;i.unstable_now=function(){return h.now()}}else{var g=Date,j=g.now();i.unstable_now=function(){return g.now()-j}}var k=[],_=[],P=1,N=null,M=3,H=!1,K=!1,T=!1,E=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function J(W){for(var X=s(_);X!==null;){if(X.callback===null)d(_);else if(X.startTime<=W)d(_),X.sortIndex=X.expirationTime,u(k,X);else break;X=s(_)}}function U(W){if(T=!1,J(W),!K)if(s(k)!==null)K=!0,Oe(ce);else{var X=s(_);X!==null&&ve(U,X.startTime-W)}}function ce(W,X){K=!1,T&&(T=!1,A(xe),xe=-1),H=!0;var F=M;try{for(J(X),N=s(k);N!==null&&(!(N.expirationTime>X)||W&&!Ke());){var y=N.callback;if(typeof y=="function"){N.callback=null,M=N.priorityLevel;var R=y(N.expirationTime<=X);X=i.unstable_now(),typeof R=="function"?N.callback=R:N===s(k)&&d(k),J(X)}else d(k);N=s(k)}if(N!==null)var ee=!0;else{var re=s(_);re!==null&&ve(U,re.startTime-X),ee=!1}return ee}finally{N=null,M=F,H=!1}}var de=!1,Ce=null,xe=-1,qe=5,We=-1;function Ke(){return!(i.unstable_now()-WeW||125y?(W.sortIndex=F,u(_,W),s(k)===null&&W===s(_)&&(T?(A(xe),xe=-1):T=!0,ve(U,F-y))):(W.sortIndex=R,u(k,W),K||H||(K=!0,Oe(ce))),W},i.unstable_shouldYield=Ke,i.unstable_wrapCallback=function(W){var X=M;return function(){var F=M;M=X;try{return W.apply(this,arguments)}finally{M=F}}}})(ys)),ys}var kc;function op(){return kc||(kc=1,gs.exports=lp()),gs.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var wc;function ip(){if(wc)return dt;wc=1;var i=Ps(),u=op();function s(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),k=Object.prototype.hasOwnProperty,_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,P={},N={};function M(e){return k.call(N,e)?!0:k.call(P,e)?!1:_.test(e)?N[e]=!0:(P[e]=!0,!1)}function H(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function K(e,t,n,r){if(t===null||typeof t>"u"||H(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function T(e,t,n,r,l,o,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new T(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];E[t]=new T(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new T(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new T(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new T(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new T(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new T(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new T(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new T(e,5,!1,e.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function $(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(A,$);E[t]=new T(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(A,$);E[t]=new T(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(A,$);E[t]=new T(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new T(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new T("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new T(e,1,!1,e.toLowerCase(),null,!0,!0)});function J(e,t,n,r){var l=E.hasOwnProperty(t)?E[t]:null;(l!==null?l.type!==0:r||!(2f||l[a]!==o[f]){var m=` -`+l[a].replace(" at new "," at ");return e.displayName&&m.includes("")&&(m=m.replace("",e.displayName)),m}while(1<=a&&0<=f);break}}}finally{ee=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?R(e):""}function le(e){switch(e.tag){case 5:return R(e.type);case 16:return R("Lazy");case 13:return R("Suspense");case 19:return R("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function oe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ce:return"Fragment";case de:return"Portal";case qe:return"Profiler";case xe:return"StrictMode";case Te:return"Suspense";case Ae:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ke:return(e.displayName||"Context")+".Consumer";case We:return(e._context.displayName||"Context")+".Provider";case Ee:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case be:return t=e.displayName||null,t!==null?t:oe(e.type)||"Memo";case Oe:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}function ae(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return oe(t);case 8:return t===xe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function se(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function fe(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Fe(e){var t=fe(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(a){r=""+a,o.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function At(e){e._valueTracker||(e._valueTracker=Fe(e))}function En(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=fe(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function $t(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Vt(e,t){var n=t.checked;return F({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function _n(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=se(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function en(e,t){t=t.checked,t!=null&&J(e,"checked",t,!1)}function Ht(e,t){en(e,t);var n=se(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?tn(e,t.type,n):t.hasOwnProperty("defaultValue")&&tn(e,t.type,se(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Nn(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function tn(e,t,n){(t!=="number"||$t(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var _t=Array.isArray;function Dt(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=pt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ke(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var yt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Tn=["Webkit","ms","Moz","O"];Object.keys(yt).forEach(function(e){Tn.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),yt[t]=yt[e]})});function Vn(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||yt.hasOwnProperty(e)&&yt[e]?(""+t).trim():t+"px"}function I(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Vn(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var ne=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ie(e,t){if(t){if(ne[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(s(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(s(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(s(61))}if(t.style!=null&&typeof t.style!="object")throw Error(s(62))}}function Me(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var xt=null;function wr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ro=null,Hn=null,Qn=null;function Ls(e){if(e=Vr(e)){if(typeof Ro!="function")throw Error(s(280));var t=e.stateNode;t&&(t=Ol(t),Ro(e.stateNode,e.type,t))}}function Os(e){Hn?Qn?Qn.push(e):Qn=[e]:Hn=e}function Ds(){if(Hn){var e=Hn,t=Qn;if(Qn=Hn=null,Ls(e),t)for(e=0;e>>=0,e===0?32:31-(fd(e)/pd|0)|0}var ml=64,vl=4194304;function Er(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function gl(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var f=a&~l;f!==0?r=Er(f):(o&=a,o!==0&&(r=Er(o)))}else a=n&~l,a!==0?r=Er(a):o!==0&&(r=Er(o));if(r===0)return 0;if(t!==0&&t!==r&&(t&l)===0&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function _r(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Nt(t),e[t]=n}function gd(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Dr),aa=" ",ua=!1;function ca(e,t){switch(e){case"keyup":return Qd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function da(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Gn=!1;function Yd(e,t){switch(e){case"compositionend":return da(t);case"keypress":return t.which!==32?null:(ua=!0,aa);case"textInput":return e=t.data,e===aa&&ua?null:e;default:return null}}function Gd(e,t){if(Gn)return e==="compositionend"||!Go&&ca(e,t)?(e=na(),Sl=$o=sn=null,Gn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ya(n)}}function ka(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ka(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function wa(){for(var e=window,t=$t();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=$t(e.document)}return t}function Zo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function rf(e){var t=wa(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ka(n.ownerDocument.documentElement,n)){if(r!==null&&Zo(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=xa(n,o);var a=xa(n,r);l&&a&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Jn=null,qo=null,Fr=null,bo=!1;function Sa(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;bo||Jn==null||Jn!==$t(r)||(r=Jn,"selectionStart"in r&&Zo(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Fr&&Wr(Fr,r)||(Fr=r,r=Rl(qo,"onSelect"),0er||(e.current=di[er],di[er]=null,er--)}function ye(e,t){er++,di[er]=e.current,e.current=t}var dn={},et=cn(dn),it=cn(!1),Ln=dn;function tr(e,t){var n=e.type.contextTypes;if(!n)return dn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function st(e){return e=e.childContextTypes,e!=null}function Dl(){Se(it),Se(et)}function Wa(e,t,n){if(et.current!==dn)throw Error(s(168));ye(et,t),ye(it,n)}function Fa(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(s(108,ae(e)||"Unknown",l));return F({},n,r)}function Ml(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||dn,Ln=et.current,ye(et,e),ye(it,it.current),!0}function Ua(e,t,n){var r=e.stateNode;if(!r)throw Error(s(169));n?(e=Fa(e,t,Ln),r.__reactInternalMemoizedMergedChildContext=e,Se(it),Se(et),ye(et,e)):Se(it),ye(it,n)}var Kt=null,Il=!1,fi=!1;function Ba(e){Kt===null?Kt=[e]:Kt.push(e)}function vf(e){Il=!0,Ba(e)}function fn(){if(!fi&&Kt!==null){fi=!0;var e=0,t=ge;try{var n=Kt;for(ge=1;e>=a,l-=a,Yt=1<<32-Nt(t)+l|n<b?(Qe=q,q=null):Qe=q.sibling;var me=z(x,q,w[b],D);if(me===null){q===null&&(q=Qe);break}e&&q&&me.alternate===null&&t(x,q),v=o(me,v,b),Z===null?G=me:Z.sibling=me,Z=me,q=Qe}if(b===w.length)return n(x,q),je&&Dn(x,b),G;if(q===null){for(;bb?(Qe=q,q=null):Qe=q.sibling;var wn=z(x,q,me.value,D);if(wn===null){q===null&&(q=Qe);break}e&&q&&wn.alternate===null&&t(x,q),v=o(wn,v,b),Z===null?G=wn:Z.sibling=wn,Z=wn,q=Qe}if(me.done)return n(x,q),je&&Dn(x,b),G;if(q===null){for(;!me.done;b++,me=w.next())me=O(x,me.value,D),me!==null&&(v=o(me,v,b),Z===null?G=me:Z.sibling=me,Z=me);return je&&Dn(x,b),G}for(q=r(x,q);!me.done;b++,me=w.next())me=B(q,x,b,me.value,D),me!==null&&(e&&me.alternate!==null&&q.delete(me.key===null?b:me.key),v=o(me,v,b),Z===null?G=me:Z.sibling=me,Z=me);return e&&q.forEach(function(Xf){return t(x,Xf)}),je&&Dn(x,b),G}function Le(x,v,w,D){if(typeof w=="object"&&w!==null&&w.type===Ce&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case ce:e:{for(var G=w.key,Z=v;Z!==null;){if(Z.key===G){if(G=w.type,G===Ce){if(Z.tag===7){n(x,Z.sibling),v=l(Z,w.props.children),v.return=x,x=v;break e}}else if(Z.elementType===G||typeof G=="object"&&G!==null&&G.$$typeof===Oe&&Ka(G)===Z.type){n(x,Z.sibling),v=l(Z,w.props),v.ref=Hr(x,Z,w),v.return=x,x=v;break e}n(x,Z);break}else t(x,Z);Z=Z.sibling}w.type===Ce?(v=$n(w.props.children,x.mode,D,w.key),v.return=x,x=v):(D=co(w.type,w.key,w.props,null,x.mode,D),D.ref=Hr(x,v,w),D.return=x,x=D)}return a(x);case de:e:{for(Z=w.key;v!==null;){if(v.key===Z)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(x,v.sibling),v=l(v,w.children||[]),v.return=x,x=v;break e}else{n(x,v);break}else t(x,v);v=v.sibling}v=us(w,x.mode,D),v.return=x,x=v}return a(x);case Oe:return Z=w._init,Le(x,v,Z(w._payload),D)}if(_t(w))return Q(x,v,w,D);if(X(w))return Y(x,v,w,D);Bl(x,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(x,v.sibling),v=l(v,w),v.return=x,x=v):(n(x,v),v=as(w,x.mode,D),v.return=x,x=v),a(x)):n(x,v)}return Le}var or=Ya(!0),Ga=Ya(!1),Al=cn(null),$l=null,ir=null,yi=null;function xi(){yi=ir=$l=null}function ki(e){var t=Al.current;Se(Al),e._currentValue=t}function wi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function sr(e,t){$l=e,yi=ir=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(at=!0),e.firstContext=null)}function St(e){var t=e._currentValue;if(yi!==e)if(e={context:e,memoizedValue:t,next:null},ir===null){if($l===null)throw Error(s(308));ir=e,$l.dependencies={lanes:0,firstContext:e}}else ir=ir.next=e;return t}var Mn=null;function Si(e){Mn===null?Mn=[e]:Mn.push(e)}function Ja(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Si(t)):(n.next=l.next,l.next=n),t.interleaved=n,Jt(e,r)}function Jt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var pn=!1;function ji(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Xt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function hn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(he&2)!==0){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Jt(e,n)}return l=r.interleaved,l===null?(t.next=t,Si(r)):(t.next=l.next,l.next=t),r.interleaved=t,Jt(e,n)}function Vl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Wo(e,n)}}function Za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?l=o=a:o=o.next=a,n=n.next}while(n!==null);o===null?l=o=t:o=o.next=t}else l=o=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Hl(e,t,n,r){var l=e.updateQueue;pn=!1;var o=l.firstBaseUpdate,a=l.lastBaseUpdate,f=l.shared.pending;if(f!==null){l.shared.pending=null;var m=f,C=m.next;m.next=null,a===null?o=C:a.next=C,a=m;var L=e.alternate;L!==null&&(L=L.updateQueue,f=L.lastBaseUpdate,f!==a&&(f===null?L.firstBaseUpdate=C:f.next=C,L.lastBaseUpdate=m))}if(o!==null){var O=l.baseState;a=0,L=C=m=null,f=o;do{var z=f.lane,B=f.eventTime;if((r&z)===z){L!==null&&(L=L.next={eventTime:B,lane:0,tag:f.tag,payload:f.payload,callback:f.callback,next:null});e:{var Q=e,Y=f;switch(z=t,B=n,Y.tag){case 1:if(Q=Y.payload,typeof Q=="function"){O=Q.call(B,O,z);break e}O=Q;break e;case 3:Q.flags=Q.flags&-65537|128;case 0:if(Q=Y.payload,z=typeof Q=="function"?Q.call(B,O,z):Q,z==null)break e;O=F({},O,z);break e;case 2:pn=!0}}f.callback!==null&&f.lane!==0&&(e.flags|=64,z=l.effects,z===null?l.effects=[f]:z.push(f))}else B={eventTime:B,lane:z,tag:f.tag,payload:f.payload,callback:f.callback,next:null},L===null?(C=L=B,m=O):L=L.next=B,a|=z;if(f=f.next,f===null){if(f=l.shared.pending,f===null)break;z=f,f=z.next,z.next=null,l.lastBaseUpdate=z,l.shared.pending=null}}while(!0);if(L===null&&(m=O),l.baseState=m,l.firstBaseUpdate=C,l.lastBaseUpdate=L,t=l.shared.interleaved,t!==null){l=t;do a|=l.lane,l=l.next;while(l!==t)}else o===null&&(l.shared.lanes=0);Fn|=a,e.lanes=a,e.memoizedState=O}}function qa(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Pi.transition;Pi.transition={};try{e(!1),t()}finally{ge=n,Pi.transition=r}}function gu(){return jt().memoizedState}function kf(e,t,n){var r=yn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},yu(e))xu(t,n);else if(n=Ja(e,t,n,r),n!==null){var l=ot();Ot(n,e,r,l),ku(n,t,r)}}function wf(e,t,n){var r=yn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(yu(e))xu(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,f=o(a,n);if(l.hasEagerState=!0,l.eagerState=f,Pt(f,a)){var m=t.interleaved;m===null?(l.next=l,Si(t)):(l.next=m.next,m.next=l),t.interleaved=l;return}}catch{}finally{}n=Ja(e,t,l,r),n!==null&&(l=ot(),Ot(n,e,r,l),ku(n,t,r))}}function yu(e){var t=e.alternate;return e===Ne||t!==null&&t===Ne}function xu(e,t){Gr=Yl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ku(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Wo(e,n)}}var Xl={readContext:St,useCallback:tt,useContext:tt,useEffect:tt,useImperativeHandle:tt,useInsertionEffect:tt,useLayoutEffect:tt,useMemo:tt,useReducer:tt,useRef:tt,useState:tt,useDebugValue:tt,useDeferredValue:tt,useTransition:tt,useMutableSource:tt,useSyncExternalStore:tt,useId:tt,unstable_isNewReconciler:!1},Sf={readContext:St,useCallback:function(e,t){return Ft().memoizedState=[e,t===void 0?null:t],e},useContext:St,useEffect:uu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Gl(4194308,4,fu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Gl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Gl(4,2,e,t)},useMemo:function(e,t){var n=Ft();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ft();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=kf.bind(null,Ne,e),[r.memoizedState,e]},useRef:function(e){var t=Ft();return e={current:e},t.memoizedState=e},useState:su,useDebugValue:Mi,useDeferredValue:function(e){return Ft().memoizedState=e},useTransition:function(){var e=su(!1),t=e[0];return e=xf.bind(null,e[1]),Ft().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ne,l=Ft();if(je){if(n===void 0)throw Error(s(407));n=n()}else{if(n=t(),He===null)throw Error(s(349));(Wn&30)!==0||nu(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,uu(lu.bind(null,r,o,e),[e]),r.flags|=2048,Zr(9,ru.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Ft(),t=He.identifierPrefix;if(je){var n=Gt,r=Yt;n=(r&~(1<<32-Nt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Jr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[It]=t,e[$r]=r,Bu(e,t,!1,!1),t.stateNode=e;e:{switch(a=Me(n,r),n){case"dialog":we("cancel",e),we("close",e),l=r;break;case"iframe":case"object":case"embed":we("load",e),l=r;break;case"video":case"audio":for(l=0;lfr&&(t.flags|=128,r=!0,qr(o,!1),t.lanes=4194304)}else{if(!r)if(e=Ql(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),qr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!je)return nt(t),null}else 2*ze()-o.renderingStartTime>fr&&n!==1073741824&&(t.flags|=128,r=!0,qr(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=ze(),t.sibling=null,n=_e.current,ye(_e,r?n&1|2:n&1),t):(nt(t),null);case 22:case 23:return os(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(gt&1073741824)!==0&&(nt(t),t.subtreeFlags&6&&(t.flags|=8192)):nt(t),null;case 24:return null;case 25:return null}throw Error(s(156,t.tag))}function Rf(e,t){switch(hi(t),t.tag){case 1:return st(t.type)&&Dl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ar(),Se(it),Se(et),Ni(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Ei(t),null;case 13:if(Se(_e),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));lr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(_e),null;case 4:return ar(),null;case 10:return ki(t.type._context),null;case 22:case 23:return os(),null;case 24:return null;default:return null}}var eo=!1,rt=!1,zf=typeof WeakSet=="function"?WeakSet:Set,V=null;function cr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Re(e,t,r)}else n.current=null}function Yi(e,t,n){try{n()}catch(r){Re(e,t,r)}}var Vu=!1;function Lf(e,t){if(oi=kl,e=wa(),Zo(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,f=-1,m=-1,C=0,L=0,O=e,z=null;t:for(;;){for(var B;O!==n||l!==0&&O.nodeType!==3||(f=a+l),O!==o||r!==0&&O.nodeType!==3||(m=a+r),O.nodeType===3&&(a+=O.nodeValue.length),(B=O.firstChild)!==null;)z=O,O=B;for(;;){if(O===e)break t;if(z===n&&++C===l&&(f=a),z===o&&++L===r&&(m=a),(B=O.nextSibling)!==null)break;O=z,z=O.parentNode}O=B}n=f===-1||m===-1?null:{start:f,end:m}}else n=null}n=n||{start:0,end:0}}else n=null;for(ii={focusedElem:e,selectionRange:n},kl=!1,V=t;V!==null;)if(t=V,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,V=e;else for(;V!==null;){t=V;try{var Q=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(Q!==null){var Y=Q.memoizedProps,Le=Q.memoizedState,x=t.stateNode,v=x.getSnapshotBeforeUpdate(t.elementType===t.type?Y:Rt(t.type,Y),Le);x.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(D){Re(t,t.return,D)}if(e=t.sibling,e!==null){e.return=t.return,V=e;break}V=t.return}return Q=Vu,Vu=!1,Q}function br(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var o=l.destroy;l.destroy=void 0,o!==void 0&&Yi(t,n,o)}l=l.next}while(l!==r)}}function to(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Gi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Hu(e){var t=e.alternate;t!==null&&(e.alternate=null,Hu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[It],delete t[$r],delete t[ci],delete t[hf],delete t[mf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Qu(e){return e.tag===5||e.tag===3||e.tag===4}function Ku(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Qu(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ji(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ll));else if(r!==4&&(e=e.child,e!==null))for(Ji(e,t,n),e=e.sibling;e!==null;)Ji(e,t,n),e=e.sibling}function Xi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Xi(e,t,n),e=e.sibling;e!==null;)Xi(e,t,n),e=e.sibling}var Ge=null,zt=!1;function mn(e,t,n){for(n=n.child;n!==null;)Yu(e,t,n),n=n.sibling}function Yu(e,t,n){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(hl,n)}catch{}switch(n.tag){case 5:rt||cr(n,t);case 6:var r=Ge,l=zt;Ge=null,mn(e,t,n),Ge=r,zt=l,Ge!==null&&(zt?(e=Ge,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ge.removeChild(n.stateNode));break;case 18:Ge!==null&&(zt?(e=Ge,n=n.stateNode,e.nodeType===8?ui(e.parentNode,n):e.nodeType===1&&ui(e,n),zr(e)):ui(Ge,n.stateNode));break;case 4:r=Ge,l=zt,Ge=n.stateNode.containerInfo,zt=!0,mn(e,t,n),Ge=r,zt=l;break;case 0:case 11:case 14:case 15:if(!rt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,a=o.destroy;o=o.tag,a!==void 0&&((o&2)!==0||(o&4)!==0)&&Yi(n,t,a),l=l.next}while(l!==r)}mn(e,t,n);break;case 1:if(!rt&&(cr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(f){Re(n,t,f)}mn(e,t,n);break;case 21:mn(e,t,n);break;case 22:n.mode&1?(rt=(r=rt)||n.memoizedState!==null,mn(e,t,n),rt=r):mn(e,t,n);break;default:mn(e,t,n)}}function Gu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new zf),t.forEach(function(r){var l=Af.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Lt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=a),r&=~o}if(r=l,r=ze()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Df(r/1960))-r,10e?16:e,gn===null)var r=!1;else{if(e=gn,gn=null,io=0,(he&6)!==0)throw Error(s(331));var l=he;for(he|=4,V=e.current;V!==null;){var o=V,a=o.child;if((V.flags&16)!==0){var f=o.deletions;if(f!==null){for(var m=0;mze()-bi?Bn(e,0):qi|=n),ct(e,t)}function sc(e,t){t===0&&((e.mode&1)===0?t=1:(t=vl,vl<<=1,(vl&130023424)===0&&(vl=4194304)));var n=ot();e=Jt(e,t),e!==null&&(_r(e,t,n),ct(e,n))}function Bf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sc(e,n)}function Af(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(s(314))}r!==null&&r.delete(t),sc(e,n)}var ac;ac=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||it.current)at=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return at=!1,Pf(e,t,n);at=(e.flags&131072)!==0}else at=!1,je&&(t.flags&1048576)!==0&&Aa(t,Fl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;bl(e,t),e=t.pendingProps;var l=tr(t,et.current);sr(t,n),l=Ri(null,t,r,e,l,n);var o=zi();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,st(r)?(o=!0,Ml(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,ji(t),l.updater=Zl,t.stateNode=l,l._reactInternals=t,Wi(t,r,e,n),t=Ai(null,t,r,!0,o,n)):(t.tag=0,je&&o&&pi(t),lt(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(bl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Vf(r),e=Rt(r,e),l){case 0:t=Bi(null,t,r,e,n);break e;case 1:t=Du(null,t,r,e,n);break e;case 11:t=Tu(null,t,r,e,n);break e;case 14:t=Ru(null,t,r,Rt(r.type,e),n);break e}throw Error(s(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Rt(r,l),Bi(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Rt(r,l),Du(e,t,r,l,n);case 3:e:{if(Mu(t),e===null)throw Error(s(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Xa(e,t),Hl(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=ur(Error(s(423)),t),t=Iu(e,t,r,n,l);break e}else if(r!==l){l=ur(Error(s(424)),t),t=Iu(e,t,r,n,l);break e}else for(vt=un(t.stateNode.containerInfo.firstChild),mt=t,je=!0,Tt=null,n=Ga(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(lr(),r===l){t=Zt(e,t,n);break e}lt(e,t,r,n)}t=t.child}return t;case 5:return ba(t),e===null&&vi(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,a=l.children,si(r,l)?a=null:o!==null&&si(r,o)&&(t.flags|=32),Ou(e,t),lt(e,t,a,n),t.child;case 6:return e===null&&vi(t),null;case 13:return Wu(e,t,n);case 4:return Ci(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=or(t,null,r,n):lt(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Rt(r,l),Tu(e,t,r,l,n);case 7:return lt(e,t,t.pendingProps,n),t.child;case 8:return lt(e,t,t.pendingProps.children,n),t.child;case 12:return lt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,a=l.value,ye(Al,r._currentValue),r._currentValue=a,o!==null)if(Pt(o.value,a)){if(o.children===l.children&&!it.current){t=Zt(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var f=o.dependencies;if(f!==null){a=o.child;for(var m=f.firstContext;m!==null;){if(m.context===r){if(o.tag===1){m=Xt(-1,n&-n),m.tag=2;var C=o.updateQueue;if(C!==null){C=C.shared;var L=C.pending;L===null?m.next=m:(m.next=L.next,L.next=m),C.pending=m}}o.lanes|=n,m=o.alternate,m!==null&&(m.lanes|=n),wi(o.return,n,t),f.lanes|=n;break}m=m.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(s(341));a.lanes|=n,f=a.alternate,f!==null&&(f.lanes|=n),wi(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}lt(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,sr(t,n),l=St(l),r=r(l),t.flags|=1,lt(e,t,r,n),t.child;case 14:return r=t.type,l=Rt(r,t.pendingProps),l=Rt(r.type,l),Ru(e,t,r,l,n);case 15:return zu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Rt(r,l),bl(e,t),t.tag=1,st(r)?(e=!0,Ml(t)):e=!1,sr(t,n),Su(t,r,l),Wi(t,r,l,n),Ai(null,t,r,!0,e,n);case 19:return Uu(e,t,n);case 22:return Lu(e,t,n)}throw Error(s(156,t.tag))};function uc(e,t){return $s(e,t)}function $f(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Et(e,t,n,r){return new $f(e,t,n,r)}function ss(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Vf(e){if(typeof e=="function")return ss(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ee)return 11;if(e===be)return 14}return 2}function kn(e,t){var n=e.alternate;return n===null?(n=Et(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function co(e,t,n,r,l,o){var a=2;if(r=e,typeof e=="function")ss(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Ce:return $n(n.children,l,o,t);case xe:a=8,l|=8;break;case qe:return e=Et(12,n,t,l|2),e.elementType=qe,e.lanes=o,e;case Te:return e=Et(13,n,t,l),e.elementType=Te,e.lanes=o,e;case Ae:return e=Et(19,n,t,l),e.elementType=Ae,e.lanes=o,e;case ve:return fo(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case We:a=10;break e;case Ke:a=9;break e;case Ee:a=11;break e;case be:a=14;break e;case Oe:a=16,r=null;break e}throw Error(s(130,e==null?e:typeof e,""))}return t=Et(a,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function $n(e,t,n,r){return e=Et(7,e,r,t),e.lanes=n,e}function fo(e,t,n,r){return e=Et(22,e,r,t),e.elementType=ve,e.lanes=n,e.stateNode={isHidden:!1},e}function as(e,t,n){return e=Et(6,e,null,t),e.lanes=n,e}function us(e,t,n){return t=Et(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Hf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Io(0),this.expirationTimes=Io(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Io(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function cs(e,t,n,r,l,o,a,f,m){return e=new Hf(e,t,n,f,m),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Et(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ji(o),e}function Qf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(u){console.error(u)}}return i(),vs.exports=ip(),vs.exports}var jc;function sp(){if(jc)return xo;jc=1;var i=Bc();return xo.createRoot=i.createRoot,xo.hydrateRoot=i.hydrateRoot,xo}var ap=sp();Bc();/** - * @remix-run/router v1.23.3 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function al(){return al=Object.assign?Object.assign.bind():function(i){for(var u=1;u"u")throw new Error(u)}function Ts(i,u){if(!i){typeof console<"u"&&console.warn(u);try{throw new Error(u)}catch{}}}function cp(){return Math.random().toString(36).substr(2,8)}function Ec(i,u){return{usr:i.state,key:i.key,idx:u}}function js(i,u,s,d){return s===void 0&&(s=null),al({pathname:typeof i=="string"?i:i.pathname,search:"",hash:""},typeof u=="string"?yr(u):u,{state:s,key:u&&u.key||d||cp()})}function Co(i){let{pathname:u="/",search:s="",hash:d=""}=i;return s&&s!=="?"&&(u+=s.charAt(0)==="?"?s:"?"+s),d&&d!=="#"&&(u+=d.charAt(0)==="#"?d:"#"+d),u}function yr(i){let u={};if(i){let s=i.indexOf("#");s>=0&&(u.hash=i.substr(s),i=i.substr(0,s));let d=i.indexOf("?");d>=0&&(u.search=i.substr(d),i=i.substr(0,d)),i&&(u.pathname=i)}return u}function dp(i,u,s,d){d===void 0&&(d={});let{window:p=document.defaultView,v5Compat:h=!1}=d,g=p.history,j=Sn.Pop,k=null,_=P();_==null&&(_=0,g.replaceState(al({},g.state,{idx:_}),""));function P(){return(g.state||{idx:null}).idx}function N(){j=Sn.Pop;let E=P(),A=E==null?null:E-_;_=E,k&&k({action:j,location:T.location,delta:A})}function M(E,A){j=Sn.Push;let $=js(T.location,E,A);_=P()+1;let J=Ec($,_),U=T.createHref($);try{g.pushState(J,"",U)}catch(ce){if(ce instanceof DOMException&&ce.name==="DataCloneError")throw ce;p.location.assign(U)}h&&k&&k({action:j,location:T.location,delta:1})}function H(E,A){j=Sn.Replace;let $=js(T.location,E,A);_=P();let J=Ec($,_),U=T.createHref($);g.replaceState(J,"",U),h&&k&&k({action:j,location:T.location,delta:0})}function K(E){let A=p.location.origin!=="null"?p.location.origin:p.location.href,$=typeof E=="string"?E:Co(E);return $=$.replace(/ $/,"%20"),Pe(A,"No window.location.(origin|href) available to create URL for href: "+$),new URL($,A)}let T={get action(){return j},get location(){return i(p,g)},listen(E){if(k)throw new Error("A history only accepts one active listener");return p.addEventListener(Cc,N),k=E,()=>{p.removeEventListener(Cc,N),k=null}},createHref(E){return u(p,E)},createURL:K,encodeLocation(E){let A=K(E);return{pathname:A.pathname,search:A.search,hash:A.hash}},push:M,replace:H,go(E){return g.go(E)}};return T}var _c;(function(i){i.data="data",i.deferred="deferred",i.redirect="redirect",i.error="error"})(_c||(_c={}));function fp(i,u,s){return s===void 0&&(s="/"),pp(i,u,s)}function pp(i,u,s,d){let p=typeof u=="string"?yr(u):u,h=vr(p.pathname||"/",s);if(h==null)return null;let g=Ac(i);hp(g);let j=null,k=Ep(h);for(let _=0;j==null&&_{let k={relativePath:j===void 0?h.path||"":j,caseSensitive:h.caseSensitive===!0,childrenIndex:g,route:h};k.relativePath.startsWith("/")&&(Pe(k.relativePath.startsWith(d),'Absolute route path "'+k.relativePath+'" nested under path '+('"'+d+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),k.relativePath=k.relativePath.slice(d.length));let _=jn([d,k.relativePath]),P=s.concat(k);h.children&&h.children.length>0&&(Pe(h.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+_+'".')),Ac(h.children,u,P,_)),!(h.path==null&&!h.index)&&u.push({path:_,score:wp(_,h.index),routesMeta:P})};return i.forEach((h,g)=>{var j;if(h.path===""||!((j=h.path)!=null&&j.includes("?")))p(h,g);else for(let k of $c(h.path))p(h,g,k)}),u}function $c(i){let u=i.split("/");if(u.length===0)return[];let[s,...d]=u,p=s.endsWith("?"),h=s.replace(/\?$/,"");if(d.length===0)return p?[h,""]:[h];let g=$c(d.join("/")),j=[];return j.push(...g.map(k=>k===""?h:[h,k].join("/"))),p&&j.push(...g),j.map(k=>i.startsWith("/")&&k===""?"/":k)}function hp(i){i.sort((u,s)=>u.score!==s.score?s.score-u.score:Sp(u.routesMeta.map(d=>d.childrenIndex),s.routesMeta.map(d=>d.childrenIndex)))}const mp=/^:[\w-]+$/,vp=3,gp=2,yp=1,xp=10,kp=-2,Nc=i=>i==="*";function wp(i,u){let s=i.split("/"),d=s.length;return s.some(Nc)&&(d+=kp),u&&(d+=gp),s.filter(p=>!Nc(p)).reduce((p,h)=>p+(mp.test(h)?vp:h===""?yp:xp),d)}function Sp(i,u){return i.length===u.length&&i.slice(0,-1).every((d,p)=>d===u[p])?i[i.length-1]-u[u.length-1]:0}function jp(i,u,s){let{routesMeta:d}=i,p={},h="/",g=[];for(let j=0;j{let{paramName:M,isOptional:H}=P;if(M==="*"){let T=j[N]||"";g=h.slice(0,h.length-T.length).replace(/(.)\/+$/,"$1")}const K=j[N];return H&&!K?_[M]=void 0:_[M]=(K||"").replace(/%2F/g,"/"),_},{}),pathname:h,pathnameBase:g,pattern:i}}function Cp(i,u,s){u===void 0&&(u=!1),s===void 0&&(s=!0),Ts(i==="*"||!i.endsWith("*")||i.endsWith("/*"),'Route path "'+i+'" will be treated as if it were '+('"'+i.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+i.replace(/\*$/,"/*")+'".'));let d=[],p="^"+i.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(g,j,k)=>(d.push({paramName:j,isOptional:k!=null}),k?"/?([^\\/]+)?":"/([^\\/]+)"));return i.endsWith("*")?(d.push({paramName:"*"}),p+=i==="*"||i==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?p+="\\/*$":i!==""&&i!=="/"&&(p+="(?:(?=\\/|$))"),[new RegExp(p,u?void 0:"i"),d]}function Ep(i){try{return i.split("/").map(u=>decodeURIComponent(u).replace(/\//g,"%2F")).join("/")}catch(u){return Ts(!1,'The URL path "'+i+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+u+").")),i}}function vr(i,u){if(u==="/")return i;if(!i.toLowerCase().startsWith(u.toLowerCase()))return null;let s=u.endsWith("/")?u.length-1:u.length,d=i.charAt(s);return d&&d!=="/"?null:i.slice(s)||"/"}const _p=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Np=i=>_p.test(i);function Pp(i,u){u===void 0&&(u="/");let{pathname:s,search:d="",hash:p=""}=typeof i=="string"?yr(i):i,h;if(s)if(Np(s))h=s;else{if(s.includes("//")){let g=s;s=Vc(s),Ts(!1,"Pathnames cannot have embedded double slashes - normalizing "+(g+" -> "+s))}s.startsWith("/")?h=Pc(s.substring(1),"/"):h=Pc(s,u)}else h=u;return{pathname:h,search:zp(d),hash:Lp(p)}}function Pc(i,u){let s=u.replace(/\/+$/,"").split("/");return i.split("/").forEach(p=>{p===".."?s.length>1&&s.pop():p!=="."&&s.push(p)}),s.length>1?s.join("/"):"/"}function xs(i,u,s,d){return"Cannot include a '"+i+"' character in a manually specified "+("`to."+u+"` field ["+JSON.stringify(d)+"]. Please separate it out to the ")+("`to."+s+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Tp(i){return i.filter((u,s)=>s===0||u.route.path&&u.route.path.length>0)}function Rs(i,u){let s=Tp(i);return u?s.map((d,p)=>p===s.length-1?d.pathname:d.pathnameBase):s.map(d=>d.pathnameBase)}function zs(i,u,s,d){d===void 0&&(d=!1);let p;typeof i=="string"?p=yr(i):(p=al({},i),Pe(!p.pathname||!p.pathname.includes("?"),xs("?","pathname","search",p)),Pe(!p.pathname||!p.pathname.includes("#"),xs("#","pathname","hash",p)),Pe(!p.search||!p.search.includes("#"),xs("#","search","hash",p)));let h=i===""||p.pathname==="",g=h?"/":p.pathname,j;if(g==null)j=s;else{let N=u.length-1;if(!d&&g.startsWith("..")){let M=g.split("/");for(;M[0]==="..";)M.shift(),N-=1;p.pathname=M.join("/")}j=N>=0?u[N]:"/"}let k=Pp(p,j),_=g&&g!=="/"&&g.endsWith("/"),P=(h||g===".")&&s.endsWith("/");return!k.pathname.endsWith("/")&&(_||P)&&(k.pathname+="/"),k}const Vc=i=>i.replace(/\/\/+/g,"/"),jn=i=>Vc(i.join("/")),Rp=i=>i.replace(/\/+$/,"").replace(/^\/*/,"/"),zp=i=>!i||i==="?"?"":i.startsWith("?")?i:"?"+i,Lp=i=>!i||i==="#"?"":i.startsWith("#")?i:"#"+i;function Op(i){return i!=null&&typeof i.status=="number"&&typeof i.statusText=="string"&&typeof i.internal=="boolean"&&"data"in i}const Hc=["post","put","patch","delete"];new Set(Hc);const Dp=["get",...Hc];new Set(Dp);/** - * React Router v6.30.4 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function ul(){return ul=Object.assign?Object.assign.bind():function(i){for(var u=1;u{j.current=!0}),S.useCallback(function(_,P){if(P===void 0&&(P={}),!j.current)return;if(typeof _=="number"){d.go(_);return}let N=zs(_,JSON.parse(g),h,P.relative==="path");i==null&&u!=="/"&&(N.pathname=N.pathname==="/"?u:jn([u,N.pathname])),(P.replace?d.replace:d.push)(N,P.state,P)},[u,d,g,h,i])}function Po(i,u){let{relative:s}=u===void 0?{}:u,{future:d}=S.useContext(bt),{matches:p}=S.useContext(Cn),{pathname:h}=kr(),g=JSON.stringify(Rs(p,d.v7_relativeSplatPath));return S.useMemo(()=>zs(i,JSON.parse(g),h,s==="path"),[i,g,h,s])}function Wp(i,u){return Fp(i,u)}function Fp(i,u,s,d){xr()||Pe(!1);let{navigator:p}=S.useContext(bt),{matches:h}=S.useContext(Cn),g=h[h.length-1],j=g?g.params:{};g&&g.pathname;let k=g?g.pathnameBase:"/";g&&g.route;let _=kr(),P;if(u){var N;let E=typeof u=="string"?yr(u):u;k==="/"||(N=E.pathname)!=null&&N.startsWith(k)||Pe(!1),P=E}else P=_;let M=P.pathname||"/",H=M;if(k!=="/"){let E=k.replace(/^\//,"").split("/");H="/"+M.replace(/^\//,"").split("/").slice(E.length).join("/")}let K=fp(i,{pathname:H}),T=Vp(K&&K.map(E=>Object.assign({},E,{params:Object.assign({},j,E.params),pathname:jn([k,p.encodeLocation?p.encodeLocation(E.pathname).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?k:jn([k,p.encodeLocation?p.encodeLocation(E.pathnameBase).pathname:E.pathnameBase])})),h,s,d);return u&&T?S.createElement(No.Provider,{value:{location:ul({pathname:"/",search:"",hash:"",state:null,key:"default"},P),navigationType:Sn.Pop}},T):T}function Up(){let i=Yp(),u=Op(i)?i.status+" "+i.statusText:i instanceof Error?i.message:JSON.stringify(i),s=i instanceof Error?i.stack:null,p={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},u),s?S.createElement("pre",{style:p},s):null,null)}const Bp=S.createElement(Up,null);class Ap extends S.Component{constructor(u){super(u),this.state={location:u.location,revalidation:u.revalidation,error:u.error}}static getDerivedStateFromError(u){return{error:u}}static getDerivedStateFromProps(u,s){return s.location!==u.location||s.revalidation!=="idle"&&u.revalidation==="idle"?{error:u.error,location:u.location,revalidation:u.revalidation}:{error:u.error!==void 0?u.error:s.error,location:s.location,revalidation:u.revalidation||s.revalidation}}componentDidCatch(u,s){console.error("React Router caught the following error during render",u,s)}render(){return this.state.error!==void 0?S.createElement(Cn.Provider,{value:this.props.routeContext},S.createElement(Kc.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function $p(i){let{routeContext:u,match:s,children:d}=i,p=S.useContext(_o);return p&&p.static&&p.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(p.staticContext._deepestRenderedBoundaryId=s.route.id),S.createElement(Cn.Provider,{value:u},d)}function Vp(i,u,s,d){var p;if(u===void 0&&(u=[]),s===void 0&&(s=null),d===void 0&&(d=null),i==null){var h;if(!s)return null;if(s.errors)i=s.matches;else if((h=d)!=null&&h.v7_partialHydration&&u.length===0&&!s.initialized&&s.matches.length>0)i=s.matches;else return null}let g=i,j=(p=s)==null?void 0:p.errors;if(j!=null){let P=g.findIndex(N=>N.route.id&&(j==null?void 0:j[N.route.id])!==void 0);P>=0||Pe(!1),g=g.slice(0,Math.min(g.length,P+1))}let k=!1,_=-1;if(s&&d&&d.v7_partialHydration)for(let P=0;P=0?g=g.slice(0,_+1):g=[g[0]];break}}}return g.reduceRight((P,N,M)=>{let H,K=!1,T=null,E=null;s&&(H=j&&N.route.id?j[N.route.id]:void 0,T=N.route.errorElement||Bp,k&&(_<0&&M===0?(Jp("route-fallback"),K=!0,E=null):_===M&&(K=!0,E=N.route.hydrateFallbackElement||null)));let A=u.concat(g.slice(0,M+1)),$=()=>{let J;return H?J=T:K?J=E:N.route.Component?J=S.createElement(N.route.Component,null):N.route.element?J=N.route.element:J=P,S.createElement($p,{match:N,routeContext:{outlet:P,matches:A,isDataRoute:s!=null},children:J})};return s&&(N.route.ErrorBoundary||N.route.errorElement||M===0)?S.createElement(Ap,{location:s.location,revalidation:s.revalidation,component:T,error:H,children:$(),routeContext:{outlet:null,matches:A,isDataRoute:!0}}):$()},null)}var Jc=(function(i){return i.UseBlocker="useBlocker",i.UseRevalidator="useRevalidator",i.UseNavigateStable="useNavigate",i})(Jc||{}),Xc=(function(i){return i.UseBlocker="useBlocker",i.UseLoaderData="useLoaderData",i.UseActionData="useActionData",i.UseRouteError="useRouteError",i.UseNavigation="useNavigation",i.UseRouteLoaderData="useRouteLoaderData",i.UseMatches="useMatches",i.UseRevalidator="useRevalidator",i.UseNavigateStable="useNavigate",i.UseRouteId="useRouteId",i})(Xc||{});function Hp(i){let u=S.useContext(_o);return u||Pe(!1),u}function Qp(i){let u=S.useContext(Qc);return u||Pe(!1),u}function Kp(i){let u=S.useContext(Cn);return u||Pe(!1),u}function Zc(i){let u=Kp(),s=u.matches[u.matches.length-1];return s.route.id||Pe(!1),s.route.id}function Yp(){var i;let u=S.useContext(Kc),s=Qp(),d=Zc();return u!==void 0?u:(i=s.errors)==null?void 0:i[d]}function Gp(){let{router:i}=Hp(Jc.UseNavigateStable),u=Zc(Xc.UseNavigateStable),s=S.useRef(!1);return Yc(()=>{s.current=!0}),S.useCallback(function(p,h){h===void 0&&(h={}),s.current&&(typeof p=="number"?i.navigate(p):i.navigate(p,ul({fromRouteId:u},h)))},[i,u])}const Tc={};function Jp(i,u,s){Tc[i]||(Tc[i]=!0)}function Xp(i,u){i==null||i.v7_startTransition,i==null||i.v7_relativeSplatPath}function ks(i){let{to:u,replace:s,state:d,relative:p}=i;xr()||Pe(!1);let{future:h,static:g}=S.useContext(bt),{matches:j}=S.useContext(Cn),{pathname:k}=kr(),_=Gc(),P=zs(u,Rs(j,h.v7_relativeSplatPath),k,p==="path"),N=JSON.stringify(P);return S.useEffect(()=>_(JSON.parse(N),{replace:s,state:d,relative:p}),[_,N,p,s,d]),null}function il(i){Pe(!1)}function Zp(i){let{basename:u="/",children:s=null,location:d,navigationType:p=Sn.Pop,navigator:h,static:g=!1,future:j}=i;xr()&&Pe(!1);let k=u.replace(/^\/*/,"/"),_=S.useMemo(()=>({basename:k,navigator:h,static:g,future:ul({v7_relativeSplatPath:!1},j)}),[k,j,h,g]);typeof d=="string"&&(d=yr(d));let{pathname:P="/",search:N="",hash:M="",state:H=null,key:K="default"}=d,T=S.useMemo(()=>{let E=vr(P,k);return E==null?null:{location:{pathname:E,search:N,hash:M,state:H,key:K},navigationType:p}},[k,P,N,M,H,K,p]);return T==null?null:S.createElement(bt.Provider,{value:_},S.createElement(No.Provider,{children:s,value:T}))}function qp(i){let{children:u,location:s}=i;return Wp(Es(u),s)}new Promise(()=>{});function Es(i,u){u===void 0&&(u=[]);let s=[];return S.Children.forEach(i,(d,p)=>{if(!S.isValidElement(d))return;let h=[...u,p];if(d.type===S.Fragment){s.push.apply(s,Es(d.props.children,h));return}d.type!==il&&Pe(!1),!d.props.index||!d.props.children||Pe(!1);let g={id:d.props.id||h.join("-"),caseSensitive:d.props.caseSensitive,element:d.props.element,Component:d.props.Component,index:d.props.index,path:d.props.path,loader:d.props.loader,action:d.props.action,errorElement:d.props.errorElement,ErrorBoundary:d.props.ErrorBoundary,hasErrorBoundary:d.props.ErrorBoundary!=null||d.props.errorElement!=null,shouldRevalidate:d.props.shouldRevalidate,handle:d.props.handle,lazy:d.props.lazy};d.props.children&&(g.children=Es(d.props.children,h)),s.push(g)}),s}/** - * React Router DOM v6.30.4 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function Eo(){return Eo=Object.assign?Object.assign.bind():function(i){for(var u=1;u{_&&Rc?Rc(()=>k(N)):k(N)},[k,_]);return S.useLayoutEffect(()=>g.listen(P),[g,P]),S.useEffect(()=>Xp(d),[d]),S.createElement(Zp,{basename:u,children:s,location:j.location,navigationType:j.action,navigator:g,future:d})}const sh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ah=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,uh=S.forwardRef(function(u,s){let{onClick:d,relative:p,reloadDocument:h,replace:g,state:j,target:k,to:_,preventScrollReset:P,viewTransition:N}=u,M=qc(u,th),{basename:H}=S.useContext(bt),K,T=!1;if(typeof _=="string"&&ah.test(_)&&(K=_,sh))try{let J=new URL(window.location.href),U=_.startsWith("//")?new URL(J.protocol+_):new URL(_),ce=vr(U.pathname,H);U.origin===J.origin&&ce!=null?_=ce+U.search+U.hash:T=!0}catch{}let E=Mp(_,{relative:p}),A=fh(_,{replace:g,state:j,target:k,preventScrollReset:P,relative:p,viewTransition:N});function $(J){d&&d(J),J.defaultPrevented||A(J)}return S.createElement("a",Eo({},M,{href:K||E,onClick:T||h?d:$,ref:s,target:k}))}),ch=S.forwardRef(function(u,s){let{"aria-current":d="page",caseSensitive:p=!1,className:h="",end:g=!1,style:j,to:k,viewTransition:_,children:P}=u,N=qc(u,nh),M=Po(k,{relative:N.relative}),H=kr(),K=S.useContext(Qc),{navigator:T,basename:E}=S.useContext(bt),A=K!=null&&ph(M)&&_===!0,$=T.encodeLocation?T.encodeLocation(M).pathname:M.pathname,J=H.pathname,U=K&&K.navigation&&K.navigation.location?K.navigation.location.pathname:null;p||(J=J.toLowerCase(),U=U?U.toLowerCase():null,$=$.toLowerCase()),U&&E&&(U=vr(U,E)||U);const ce=$!=="/"&&$.endsWith("/")?$.length-1:$.length;let de=J===$||!g&&J.startsWith($)&&J.charAt(ce)==="/",Ce=U!=null&&(U===$||!g&&U.startsWith($)&&U.charAt($.length)==="/"),xe={isActive:de,isPending:Ce,isTransitioning:A},qe=de?d:void 0,We;typeof h=="function"?We=h(xe):We=[h,de?"active":null,Ce?"pending":null,A?"transitioning":null].filter(Boolean).join(" ");let Ke=typeof j=="function"?j(xe):j;return S.createElement(uh,Eo({},N,{"aria-current":qe,className:We,ref:s,style:Ke,to:k,viewTransition:_}),typeof P=="function"?P(xe):P)});var _s;(function(i){i.UseScrollRestoration="useScrollRestoration",i.UseSubmit="useSubmit",i.UseSubmitFetcher="useSubmitFetcher",i.UseFetcher="useFetcher",i.useViewTransitionState="useViewTransitionState"})(_s||(_s={}));var zc;(function(i){i.UseFetcher="useFetcher",i.UseFetchers="useFetchers",i.UseScrollRestoration="useScrollRestoration"})(zc||(zc={}));function dh(i){let u=S.useContext(_o);return u||Pe(!1),u}function fh(i,u){let{target:s,replace:d,state:p,preventScrollReset:h,relative:g,viewTransition:j}=u===void 0?{}:u,k=Gc(),_=kr(),P=Po(i,{relative:g});return S.useCallback(N=>{if(eh(N,s)){N.preventDefault();let M=d!==void 0?d:Co(_)===Co(P);k(i,{replace:M,state:p,preventScrollReset:h,relative:g,viewTransition:j})}},[_,k,P,d,p,s,i,h,g,j])}function ph(i,u){u===void 0&&(u={});let s=S.useContext(lh);s==null&&Pe(!1);let{basename:d}=dh(_s.useViewTransitionState),p=Po(i,{relative:u.relative});if(!s.isTransitioning)return!1;let h=vr(s.currentLocation.pathname,d)||s.currentLocation.pathname,g=vr(s.nextLocation.pathname,d)||s.nextLocation.pathname;return Cs(p.pathname,g)!=null||Cs(p.pathname,h)!=null}function hh(){if(window.matchMedia("(display-mode: standalone)").matches)return;const i=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith("hnf_inactivity_mins="));if(!i)return;const u=parseInt(i.split("=")[1]);return isNaN(u)||u<=0?void 0:u*60*1e3}const Lc={background:"var(--navy-dark)",border:"1px solid var(--surface-2)",borderRadius:"6px",color:"var(--text)",padding:"0.625rem 0.75rem",fontSize:"1rem",width:"100%",outline:"none"},mh={background:"var(--hk-green)",color:"#fff",border:"none",borderRadius:"6px",padding:"0.625rem",fontSize:"1rem",fontWeight:600,marginTop:"0.25rem",width:"100%"};function vh({children:i}){const[u,s]=S.useState("checking"),[d,p]=S.useState(null),[h,g]=S.useState(""),[j,k]=S.useState(""),[_,P]=S.useState(""),[N,M]=S.useState(!1),H=S.useRef(null);S.useEffect(()=>{fetch("/api/auth/verify?app=hk-planner",{credentials:"include"}).then(async T=>{T.ok?(p(await T.json()),s("authed")):s("login")}).catch(()=>s("login"))},[]),S.useEffect(()=>{const T=hh();if(u!=="authed"||!T)return;async function E(){await fetch("/api/auth/logout",{method:"POST",credentials:"include"}).catch(()=>{}),p(null),s("login")}function A(){H.current&&clearTimeout(H.current),H.current=setTimeout(E,T)}const $=["mousemove","keydown","click","touchstart"];return $.forEach(J=>window.addEventListener(J,A,{passive:!0})),A(),()=>{H.current&&clearTimeout(H.current),$.forEach(J=>window.removeEventListener(J,A))}},[u]);async function K(T){T.preventDefault(),M(!0),P("");try{if(!(await fetch("/api/auth/login",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:h,password:j})})).ok){P("Invalid email or password");return}const A=await fetch("/api/auth/verify?app=hk-planner",{credentials:"include"});A.ok?(p(await A.json()),s("authed")):P("You don't have access to this app.")}catch{P("Connection error — please try again")}finally{M(!1)}}return u==="checking"?c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100dvh"},children:c.jsx("div",{style:{color:"var(--text-muted)"},children:"Loading…"})}):u==="login"?c.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100dvh",padding:"1.5rem",background:"var(--navy-dark)"},children:c.jsxs("div",{style:{background:"var(--navy)",borderRadius:"var(--radius)",padding:"2rem",width:"100%",maxWidth:"360px",border:"1px solid var(--surface-2)"},children:[c.jsx("h1",{style:{fontSize:"1.4rem",marginBottom:"0.25rem",color:"#74c69d"},children:"HK Planner"}),c.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.875rem",marginBottom:"1.5rem"},children:void 0}),c.jsxs("form",{onSubmit:K,style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[c.jsx("input",{type:"email",value:h,onChange:T=>g(T.target.value),placeholder:"Email",required:!0,autoComplete:"email",style:Lc}),c.jsx("input",{type:"password",value:j,onChange:T=>k(T.target.value),placeholder:"Password",required:!0,autoComplete:"current-password",style:Lc}),_&&c.jsx("p",{style:{color:"#f87171",fontSize:"0.875rem"},children:_}),c.jsx("button",{type:"submit",disabled:N,style:mh,children:N?"Signing in…":"Sign in"})]})]})}):c.jsx(c.Fragment,{children:i(d)})}/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bc=(...i)=>i.filter((u,s,d)=>!!u&&u.trim()!==""&&d.indexOf(u)===s).join(" ").trim();/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gh=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yh=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(u,s,d)=>d?d.toUpperCase():s.toLowerCase());/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Oc=i=>{const u=yh(i);return u.charAt(0).toUpperCase()+u.slice(1)};/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var ws={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const xh=i=>{for(const u in i)if(u.startsWith("aria-")||u==="role"||u==="title")return!0;return!1},kh=S.createContext({}),wh=()=>S.useContext(kh),Sh=S.forwardRef(({color:i,size:u,strokeWidth:s,absoluteStrokeWidth:d,className:p="",children:h,iconNode:g,...j},k)=>{const{size:_=24,strokeWidth:P=2,absoluteStrokeWidth:N=!1,color:M="currentColor",className:H=""}=wh()??{},K=d??N?Number(s??P)*24/Number(u??_):s??P;return S.createElement("svg",{ref:k,...ws,width:u??_??ws.width,height:u??_??ws.height,stroke:i??M,strokeWidth:K,className:bc("lucide",H,p),...!h&&!xh(j)&&{"aria-hidden":"true"},...j},[...g.map(([T,E])=>S.createElement(T,E)),...Array.isArray(h)?h:[h]])});/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cl=(i,u)=>{const s=S.forwardRef(({className:d,...p},h)=>S.createElement(Sh,{ref:h,iconNode:u,className:bc(`lucide-${gh(Oc(i))}`,`lucide-${i}`,d),...p}));return s.displayName=Oc(i),s};/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const jh=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Dc=cl("calendar-clock",jh);/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ch=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Eh=cl("grip-vertical",Ch);/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _h=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Nh=cl("log-out",_h);/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ph=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ns=cl("refresh-cw",Ph);/** - * @license lucide-react v1.24.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Th=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Rh=cl("settings",Th);function zh({visible:i}){return i?c.jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"var(--sidebar)",color:"var(--text-light)",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"10px 16px",fontSize:"14px",boxShadow:"0 -2px 8px rgba(0,0,0,0.3)"},children:[c.jsx("span",{children:"A new version is available."}),c.jsxs("button",{onClick:()=>window.location.reload(),style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--accent)",color:"var(--sidebar)",border:"none",borderRadius:"4px",padding:"6px 14px",fontWeight:600,cursor:"pointer",fontSize:"13px"},children:[c.jsx(Ns,{size:14,strokeWidth:1.75}),"Reload"]})]}):null}const Lh=120*1e3;function Oh(i){const[u,s]=S.useState(!1);return S.useEffect(()=>{let d=null;async function p(){try{const j=await fetch(i,{cache:"no-store"});if(!j.ok)return;const _=(await j.json()).version;if(!_)return;d===null?d=_:_!==d&&s(!0)}catch{}}p();const h=setInterval(p,Lh);function g(){document.visibilityState==="visible"&&p()}return document.addEventListener("visibilitychange",g),()=>{clearInterval(h),document.removeEventListener("visibilitychange",g)}},[i]),u}function ed(i,u){return i.is_admin||i.caps.includes(u)}const Dh="width=1280",Mh="width=device-width, initial-scale=1.0";function Mc(i){const u=document.querySelector('meta[name="viewport"]');u&&(u.content=i)}function Ih(i){S.useEffect(()=>(Mc(Dh),window.parent.postMessage({type:"hnf:viewport",mode:i},"*"),()=>{Mc(Mh),window.parent.postMessage({type:"hnf:viewport",mode:"responsive"},"*")}),[i])}function Wh({user:i,children:u}){Ih("desktop");async function s(){await fetch("/hk-planner/api/auth/logout",{method:"POST",credentials:"include"}),window.location.reload()}return c.jsxs("div",{style:{display:"flex",height:"100dvh",overflow:"hidden"},children:[c.jsxs("nav",{style:{width:"200px",flexShrink:0,background:"var(--navy)",display:"flex",flexDirection:"column",padding:"1rem 0",borderRight:"1px solid var(--surface-2)"},children:[c.jsx("div",{style:{padding:"0 1rem 1rem",borderBottom:"1px solid var(--surface-2)"},children:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[c.jsx(Dc,{size:20,strokeWidth:1.75,color:"#74c69d"}),c.jsx("span",{style:{color:"#74c69d",fontWeight:700,fontSize:"0.95rem"},children:"HK Planner"})]})}),c.jsxs("div",{className:"nav-scroll",style:{flex:1,padding:"0.5rem 0",overflowY:"auto"},children:[c.jsx(Ic,{to:"/planner",icon:Dc,label:"Planner"}),ed(i,"settings")&&c.jsx(Ic,{to:"/settings",icon:Rh,label:"Settings"})]}),c.jsxs("div",{style:{padding:"0.75rem 1rem",borderTop:"1px solid var(--surface-2)"},children:[c.jsxs("div",{style:{marginBottom:"0.5rem"},children:[c.jsx("div",{style:{color:"var(--text)",fontSize:"0.8rem",fontWeight:600},children:i.name}),c.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.72rem"},children:i.email})]}),c.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"0.5rem",background:"none",border:"none",color:"var(--text-muted)",fontSize:"0.8rem",padding:"0.375rem 0",width:"100%",cursor:"pointer"},children:[c.jsx(Nh,{size:14,strokeWidth:1.75}),"Sign out"]})]})]}),c.jsx("main",{style:{flex:1,overflow:"auto",background:"var(--body-bg)"},children:u})]})}function Ic({to:i,icon:u,label:s}){return c.jsxs(ch,{to:i,style:({isActive:d})=>({display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.625rem 1rem",textDecoration:"none",color:d?"#74c69d":"var(--text)",background:d?"var(--surface)":"transparent",borderLeft:d?"2px solid #74c69d":"2px solid transparent",fontSize:"0.875rem",transition:"background 0.15s"}),children:[c.jsx(u,{size:15,strokeWidth:1.75}),s]})}const Fh="/hk-planner/api";async function Ze(i,u){const s=await fetch(Fh+i,{credentials:"include",...u});if(s.status===401)throw(window.top??window).location.href="/login",new Error("Unauthenticated");if(!s.ok){const d=await s.json().catch(()=>({}));throw new Error(d.error||`HTTP ${s.status}`)}return s.json()}function Uh(i,u,s=!1){const d=new URLSearchParams;return i&&d.set("week_start",i),u&&d.set("last_viewed",u),s&&d.set("force_refresh","1"),Ze(`/bookings?${d}`)}function td(){return Ze("/config")}function Bh(i,u,s){return Ze("/config/time-requirements",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cat:i,action:u,value:s})})}function Ah(i){return Ze("/config/staff",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({staff_data:i})})}function $h(i){return Ze("/config/pickup",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({pickup_data:i})})}function Vh(i){return Ze("/config/general-tasks",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({general_tasks:i})})}function Hh(i){return Ze("/config/last-reviewed",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({date:i})})}function Qh(){return Ze("/categories")}function Kh(i,u){return Ze("/categories",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:i,excluded:u})})}function Yh(){return Ze("/newbook/test",{method:"POST"})}function Gh(){return Ze("/workforce/departments")}function Jh(i){return Ze("/config/workforce-departments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dept_ids:i})})}function Xh(){return Ze("/workforce/sync",{method:"POST"})}function Wc(i,u){return Ze(`/workforce/shifts?start=${i}&end=${u}`)}function Zh(){return Ze("/workforce/staff")}function qh(i){return Ze("/config/adjustments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({adjustments:i})})}function bh(i){return Ze("/config/warning-thresholds",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}function ko(){const i=new Date;return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function wo(i,u){const[s,d,p]=i.split("-").map(Number),h=new Date(s,d-1,p);return h.setDate(h.getDate()+u),`${h.getFullYear()}-${String(h.getMonth()+1).padStart(2,"0")}-${String(h.getDate()).padStart(2,"0")}`}function To(i){const u=new Date(i+"T00:00:00");return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][u.getDay()]+" "+u.getDate()+" "+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][u.getMonth()]}function em(i){const u=new Date(i+"T00:00:00");return["Mon","Tue","Wed","Thu","Fri","Sat","Sun"][(u.getDay()+6)%7]}function tm(i){const u=new Date(i+"T00:00:00");return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][u.getDay()]}function sl(i){const u=new Date(i+"T00:00:00").getDay();return u===0||u===6}function nm(i,u){const s=u.pickup_hint??0,d=u.pickup_lead??0,p=s>0?`${s} room${s===1?"":"s"} picked up within ${d} day${d===1?"":"s"} of arrival`:"no late pickups";return`Last ${tm(i)}: ${u.prior_occ} occ (${u.prior_vac} vac) — ${p}`}function Fc(i){return new Date(i+"T00:00:00").toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function Xe(i){return i.toFixed(2)+"h"}function gr(i,u,s,d,p){var _;const h=Math.max(0,p-d),g=(_=i[u])==null?void 0:_[s];if(!g||!g.count)return 0;const j=g.total-g.count,k=d>j?Math.max(0,g.total-d):g.count;return Math.min(k,h)}function rm(i,u,s,d,p){const h={};for(const g of i.dates){const j=em(g),k=d.reduce((P,N)=>P+(N.hours[j]||0)/60,0),_=p.reduce((P,N)=>P+(N.hours[g]||0),0);h[g]={booked:0,pickup:0,general:k,adjustments:_,total:k+_,by_cat:{},pickup_by_cat:{}}}for(const g of i.categories){const j=u[g.id]||{depart:0,stay:0,arrive:0};i.dates.forEach((k,_)=>{const P=g.days[k],N=P.stays+P.arrivals,M=gr(s,g.id,k,N,g.total_rooms),H=(P.departs*(j.depart||0)+P.stays*(j.stay||0)+P.arrivals*(j.arrive||0))/60,K=M*(j.arrive||0)/60;h[k].by_cat[g.id]=H,h[k].pickup_by_cat[g.id]=(h[k].pickup_by_cat[g.id]||0)+K,h[k].booked+=H,h[k].pickup+=K,h[k].total+=H+K;const T=i.dates[_+1];if(T&&M>0){const E=M*(j.depart||0)/60;h[T].pickup_by_cat[g.id]=(h[T].pickup_by_cat[g.id]||0)+E,h[T].pickup+=E,h[T].total+=E}})}return h}function lm(){const[i,u]=S.useState(null),[s,d]=S.useState({}),[p,h]=S.useState([]),[g,j]=S.useState({}),[k,_]=S.useState([]),[P,N]=S.useState([]),[M,H]=S.useState(4),[K,T]=S.useState(1),[E,A]=S.useState(1),[$,J]=S.useState(2),[U,ce]=S.useState({}),[de,Ce]=S.useState([]),[xe,qe]=S.useState(!1),[We,Ke]=S.useState(null),[Ee,Te]=S.useState(""),[Ae,be]=S.useState(""),[Oe,ve]=S.useState(!0),[W,X]=S.useState(""),[F,y]=S.useState(null),R=S.useRef({}),ee=S.useRef(null),re=S.useRef(!1),le=S.useRef(null);le.current=We;function oe(te,pe,De=400){clearTimeout(R.current[te]),R.current[te]=setTimeout(pe,De)}function ae(te,pe=!1){ee.current&&clearTimeout(ee.current),y({text:te,err:pe}),ee.current=setTimeout(()=>y(null),pe?15e3:2500)}function se(){const te=ko();te!==Ae&&(be(te),Hh(te).catch(()=>{}))}const fe=S.useCallback(async(te=!1,pe)=>{ve(!0),X("");const De=ko(),Ye=le.current||De,ft=wo(Ye,6),pt=pe!==void 0?pe||wo(De,-1):Ee||Ae||wo(De,-1);try{const[$e,ke,yt]=await Promise.all([Uh(Ye,pt,te),td(),Wc(Ye,ft).catch(()=>({}))]);u($e),d(ke.time_requirements||{}),h(ke.staff_data||[]),j(ke.pickup_data||{}),_(ke.general_tasks||[]),N(ke.adjustments||[]),H(ke.warn_over_red_hrs??4),T(ke.warn_over_amber_hrs??1),A(ke.warn_under_amber_hrs??1),J(ke.warn_under_red_hrs??2),ce(yt),ke.last_reviewed&&(be(ke.last_reviewed),Ee||Te(ke.last_reviewed))}catch($e){X($e instanceof Error?$e.message:"Failed to load data")}finally{ve(!1)}},[Ee,Ae]);S.useEffect(()=>{fe(!1)},[]),S.useEffect(()=>{Object.keys(U).length>0&&!re.current&&(re.current=!0,Zh().then(Ce).catch(()=>{}))},[U]),S.useEffect(()=>{function te(De,Ye){fetch(De,{method:"PUT",keepalive:!0,credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ye)})}function pe(){p.length&&te("/hk-planner/api/config/staff",{staff_data:p}),Object.keys(g).length&&te("/hk-planner/api/config/pickup",{pickup_data:g}),P.length&&te("/hk-planner/api/config/adjustments",{adjustments:P})}return window.addEventListener("beforeunload",pe),()=>window.removeEventListener("beforeunload",pe)},[p,g,P]);function Fe(te){const pe=ko(),De=wo(le.current||pe,te);le.current=De,Ke(De),se(),fe(!0)}function At(){le.current=null,Ke(null),se(),fe(!0)}function En(){se(),fe(!0)}function $t(te,pe,De,Ye){const ft=Ye.days[pe],pt=ft.stays+ft.arrivals,$e=Math.max(0,Ye.total_rooms-pt),ke=gr(g,te,pe,pt,Ye.total_rooms),yt=Math.max(0,Math.min(ke+De,$e)),Tn={...g,[te]:{...g[te]||{},[pe]:{count:yt,total:pt+yt}}};j(Tn),se(),oe("pickup",()=>$h(Tn).then(()=>ae("Pickup saved")).catch(Vn=>ae(Vn.message,!0)))}function Vt(te){N(te),oe("adjustments",()=>qh(te).then(()=>ae("Adjustments saved")).catch(pe=>ae(pe.message,!0)))}function _n(){Vt([...P,{label:"",hours:{}}])}function en(te){h(te),se(),oe("staff",()=>Ah(te).then(()=>ae("Staff hours saved")).catch(pe=>ae(pe.message,!0)))}function Ht(){en([...p,{name:"",hours:{}}])}async function Nn(){qe(!0);try{if(await Xh(),i){const te=await Wc(i.dates[0],i.dates[i.dates.length-1]);ce(te)}ae("Rota synced from Workforce")}catch(te){ae(te instanceof Error?te.message:"Sync failed",!0)}finally{qe(!1)}}function tn(){if(!i)return"";const te=i.dates.filter($e=>U[$e]);if(!te.length)return"Not synced";const pe=te.reduce(($e,ke)=>new Date(U[ke].synced_at)!U[$e]).length?`Partial sync — from ${Ye} ${ft}`:`From ${Ye} ${ft}`}const _t=i?rm(i,s,g,k,P):null,Dt=ko(),Pn=We||Dt;return c.jsxs("div",{style:{padding:"1.5rem",maxWidth:"1600px"},children:[c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0.75rem",marginBottom:"1.25rem"},children:[c.jsxs("div",{children:[c.jsx("h1",{style:{fontSize:"1.15rem",fontWeight:700,color:"var(--text-dark)"},children:"Housekeeping Planner"}),i&&c.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-mid)",marginTop:"0.1rem"},children:[Fc(i.dates[0])," – ",Fc(i.dates[i.dates.length-1])]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",marginLeft:"auto",flexWrap:"wrap"},children:[c.jsx(hr,{onClick:()=>Fe(-7),children:"‹ Prev"}),c.jsx(hr,{onClick:At,primary:!0,children:"Today"}),c.jsx(hr,{onClick:()=>Fe(7),children:"Next ›"}),c.jsx("input",{type:"date",value:Pn,onChange:te=>{if(te.target.value){const pe=te.target.value;le.current=pe,Ke(pe),se(),oe("weekStart",()=>fe(!0),600)}},style:{border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.35rem 0.5rem",fontSize:"0.82rem",color:"var(--text-dark)"}}),c.jsx("div",{style:{width:"1px",height:"24px",background:"var(--card-border)"}}),c.jsxs("label",{style:{fontSize:"0.78rem",color:"var(--text-mid)",display:"flex",alignItems:"center",gap:"0.3rem"},children:[c.jsx("span",{children:"Since"}),c.jsx("input",{type:"date",value:Ee,onChange:te=>{if(te.target.value){const pe=te.target.value;Te(pe),oe("lastViewed",()=>fe(!0,pe),600)}},style:{border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.3rem 0.5rem",fontSize:"0.78rem",color:"var(--text-dark)"}})]}),c.jsx(hr,{onClick:()=>{se(),fe(!0)},children:"Update to now"}),c.jsx("div",{style:{width:"1px",height:"24px",background:"var(--card-border)"}}),c.jsx("button",{onClick:En,title:"Refresh",style:{background:"var(--card-bg)",border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.35rem 0.5rem",display:"flex",alignItems:"center",gap:"0.3rem",fontSize:"0.82rem",color:"var(--text-dark)"},children:c.jsx(Ns,{size:13,strokeWidth:1.75,style:{animation:Oe?"spin 1s linear infinite":"none"}})})]})]}),c.jsx("style",{children:"@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }"}),F&&c.jsx("div",{style:{display:"inline-block",marginBottom:"0.75rem",padding:"0.35rem 0.75rem",borderRadius:"6px",fontSize:"0.8rem",fontWeight:500,background:F.err?"#fee2e2":"#dcfce7",color:F.err?"var(--danger)":"var(--success)"},children:F.text}),W&&c.jsxs("div",{style:{marginBottom:"1rem",padding:"0.75rem 1rem",borderRadius:"8px",background:"#fee2e2",color:"var(--danger)",fontSize:"0.875rem"},children:["Error: ",W]}),Oe&&!i&&c.jsx("div",{style:{color:"var(--text-mid)",padding:"2rem 0",textAlign:"center"},children:"Loading bookings…"}),i&&_t&&c.jsxs(c.Fragment,{children:[c.jsx(So,{title:"7-Day Occupancy",children:c.jsx("div",{className:"table-scroll",children:c.jsx(om,{bookings:i,pickup:g,onPickupChange:$t})})}),c.jsx(So,{title:"Required Hours",children:c.jsx("div",{className:"table-scroll",children:c.jsx(am,{bookings:i,required:_t})})}),c.jsx(So,{title:"Adjustments",action:c.jsx(hr,{onClick:_n,children:"+ Add adjustment"}),children:c.jsx("div",{className:"table-scroll",children:c.jsx(fm,{bookings:i,adjustments:P,onChange:Vt})})}),c.jsx(So,{title:"Staff Rota",action:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flexWrap:"wrap"},children:[c.jsxs("button",{onClick:Nn,disabled:xe,style:{display:"flex",alignItems:"center",gap:"0.3rem",background:"var(--card-bg)",color:"var(--text-dark)",border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.3rem 0.65rem",fontSize:"0.78rem",fontWeight:600},children:[c.jsx(Ns,{size:11,strokeWidth:1.75,style:{animation:xe?"spin 1s linear infinite":"none"}}),xe?"Syncing…":"Sync from Workforce"]}),c.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:tn()}),c.jsx(hr,{onClick:Ht,children:"+ Add staff"})]}),children:c.jsx("div",{className:"table-scroll",children:c.jsx(cm,{bookings:i,staff:p,required:_t,warnOverRed:M,warnOverAmber:K,warnUnderAmber:E,warnUnderRed:$,onChange:en,wfShifts:U,wfStaff:de})})})]})]})}function So({title:i,children:u,action:s}){return c.jsxs("div",{style:{marginBottom:"1.5rem"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"0.5rem"},children:[c.jsx("h2",{style:{fontSize:"0.72rem",fontWeight:700,color:"var(--text-mid)",textTransform:"uppercase",letterSpacing:"0.08em"},children:i}),s]}),u]})}function hr({children:i,onClick:u,primary:s}){return c.jsx("button",{onClick:u,style:{background:s?"var(--hk-green)":"var(--card-bg)",color:s?"#fff":"var(--text-dark)",border:`1px solid ${s?"var(--hk-green)":"var(--card-border)"}`,borderRadius:"6px",padding:"0.35rem 0.75rem",fontSize:"0.82rem",fontWeight:600},children:i})}function om({bookings:i,pickup:u,onPickupChange:s}){const{dates:d,categories:p}=i;return c.jsxs("table",{className:"hk-table",children:[c.jsxs("thead",{children:[c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",rowSpan:2,children:"Category"}),d.map(h=>c.jsx("th",{colSpan:2,style:{borderLeft:"2px solid rgba(255,255,255,0.3)",...sl(h)?{background:"#253555"}:{}},children:To(h)},h))]}),c.jsx("tr",{children:d.map(h=>c.jsxs(c.Fragment,{children:[c.jsx("th",{style:{fontSize:"0.72rem",fontWeight:400,minWidth:"72px",background:sl(h)?"#2a3d5e":"#1e2d42",borderLeft:"2px solid rgba(255,255,255,0.3)"},children:"Rooms"},h+"-r"),c.jsx("th",{style:{fontSize:"0.72rem",fontWeight:400,minWidth:"56px",textAlign:"center",background:sl(h)?"#2a3d5e":"#1e2d42",borderLeft:"1px solid rgba(255,255,255,0.1)"},children:"D / S / A"},h+"-d")]}))})]}),c.jsx("tbody",{children:p.map((h,g)=>{const j=g===p.length-1;return c.jsx(im,{cat:h,dates:d,pickup:u,onPickupChange:(k,_)=>s(h.id,k,_,h),isLast:j},h.id)})}),c.jsx("tfoot",{children:c.jsx(sm,{dates:d,cats:p,pickup:u})})]})}function im({cat:i,dates:u,pickup:s,onPickupChange:d,isLast:p}){const h=p?"2px solid var(--card-border)":void 0;return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{borderBottom:h},children:i.name}),u.map((g,j)=>{var ce;const k=i.days[g],_=k.stays+k.arrivals,P=Math.max(0,i.total_rooms-_),N=gr(s,i.id,g,_,i.total_rooms),M=u[j-1],H=M?i.days[M].stays+i.days[M].arrivals:0,K=M?gr(s,i.id,M,H,i.total_rooms):0,T=k.delta_new||0,E=k.delta_cancelled||0,A=sl(g),$=(ce=s[i.id])==null?void 0:ce[g],J=nm(g,k);let U="";if($&&$.count){const de=$.total-$.count,Ce=_>de?"changed":"unchanged",xe=_>de?"decreased":"remains";U=`+${$.count} pickup set when booked was ${de} (target ${$.total}). Booked ${Ce}, so pickup ${xe}.`}return U=(U?U+" | ":"")+J,c.jsxs(c.Fragment,{children:[c.jsxs("td",{style:{textAlign:"center",verticalAlign:"middle",borderBottom:h,padding:"0.4rem 0.3rem",borderLeft:"2px solid var(--card-border)",...A?{background:"rgba(100,120,160,0.07)"}:{}},children:[(T>0||E>0)&&c.jsxs("div",{style:{marginBottom:"2px",fontSize:"0.72rem"},children:[T>0&&c.jsxs("span",{className:"delta-new",children:["▲",T]}),E>0&&c.jsxs("span",{className:"delta-canc",children:[" ▼",E]})]}),c.jsxs("div",{style:{fontWeight:700,fontSize:"1.1rem"},title:U,children:[_,N>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",N]})]}),c.jsxs("div",{style:{fontSize:"0.72rem",color:"var(--text-mid)",marginBottom:"4px"},children:[P," vac",N>0&&c.jsxs("span",{className:"pickup-tag",children:[" (",P-N,")"]})]}),c.jsxs("div",{className:"pickup-ctrl",children:[c.jsx("button",{className:"pickup-btn",disabled:N<=0,onClick:()=>d(g,-1),children:"−"}),c.jsx("span",{className:"pickup-num",children:N}),c.jsx("button",{className:"pickup-btn",disabled:N>=P,title:J,onClick:()=>d(g,1),children:"+"})]})]},g+"-r"),c.jsxs("td",{style:{verticalAlign:"middle",borderLeft:"1px solid var(--card-border)",borderBottom:h,padding:"0.4rem 0.3rem",textAlign:"center",...A?{background:"rgba(100,120,160,0.07)"}:{}},children:[c.jsxs("div",{style:{fontSize:"0.8rem",color:"#c2502e",fontWeight:600},children:[k.departs,"d",K>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",K]})]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1d6fb8",fontWeight:600},children:[k.stays,"s"]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1a7a4a",fontWeight:600},children:[k.arrivals,"a",N>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",N]})]})]},g+"-dsa")]})})]})}function sm({dates:i,cats:u,pickup:s}){return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontStyle:"italic"},children:"Total"}),i.map((d,p)=>{let h=0,g=0,j=0,k=0,_=0,P=0,N=0,M=0,H=0;for(const T of u){const E=T.days[d],A=E.stays+E.arrivals,$=Math.max(0,T.total_rooms-A),J=gr(s,T.id,d,A,T.total_rooms),U=i[p-1],ce=U?T.days[U].stays+T.days[U].arrivals:0,de=U?gr(s,T.id,U,ce,T.total_rooms):0;h+=A,g+=$,j+=J,k+=de,_+=E.departs,P+=E.stays,N+=E.arrivals,M+=E.delta_new||0,H+=E.delta_cancelled||0}const K=sl(d);return c.jsxs(c.Fragment,{children:[c.jsxs("td",{style:{textAlign:"center",verticalAlign:"middle",padding:"0.4rem 0.3rem",borderLeft:"2px solid var(--card-border)",...K?{background:"rgba(100,120,160,0.07)"}:{}},children:[(M>0||H>0)&&c.jsxs("div",{style:{marginBottom:"2px",fontSize:"0.72rem"},children:[M>0&&c.jsxs("span",{className:"delta-new",children:["▲",M]}),H>0&&c.jsxs("span",{className:"delta-canc",children:[" ▼",H]})]}),c.jsxs("div",{style:{fontWeight:700,fontSize:"1.1rem"},children:[h,j>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",j]})]}),c.jsxs("div",{style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:[g," vac",j>0&&c.jsxs("span",{className:"pickup-tag",children:[" (",g-j,")"]})]})]},d+"-r"),c.jsxs("td",{style:{verticalAlign:"middle",borderLeft:"1px solid var(--card-border)",padding:"0.4rem 0.3rem",textAlign:"center",...K?{background:"rgba(100,120,160,0.07)"}:{}},children:[c.jsxs("div",{style:{fontSize:"0.8rem",color:"#c2502e",fontWeight:600},children:[_,"d",k>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",k]})]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1d6fb8",fontWeight:600},children:[P,"s"]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1a7a4a",fontWeight:600},children:[N,"a",j>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",j]})]})]},d+"-dsa")]})})]})}function am({bookings:i,required:u}){const{dates:s,categories:d}=i;return c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Category"}),s.map(p=>c.jsx("th",{children:To(p)},p))]})}),c.jsx("tbody",{children:d.map(p=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",children:p.name}),s.map(h=>{const g=u[h].by_cat[p.id]||0,j=u[h].pickup_by_cat[p.id]||0;return c.jsxs("td",{children:[g===0&&j===0?"—":Xe(g),j>.001&&c.jsxs("span",{className:"pickup-tag",children:[" (+",Xe(j),")"]})]},h)})]},p.id))}),c.jsxs("tfoot",{children:[c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Booked hrs"}),s.map(p=>c.jsx("td",{children:Xe(u[p].booked)},p))]}),c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Pickup hrs"}),s.map(p=>c.jsx("td",{children:u[p].pickup>.001?Xe(u[p].pickup):"—"},p))]}),c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Recurring tasks"}),s.map(p=>c.jsx("td",{children:u[p].general>.001?Xe(u[p].general):"—"},p))]}),s.some(p=>u[p].adjustments!==0)&&c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Adjustments"}),s.map(p=>{const h=u[p].adjustments;return c.jsx("td",{style:{color:h<0?"var(--danger)":h>0?"#1a7a4a":"var(--text-mid)"},children:h===0?"—":(h>0?"+":"")+Xe(h)},p)})]}),c.jsxs("tr",{style:{background:"#e2e8f0"},children:[c.jsx("td",{className:"col-label",children:"Total Required"}),s.map(p=>c.jsxs("td",{style:{fontWeight:700},children:[Xe(u[p].total),u[p].pickup>.001&&c.jsxs("span",{className:"pickup-tag",style:{display:"block",fontSize:"0.7rem"},children:["inc ",Xe(u[p].pickup)," pickup"]})]},p))]})]})]})}function um(i,u){const s={};for(const d of u){const p=i[d];if(p)for(const h of p.staff)s[h.id]||(s[h.id]={id:h.id,name:h.name,days:{}}),s[h.id].days[d]={hours:h.hours,times:h.times}}return Object.values(s).sort((d,p)=>d.name.localeCompare(p.name))}function cm({bookings:i,staff:u,required:s,warnOverRed:d,warnOverAmber:p,warnUnderAmber:h,warnUnderRed:g,onChange:j,wfShifts:k,wfStaff:_}){const{dates:P}=i;function N(T,E){const A=u.map(($,J)=>J===T?{...$,name:E}:$);j(A)}function M(T,E,A){const $=parseFloat(A),J=u.map((U,ce)=>{if(ce!==T)return U;const de={...U.hours};return!isNaN($)&&$>=0?de[E]=$:delete de[E],{...U,hours:de}});j(J)}function H(T){j(u.filter((E,A)=>A!==T))}const K=um(k,P);return c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Staff Member"}),P.map(T=>c.jsx("th",{children:To(T)},T)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsxs("tbody",{children:[K.map(T=>c.jsxs("tr",{style:{background:"rgba(42,100,72,0.05)"},children:[c.jsxs("td",{className:"col-label",children:[c.jsx("span",{style:{display:"inline-block",fontSize:"0.67rem",fontWeight:700,background:"rgba(42,100,72,0.18)",color:"#1a7a4a",borderRadius:"3px",padding:"0 4px",marginRight:"0.4rem",lineHeight:"1.5"},children:"WF"}),T.name]}),P.map(E=>{const A=T.days[E];return c.jsx("td",{style:{textAlign:"center",padding:"0.3rem 0.4rem",verticalAlign:"middle"},children:A?c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{fontSize:"0.68rem",color:"var(--text-mid)",lineHeight:1.25},children:A.times}),c.jsx("div",{style:{fontWeight:600},children:Xe(A.hours)})]}):c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"})},E)}),c.jsx("td",{})]},"wf-"+T.id)),_.length>0&&c.jsx("datalist",{id:"wf-staff-datalist",children:_.map(T=>c.jsx("option",{value:T.name},T.id))}),u.map((T,E)=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:T.name,placeholder:"Staff name",list:_.length>0?"wf-staff-datalist":void 0,onChange:A=>N(E,A.target.value)})}),P.map(A=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:24,step:.5,value:T.hours[A]??"",placeholder:"0",onChange:$=>M(E,A,$.target.value)})},A)),c.jsx("td",{children:c.jsx("button",{onClick:()=>H(E),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},E))]}),c.jsx("tfoot",{children:(()=>{const T={};for(const E of P){const A=K.reduce((J,U)=>{var ce;return J+(((ce=U.days[E])==null?void 0:ce.hours)||0)},0),$=u.reduce((J,U)=>J+(U.hours[E]||0),0);T[E]=A+$}return c.jsxs(c.Fragment,{children:[c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.78rem",color:"var(--text-mid)"},children:"Total Available"}),P.map(E=>c.jsx("td",{children:Xe(T[E])},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"vs Booked"}),P.map(E=>c.jsx("td",{children:c.jsx(Ss,{available:T[E],required:s[E].booked,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"with Recurring Tasks"}),P.map(E=>c.jsx("td",{children:c.jsx(Ss,{available:T[E],required:s[E].booked+s[E].general,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"with Pickup"}),P.map(E=>c.jsx("td",{children:c.jsx(Ss,{available:T[E],required:s[E].booked+s[E].general+s[E].pickup,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{style:{background:"#e2e8f0"},children:[c.jsx("td",{className:"col-label",style:{fontWeight:700},children:"with Adjustments"}),P.map(E=>c.jsx("td",{children:c.jsx(dm,{available:T[E],required:s[E].total,warnOverRed:d,warnOverAmber:p,warnUnderAmber:h,warnUnderRed:g})},E)),c.jsx("td",{})]})]})})()})]})}function Ss({available:i,required:u,warnOverAmber:s,warnUnderAmber:d}){if(i===0&&u===0)return c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"});const p=i-u,h=p>s?"⚠":p<-d?"✗":"✓";return c.jsxs("span",{style:{color:"var(--text-mid)",fontSize:"0.82rem"},children:[h," ",p>=0?"+":"",Xe(p)]})}function dm({available:i,required:u,warnOverRed:s,warnOverAmber:d,warnUnderAmber:p,warnUnderRed:h}){if(i===0&&u===0)return c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"});const g=i-u;return g>s?c.jsxs("span",{className:"diff-over-red",children:["⚠ ",Xe(g)," spare"]}):g>d?c.jsxs("span",{className:"diff-over",children:["⚠ ",Xe(g)," spare"]}):g<-h?c.jsxs("span",{className:"diff-under",children:["✗ ",Xe(Math.abs(g))," short"]}):g<-p?c.jsxs("span",{className:"diff-under-amber",children:["✗ ",Xe(Math.abs(g))," short"]}):c.jsxs("span",{className:"diff-ok",children:["✓ ",g>=0?"+":"",Xe(g)]})}function fm({bookings:i,adjustments:u,onChange:s}){const{dates:d}=i;function p(j,k){s(u.map((_,P)=>P===j?{..._,label:k}:_))}function h(j,k,_){const P=parseFloat(_);s(u.map((N,M)=>{if(M!==j)return N;const H={...N.hours};return isNaN(P)?delete H[k]:H[k]=P,{...N,hours:H}}))}function g(j){s(u.filter((k,_)=>_!==j))}return u.length===0?c.jsx("p",{style:{color:"var(--text-mid)",fontSize:"0.82rem",padding:"0.5rem 0"},children:'No adjustments — use "+ Add adjustment" above to add a one-off hour offset for a specific date.'}):c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Label"}),d.map(j=>c.jsx("th",{children:To(j)},j)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsx("tbody",{children:u.map((j,k)=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:j.label,placeholder:"e.g. Rooms from Sunday",onChange:_=>p(k,_.target.value)})}),d.map(_=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",step:.25,value:j.hours[_]??"",placeholder:"0",onChange:P=>h(k,_,P.target.value)})},_)),c.jsx("td",{children:c.jsx("button",{onClick:()=>g(k),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},k))}),c.jsx("tfoot",{children:c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.78rem",color:"var(--text-mid)"},children:"Total"}),d.map(j=>{const k=u.reduce((_,P)=>_+(P.hours[j]||0),0);return c.jsx("td",{style:{color:k<0?"var(--danger)":k>0?"#1a7a4a":"var(--text-mid)",fontWeight:k!==0?600:void 0},children:k===0?"—":(k>0?"+":"")+Xe(k)},j)}),c.jsx("td",{})]})})]})}const Uc=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function pm(){const[i,u]=S.useState([]),[s,d]=S.useState(!0),[p,h]=S.useState(!1),[g,j]=S.useState(!1),[k,_]=S.useState(""),[P,N]=S.useState(""),[M,H]=S.useState(null),[K,T]=S.useState([]),[E,A]=S.useState([]),[$,J]=S.useState(!0),[U,ce]=S.useState(""),[de,Ce]=S.useState(!1),[xe,qe]=S.useState(!1),[We,Ke]=S.useState(""),[Ee,Te]=S.useState([]),[Ae,be]=S.useState(!1),[Oe,ve]=S.useState(""),[W,X]=S.useState(""),[F,y]=S.useState({}),[R,ee]=S.useState(""),[re,le]=S.useState(""),[oe,ae]=S.useState(4),[se,fe]=S.useState(1),[Fe,At]=S.useState(1),[En,$t]=S.useState(2),[Vt,_n]=S.useState(!1),[en,Ht]=S.useState(""),[Nn,tn]=S.useState("");S.useEffect(()=>{Promise.all([Qh(),td(),Gh().catch(I=>(I.message.includes("503")||I.message.toLowerCase().includes("not configured")?Ce(!0):ce(I.message),null))]).then(([I,ne,ie])=>{u(I.categories),Te(ne.general_tasks||[]),y(ne.time_requirements||{}),A(ne.workforce_departments||[]),ae(ne.warn_over_red_hrs??4),fe(ne.warn_over_amber_hrs??1),At(ne.warn_under_amber_hrs??1),$t(ne.warn_under_red_hrs??2),ie&&T(ie),d(!1),J(!1)}).catch(I=>{_(I.message),d(!1),J(!1)})},[]);function _t(I){u(i.map((ne,ie)=>ie===I?{...ne,excluded:!ne.excluded}:ne))}function Dt(I,ne){H(ne),I.dataTransfer.effectAllowed="move"}function Pn(I,ne){if(I.preventDefault(),M===null||M===ne)return;const ie=[...i],[Me]=ie.splice(M,1);ie.splice(ne,0,Me),u(ie),H(ne)}function te(){H(null)}async function pe(){h(!0),_(""),N("");try{await Kh(i.map(I=>I.id),i.filter(I=>I.excluded).map(I=>I.id)),N("Saved"),setTimeout(()=>N(""),2500)}catch(I){_(I instanceof Error?I.message:"Save failed")}finally{h(!1)}}async function De(){j(!0),_(""),N("");try{const I=await Yh();N(I.ok?`Connection OK: ${I.message||""}`:`Failed: ${I.error||"unknown"}`)}catch(I){_(I instanceof Error?I.message:"Test failed")}finally{j(!1)}}function Ye(I){A(ne=>ne.includes(I)?ne.filter(ie=>ie!==I):[...ne,I])}async function ft(){qe(!0),ce(""),Ke("");try{await Jh(E),Ke("Departments saved"),setTimeout(()=>Ke(""),2500)}catch(I){ce(I instanceof Error?I.message:"Save failed")}finally{qe(!1)}}function pt(I,ne){Te(Ee.map((ie,Me)=>Me===I?{...ie,name:ne}:ie))}function $e(I,ne,ie){const Me=parseInt(ie,10);Te(Ee.map((xt,wr)=>wr!==I?xt:{...xt,hours:{...xt.hours,[ne]:isNaN(Me)?0:Math.max(0,Me)}}))}function ke(I){Te(Ee.filter((ne,ie)=>ie!==I))}async function yt(){be(!0),X(""),ve("");try{await Vh(Ee),ve("Saved"),setTimeout(()=>ve(""),2500)}catch(I){X(I instanceof Error?I.message:"Save failed")}finally{be(!1)}}async function Tn(I,ne,ie){const Me={...F,[I]:{...F[I]||{depart:0,stay:0,arrive:0},[ne]:ie}};y(Me);try{await Bh(I,ne,ie),ee("Saved"),setTimeout(()=>ee(""),1500)}catch(xt){le(xt instanceof Error?xt.message:"Save failed")}}async function Vn(){_n(!0),tn(""),Ht("");try{await bh({warn_over_red_hrs:oe,warn_over_amber_hrs:se,warn_under_amber_hrs:Fe,warn_under_red_hrs:En}),Ht("Saved"),setTimeout(()=>Ht(""),2500)}catch(I){tn(I instanceof Error?I.message:"Save failed")}finally{_n(!1)}}return s?c.jsx("div",{style:{padding:"2rem",color:"var(--text-mid)"},children:"Loading…"}):c.jsxs("div",{style:{padding:"1.5rem",maxWidth:"680px"},children:[c.jsx("h1",{style:{fontSize:"1.1rem",fontWeight:700,color:"var(--text-dark)",marginBottom:"1.5rem"},children:"Settings"}),c.jsx(ol,{title:"Room Categories"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Drag to reorder. Toggle to exclude categories from the planner."}),k&&c.jsx(Bt,{type:"error",children:k}),P&&c.jsx(Bt,{type:"ok",children:P}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:i.map((I,ne)=>c.jsxs("div",{draggable:!0,onDragStart:ie=>Dt(ie,ne),onDragOver:ie=>Pn(ie,ne),onDragEnd:te,style:{display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.625rem 0.875rem",border:"1px solid var(--card-border)",borderRadius:"8px",background:I.excluded?"#f8fafc":"var(--card-bg)",opacity:M===ne?.5:1},children:[c.jsx(Eh,{size:16,color:"var(--text-mid)",style:{cursor:"grab",flexShrink:0}}),c.jsx("span",{style:{flex:1,fontSize:"0.9rem",color:I.excluded?"var(--text-mid)":"var(--text-dark)",textDecoration:I.excluded?"line-through":"none"},children:I.name}),c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--text-mid)",marginRight:"0.5rem"},children:[I.room_count," rooms"]}),c.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.375rem",fontSize:"0.8rem",color:"var(--text-mid)"},children:[c.jsx("input",{type:"checkbox",checked:!I.excluded,onChange:()=>_t(ne)}),"Active"]})]},I.id))}),c.jsxs("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap",marginBottom:"2.5rem"},children:[c.jsx(mr,{onClick:pe,disabled:p,primary:!0,children:p?"Saving…":"Save Order & Visibility"}),c.jsx(mr,{onClick:De,disabled:g,children:g?"Testing…":"Test Newbook Connection"})]}),c.jsx(jo,{}),c.jsx(ol,{title:"Workforce Departments"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Select the department(s) whose shifts should appear in the HK staff rota."}),de&&c.jsxs("div",{style:{padding:"0.75rem",borderRadius:"8px",background:"#f8fafc",border:"1px solid var(--card-border)",color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"2rem"},children:["Workforce integration not configured — add the bearer token in ",c.jsx("strong",{children:"Settings → Integrations → Workforce"}),"."]}),!de&&$&&c.jsx("div",{style:{color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"2rem"},children:"Loading departments…"}),!de&&!$&&c.jsxs("div",{style:{marginBottom:"2.5rem"},children:[U&&c.jsx(Bt,{type:"error",children:U}),We&&c.jsx(Bt,{type:"ok",children:We}),K.length===0?c.jsx("div",{style:{color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"1rem"},children:"No departments found for this location."}):c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem",marginBottom:"1rem"},children:K.map(I=>c.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.5rem 0.75rem",border:"1px solid var(--card-border)",borderRadius:"7px",background:E.includes(I.id)?"rgba(42,100,72,0.05)":"var(--card-bg)",cursor:"pointer",fontSize:"0.9rem",color:"var(--text-dark)"},children:[c.jsx("input",{type:"checkbox",checked:E.includes(I.id),onChange:()=>Ye(I.id)}),I.name]},I.id))}),E.length===0&&K.length>0&&c.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"#b45309"},children:"Select at least one department to enable Workforce sync."}),c.jsx(mr,{onClick:ft,disabled:xe,primary:!0,children:xe?"Saving…":"Save Departments"})]}),c.jsx(jo,{}),c.jsx(ol,{title:"Recurring General Tasks"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Tasks that recur every week. Enter minutes per day. These add to the total required hours every week."}),W&&c.jsx(Bt,{type:"error",children:W}),Oe&&c.jsx(Bt,{type:"ok",children:Oe}),c.jsx("div",{style:{overflowX:"auto",marginBottom:"1rem"},children:c.jsxs("table",{className:"hk-table",style:{minWidth:"560px"},children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Task"}),Uc.map(I=>c.jsx("th",{children:I},I)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsxs("tbody",{children:[Ee.length===0&&c.jsx("tr",{children:c.jsx("td",{colSpan:9,style:{color:"var(--text-mid)",textAlign:"center",padding:"1rem"},children:"No tasks yet"})}),Ee.map((I,ne)=>c.jsxs("tr",{children:[c.jsx("td",{style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:I.name,placeholder:"Task name",onChange:ie=>pt(ne,ie.target.value)})}),Uc.map(ie=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:999,value:I.hours[ie]||"",placeholder:"0",onChange:Me=>$e(ne,ie,Me.target.value)})},ie)),c.jsx("td",{children:c.jsx("button",{onClick:()=>ke(ne),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},ne))]})]})}),c.jsxs("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap",marginBottom:"2.5rem"},children:[c.jsx(mr,{onClick:()=>Te([...Ee,{name:"",hours:{}}]),children:"+ Add task"}),c.jsx(mr,{onClick:yt,disabled:Ae,primary:!0,children:Ae?"Saving…":"Save Tasks"})]}),c.jsx(jo,{}),c.jsx(ol,{title:"Time Requirements (minutes per room)"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"How many minutes each room type takes depending on guest status."}),re&&c.jsx(Bt,{type:"error",children:re}),R&&c.jsx(Bt,{type:"ok",children:R}),c.jsx("div",{style:{overflowX:"auto",marginBottom:"2rem"},children:c.jsxs("table",{className:"hk-table",style:{maxWidth:"500px"},children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Category"}),c.jsx("th",{children:"Depart (mins)"}),c.jsx("th",{children:"Stay (mins)"}),c.jsx("th",{children:"Arrive (mins)"})]})}),c.jsx("tbody",{children:i.filter(I=>!I.excluded).map(I=>{const ne=F[I.id]||{depart:0,stay:0,arrive:0};return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",children:I.name}),["depart","stay","arrive"].map(ie=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:999,value:ne[ie]||"",placeholder:"0",onChange:Me=>Tn(I.id,ie,parseInt(Me.target.value,10)||0),onBlur:Me=>Tn(I.id,ie,parseInt(Me.target.value,10)||0)})},ie))]},I.id)})})]})}),c.jsx(jo,{}),c.jsx(ol,{title:"Warning Thresholds"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:'Controls the colour and icon shown on the "with Adjustments" row in the staff rota. All values are in hours.'}),Nn&&c.jsx(Bt,{type:"error",children:Nn}),en&&c.jsx(Bt,{type:"ok",children:en}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.625rem",marginBottom:"1.25rem",maxWidth:"420px"},children:[{label:"⚠ Red warning — spare over",value:oe,set:ae,help:"default 4h"},{label:"⚠ Amber warning — spare over",value:se,set:fe,help:"default 1h"},{label:"✗ Amber cross — short over",value:Fe,set:At,help:"default 1h"},{label:"✗ Red cross — short over",value:En,set:$t,help:"default 2h"}].map(({label:I,value:ne,set:ie,help:Me})=>c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[c.jsx("span",{style:{flex:1,fontSize:"0.875rem",color:"var(--text-dark)"},children:I}),c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:24,step:.5,value:ne,onChange:xt=>ie(parseFloat(xt.target.value)||0),style:{width:"68px"}}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-mid)",minWidth:"52px"},children:Me})]},I))}),c.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Green ✓ is automatic — shown when the difference is within the amber spare and short thresholds above."}),c.jsx("div",{style:{marginBottom:"2.5rem"},children:c.jsx(mr,{onClick:Vn,disabled:Vt,primary:!0,children:Vt?"Saving…":"Save Thresholds"})})]})}function ol({title:i}){return c.jsx("h2",{style:{fontSize:"0.95rem",fontWeight:700,color:"var(--text-dark)",marginBottom:"0.25rem"},children:i})}function jo(){return c.jsx("div",{style:{height:"1px",background:"var(--card-border)",margin:"0.5rem 0 2rem"}})}function Bt({type:i,children:u}){return c.jsx("div",{style:{marginBottom:"0.75rem",padding:"0.75rem",borderRadius:"8px",fontSize:"0.875rem",background:i==="ok"?"#dcfce7":"#fee2e2",color:i==="ok"?"var(--success)":"var(--danger)"},children:u})}function mr({children:i,onClick:u,disabled:s,primary:d}){return c.jsx("button",{onClick:u,disabled:s,style:{background:d?"var(--hk-green)":"var(--card-bg)",color:d?"#fff":"var(--text-dark)",border:`1px solid ${d?"var(--hk-green)":"var(--card-border)"}`,borderRadius:"6px",padding:"0.5rem 1.25rem",fontSize:"0.875rem",fontWeight:600},children:i})}function hm({user:i}){return c.jsx(Wh,{user:i,children:c.jsxs(qp,{children:[c.jsx(il,{path:"/",element:c.jsx(ks,{to:"/planner",replace:!0})}),c.jsx(il,{path:"/planner",element:c.jsx(lm,{})}),c.jsx(il,{path:"/settings",element:ed(i,"settings")?c.jsx(pm,{}):c.jsx(ks,{to:"/planner",replace:!0})}),c.jsx(il,{path:"*",element:c.jsx(ks,{to:"/planner",replace:!0})})]})})}function mm(){const i=Oh("/hk-planner/health");return c.jsxs(c.Fragment,{children:[c.jsx(ih,{basename:"/hk-planner",children:c.jsx(vh,{children:u=>c.jsx(hm,{user:u})})}),c.jsx(zh,{visible:i})]})}new URLSearchParams(window.location.search).has("install")&&window.addEventListener("beforeinstallprompt",i=>{i.preventDefault(),i.prompt()},{once:!0});ap.createRoot(document.getElementById("root")).render(c.jsx(S.StrictMode,{children:c.jsx(mm,{})})); diff --git a/frontend/dist/assets/index-C9TVzZ7i.js b/frontend/dist/assets/index-C9TVzZ7i.js new file mode 100644 index 0000000..0ed3a93 --- /dev/null +++ b/frontend/dist/assets/index-C9TVzZ7i.js @@ -0,0 +1,132 @@ +function qf(o,u){for(var s=0;sd[p]})}}}return Object.freeze(Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}))}(function(){const u=document.createElement("link").relList;if(u&&u.supports&&u.supports("modulepreload"))return;for(const p of document.querySelectorAll('link[rel="modulepreload"]'))d(p);new MutationObserver(p=>{for(const h of p)if(h.type==="childList")for(const g of h.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&d(g)}).observe(document,{childList:!0,subtree:!0});function s(p){const h={};return p.integrity&&(h.integrity=p.integrity),p.referrerPolicy&&(h.referrerPolicy=p.referrerPolicy),p.crossOrigin==="use-credentials"?h.credentials="include":p.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function d(p){if(p.ep)return;p.ep=!0;const h=s(p);fetch(p.href,h)}})();function bf(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var hs={exports:{}},il={},ms={exports:{}},ce={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var vc;function ep(){if(vc)return ce;vc=1;var o=Symbol.for("react.element"),u=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),g=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),_=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),N=Symbol.iterator;function I(y){return y===null||typeof y!="object"?null:(y=N&&y[N]||y["@@iterator"],typeof y=="function"?y:null)}var H={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},K=Object.assign,T={};function E(y,R,ne){this.props=y,this.context=R,this.refs=T,this.updater=ne||H}E.prototype.isReactComponent={},E.prototype.setState=function(y,R){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,R,"setState")},E.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function B(){}B.prototype=E.prototype;function $(y,R,ne){this.props=y,this.context=R,this.refs=T,this.updater=ne||H}var G=$.prototype=new B;G.constructor=$,K(G,E.prototype),G.isPureReactComponent=!0;var F=Array.isArray,ie=Object.prototype.hasOwnProperty,fe={current:null},Ce={key:!0,ref:!0,__self:!0,__source:!0};function ye(y,R,ne){var re,oe={},se=null,de=null;if(R!=null)for(re in R.ref!==void 0&&(de=R.ref),R.key!==void 0&&(se=""+R.key),R)ie.call(R,re)&&!Ce.hasOwnProperty(re)&&(oe[re]=R[re]);var ae=arguments.length-2;if(ae===1)oe.children=ne;else if(1>>1,R=W[y];if(0>>1;yp(oe,U))sep(de,oe)?(W[y]=de,W[se]=U,y=se):(W[y]=oe,W[re]=U,y=re);else if(sep(de,U))W[y]=de,W[se]=U,y=se;else break e}}return X}function p(W,X){var U=W.sortIndex-X.sortIndex;return U!==0?U:W.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var h=performance;o.unstable_now=function(){return h.now()}}else{var g=Date,j=g.now();o.unstable_now=function(){return g.now()-j}}var k=[],_=[],P=1,N=null,I=3,H=!1,K=!1,T=!1,E=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function G(W){for(var X=s(_);X!==null;){if(X.callback===null)d(_);else if(X.startTime<=W)d(_),X.sortIndex=X.expirationTime,u(k,X);else break;X=s(_)}}function F(W){if(T=!1,G(W),!K)if(s(k)!==null)K=!0,De(ie);else{var X=s(_);X!==null&&ve(F,X.startTime-W)}}function ie(W,X){K=!1,T&&(T=!1,B(ye),ye=-1),H=!0;var U=I;try{for(G(X),N=s(k);N!==null&&(!(N.expirationTime>X)||W&&!qe());){var y=N.callback;if(typeof y=="function"){N.callback=null,I=N.priorityLevel;var R=y(N.expirationTime<=X);X=o.unstable_now(),typeof R=="function"?N.callback=R:N===s(k)&&d(k),G(X)}else d(k);N=s(k)}if(N!==null)var ne=!0;else{var re=s(_);re!==null&&ve(F,re.startTime-X),ne=!1}return ne}finally{N=null,I=U,H=!1}}var fe=!1,Ce=null,ye=-1,Ze=5,Le=-1;function qe(){return!(o.unstable_now()-LeW||125y?(W.sortIndex=U,u(_,W),s(k)===null&&W===s(_)&&(T?(B(ye),ye=-1):T=!0,ve(F,U-y))):(W.sortIndex=R,u(k,W),K||H||(K=!0,De(ie))),W},o.unstable_shouldYield=qe,o.unstable_wrapCallback=function(W){var X=I;return function(){var U=I;I=X;try{return W.apply(this,arguments)}finally{I=U}}}})(ys)),ys}var wc;function op(){return wc||(wc=1,gs.exports=ip()),gs.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Sc;function sp(){if(Sc)return ht;Sc=1;var o=Ts(),u=op();function s(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),k=Object.prototype.hasOwnProperty,_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,P={},N={};function I(e){return k.call(N,e)?!0:k.call(P,e)?!1:_.test(e)?N[e]=!0:(P[e]=!0,!1)}function H(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function K(e,t,n,r){if(t===null||typeof t>"u"||H(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function T(e,t,n,r,l,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new T(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];E[t]=new T(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new T(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new T(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new T(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new T(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new T(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new T(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new T(e,5,!1,e.toLowerCase(),null,!1,!1)});var B=/[\-:]([a-z])/g;function $(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(B,$);E[t]=new T(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(B,$);E[t]=new T(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(B,$);E[t]=new T(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new T(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new T("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new T(e,1,!1,e.toLowerCase(),null,!0,!0)});function G(e,t,n,r){var l=E.hasOwnProperty(t)?E[t]:null;(l!==null?l.type!==0:r||!(2f||l[a]!==i[f]){var m=` +`+l[a].replace(" at new "," at ");return e.displayName&&m.includes("")&&(m=m.replace("",e.displayName)),m}while(1<=a&&0<=f);break}}}finally{ne=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?R(e):""}function oe(e){switch(e.tag){case 5:return R(e.type);case 16:return R("Lazy");case 13:return R("Suspense");case 19:return R("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function se(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ce:return"Fragment";case fe:return"Portal";case Ze:return"Profiler";case ye:return"StrictMode";case Ee:return"Suspense";case Ue:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case qe:return(e.displayName||"Context")+".Consumer";case Le:return(e._context.displayName||"Context")+".Provider";case Oe:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case be:return t=e.displayName||null,t!==null?t:se(e.type)||"Memo";case De:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}function de(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return se(t);case 8:return t===ye?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function ae(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ue(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Se(e){var t=ue(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function lt(e){e._valueTracker||(e._valueTracker=Se(e))}function qt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ue(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Bt(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function bt(e,t){var n=t.checked;return U({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Nn(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ae(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function en(e,t){t=t.checked,t!=null&&G(e,"checked",t,!1)}function At(e,t){en(e,t);var n=ae(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?nn(e,t.type,n):t.hasOwnProperty("defaultValue")&&nn(e,t.type,ae(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function tn(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function nn(e,t,n){(t!=="number"||Bt(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var $t=Array.isArray;function Ot(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Te.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function it(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var at={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},$e=["Webkit","ms","Moz","O"];Object.keys(at).forEach(function(e){$e.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),at[t]=at[e]})});function Re(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||at.hasOwnProperty(e)&&at[e]?(""+t).trim():t+"px"}function D(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Re(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var ee=U({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function le(e,t){if(t){if(ee[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(s(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(s(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(s(61))}if(t.style!=null&&typeof t.style!="object")throw Error(s(62))}}function We(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var xt=null;function Sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ti=null,Hn=null,Qn=null;function Os(e){if(e=Hr(e)){if(typeof Ti!="function")throw Error(s(280));var t=e.stateNode;t&&(t=Ol(t),Ti(e.stateNode,e.type,t))}}function Ds(e){Hn?Qn?Qn.push(e):Qn=[e]:Hn=e}function Ms(){if(Hn){var e=Hn,t=Qn;if(Qn=Hn=null,Os(e),t)for(e=0;e>>=0,e===0?32:31-(pd(e)/hd|0)|0}var ml=64,vl=4194304;function _r(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function gl(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var f=a&~l;f!==0?r=_r(f):(i&=a,i!==0&&(r=_r(i)))}else a=n&~l,a!==0?r=_r(a):i!==0&&(r=_r(i));if(r===0)return 0;if(t!==0&&t!==r&&(t&l)===0&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Nr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-_t(t),e[t]=n}function yd(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Mr),ua=" ",ca=!1;function da(e,t){switch(e){case"keyup":return Kd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fa(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Gn=!1;function Gd(e,t){switch(e){case"compositionend":return fa(t);case"keypress":return t.which!==32?null:(ca=!0,ua);case"textInput":return e=t.data,e===ua&&ca?null:e;default:return null}}function Jd(e,t){if(Gn)return e==="compositionend"||!Yi&&da(e,t)?(e=ra(),Sl=Ai=un=null,Gn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=xa(n)}}function wa(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?wa(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Sa(){for(var e=window,t=Bt();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Bt(e.document)}return t}function Xi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function lf(e){var t=Sa(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&wa(n.ownerDocument.documentElement,n)){if(r!==null&&Xi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=ka(n,i);var a=ka(n,r);l&&a&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Jn=null,Zi=null,Ur=null,qi=!1;function ja(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;qi||Jn==null||Jn!==Bt(r)||(r=Jn,"selectionStart"in r&&Xi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ur&&Fr(Ur,r)||(Ur=r,r=Rl(Zi,"onSelect"),0er||(e.current=co[er],co[er]=null,er--)}function xe(e,t){er++,co[er]=e.current,e.current=t}var pn={},et=fn(pn),ut=fn(!1),zn=pn;function tr(e,t){var n=e.type.contextTypes;if(!n)return pn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function ct(e){return e=e.childContextTypes,e!=null}function Dl(){we(ut),we(et)}function Fa(e,t,n){if(et.current!==pn)throw Error(s(168));xe(et,t),xe(ut,n)}function Ua(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(s(108,de(e)||"Unknown",l));return U({},n,r)}function Ml(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||pn,zn=et.current,xe(et,e),xe(ut,ut.current),!0}function Ba(e,t,n){var r=e.stateNode;if(!r)throw Error(s(169));n?(e=Ua(e,t,zn),r.__reactInternalMemoizedMergedChildContext=e,we(ut),we(et),xe(et,e)):we(ut),xe(ut,n)}var Ht=null,Il=!1,fo=!1;function Aa(e){Ht===null?Ht=[e]:Ht.push(e)}function gf(e){Il=!0,Aa(e)}function hn(){if(!fo&&Ht!==null){fo=!0;var e=0,t=ge;try{var n=Ht;for(ge=1;e>=a,l-=a,Qt=1<<32-_t(t)+l|n<te?(Qe=q,q=null):Qe=q.sibling;var me=z(x,q,w[te],M);if(me===null){q===null&&(q=Qe);break}e&&q&&me.alternate===null&&t(x,q),v=i(me,v,te),Z===null?J=me:Z.sibling=me,Z=me,q=Qe}if(te===w.length)return n(x,q),je&&On(x,te),J;if(q===null){for(;tete?(Qe=q,q=null):Qe=q.sibling;var jn=z(x,q,me.value,M);if(jn===null){q===null&&(q=Qe);break}e&&q&&jn.alternate===null&&t(x,q),v=i(jn,v,te),Z===null?J=jn:Z.sibling=jn,Z=jn,q=Qe}if(me.done)return n(x,q),je&&On(x,te),J;if(q===null){for(;!me.done;te++,me=w.next())me=O(x,me.value,M),me!==null&&(v=i(me,v,te),Z===null?J=me:Z.sibling=me,Z=me);return je&&On(x,te),J}for(q=r(x,q);!me.done;te++,me=w.next())me=A(q,x,te,me.value,M),me!==null&&(e&&me.alternate!==null&&q.delete(me.key===null?te:me.key),v=i(me,v,te),Z===null?J=me:Z.sibling=me,Z=me);return e&&q.forEach(function(Zf){return t(x,Zf)}),je&&On(x,te),J}function Ie(x,v,w,M){if(typeof w=="object"&&w!==null&&w.type===Ce&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case ie:e:{for(var J=w.key,Z=v;Z!==null;){if(Z.key===J){if(J=w.type,J===Ce){if(Z.tag===7){n(x,Z.sibling),v=l(Z,w.props.children),v.return=x,x=v;break e}}else if(Z.elementType===J||typeof J=="object"&&J!==null&&J.$$typeof===De&&Ya(J)===Z.type){n(x,Z.sibling),v=l(Z,w.props),v.ref=Qr(x,Z,w),v.return=x,x=v;break e}n(x,Z);break}else t(x,Z);Z=Z.sibling}w.type===Ce?(v=An(w.props.children,x.mode,M,w.key),v.return=x,x=v):(M=ci(w.type,w.key,w.props,null,x.mode,M),M.ref=Qr(x,v,w),M.return=x,x=M)}return a(x);case fe:e:{for(Z=w.key;v!==null;){if(v.key===Z)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(x,v.sibling),v=l(v,w.children||[]),v.return=x,x=v;break e}else{n(x,v);break}else t(x,v);v=v.sibling}v=us(w,x.mode,M),v.return=x,x=v}return a(x);case De:return Z=w._init,Ie(x,v,Z(w._payload),M)}if($t(w))return Q(x,v,w,M);if(X(w))return Y(x,v,w,M);Bl(x,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(x,v.sibling),v=l(v,w),v.return=x,x=v):(n(x,v),v=as(w,x.mode,M),v.return=x,x=v),a(x)):n(x,v)}return Ie}var ir=Ga(!0),Ja=Ga(!1),Al=fn(null),$l=null,or=null,yo=null;function xo(){yo=or=$l=null}function ko(e){var t=Al.current;we(Al),e._currentValue=t}function wo(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function sr(e,t){$l=e,yo=or=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(dt=!0),e.firstContext=null)}function St(e){var t=e._currentValue;if(yo!==e)if(e={context:e,memoizedValue:t,next:null},or===null){if($l===null)throw Error(s(308));or=e,$l.dependencies={lanes:0,firstContext:e}}else or=or.next=e;return t}var Dn=null;function So(e){Dn===null?Dn=[e]:Dn.push(e)}function Xa(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,So(t)):(n.next=l.next,l.next=n),t.interleaved=n,Yt(e,r)}function Yt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var mn=!1;function jo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Za(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Gt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function vn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(he&2)!==0){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Yt(e,n)}return l=r.interleaved,l===null?(t.next=t,So(r)):(t.next=l.next,l.next=t),r.interleaved=t,Yt(e,n)}function Vl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ii(e,n)}}function qa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Hl(e,t,n,r){var l=e.updateQueue;mn=!1;var i=l.firstBaseUpdate,a=l.lastBaseUpdate,f=l.shared.pending;if(f!==null){l.shared.pending=null;var m=f,C=m.next;m.next=null,a===null?i=C:a.next=C,a=m;var L=e.alternate;L!==null&&(L=L.updateQueue,f=L.lastBaseUpdate,f!==a&&(f===null?L.firstBaseUpdate=C:f.next=C,L.lastBaseUpdate=m))}if(i!==null){var O=l.baseState;a=0,L=C=m=null,f=i;do{var z=f.lane,A=f.eventTime;if((r&z)===z){L!==null&&(L=L.next={eventTime:A,lane:0,tag:f.tag,payload:f.payload,callback:f.callback,next:null});e:{var Q=e,Y=f;switch(z=t,A=n,Y.tag){case 1:if(Q=Y.payload,typeof Q=="function"){O=Q.call(A,O,z);break e}O=Q;break e;case 3:Q.flags=Q.flags&-65537|128;case 0:if(Q=Y.payload,z=typeof Q=="function"?Q.call(A,O,z):Q,z==null)break e;O=U({},O,z);break e;case 2:mn=!0}}f.callback!==null&&f.lane!==0&&(e.flags|=64,z=l.effects,z===null?l.effects=[f]:z.push(f))}else A={eventTime:A,lane:z,tag:f.tag,payload:f.payload,callback:f.callback,next:null},L===null?(C=L=A,m=O):L=L.next=A,a|=z;if(f=f.next,f===null){if(f=l.shared.pending,f===null)break;z=f,f=z.next,z.next=null,l.lastBaseUpdate=z,l.shared.pending=null}}while(!0);if(L===null&&(m=O),l.baseState=m,l.firstBaseUpdate=C,l.lastBaseUpdate=L,t=l.shared.interleaved,t!==null){l=t;do a|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);Wn|=a,e.lanes=a,e.memoizedState=O}}function ba(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Po.transition;Po.transition={};try{e(!1),t()}finally{ge=n,Po.transition=r}}function yu(){return jt().memoizedState}function wf(e,t,n){var r=kn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},xu(e))ku(t,n);else if(n=Xa(e,t,n,r),n!==null){var l=st();Lt(n,e,r,l),wu(n,t,r)}}function Sf(e,t,n){var r=kn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(xu(e))ku(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,f=i(a,n);if(l.hasEagerState=!0,l.eagerState=f,Nt(f,a)){var m=t.interleaved;m===null?(l.next=l,So(t)):(l.next=m.next,m.next=l),t.interleaved=l;return}}catch{}finally{}n=Xa(e,t,l,r),n!==null&&(l=st(),Lt(n,e,r,l),wu(n,t,r))}}function xu(e){var t=e.alternate;return e===Ne||t!==null&&t===Ne}function ku(e,t){Jr=Yl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function wu(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ii(e,n)}}var Xl={readContext:St,useCallback:tt,useContext:tt,useEffect:tt,useImperativeHandle:tt,useInsertionEffect:tt,useLayoutEffect:tt,useMemo:tt,useReducer:tt,useRef:tt,useState:tt,useDebugValue:tt,useDeferredValue:tt,useTransition:tt,useMutableSource:tt,useSyncExternalStore:tt,useId:tt,unstable_isNewReconciler:!1},jf={readContext:St,useCallback:function(e,t){return Wt().memoizedState=[e,t===void 0?null:t],e},useContext:St,useEffect:cu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Gl(4194308,4,pu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Gl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Gl(4,2,e,t)},useMemo:function(e,t){var n=Wt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Wt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=wf.bind(null,Ne,e),[r.memoizedState,e]},useRef:function(e){var t=Wt();return e={current:e},t.memoizedState=e},useState:au,useDebugValue:Mo,useDeferredValue:function(e){return Wt().memoizedState=e},useTransition:function(){var e=au(!1),t=e[0];return e=kf.bind(null,e[1]),Wt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ne,l=Wt();if(je){if(n===void 0)throw Error(s(407));n=n()}else{if(n=t(),He===null)throw Error(s(349));(In&30)!==0||ru(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,cu(iu.bind(null,r,i,e),[e]),r.flags|=2048,qr(9,lu.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Wt(),t=He.identifierPrefix;if(je){var n=Kt,r=Qt;n=(r&~(1<<32-_t(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Xr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[Mt]=t,e[Vr]=r,Au(e,t,!1,!1),t.stateNode=e;e:{switch(a=We(n,r),n){case"dialog":ke("cancel",e),ke("close",e),l=r;break;case"iframe":case"object":case"embed":ke("load",e),l=r;break;case"video":case"audio":for(l=0;lfr&&(t.flags|=128,r=!0,br(i,!1),t.lanes=4194304)}else{if(!r)if(e=Ql(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),br(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!je)return nt(t),null}else 2*Me()-i.renderingStartTime>fr&&n!==1073741824&&(t.flags|=128,r=!0,br(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Me(),t.sibling=null,n=_e.current,xe(_e,r?n&1|2:n&1),t):(nt(t),null);case 22:case 23:return is(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(yt&1073741824)!==0&&(nt(t),t.subtreeFlags&6&&(t.flags|=8192)):nt(t),null;case 24:return null;case 25:return null}throw Error(s(156,t.tag))}function zf(e,t){switch(ho(t),t.tag){case 1:return ct(t.type)&&Dl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ar(),we(ut),we(et),No(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Eo(t),null;case 13:if(we(_e),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));lr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return we(_e),null;case 4:return ar(),null;case 10:return ko(t.type._context),null;case 22:case 23:return is(),null;case 24:return null;default:return null}}var ei=!1,rt=!1,Lf=typeof WeakSet=="function"?WeakSet:Set,V=null;function cr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ze(e,t,r)}else n.current=null}function Yo(e,t,n){try{n()}catch(r){ze(e,t,r)}}var Hu=!1;function Of(e,t){if(lo=kl,e=Sa(),Xi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,f=-1,m=-1,C=0,L=0,O=e,z=null;t:for(;;){for(var A;O!==n||l!==0&&O.nodeType!==3||(f=a+l),O!==i||r!==0&&O.nodeType!==3||(m=a+r),O.nodeType===3&&(a+=O.nodeValue.length),(A=O.firstChild)!==null;)z=O,O=A;for(;;){if(O===e)break t;if(z===n&&++C===l&&(f=a),z===i&&++L===r&&(m=a),(A=O.nextSibling)!==null)break;O=z,z=O.parentNode}O=A}n=f===-1||m===-1?null:{start:f,end:m}}else n=null}n=n||{start:0,end:0}}else n=null;for(io={focusedElem:e,selectionRange:n},kl=!1,V=t;V!==null;)if(t=V,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,V=e;else for(;V!==null;){t=V;try{var Q=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(Q!==null){var Y=Q.memoizedProps,Ie=Q.memoizedState,x=t.stateNode,v=x.getSnapshotBeforeUpdate(t.elementType===t.type?Y:Tt(t.type,Y),Ie);x.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(M){ze(t,t.return,M)}if(e=t.sibling,e!==null){e.return=t.return,V=e;break}V=t.return}return Q=Hu,Hu=!1,Q}function el(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Yo(t,n,i)}l=l.next}while(l!==r)}}function ti(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Go(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Qu(e){var t=e.alternate;t!==null&&(e.alternate=null,Qu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Mt],delete t[Vr],delete t[uo],delete t[mf],delete t[vf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ku(e){return e.tag===5||e.tag===3||e.tag===4}function Yu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ku(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Jo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ll));else if(r!==4&&(e=e.child,e!==null))for(Jo(e,t,n),e=e.sibling;e!==null;)Jo(e,t,n),e=e.sibling}function Xo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Xo(e,t,n),e=e.sibling;e!==null;)Xo(e,t,n),e=e.sibling}var Ge=null,Rt=!1;function gn(e,t,n){for(n=n.child;n!==null;)Gu(e,t,n),n=n.sibling}function Gu(e,t,n){if(Dt&&typeof Dt.onCommitFiberUnmount=="function")try{Dt.onCommitFiberUnmount(hl,n)}catch{}switch(n.tag){case 5:rt||cr(n,t);case 6:var r=Ge,l=Rt;Ge=null,gn(e,t,n),Ge=r,Rt=l,Ge!==null&&(Rt?(e=Ge,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ge.removeChild(n.stateNode));break;case 18:Ge!==null&&(Rt?(e=Ge,n=n.stateNode,e.nodeType===8?ao(e.parentNode,n):e.nodeType===1&&ao(e,n),Lr(e)):ao(Ge,n.stateNode));break;case 4:r=Ge,l=Rt,Ge=n.stateNode.containerInfo,Rt=!0,gn(e,t,n),Ge=r,Rt=l;break;case 0:case 11:case 14:case 15:if(!rt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,a=i.destroy;i=i.tag,a!==void 0&&((i&2)!==0||(i&4)!==0)&&Yo(n,t,a),l=l.next}while(l!==r)}gn(e,t,n);break;case 1:if(!rt&&(cr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(f){ze(n,t,f)}gn(e,t,n);break;case 21:gn(e,t,n);break;case 22:n.mode&1?(rt=(r=rt)||n.memoizedState!==null,gn(e,t,n),rt=r):gn(e,t,n);break;default:gn(e,t,n)}}function Ju(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Lf),t.forEach(function(r){var l=$f.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function zt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=a),r&=~i}if(r=l,r=Me()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Mf(r/1960))-r,10e?16:e,xn===null)var r=!1;else{if(e=xn,xn=null,oi=0,(he&6)!==0)throw Error(s(331));var l=he;for(he|=4,V=e.current;V!==null;){var i=V,a=i.child;if((V.flags&16)!==0){var f=i.deletions;if(f!==null){for(var m=0;mMe()-bo?Un(e,0):qo|=n),pt(e,t)}function ac(e,t){t===0&&((e.mode&1)===0?t=1:(t=vl,vl<<=1,(vl&130023424)===0&&(vl=4194304)));var n=st();e=Yt(e,t),e!==null&&(Nr(e,t,n),pt(e,n))}function Af(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ac(e,n)}function $f(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(s(314))}r!==null&&r.delete(t),ac(e,n)}var uc;uc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ut.current)dt=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return dt=!1,Tf(e,t,n);dt=(e.flags&131072)!==0}else dt=!1,je&&(t.flags&1048576)!==0&&$a(t,Fl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;bl(e,t),e=t.pendingProps;var l=tr(t,et.current);sr(t,n),l=Ro(null,t,r,e,l,n);var i=zo();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ct(r)?(i=!0,Ml(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,jo(t),l.updater=Zl,t.stateNode=l,l._reactInternals=t,Wo(t,r,e,n),t=Ao(null,t,r,!0,i,n)):(t.tag=0,je&&i&&po(t),ot(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(bl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Hf(r),e=Tt(r,e),l){case 0:t=Bo(null,t,r,e,n);break e;case 1:t=Mu(null,t,r,e,n);break e;case 11:t=Ru(null,t,r,e,n);break e;case 14:t=zu(null,t,r,Tt(r.type,e),n);break e}throw Error(s(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Tt(r,l),Bo(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Tt(r,l),Mu(e,t,r,l,n);case 3:e:{if(Iu(t),e===null)throw Error(s(387));r=t.pendingProps,i=t.memoizedState,l=i.element,Za(e,t),Hl(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=ur(Error(s(423)),t),t=Wu(e,t,r,n,l);break e}else if(r!==l){l=ur(Error(s(424)),t),t=Wu(e,t,r,n,l);break e}else for(gt=dn(t.stateNode.containerInfo.firstChild),vt=t,je=!0,Pt=null,n=Ja(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(lr(),r===l){t=Jt(e,t,n);break e}ot(e,t,r,n)}t=t.child}return t;case 5:return eu(t),e===null&&vo(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,a=l.children,oo(r,l)?a=null:i!==null&&oo(r,i)&&(t.flags|=32),Du(e,t),ot(e,t,a,n),t.child;case 6:return e===null&&vo(t),null;case 13:return Fu(e,t,n);case 4:return Co(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ir(t,null,r,n):ot(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Tt(r,l),Ru(e,t,r,l,n);case 7:return ot(e,t,t.pendingProps,n),t.child;case 8:return ot(e,t,t.pendingProps.children,n),t.child;case 12:return ot(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,a=l.value,xe(Al,r._currentValue),r._currentValue=a,i!==null)if(Nt(i.value,a)){if(i.children===l.children&&!ut.current){t=Jt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var f=i.dependencies;if(f!==null){a=i.child;for(var m=f.firstContext;m!==null;){if(m.context===r){if(i.tag===1){m=Gt(-1,n&-n),m.tag=2;var C=i.updateQueue;if(C!==null){C=C.shared;var L=C.pending;L===null?m.next=m:(m.next=L.next,L.next=m),C.pending=m}}i.lanes|=n,m=i.alternate,m!==null&&(m.lanes|=n),wo(i.return,n,t),f.lanes|=n;break}m=m.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(s(341));a.lanes|=n,f=a.alternate,f!==null&&(f.lanes|=n),wo(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}ot(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,sr(t,n),l=St(l),r=r(l),t.flags|=1,ot(e,t,r,n),t.child;case 14:return r=t.type,l=Tt(r,t.pendingProps),l=Tt(r.type,l),zu(e,t,r,l,n);case 15:return Lu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Tt(r,l),bl(e,t),t.tag=1,ct(r)?(e=!0,Ml(t)):e=!1,sr(t,n),ju(t,r,l),Wo(t,r,l,n),Ao(null,t,r,!0,e,n);case 19:return Bu(e,t,n);case 22:return Ou(e,t,n)}throw Error(s(156,t.tag))};function cc(e,t){return Vs(e,t)}function Vf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Et(e,t,n,r){return new Vf(e,t,n,r)}function ss(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hf(e){if(typeof e=="function")return ss(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Oe)return 11;if(e===be)return 14}return 2}function Sn(e,t){var n=e.alternate;return n===null?(n=Et(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function ci(e,t,n,r,l,i){var a=2;if(r=e,typeof e=="function")ss(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Ce:return An(n.children,l,i,t);case ye:a=8,l|=8;break;case Ze:return e=Et(12,n,t,l|2),e.elementType=Ze,e.lanes=i,e;case Ee:return e=Et(13,n,t,l),e.elementType=Ee,e.lanes=i,e;case Ue:return e=Et(19,n,t,l),e.elementType=Ue,e.lanes=i,e;case ve:return di(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Le:a=10;break e;case qe:a=9;break e;case Oe:a=11;break e;case be:a=14;break e;case De:a=16,r=null;break e}throw Error(s(130,e==null?e:typeof e,""))}return t=Et(a,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function An(e,t,n,r){return e=Et(7,e,r,t),e.lanes=n,e}function di(e,t,n,r){return e=Et(22,e,r,t),e.elementType=ve,e.lanes=n,e.stateNode={isHidden:!1},e}function as(e,t,n){return e=Et(6,e,null,t),e.lanes=n,e}function us(e,t,n){return t=Et(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Qf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mi(0),this.expirationTimes=Mi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mi(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function cs(e,t,n,r,l,i,a,f,m){return e=new Qf(e,t,n,f,m),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Et(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},jo(i),e}function Kf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o)}catch(u){console.error(u)}}return o(),vs.exports=sp(),vs.exports}var Cc;function ap(){if(Cc)return yi;Cc=1;var o=Bc();return yi.createRoot=o.createRoot,yi.hydrateRoot=o.hydrateRoot,yi}var up=ap();Bc();/** + * @remix-run/router v1.23.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function ul(){return ul=Object.assign?Object.assign.bind():function(o){for(var u=1;u"u")throw new Error(u)}function Rs(o,u){if(!o){typeof console<"u"&&console.warn(u);try{throw new Error(u)}catch{}}}function dp(){return Math.random().toString(36).substr(2,8)}function _c(o,u){return{usr:o.state,key:o.key,idx:u}}function Cs(o,u,s,d){return s===void 0&&(s=null),ul({pathname:typeof o=="string"?o:o.pathname,search:"",hash:""},typeof u=="string"?yr(u):u,{state:s,key:u&&u.key||d||dp()})}function ji(o){let{pathname:u="/",search:s="",hash:d=""}=o;return s&&s!=="?"&&(u+=s.charAt(0)==="?"?s:"?"+s),d&&d!=="#"&&(u+=d.charAt(0)==="#"?d:"#"+d),u}function yr(o){let u={};if(o){let s=o.indexOf("#");s>=0&&(u.hash=o.substr(s),o=o.substr(0,s));let d=o.indexOf("?");d>=0&&(u.search=o.substr(d),o=o.substr(0,d)),o&&(u.pathname=o)}return u}function fp(o,u,s,d){d===void 0&&(d={});let{window:p=document.defaultView,v5Compat:h=!1}=d,g=p.history,j=Cn.Pop,k=null,_=P();_==null&&(_=0,g.replaceState(ul({},g.state,{idx:_}),""));function P(){return(g.state||{idx:null}).idx}function N(){j=Cn.Pop;let E=P(),B=E==null?null:E-_;_=E,k&&k({action:j,location:T.location,delta:B})}function I(E,B){j=Cn.Push;let $=Cs(T.location,E,B);_=P()+1;let G=_c($,_),F=T.createHref($);try{g.pushState(G,"",F)}catch(ie){if(ie instanceof DOMException&&ie.name==="DataCloneError")throw ie;p.location.assign(F)}h&&k&&k({action:j,location:T.location,delta:1})}function H(E,B){j=Cn.Replace;let $=Cs(T.location,E,B);_=P();let G=_c($,_),F=T.createHref($);g.replaceState(G,"",F),h&&k&&k({action:j,location:T.location,delta:0})}function K(E){let B=p.location.origin!=="null"?p.location.origin:p.location.href,$=typeof E=="string"?E:ji(E);return $=$.replace(/ $/,"%20"),Pe(B,"No window.location.(origin|href) available to create URL for href: "+$),new URL($,B)}let T={get action(){return j},get location(){return o(p,g)},listen(E){if(k)throw new Error("A history only accepts one active listener");return p.addEventListener(Ec,N),k=E,()=>{p.removeEventListener(Ec,N),k=null}},createHref(E){return u(p,E)},createURL:K,encodeLocation(E){let B=K(E);return{pathname:B.pathname,search:B.search,hash:B.hash}},push:I,replace:H,go(E){return g.go(E)}};return T}var Nc;(function(o){o.data="data",o.deferred="deferred",o.redirect="redirect",o.error="error"})(Nc||(Nc={}));function pp(o,u,s){return s===void 0&&(s="/"),hp(o,u,s)}function hp(o,u,s,d){let p=typeof u=="string"?yr(u):u,h=vr(p.pathname||"/",s);if(h==null)return null;let g=Ac(o);mp(g);let j=null,k=_p(h);for(let _=0;j==null&&_{let k={relativePath:j===void 0?h.path||"":j,caseSensitive:h.caseSensitive===!0,childrenIndex:g,route:h};k.relativePath.startsWith("/")&&(Pe(k.relativePath.startsWith(d),'Absolute route path "'+k.relativePath+'" nested under path '+('"'+d+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),k.relativePath=k.relativePath.slice(d.length));let _=En([d,k.relativePath]),P=s.concat(k);h.children&&h.children.length>0&&(Pe(h.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+_+'".')),Ac(h.children,u,P,_)),!(h.path==null&&!h.index)&&u.push({path:_,score:Sp(_,h.index),routesMeta:P})};return o.forEach((h,g)=>{var j;if(h.path===""||!((j=h.path)!=null&&j.includes("?")))p(h,g);else for(let k of $c(h.path))p(h,g,k)}),u}function $c(o){let u=o.split("/");if(u.length===0)return[];let[s,...d]=u,p=s.endsWith("?"),h=s.replace(/\?$/,"");if(d.length===0)return p?[h,""]:[h];let g=$c(d.join("/")),j=[];return j.push(...g.map(k=>k===""?h:[h,k].join("/"))),p&&j.push(...g),j.map(k=>o.startsWith("/")&&k===""?"/":k)}function mp(o){o.sort((u,s)=>u.score!==s.score?s.score-u.score:jp(u.routesMeta.map(d=>d.childrenIndex),s.routesMeta.map(d=>d.childrenIndex)))}const vp=/^:[\w-]+$/,gp=3,yp=2,xp=1,kp=10,wp=-2,Pc=o=>o==="*";function Sp(o,u){let s=o.split("/"),d=s.length;return s.some(Pc)&&(d+=wp),u&&(d+=yp),s.filter(p=>!Pc(p)).reduce((p,h)=>p+(vp.test(h)?gp:h===""?xp:kp),d)}function jp(o,u){return o.length===u.length&&o.slice(0,-1).every((d,p)=>d===u[p])?o[o.length-1]-u[u.length-1]:0}function Cp(o,u,s){let{routesMeta:d}=o,p={},h="/",g=[];for(let j=0;j{let{paramName:I,isOptional:H}=P;if(I==="*"){let T=j[N]||"";g=h.slice(0,h.length-T.length).replace(/(.)\/+$/,"$1")}const K=j[N];return H&&!K?_[I]=void 0:_[I]=(K||"").replace(/%2F/g,"/"),_},{}),pathname:h,pathnameBase:g,pattern:o}}function Ep(o,u,s){u===void 0&&(u=!1),s===void 0&&(s=!0),Rs(o==="*"||!o.endsWith("*")||o.endsWith("/*"),'Route path "'+o+'" will be treated as if it were '+('"'+o.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+o.replace(/\*$/,"/*")+'".'));let d=[],p="^"+o.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(g,j,k)=>(d.push({paramName:j,isOptional:k!=null}),k?"/?([^\\/]+)?":"/([^\\/]+)"));return o.endsWith("*")?(d.push({paramName:"*"}),p+=o==="*"||o==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?p+="\\/*$":o!==""&&o!=="/"&&(p+="(?:(?=\\/|$))"),[new RegExp(p,u?void 0:"i"),d]}function _p(o){try{return o.split("/").map(u=>decodeURIComponent(u).replace(/\//g,"%2F")).join("/")}catch(u){return Rs(!1,'The URL path "'+o+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+u+").")),o}}function vr(o,u){if(u==="/")return o;if(!o.toLowerCase().startsWith(u.toLowerCase()))return null;let s=u.endsWith("/")?u.length-1:u.length,d=o.charAt(s);return d&&d!=="/"?null:o.slice(s)||"/"}const Np=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pp=o=>Np.test(o);function Tp(o,u){u===void 0&&(u="/");let{pathname:s,search:d="",hash:p=""}=typeof o=="string"?yr(o):o,h;if(s)if(Pp(s))h=s;else{if(s.includes("//")){let g=s;s=Vc(s),Rs(!1,"Pathnames cannot have embedded double slashes - normalizing "+(g+" -> "+s))}s.startsWith("/")?h=Tc(s.substring(1),"/"):h=Tc(s,u)}else h=u;return{pathname:h,search:Lp(d),hash:Op(p)}}function Tc(o,u){let s=u.replace(/\/+$/,"").split("/");return o.split("/").forEach(p=>{p===".."?s.length>1&&s.pop():p!=="."&&s.push(p)}),s.length>1?s.join("/"):"/"}function xs(o,u,s,d){return"Cannot include a '"+o+"' character in a manually specified "+("`to."+u+"` field ["+JSON.stringify(d)+"]. Please separate it out to the ")+("`to."+s+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Rp(o){return o.filter((u,s)=>s===0||u.route.path&&u.route.path.length>0)}function zs(o,u){let s=Rp(o);return u?s.map((d,p)=>p===s.length-1?d.pathname:d.pathnameBase):s.map(d=>d.pathnameBase)}function Ls(o,u,s,d){d===void 0&&(d=!1);let p;typeof o=="string"?p=yr(o):(p=ul({},o),Pe(!p.pathname||!p.pathname.includes("?"),xs("?","pathname","search",p)),Pe(!p.pathname||!p.pathname.includes("#"),xs("#","pathname","hash",p)),Pe(!p.search||!p.search.includes("#"),xs("#","search","hash",p)));let h=o===""||p.pathname==="",g=h?"/":p.pathname,j;if(g==null)j=s;else{let N=u.length-1;if(!d&&g.startsWith("..")){let I=g.split("/");for(;I[0]==="..";)I.shift(),N-=1;p.pathname=I.join("/")}j=N>=0?u[N]:"/"}let k=Tp(p,j),_=g&&g!=="/"&&g.endsWith("/"),P=(h||g===".")&&s.endsWith("/");return!k.pathname.endsWith("/")&&(_||P)&&(k.pathname+="/"),k}const Vc=o=>o.replace(/\/\/+/g,"/"),En=o=>Vc(o.join("/")),zp=o=>o.replace(/\/+$/,"").replace(/^\/*/,"/"),Lp=o=>!o||o==="?"?"":o.startsWith("?")?o:"?"+o,Op=o=>!o||o==="#"?"":o.startsWith("#")?o:"#"+o;function Dp(o){return o!=null&&typeof o.status=="number"&&typeof o.statusText=="string"&&typeof o.internal=="boolean"&&"data"in o}const Hc=["post","put","patch","delete"];new Set(Hc);const Mp=["get",...Hc];new Set(Mp);/** + * React Router v6.30.4 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function cl(){return cl=Object.assign?Object.assign.bind():function(o){for(var u=1;u{j.current=!0}),S.useCallback(function(_,P){if(P===void 0&&(P={}),!j.current)return;if(typeof _=="number"){d.go(_);return}let N=Ls(_,JSON.parse(g),h,P.relative==="path");o==null&&u!=="/"&&(N.pathname=N.pathname==="/"?u:En([u,N.pathname])),(P.replace?d.replace:d.push)(N,P.state,P)},[u,d,g,h,o])}function Ni(o,u){let{relative:s}=u===void 0?{}:u,{future:d}=S.useContext(Zt),{matches:p}=S.useContext(_n),{pathname:h}=kr(),g=JSON.stringify(zs(p,d.v7_relativeSplatPath));return S.useMemo(()=>Ls(o,JSON.parse(g),h,s==="path"),[o,g,h,s])}function Fp(o,u){return Up(o,u)}function Up(o,u,s,d){xr()||Pe(!1);let{navigator:p}=S.useContext(Zt),{matches:h}=S.useContext(_n),g=h[h.length-1],j=g?g.params:{};g&&g.pathname;let k=g?g.pathnameBase:"/";g&&g.route;let _=kr(),P;if(u){var N;let E=typeof u=="string"?yr(u):u;k==="/"||(N=E.pathname)!=null&&N.startsWith(k)||Pe(!1),P=E}else P=_;let I=P.pathname||"/",H=I;if(k!=="/"){let E=k.replace(/^\//,"").split("/");H="/"+I.replace(/^\//,"").split("/").slice(E.length).join("/")}let K=pp(o,{pathname:H}),T=Hp(K&&K.map(E=>Object.assign({},E,{params:Object.assign({},j,E.params),pathname:En([k,p.encodeLocation?p.encodeLocation(E.pathname).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?k:En([k,p.encodeLocation?p.encodeLocation(E.pathnameBase).pathname:E.pathnameBase])})),h,s,d);return u&&T?S.createElement(_i.Provider,{value:{location:cl({pathname:"/",search:"",hash:"",state:null,key:"default"},P),navigationType:Cn.Pop}},T):T}function Bp(){let o=Gp(),u=Dp(o)?o.status+" "+o.statusText:o instanceof Error?o.message:JSON.stringify(o),s=o instanceof Error?o.stack:null,p={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},u),s?S.createElement("pre",{style:p},s):null,null)}const Ap=S.createElement(Bp,null);class $p extends S.Component{constructor(u){super(u),this.state={location:u.location,revalidation:u.revalidation,error:u.error}}static getDerivedStateFromError(u){return{error:u}}static getDerivedStateFromProps(u,s){return s.location!==u.location||s.revalidation!=="idle"&&u.revalidation==="idle"?{error:u.error,location:u.location,revalidation:u.revalidation}:{error:u.error!==void 0?u.error:s.error,location:s.location,revalidation:u.revalidation||s.revalidation}}componentDidCatch(u,s){console.error("React Router caught the following error during render",u,s)}render(){return this.state.error!==void 0?S.createElement(_n.Provider,{value:this.props.routeContext},S.createElement(Kc.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Vp(o){let{routeContext:u,match:s,children:d}=o,p=S.useContext(Ei);return p&&p.static&&p.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(p.staticContext._deepestRenderedBoundaryId=s.route.id),S.createElement(_n.Provider,{value:u},d)}function Hp(o,u,s,d){var p;if(u===void 0&&(u=[]),s===void 0&&(s=null),d===void 0&&(d=null),o==null){var h;if(!s)return null;if(s.errors)o=s.matches;else if((h=d)!=null&&h.v7_partialHydration&&u.length===0&&!s.initialized&&s.matches.length>0)o=s.matches;else return null}let g=o,j=(p=s)==null?void 0:p.errors;if(j!=null){let P=g.findIndex(N=>N.route.id&&(j==null?void 0:j[N.route.id])!==void 0);P>=0||Pe(!1),g=g.slice(0,Math.min(g.length,P+1))}let k=!1,_=-1;if(s&&d&&d.v7_partialHydration)for(let P=0;P=0?g=g.slice(0,_+1):g=[g[0]];break}}}return g.reduceRight((P,N,I)=>{let H,K=!1,T=null,E=null;s&&(H=j&&N.route.id?j[N.route.id]:void 0,T=N.route.errorElement||Ap,k&&(_<0&&I===0?(Xp("route-fallback"),K=!0,E=null):_===I&&(K=!0,E=N.route.hydrateFallbackElement||null)));let B=u.concat(g.slice(0,I+1)),$=()=>{let G;return H?G=T:K?G=E:N.route.Component?G=S.createElement(N.route.Component,null):N.route.element?G=N.route.element:G=P,S.createElement(Vp,{match:N,routeContext:{outlet:P,matches:B,isDataRoute:s!=null},children:G})};return s&&(N.route.ErrorBoundary||N.route.errorElement||I===0)?S.createElement($p,{location:s.location,revalidation:s.revalidation,component:T,error:H,children:$(),routeContext:{outlet:null,matches:B,isDataRoute:!0}}):$()},null)}var Jc=(function(o){return o.UseBlocker="useBlocker",o.UseRevalidator="useRevalidator",o.UseNavigateStable="useNavigate",o})(Jc||{}),Xc=(function(o){return o.UseBlocker="useBlocker",o.UseLoaderData="useLoaderData",o.UseActionData="useActionData",o.UseRouteError="useRouteError",o.UseNavigation="useNavigation",o.UseRouteLoaderData="useRouteLoaderData",o.UseMatches="useMatches",o.UseRevalidator="useRevalidator",o.UseNavigateStable="useNavigate",o.UseRouteId="useRouteId",o})(Xc||{});function Qp(o){let u=S.useContext(Ei);return u||Pe(!1),u}function Kp(o){let u=S.useContext(Qc);return u||Pe(!1),u}function Yp(o){let u=S.useContext(_n);return u||Pe(!1),u}function Zc(o){let u=Yp(),s=u.matches[u.matches.length-1];return s.route.id||Pe(!1),s.route.id}function Gp(){var o;let u=S.useContext(Kc),s=Kp(),d=Zc();return u!==void 0?u:(o=s.errors)==null?void 0:o[d]}function Jp(){let{router:o}=Qp(Jc.UseNavigateStable),u=Zc(Xc.UseNavigateStable),s=S.useRef(!1);return Yc(()=>{s.current=!0}),S.useCallback(function(p,h){h===void 0&&(h={}),s.current&&(typeof p=="number"?o.navigate(p):o.navigate(p,cl({fromRouteId:u},h)))},[o,u])}const Rc={};function Xp(o,u,s){Rc[o]||(Rc[o]=!0)}function Zp(o,u){o==null||o.v7_startTransition,o==null||o.v7_relativeSplatPath}function ks(o){let{to:u,replace:s,state:d,relative:p}=o;xr()||Pe(!1);let{future:h,static:g}=S.useContext(Zt),{matches:j}=S.useContext(_n),{pathname:k}=kr(),_=Gc(),P=Ls(u,zs(j,h.v7_relativeSplatPath),k,p==="path"),N=JSON.stringify(P);return S.useEffect(()=>_(JSON.parse(N),{replace:s,state:d,relative:p}),[_,N,p,s,d]),null}function sl(o){Pe(!1)}function qp(o){let{basename:u="/",children:s=null,location:d,navigationType:p=Cn.Pop,navigator:h,static:g=!1,future:j}=o;xr()&&Pe(!1);let k=u.replace(/^\/*/,"/"),_=S.useMemo(()=>({basename:k,navigator:h,static:g,future:cl({v7_relativeSplatPath:!1},j)}),[k,j,h,g]);typeof d=="string"&&(d=yr(d));let{pathname:P="/",search:N="",hash:I="",state:H=null,key:K="default"}=d,T=S.useMemo(()=>{let E=vr(P,k);return E==null?null:{location:{pathname:E,search:N,hash:I,state:H,key:K},navigationType:p}},[k,P,N,I,H,K,p]);return T==null?null:S.createElement(Zt.Provider,{value:_},S.createElement(_i.Provider,{children:s,value:T}))}function bp(o){let{children:u,location:s}=o;return Fp(_s(u),s)}new Promise(()=>{});function _s(o,u){u===void 0&&(u=[]);let s=[];return S.Children.forEach(o,(d,p)=>{if(!S.isValidElement(d))return;let h=[...u,p];if(d.type===S.Fragment){s.push.apply(s,_s(d.props.children,h));return}d.type!==sl&&Pe(!1),!d.props.index||!d.props.children||Pe(!1);let g={id:d.props.id||h.join("-"),caseSensitive:d.props.caseSensitive,element:d.props.element,Component:d.props.Component,index:d.props.index,path:d.props.path,loader:d.props.loader,action:d.props.action,errorElement:d.props.errorElement,ErrorBoundary:d.props.ErrorBoundary,hasErrorBoundary:d.props.ErrorBoundary!=null||d.props.errorElement!=null,shouldRevalidate:d.props.shouldRevalidate,handle:d.props.handle,lazy:d.props.lazy};d.props.children&&(g.children=_s(d.props.children,h)),s.push(g)}),s}/** + * React Router DOM v6.30.4 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ci(){return Ci=Object.assign?Object.assign.bind():function(o){for(var u=1;u{_&&zc?zc(()=>k(N)):k(N)},[k,_]);return S.useLayoutEffect(()=>g.listen(P),[g,P]),S.useEffect(()=>Zp(d),[d]),S.createElement(qp,{basename:u,children:s,location:j.location,navigationType:j.action,navigator:g,future:d})}const ah=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",uh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ch=S.forwardRef(function(u,s){let{onClick:d,relative:p,reloadDocument:h,replace:g,state:j,target:k,to:_,preventScrollReset:P,viewTransition:N}=u,I=qc(u,nh),{basename:H}=S.useContext(Zt),K,T=!1;if(typeof _=="string"&&uh.test(_)&&(K=_,ah))try{let G=new URL(window.location.href),F=_.startsWith("//")?new URL(G.protocol+_):new URL(_),ie=vr(F.pathname,H);F.origin===G.origin&&ie!=null?_=ie+F.search+F.hash:T=!0}catch{}let E=Ip(_,{relative:p}),B=ph(_,{replace:g,state:j,target:k,preventScrollReset:P,relative:p,viewTransition:N});function $(G){d&&d(G),G.defaultPrevented||B(G)}return S.createElement("a",Ci({},I,{href:K||E,onClick:T||h?d:$,ref:s,target:k}))}),dh=S.forwardRef(function(u,s){let{"aria-current":d="page",caseSensitive:p=!1,className:h="",end:g=!1,style:j,to:k,viewTransition:_,children:P}=u,N=qc(u,rh),I=Ni(k,{relative:N.relative}),H=kr(),K=S.useContext(Qc),{navigator:T,basename:E}=S.useContext(Zt),B=K!=null&&hh(I)&&_===!0,$=T.encodeLocation?T.encodeLocation(I).pathname:I.pathname,G=H.pathname,F=K&&K.navigation&&K.navigation.location?K.navigation.location.pathname:null;p||(G=G.toLowerCase(),F=F?F.toLowerCase():null,$=$.toLowerCase()),F&&E&&(F=vr(F,E)||F);const ie=$!=="/"&&$.endsWith("/")?$.length-1:$.length;let fe=G===$||!g&&G.startsWith($)&&G.charAt(ie)==="/",Ce=F!=null&&(F===$||!g&&F.startsWith($)&&F.charAt($.length)==="/"),ye={isActive:fe,isPending:Ce,isTransitioning:B},Ze=fe?d:void 0,Le;typeof h=="function"?Le=h(ye):Le=[h,fe?"active":null,Ce?"pending":null,B?"transitioning":null].filter(Boolean).join(" ");let qe=typeof j=="function"?j(ye):j;return S.createElement(ch,Ci({},N,{"aria-current":Ze,className:Le,ref:s,style:qe,to:k,viewTransition:_}),typeof P=="function"?P(ye):P)});var Ns;(function(o){o.UseScrollRestoration="useScrollRestoration",o.UseSubmit="useSubmit",o.UseSubmitFetcher="useSubmitFetcher",o.UseFetcher="useFetcher",o.useViewTransitionState="useViewTransitionState"})(Ns||(Ns={}));var Lc;(function(o){o.UseFetcher="useFetcher",o.UseFetchers="useFetchers",o.UseScrollRestoration="useScrollRestoration"})(Lc||(Lc={}));function fh(o){let u=S.useContext(Ei);return u||Pe(!1),u}function ph(o,u){let{target:s,replace:d,state:p,preventScrollReset:h,relative:g,viewTransition:j}=u===void 0?{}:u,k=Gc(),_=kr(),P=Ni(o,{relative:g});return S.useCallback(N=>{if(th(N,s)){N.preventDefault();let I=d!==void 0?d:ji(_)===ji(P);k(o,{replace:I,state:p,preventScrollReset:h,relative:g,viewTransition:j})}},[_,k,P,d,p,s,o,h,g,j])}function hh(o,u){u===void 0&&(u={});let s=S.useContext(ih);s==null&&Pe(!1);let{basename:d}=fh(Ns.useViewTransitionState),p=Ni(o,{relative:u.relative});if(!s.isTransitioning)return!1;let h=vr(s.currentLocation.pathname,d)||s.currentLocation.pathname,g=vr(s.nextLocation.pathname,d)||s.nextLocation.pathname;return Es(p.pathname,g)!=null||Es(p.pathname,h)!=null}function mh(){if(window.matchMedia("(display-mode: standalone)").matches)return;const o=document.cookie.split(";").map(s=>s.trim()).find(s=>s.startsWith("hnf_inactivity_mins="));if(!o)return;const u=parseInt(o.split("=")[1]);return isNaN(u)||u<=0?void 0:u*60*1e3}const Oc={background:"var(--navy-dark)",border:"1px solid var(--surface-2)",borderRadius:"6px",color:"var(--text)",padding:"0.625rem 0.75rem",fontSize:"1rem",width:"100%",outline:"none"},vh={background:"var(--hk-green)",color:"#fff",border:"none",borderRadius:"6px",padding:"0.625rem",fontSize:"1rem",fontWeight:600,marginTop:"0.25rem",width:"100%"};function gh({children:o}){const[u,s]=S.useState("checking"),[d,p]=S.useState(null),[h,g]=S.useState(""),[j,k]=S.useState(""),[_,P]=S.useState(""),[N,I]=S.useState(!1),H=S.useRef(null);S.useEffect(()=>{fetch("/api/auth/verify?app=hk-planner",{credentials:"include"}).then(async T=>{T.ok?(p(await T.json()),s("authed")):s("login")}).catch(()=>s("login"))},[]),S.useEffect(()=>{const T=mh();if(u!=="authed"||!T)return;async function E(){await fetch("/api/auth/logout",{method:"POST",credentials:"include"}).catch(()=>{}),p(null),s("login")}function B(){H.current&&clearTimeout(H.current),H.current=setTimeout(E,T)}const $=["mousemove","keydown","click","touchstart"];return $.forEach(G=>window.addEventListener(G,B,{passive:!0})),B(),()=>{H.current&&clearTimeout(H.current),$.forEach(G=>window.removeEventListener(G,B))}},[u]);async function K(T){T.preventDefault(),I(!0),P("");try{if(!(await fetch("/api/auth/login",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:h,password:j})})).ok){P("Invalid email or password");return}const B=await fetch("/api/auth/verify?app=hk-planner",{credentials:"include"});B.ok?(p(await B.json()),s("authed")):P("You don't have access to this app.")}catch{P("Connection error — please try again")}finally{I(!1)}}return u==="checking"?c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100dvh"},children:c.jsx("div",{style:{color:"var(--text-muted)"},children:"Loading…"})}):u==="login"?c.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100dvh",padding:"1.5rem",background:"var(--navy-dark)"},children:c.jsxs("div",{style:{background:"var(--navy)",borderRadius:"var(--radius)",padding:"2rem",width:"100%",maxWidth:"360px",border:"1px solid var(--surface-2)"},children:[c.jsx("h1",{style:{fontSize:"1.4rem",marginBottom:"0.25rem",color:"#74c69d"},children:"HK Planner"}),c.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.875rem",marginBottom:"1.5rem"},children:void 0}),c.jsxs("form",{onSubmit:K,style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[c.jsx("input",{type:"email",value:h,onChange:T=>g(T.target.value),placeholder:"Email",required:!0,autoComplete:"email",style:Oc}),c.jsx("input",{type:"password",value:j,onChange:T=>k(T.target.value),placeholder:"Password",required:!0,autoComplete:"current-password",style:Oc}),_&&c.jsx("p",{style:{color:"#f87171",fontSize:"0.875rem"},children:_}),c.jsx("button",{type:"submit",disabled:N,style:vh,children:N?"Signing in…":"Sign in"})]})]})}):c.jsx(c.Fragment,{children:o(d)})}/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bc=(...o)=>o.filter((u,s,d)=>!!u&&u.trim()!==""&&d.indexOf(u)===s).join(" ").trim();/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yh=o=>o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xh=o=>o.replace(/^([A-Z])|[\s-_]+(\w)/g,(u,s,d)=>d?d.toUpperCase():s.toLowerCase());/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dc=o=>{const u=xh(o);return u.charAt(0).toUpperCase()+u.slice(1)};/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var ws={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kh=o=>{for(const u in o)if(u.startsWith("aria-")||u==="role"||u==="title")return!0;return!1},wh=S.createContext({}),Sh=()=>S.useContext(wh),jh=S.forwardRef(({color:o,size:u,strokeWidth:s,absoluteStrokeWidth:d,className:p="",children:h,iconNode:g,...j},k)=>{const{size:_=24,strokeWidth:P=2,absoluteStrokeWidth:N=!1,color:I="currentColor",className:H=""}=Sh()??{},K=d??N?Number(s??P)*24/Number(u??_):s??P;return S.createElement("svg",{ref:k,...ws,width:u??_??ws.width,height:u??_??ws.height,stroke:o??I,strokeWidth:K,className:bc("lucide",H,p),...!h&&!kh(j)&&{"aria-hidden":"true"},...j},[...g.map(([T,E])=>S.createElement(T,E)),...Array.isArray(h)?h:[h]])});/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wr=(o,u)=>{const s=S.forwardRef(({className:d,...p},h)=>S.createElement(jh,{ref:h,iconNode:u,className:bc(`lucide-${yh(Dc(o))}`,`lucide-${o}`,d),...p}));return s.displayName=Dc(o),s};/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ch=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Mc=wr("calendar-clock",Ch);/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],ed=wr("clock",Eh);/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _h=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Nh=wr("grip-vertical",_h);/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ph=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Th=wr("log-out",Ph);/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rh=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ps=wr("refresh-cw",Rh);/** + * @license lucide-react v1.24.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zh=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Lh=wr("settings",zh);function Oh({visible:o}){return o?c.jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"var(--sidebar)",color:"var(--text-light)",display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"10px 16px",fontSize:"14px",boxShadow:"0 -2px 8px rgba(0,0,0,0.3)"},children:[c.jsx("span",{children:"A new version is available."}),c.jsxs("button",{onClick:()=>window.location.reload(),style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--accent)",color:"var(--sidebar)",border:"none",borderRadius:"4px",padding:"6px 14px",fontWeight:600,cursor:"pointer",fontSize:"13px"},children:[c.jsx(Ps,{size:14,strokeWidth:1.75}),"Reload"]})]}):null}const Dh=120*1e3;function Mh(o){const[u,s]=S.useState(!1);return S.useEffect(()=>{let d=null;async function p(){try{const j=await fetch(o,{cache:"no-store"});if(!j.ok)return;const _=(await j.json()).version;if(!_)return;d===null?d=_:_!==d&&s(!0)}catch{}}p();const h=setInterval(p,Dh);function g(){document.visibilityState==="visible"&&p()}return document.addEventListener("visibilitychange",g),()=>{clearInterval(h),document.removeEventListener("visibilitychange",g)}},[o]),u}function td(o,u){return o.is_admin||o.caps.includes(u)}const Ih="width=1280",Wh="width=device-width, initial-scale=1.0";function Ic(o){const u=document.querySelector('meta[name="viewport"]');u&&(u.content=o)}function Fh(o){S.useEffect(()=>(Ic(Ih),window.parent.postMessage({type:"hnf:viewport",mode:o},"*"),()=>{Ic(Wh),window.parent.postMessage({type:"hnf:viewport",mode:"responsive"},"*")}),[o])}function Uh({user:o,children:u}){Fh("desktop");async function s(){await fetch("/hk-planner/api/auth/logout",{method:"POST",credentials:"include"}),window.location.reload()}return c.jsxs("div",{style:{display:"flex",height:"100dvh",overflow:"hidden"},children:[c.jsxs("nav",{style:{width:"200px",flexShrink:0,background:"var(--navy)",display:"flex",flexDirection:"column",padding:"1rem 0",borderRight:"1px solid var(--surface-2)"},children:[c.jsx("div",{style:{padding:"0 1rem 1rem",borderBottom:"1px solid var(--surface-2)"},children:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[c.jsx(Mc,{size:20,strokeWidth:1.75,color:"#74c69d"}),c.jsx("span",{style:{color:"#74c69d",fontWeight:700,fontSize:"0.95rem"},children:"HK Planner"})]})}),c.jsxs("div",{className:"nav-scroll",style:{flex:1,padding:"0.5rem 0",overflowY:"auto"},children:[c.jsx(Wc,{to:"/planner",icon:Mc,label:"Planner"}),td(o,"settings")&&c.jsx(Wc,{to:"/settings",icon:Lh,label:"Settings"})]}),c.jsxs("div",{style:{padding:"0.75rem 1rem",borderTop:"1px solid var(--surface-2)"},children:[c.jsxs("div",{style:{marginBottom:"0.5rem"},children:[c.jsx("div",{style:{color:"var(--text)",fontSize:"0.8rem",fontWeight:600},children:o.name}),c.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.72rem"},children:o.email})]}),c.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"0.5rem",background:"none",border:"none",color:"var(--text-muted)",fontSize:"0.8rem",padding:"0.375rem 0",width:"100%",cursor:"pointer"},children:[c.jsx(Th,{size:14,strokeWidth:1.75}),"Sign out"]})]})]}),c.jsx("main",{style:{flex:1,overflow:"auto",background:"var(--body-bg)"},children:u})]})}function Wc({to:o,icon:u,label:s}){return c.jsxs(dh,{to:o,style:({isActive:d})=>({display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.625rem 1rem",textDecoration:"none",color:d?"#74c69d":"var(--text)",background:d?"var(--surface)":"transparent",borderLeft:d?"2px solid #74c69d":"2px solid transparent",fontSize:"0.875rem",transition:"background 0.15s"}),children:[c.jsx(u,{size:15,strokeWidth:1.75}),s]})}const Bh="/hk-planner/api";async function Ke(o,u){const s=await fetch(Bh+o,{credentials:"include",...u});if(s.status===401)throw(window.top??window).location.href="/login",new Error("Unauthenticated");if(!s.ok){const d=await s.json().catch(()=>({}));throw new Error(d.error||`HTTP ${s.status}`)}return s.json()}function Ah(o,u,s=!1){const d=new URLSearchParams;return o&&d.set("week_start",o),u&&d.set("last_viewed",u),s&&d.set("force_refresh","1"),Ke(`/bookings?${d}`)}function nd(){return Ke("/config")}function $h(o,u,s){return Ke("/config/time-requirements",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cat:o,action:u,value:s})})}function Vh(o){return Ke("/config/staff",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({staff_data:o})})}function Hh(o){return Ke("/config/pickup",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({pickup_data:o})})}function Qh(o){return Ke("/config/general-tasks",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({general_tasks:o})})}function Kh(o){return Ke("/config/last-reviewed",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({date:o})})}function Yh(){return Ke("/categories")}function Gh(o,u){return Ke("/categories",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:o,excluded:u})})}function Jh(){return Ke("/newbook/test",{method:"POST"})}function Xh(){return Ke("/workforce/departments")}function Zh(o){return Ke("/config/workforce-departments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dept_ids:o})})}function qh(){return Ke("/workforce/sync",{method:"POST"})}function bh(){return Ke("/workforce/sync-timesheets",{method:"POST"})}function Ss(o,u){return Ke(`/workforce/shifts?start=${o}&end=${u}`)}function em(){return Ke("/workforce/staff")}function tm(o){return Ke("/config/adjustments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({adjustments:o})})}function nm(o){return Ke("/config/warning-thresholds",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}function xi(){const o=new Date;return`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-${String(o.getDate()).padStart(2,"0")}`}function ki(o,u){const[s,d,p]=o.split("-").map(Number),h=new Date(s,d-1,p);return h.setDate(h.getDate()+u),`${h.getFullYear()}-${String(h.getMonth()+1).padStart(2,"0")}-${String(h.getDate()).padStart(2,"0")}`}function Pi(o){const u=new Date(o+"T00:00:00");return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][u.getDay()]+" "+u.getDate()+" "+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][u.getMonth()]}function rm(o){const u=new Date(o+"T00:00:00");return["Mon","Tue","Wed","Thu","Fri","Sat","Sun"][(u.getDay()+6)%7]}function lm(o){const u=new Date(o+"T00:00:00");return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][u.getDay()]}function al(o){const u=new Date(o+"T00:00:00").getDay();return u===0||u===6}function im(o,u){const s=u.pickup_hint??0,d=u.pickup_lead??0,p=s>0?`${s} room${s===1?"":"s"} picked up within ${d} day${d===1?"":"s"} of arrival`:"no late pickups";return`Last ${lm(o)}: ${u.prior_occ} occ (${u.prior_vac} vac) — ${p}`}function Fc(o){return new Date(o+"T00:00:00").toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function Xe(o){return o.toFixed(2)+"h"}function gr(o,u,s,d,p){var _;const h=Math.max(0,p-d),g=(_=o[u])==null?void 0:_[s];if(!g||!g.count)return 0;const j=g.total-g.count,k=d>j?Math.max(0,g.total-d):g.count;return Math.min(k,h)}function om(o,u,s,d,p){const h={};for(const g of o.dates){const j=rm(g),k=d.reduce((P,N)=>P+(N.hours[j]||0)/60,0),_=p.reduce((P,N)=>P+(N.hours[g]||0),0);h[g]={booked:0,pickup:0,general:k,adjustments:_,total:k+_,by_cat:{},pickup_by_cat:{}}}for(const g of o.categories){const j=u[g.id]||{depart:0,stay:0,arrive:0};o.dates.forEach((k,_)=>{const P=g.days[k],N=P.stays+P.arrivals,I=gr(s,g.id,k,N,g.total_rooms),H=(P.departs*(j.depart||0)+P.stays*(j.stay||0)+P.arrivals*(j.arrive||0))/60,K=I*(j.arrive||0)/60;h[k].by_cat[g.id]=H,h[k].pickup_by_cat[g.id]=(h[k].pickup_by_cat[g.id]||0)+K,h[k].booked+=H,h[k].pickup+=K,h[k].total+=H+K;const T=o.dates[_+1];if(T&&I>0){const E=I*(j.depart||0)/60;h[T].pickup_by_cat[g.id]=(h[T].pickup_by_cat[g.id]||0)+E,h[T].pickup+=E,h[T].total+=E}})}return h}function sm(){const[o,u]=S.useState(null),[s,d]=S.useState({}),[p,h]=S.useState([]),[g,j]=S.useState({}),[k,_]=S.useState([]),[P,N]=S.useState([]),[I,H]=S.useState(4),[K,T]=S.useState(1),[E,B]=S.useState(1),[$,G]=S.useState(2),[F,ie]=S.useState({}),[fe,Ce]=S.useState([]),[ye,Ze]=S.useState(!1),[Le,qe]=S.useState(!1),[Oe,Ee]=S.useState(null),[Ue,be]=S.useState(""),[De,ve]=S.useState(""),[W,X]=S.useState(!0),[U,y]=S.useState(""),[R,ne]=S.useState(null),re=S.useRef({}),oe=S.useRef(null),se=S.useRef(!1),de=S.useRef(null);de.current=Oe;function ae(b,pe,Te=400){clearTimeout(re.current[b]),re.current[b]=setTimeout(pe,Te)}function ue(b,pe=!1){oe.current&&clearTimeout(oe.current),ne({text:b,err:pe}),oe.current=setTimeout(()=>ne(null),pe?15e3:2500)}function Se(){const b=xi();b!==De&&(ve(b),Kh(b).catch(()=>{}))}const lt=S.useCallback(async(b=!1,pe)=>{X(!0),y("");const Te=xi(),Ye=de.current||Te,it=ki(Ye,6),at=pe!==void 0?pe||ki(Te,-1):Ue||De||ki(Te,-1);try{const[$e,Re,D]=await Promise.all([Ah(Ye,at,b),nd(),Ss(Ye,it).catch(()=>({}))]);u($e),d(Re.time_requirements||{}),h(Re.staff_data||[]),j(Re.pickup_data||{}),_(Re.general_tasks||[]),N(Re.adjustments||[]),H(Re.warn_over_red_hrs??4),T(Re.warn_over_amber_hrs??1),B(Re.warn_under_amber_hrs??1),G(Re.warn_under_red_hrs??2),ie(D),Re.last_reviewed&&(ve(Re.last_reviewed),Ue||be(Re.last_reviewed))}catch($e){y($e instanceof Error?$e.message:"Failed to load data")}finally{X(!1)}},[Ue,De]);S.useEffect(()=>{lt(!1)},[]),S.useEffect(()=>{Object.keys(F).length>0&&!se.current&&(se.current=!0,em().then(Ce).catch(()=>{}))},[F]),S.useEffect(()=>{function b(Te,Ye){fetch(Te,{method:"PUT",keepalive:!0,credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ye)})}function pe(){p.length&&b("/hk-planner/api/config/staff",{staff_data:p}),Object.keys(g).length&&b("/hk-planner/api/config/pickup",{pickup_data:g}),P.length&&b("/hk-planner/api/config/adjustments",{adjustments:P})}return window.addEventListener("beforeunload",pe),()=>window.removeEventListener("beforeunload",pe)},[p,g,P]);function qt(b){const pe=xi(),Te=ki(de.current||pe,b);de.current=Te,Ee(Te),Se(),lt(!0)}function Bt(){de.current=null,Ee(null),Se(),lt(!0)}function bt(){Se(),lt(!0)}function Nn(b,pe,Te,Ye){const it=Ye.days[pe],at=it.stays+it.arrivals,$e=Math.max(0,Ye.total_rooms-at),Re=gr(g,b,pe,at,Ye.total_rooms),D=Math.max(0,Math.min(Re+Te,$e)),ee={...g,[b]:{...g[b]||{},[pe]:{count:D,total:at+D}}};j(ee),Se(),ae("pickup",()=>Hh(ee).then(()=>ue("Pickup saved")).catch(le=>ue(le.message,!0)))}function en(b){N(b),ae("adjustments",()=>tm(b).then(()=>ue("Adjustments saved")).catch(pe=>ue(pe.message,!0)))}function At(){en([...P,{label:"",hours:{}}])}function tn(b){h(b),Se(),ae("staff",()=>Vh(b).then(()=>ue("Staff hours saved")).catch(pe=>ue(pe.message,!0)))}function nn(){tn([...p,{name:"",hours:{}}])}async function $t(){Ze(!0);try{if(await qh(),o){const b=await Ss(o.dates[0],o.dates[o.dates.length-1]);ie(b)}ue("Rota synced from Workforce")}catch(b){ue(b instanceof Error?b.message:"Sync failed",!0)}finally{Ze(!1)}}async function Ot(){qe(!0);try{if(await bh(),o){const b=await Ss(o.dates[0],o.dates[o.dates.length-1]);ie(b)}ue("Timesheets pulled from Workforce")}catch(b){ue(b instanceof Error?b.message:"Timesheet sync failed",!0)}finally{qe(!1)}}function Pn(){if(!o)return"";const b=o.dates.filter($e=>F[$e]);if(!b.length)return"Not synced";const pe=b.reduce(($e,Re)=>new Date(F[Re].synced_at)!F[$e]).length?`Partial sync — from ${Ye} ${it}`:`From ${Ye} ${it}`}const rn=o?om(o,s,g,k,P):null,$n=xi(),Vn=Oe||$n;return c.jsxs("div",{style:{padding:"1.5rem",maxWidth:"1600px"},children:[c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0.75rem",marginBottom:"1.25rem"},children:[c.jsxs("div",{children:[c.jsx("h1",{style:{fontSize:"1.15rem",fontWeight:700,color:"var(--text-dark)"},children:"Housekeeping Planner"}),o&&c.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-mid)",marginTop:"0.1rem"},children:[Fc(o.dates[0])," – ",Fc(o.dates[o.dates.length-1])]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",marginLeft:"auto",flexWrap:"wrap"},children:[c.jsx(hr,{onClick:()=>qt(-7),children:"‹ Prev"}),c.jsx(hr,{onClick:Bt,primary:!0,children:"Today"}),c.jsx(hr,{onClick:()=>qt(7),children:"Next ›"}),c.jsx("input",{type:"date",value:Vn,onChange:b=>{if(b.target.value){const pe=b.target.value;de.current=pe,Ee(pe),Se(),ae("weekStart",()=>lt(!0),600)}},style:{border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.35rem 0.5rem",fontSize:"0.82rem",color:"var(--text-dark)"}}),c.jsx("div",{style:{width:"1px",height:"24px",background:"var(--card-border)"}}),c.jsxs("label",{style:{fontSize:"0.78rem",color:"var(--text-mid)",display:"flex",alignItems:"center",gap:"0.3rem"},children:[c.jsx("span",{children:"Since"}),c.jsx("input",{type:"date",value:Ue,onChange:b=>{if(b.target.value){const pe=b.target.value;be(pe),ae("lastViewed",()=>lt(!0,pe),600)}},style:{border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.3rem 0.5rem",fontSize:"0.78rem",color:"var(--text-dark)"}})]}),c.jsx(hr,{onClick:()=>{Se(),lt(!0)},children:"Update to now"}),c.jsx("div",{style:{width:"1px",height:"24px",background:"var(--card-border)"}}),c.jsx("button",{onClick:bt,title:"Refresh",style:{background:"var(--card-bg)",border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.35rem 0.5rem",display:"flex",alignItems:"center",gap:"0.3rem",fontSize:"0.82rem",color:"var(--text-dark)"},children:c.jsx(Ps,{size:13,strokeWidth:1.75,style:{animation:W?"spin 1s linear infinite":"none"}})})]})]}),c.jsx("style",{children:"@keyframes spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }"}),R&&c.jsx("div",{style:{display:"inline-block",marginBottom:"0.75rem",padding:"0.35rem 0.75rem",borderRadius:"6px",fontSize:"0.8rem",fontWeight:500,background:R.err?"#fee2e2":"#dcfce7",color:R.err?"var(--danger)":"var(--success)"},children:R.text}),U&&c.jsxs("div",{style:{marginBottom:"1rem",padding:"0.75rem 1rem",borderRadius:"8px",background:"#fee2e2",color:"var(--danger)",fontSize:"0.875rem"},children:["Error: ",U]}),W&&!o&&c.jsx("div",{style:{color:"var(--text-mid)",padding:"2rem 0",textAlign:"center"},children:"Loading bookings…"}),o&&rn&&c.jsxs(c.Fragment,{children:[c.jsx(wi,{title:"7-Day Occupancy",children:c.jsx("div",{className:"table-scroll",children:c.jsx(am,{bookings:o,pickup:g,onPickupChange:Nn})})}),c.jsx(wi,{title:"Required Hours",children:c.jsx("div",{className:"table-scroll",children:c.jsx(dm,{bookings:o,required:rn})})}),c.jsx(wi,{title:"Adjustments",action:c.jsx(hr,{onClick:At,children:"+ Add adjustment"}),children:c.jsx("div",{className:"table-scroll",children:c.jsx(mm,{bookings:o,adjustments:P,onChange:en})})}),c.jsx(wi,{title:"Staff Rota",action:c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flexWrap:"wrap"},children:[c.jsxs("button",{onClick:$t,disabled:ye||Le,style:{display:"flex",alignItems:"center",gap:"0.3rem",background:"var(--card-bg)",color:"var(--text-dark)",border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.3rem 0.65rem",fontSize:"0.78rem",fontWeight:600},children:[c.jsx(Ps,{size:11,strokeWidth:1.75,style:{animation:ye?"spin 1s linear infinite":"none"}}),ye?"Syncing…":"Sync rota"]}),c.jsxs("button",{onClick:Ot,disabled:ye||Le,style:{display:"flex",alignItems:"center",gap:"0.3rem",background:"var(--card-bg)",color:"var(--text-dark)",border:"1px solid var(--card-border)",borderRadius:"6px",padding:"0.3rem 0.65rem",fontSize:"0.78rem",fontWeight:600},children:[c.jsx(ed,{size:11,strokeWidth:1.75,style:{animation:Le?"spin 1s linear infinite":"none"}}),Le?"Pulling…":"Pull timesheets"]}),c.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:Pn()}),c.jsx(hr,{onClick:nn,children:"+ Add staff"})]}),children:c.jsx("div",{className:"table-scroll",children:c.jsx(pm,{bookings:o,staff:p,required:rn,warnOverRed:I,warnOverAmber:K,warnUnderAmber:E,warnUnderRed:$,onChange:tn,wfShifts:F,wfStaff:fe})})})]})]})}function wi({title:o,children:u,action:s}){return c.jsxs("div",{style:{marginBottom:"1.5rem"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"0.5rem"},children:[c.jsx("h2",{style:{fontSize:"0.72rem",fontWeight:700,color:"var(--text-mid)",textTransform:"uppercase",letterSpacing:"0.08em"},children:o}),s]}),u]})}function hr({children:o,onClick:u,primary:s}){return c.jsx("button",{onClick:u,style:{background:s?"var(--hk-green)":"var(--card-bg)",color:s?"#fff":"var(--text-dark)",border:`1px solid ${s?"var(--hk-green)":"var(--card-border)"}`,borderRadius:"6px",padding:"0.35rem 0.75rem",fontSize:"0.82rem",fontWeight:600},children:o})}function am({bookings:o,pickup:u,onPickupChange:s}){const{dates:d,categories:p}=o;return c.jsxs("table",{className:"hk-table",children:[c.jsxs("thead",{children:[c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",rowSpan:2,children:"Category"}),d.map(h=>c.jsx("th",{colSpan:2,style:{borderLeft:"2px solid rgba(255,255,255,0.3)",...al(h)?{background:"#253555"}:{}},children:Pi(h)},h))]}),c.jsx("tr",{children:d.map(h=>c.jsxs(c.Fragment,{children:[c.jsx("th",{style:{fontSize:"0.72rem",fontWeight:400,minWidth:"72px",background:al(h)?"#2a3d5e":"#1e2d42",borderLeft:"2px solid rgba(255,255,255,0.3)"},children:"Rooms"},h+"-r"),c.jsx("th",{style:{fontSize:"0.72rem",fontWeight:400,minWidth:"56px",textAlign:"center",background:al(h)?"#2a3d5e":"#1e2d42",borderLeft:"1px solid rgba(255,255,255,0.1)"},children:"D / S / A"},h+"-d")]}))})]}),c.jsx("tbody",{children:p.map((h,g)=>{const j=g===p.length-1;return c.jsx(um,{cat:h,dates:d,pickup:u,onPickupChange:(k,_)=>s(h.id,k,_,h),isLast:j},h.id)})}),c.jsx("tfoot",{children:c.jsx(cm,{dates:d,cats:p,pickup:u})})]})}function um({cat:o,dates:u,pickup:s,onPickupChange:d,isLast:p}){const h=p?"2px solid var(--card-border)":void 0;return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{borderBottom:h},children:o.name}),u.map((g,j)=>{var ie;const k=o.days[g],_=k.stays+k.arrivals,P=Math.max(0,o.total_rooms-_),N=gr(s,o.id,g,_,o.total_rooms),I=u[j-1],H=I?o.days[I].stays+o.days[I].arrivals:0,K=I?gr(s,o.id,I,H,o.total_rooms):0,T=k.delta_new||0,E=k.delta_cancelled||0,B=al(g),$=(ie=s[o.id])==null?void 0:ie[g],G=im(g,k);let F="";if($&&$.count){const fe=$.total-$.count,Ce=_>fe?"changed":"unchanged",ye=_>fe?"decreased":"remains";F=`+${$.count} pickup set when booked was ${fe} (target ${$.total}). Booked ${Ce}, so pickup ${ye}.`}return F=(F?F+" | ":"")+G,c.jsxs(c.Fragment,{children:[c.jsxs("td",{style:{textAlign:"center",verticalAlign:"middle",borderBottom:h,padding:"0.4rem 0.3rem",borderLeft:"2px solid var(--card-border)",...B?{background:"rgba(100,120,160,0.07)"}:{}},children:[(T>0||E>0)&&c.jsxs("div",{style:{marginBottom:"2px",fontSize:"0.72rem"},children:[T>0&&c.jsxs("span",{className:"delta-new",children:["▲",T]}),E>0&&c.jsxs("span",{className:"delta-canc",children:[" ▼",E]})]}),c.jsxs("div",{style:{fontWeight:700,fontSize:"1.1rem"},title:F,children:[_,N>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",N]})]}),c.jsxs("div",{style:{fontSize:"0.72rem",color:"var(--text-mid)",marginBottom:"4px"},children:[P," vac",N>0&&c.jsxs("span",{className:"pickup-tag",children:[" (",P-N,")"]})]}),c.jsxs("div",{className:"pickup-ctrl",children:[c.jsx("button",{className:"pickup-btn",disabled:N<=0,onClick:()=>d(g,-1),children:"−"}),c.jsx("span",{className:"pickup-num",children:N}),c.jsx("button",{className:"pickup-btn",disabled:N>=P,title:G,onClick:()=>d(g,1),children:"+"})]})]},g+"-r"),c.jsxs("td",{style:{verticalAlign:"middle",borderLeft:"1px solid var(--card-border)",borderBottom:h,padding:"0.4rem 0.3rem",textAlign:"center",...B?{background:"rgba(100,120,160,0.07)"}:{}},children:[c.jsxs("div",{style:{fontSize:"0.8rem",color:"#c2502e",fontWeight:600},children:[k.departs,"d",K>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",K]})]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1d6fb8",fontWeight:600},children:[k.stays,"s"]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1a7a4a",fontWeight:600},children:[k.arrivals,"a",N>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",N]})]})]},g+"-dsa")]})})]})}function cm({dates:o,cats:u,pickup:s}){return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontStyle:"italic"},children:"Total"}),o.map((d,p)=>{let h=0,g=0,j=0,k=0,_=0,P=0,N=0,I=0,H=0;for(const T of u){const E=T.days[d],B=E.stays+E.arrivals,$=Math.max(0,T.total_rooms-B),G=gr(s,T.id,d,B,T.total_rooms),F=o[p-1],ie=F?T.days[F].stays+T.days[F].arrivals:0,fe=F?gr(s,T.id,F,ie,T.total_rooms):0;h+=B,g+=$,j+=G,k+=fe,_+=E.departs,P+=E.stays,N+=E.arrivals,I+=E.delta_new||0,H+=E.delta_cancelled||0}const K=al(d);return c.jsxs(c.Fragment,{children:[c.jsxs("td",{style:{textAlign:"center",verticalAlign:"middle",padding:"0.4rem 0.3rem",borderLeft:"2px solid var(--card-border)",...K?{background:"rgba(100,120,160,0.07)"}:{}},children:[(I>0||H>0)&&c.jsxs("div",{style:{marginBottom:"2px",fontSize:"0.72rem"},children:[I>0&&c.jsxs("span",{className:"delta-new",children:["▲",I]}),H>0&&c.jsxs("span",{className:"delta-canc",children:[" ▼",H]})]}),c.jsxs("div",{style:{fontWeight:700,fontSize:"1.1rem"},children:[h,j>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",j]})]}),c.jsxs("div",{style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:[g," vac",j>0&&c.jsxs("span",{className:"pickup-tag",children:[" (",g-j,")"]})]})]},d+"-r"),c.jsxs("td",{style:{verticalAlign:"middle",borderLeft:"1px solid var(--card-border)",padding:"0.4rem 0.3rem",textAlign:"center",...K?{background:"rgba(100,120,160,0.07)"}:{}},children:[c.jsxs("div",{style:{fontSize:"0.8rem",color:"#c2502e",fontWeight:600},children:[_,"d",k>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",k]})]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1d6fb8",fontWeight:600},children:[P,"s"]}),c.jsxs("div",{style:{fontSize:"0.8rem",color:"#1a7a4a",fontWeight:600},children:[N,"a",j>0&&c.jsxs("span",{className:"pickup-tag",children:[" +",j]})]})]},d+"-dsa")]})})]})}function dm({bookings:o,required:u}){const{dates:s,categories:d}=o;return c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Category"}),s.map(p=>c.jsx("th",{children:Pi(p)},p))]})}),c.jsx("tbody",{children:d.map(p=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",children:p.name}),s.map(h=>{const g=u[h].by_cat[p.id]||0,j=u[h].pickup_by_cat[p.id]||0;return c.jsxs("td",{children:[g===0&&j===0?"—":Xe(g),j>.001&&c.jsxs("span",{className:"pickup-tag",children:[" (+",Xe(j),")"]})]},h)})]},p.id))}),c.jsxs("tfoot",{children:[c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Booked hrs"}),s.map(p=>c.jsx("td",{children:Xe(u[p].booked)},p))]}),c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Pickup hrs"}),s.map(p=>c.jsx("td",{children:u[p].pickup>.001?Xe(u[p].pickup):"—"},p))]}),c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Recurring tasks"}),s.map(p=>c.jsx("td",{children:u[p].general>.001?Xe(u[p].general):"—"},p))]}),s.some(p=>u[p].adjustments!==0)&&c.jsxs("tr",{style:{background:"#f1f5f9"},children:[c.jsx("td",{className:"col-label",style:{color:"var(--text-mid)",fontSize:"0.78rem"},children:"Adjustments"}),s.map(p=>{const h=u[p].adjustments;return c.jsx("td",{style:{color:h<0?"var(--danger)":h>0?"#1a7a4a":"var(--text-mid)"},children:h===0?"—":(h>0?"+":"")+Xe(h)},p)})]}),c.jsxs("tr",{style:{background:"#e2e8f0"},children:[c.jsx("td",{className:"col-label",children:"Total Required"}),s.map(p=>c.jsxs("td",{style:{fontWeight:700},children:[Xe(u[p].total),u[p].pickup>.001&&c.jsxs("span",{className:"pickup-tag",style:{display:"block",fontSize:"0.7rem"},children:["inc ",Xe(u[p].pickup)," pickup"]})]},p))]})]})]})}function fm(o,u){const s={};for(const d of u){const p=o[d];if(p)for(const h of p.staff)s[h.id]||(s[h.id]={id:h.id,name:h.name,days:{}}),s[h.id].days[d]={hours:h.hours,times:h.times,status:h.status}}return Object.values(s).sort((d,p)=>d.name.localeCompare(p.name))}function pm({bookings:o,staff:u,required:s,warnOverRed:d,warnOverAmber:p,warnUnderAmber:h,warnUnderRed:g,onChange:j,wfShifts:k,wfStaff:_}){const{dates:P}=o;function N(T,E){const B=u.map(($,G)=>G===T?{...$,name:E}:$);j(B)}function I(T,E,B){const $=parseFloat(B),G=u.map((F,ie)=>{if(ie!==T)return F;const fe={...F.hours};return!isNaN($)&&$>=0?fe[E]=$:delete fe[E],{...F,hours:fe}});j(G)}function H(T){j(u.filter((E,B)=>B!==T))}const K=fm(k,P);return c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Staff Member"}),P.map(T=>c.jsx("th",{children:Pi(T)},T)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsxs("tbody",{children:[K.map(T=>c.jsxs("tr",{style:{background:"rgba(42,100,72,0.05)"},children:[c.jsxs("td",{className:"col-label",children:[c.jsx("span",{style:{display:"inline-block",fontSize:"0.67rem",fontWeight:700,background:"rgba(42,100,72,0.18)",color:"#1a7a4a",borderRadius:"3px",padding:"0 4px",marginRight:"0.4rem",lineHeight:"1.5"},children:"WF"}),T.name]}),P.map(E=>{var F;const B=T.days[E],$=((F=k[E])==null?void 0:F.source)==="timesheet",G=$&&(B==null?void 0:B.status)!=="APPROVED";return c.jsx("td",{style:{textAlign:"center",padding:"0.3rem 0.4rem",verticalAlign:"middle"},children:B?c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{fontSize:"0.68rem",color:"var(--text-mid)",lineHeight:1.25},children:B.times}),c.jsxs("div",{style:{fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",gap:"0.2rem"},children:[$&&c.jsx(ed,{size:10,strokeWidth:1.75,style:{color:G?"#d97706":"#1a7a4a",flexShrink:0}}),Xe(B.hours)]})]}):c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"})},E)}),c.jsx("td",{})]},"wf-"+T.id)),_.length>0&&c.jsx("datalist",{id:"wf-staff-datalist",children:_.map(T=>c.jsx("option",{value:T.name},T.id))}),u.map((T,E)=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:T.name,placeholder:"Staff name",list:_.length>0?"wf-staff-datalist":void 0,onChange:B=>N(E,B.target.value)})}),P.map(B=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:24,step:.5,value:T.hours[B]??"",placeholder:"0",onChange:$=>I(E,B,$.target.value)})},B)),c.jsx("td",{children:c.jsx("button",{onClick:()=>H(E),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},E))]}),c.jsx("tfoot",{children:(()=>{const T={};for(const E of P){const B=K.reduce((G,F)=>{var ie;return G+(((ie=F.days[E])==null?void 0:ie.hours)||0)},0),$=u.reduce((G,F)=>G+(F.hours[E]||0),0);T[E]=B+$}return c.jsxs(c.Fragment,{children:[c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.78rem",color:"var(--text-mid)"},children:"Total Available"}),P.map(E=>c.jsx("td",{children:Xe(T[E])},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"vs Booked"}),P.map(E=>c.jsx("td",{children:c.jsx(js,{available:T[E],required:s[E].booked,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"with Recurring Tasks"}),P.map(E=>c.jsx("td",{children:c.jsx(js,{available:T[E],required:s[E].booked+s[E].general,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.72rem",color:"var(--text-mid)"},children:"with Pickup"}),P.map(E=>c.jsx("td",{children:c.jsx(js,{available:T[E],required:s[E].booked+s[E].general+s[E].pickup,warnOverAmber:p,warnUnderAmber:h})},E)),c.jsx("td",{})]}),c.jsxs("tr",{style:{background:"#e2e8f0"},children:[c.jsx("td",{className:"col-label",style:{fontWeight:700},children:"with Adjustments"}),P.map(E=>c.jsx("td",{children:c.jsx(hm,{available:T[E],required:s[E].total,warnOverRed:d,warnOverAmber:p,warnUnderAmber:h,warnUnderRed:g})},E)),c.jsx("td",{})]})]})})()})]})}function js({available:o,required:u,warnOverAmber:s,warnUnderAmber:d}){if(o===0&&u===0)return c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"});const p=o-u,h=p>s?"⚠":p<-d?"✗":"✓";return c.jsxs("span",{style:{color:"var(--text-mid)",fontSize:"0.82rem"},children:[h," ",p>=0?"+":"",Xe(p)]})}function hm({available:o,required:u,warnOverRed:s,warnOverAmber:d,warnUnderAmber:p,warnUnderRed:h}){if(o===0&&u===0)return c.jsx("span",{style:{color:"var(--text-mid)"},children:"—"});const g=o-u;return g>s?c.jsxs("span",{className:"diff-over-red",children:["⚠ ",Xe(g)," spare"]}):g>d?c.jsxs("span",{className:"diff-over",children:["⚠ ",Xe(g)," spare"]}):g<-h?c.jsxs("span",{className:"diff-under",children:["✗ ",Xe(Math.abs(g))," short"]}):g<-p?c.jsxs("span",{className:"diff-under-amber",children:["✗ ",Xe(Math.abs(g))," short"]}):c.jsxs("span",{className:"diff-ok",children:["✓ ",g>=0?"+":"",Xe(g)]})}function mm({bookings:o,adjustments:u,onChange:s}){const{dates:d}=o;function p(j,k){s(u.map((_,P)=>P===j?{..._,label:k}:_))}function h(j,k,_){const P=parseFloat(_);s(u.map((N,I)=>{if(I!==j)return N;const H={...N.hours};return isNaN(P)?delete H[k]:H[k]=P,{...N,hours:H}}))}function g(j){s(u.filter((k,_)=>_!==j))}return u.length===0?c.jsx("p",{style:{color:"var(--text-mid)",fontSize:"0.82rem",padding:"0.5rem 0"},children:'No adjustments — use "+ Add adjustment" above to add a one-off hour offset for a specific date.'}):c.jsxs("table",{className:"hk-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Label"}),d.map(j=>c.jsx("th",{children:Pi(j)},j)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsx("tbody",{children:u.map((j,k)=>c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:j.label,placeholder:"e.g. Rooms from Sunday",onChange:_=>p(k,_.target.value)})}),d.map(_=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",step:.25,value:j.hours[_]??"",placeholder:"0",onChange:P=>h(k,_,P.target.value)})},_)),c.jsx("td",{children:c.jsx("button",{onClick:()=>g(k),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},k))}),c.jsx("tfoot",{children:c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",style:{fontSize:"0.78rem",color:"var(--text-mid)"},children:"Total"}),d.map(j=>{const k=u.reduce((_,P)=>_+(P.hours[j]||0),0);return c.jsx("td",{style:{color:k<0?"var(--danger)":k>0?"#1a7a4a":"var(--text-mid)",fontWeight:k!==0?600:void 0},children:k===0?"—":(k>0?"+":"")+Xe(k)},j)}),c.jsx("td",{})]})})]})}const Uc=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function vm(){const[o,u]=S.useState([]),[s,d]=S.useState(!0),[p,h]=S.useState(!1),[g,j]=S.useState(!1),[k,_]=S.useState(""),[P,N]=S.useState(""),[I,H]=S.useState(null),[K,T]=S.useState([]),[E,B]=S.useState([]),[$,G]=S.useState(!0),[F,ie]=S.useState(""),[fe,Ce]=S.useState(!1),[ye,Ze]=S.useState(!1),[Le,qe]=S.useState(""),[Oe,Ee]=S.useState([]),[Ue,be]=S.useState(!1),[De,ve]=S.useState(""),[W,X]=S.useState(""),[U,y]=S.useState({}),[R,ne]=S.useState(""),[re,oe]=S.useState(""),[se,de]=S.useState(4),[ae,ue]=S.useState(1),[Se,lt]=S.useState(1),[qt,Bt]=S.useState(2),[bt,Nn]=S.useState(!1),[en,At]=S.useState(""),[tn,nn]=S.useState("");S.useEffect(()=>{Promise.all([Yh(),nd(),Xh().catch(D=>(D.message.includes("503")||D.message.toLowerCase().includes("not configured")?Ce(!0):ie(D.message),null))]).then(([D,ee,le])=>{u(D.categories),Ee(ee.general_tasks||[]),y(ee.time_requirements||{}),B(ee.workforce_departments||[]),de(ee.warn_over_red_hrs??4),ue(ee.warn_over_amber_hrs??1),lt(ee.warn_under_amber_hrs??1),Bt(ee.warn_under_red_hrs??2),le&&T(le),d(!1),G(!1)}).catch(D=>{_(D.message),d(!1),G(!1)})},[]);function $t(D){u(o.map((ee,le)=>le===D?{...ee,excluded:!ee.excluded}:ee))}function Ot(D,ee){H(ee),D.dataTransfer.effectAllowed="move"}function Pn(D,ee){if(D.preventDefault(),I===null||I===ee)return;const le=[...o],[We]=le.splice(I,1);le.splice(ee,0,We),u(le),H(ee)}function rn(){H(null)}async function $n(){h(!0),_(""),N("");try{await Gh(o.map(D=>D.id),o.filter(D=>D.excluded).map(D=>D.id)),N("Saved"),setTimeout(()=>N(""),2500)}catch(D){_(D instanceof Error?D.message:"Save failed")}finally{h(!1)}}async function Vn(){j(!0),_(""),N("");try{const D=await Jh();N(D.ok?`Connection OK: ${D.message||""}`:`Failed: ${D.error||"unknown"}`)}catch(D){_(D instanceof Error?D.message:"Test failed")}finally{j(!1)}}function b(D){B(ee=>ee.includes(D)?ee.filter(le=>le!==D):[...ee,D])}async function pe(){Ze(!0),ie(""),qe("");try{await Zh(E),qe("Departments saved"),setTimeout(()=>qe(""),2500)}catch(D){ie(D instanceof Error?D.message:"Save failed")}finally{Ze(!1)}}function Te(D,ee){Ee(Oe.map((le,We)=>We===D?{...le,name:ee}:le))}function Ye(D,ee,le){const We=parseInt(le,10);Ee(Oe.map((xt,Sr)=>Sr!==D?xt:{...xt,hours:{...xt.hours,[ee]:isNaN(We)?0:Math.max(0,We)}}))}function it(D){Ee(Oe.filter((ee,le)=>le!==D))}async function at(){be(!0),X(""),ve("");try{await Qh(Oe),ve("Saved"),setTimeout(()=>ve(""),2500)}catch(D){X(D instanceof Error?D.message:"Save failed")}finally{be(!1)}}async function $e(D,ee,le){const We={...U,[D]:{...U[D]||{depart:0,stay:0,arrive:0},[ee]:le}};y(We);try{await $h(D,ee,le),ne("Saved"),setTimeout(()=>ne(""),1500)}catch(xt){oe(xt instanceof Error?xt.message:"Save failed")}}async function Re(){Nn(!0),nn(""),At("");try{await nm({warn_over_red_hrs:se,warn_over_amber_hrs:ae,warn_under_amber_hrs:Se,warn_under_red_hrs:qt}),At("Saved"),setTimeout(()=>At(""),2500)}catch(D){nn(D instanceof Error?D.message:"Save failed")}finally{Nn(!1)}}return s?c.jsx("div",{style:{padding:"2rem",color:"var(--text-mid)"},children:"Loading…"}):c.jsxs("div",{style:{padding:"1.5rem",maxWidth:"680px"},children:[c.jsx("h1",{style:{fontSize:"1.1rem",fontWeight:700,color:"var(--text-dark)",marginBottom:"1.5rem"},children:"Settings"}),c.jsx(ol,{title:"Room Categories"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Drag to reorder. Toggle to exclude categories from the planner."}),k&&c.jsx(Ut,{type:"error",children:k}),P&&c.jsx(Ut,{type:"ok",children:P}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:o.map((D,ee)=>c.jsxs("div",{draggable:!0,onDragStart:le=>Ot(le,ee),onDragOver:le=>Pn(le,ee),onDragEnd:rn,style:{display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.625rem 0.875rem",border:"1px solid var(--card-border)",borderRadius:"8px",background:D.excluded?"#f8fafc":"var(--card-bg)",opacity:I===ee?.5:1},children:[c.jsx(Nh,{size:16,color:"var(--text-mid)",style:{cursor:"grab",flexShrink:0}}),c.jsx("span",{style:{flex:1,fontSize:"0.9rem",color:D.excluded?"var(--text-mid)":"var(--text-dark)",textDecoration:D.excluded?"line-through":"none"},children:D.name}),c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--text-mid)",marginRight:"0.5rem"},children:[D.room_count," rooms"]}),c.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.375rem",fontSize:"0.8rem",color:"var(--text-mid)"},children:[c.jsx("input",{type:"checkbox",checked:!D.excluded,onChange:()=>$t(ee)}),"Active"]})]},D.id))}),c.jsxs("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap",marginBottom:"2.5rem"},children:[c.jsx(mr,{onClick:$n,disabled:p,primary:!0,children:p?"Saving…":"Save Order & Visibility"}),c.jsx(mr,{onClick:Vn,disabled:g,children:g?"Testing…":"Test Newbook Connection"})]}),c.jsx(Si,{}),c.jsx(ol,{title:"Workforce Departments"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Select the department(s) whose shifts should appear in the HK staff rota."}),fe&&c.jsxs("div",{style:{padding:"0.75rem",borderRadius:"8px",background:"#f8fafc",border:"1px solid var(--card-border)",color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"2rem"},children:["Workforce integration not configured — add the bearer token in ",c.jsx("strong",{children:"Settings → Integrations → Workforce"}),"."]}),!fe&&$&&c.jsx("div",{style:{color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"2rem"},children:"Loading departments…"}),!fe&&!$&&c.jsxs("div",{style:{marginBottom:"2.5rem"},children:[F&&c.jsx(Ut,{type:"error",children:F}),Le&&c.jsx(Ut,{type:"ok",children:Le}),K.length===0?c.jsx("div",{style:{color:"var(--text-mid)",fontSize:"0.85rem",marginBottom:"1rem"},children:"No departments found for this location."}):c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem",marginBottom:"1rem"},children:K.map(D=>c.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.5rem 0.75rem",border:"1px solid var(--card-border)",borderRadius:"7px",background:E.includes(D.id)?"rgba(42,100,72,0.05)":"var(--card-bg)",cursor:"pointer",fontSize:"0.9rem",color:"var(--text-dark)"},children:[c.jsx("input",{type:"checkbox",checked:E.includes(D.id),onChange:()=>b(D.id)}),D.name]},D.id))}),E.length===0&&K.length>0&&c.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"#b45309"},children:"Select at least one department to enable Workforce sync."}),c.jsx(mr,{onClick:pe,disabled:ye,primary:!0,children:ye?"Saving…":"Save Departments"})]}),c.jsx(Si,{}),c.jsx(ol,{title:"Recurring General Tasks"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Tasks that recur every week. Enter minutes per day. These add to the total required hours every week."}),W&&c.jsx(Ut,{type:"error",children:W}),De&&c.jsx(Ut,{type:"ok",children:De}),c.jsx("div",{style:{overflowX:"auto",marginBottom:"1rem"},children:c.jsxs("table",{className:"hk-table",style:{minWidth:"560px"},children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Task"}),Uc.map(D=>c.jsx("th",{children:D},D)),c.jsx("th",{style:{width:"32px"}})]})}),c.jsxs("tbody",{children:[Oe.length===0&&c.jsx("tr",{children:c.jsx("td",{colSpan:9,style:{color:"var(--text-mid)",textAlign:"center",padding:"1rem"},children:"No tasks yet"})}),Oe.map((D,ee)=>c.jsxs("tr",{children:[c.jsx("td",{style:{padding:"0.3rem 0.5rem"},children:c.jsx("input",{className:"hk-text-input",value:D.name,placeholder:"Task name",onChange:le=>Te(ee,le.target.value)})}),Uc.map(le=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:999,value:D.hours[le]||"",placeholder:"0",onChange:We=>Ye(ee,le,We.target.value)})},le)),c.jsx("td",{children:c.jsx("button",{onClick:()=>it(ee),style:{background:"none",border:"none",color:"var(--text-mid)",fontSize:"1rem",padding:"0.2rem 0.4rem"},children:"×"})})]},ee))]})]})}),c.jsxs("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap",marginBottom:"2.5rem"},children:[c.jsx(mr,{onClick:()=>Ee([...Oe,{name:"",hours:{}}]),children:"+ Add task"}),c.jsx(mr,{onClick:at,disabled:Ue,primary:!0,children:Ue?"Saving…":"Save Tasks"})]}),c.jsx(Si,{}),c.jsx(ol,{title:"Time Requirements (minutes per room)"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"How many minutes each room type takes depending on guest status."}),re&&c.jsx(Ut,{type:"error",children:re}),R&&c.jsx(Ut,{type:"ok",children:R}),c.jsx("div",{style:{overflowX:"auto",marginBottom:"2rem"},children:c.jsxs("table",{className:"hk-table",style:{maxWidth:"500px"},children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"col-label",children:"Category"}),c.jsx("th",{children:"Depart (mins)"}),c.jsx("th",{children:"Stay (mins)"}),c.jsx("th",{children:"Arrive (mins)"})]})}),c.jsx("tbody",{children:o.filter(D=>!D.excluded).map(D=>{const ee=U[D.id]||{depart:0,stay:0,arrive:0};return c.jsxs("tr",{children:[c.jsx("td",{className:"col-label",children:D.name}),["depart","stay","arrive"].map(le=>c.jsx("td",{style:{padding:"0.3rem 0.4rem"},children:c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:999,value:ee[le]||"",placeholder:"0",onChange:We=>$e(D.id,le,parseInt(We.target.value,10)||0),onBlur:We=>$e(D.id,le,parseInt(We.target.value,10)||0)})},le))]},D.id)})})]})}),c.jsx(Si,{}),c.jsx(ol,{title:"Warning Thresholds"}),c.jsx("p",{style:{fontSize:"0.82rem",color:"var(--text-mid)",marginBottom:"1rem"},children:'Controls the colour and icon shown on the "with Adjustments" row in the staff rota. All values are in hours.'}),tn&&c.jsx(Ut,{type:"error",children:tn}),en&&c.jsx(Ut,{type:"ok",children:en}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.625rem",marginBottom:"1.25rem",maxWidth:"420px"},children:[{label:"⚠ Red warning — spare over",value:se,set:de,help:"default 4h"},{label:"⚠ Amber warning — spare over",value:ae,set:ue,help:"default 1h"},{label:"✗ Amber cross — short over",value:Se,set:lt,help:"default 1h"},{label:"✗ Red cross — short over",value:qt,set:Bt,help:"default 2h"}].map(({label:D,value:ee,set:le,help:We})=>c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[c.jsx("span",{style:{flex:1,fontSize:"0.875rem",color:"var(--text-dark)"},children:D}),c.jsx("input",{type:"number",className:"hk-num-input",min:0,max:24,step:.5,value:ee,onChange:xt=>le(parseFloat(xt.target.value)||0),style:{width:"68px"}}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-mid)",minWidth:"52px"},children:We})]},D))}),c.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-mid)",marginBottom:"1rem"},children:"Green ✓ is automatic — shown when the difference is within the amber spare and short thresholds above."}),c.jsx("div",{style:{marginBottom:"2.5rem"},children:c.jsx(mr,{onClick:Re,disabled:bt,primary:!0,children:bt?"Saving…":"Save Thresholds"})})]})}function ol({title:o}){return c.jsx("h2",{style:{fontSize:"0.95rem",fontWeight:700,color:"var(--text-dark)",marginBottom:"0.25rem"},children:o})}function Si(){return c.jsx("div",{style:{height:"1px",background:"var(--card-border)",margin:"0.5rem 0 2rem"}})}function Ut({type:o,children:u}){return c.jsx("div",{style:{marginBottom:"0.75rem",padding:"0.75rem",borderRadius:"8px",fontSize:"0.875rem",background:o==="ok"?"#dcfce7":"#fee2e2",color:o==="ok"?"var(--success)":"var(--danger)"},children:u})}function mr({children:o,onClick:u,disabled:s,primary:d}){return c.jsx("button",{onClick:u,disabled:s,style:{background:d?"var(--hk-green)":"var(--card-bg)",color:d?"#fff":"var(--text-dark)",border:`1px solid ${d?"var(--hk-green)":"var(--card-border)"}`,borderRadius:"6px",padding:"0.5rem 1.25rem",fontSize:"0.875rem",fontWeight:600},children:o})}function gm({user:o}){return c.jsx(Uh,{user:o,children:c.jsxs(bp,{children:[c.jsx(sl,{path:"/",element:c.jsx(ks,{to:"/planner",replace:!0})}),c.jsx(sl,{path:"/planner",element:c.jsx(sm,{})}),c.jsx(sl,{path:"/settings",element:td(o,"settings")?c.jsx(vm,{}):c.jsx(ks,{to:"/planner",replace:!0})}),c.jsx(sl,{path:"*",element:c.jsx(ks,{to:"/planner",replace:!0})})]})})}function ym(){const o=Mh("/hk-planner/health");return c.jsxs(c.Fragment,{children:[c.jsx(sh,{basename:"/hk-planner",children:c.jsx(gh,{children:u=>c.jsx(gm,{user:u})})}),c.jsx(Oh,{visible:o})]})}new URLSearchParams(window.location.search).has("install")&&window.addEventListener("beforeinstallprompt",o=>{o.preventDefault(),o.prompt()},{once:!0});up.createRoot(document.getElementById("root")).render(c.jsx(S.StrictMode,{children:c.jsx(ym,{})})); diff --git a/frontend/dist/index.html b/frontend/dist/index.html index f1ed10c..e8e9152 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -5,7 +5,7 @@ HK Planner - + diff --git a/frontend/dist/sw.js b/frontend/dist/sw.js index c06c422..12337c3 100644 --- a/frontend/dist/sw.js +++ b/frontend/dist/sw.js @@ -1 +1 @@ -if(!self.define){let e,i={};const n=(n,s)=>(n=new URL(n+".js",s).href,i[n]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()}).then(()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(s,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(i[o])return;let t={};const c=e=>n(e,o),d={module:{uri:o},exports:t,require:c};i[o]=Promise.all(s.map(e=>d[e]||c(e))).then(e=>(r(...e),t))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"a2c395d8c225f1b3ea12388f15189bce"},{url:"index.html",revision:"69c09c935ebcd7adcba85b212773b6f6"},{url:"icons/icon-512.png",revision:"c32202b9deed67ef38331f63dec9d1c8"},{url:"icons/icon-192.png",revision:"46ece317d50d10b8f5e225e073b3221d"},{url:"assets/index-C1fxqzme.js",revision:null},{url:"assets/index-B7_UXJgZ.css",revision:null},{url:"manifest.webmanifest",revision:"c2510de876adb84db0c4b300b71216fa"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/hk-planner/index.html"),{denylist:[/\/api\//]}))}); +if(!self.define){let e,i={};const n=(n,s)=>(n=new URL(n+".js",s).href,i[n]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()}).then(()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(s,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(i[o])return;let t={};const c=e=>n(e,o),d={module:{uri:o},exports:t,require:c};i[o]=Promise.all(s.map(e=>d[e]||c(e))).then(e=>(r(...e),t))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"a2c395d8c225f1b3ea12388f15189bce"},{url:"index.html",revision:"3b1c49874f107c5a3d6697cd6a89320e"},{url:"icons/icon-512.png",revision:"c32202b9deed67ef38331f63dec9d1c8"},{url:"icons/icon-192.png",revision:"46ece317d50d10b8f5e225e073b3221d"},{url:"assets/index-C9TVzZ7i.js",revision:null},{url:"assets/index-B7_UXJgZ.css",revision:null},{url:"manifest.webmanifest",revision:"c2510de876adb84db0c4b300b71216fa"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/hk-planner/index.html"),{denylist:[/\/api\//]}))}); diff --git a/frontend/src/api.js b/frontend/src/api.js index fc06e47..5f9d882 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -86,6 +86,9 @@ export function putWorkforceDepartments(dept_ids) { export function syncWorkforce() { return request('/workforce/sync', { method: 'POST' }); } +export function syncTimesheets() { + return request('/workforce/sync-timesheets', { method: 'POST' }); +} export function getWorkforceShifts(start, end) { return request(`/workforce/shifts?start=${start}&end=${end}`); } diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 6b1445a..990a82a 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -120,6 +120,10 @@ export function syncWorkforce(): Promise<{ ok: boolean; from: string; to: string return request('/workforce/sync', { method: 'POST' }) } +export function syncTimesheets(): Promise<{ ok: boolean; from: string; to: string; dates_synced: number }> { + return request('/workforce/sync-timesheets', { method: 'POST' }) +} + export function getWorkforceShifts(start: string, end: string): Promise> { return request(`/workforce/shifts?start=${start}&end=${end}`) } diff --git a/frontend/src/pages/Planner.js b/frontend/src/pages/Planner.js index 2277351..95e46ee 100644 --- a/frontend/src/pages/Planner.js +++ b/frontend/src/pages/Planner.js @@ -1,7 +1,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { useState, useEffect, useRef, useCallback } from 'react'; -import { RefreshCw } from 'lucide-react'; -import { getBookings, getConfig, putStaff, putPickup, putLastReviewed, putAdjustments, syncWorkforce, getWorkforceShifts, getWorkforceStaff, } from '../api'; +import { RefreshCw, Clock } from 'lucide-react'; +import { getBookings, getConfig, putStaff, putPickup, putLastReviewed, putAdjustments, syncWorkforce, syncTimesheets, getWorkforceShifts, getWorkforceStaff, } from '../api'; // ── Date helpers ────────────────────────────────────────────────────────────── function todayStr() { const d = new Date(); @@ -104,6 +104,7 @@ export function Planner() { const [wfShifts, setWfShifts] = useState({}); const [wfStaff, setWfStaff] = useState([]); const [syncing, setSyncing] = useState(false); + const [timesheetSyncing, setTimesheetSyncing] = useState(false); const [weekStart, setWeekStart] = useState(null); const [lastViewed, setLastViewed] = useState(''); const [savedLastReviewed, setSavedLastReviewed] = useState(''); @@ -265,6 +266,23 @@ export function Planner() { setSyncing(false); } } + async function syncTimesheetData() { + setTimesheetSyncing(true); + try { + await syncTimesheets(); + if (bookings) { + const shifts = await getWorkforceShifts(bookings.dates[0], bookings.dates[bookings.dates.length - 1]); + setWfShifts(shifts); + } + flash('Timesheets pulled from Workforce'); + } + catch (e) { + flash(e instanceof Error ? e.message : 'Timesheet sync failed', true); + } + finally { + setTimesheetSyncing(false); + } + } function wfSyncLabel() { if (!bookings) return ''; @@ -305,12 +323,17 @@ export function Planner() { }, children: saveMsg.text })), error && (_jsxs("div", { style: { marginBottom: '1rem', padding: '0.75rem 1rem', borderRadius: '8px', background: '#fee2e2', color: 'var(--danger)', fontSize: '0.875rem', - }, children: ["Error: ", error] })), loading && !bookings && (_jsx("div", { style: { color: 'var(--text-mid)', padding: '2rem 0', textAlign: 'center' }, children: "Loading bookings\u2026" })), bookings && required && (_jsxs(_Fragment, { children: [_jsx(Section, { title: "7-Day Occupancy", children: _jsx("div", { className: "table-scroll", children: _jsx(SummaryTable, { bookings: bookings, pickup: pickup, onPickupChange: handlePickupChange }) }) }), _jsx(Section, { title: "Required Hours", children: _jsx("div", { className: "table-scroll", children: _jsx(RequiredTable, { bookings: bookings, required: required }) }) }), _jsx(Section, { title: "Adjustments", action: _jsx(CtrlBtn, { onClick: addAdjustmentRow, children: "+ Add adjustment" }), children: _jsx("div", { className: "table-scroll", children: _jsx(AdjustmentsTable, { bookings: bookings, adjustments: adjustments, onChange: handleAdjustmentsChange }) }) }), _jsx(Section, { title: "Staff Rota", action: _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '0.5rem', flexWrap: 'wrap' }, children: [_jsxs("button", { onClick: syncRota, disabled: syncing, style: { + }, children: ["Error: ", error] })), loading && !bookings && (_jsx("div", { style: { color: 'var(--text-mid)', padding: '2rem 0', textAlign: 'center' }, children: "Loading bookings\u2026" })), bookings && required && (_jsxs(_Fragment, { children: [_jsx(Section, { title: "7-Day Occupancy", children: _jsx("div", { className: "table-scroll", children: _jsx(SummaryTable, { bookings: bookings, pickup: pickup, onPickupChange: handlePickupChange }) }) }), _jsx(Section, { title: "Required Hours", children: _jsx("div", { className: "table-scroll", children: _jsx(RequiredTable, { bookings: bookings, required: required }) }) }), _jsx(Section, { title: "Adjustments", action: _jsx(CtrlBtn, { onClick: addAdjustmentRow, children: "+ Add adjustment" }), children: _jsx("div", { className: "table-scroll", children: _jsx(AdjustmentsTable, { bookings: bookings, adjustments: adjustments, onChange: handleAdjustmentsChange }) }) }), _jsx(Section, { title: "Staff Rota", action: _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '0.5rem', flexWrap: 'wrap' }, children: [_jsxs("button", { onClick: syncRota, disabled: syncing || timesheetSyncing, style: { display: 'flex', alignItems: 'center', gap: '0.3rem', background: 'var(--card-bg)', color: 'var(--text-dark)', border: '1px solid var(--card-border)', borderRadius: '6px', padding: '0.3rem 0.65rem', fontSize: '0.78rem', fontWeight: 600, - }, children: [_jsx(RefreshCw, { size: 11, strokeWidth: 1.75, style: { animation: syncing ? 'spin 1s linear infinite' : 'none' } }), syncing ? 'Syncing…' : 'Sync from Workforce'] }), _jsx("span", { style: { fontSize: '0.72rem', color: 'var(--text-mid)' }, children: wfSyncLabel() }), _jsx(CtrlBtn, { onClick: addStaffRow, children: "+ Add staff" })] }), children: _jsx("div", { className: "table-scroll", children: _jsx(StaffTable, { bookings: bookings, staff: staff, required: required, warnOverRed: warnOverRed, warnOverAmber: warnOverAmber, warnUnderAmber: warnUnderAmber, warnUnderRed: warnUnderRed, onChange: handleStaffChange, wfShifts: wfShifts, wfStaff: wfStaff }) }) })] }))] })); + }, children: [_jsx(RefreshCw, { size: 11, strokeWidth: 1.75, style: { animation: syncing ? 'spin 1s linear infinite' : 'none' } }), syncing ? 'Syncing…' : 'Sync rota'] }), _jsxs("button", { onClick: syncTimesheetData, disabled: syncing || timesheetSyncing, style: { + display: 'flex', alignItems: 'center', gap: '0.3rem', + background: 'var(--card-bg)', color: 'var(--text-dark)', + border: '1px solid var(--card-border)', borderRadius: '6px', + padding: '0.3rem 0.65rem', fontSize: '0.78rem', fontWeight: 600, + }, children: [_jsx(Clock, { size: 11, strokeWidth: 1.75, style: { animation: timesheetSyncing ? 'spin 1s linear infinite' : 'none' } }), timesheetSyncing ? 'Pulling…' : 'Pull timesheets'] }), _jsx("span", { style: { fontSize: '0.72rem', color: 'var(--text-mid)' }, children: wfSyncLabel() }), _jsx(CtrlBtn, { onClick: addStaffRow, children: "+ Add staff" })] }), children: _jsx("div", { className: "table-scroll", children: _jsx(StaffTable, { bookings: bookings, staff: staff, required: required, warnOverRed: warnOverRed, warnOverAmber: warnOverAmber, warnUnderAmber: warnUnderAmber, warnUnderRed: warnUnderRed, onChange: handleStaffChange, wfShifts: wfShifts, wfStaff: wfStaff }) }) })] }))] })); } // ── Section wrapper ─────────────────────────────────────────────────────────── function Section({ title, children, action }) { @@ -433,7 +456,7 @@ function pivotWfShifts(wfShifts, dates) { for (const s of day.staff) { if (!members[s.id]) members[s.id] = { id: s.id, name: s.name, days: {} }; - members[s.id].days[date] = { hours: s.hours, times: s.times }; + members[s.id].days[date] = { hours: s.hours, times: s.times, status: s.status }; } } return Object.values(members).sort((a, b) => a.name.localeCompare(b.name)); @@ -468,7 +491,9 @@ function StaffTable({ bookings, staff, required, warnOverRed, warnOverAmber, war borderRadius: '3px', padding: '0 4px', marginRight: '0.4rem', lineHeight: '1.5', }, children: "WF" }), member.name] }), dates.map(date => { const shift = member.days[date]; - return (_jsx("td", { style: { textAlign: 'center', padding: '0.3rem 0.4rem', verticalAlign: 'middle' }, children: shift ? (_jsxs(_Fragment, { children: [_jsx("div", { style: { fontSize: '0.68rem', color: 'var(--text-mid)', lineHeight: 1.25 }, children: shift.times }), _jsx("div", { style: { fontWeight: 600 }, children: fmtH(shift.hours) })] })) : _jsx("span", { style: { color: 'var(--text-mid)' }, children: "\u2014" }) }, date)); + const isTimesheet = wfShifts[date]?.source === 'timesheet'; + const isPending = isTimesheet && shift?.status !== 'APPROVED'; + return (_jsx("td", { style: { textAlign: 'center', padding: '0.3rem 0.4rem', verticalAlign: 'middle' }, children: shift ? (_jsxs(_Fragment, { children: [_jsx("div", { style: { fontSize: '0.68rem', color: 'var(--text-mid)', lineHeight: 1.25 }, children: shift.times }), _jsxs("div", { style: { fontWeight: 600, display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '0.2rem' }, children: [isTimesheet && (_jsx(Clock, { size: 10, strokeWidth: 1.75, style: { color: isPending ? '#d97706' : '#1a7a4a', flexShrink: 0 } })), fmtH(shift.hours)] })] })) : _jsx("span", { style: { color: 'var(--text-mid)' }, children: "\u2014" }) }, date)); }), _jsx("td", {})] }, 'wf-' + member.id))), wfStaff.length > 0 && (_jsx("datalist", { id: "wf-staff-datalist", children: wfStaff.map(s => _jsx("option", { value: s.name }, s.id)) })), staff.map((member, i) => (_jsxs("tr", { children: [_jsx("td", { className: "col-label", style: { padding: '0.3rem 0.5rem' }, children: _jsx("input", { className: "hk-text-input", value: member.name, placeholder: "Staff name", list: wfStaff.length > 0 ? 'wf-staff-datalist' : undefined, onChange: e => setMemberName(i, e.target.value) }) }), dates.map(date => (_jsx("td", { style: { padding: '0.3rem 0.4rem' }, children: _jsx("input", { type: "number", className: "hk-num-input", min: 0, max: 24, step: 0.5, value: member.hours[date] ?? '', placeholder: "0", onChange: e => setMemberHours(i, date, e.target.value) }) }, date))), _jsx("td", { children: _jsx("button", { onClick: () => removeRow(i), style: { background: 'none', border: 'none', color: 'var(--text-mid)', fontSize: '1rem', padding: '0.2rem 0.4rem', diff --git a/frontend/src/pages/Planner.tsx b/frontend/src/pages/Planner.tsx index 1cccfd3..a2bf61e 100644 --- a/frontend/src/pages/Planner.tsx +++ b/frontend/src/pages/Planner.tsx @@ -1,8 +1,8 @@ import { useState, useEffect, useRef, useCallback } from 'react' -import { RefreshCw } from 'lucide-react' +import { RefreshCw, Clock } from 'lucide-react' import { getBookings, getConfig, putStaff, putPickup, - putLastReviewed, putAdjustments, syncWorkforce, getWorkforceShifts, getWorkforceStaff, + putLastReviewed, putAdjustments, syncWorkforce, syncTimesheets, getWorkforceShifts, getWorkforceStaff, } from '../api' import type { BookingsData, TimeReqs, StaffMember, GeneralTask, @@ -135,7 +135,8 @@ export function Planner() { const [warnUnderRed, setWarnUnderRed] = useState(2) const [wfShifts, setWfShifts] = useState>({}) const [wfStaff, setWfStaff] = useState<{ id: string; name: string }[]>([]) - const [syncing, setSyncing] = useState(false) + const [syncing, setSyncing] = useState(false) + const [timesheetSyncing, setTimesheetSyncing] = useState(false) const [weekStart, setWeekStart] = useState(null) const [lastViewed, setLastViewed] = useState('') const [savedLastReviewed, setSavedLastReviewed] = useState('') @@ -312,6 +313,22 @@ export function Planner() { } } + async function syncTimesheetData() { + setTimesheetSyncing(true) + try { + await syncTimesheets() + if (bookings) { + const shifts = await getWorkforceShifts(bookings.dates[0], bookings.dates[bookings.dates.length - 1]) + setWfShifts(shifts) + } + flash('Timesheets pulled from Workforce') + } catch (e) { + flash(e instanceof Error ? e.message : 'Timesheet sync failed', true) + } finally { + setTimesheetSyncing(false) + } + } + function wfSyncLabel(): string { if (!bookings) return '' const viewDates = bookings.dates.filter(d => wfShifts[d]) @@ -447,7 +464,7 @@ export function Planner() {
+ {wfSyncLabel()} + Add staff @@ -804,7 +834,7 @@ function pivotWfShifts(wfShifts: Record, dates: string[]): Wf if (!day) continue for (const s of day.staff) { if (!members[s.id]) members[s.id] = { id: s.id, name: s.name, days: {} } - members[s.id].days[date] = { hours: s.hours, times: s.times } + members[s.id].days[date] = { hours: s.hours, times: s.times, status: s.status } } } return Object.values(members).sort((a, b) => a.name.localeCompare(b.name)) @@ -869,13 +899,20 @@ function StaffTable({ bookings, staff, required, warnOverRed, warnOverAmber, war {member.name} {dates.map(date => { - const shift = member.days[date] + const shift = member.days[date] + const isTimesheet = wfShifts[date]?.source === 'timesheet' + const isPending = isTimesheet && shift?.status !== 'APPROVED' return ( {shift ? ( <>
{shift.times}
-
{fmtH(shift.hours)}
+
+ {isTimesheet && ( + + )} + {fmtH(shift.hours)} +
) : } diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 005072b..5bf5cdb 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -57,6 +57,7 @@ export interface Adjustment { export interface WfShiftDay { hours: number times: string + status?: string } export interface WfStaffMember { @@ -68,7 +69,7 @@ export interface WfStaffMember { export interface WfDayData { synced_at: string source: string - staff: { id: string; name: string; hours: number; times: string }[] + staff: { id: string; name: string; hours: number; times: string; status?: string }[] } export interface RequiredDay {