diff --git a/AGENTS.md b/AGENTS.md index 34c4a84..4e1ae44 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,6 +9,7 @@ Guidance for coding agents working in this repository (`tickcount/luci-app-dawnl - `rules/frontend.md` — TypeScript admin UI and portal: layout of `web/src`, pollers and the live revision. - `rules/shell.md` — install, uninstall, init and CI scripts. - `rules/ui-design.md` — how the admin UI and the portal look: modern product quality, mock first from the real CSS and components, verified in the browser. +- `DESIGN.md` — the personal portal's design system: tokens, components, layout and motion, measured on the live page. Read it before any work on the portal (`web/src/portal`, and what it uses from `web/src/shared`); a change to how the portal looks or moves updates it in the same change. - `rules/i18n.md` — translations: every visible string and backend message wrapped, the catalogs, the Russian style guide and glossary. Anything added to the admin UI or the portal is localized in the same change; anything removed takes its catalog entries with it. This repo usually sits inside the router-admin workspace (`../AGENTS.md`). Its rules apply to anything that touches the router: read-only first, backup before mutating, router shell as a literal stdin heredoc over SSH (`../rules/`). diff --git a/DESIGN.md b/DESIGN.md new file mode 100644 index 0000000..c0338a7 --- /dev/null +++ b/DESIGN.md @@ -0,0 +1,1453 @@ +--- +version: alpha +name: Dawnline Portal +description: >- + The personal portal of Dawnline (an AmneziaWG access server for OpenWrt): one page per person + with their devices, their access and the set-up of a new device. Near-black and quiet, surfaces + that step up in brightness instead of borders, one sky-blue accent, colour only for state, + physical spring motion, and text that changes in place letter by letter. +colors: + # Dark (the default; measured from skiper21). Light values follow with the light- prefix. + bg: "#080808" + raised: "#121212" + field: "#161616" + knob: "#232323" + seg: "rgba(237, 237, 237, 0.05)" + line: "rgba(255, 255, 255, 0.06)" + line-glass: "rgba(255, 255, 255, 0.07)" + text: "#ededed" + text-2: "#8c8c8a" + text-3: "#4f4f4e" + accent: "#4eafff" + accent-ink: "#ffffff" + accent-soft: "rgba(78, 175, 255, 0.13)" + ok: "#57d64b" + ok-soft: "rgba(87, 214, 75, 0.14)" + warn: "#ff8a3d" + bad: "#ff5c5c" + bad-soft: "rgba(255, 92, 92, 0.13)" + selection-bg: "rgba(131, 209, 255, 0.25)" + selection-fg: "#64c6ff" + scrim: "rgba(8, 8, 8, 0.8)" + bar: "rgba(237, 237, 237, 0.13)" + toast: "#232323" + toast-fg: "#ededed" + qr-bg: "#0a0a0a" + light-bg: "#f2f2f1" + light-raised: "#ffffff" + light-field: "#f3f3f2" + light-knob: "#e8e8e7" + light-seg: "#ffffff" + light-line: "rgba(0, 0, 0, 0.07)" + light-text: "#0b0b0b" + light-text-2: "#6d6d6b" + light-text-3: "#a6a6a4" + light-accent: "#2b9dff" + light-accent-soft: "rgba(43, 157, 255, 0.12)" + light-ok: "#33a328" + light-ok-soft: "rgba(51, 163, 40, 0.12)" + light-warn: "#ee6a12" + light-bad: "#e5484d" + light-bad-soft: "rgba(229, 72, 77, 0.1)" + light-selection-bg: "rgba(78, 175, 255, 0.22)" + light-selection-fg: "#0a76cf" + light-scrim: "rgba(236, 236, 235, 0.62)" + light-bar: "rgba(11, 11, 11, 0.11)" + light-toast: "#0b0b0b" + light-toast-fg: "#f2f2f1" + light-qr-bg: "#ffffff" +typography: + body: + fontFamily: Geist + fontSize: 15px + fontWeight: 400 + lineHeight: 22px + letterSpacing: -0.011em + display-number: + fontFamily: Geist + fontSize: 36px + fontWeight: 600 + lineHeight: 40px + letterSpacing: -0.045em + card-title-alone: + fontFamily: Geist + fontSize: 22px + fontWeight: 500 + lineHeight: 28px + letterSpacing: -0.03em + section-title: + fontFamily: Geist + fontSize: 20px + fontWeight: 500 + lineHeight: 28px + letterSpacing: -0.025em + sheet-title: + fontFamily: Geist + fontSize: 20px + fontWeight: 500 + lineHeight: 28px + letterSpacing: -0.5px + empty-title: + fontFamily: Geist + fontSize: 18px + fontWeight: 500 + lineHeight: 24px + letterSpacing: -0.02em + value: + fontFamily: Geist + fontSize: 17px + fontWeight: 500 + lineHeight: 24px + letterSpacing: -0.02em + fontFeature: '"tnum"' + card-title: + fontFamily: Geist + fontSize: 16px + fontWeight: 500 + lineHeight: 22px + letterSpacing: -0.02em + button: + fontFamily: Geist + fontSize: 16px + fontWeight: 500 + lineHeight: 22px + letterSpacing: -0.015em + button-strong: + fontFamily: Geist + fontSize: 16px + fontWeight: 600 + lineHeight: 22px + letterSpacing: -0.015em + input: + fontFamily: Geist + fontSize: 16px + fontWeight: 500 + lineHeight: 24px + letterSpacing: -0.012em + step-title: + fontFamily: Geist + fontSize: 16px + fontWeight: 500 + lineHeight: 24px + letterSpacing: -0.02em + row-title: + fontFamily: Geist + fontSize: 15px + fontWeight: 500 + lineHeight: 22px + letterSpacing: -0.02em + breadcrumb: + fontFamily: Geist + fontSize: 15px + fontWeight: 400 + lineHeight: 22px + letterSpacing: -0.15px + question-text: + fontFamily: Geist + fontSize: 15px + fontWeight: 400 + lineHeight: 21px + desc: + fontFamily: Geist + fontSize: 14px + fontWeight: 400 + lineHeight: 20px + menu-item: + fontFamily: Geist + fontSize: 14px + fontWeight: 500 + lineHeight: 20px + toast: + fontFamily: Geist + fontSize: 14px + fontWeight: 500 + lineHeight: 20px + meta: + fontFamily: Geist + fontSize: 13px + fontWeight: 400 + lineHeight: 18px + pill-label: + fontFamily: Geist + fontSize: 13px + fontWeight: 600 + lineHeight: 18px + label-sm: + fontFamily: Geist + fontSize: 12px + fontWeight: 500 + lineHeight: 16px + tooltip: + fontFamily: Geist + fontSize: 12px + fontWeight: 500 + lineHeight: 12px + letterSpacing: -0.1px + divider-label: + fontFamily: Geist + fontSize: 12px + fontWeight: 500 + lineHeight: 22px + letterSpacing: 0.06em + axis: + fontFamily: Geist + fontSize: 11px + fontWeight: 500 + lineHeight: 16px + axis-xs: + fontFamily: Geist + fontSize: 10px + fontWeight: 500 + lineHeight: 14px + calendar-head: + fontFamily: Geist + fontSize: 9px + fontWeight: 600 + lineHeight: 10px + mono-link: + fontFamily: Geist Mono + fontSize: 13px + fontWeight: 400 + lineHeight: 22px + letterSpacing: 0px + mono-code: + fontFamily: Geist Mono + fontSize: 12px + fontWeight: 400 + lineHeight: 18px + letterSpacing: 0px +rounded: + sheet: 36px + card: 28px + notice: 24px + qr-big: 24px + qr-dense: 22px + row: 20px + menu: 20px + badge: 18px + qr: 18px + field: 16px + tile: 16px + kind: 14px + inner: 14px + key: 12px + way-end: 11px + chip: 10px + bar: 3px + full: 999px +spacing: + gutter: 16px + page-top: 40px + page-bottom: 112px + page-max: 1072px + access-column: 384px + columns-gap: 36px + stack-gap: 40px + crumbs-below: 32px + section-head-below: 12px + grid-gap: 10px + card-padding: 8px + sheet-padding: 24px + sheet-width: 400px + sheet-edge: 16px + open-row-gap: 10px + tile-gap: 8px + notice-below: 22px +components: + button-primary: + backgroundColor: "{colors.accent}" + textColor: "{colors.accent-ink}" + typography: "{typography.button-strong}" + rounded: "{rounded.full}" + height: 48px + padding: 0 20px + button-tint: + backgroundColor: "{colors.accent-soft}" + textColor: "{colors.accent}" + typography: "{typography.button-strong}" + rounded: "{rounded.full}" + height: 48px + padding: 0 20px + button-soft: + backgroundColor: "{colors.knob}" + textColor: "{colors.text}" + typography: "{typography.button}" + rounded: "{rounded.full}" + height: 48px + padding: 0 20px + button-danger: + backgroundColor: "{colors.bad}" + textColor: "#ffffff" + typography: "{typography.button-strong}" + rounded: "{rounded.full}" + height: 48px + padding: 0 20px + button-small: + rounded: "{rounded.full}" + height: 40px + padding: 0 16px + knob: + backgroundColor: "{colors.knob}" + textColor: "{colors.text}" + rounded: "{rounded.full}" + size: 32px + field: + backgroundColor: "{colors.field}" + textColor: "{colors.text}" + typography: "{typography.input}" + rounded: "{rounded.field}" + height: 48px + padding: 0 4px 0 16px + go-button: + backgroundColor: "{colors.knob}" + textColor: "{colors.text-3}" + rounded: "{rounded.key}" + width: 48px + height: 40px + go-button-ready: + backgroundColor: "{colors.accent}" + textColor: "{colors.accent-ink}" + rounded: "{rounded.key}" + width: 48px + height: 40px + device-card: + backgroundColor: "{colors.raised}" + rounded: "{rounded.card}" + padding: 8px + usage-block: + backgroundColor: "{colors.field}" + rounded: "{rounded.row}" + padding: 12px 14px 12px 16px + height: 66px + accordion-row: + backgroundColor: "{colors.raised}" + typography: "{typography.row-title}" + rounded: "{rounded.row}" + height: 52px + padding: 0 8px + accordion-row-inset: + backgroundColor: "{colors.field}" + rounded: "{rounded.row}" + height: 52px + sheet: + backgroundColor: "{colors.raised}" + rounded: "{rounded.sheet}" + width: 400px + padding: 0 24px 24px + menu: + backgroundColor: "{colors.field}" + rounded: "{rounded.menu}" + padding: 6px + width: 224px + menu-item: + typography: "{typography.menu-item}" + rounded: "{rounded.inner}" + height: 40px + padding: 0 12px + toast: + backgroundColor: "{colors.toast}" + textColor: "{colors.toast-fg}" + typography: "{typography.toast}" + rounded: "{rounded.full}" + height: 42px + padding: 0 18px 0 13px + tooltip: + backgroundColor: "{colors.toast}" + textColor: "{colors.toast-fg}" + typography: "{typography.tooltip}" + rounded: "{rounded.full}" + height: 26px + padding: 0 10px + notice: + backgroundColor: "{colors.raised}" + rounded: "{rounded.notice}" + padding: 14px 18px 14px 14px + segmented: + backgroundColor: "{colors.field}" + rounded: "{rounded.field}" + height: 48px + padding: 0 4px + segmented-pill: + backgroundColor: "{colors.seg}" + rounded: "{rounded.key}" + height: 40px + kind-tile: + backgroundColor: "{colors.field}" + rounded: "{rounded.kind}" + height: 56px + badge: + backgroundColor: "{colors.field}" + rounded: "{rounded.badge}" + height: 60px + padding: 0 14px 0 12px + link-row: + backgroundColor: "{colors.field}" + typography: "{typography.mono-link}" + rounded: "{rounded.inner}" + height: 44px + padding: 0 4px 0 14px + update-pill: + backgroundColor: "rgba(255, 138, 61, 0.14)" + textColor: "{colors.warn}" + typography: "{typography.pill-label}" + rounded: "{rounded.full}" + height: 32px + padding: 0 12px 0 10px + language-pill: + backgroundColor: "{colors.knob}" + textColor: "{colors.text}" + rounded: "{rounded.full}" + height: 32px + padding: 0 8px 0 12px + name-chip: + backgroundColor: "{colors.field}" + typography: "{typography.mono-link}" + rounded: "{rounded.chip}" + height: 32px + padding: 0 10px 0 12px + qr-code: + backgroundColor: "{colors.qr-bg}" + rounded: "{rounded.qr}" + size: 148px + qr-code-big: + backgroundColor: "{colors.qr-bg}" + rounded: "{rounded.qr-big}" + size: 208px +--- + +# DESIGN.md — the Dawnline personal portal + +This file describes the **personal portal** (`web/src/portal`, plus the parts of `web/src/shared` it uses): its look, its components and, in its own part, its motion. The admin pages inside LuCI follow `rules/ui-design.md` and the LuCI theme and are not covered here. + +The front matter follows the [DESIGN.md](https://github.com/google-labs-code/design.md) draft format (alpha). The prose sections come in that format's order. **Motion Design**, **Content & Voice**, **Accessibility**, **Live audit** and **Source map** are extra sections after them. + +**How this was researched (2026-10-20, Dawnline 0.11.0).** Two passes: + +1. **The code.** Every stylesheet in `web/src/portal/styles`, the motion engine (`motion.ts`), every UI module (`ui/`), the page (`page/`) and the flows (`flows/`). +2. **The live demo** ([dawnline-demo.vercel.app](https://dawnline-demo.vercel.app), the real portal over an in-page router). I went through every scenario, sheet, menu, picker and button at desktop width (1138 px) and phone width (375 px), in dark and in light, in English and in Russian. A recorder hooked `Element.prototype.animate`, `transitionrun` and `animationstart`, so every duration, delay and easing in this file was seen running, not only read. Spring durations and overshoot were computed from the same function the portal uses (see *Motion → Springs*). + +Where code, older plans and the live page disagree, the live page wins. The disagreements are listed in *Live audit*. + +--- + +## Overview + +The portal is one person's page on a router. It opens from a personal link with no account and no cookie, and it has three jobs: + +- show the person's **devices**; +- show their **access** (what it reaches, how much data, until when); +- **set up** a new device in about a minute. + +The router serves it as a CGI process under a strict CSP, which forbids inline scripts and `style=` attributes. It is plain TypeScript, with no framework, and it does not poll. + +**Lineage.** The look was approved as a mockup (Oct 2026). It borrows from four places: + +- **skiper-ui:** skiper21's palette, accent, highlight and tab pill, and skiper103's bouncy accordion; +- **iconiqui:** the breadcrumb and the edge fades (dia-text); +- **aicss.dev:** the busy orb, "Orbs B4 Converge"; +- **Vercel's Geist:** the type. + +**Personality.** Calm, dark and tactile. The page is near-black (`#080808`). There are no borders: each layer is a step brighter than the one under it. One sky blue is the only accent. Every other colour means a state. The UI is made of big round shapes (36 px sheets, 28 px cards, pills), and glass icons are the only illustration. + +### Principles + +1. **Structure over text.** Tiles, rings, bars, calendars and pills say it before a sentence does. Summaries come first ("38.6 GB / 100 GB"), details sit one tap deeper (the accordion). +2. **Depth from brightness, not lines.** Each layer goes bg → raised → field → knob, every step a little lighter. A ring is drawn inset, and only to mean something: focus, the picked tile, this device, a notice's tone. +3. **Colour is meaning.** Accent blue means action or "you are here". Green means fine or connected, orange means attention or paused, red means stopped, out or destructive. Grey is everything else. +4. **One place per fact.** The count sits beside "Your devices", the usage sits on its card, and the access sits in its rows. Nothing is repeated. +5. **Nothing blinks.** A change happens where it is: text morphs letter by letter, cards glide to their new places, a sheet glides to its new height. A repaint never flashes. +6. **Physical, interruptible motion.** Springs are given as stiffness and damping, and each animation starts from where the element stands right now. +7. **The keyboard never animates.** Escape closes a sheet or a menu instantly. Reduced motion keeps fades and drops all travel. +8. **Honest states.** Paused, out of data, outside the hours, a plain-HTTP link: each is said once, where it matters, in the state's colour. + +--- + +## Colors + +All colours are CSS custom properties in `styles/tokens.css`. The dark theme comes first. Light applies under `@media (prefers-color-scheme: light)`, with no toggle: the page follows the system, and its QR codes repaint in place when the system theme changes. + +### Surfaces: the brightness ladder + +| Token | Dark | Light | Role | Where | +|---|---|---|---|---| +| `--bg` | `#080808` | `#f2f2f1` | The ground | `body`, the edge fades | +| `--raised` | `#121212` | `#ffffff` | Things on the ground | device cards, accordion rows, sheet, notices, the "gone" card | +| `--field` | `#161616` | `#f3f3f2` | Things inside raised | usage block, inputs, segmented track, inset rows, tiles, badges, QR row, menu | +| `--knob` | `#232323` | `#e8e8e7` | Controls on anything | knobs, soft buttons, step numbers, hover fills, toast (dark) | +| `--seg` | `rgba(237,237,237,.05)` | `#ffffff` + `--seg-shadow` | The picked pill in the app picker | `.seg-pill` | +| `--line` | `rgba(255,255,255,.06)` | `rgba(0,0,0,.07)` | The only hairline | "OR" divider, menu separator and inner rim, light QR rim | + +The measured luminance steps are tiny. In dark, raised vs bg is 1.07:1, field vs raised 1.04:1 and knob vs raised 1.19:1. In light they are 1.12, 1.11 and 1.23. Hierarchy comes from the shape and the radius as much as from the fill, so **do not add borders** to make a level visible. + +### Text ladder + +| Token | Dark | Light | Use | +|---|---|---|---| +| `--text` | `#ededed` | `#0b0b0b` | Titles, values, current crumb, bold steps | +| `--text-2` | `#8c8c8a` | `#6d6d6b` | Secondary lines: statuses at rest, labels, hints, sheet subs, head values, accordion chevrons | +| `--text-3` | `#4f4f4e` | `#a6a6a4` | Faint: counts ("3 of 4"), "OR", axis ends, placeholders, idle picker icons, the limit note, chevrons in badges | + +`.desc` is `--text` at `opacity: .6`, not `--text-2`, so it stays readable inside rows of any fill. + +### Accent and states + +| Token | Dark | Light | Meaning | +|---|---|---|---| +| `--accent` | `#4eafff` | `#2b9dff` | Primary action, "this device", today, links in hints, the selection ring | +| `--accent-ink` | `#ffffff` | `#ffffff` | Text on a filled accent button | +| `--accent-soft` | `blue @ 13%` | `blue @ 12%` | Tinted "Connect", the Demo chip, a primary badge's icon tile | +| `--ok` / `--ok-soft` | `#57d64b` / 14% | `#33a328` / 12% | Connected, included, the way filling green, the arrival ring | +| `--warn` | `#ff8a3d` | `#ee6a12` | Not set up yet, settings changed, outside hours, Reconnect, ends soon | +| `--bad` / `--bad-soft` | `#ff5c5c` / 13% | `#e5484d` / 10% | Out of data, access ended, Remove, errors | +| `--sel-bg` / `--sel-fg` | `rgba(131,209,255,.25)` / `#64c6ff` | `rgba(78,175,255,.22)` / `#0a76cf` | `::selection` | +| `--bar` | `text @ 13%` | `text @ 11%` | Chart bars, meter and ring tracks | + +### Tint recipes (keep them) + +All tints come from `color-mix`, never from new hex values: + +| Recipe | Where | +|---|---| +| `color-mix(in srgb, var(--knob), var(--text) 6%)` | hover of knob, soft button, language pill, pinned keys | +| `… var(--text) 10%` | pressed or open (`aria-expanded`) knob and language pill | +| `color-mix(in srgb, var(--accent) 82%, transparent)` | hover of the filled accent button | +| `accent 20%` / `24%` over transparent | hover / active of the tinted button | +| `color-mix(in srgb, var(--warn|--bad) 10%, var(--raised))` + `inset 0 0 0 1px tone 22%` | warn / bad notice | +| `warn 14%` → hover `22%` | the Update pill | +| `color-mix(in srgb, var(--raised), var(--knob) 40%)` | hover of an accordion row (inset rows: field + knob 50%) | +| `color-mix(in srgb, var(--accent) 32%, transparent)` inset 1px | ring of the card of "this device" | +| `color-mix(in srgb, var(--text) 16%, transparent)` inset 1.5px | focused field | +| `color-mix(in srgb, var(--accent) 65%, transparent)` 2px outline, offset 2px | `:focus-visible` everywhere | + +### Overlays and floating colours + +- **Scrim:** dark `rgba(8,8,8,.8)`, light `rgba(236,236,235,.62)`, both with `backdrop-filter: blur(8px)`. +- **Toast and tooltip:** `#232323` on dark. On light they invert to `#0b0b0b` with `#f2f2f1` text. +- **QR card:** `#0a0a0a` "night" (light dots) on dark, `#ffffff` "day" (dark dots) on light, with a 1px `--line` rim in light. + +### Glass icon tones + +Glass icons (`ui/glass.ts`) draw a tinted back shape, the same shape blurred behind a frosted pane, a rim and white detail strokes. Their colours come only from classes, because the CSP drops `style=`. + +| Tone | Dark a → b | Light a → b | Used for | +|---|---|---|---| +| `t-grey` | `#cfcfcd` → `#5a5a59` | `#a9a9a7` → `#3d3d3c` | Device cards (default), access rows, Add | +| `t-blue` | `#a6d9ff` → `#1d84e6` | `#7cc4ff` → `#0a6fd6` | This device, first device, kinds, reach tiles that are on, lock | +| `t-green` | `#a8f29c` → `#3aa32c` | `#82e070` → `#2e8a22` | "Everything works" (demo) | +| `t-orange` | `#ffc08f` → `#ec6a12` | *same as dark* | Warn notices, Reconnect question | +| `t-red` | `#ffadad` → `#dc3a3a` | `#ff9090` → `#c92a2a` | Bad notices, Remove question | + +Frosted pane: dark `--gi-a .58 / --gi-b .14` white with a `.5` rim and no edge stroke. Light uses a `.72 / .5` grey pane, a `.9` rim and an `rgba(0,0,0,.11)` edge, with dark detail strokes. + +### Contrast (measured, WCAG 2.x) + +| Pair | Dark | Light | Verdict | +|---|---|---|---| +| text on bg / raised | 17.1 / 16.0 | 17.6 / 19.7 | AAA | +| text-2 on raised / field | 5.6 / 5.4 | 5.2 / 4.7 | AA | +| text-3 on bg / raised / field | 2.4 / 2.3 | 2.2 / 2.4 | **below AA**: decorative only | +| accent text on raised | 7.9 | **2.9** | AA in dark only | +| white on accent (primary buttons) | **2.4** | **2.9** | below AA, a known trade-off of the skiper21 palette | +| white on bad (Remove) | 3.0 | 3.9 | AA large only | +| ok / warn / bad text on raised | 9.9 / 8.0 / 6.2 | **3.3 / 3.1** / 3.9 | dark AA, light below AA at 13 px | + +These ratios feed the findings in *Live audit*. + +--- + +## Typography + +**Families:** **Geist** (variable, 100–900) and **Geist Mono**. They are self-hosted as woff2 next to `portal.css` (CSP `font-src 'self'`). Geist ships in Latin and Cyrillic subsets split by `unicode-range`, Geist Mono in Latin. Fallbacks are `-apple-system, system-ui, 'Segoe UI', sans-serif` and `ui-monospace, 'SF Mono', Menlo, monospace`, all with `font-display: swap`. + +**Base:** `400 15px/22px`, `letter-spacing: -0.011em`, `-webkit-font-smoothing: antialiased`. Body `cursor: default`, because the page is an app, not a document. Fields, the link and the configuration keep the I-beam. + +### Scale (measured live) + +| Role | Size / line | Weight | Tracking | Where | +|---|---|---|---|---| +| Display number | 36 / 40 | 600 | −0.045em | Days left in "Access until" | +| Card alone title | 22 / 28 | 500 | −0.03em | "Access paused", "This link no longer works" | +| Section title | 20 / 28 | 500 | −0.025em | "Your devices", "Your access" | +| Sheet title | 20 / 28 | 500 | −0.5px | View heads, question titles | +| Empty title | 18 / 24 | 500 | −0.02em | "Add your first device" | +| Value | 17 / 24 | 500 | −0.02em | Weekly usage on a card | +| Card title | 16 / 22 | 500 | −0.02em | Device name | +| Button | 16 / 22 | 500 (600 on accent, tint, red) | −0.015em | `.btn` (`.sm`: 15 px) | +| Input | 16 / 24 | 500 | −0.012em | Name fields (16 px stops iOS zoom) | +| Step title | 16 / 24 | 500 | −0.02em | "1 Get AmneziaVPN" | +| Row title | 15 / 22 | 500 | −0.02em | Accordion heads, notice title, month total | +| Breadcrumb | 15 / 22 | 400 (current 500) | −0.15px | Server › person | +| Question text | 15 / 21 | 400 | — | Remove / Reconnect body | +| Desc / sub / value line | 14 / 20 | 400 | — | Row descriptions, sheet subs, head values | +| Menu item, toast | 14 / 20 | 500 | — | ⋯ menu, toast | +| Meta | 13 / 18 | 400 | — | Card status, usage label, hints, "how to" paths, limit note | +| Pill label | 13 | 600 | — | Update pill, Demo chip | +| Small label | 12 / 16 | 500 | — | Kind labels, badge top line, reach tile sub, "Copy…" labels | +| Divider | 12 | 500 | +0.06em | "OR" (the only positive tracking) | +| Axis | 11 (10 for hours) | 500 | — | Month and hours axes | +| Calendar head | 9 / 10 | 600 | — | Weekday initials | +| Mono link | 13 | 400 | 0 | Link rows, name chips | +| Mono code | 12 / 18 | 400 | 0 | `.conf` view; the file card icon is mono 10 / 600 | + +### Rules + +- **Tracking tightens as size grows:** −0.011em for body, −0.02em at 15–17 px, −0.025em to −0.045em for titles and numbers. Mono is always `0`. +- **Only 400, 500 and 600.** 500 marks a title or a value, 600 marks a filled button, a number on display, a pill or a step number. +- **Numbers that change use `.num`** (`tabular-nums`), so a morph or a hover readout never shifts its neighbours. +- **Mono is for things typed or copied by hand:** addresses, links, hostnames, the configuration. Names stay in Geist. +- **One line where it fits:** names, statuses, crumbs and link rows end in an ellipsis. The full text goes in `title`. +- `text-wrap: balance` for short centred paragraphs (first device, "gone" card, secure sheet). `pretty` for left-aligned question text. +- **No uppercase** except the "OR" divider. **No ellipsis on buttons**: "Remove", never "Remove…". "…" appears only for progress and truncation. The single exception is another app's own menu label quoted verbatim ("Import Tunnel(s) from File…"). +- Russian runs 20–30% longer. Every new string is checked at 375 px in Russian (`rules/i18n.md`). + +--- + +## Layout + +### Page frame + +- `.page`: `max-width: 1072px`, centred. The side gutter is `max(16px, safe-area)`. The top is `40px + safe-area-top` and the bottom `112px`, so the end of the scroll clears the bottom fade. +- No navbar. The page opens with a **breadcrumb row**: 32 px high and 32 px above the content. The Dawnline mark sits in a 32 px box (logo 24 px), then `server › person`, then on the right the language pill and the QR knob. Without a server name the place reads "Dawnline". The browser tab title is the place too. +- **Edge fades** sit above the page and under every overlay: + - **top:** 80 px plus the safe area, a `bg → 75% → 0` gradient with `backdrop-filter: blur(12px)`, masked `1 → .88 @44% → 0`. It shows only once `scrollY > 2`, so the breadcrumb at rest stays crisp. + - **bottom:** 96 px, a plain `bg → transparent` gradient interpolated `in oklab`. + +### Columns and order + +| Width | Layout | +|---|---| +| < 560 | One column. **"Your access" first** (`order: -1`), then "Your devices". Device grid in one column. | +| 560–959 | One column, device grid in two columns (`gap 10`). | +| ≥ 960 | Two columns: devices on the left (fluid), access on the right (`384px`, `position: sticky; top: 84px + safe-area`). Column gap 36 (40 when stacked). | + +Other breakpoints and container queries: + +| Condition | Effect | +|---|---| +| `≤ 380px` | A code row stacks (code above its words) | +| `≤ 440px` | The scan line puts the menu path under its label for every app | +| `≥ 760px` | The sheet becomes a centred dialog (below that, a bottom drawer) | +| `@container (≤ 300px)` on the app picker | Items shrink to 44 px, padding 12 | +| `@container (≤ 330px)` on kinds | Tiles 50 px high, labels 11.5 px | + +### Single card mode + +When there is nothing else to show (access paused, the link stopped working, the page could not load), the page becomes **one card in the middle of the screen** with the breadcrumb above it. + +- **The card:** `.gone`, radius 36, padding `32 24 28`, a 56 px glass icon, a 22 px title and a balanced line of text. +- **The breadcrumb:** centred on its words, with the mark hanging to their left. It is nudged right by 12 px so mark and words read as centred together. +- **What it drops:** the language and QR controls. + +### Spacing rhythm + +There is no strict 4/8 grid. The values in use are `2 3 4 5 6 8 10 12 14 16 18 20 22 24 28 32 36 40`. The common pairs: + +- card padding **8**, with the inner block radius = card radius − 8; +- grid gap **10**, and the gap of an open accordion row **10**; +- tile gaps **8**; +- sheet padding **24**; +- section head padding `0 4 12`; +- notice below **22**; +- step spacing **20**, with 10 inside a step. + +### Stacking + +| Layer | z-index | +|---|---| +| Page | auto | +| Edge fades | 30 | +| Sheet root (scrim + sheet) | 50 | +| ⋯ menu | 60 | +| Toasts | 70 | +| Inside the sheet: ×, pinned keys | 3; their tooltip 4 | + +`html { scrollbar-gutter: stable }` and `body.locked { overflow: hidden }` keep the page from shifting sideways when a sheet locks the scroll. + +--- + +## Elevation & Depth + +- **Resting surfaces have no shadow.** Depth comes from the brightness ladder alone, so cards, rows, tiles and fields are all flat. +- **Floating layers get one shadow each:** + - `--pop-shadow`: dark `0 18px 48px -14px rgba(0,0,0,.75)`, light `0 18px 44px -14px rgba(0,0,0,.2)`. Used on the ⋯ menu (plus `inset 0 0 0 1px var(--line)`), the toast and the tooltip (plus `0 0 0 1px var(--line-glass)`). + - `--sheet-shadow`: dark `0 24px 64px -16px rgba(0,0,0,.6)`, light `… -18px rgba(0,0,0,.22)`. Used on the sheet. +- **Scrim:** 80% (dark) or 62% (light) plus an 8 px backdrop blur. The page behind a sheet is out of focus, not just darker. +- **Inset rings replace borders.** Every ring is `box-shadow: inset 0 0 0 Npx`: + - focus: 1.5 px, `text` at 16%; + - picked kind: 1.5 px accent; + - this device: 1 px, accent at 32%; + - notice tone: 1 px, tone at 22%; + - the arrival flash: 1.5 px `--ok`, fading. +- **Inset context.** Inside the sheet, accordion rows use `--field` (`.acc.inset`), one step above the sheet's `--raised`. Segmented controls inside them step up again (`knob 65% + field`). +- **Glass icons** are the only "material" effect: a frosted pane over a 1.5 px Gaussian-blurred copy of the tinted back shape, with a rim stroke. Keep it to icons. + +--- + +## Shapes + +### Radius scale + +| Radius | Where | +|---|---| +| 36 | Sheet, "gone" card | +| 28 | Device card (and the add / first cards) | +| 24 | Notice, big QR | +| 22 | Dense QR | +| 20 | Accordion row (open, and the shared ends of closed rows), usage block, ⋯ menu, the way | +| 18 | Badge, QR in a row, file card | +| 16 | Field, segmented track, reach tile, "until" and "hours" blocks; the pinned keys' outer corners | +| 14 | Kind tile, link row, menu item and highlight, `.conf` block | +| 12 | Go button, segmented pill | +| 11 | Ends of the way | +| 10 | Name chip, badge icon tile, link row knobs | +| 9 | File card icon | +| 6 | Inner corners of the joined pinned keys | +| 2.5–4 | Chart bars (2.5 month, 3 spark, 3 calendar cells), meter and hours bar | +| 999 / 50% | Buttons, pills, chips, toasts, tooltips / knobs, step numbers, reach marks | + +### Shape rules + +- **Nesting:** inner radius = outer radius − padding. Card 28 − 8 = usage 20. Field 16 − 4 = go button 12. Segmented track 16 − 4 = pill 12. +- **Closed accordion rows touch and share rounded ends.** Only the first row's top and the last row's bottom are round. An open row lifts out with 10 px gaps and gets all four corners, and so do its neighbours' facing corners. +- **Joined key pairs** (Download | Copy beside ×): `16 6 6 16` and `6 16 16 6`, with a 2 px gap. +- **Line icons:** 24 viewBox, `stroke-width 1.8`, round caps and joins, `currentColor`. Shown at 14, 16, 18 or 20 px. +- **Glass icons:** 24 viewBox drawn at 22 (rows), 24, 26 (kinds), 28 (reach), 30 (demo rows), 32 (cards), 36 (notices, add), 44 (first), 56 (gone) and 64 (questions). +- **QR codes:** round dots (r 0.42, 0.48 when dense), eyes drawn whole as rounded squares (2.6 / 1.8 / 1.5), and the Dawnline mark in a rounded tile at the centre (dense codes have none). Light dots on `#0a0a0a` in dark, dark dots on white in light. +- **The mark:** a sun dome over a horizon bar, one colour, `fill: var(--text)`: white on dark, black on light, never the accent. Clipped above the bar so the sun can rise from behind it. + +--- + +## Components + +Measurements are CSS pixels, read live at 1138 px and 375 px. Source files are under `web/src/portal/`. + +### Breadcrumb · `page/frame.ts` + +- **Layout:** a 32 px row with `gap 10`. The mark box is 32 × 32 (logo 24). The path is 15/22 `text-2` with `gap 6` and a 14 px chevron; the current crumb is `text` 500 with `aria-current="page"`. +- **Language pill** (`.cr-lang`): 32 high, pill, `knob` fill, 14 px 500 language code plus a 14 px chevron that points down and turns up while its menu is open. +- **QR knob** (`.cr-qr`): opens "Open on another device". +- **Truncation:** the crumbs truncate independently. At 375 px with the demo chip they become "Dawnlin… › U…". See *Live audit*. + +### Knob · `styles/controls.css` + +- 32 px circle, `knob` fill, 16 px icon. +- Hover: +6% text. `aria-expanded` or open: +10%. Press: `scale(.8)`. +- Variants: + - `.back`: chevron rotated 180°; + - in link rows: 36 px, radius 10, transparent until hover. + +### Buttons · `.btn` + +| Variant | Fill / text | Weight | Use | +|---|---|---|---| +| `accent` | accent / white | 600 | The one primary action: Add this device, Reconnect, Open securely, Download (router) | +| `tint` | accent 13% / accent | 600 | A card's **Connect** (quiet primary) | +| `soft` | knob / text | 500 | Cancel, "Add it from the device", Show key, Copy, Start over | +| `red` | bad / white | 600 | Remove | + +- **Size:** 48 high (`.sm` 40, 15 px), pill, padding 0 20 (`.sm` 0 16), gap 8, `.block` = full width. +- **Press:** `scale(.95)`. No ellipsis, no blue text links for actions. +- **Busy:** the button keeps its size. Its content blurs away and the **orb** comes up through the blur in the button's own colour. See *Motion → Busy orb*. + +### Field and go button · `.field`, `.go` + +- **Field:** 48 high, radius 16, `field` fill, padding `0 4 0 16`. The input is 16/24 500 and the placeholder `text-3`. Focus: inset 1.5 px ring at text 16%. +- **Go button:** 48 × 40, radius 12, at the field's end. Idle: `knob` / `text-3`, `cursor: not-allowed`. Ready: accent / white. Press `.9`. +- Arrow for create, check for save. The field and its go button are the whole form: no label row, no separate Save. + +### Notice · `page/notices.ts` + +- **Layout:** radius 24, padding `14 18 14 14`, gap 14, a 36 px glass icon, a 15/22 500 title and a 14/20 `text-2` line that adds to the title and never repeats it. +- **Tones:** `warn` (orange) for paused, outside hours, server off, no server and ends soon. `bad` (red) for out of data and access ended. +- **Placement:** one per page, above the columns, 22 px above them. Paused is not a notice: the whole page becomes the single card. + +### Section head + +- 20/28 500 title with a `text-3` 14 px 500 aside at the baseline: "3 of 4" in the page's numerals, `warn` when the admin let the person go over the limit. +- Under the grid sits a `note-s` (13/18 `text-3`) for "You have reached your limit of N devices. Remove one to add another." + +### Device card · `page/devices.ts` + +**Anatomy:** + +- Card: `raised`, radius 28, padding 8, gap 8. +- Top row (padding `8 6 6 10`, gap 12): a 32 px glass icon (blue on "this device", else grey), the name (16/22 500, one line), the status (13/18, one line, full wording in `title`), and the ⋯ knob. +- Bottom, one of three: + - **Usage** (`field`, radius 20, padding `12 14 12 16`, min-height 66): "Last 7 days" 13/18 `text-2` over the total 17/24 500 tabular. Spark of 7 bars at the right: 6 px wide, gap 4, ≤ 34 px high, min 3, radius 3, `--bar`, today in accent. Hovering a bar puts that day's name and bytes in place of the label and total instantly, with no morph. + - **Update pill** (instead of the spark) when the settings changed: 32 high, warn 14%, 13 px 600, refresh icon 14. + - **Connect** when never set up: a `tint` block button with the QR icon. It disappears when the admin locked the person. + +**Order:** "this device" first, then online, then seen, then never set up, then disabled (`byDeviceState`). The grid keeps cards in place across repaints and glides them (FLIP). + +**Status line (the full matrix):** + +| Condition | Text | Colour | +|---|---|---| +| Page opened through this device's tunnel | This device | accent (and the card gets the accent ring, the icon turns blue) | +| Disabled by the admin | Disabled | text-2, card at 50% opacity | +| Settings changed and it has connected before | Settings changed | warn (+ Update pill) | +| Online while out of data | Connected, no data left | warn | +| Online outside the hours | Connected, outside your hours | warn | +| Online | Connected | ok | +| Never connected | Not set up yet | warn (+ Connect) | +| Otherwise | Last connected 3 h ago (exact time in `title`) | text-2 | + +**Menu items** (⋯): + +- **Copy IP address** and **Copy local address**, only where the home network can reach the device; +- a separator; +- **Rename**; +- **Reconnect** (warn tone); +- **Remove** (bad tone). + +A disabled device has no Rename, Reconnect or Remove. A locked page has no ⋯ at all. + +**Add card:** a `button.dev.add`, min-height 144, centred, grey glass plus 36 and "Add device" in `text-2` 500. Hover raised + knob 45%, press `.98`. Gone when no slot is free or the page is locked. + +**First card** (no devices yet): + +- spans the grid, padding `28 24 24`; +- blue glass plus 44, "Add your first device" 18/24 500; +- one balanced 14/20 line (max 34ch); +- an accent block button, max 320: "Add this phone" on mobile, "Add this device" otherwise. + +### Accordion · `ui/accordion.ts` + +- **Row:** `raised`, padding `0 8`. Head 52 high, gap 10, with a 22 px glass icon, a 15/22 500 title (ellipsis), an optional chip, an optional value at the end (14 px `text-2`) and a 16 px chevron (pointing down, rotated 90°, and up when open). +- **Body:** padding `0 8 16 40` (inset rows `0 8 16 8`), column, gap 12. +- **One row open at a time.** A **still** row (nothing to open) has no chevron, no hover and no click. +- **`valHide`:** a row whose body shows the same numbers drops its head value while open (blur, fade, slide 8 px right). +- **Inset variant** (inside the sheet): rows on `field`, hover field + knob 50%. + +### "Your access" rows · `page/access.ts` + +| Row | Head | Body | +|---|---|---| +| **What it reaches** (shield, home or globe glass) | "Home network + Internet" / "Internet" / "Home network" | Two **reach tiles** (radius 16, `field`, padding `12 12 12 14`, glass 28, title 14/20 500, sub 12/16; a 20 px round mark at the top right: ok-soft check or knob minus, the tile dimmed when off). Then a sentence with the hostname pattern in mono, and **name chips** (32 high, radius 10, mono 13, the domain part in `text-3`, a copy icon 14; a click copies). | +| **Data this month** (chart glass; "Data used" for a total limit) | A 16 px **ring** (track `--bar`, arc accent, warn ≥ 90%, bad ≥ 100%) and "38.6 GB / 100 GB" or "· no limit"; hidden while open | The **month**: one bar per day (flex, gap 3, 64 high, radius 2.5, min 3; days to come at 45% bar; today accent), an axis 11 px `text-3` with "Today" in accent under its bar (the month's ends hide when it comes close), the total line ("38.6 GB used" / "61.4 GB left", `bad` when out), a 6 px **meter** (same tone thresholds), and a `.desc` about the reset. Hovering a bar puts "X on 13 Oct" in place of the total instantly. | +| **Access until** (calendar glass) | "30 Nov" plus "42 days" in ok, warn when soon, or "ended" in bad | The **until block** (`field`, radius 16, padding `14 16`): the days left as a 36/40 600 number (warn when soon), "days left", "Ends Mon 30 Nov" in `text-3`, and a **calendar** of the weeks to the end. 7 columns of 10 px cells with gap 5 and radius 3: past at text 5%, left at text 16%, today in accent, the last day ringed 1.5 px accent; warn colours when soon. Under it the **hours bar** when set: 8 px track, the allowed window in ok 70%, a 2 × 16 "now" marker (`text`, warn when outside, with a 2 px field ring), and axis 00/06/12/18/24 at 10 px. Without an end date and hours, the row is still. | + +The data row is open by default. A repaint keeps whichever row was open. + +### Sheet · `ui/sheet.ts` + +**Shape:** `raised`, radius 36, `--sheet-shadow`, `overflow: hidden`. + +| Width | Form | +|---|---| +| < 760 | **Drawer** floating 16 px from the left, right and bottom edges (plus safe areas), max-width 400, max-height `100% − 32 − safe areas` | +| ≥ 760 | **Dialog** centred by flex layout (not a transform, so text stays on the pixel grid), width `100% − gutters`, max-width 400 | + +**Width plan.** On a computer the sheet widens for a dense QR code (an AmneziaVPN key) until the code gets about **3.2 px per module** (+80 px padding), capped by the viewport. Live: 400 → 448 for a key, 400 → 410–422 for a `.conf`. It then scrolls the code fully into view. + +**Inside:** + +- **×:** a knob pinned at top 22 / right 22. +- **Pinned keys:** a view's own buttons, pinned at top 22 / right 58. +- **View:** padding `0 24 24`. +- **View head** (`.vhead`): 76 high. Title 20/28 500, centred with a Back knob inside a flow. The head is the drag handle, with `touch-action: none` and a grab cursor. +- **Sub line:** 14/20 `text-2`, pulled up 16 px under the head. + +**Behaviour:** + +- **Views stack.** `go()` pushes and `back()` pops. The sheet glides to each view's height. +- **Closes by:** ×, the scrim, Escape (instant), the phone's back button (the sheet is a history entry), or a pull down on its head. Focus returns to the opener. +- **Labels:** `role="dialog"` named by the view title, or `alertdialog` for questions. + +**Pinned keys** (`.hpill`, a phone or tablet set up from elsewhere): Download and Copy for the picked app's config, each 38 × 32, joined. + +- **Tooltip:** one 26 px pill in toast colours under the keys. It appears after 420 ms of hover, then follows the pointer from key to key at once, and says "Copied" after a copy. +- **On arrival:** when the device connects, × and the keys step away (`.arrived`). + +**Question view** (`.ask`: Reconnect, Remove): + +- left-aligned, as iOS asks now, with 24 px top padding; +- a 64 px glass icon in the action's tone, a 20/28 500 question and a 15/21 `text-2` paragraph; +- two equal buttons: **Cancel** (soft) and the action (accent for Reconnect, red for Remove); +- no × beside them. + +**Secure view** (plain HTTP): centred lock glass, "Open securely" (accent, a link to the HTTPS twin in the same tab), and an honest note about the router's own certificate. + +### ⋯ Menu · `ui/menu.ts` + +**Panel:** `position: fixed`, min-width 224, padding 6, radius 20, `field` fill, `--pop-shadow` plus an inner 1 px `--line`. + +**Items:** 40 high, radius 14, padding `0 12`, gap 12, 14 px 500, a 16 px icon in `text-2`. Tones: `warn` (Reconnect) and `bad` (Remove) colour both text and icon. Separators are a 1 px line with `6 12` margin, kept only between items. + +**Highlight:** one `knob` pill behind the items that **glides** after the pointer and takes the item's tone (`bad-soft`, `warn 13%`). + +**Options:** an option list (language) shows a check on the current item and keeps an invisible check on the others so the names line up. + +**Placement:** under its button, right-aligned, 8 px away, or above it where the screen ends. It grows out of the button's corner. + +**Closes on:** a press outside, scroll, Escape (instant), its button again, or another menu opening. + +### Toast · `ui/feedback.ts` + +- Bottom centre, `24px + safe-area` from the bottom, one at a time; a new one replaces the shown one. +- 42 high pill, padding `0 18 0 13`, 14 px 500, an 18 px icon (check in ok, alert in bad). +- 2.4 s on screen. Used for every result and every failure ("Renamed", "Device removed", "Address copied", an error message). + +### App picker · `ui/seg.ts` + +- **Track:** 48 high, radius 16, `field`, padding `0 4`. +- **Items:** icons only (20 px) at 56 px each. The picked item takes the remaining width (`flex-grow`) and shows its name. +- **Pill:** 40 px, radius 12. It stretches like skiper21's tabs: the leading edge reaches the new item first and the trailing edge follows. +- **Item colours:** idle `text-3`, hover `text-2`, picked `text`. +- **Apps by disguise:** AmneziaVPN and AmneziaWG, plus WireGuard only when the server's disguise is off. Routers never get AmneziaVPN. The last app picked per device is remembered in `localStorage`. + +### Kinds picker · `flows/add.ts` + +- **Tiles:** four in a grid (`--n` columns, gap 8): PC, Mobile (phones and tablets are one choice), Router, Other. Each is 56 high, radius 14, `field`. +- **Icons and labels:** a 26 px blue glass icon, greyscale at 55% opacity until picked. The label sits under the tile at 12/16 500. +- **Picked:** the tile gets an inset 1.5 px accent ring **in place**, without travelling between tiles. Hover → `knob`, press `.94`. +- **Defaults:** the kind and the name are guessed from the browser (iPhone, iPad, a Samsung model through Client Hints, Mac, Windows PC…), deduplicated with " 2", " 3". + +### Badge · `flows/setup-parts.ts` + +- 60 high, radius 18, `field`, padding `0 14 0 12`, gap 12. +- A 36 px icon tile, radius 10, **inverted** (`text` fill, `raised` mark). +- Two lines: top 12/16 `text-2`, main 15/20 500. +- A 16 px trailing mark: chevron for an action, "open" for a store page in a new tab. +- `.primary` (the one thing to tap in step 2): the icon tile is accent-soft / accent. +- `.badges2`: two side by side (Android's Google Play beside the APK), no trailing mark. + +### Set-up sheet · `flows/setup-view.ts` + +The layout follows where the page is open: + +| Layout | When | Content | +|---|---|---| +| `same` | The page is on the device being set up | "Not on the X right now?" inset accordion (opening it folds the steps away), then **1 Get ** (picker + store badge) and **2 Add the connection** (primary badge: a vpn:// link, the share sheet, a key to copy or a file to download, plus a "how to" path) | +| `away` | A phone or tablet set up from elsewhere | Inset accordion: "Open your link on the phone" (QR of the set-up link + link row) / "Already has the app" (picker + the connection as a QR + scan line), open by default; pinned Download / Copy keys | +| `pc-away` | A computer set up from elsewhere | "Open your link on the computer" / "Copy or save the connection" (picker + two small soft buttons) | +| `router` | A router | **1 Get AmneziaWG on the router** (OpenWrt packages badge), **2 Import the configuration** (file card with Download / Share, plus a "Configuration" inset row with Show key / Copy and the `.conf`, keys masked) | + +**Steps:** a 24 px round number (knob, 13 px 600), a 16/24 500 title and a body with gap 10. Steps sit 20 px apart. + +**"How to" path:** `Open AmneziaWG › + › Import Tunnel(s) from File…` in 13 px `text-2`, the app's own words in `text` 500, quoted verbatim from each app in each language. + +**Scan line:** "In WireGuard: + › Create from QR code". Where iOS and Android name a step differently, that word alternates every 3 s, with the or Android mark beside it. + +**The way** (waiting for the first connection), on top of every layout: + +- **Block:** `field`, radius 20, padding `12 14`. +- **Ends:** two 34 px rounded squares (radius 11): the device icon in `knob`, and the server in accent tint. +- **Track:** a dotted line between the ends (1.4 px dots every 9 px, `text-3` at 80%). +- **Waiting:** a light runs along the track and rests a beat. +- **Line under it:** "Waiting for the connection" (14/20 500). +- **On connection:** the track fills green from the device, the line morphs to " connected" in green, and the server end turns green last with a pop. +- **After 10 minutes:** the line reads "No connection yet" with a 13 px hint. + +### Code row, QR and link row · `ui/codes.ts` + +- **QR:** 148 px (radius 18) beside its words (gap 14). Big: 208 (radius 24). Dense: full width, square, radius 22, words under it. +- **Link row:** 44 high, radius 14, the URL in mono 13 without its scheme (ellipsis, `user-select: all`), then copy and, where the browser has it, share. +- A code that changes **cross-fades in place**: the new one comes in first, so the place is never empty. + +### File card and configuration + +- **File card:** `field`, radius 18, padding 12. A 38 × 46 "file" icon (radius 9, mono 10 600 ".conf"), the filename in mono 13, "For computers and routers" at 12 px, and an accent `sm` block button. +- **Configuration:** `pre` 12/18 mono, max-height 16 rem, scrolls. + - colours: section headers in accent, keys in `text`, values in `text-2`; + - **PrivateKey and PresharedKey are masked** (`••••` in `text-3`, letter-spaced 1 px) until "Show key". + +### Glass icon catalogue · `ui/glass.ts` + +`phone, mobile, tablet, computer, router, other, plus, globe, home, shield, chart, calendar, clock, pause, server, link, key, lock, check, trash, refresh, app (AmneziaVPN mark), file`. An unknown name falls back to `other`. + +### Demo-only pieces · `demo/` (not in the router build) + +- "Demo" chip after the crumbs (26 high, accent-soft, 13 px 600). +- GitHub pill before the language pill (hidden below 480 px; a button in the drawer instead). +- Scenario drawer: grouped rows on `field`, 2 px apart inside a radius-20 group, 60 px min, glass 30; the current row in accent with a check. + +--- + +## Do's and Don'ts + +**Do** + +- Build from the existing classes and tokens (`--bg … --knob`, `--text-2/3`, `.btn` variants, `.knob`, `.acc`, `.field`, `.badge`, `.seg`, glass icons). A new class uses the same tokens. +- Step surfaces up in brightness: a block inside `raised` is `field`, a control on `field` is `knob`. +- Keep the accent for the one primary action and for "you are here". Use tone colours only for their states. +- Say a state once, where it matters, in its colour. One notice per page. +- Put numbers in `.num`, hostnames and links in mono, and one-line names with `title`. +- Make every changing text go through `morphText`, and every appearing block through a blur-in (see *Motion*). +- Translate in the same change and check the Russian at 375 px. +- Respect the CSP: no `style=` attributes. Set styles through `el.style` and colours through classes. + +**Don't** + +- Add borders or dividers to separate surfaces (the "OR" divider and the menu separator are the only lines). +- Add shadows to resting cards, or more than one shadow to a floating layer. +- Use blue text links for actions. Use buttons and pills. +- Put an ellipsis on a button or menu item. +- Use the accent for decoration, or a new hue for anything. +- Animate with ad-hoc durations and curves. Use the springs and the two eases (see *Motion → Drift*). +- Animate in response to the keyboard (Escape), or rely on motion to convey a state. +- Use `--text-3` for text a person needs to read (see *Contrast*). + +--- + +## Motion Design + +### Philosophy + +Motion in the portal does three jobs: + +- **Continuity.** Things move from where they are to where they go: cards glide, sheets glide to their new height, letters slide. +- **Causality.** A response grows out of what caused it: a menu from its button, a dialog from its centre, a toast from below. +- **Calm feedback.** The orb shows waiting, the check shows a copy, the green way shows a connection. + +It never decorates, never loops without a reason (the only loops are the busy orb, the way's light and the OS alternation), and **never blinks**: nothing is torn down and redrawn in sight. + +Six rules hold everywhere: + +1. **Springs, not durations.** Layout motion runs on physical springs (stiffness, damping, mass 1), sampled into CSS `linear()`, so CSS transitions and script animations share one curve. +2. **Exits are quick, entrances are soft.** Exits use an ease-in curve and run 120–220 ms. Entrances use ease-out or a spring and run 280–572 ms. In a cross-fade the incoming part waits 60–110 ms so the two overlap in the blur. +3. **Blur is the transition medium.** Things appear and disappear through `filter: blur(2–6px)` with opacity and a small scale (`.86–.96`) or a few px of travel. Large travel is reserved for the drawer (`translateY(100% + 40px)`) and the FLIP of cards. +4. **Interruptible from the present.** Every new animation starts from the computed current state (`getComputedStyle`, a morph's live width, the pill's current edges) and cancels the old one only after the new one is in place. +5. **The keyboard never animates.** Escape closes menus and sheets instantly. +6. **Reduced motion keeps fades, drops travel.** See *Reduced motion*. + +### The engine · `motion.ts` + +```ts +spring(k, c, m = 1) // closed-form damped harmonic oscillator; under-, critically and over-damped branches + // duration = time until it stays within 0.15% of the end (sampled every 4 ms, ≤ 3 s) + // easing = CSS linear() with 65 points; at(ms) = progress for script-driven motion +publishSprings(root) // --spring-{bouncy,smooth,soft,quick} and --spring-*-dur on for CSS transitions +play(el, frames, o) // el.animate() with the reduced-motion policy +rubber(dist, dim) // (1 − 1 / (dist·0.55/dim + 1))·dim: resistance that grows with the pull +dismisses(dy, v, h) // a pulled sheet goes on a flick down (v > 0.4 px/ms) or past h/3; never on a flick back up (v < −0.1) +``` + +Animations from script go through `play()` (WAAPI). Hover and press states are CSS transitions. Loops and one-shots are CSS keyframes (`orb-converge`, `orb-breathe`, `way-run`, `way-pop`, `cal-in`). + +### Springs + +Computed from `spring()` and confirmed live: the published CSS variables read 572, 524, 476 and 296 ms. + +| Token | k / c | ζ | Settles | Overshoot | 50% at | 90% at | Peak at | Used for | +|---|---|---|---|---|---|---|---|---| +| **BOUNCY** | 300 / 20 | 0.58 | 572 ms | **10.8%** | 78 ms | 133 ms | 222 ms | Toast in, a newly created device card popping in, the way's server icon pop (via CSS var) | +| **POP** | 520 / 24 | 0.53 | 544 ms | **14.3%** | 58 ms | 96 ms | 162 ms | ⋯ menu open, check icon after copy, the OS mark turning in | +| **SOFT** | 380 / 28 | 0.72 | 476 ms | 3.9% | 74 ms | 138 ms | 232 ms | Accordion rows and chevron, dialog open (computer) and its scrim | +| **SMOOTH** | 300 / 35 | 1.01 | 524 ms | 0 | 98 ms | 228 ms | — | Widths and heights (morph width, sheet height glide, sheet width), FLIP of cards and letters, picker pill trailing edge, flex-grow, folds, tooltip glide, snap-back after a pull | +| **LEAD** | 520 / 46 | 1.01 | 396 ms | 0 | 74 ms | 173 ms | — | Leading edge of the stretching picker pill | +| **QUICK** | 900 / 60 | 1.00 | 296 ms | 0 | 56 ms | 130 ms | — | ⋯ menu highlight following the pointer | + +"Settles" is the whole curve, but the motion reads as done at the 90% mark. That is why a 572 ms BOUNCY toast feels like ~200 ms. + +### Curves and durations + +| Name | Value | Role | +|---|---|---| +| `EASE_OUT` (`--ease-out`) | `cubic-bezier(.23, 1, .32, 1)` | Entrances, hover and press transitions, folds of a finished step | +| `EASE_IN` | `cubic-bezier(.55, 0, 1, .45)` | Exits: menu, toast, dialog close, busy content out, ghosts | +| `DRAWER` | `cubic-bezier(.32, .72, 0, 1)` | The phone drawer, up 500 ms and down 420 ms (Vaul's curve) | +| ad hoc | `cubic-bezier(.2, 0, 0, 1)` | Sheet view swap and pinned keys (see *Drift*) | +| ad hoc | `cubic-bezier(.25, 1, .5, 1)` | Sheet height on a view swap, 360 ms (see *Drift*) | +| ad hoc | `cubic-bezier(0, 0, .58, 1)` | Accordion body fade-in, 300 ms | +| `ease-out` / `ease` keywords | — | Drawer scrim (420 in / 320 out), tooltip hide, arrival ring, hover background colours | + +The duration ladder in use is **120 · 140 · 150 · 160 · 180 · 200 · 220 · 240 · 260 · 280 · 300 · 320 · 340 · 360 · 380 · 400 · 420 · 500 · 520 · 700 · 900 · 1800 ms**, plus springs. Below 200 ms means feedback or exit, 200–400 ms means entrance or cross-fade, ≥ 500 ms means travel or a one-time moment. + +### Hover and press (CSS transitions) + +| Element | Press | Hover | Timing | +|---|---|---|---| +| `.knob` | `scale(.8)` | bg +6% text | 150 ms ease-out (transform), 150 ms (bg) | +| `.btn` | `scale(.95)` | accent 82% / tint 20% (active 24%) / soft +6% | 200 ms ease-out (transform, bg, colour) | +| `.go.ready` | `scale(.9)` | — | 200 ms ease-out | +| `.kind` tile | `scale(.94)` | `knob` | 200 ms (bg, transform), ring 220, icon colour 260 | +| `.badge`, `.dev.add` | `scale(.98)` | `knob` / raised+knob 45% | 200 ms | +| `.namechip` | `scale(.96)` | `knob` | 150 ms | +| `.upd-pill`, `.cr-lang`, `.hp-b`, demo chip / GitHub | `scale(.94)` | +6% / tone 22% | 150 ms | +| Accordion row | — | raised+knob 40% (inset: field+knob 50%) | 150 ms | +| Picker item | — | `text-3` → `text-2` | 200 ms colour | +| Spark / month bar | — | `--bar` → `text-2` (today: accent+text 25%) | 150 / 120 ms | +| Field | — | focus ring inset 1.5 px | 200 ms | +| Language chevron | — | rotates `90° → −90°` while open | 200 ms ease-out | + +### Catalogue: every animation, measured live + +Notation: + +- `in` and `out` are opacity transitions; +- `b4` means `filter: blur(4px)`; +- `s.9` means `scale(.9)`; +- `y10` means `translateY(10px)`; +- timings are `duration / delay`. + +#### 1. Page intro (first paint, once per visit) + +| What | From → to | Timing | +|---|---|---| +| Each block (crumbs, notice, section heads, each card, the limit note, each access row, the gone card), in DOM order | `opacity 0 → its own opacity, y10 → 0, b4 → 0` | 520 / 60 + 40·i, EASE_OUT, fill backwards | +| The sun of the logo | `translateY(7px) → 0`, clipped above the horizon bar: the sun rises | 900 / 150, EASE_OUT | + +A disabled card rises to its own 50%, not to 1. Live at 375 px, the wave ran from `crumbs @60` through `devices head @100`, the cards @140–260, `access head @300` and the access rows @340–420. See *Live audit #2*. + +#### 2. Repaint choreography (the page after a change) + +| What | Motion | Timing | +|---|---|---| +| Cards that stay but moved (FLIP) | `translate(Δx, Δy) → 0` (live: ±315 px sideways, (−315, 154) diagonally) | SMOOTH 524 | +| A device just created (`pop`) | `in, s.9 → 1, b6 → 0` | BOUNCY 572 | +| A card that newly shows (Add card after a removal, the first card) | `in (to own opacity), s.9, b6` | SMOOTH 524 / 60 | +| A device that just connected (`flash`) | `inset 1.5px var(--ok) → transparent` | 1800, ease-out | +| Changed texts on cards and access rows (`data-t` keys) | letter morph (see 3) | — | +| The count "3 of 4 → 4 of 4" | letter morph | — | +| Limit note appears | `in, y6 → 0, b4 → 0` | 420, EASE_OUT | +| Limit note leaves (a slot freed) | `out, b4`, then `hidden` | 200, EASE_IN | +| A removed card leaves (before the repaint) | `out, s.9, b6` | 220, EASE_IN, then the repaint glides the rest | + +#### 3. Text morph · `ui/morph.ts` + +Every text that changes in place while visible morphs. Hover readouts over chart bars are the deliberate exception and swap instantly. + +**Letter mode** (default): + +- **Kept letters slide.** The letters both texts share stay and slide to their new places (SMOOTH 524). They are the common prefix and suffix plus the longest common subsequence in between. +- **Old letters lift away:** `out, y −0.45em, b4`, 220 ms EASE_IN, stagger `min(12, 160/n)` ms. +- **New letters rise in:** `in, y +0.45em → 0, b4 → 0`, 380 ms EASE_OUT, delay `120 + i·min(22, 260/n)` ms. +- **Width glides** from the old text's width to the new one's on SMOOTH, so what follows never steps. The old letters are pinned to the edge that stays put: the start, the end of a right-aligned value, or the middle of a centred line. +- **Kerning correction:** each letter is nudged onto the plain text's kerned position, so the last frame lands exactly on the final text. +- **Done:** at the end the element holds plain text again, and an ellipsis box keeps its ellipsis. + +**Whole mode** (`whole: true`, for words in a flowing sentence, app names, menu paths): old words `out, b4` 180 ms EASE_IN, new words `in, b4 → 0` 280 / 60 EASE_OUT. + +**`morphInto(box, kids)`** refills a whole box without a blink: + +- unchanged pieces stay still; +- a piece with new words morphs where it stands (whole mode, up to 40 characters); +- a changed drawing blurs in (280 / 60); +- a piece that changed kind or height crosses: the old one is pinned where it stood and fades `b4` over 180 ms while the new one blurs in; +- pieces that only moved glide on SMOOTH. + +**Interrupting:** a morph under way ends where it was going (`finish`), and the width carries on from its on-screen width. No morph runs for reduced motion or for an element that is not on screen. + +Live examples: + +| Change | What ran | +|---|---| +| "iPhone 16" → "iPhone 16 Pro" | 4 letters rise at 120, 142, 164 and 186 ms | +| "Connected" → "Not set up yet" | 5 kept letters slide, the rest lift and rise | +| "Waiting for the connection" → "iPad Air connected" | 14 out at 11.4 ms steps, 11 in, width 168 → 156 px | +| Tooltip "Download …" → "Copy … config" | 19 kept letters slide ≈ 12–15 px | + +#### 4. Accordion + +| What | Motion | Timing | +|---|---|---| +| Every row whose shape changes | `height, margin-top/bottom, four radii` from the measured "before" to the "after" | SOFT 476 | +| Body of the opening row | `opacity 0 → 1, b2 → 0` | 300, `cubic-bezier(0,0,.58,1)` | +| Body of the closing row | `opacity 1 → 0, b2`, kept displayed (`.closing`) until the row finishes | 160, EASE_IN | +| Chevron | `rotate(90°) → rotate(−90°)` | SOFT 476 (CSS var) | +| Head value (`valHide`) | `out, b4, translateX(8px)` | 200 (opacity, blur), 260 (transform), EASE_OUT | +| Calendar cells when "Access until" opens | `cal-in`: `opacity 0, scale .4 → 1` | 360 / 7·i ms (49 cells ≈ 700 ms total), EASE_OUT | + +On open the neighbours' facing corners round at the same time, so the open row lifts out of the stack rather than splitting it. Inside the sheet the accordion plans the sheet's width first, so a dense code that comes into view gets its width on the same frame. + +#### 5. Sheet + +**Open and close:** + +| Context | Element | Motion | Timing | +|---|---|---|---| +| Computer (≥ 760) open | sheet | `in, s.9 → 1, b4 → 0` from its centre | SOFT 476 | +| | scrim | `in` | SOFT 476 | +| Computer close | sheet | `out, s.96, b3` into its centre | 120, EASE_IN | +| | scrim | `out` | 120, EASE_IN | +| Phone open | sheet | `translateY(calc(100% + 40px)) → 0` | 500, DRAWER | +| | scrim | `in` | 420, ease-out | +| Phone close | sheet | from its current transform → `translateY(100% + 40px)` | 420, DRAWER | +| | scrim | from its current opacity → 0 | 320, ease-out | +| Escape, or a link that stopped working | everything | gone at once | 0 | + +**View swap** (`go`, `back`, a new flow in an open sheet): + +| Element | Motion | Timing | +|---|---|---| +| Old view (pinned absolutely, inert) | `out, s.96, b2` | 200, `cubic-bezier(.2,0,0,1)` | +| New view | `in, s.96 → 1, b4 → 0` | 280 / 110, same curve | +| Viewport height | old → new (live: 297 → 830, 430 → 638) | 360, `cubic-bezier(.25,1,.5,1)` | +| Sheet width | 400 → 448 for a dense key | SMOOTH 524 | +| Pinned keys | old out `s.9, b3` 180; new in `s.9 → 1, b3 → 0` | 260 / 110 | +| Clicks on the new view | ignored for 320 ms, so a tap meant for the old button doesn't press the new one | — | + +**Content glide** (`glide()`, a pick that changes a view): + +- the viewport height glides on SMOOTH; +- every element that moved inside glides from its old place (outermost only) on SMOOTH; +- blocks named as changed blur in (280, EASE_OUT). + +**Pull to close** (phone, by the head): + +- downward drag follows the finger 1:1, and the scrim fades by `1 − dy/420`; +- upward drag resists by `rubber()`; +- release closes on a flick (> 0.4 px/ms) or past a third of the height. Live, a 250 px pull closed from scrim .40, and a fast 50 px flick closed from scrim .88. +- otherwise the sheet snaps back on SMOOTH. + +**Arrived** (`.arrived`) and question (`.asks`): × and the pinned keys go `out, b3, scale .9` over 240 ms EASE_OUT and stop taking clicks. + +#### 6. ⋯ Menu + +| What | Motion | Timing | +|---|---|---| +| Open | `in, s.9 → 1, b4 → 0`, origin at the button's corner (top right, or bottom right when above) | POP 544 | +| Close | `out, s.96, b3` | 120, EASE_IN | +| Highlight appears | opacity at the hovered item | 150, EASE_OUT | +| Highlight moves | `translateY` to the next item; colour to its tone | QUICK 296; bg 150 | +| Highlight leaves | opacity 0 when the pointer leaves the menu | 150 | + +QUICK replaced SMOOTH for the highlight because SMOOTH felt late: it reaches 90% at 130 ms against SMOOTH's 228 ms. + +#### 7. Toast + +| What | Motion | Timing | +|---|---|---| +| In | `in, translateY(18px) scale(.9) → 0, b6 → 0` | BOUNCY 572 | +| Dwell | — | 2400 ms | +| Out | `out, translateY(6px) scale(.96), b4` | 180, EASE_IN | +| Replaced by a new toast | `out, s.96, b4`, while the new one comes in over it | 140, EASE_IN | + +#### 8. Busy orb · `ui/busy.ts`, `controls.css` + +The orb is aicss.dev's **Orbs B4 Converge** at its 28 px stage, twice its speed, drawn in the button's own colour. + +| What | Motion | Timing | +|---|---|---| +| Click: content out | `out, s.86, b5` | 180, EASE_IN | +| Orb in | `in, s.6 → 1, b5 → 0` | 340 / 70, EASE_OUT | +| Minimum hold | a quick answer waits until the orb is fully in (`BUSY_IN` = 410 ms), so it never flickers | — | +| Answer: orb out / content back | mirror of the above, starting from where each stands | 180 / 340 + 70 | +| Orb loop: front dot (7 px) | walks a triangle (top → bottom right → bottom left). It rests 10% at each corner, leaves ease-in (`.55,0,1,.45`), arrives ease-out (`.33,1,.68,1`), and is `scale .72, blur .8` between corners. | 1.8 s, linear keyframe timeline | +| Orb loop: back dot | breathes in the centre: opacity .16 ↔ .32, blur 2.4 ↔ 1.6, scale 1.2 ↔ .98 | 1.8 s, ease-in-out | + +The orb starts on the click itself (a 250 ms "only if slow" delay was tried and rejected). The button stays disabled until the answer, which also guards against double submits. `contain: strict` keeps the loop off layout. + +#### 9. Copy feedback + +The control that copied says so for 1.6 s: + +- its icon swaps to a check (POP 544, from `s.6, b3`); +- its "Copy…" label morphs to "Copied" and back; +- a toast says what was copied; +- in the pinned keys, the tooltip glides and rewords to "Copied" (SMOOTH). + +#### 10. App picker stretch + +On a pick: + +- **Edges:** the pill's two edges are driven per frame by `spring.at(t)`. The leading edge (toward the new item) runs on LEAD (396 ms) and the trailing edge on SMOOTH (524 ms), so the pill stretches toward the target and then contracts. +- **Width shares:** items change `flex-grow` 0 ↔ 1 on SMOOTH. Shares of the track, not pixels, so they stay right while the sheet's width changes. +- **Labels:** the old label collapses (`max-width → 0, margin-left −8, out`, 220 ease-out) while the new one blurs in (280 / 70, EASE_OUT), always inside the pill. +- **What follows:** everything the pick changes `morphInto`s in place (step title, store badge, step 2, the code) and the sheet glides. + +#### 11. Kinds picker + +The ring does not travel: the old tile's ring fades and the new tile's ring draws in place (box-shadow 220 ms). The icon desaturates or saturates (260 ms) and the label colour changes (200 ms). The name field updates without motion while untouched. + +#### 12. Codes and words + +| What | Motion | Timing | +|---|---|---| +| A new QR in the same box | new `in` first (200, EASE_OUT); old laid over it goes `out` (220 / 110, EASE_IN) | the box is never empty | +| The same code for another app (WireGuard ↔ AmneziaWG take one file) | only the words change | — | +| Words beside a code | new `in, b3 → 0` 220 EASE_OUT; old `out, b3` 200 / 90 EASE_IN | — | +| Scan line, another app | app name and each path part morph whole; the OS mark grows or shrinks (`width 0 ↔ 1.05em`, `b3`) | SMOOTH; mark out 220 | +| Scan line, OS alternation (every 3000 ms while on screen) | the differing word letter-morphs; the old mark `out, scale .5 rotate −40°, b3` (200, EASE_IN); the new one turns in from `scale .5 rotate 40°` | POP 544 / 80 | + +#### 13. Waiting for the first connection · `flows/wait.ts` + +**While waiting:** the way's light (`way-run`) is a gradient band masked to the dots. It travels from −70% to +70% in the first 72% of a 2 s loop (`cubic-bezier(.45,0,.55,1)`) and rests for the last 28% (≈ 560 ms). Behind it, polls run every 5 s six times, then every 15 s six times, then every 30 s. They skip while the tab is hidden and stop at 10 minutes. + +**Arrival timeline**, measured live (t = 0 when the poll sees a fresh handshake): + +| t (ms) | What | +|---|---| +| 0 | The line morphs to " connected" (width glides on SMOOTH, letters lift and rise). Its colour turns green (300 ms). | +| 0 | × and the pinned keys step away (`out, b3, s.9`, 240 ms). The sheet scrolls to the top. | +| 0 → 200 | The light fades out (200 ms). | +| 80 → 780 | The green fills the dots from the device's end (`clip-path inset(0 100% 0 0) → inset(0)`, 700 / 80 ms, EASE_OUT). The device's end turns green (400 ms). | +| 600 → 1000 | The server's end turns green (400 / 600). Its icon pops (`way-pop`, scale .6 → 1, 420 / 600, on BOUNCY's curve). | +| 410 → 930 | Everything under the way folds shut: height → 0, `out, b4` (520 ms, EASE_OUT), and the way's bottom margin goes 18 → 0. | +| 410 → 2810 | **2.4 s of reading time.** Unchanged with reduced motion: it is not motion. | +| 2810 | The sheet closes (120 ms on a computer, 420 on a phone). | +| ≈ 2950 | The page repaints: the card glides to its new place (SMOOTH), its status morphs to "Connected", and its **green ring fades** over 1.8 s. | + +#### 14. Other moments + +| What | Motion | Timing | +|---|---|---| +| Add sheet, error under the field | `in, translateY(−4px) → 0`; a second error morphs its words | 220, EASE_OUT | +| "No connection yet" after 10 min | its line blurs in | 280, EASE_OUT | +| Show key | keys and masks come into focus: `b4, opacity .4 → none` | 320, EASE_OUT | +| Steps fold (same-device layout, the "Not on the X" row) | `height, opacity, blur(0 ↔ 4px)` | SMOOTH 524 | +| Top edge fade | opacity 0 ↔ 1 at `scrollY > 2` | 200 ms | +| Demo scenario switch | page `out, b4` 160 EASE_OUT → repaint → `in, y6, b4 → 0` 420 EASE_OUT | demo only | + +### Choreographies, end to end (live, demo latency ~0.5–0.75 s) + +**Rename:** + +- 0: busy (content out 180, orb in 70 + 340); +- +513: answer, sheet out 120, orb out; +- +645: repaint, the name letter-morphs; +- +650: "Renamed" toast (BOUNCY). + +**Reconnect:** + +- 0: busy; +- +720: answer. Under the sheet the cards FLIP (iPhone and MacBook swap places, ±315 px) and the status morphs to "Not set up yet"; +- +795: view swap to set-up. Old out 200, new in 280 / 110, height 297 → 830 (360), width 400 → 448 (SMOOTH), pinned keys in 260 / 110, × back (240), the light starts. + +**Add:** + +- 0: go button busy; +- +460: the new card pops (BOUNCY) under the sheet, the count morphs "3 of 4 → 4 of 4", the limit note rises (420); +- +509: view swap to set-up. + +**Remove:** + +- 0: busy; +- +750: answer, sheet out 120; +- +877: the card leaves (220, EASE_IN, `s.9, b6`); +- +1103: repaint. The neighbour glides (−315, 154), the Add card blurs in (SMOOTH / 60), the limit note fades (200), "Device removed" toast. + +### Reduced motion (`prefers-reduced-motion: reduce`) + +`play()` keeps only the opacity of an animation that fades, at ≤ 160 ms ease-out. An animation that only moves or resizes jumps to its end (0 ms). + +| Piece | Behaviour | +|---|---| +| Text morph, `morphInto` | Plain text swap, no letters | +| Picker pill | Jumps (uses SMOOTH and t = end) | +| Busy | No 410 ms hold; orb shown as a still frame (front dot sharp, halo behind) | +| Accordion chevron, calendar cascade, way light, way fill, server pop | Off (CSS `@media` blocks) | +| OS mark alternation | Marks swap instantly (the word still changes) | +| Sheets, menus, toasts | Fade only | +| Arrival reading time (2.4 s) | Unchanged | + +CSS hover and press transitions (`scale(.8–.98)`, colours) are not reduced. They are small, direct responses to input. + +### Performance notes + +- Animated properties are `transform`, `opacity` and `filter: blur` almost everywhere. Layout properties animate only where the layout must truly change: `height`, `width`, `max-width`, margins and radii (sheet height, accordion rows, morph width, folds), `flex-grow` (picker) and `clip-path` (way fill). +- Morphs skip elements that are not on screen. The OS alternation skips while folded. Polls pause in hidden tabs. +- Blur radii stay at ≤ 6 px; the edge fade's 12 px backdrop blur is the only large one. +- One animation per property per element at a time: new runs cancel old ones after starting from their computed state. + +### Motion do's and don'ts + +- **Do** use a spring token for anything that moves or resizes. Use EASE_IN for exits and EASE_OUT for blur-ins. +- **Do** make the entering part wait 60–110 ms in a cross-fade, and keep exits under 220 ms. +- **Do** start from the current computed state and cancel after. +- **Do** keep loops tied to a real wait: a request, a connection, an alternation the person reads. +- **Don't** animate Escape, a language change or a reload. +- **Don't** morph a hover readout: it follows the pointer and must be instant. +- **Don't** use `transition: all`, bounces on exits, or travel over ~20 px except the drawer and the FLIP. +- **Don't** re-run an entrance animation on a repaint the person didn't cause (see *Live audit #1*). + +--- + +## Content & Voice + +- **Short, plain and whole.** "Your devices can't connect until it's resumed." A sentence that adds to a title never repeats it. Full rules for strings and Russian: `rules/i18n.md`. +- **Buttons are verbs, with no ellipsis:** Connect, Update, Add device, Reconnect, Remove, Cancel, Open securely, Show key, Copy. +- **Statuses are short and fit one line.** The full wording goes in the tooltip: "Settings changed, update needed". +- **Other apps are quoted word for word, in each language:** "+ › Insert › Continue" for AmneziaVPN, "Import Tunnel(s) from File…" for WireGuard. +- **Honest warnings sit where the choice is made:** plain HTTP, the router's own certificate, connected but no data left. +- **Numbers, sizes and dates** follow the page's language (`num`, `bytes`, `toLocaleDateString(locale())`). Times are the router's clock, hours shown in the visitor's time when the offset is known. +- **The language pill switches in place.** The page opens in the kept choice, else the browser's language, else English. + +--- + +## Accessibility + +- **Focus:** `:focus-visible` draws a 2 px outline in accent at 65% with a 2 px offset. Mouse focus shows nothing. +- **Roles:** + - the sheet is `dialog`, or `alertdialog` for questions, with `aria-modal` and `aria-label` = the view's title; + - the menu is `menu` with `menuitem` or `menuitemradio` (`aria-checked`); + - the picker is a `tablist` of `tab`s (`aria-selected`); the kinds are a `radiogroup` of `radio`s (`aria-checked`); + - accordion heads are buttons with `aria-expanded`; + - the way is `role="status"` with `aria-live="polite"`; + - the menu path has its own `aria-label` naming both systems' words; + - busy buttons get `aria-busy`. +- **Keyboard:** Escape closes the menu, then the sheet, without animation. The phone's back button closes the sheet. Focus returns to the opener. The rename field selects its text on open. +- **Hidden decoration:** icons and glass icons are `aria-hidden`. Morph overlays and ghosts are `aria-hidden` and click-through. An icon-only button has an `aria-label`. +- **Contrast:** see the table in *Colors*. `--text-3` and white-on-accent are below AA. +- **Targets:** buttons and fields are 48 px, menu items 40 px. Knobs and pills are 32 px, the pinned keys 38 × 32 and calendar cells 10 px (not interactive). The 32 px controls are below the 44 px touch guideline. + +--- + +## Live audit: findings (2026-10-20) + +These are observations from the code read and the live run, not changes. Each is cheap to confirm in the demo. + +### Motion + +1. **The calendar replays on every repaint.** While "Access until" is open, every repaint re-runs `cal-in` on all 49 cells (≈ 700 ms). That includes a Rename, a Reconnect (under the scrim), a device that connects, and a scenario switch. The cells are rebuilt and the CSS rule `.acc-row.open .cal-g i { animation: cal-in … }` fires again. This breaks "nothing blinks". Animate the cells only from the accordion's toggle, or skip when the row was already open. +2. **The phone intro runs out of visual order.** At < 960 px "Your access" is shown first (`order: -1`), but the intro staggers in DOM order. The wave goes crumbs → devices (below) → back up to access. Sort the intro list by on-screen position. +3. **"Show key" ↔ "Hide key" swaps instantly** (`replaceChildren`), against the rule that every in-place text morphs. Same for its icon. +4. **The sheet uses two height animations.** A view swap glides height over 360 ms `cubic-bezier(.25,1,.5,1)` with `cubic-bezier(.2,0,0,1)` cross-fades and pinned keys. In-view changes use SMOOTH (524 ms). Moving the swap onto the spring tokens would make the sheet move the same way however its content changes. +5. **`way-pop` uses BOUNCY's curve over 420 ms** instead of BOUNCY's own 572 ms. The spring is compressed and its 10.8% overshoot comes faster than the token's. +6. **The drawer scrim uses CSS keywords** (`ease-out` 420 / 320) where the dialog's scrim uses SOFT and EASE_IN. Harmless, but it sits outside the token set. +7. **Comments drift from the code.** + - `motion.ts` says BOUNCY is "the accordion", and `accordion.css` and `accordion.ts` call it "bouncy". The accordion runs on SOFT (476 ms, 3.9%), on purpose since 2026-10-19. + - `docs/plan-portal-redesign.md` says "one bottom drawer at every width" and "four kinds with a sliding ring". Live, the sheet is a centred dialog from 760 px, and the ring does not travel. +8. **The language switch is a hard cut.** The whole page is rebuilt with no fade. It is consistent with "nothing animates that the person can't follow", but it is the only visible change without a transition. + +### Visual and accessibility + +9. **White on accent** (every primary button) is 2.4:1 in dark and 2.9:1 in light. It is below AA even for large text. It is the measured skiper21 look, so it is a decision for the user. Options: a deeper accent fill with the same hue (e.g. `#1d84e6`, the glass tone b) or dark ink on the light fill. +10. **`--text-3` carries meaningful text** at 2.2–2.4:1: the limit note ("You have reached your limit…"), "3 of 4", "Ends Mon 30 Nov", axis dates and the "OR" divider. The limit note and the end date carry information and could move to `--text-2`. +11. **Light theme tone text is thin.** Status lines at 13 px in ok, warn or accent are 3.1–3.3:1 on white. Accent text links in hints are 2.9:1. +12. **`--t-orange` has no light override.** The light block redefines the grey, blue, green and red glass tones, but not orange. Orange glass icons keep their dark-theme stops in light. +13. **Breadcrumb at 375 px:** with the demo chip, both crumbs truncate to "Dawnlin… › U…". The router build has no chip, but a long server name will do the same. Consider letting the person's crumb win (`flex-shrink` on the place first). +14. **Quota tone mismatch:** the "Out of data" notice is red (`bad`) while the cards say "Connected, no data left" in orange (`warn`). Intended (the tunnel is up), but the page shows two tones for one state. +15. **"How to" paths wrap with the separator first:** a wrapped line starts with "›" ("› Pick the file and connect"). +16. **The `.conf` block has no edge inside its inset row:** both are `--field`. In light especially, the code floats without a container. +17. **The trash glass icon reads as "pause"** at small sizes: two vertical strokes in a rounded body. The lid separates it at 64 px only. + +--- + +## Source map + +| Area | Files | +|---|---| +| Tokens, fonts, light theme | `web/src/portal/styles/tokens.css` | +| Reset, type, focus, selection, icons | `styles/base.css` | +| Knob, buttons, orb, field, picker, kinds, badges, hints, link row, QR | `styles/controls.css` | +| Page frame, edge fades, crumbs, columns, notices, single card | `styles/page.css`, `page/frame.ts`, `page/notices.ts` | +| Device cards | `styles/devices.css`, `page/devices.ts` | +| Access rows | `styles/access.css`, `page/access.ts`, `days.ts` | +| Accordion | `styles/accordion.css`, `ui/accordion.ts` | +| Sheet, views, questions | `styles/sheet.css`, `ui/sheet.ts`, `flows/device-actions.ts`, `flows/secure.ts` | +| Set-up | `styles/setup.css`, `flows/setup-view.ts`, `flows/setup-parts.ts`, `flows/wait.ts`, `setup.ts` | +| Menu, toast | `styles/menu-toast.css`, `ui/menu.ts`, `ui/feedback.ts` | +| Motion engine | `motion.ts`; morph `ui/morph.ts` + `styles/morph.css`; busy `ui/busy.ts`; picker `ui/seg.ts` | +| Glass icons, line icons, QR | `ui/glass.ts`, `web/src/shared/icons.ts`, `web/src/shared/qr.ts`, `ui/codes.ts` | +| Demo | `web/src/portal/demo/*` (deployed to dawnline-demo.vercel.app) | +| Rules | `rules/ui-design.md`, `rules/frontend.md`, `rules/i18n.md` | + +### Measuring motion live + +Paste this into the console of the demo (or the portal) before interacting, then read `__dump()`. Springs show by name because each has a unique duration. + +```js +const N = {572:'BOUNCY',524:'SMOOTH',476:'SOFT',296:'QUICK',544:'POP',396:'LEAD'}, L = (window.__log = []); +const d = (e) => e.tagName.toLowerCase() + '.' + String(e.className?.baseVal ?? e.className).trim().replace(/\s+/g, '.'); +const ez = (e, t) => (e?.startsWith('linear(') ? N[t] ?? 'spring' : e ?? 'linear'); +const A = Element.prototype.animate; +Element.prototype.animate = function (f, o) { + L.push([d(this), o?.duration, o?.delay ?? 0, ez(o?.easing, o?.duration), JSON.stringify(f).slice(0, 160)].join(' | ')); + return A.call(this, f, o); +}; +addEventListener('transitionrun', (e) => L.push(['css', d(e.target), e.propertyName].join(' | ')), true); +addEventListener('animationstart', (e) => L.push(['kf', d(e.target), e.animationName].join(' | ')), true); +window.__dump = () => L.splice(0).join('\n'); +``` diff --git a/README.md b/README.md index d7e897e..ac7e225 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ follows a modern design.

🏠 Internet like a home device

-

People's devices go online the way the devices at home do, so your proxies, ad and DNS filters cover them too.

+

Turn it on and people's devices go online the way the devices at home do, so your proxies, ad and DNS filters cover them too. Off by default: it costs speed.

🗺️ Overview and places

diff --git a/README_ru.md b/README_ru.md index 33cfbc0..d41259e 100644 --- a/README_ru.md +++ b/README_ru.md @@ -110,7 +110,7 @@ Dawnline запускает сервер [AmneziaWG] на вашем роуте

🏠 Интернет как у домашних устройств

-

Устройства людей выходят в интернет так же, как домашние, поэтому ваши прокси, фильтры рекламы и DNS работают и для них.

+

Включите, и устройства людей выйдут в интернет так же, как домашние: ваши прокси, фильтры рекламы и DNS сработают и для них. По умолчанию выключено: это стоит скорости.

🗺️ Обзор и места

diff --git a/package/luci-app-dawnline/Makefile b/package/luci-app-dawnline/Makefile index 7049dcb..1751bdb 100644 --- a/package/luci-app-dawnline/Makefile +++ b/package/luci-app-dawnline/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-dawnline -PKG_VERSION:=0.12.1 +PKG_VERSION:=0.13.0 PKG_RELEASE:=1 PKG_LICENSE:=MIT # po//dawnline.po becomes luci-i18n-dawnline- (luci.mk), released diff --git a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js index 8b78eb2..7b88991 100644 --- a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js +++ b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js @@ -5,27 +5,27 @@ 'require poll'; 'require rpc'; 'require ui'; -var Ha=Object.create;var Go=Object.defineProperty;var za=Object.getOwnPropertyDescriptor;var Ra=Object.getOwnPropertyNames;var Ia=Object.getPrototypeOf,Ba=Object.prototype.hasOwnProperty;var Oa=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var ja=(n,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ra(e))!Ba.call(n,r)&&r!==o&&Go(n,r,{get:()=>e[r],enumerable:!(s=za(e,r))||s.enumerable});return n};var Ua=(n,e,o)=>(o=n!=null?Ha(Ia(n)):{},ja(e||!n||!n.__esModule?Go(o,"default",{value:n,enumerable:!0}):o,n));var os=Oa((ts,ns)=>{"use strict";var es=(function(){var n=function(S,$){var b=236,C=17,y=S,z=o[$],k=null,f=0,x=null,T=[],I={},V=function(R,O){f=y*4+17,k=(function(P){for(var U=new Array(P),D=0;D=7&&ne(R),x==null&&(x=Y(y,z,T)),oe(x,O)},J=function(R,O){for(var P=-1;P<=7;P+=1)if(!(R+P<=-1||f<=R+P))for(var U=-1;U<=7;U+=1)O+U<=-1||f<=O+U||(0<=P&&P<=6&&(U==0||U==6)||0<=U&&U<=6&&(P==0||P==6)||2<=P&&P<=4&&2<=U&&U<=4?k[R+P][O+U]=!0:k[R+P][O+U]=!1)},te=function(){for(var R=0,O=0,P=0;P<8;P+=1){V(!0,P);var U=r.getLostPoint(I);(P==0||R>U)&&(R=U,O=P)}return O},B=function(){for(var R=8;R>P&1)==1;k[Math.floor(P/3)][P%3+f-8-3]=U}for(var P=0;P<18;P+=1){var U=!R&&(O>>P&1)==1;k[P%3+f-8-3][Math.floor(P/3)]=U}},fe=function(R,O){for(var P=z<<3|O,U=r.getBCHTypeInfo(P),D=0;D<15;D+=1){var G=!R&&(U>>D&1)==1;D<6?k[D][8]=G:D<8?k[D+1][8]=G:k[f-15+D][8]=G}for(var D=0;D<15;D+=1){var G=!R&&(U>>D&1)==1;D<8?k[8][f-D-1]=G:D<9?k[8][15-D-1+1]=G:k[8][15-D-1]=G}k[f-8][8]=!R},oe=function(R,O){for(var P=-1,U=f-1,D=7,G=0,ee=r.getMaskFunction(O),X=f-1;X>0;X-=2)for(X==6&&(X-=1);;){for(var be=0;be<2;be+=1)if(k[U][X-be]==null){var Le=!1;G>>D&1)==1);var re=ee(U,X-be);re&&(Le=!Le),k[U][X-be]=Le,D-=1,D==-1&&(G+=1,D=7)}if(U+=P,U<0||f<=U){U-=P,P=-P;break}}},j=function(R,O){for(var P=0,U=0,D=0,G=new Array(O.length),ee=new Array(O.length),X=0;X=0?jo.getAt(Uo):0}}for(var Wo=0,re=0;reX*8)throw"code length overflow. ("+D.getLengthInBits()+">"+X*8+")";for(D.getLengthInBits()+4<=X*8&&D.put(0,4);D.getLengthInBits()%8!=0;)D.putBit(!1);for(;!(D.getLengthInBits()>=X*8||(D.put(b,8),D.getLengthInBits()>=X*8));)D.put(C,8);return j(D,U)};I.addData=function(R,O){O=O||"Byte";var P=null;switch(O){case"Numeric":P=c(R);break;case"Alphanumeric":P=p(R);break;case"Byte":P=u(R);break;case"Kanji":P=w(R);break;default:throw"mode:"+O}T.push(P),x=null},I.isDark=function(R,O){if(R<0||f<=R||O<0||f<=O)throw R+","+O;return k[R][O]},I.getModuleCount=function(){return f},I.make=function(){if(y<1){for(var R=1;R<40;R++){for(var O=l.getRSBlocks(R,z),P=d(),U=0;U"u"?R*4:O;var P="";P+='";for(var D=0;D';P+=""}return P+="",P+="
",P},I.createSvgTag=function(R,O,P,U){var D={};typeof arguments[0]=="object"&&(D=arguments[0],R=D.cellSize,O=D.margin,P=D.alt,U=D.title),R=R||2,O=typeof O>"u"?R*4:O,P=typeof P=="string"?{text:P}:P||{},P.text=P.text||null,P.id=P.text?P.id||"qrcode-description":null,U=typeof U=="string"?{text:U}:U||{},U.text=U.text||null,U.id=U.text?U.id||"qrcode-title":null;var G=I.getModuleCount()*R+O*2,ee,X,be,Le,re="",Ie;for(Ie="l"+R+",0 0,"+R+" -"+R+",0 0,-"+R+"z ",re+=''+ie(U.text)+"":"",re+=P.text?''+ie(P.text)+"":"",re+='',re+='"u"?R*4:O;var P=I.getModuleCount()*R+O*2,U=O,D=P-O;return H(P,P,function(G,ee){if(U<=G&&G"u"?R*4:O;var U=I.getModuleCount()*R+O*2,D="";return D+="",D};var ie=function(R){for(var O="",P=0;P":O+=">";break;case"&":O+="&";break;case'"':O+=""";break;default:O+=U;break}}return O},ve=function(R){var O=1;R=typeof R>"u"?O*2:R;var P=I.getModuleCount()*O+R*2,U=R,D=P-R,G,ee,X,be,Le,re={"██":"█","█ ":"▀"," █":"▄"," ":" "},Ie={"██":"▀","█ ":"▀"," █":" "," ":" "},Be="";for(G=0;G=D?Ie[Le]:re[Le];Be+=` -`}return P%2&&R>0?Be.substring(0,Be.length-P-1)+Array(P+1).join("▀"):Be.substring(0,Be.length-1)};return I.createASCII=function(R,O){if(R=R||1,R<2)return ve(O);R-=1,O=typeof O>"u"?R*2:O;var P=I.getModuleCount()*R+O*2,U=O,D=P-O,G,ee,X,be,Le=Array(R+1).join("██"),re=Array(R+1).join(" "),Ie="",Be="";for(G=0;G>>8),z.push(x&255)):z.push(C)}}return z}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},s={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var S=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],$=1335,b=7973,C=21522,y={},z=function(k){for(var f=0;k!=0;)f+=1,k>>>=1;return f};return y.getBCHTypeInfo=function(k){for(var f=k<<10;z(f)-z($)>=0;)f^=$<=0;)f^=b<5&&(x+=3+V-5)}for(var T=0;T=256;)y-=255;return S[y]},C})();function i(S,$){if(typeof S.length>"u")throw S.length+"/"+$;var b=(function(){for(var y=0;y"u")throw"bad rs block @ typeNumber:"+y+"/errorCorrectionLevel:"+z;for(var f=k.length/3,x=[],T=0;T>>7-C%8&1)==1},b.put=function(C,y){for(var z=0;z>>y-z-1&1)==1)},b.getLengthInBits=function(){return $},b.putBit=function(C){var y=Math.floor($/8);S.length<=y&&S.push(0),C&&(S[y]|=128>>>$%8),$+=1},b},c=function(S){var $=e.MODE_NUMBER,b=S,C={};C.getMode=function(){return $},C.getLength=function(k){return b.length},C.write=function(k){for(var f=b,x=0;x+2>>8&255)*192+(T&255),k.put(T,13),x+=2}if(x>>8)},$.writeBytes=function(b,C,y){C=C||0,y=y||b.length;for(var z=0;z0&&(b+=","),b+=S[C];return b+="]",b},$},g=function(){var S=0,$=0,b=0,C="",y={},z=function(f){C+=String.fromCharCode(k(f&63))},k=function(f){if(!(f<0)){if(f<26)return 65+f;if(f<52)return 97+(f-26);if(f<62)return 48+(f-52);if(f==62)return 43;if(f==63)return 47}throw"n:"+f};return y.writeByte=function(f){for(S=S<<8|f&255,$+=8,b+=1;$>=6;)z(S>>>$-6),$-=6},y.flush=function(){if($>0&&(z(S<<6-$),S=0,$=0),b%3!=0)for(var f=3-b%3,x=0;x=$.length){if(y==0)return-1;throw"unexpected end of file./"+y}var f=$.charAt(b);if(b+=1,f=="=")return y=0,-1;if(f.match(/^\s$/))continue;C=C<<6|k(f.charCodeAt(0)),y+=6}var x=C>>>y-8&255;return y-=8,x};var k=function(f){if(65<=f&&f<=90)return f-65;if(97<=f&&f<=122)return f-97+26;if(48<=f&&f<=57)return f-48+52;if(f==43)return 62;if(f==47)return 63;throw"c:"+f};return z},E=function(S,$){var b=S,C=$,y=new Array(S*$),z={};z.setPixel=function(T,I,V){y[I*b+T]=V},z.write=function(T){T.writeString("GIF87a"),T.writeShort(b),T.writeShort(C),T.writeByte(128),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(255),T.writeByte(255),T.writeByte(255),T.writeString(","),T.writeShort(0),T.writeShort(0),T.writeShort(b),T.writeShort(C),T.writeByte(0);var I=2,V=f(I);T.writeByte(I);for(var J=0;V.length-J>255;)T.writeByte(255),T.writeBytes(V,J,255),J+=255;T.writeByte(V.length-J),T.writeBytes(V,J,V.length-J),T.writeByte(0),T.writeString(";")};var k=function(T){var I=T,V=0,J=0,te={};return te.write=function(B,Q){if(B>>>Q)throw"length over";for(;V+Q>=8;)I.writeByte(255&(B<>>=8-V,J=0,V=0;J=B<0&&I.writeByte(J)},te},f=function(T){for(var I=1<>6,128|a&63):a<55296||a>=57344?s.push(224|a>>12,128|a>>6&63,128|a&63):(r++,a=65536+((a&1023)<<10|o.charCodeAt(r)&1023),s.push(240|a>>18,128|a>>12&63,128|a>>6&63,128|a&63))}return s}return e(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof ts=="object"&&(ns.exports=n())})(function(){return es})});function Jn(n,e){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(o=>Jn(o,e)):e.push(n instanceof Node?n:String(n))),e}function t(n,e,o){let s=window.E,r=e!=null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Node);return!r&&o===void 0?s(n,{},Jn(e,[])):s(n,r?e:{},Jn(o,[]))}var qo={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function kt(n,e="dl-icon"){let o=qo[n]??qo.phone;return``}function v(n,e="dl-icon"){let o=document.createElement("span");return o.className="dl-icon-wrap",o.innerHTML=kt(n,e),o}function q(n,e="info",o=0){let s=document.querySelector(".dl-toasts");s||(s=t("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(s));let r=e==="error"?"x":e==="warning"?"alert":e==="success"?"check":null,a=()=>{i.classList.remove("show"),setTimeout(()=>i.remove(),200)},i=t("div",{class:`dl-toast ${e}`},[r?v(r):"",t("span",{},n),e==="error"?t("button",{type:"button","aria-label":_("Close"),click:a},v("x")):""]);s.appendChild(i),requestAnimationFrame(()=>i.classList.add("show")),setTimeout(a,o||(e==="error"?8e3:e==="warning"?5e3:2600))}function Ce(n){return n instanceof Error?n.message:String(n)}async function F(n,e){try{let o=await n();return e&&q(e,"success",3500),o}catch(o){q(Ce(o),"error",1e4);return}}function Fo(n){try{let e=n();e&&typeof e.then=="function"&&e.catch(o=>q(Ce(o),"error"))}catch(e){q(Ce(e),"error")}}function Zn(){return(typeof document>"u"?"":document.documentElement.lang)||"en"}function le(){let n=Zn();return n==="en"?"en-GB":n}function m(n,...e){let o=0;return n.replace(/%([%sd])/g,(s,r)=>r==="%"?"%":String(e[o++]??""))}function K(n,e){return n.toLocaleString(le(),e===void 0?void 0:{minimumFractionDigits:e,maximumFractionDigits:e})}function W(n,e,o){return m(N_(n,e,o),K(n))}function ae(n,...e){let o=0;return n.split(/(%[%sd])/).filter(Boolean).map(s=>s==="%%"?"%":s==="%s"||s==="%d"?e[o++]:s)}var Qn=n=>_(n);function Ko(n){if(n&&typeof n=="object"){if(typeof n.error=="string")throw new Error(n.error);typeof n.warning=="string"&&n.warning&&q(n.warning,"warning",12e3)}return n}function Z(n,e=[]){let o=rpc.declare({object:"luci.dawnline",method:n,params:[...e,"lang"]});return async(...s)=>Ko(await o(...e.map((r,a)=>s[a]),Zn()))}var Wa=Z("logs_clear",["person","device","category","older_days"]),Ga=(n={})=>Wa(n.person??"",n.device??"",n.category??"",n.older_days??""),qa=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets","server"]});async function Fa(n,e){let s=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(r=>e[r]),e.paused,e.services,e.circle,e.home_nets,e.server];return Ko(await qa(...s))}var Ka=Z("status",["days"]),N={rev:Z("rev"),personUpdate:Fa,settingsGet:Z("settings_get"),portalInfo:Z("portal_info"),settingsUpdate:Z("settings_update",["values"]),serviceSet:Z("service_set",["id","name","address","ports"]),serviceDelete:Z("service_delete",["id"]),geoClear:Z("geo_clear"),events:Z("events",["limit","person","since"]),logsClear:Ga,interfaces:Z("interfaces",["id"]),serverInterfaces:Z("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:Z("circle_set",["id","server","name","color","members"]),circleDelete:Z("circle_delete",["id"]),accessCheck:Z("access_check",["from","to"]),homeHosts:Z("home_hosts",["id"]),usageClear:Z("usage_clear",["scope","id"]),uninstall:Z("uninstall",["confirm"]),status:Ka,setupDefaults:Z("setup_defaults"),serverCreate:Z("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:Z("server_obfuscation",["id","preset"]),serverUpdate:Z("server_update",["id","values"]),serverPorts:Z("server_ports",["id"]),endpointProbe:Z("endpoint_probe",["host","id","port"]),serverDelete:Z("server_delete",["id"]),personLinks:Z("person_links",["id"]),personCreate:Z("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:Z("person_pause",["id","paused"]),personRegen:Z("person_regen",["id","remove"]),personDelete:Z("person_delete",["id"]),personUsage:Z("person_usage",["id","days"]),deviceCreate:Z("device_create",["person","name","kind"]),deviceConfig:Z("device_config",["id"]),deviceUpdate:Z("device_update",["id","name","disabled"]),deviceDelete:Z("device_delete",["id"]),deviceRotate:Z("device_rotate",["id"]),apply:Z("apply"),health:Z("health"),healthFix:Z("health_fix",["id"]),serviceLog:Z("service_log"),serviceLogClear:Z("service_log_clear",["older_days"]),backupList:Z("backup_list"),backupCreate:Z("backup_create"),backupRestore:Z("backup_restore",["name"]),backupDelete:Z("backup_delete",["name"]),backupRead:Z("backup_read",["name"]),backupUpload:Z("backup_upload",["data"]),exportJson:Z("export"),importJson:Z("import",["data"]),updatesStatus:Z("updates_status"),updatesRun:Z("updates_run",["what"]),updatesReleases:Z("updates_releases",["page"]),updatesNotes:Z("updates_notes",["component","tag","build"]),updatesChanges:Z("updates_changes",["from","to"])};function A(n,e,o="neutral",s={}){let{disabled:r,...a}=s,i=t("button",{class:`cbi-button cbi-button-${o}`,type:"button",...a,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!i.disabled){i.disabled=!0,i.classList.add("spinning");try{await e(l)}catch(d){q(Ce(d),"error")}finally{i.disabled=!1,i.classList.remove("spinning")}}}},n);return i.disabled=!!r,i}function $e(n,e,o,s="neutral",r=""){return A([v(n),t("span",{class:"dl-btn-label"},e)],o,s,{title:e,class:`cbi-button cbi-button-${s} dl-icon-btn ${r}`.trim()})}function Te(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var _t=null;function Xn(n=!1){let e=_t;_t=null,e?.(n)}function de(n,e,o,s=""){Xn();let r=t("div",{class:`dl-modal ${s}`},e),a=t("div",{class:"button-row"},o);r.addEventListener("keydown",i=>{if(i.key==="Escape"){i.preventDefault(),i.stopPropagation(),ce();return}if(i.key!=="Enter"||i.shiftKey||i.ctrlKey||i.metaKey||i.altKey)return;let l=i.target;if(!l||["TEXTAREA","BUTTON","SELECT","A"].includes(l.tagName))return;let d=a.querySelector(".cbi-button-positive");!d||d.disabled||(i.preventDefault(),d.click())}),ui.showModal(n,[r,a])}function ce(){Xn(),ui.hideModal()}function ue(n=_("Cancel"),e=!1){return t("button",{class:`cbi-button ${e?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:ce},n)}function me(n,e,o=_("Confirm"),s=!1){return new Promise(r=>{de(n,e,[ue()," ",t("button",{class:`cbi-button ${s?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let a=_t;_t=null,ui.hideModal(),a?.(!0)}},o)]),_t=r})}Te(()=>{_t&&(Xn(),ui.hideModal())});async function xe(n,e=_("Copied to clipboard"),o=!1){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let s=t("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(s),s.select();let r=document.execCommand("copy");if(s.remove(),!r)throw new Error(_("Copying is blocked here. Select the text and copy it by hand."))}return q(e,"success",2500),!0}catch(s){return o||q(Ce(s),"error"),!1}}function Ne(n,e,o="text/plain"){let s=globalThis,r=typeof e=="string"?new s.Blob([e],{type:o}):e,a=URL.createObjectURL(r),i=t("a",{href:a,download:n,style:"display:none"});document.body.appendChild(i),i.click(),setTimeout(()=>{URL.revokeObjectURL(a),i.remove()},1e3)}function eo(n,e){return new Promise(o=>{let s=t("input",{type:"file",accept:n,style:"display:none"});s.addEventListener("cancel",()=>{s.remove(),o(null)}),s.addEventListener("change",()=>{let r=s.files?.[0];if(s.remove(),!r)return o(null);let a=new FileReader;a.onload=()=>{let i=String(a.result??"");o({name:r.name,data:e==="base64"?i.replace(/^data:[^,]*,/,""):i})},a.onerror=()=>o(null),e==="base64"?a.readAsDataURL(r):a.readAsText(r)}),document.body.appendChild(s),s.click()})}function Se(n,e){let o=document.querySelector(".dl-dd");if(o&&(o.dlClose?o.dlClose():o.remove(),o.dlAnchor===n))return;let s=t("div",{class:"dl-dd dl-root",role:"menu"},e.map(u=>u?t("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),Fo(u.run)}},[u.icon??"",t("span",{},u.label)]):t("hr")));document.body.appendChild(s);let r=n.getBoundingClientRect(),a=s.offsetWidth,i=s.offsetHeight;s.style.top=`${r.bottom+6+i>window.innerHeight-8&&r.top-6-i>8?r.top-6-i:r.bottom+6}px`,s.style.left=`${Math.max(8,Math.min(r.right-a,window.innerWidth-a-8))}px`;let l=u=>{!s.contains(u.target)&&!n.contains(u.target)&&p()},d=u=>{if(u.key==="Escape"||u.key==="Tab")return p();let w=[...s.querySelectorAll("button:not([disabled])")];if(!w.length||!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;u.preventDefault();let M=w.indexOf(document.activeElement),g=u.key==="Home"?0:u.key==="End"?w.length-1:u.key==="ArrowDown"?(M+1)%w.length:(M-1+w.length)%w.length;w[g].focus({preventScroll:!0})},c=Te(p);s.dlAnchor=n,s.dlClose=p;function p(){s.remove(),c(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",p,!0)}),s.querySelector("button")?.focus({preventScroll:!0})}var gt=null,nt=null,to=0;function Ct(){gt&&(gt.style.display="none"),nt=null,clearInterval(to),to=0}function we(n,e){let o=s=>{gt??(gt=document.body.appendChild(t("div",{class:"dl-tip dl-tip-float dl-root"}))),gt.replaceChildren(...e().map(r=>typeof r=="string"?document.createTextNode(r):r)),gt.style.display="",gt.style.left=`${s.clientX}px`,gt.style.top=`${s.clientY-10}px`,nt=n,to||(to=window.setInterval(()=>{(!nt?.isConnected||!nt.getClientRects().length)&&Ct()},400))};n.addEventListener("mouseenter",o),n.addEventListener("mousemove",o),n.addEventListener("mouseleave",Ct),n.addEventListener("pointerup",s=>{s.pointerType!=="mouse"&&(nt===n?Ct():o(s))})}Te(Ct);window.addEventListener("scroll",()=>nt&&Ct(),{capture:!0,passive:!0});document.addEventListener("pointerdown",n=>{nt&&!nt.contains(n.target)&&Ct()},!0);function Ya(n,e,o){let s=0;for(;n>=o&&s=100||s===0?K(Math.round(n)):K(n,1)} ${e[s]}`}function se(n){return Ya(!n||n<0?0:n,[_("B"),_("KB"),_("MB"),_("GB"),_("TB")],1024)}function Fe(n){let e=n*8,o=[_("bit/s"),_("kbit/s"),_("Mbit/s"),_("Gbit/s")];if(e<1e3)return`${K(Math.round(e))} ${o[0]}`;let s=e<1e6?1:e<1e9?2:3,r=e/1e3**s;return`${K(r,s===3||r<10?1:0)} ${o[s]}`}function pe(n,e=Date.now()/1e3){if(!n)return _("never");let o=Math.max(0,Math.round(e-n));return o<60?_("just now"):o<3600?m(_("%s min ago"),Math.floor(o/60)):o<86400?m(_("%s h ago"),Math.floor(o/3600)):o<86400*30?m(_("%s d ago"),Math.floor(o/86400)):new Date(n*1e3).toLocaleDateString(le(),{day:"numeric",month:"short",year:"numeric"})}function ot(n){if(!n||n<0)return"—";let e=Math.floor(n/86400),o=Math.floor(n%86400/3600),s=Math.floor(n%3600/60);return e?m(_("%sd %sh"),e,o):o?m(_("%sh %sm"),o,s):m(_("%sm"),s)}function Ut(n){let e=new Date(n*1e3),o=new Date,s=e.toDateString()===o.toDateString(),r=e.toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"});return s?r:`${e.toLocaleDateString(le(),{day:"numeric",month:"short"})} ${r}`}function Ke(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function Mt(n){let[e,o,s]=n.split("-").map(Number);return new Date(e,(o||1)-1,s||1,12)}function Oe(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?Mt(n):new Date(n):n).toLocaleDateString(le(),{day:"numeric",month:"short",year:"numeric"})}function De(n){return n?Oe(n):""}function no(n,e){let o=s=>{let[r,a,i]=s.split("-").map(Number);return Date.UTC(r,a-1,i)};return Math.round((o(n)-o(e))/864e5)}function jt(n,e){let o=Mt(n);return o.setDate(o.getDate()+e),Ke(o)}function Lt(n,e){let[o,s,r]=n.split("-").map(Number),a=new Date(o,s-1+e,1,12),i=new Date(a.getFullYear(),a.getMonth()+1,0).getDate();return a.setDate(Math.min(r,i)),Ke(a)}function Ge(n){return n?.length?n[n.length-1].day:Ke(new Date)}function Yo(n,e,o,s,r=30){let a=n||s;return e==="day"?jt(a,o):e==="week"?jt(a,7*o):e==="month"?Lt(a,o):e==="year"?Lt(a,12*o):jt(a,r*o)}function st(n,e=Date.now()){if(!n)return null;let o=typeof e=="number"?Ke(new Date(e)):e,s=no(n,o);return s>=0?s+1:s}function rt(n,e){return e!=null&&e>0&&n.expire_warn>0&&e<=n.expire_warn}function an(n){return n<=1?_("ends today"):n===2?_("ends tomorrow"):W(n,"ends in %s day","ends in %s days")}function Et(n){return n<1024?`${K(n)} ${_("B")}`:n<1048576?`${K(n/1024,n<10240?1:0)} ${_("KB")}`:`${K(n/1048576,1)} ${_("MB")}`}function vt(n){return{lan:_("Home network"),internet:_("Internet"),both:_("Home network + Internet")}[n]}var Vo=["computer","phone","tablet","router","other"];function at(n){return{computer:_("PC"),phone:_("Phone"),tablet:_("Tablet"),router:_("Router"),other:_("Other")}[n]}function Jo(n){return{active:_("Active"),paused:_("Paused"),expired:_("Expired"),quota:_("Data limit reached"),hours:_("Outside allowed hours"),no_server:_("No server"),server_off:_("Server is turned off")}[n]}function je(n){let e=n.trim().split(/\s+/).filter(Boolean);if(!e.length)return"?";let o=e[0][0]??"",s=e.length>1?e[e.length-1][0]??"":e[0][1]??"";return(o+s).toUpperCase()}function ln(n){let e=o=>o.disabled?3:o.online?0:o.handshake?1:2;return n.map((o,s)=>[o,s]).sort((o,s)=>e(o[0])-e(s[0])||o[1]-s[1]).map(([o])=>o)}function Pe(n,e,o){return t("span",{class:`dl-pill ${n}`,title:o??null},e)}function Va(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function Ja(n){return n.state==="server_off"&&n.paused?"paused":n.state}function Zo(n){let e=Ja(n);return e==="active"||e==="server_off"?"":Pe(Va({...n,state:e}),Jo(e))}function Qo(n){let e=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],o=t("span",{class:"dl-access","aria-label":vt(n.access)},e.map(s=>t("span",{class:`dl-ibadge ${s}`},v(s==="lan"?"home":"globe"))));return we(o,()=>[t("div",{class:"dl-tip-title"},vt(n.access)),n.access==="lan"&&n.services?.length?t("div",{class:"dl-muted"},W(n.services.length,"%s home service only","%s home services only")):""]),o}function Za(n){return{active:null,paused:_("Paused"),expired:_("Access ended"),quota:_("Data limit"),hours:_("Outside hours"),server_off:_("Server off"),no_server:_("No server")}[n]}function dn(n,e,o=_("Not set up yet"),s){let r=new Date(n.handshake*1e3).toLocaleString(le()),a=n.handshake?`${m(_("Last seen %s"),pe(n.handshake,e))} · ${r}`:"";if(n.disabled)return t("span",{class:"dl-dstat",title:a},_("Disabled"));if(n.online)return t("span",{class:"dl-dstat ok"},_("Connected"));let i=s&&Za(s.state);return i?t("span",{class:"dl-dstat warn",title:a||_("Not connected yet")},i):n.handshake?t("span",{class:"dl-dstat",title:r},m(_("Last seen %s"),pe(n.handshake,e))):t("span",{class:"dl-dstat warn",title:_("Waiting for the first connection")},o)}var cn=null;function Xo(n,e,o,s){cn?.close();let r=t("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[t("div",{class:"dl-drawer-head"},[n,t("button",{type:"button",class:"dl-drawer-x","aria-label":_("Close"),click:()=>c()},v("x"))]),t("div",{class:"dl-drawer-body"},e),o?t("div",{class:"dl-drawer-foot"},o):""]),a=t("div",{class:"dl-drawer-overlay dl-root",click:u=>{u.target===a&&c()}},r),i=u=>{u.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&c()},l=!1,d=Te(()=>c());function c(){l||(l=!0,d(),document.removeEventListener("keydown",i),a.classList.remove("open"),setTimeout(()=>a.remove(),220),cn===p&&(cn=null),s())}let p={close:c,panel:r};return document.addEventListener("keydown",i),document.body.appendChild(a),requestAnimationFrame(()=>a.classList.add("open")),cn=p,p}function ge(n,e,o){return t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},n),o?t("span",{class:"dl-sub"},o):""]),t("div",{class:"dl-setrow-ctl"},e)])}function _e(n,e,o,s=e){let r=ge(n,s," "),a=r.querySelector(".dl-sub"),i=()=>{let l=o();a.textContent=l.text,a.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",i),r.refresh=i,r.help=o,i(),r}function Ee(n,e,o,s=e){let r=t("div",{class:"dl-sub"}),a=t("div",{class:"cbi-value dl-live"},[t("div",{class:"cbi-value-title"},[t("label",{},n),r]),t("div",{class:"cbi-value-field"},s)]),i=()=>{let l=o();r.textContent=l.text,r.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",i),e.addEventListener("change",i),a.refresh=i,a.help=o,i(),a}function Ue(n,e=[]){for(let o of n){let s=o.help?.();if(s?.bad)return s.text}for(let o of e){let s=o();if(s.bad)return s.text}return null}function Wt(n,e,o,s=""){return t("section",{class:`dl-setsec ${s}`},[t("div",{class:"dl-setsec-body"},[n?t("h3",{},n):"",...e]),o.length?t("div",{class:"dl-setsec-foot"},o):""])}function ke(n,e,o,s){return t("div",{class:"dl-group"},[t("div",{class:"dl-group-head"},[t("span",{class:"dl-group-ic"},v(n)),t("span",{class:"dl-stack"},[t("b",{},e),o?t("span",{class:"dl-sub"},o):""])]),t("div",{class:"dl-group-body"},s.filter(r=>r!==""))])}function it(n,e,o,s,r){return t("div",{class:`dl-row dl-need-row ${e}`},[e?t("span",{class:"dl-need-ic"},v(n)):v(n),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-sub"},s)]),r])}function bt(n,e){let o={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return t("div",{class:`alert-message ${o}`},e)}function Tt(n,e=""){let o=t("div",{class:e});return o.innerHTML=n,o}var rs=Ua(os(),1),Qa=n=>``,ss="#0a0a0a",Xa="#f2f2f2",ei={night:[ss,Xa],day:["#ffffff",ss]},ti=n=>n.length>300,St=n=>+n.toFixed(2);function oo(n,e,o,s,r){return`M${St(n+r)} ${St(e)}h${St(o-2*r)}a${r} ${r} 0 0 1 ${r} ${r}v${St(s-2*r)}a${r} ${r} 0 0 1 -${r} ${r}h-${St(o-2*r)}a${r} ${r} 0 0 1 -${r} -${r}v-${St(s-2*r)}a${r} ${r} 0 0 1 ${r} -${r}z`}function pn(n,e=3,o=!0,s="plain"){let r=ti(n),a=s!=="plain",[i,l]=a?ei[s]:["#fff","#000"],d=(0,rs.default)(0,r?"L":"H");d.addData(n,"Byte"),d.make();let c=d.getModuleCount(),p=c+e*2,u=o&&!r?Math.round(c*.22):0;u&&(c-u)%2&&u++;let w=(c-u)/2,M=w+u,g=(b,C)=>u>0&&b>=w&&b=w&&Ca&&(C<7&&b<7||C<7&&b>=c-7||C>=c-7&&b<7),E="";if(a){let b=r?.48:.42;for(let C=0;C${Qa(a?i:"#fff")}`}let $=``;return a?`${$}${S}`:`${$}${S}`}function xt(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function un(n){let e=xt();return Tt(pn(n,3,!0,e?"night":"day"),`dl-qr${e?"":" light"}`)}function so(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(n.trim());if(!e)return null;let[o,s,r,a]=e.slice(1,5).map(Number),i=Number(e[5]);if([o,s,r,a].some(c=>c>255)||i<8||i>30)return null;let l=o*2**24+s*2**16+r*2**8+a,d=2**(32-i);return{net:l-l%d,size:d}}var ni=(n,e)=>n.netso(n));function $t(n){return n.split("/")[0].split(".").slice(0,3).join(".")}function mn(n){return`${n.trim()}.0/24`}function ao(n,e,o){let s=n.trim(),r=/^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(s)?so(mn(s)):null;if(!r)return{text:_("Three numbers, like 10.77.0."),bad:!0};if(!oi.some(i=>r.net>=i.net&&r.net+r.size<=i.net+i.size))return{text:_("Use a private range: 10.x.x, 172.16–31.x or 192.168.x."),bad:!0};let a=e.find(i=>{let l=so(i.cidr);return l!=null&&ni(r,l)});if(a){let i=a.cidr.endsWith("/24")?`${$t(a.cidr)}.x`:a.cidr,l=m(_("%s already uses %s."),a.name,i);return{text:o&&o!==s?`${l} ${m(_("Try %s."),o)}`:l,bad:!0}}return{text:m(_("Devices get %s – %s, the router %s."),`${s}.2`,`${s}.254`,`${s}.1`),bad:!1}}var is=(n,e)=>e.find(o=>o.from<=n&&n<=o.to)?.who??null,si=n=>Number.isInteger(n)&&n>=1&&n<=65535;function Gt(n,e,o){if(!si(n))return{text:_("Use a port from 1 to 65535."),bad:!0};let s=is(n,e);return s?{text:m(_("Used by %s. Choose another port."),s),bad:!0}:{text:o,bad:!1}}function hn(n,e,o){let s=o?m(_("HTTPS here, plain HTTP for links on IP addresses on %s."),n+1):_("HTTPS on this port, opened on WAN."),r=Gt(n,e,s);if(r.bad||!o)return r;if(n===65535)return{text:_("Links on IP addresses also need the next port: choose a lower one."),bad:!0};let a=is(n+1,e);return a?{text:m(_("Links on IP addresses also need %s, used by %s. Choose another port."),n+1,a),bad:!0}:r}var io=n=>Array.from(n).length,as=48,ri=/[<>"\\\u0000-\u001f\u007f]/,ls=(n,e)=>m(N_(n,"Up to %s character (%s now).","Up to %s characters (%s now)."),K(n),K(io(e)));function He(n,e=[],o=""){let s=n.trim();return s?io(n)>as?{text:ls(as,n),bad:!0}:ri.test(n)?{text:_('Names can’t contain < > " or \\.'),bad:!0}:e.some(r=>r.toLowerCase()===s.toLowerCase())?{text:m(_("“%s” already exists - pick another name."),s),bad:!0}:{text:o,bad:!1}:{text:_("Enter a name."),bad:!0}}function ds(n,e=[]){return io(n)>32?{text:ls(32,n),bad:!0}:He(n,e,_("Shown on the person cards."))}var ai=/^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,ii=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Dt(n){let e=ii.exec(n);return!!e&&e.slice(1).every(o=>Number(o)<=255)}function ro(n){return/^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(n)&&!/:::/.test(n)}function Pt(n,e,o=null){let s=n.trim();if(!s)return o!=null?{text:o,bad:!1}:{text:_("Enter a hostname or IP address."),bad:!0};if(/^[a-z]+:\/\//i.test(s))return{text:_("Leave out https:// - just the name."),bad:!0};if(/\/.*/.test(s))return{text:_("Just the name, without a path."),bad:!0};if(/^[^:\[]+:\d+$/.test(s))return{text:_("Just the name, without a port (the port is on AmneziaWG)."),bad:!0};if(/\s/.test(s))return{text:_("A hostname has no spaces."),bad:!0};if(s.length>253||!(ai.test(s)||Dt(s)||ro(s)))return{text:_("Use a hostname or an IP address."),bad:!0};let r=ro(s)?`[${s}]`:s;return{text:e?m(_("Devices connect to %s."),`${r}:${e}`):m(_("Links use %s."),r),bad:!1}}function cs(n,e){let o=n.split(/[ ,]+/).filter(Boolean);if(!o.length)return{text:m(_("This router (%s): queries go where your home network sends them, and home names work."),e),bad:!1};let s=o.find(a=>!Dt(a)&&!ro(a));if(s)return{text:m(_("“%s” is not an IP address. Separate several with commas."),s),bad:!0};let r=new Intl.ListFormat(le(),{type:"conjunction"}).format(o);return{text:m(_("Devices use %s - home names and your LAN’s DNS filters no longer apply to them."),r),bad:!1}}function ps(n,e){let o=n.trim();if(!o)return{text:m(_("Automatic by device type and disguise: %s for computers and routers, %s for phones and tablets."),e.computer,e.phone),bad:!1};if(!/^\d{1,4}$/.test(o)||Number(o)<1280||Number(o)>1500)return{text:_("MTU must be 1280–1500, or empty for automatic."),bad:!0};let s=Number(o);return{text:m(_("Computers and routers get %s, phones and tablets %s."),s,Math.min(s,1280)),bad:!1}}function us(n){let e=n.trim();return e?!/^\d{1,3}$/.test(e)||Number(e)>600?{text:_("Use 0–600 seconds."),bad:!0}:Number(e)===0?{text:_("Off: NAT may close the tunnel when idle, and “Connected” lags."),bad:!1}:{text:m(_("Devices send a packet every %s s to keep NAT open (a little battery on phones)."),e),bad:!1}:{text:_("Default: a packet every 25 s keeps NAT open and “Connected” accurate."),bad:!1}}function fn(n,e=0){let o=n.trim();if(!/^\d{1,2}$/.test(o)||Number(o)<1||Number(o)>32)return{text:_("Use 1–32."),bad:!0};let s=Number(o);return e>s?{text:e-s===1?m(N_(e,"Already has %s device: remove one first, or allow more.","Already has %s devices: remove one first, or allow more."),K(e)):m(N_(e,"Already has %s device: remove %s first, or allow more.","Already has %s devices: remove %s first, or allow more."),K(e),K(e-s)),bad:!0}:{text:W(s,"They can add %s device themselves.","They can add %s devices themselves."),bad:!1}}function gn(n,e=!0){let o=n.trim();if(!o)return{text:_("Optional. No data limit."),bad:!1};let s=Number(o);return!/^\d+(\.\d+)?$/.test(o)||s<0||s>1e5?{text:_("A number of GB, up to 100000."),bad:!0}:s===0?{text:_("Optional. No data limit."),bad:!1}:{text:m(e?_("Paused after %s GB this month, resumed on the 1st."):_("Paused after %s GB in total."),K(s)),bad:!1}}function ms(n,e,o,s){let r=n.trim();if(!r)return{text:_("Optional. No end date."),bad:!1};let a=o(r,e);return a==null?{text:_("Use a date."),bad:!0}:a<0?{text:_("That date has passed: access would end at once."),bad:!0}:{text:a===1?m(_("Access ends today (%s)."),s(r)):m(N_(a,"Access ends in %s day (%s).","Access ends in %s days (%s)."),K(a),s(r)),bad:!1}}function hs(n,e=null){let o=n.trim();return o?Dt(o)?e&&!e(o)?{text:m(_("%s is not in any home network of this server: nobody would reach it."),o),bad:!1}:{text:"",bad:!1}:{text:_("Use an IPv4 address, like 192.168.1.10."),bad:!0}:{text:_("The device’s address at home."),bad:!0}}function fs(n){let e=n.split(/[ ,]+/).filter(Boolean);if(!e.length)return{text:_("All ports."),bad:!1};let o=e.find(s=>!/^\d{1,5}$/.test(s)||Number(s)<1||Number(s)>65535);return o?{text:m(_("“%s” is not a port (1–65535)."),o),bad:!0}:{text:m(N_(e.length,"Port %s.","Ports %s."),e.join(", ")),bad:!1}}function gs(n){let e=n.trim();return e?/^https?:\/\//i.test(e)?e.length>300||!/^https?:\/\/[A-Za-z0-9.-]+(:[0-9]+)?(\/[^\s"'<>]*)?$/.test(e)?{text:_("Not a usable address (no spaces or quotes)."),bad:!0}:{text:_("Wrong links are sent there instead of a “Not found”."),bad:!1}:{text:_("Must start with http:// or https://."),bad:!0}:{text:_("Wrong links get a bare “Not found”."),bad:!1}}function vs(n,e="phone.myata"){let o=n.trim();return o?/^[a-z0-9-]{1,32}(\.[a-z0-9-]{1,32})*$/.test(o)?{text:m(_("Devices get names like %s."),`${e}.${o}`),bad:!1}:{text:/[A-Z]/.test(o)?_("Lowercase only."):_("Lowercase letters, digits, dashes and dots."),bad:!0}:{text:m(_("The default, lan: devices get names like %s."),`${e}.lan`),bad:!1}}function bs(n){let e=n.trim();return e?Dt(e)?{text:m(_("%s takes over when the tunnel is down."),e),bad:!1}:{text:_("Use an IPv4 address, or leave it empty."),bad:!0}:{text:_("None: without the tunnel those devices have no DNS."),bad:!1}}function xs(n){let e=n.trim();return/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e)?{text:m(_("Runs within an hour after %s (router time)."),e),bad:!1}:{text:_("Use HH:MM, 00:00–23:59."),bad:!0}}function lo(n,e,o,s={}){let r=0,a="",i=null;return{help:()=>{let{host:c,port:p}=n(),u=Pt(c,p,s.empty??null);return u.bad||!c.trim()?u:i&&i.host===c.trim()?{text:i.text,bad:i.bad}:{text:`${s.idle?.()||u.text} ${_("Checking where it points…")}`,bad:!1}},schedule:()=>{let{host:c}=n(),p=Pt(c,n().port,s.empty??null);p.bad||!c.trim()||c.trim()===i?.host||(clearTimeout(r),r=window.setTimeout(async()=>{let u=c.trim();a=u;try{let{id:w,port:M}=n(),g=await e(u,w,M);if(a!==u)return;i={host:u,text:g.text,bad:g.status==="error"}}catch{if(a!==u)return;i={host:u,text:p.text,bad:!1}}o()},700))}}}var co=["%d system package","%d system packages","%s (after %d repair)","%s (after %d repairs)","%s - %d repairs didn't help","%s - %s","%s - not repaired again (%d repairs didn't help)","%s has no IPv4 address.","%s is not a bridge, so Dawnline cannot join the LAN as a device.","%s needs a manual switch in Components","%s still give devices the old address: set the public address in the server settings (a DDNS name keeps working), then devices need new configurations.","%s still gives devices the old address: set the public address in the server settings (a DDNS name keeps working), then devices need new configurations.","%s · restored","Access rules","Activity","AmneziaWG is missing from the router","AmneziaWG is running again","AmneziaWG is running again · accepting connections on port %d","AmneziaWG isn't accepting connections on port %d","AmneziaWG isn't running","Backup","Browsers will refuse the portal after that. Renew it with ACME, or choose another certificate in Settings.","Choose another interface name in the server settings.","Components","Connections","DNS for Home-only devices","Dawnline didn't stop it: the router's network restarted, someone stopped it by hand, or it failed.","Firewall","Install it in Dawnline → Components.","Internet like a home device","MTU is now automatic","Missing: %s.","No LAN detected.","No free address on %s.","No free link-local range for the internal link.","No free routing table.","People","Personal links","Personal portal","Router","Servers","Speed","System packages","The new version did not answer in LuCI or its agent did not start. Try again from Components, or install it with install.sh to see why.","Traffic","Watchdog","a new build needs a manual switch in Components","answers again","are loaded again","are missing","automatic update failed","background check failed: %s","can't reach Dawnline (luci.dawnline is missing in rpcd)","can't use the network interface %s: it exists and isn't Dawnline's","certificate expires %s","certificate expires within 7 days","certificate renewed · valid until %s","couldn't be repaired: %s","couldn't be updated - the previous rules stay, and changes to access wait until they load","couldn't load - no device is loaded into the tunnels until they do","couldn't load devices into the tunnel","couldn't start","couldn't start · %d failed attempts in %d min","failed - internet goes out directly for now","failed: %s",'has an invalid interface name "%s"',"installed the %s build","installed the %s build · %s","is kept down","is kept down: its disguise needs AmneziaWG %s (installed: %s)","is kept down: its disguise needs AmneziaWG %s (installed: none)","is off","is on · traffic enters %s as %s","is ready again","isn't answering on port %d","isn't installed: no tunnel can run - install it in Dawnline → Components","isn't installed: tunnels were left as they are","isn't known to the network service - restart the network or reboot","isn't running","isn't running on this router (fw4): tunnels and the portal are closed","kernel module isn't installed: no tunnel can run - install it in Dawnline → Components","kernel module isn't loaded","loading it","loading them again","moved to word codes","netifd reads its protocol handlers when it starts; it was running before AmneziaWG was installed.","network changed - Dawnline set itself up again","nightly backup failed: %s","public address changed · %s → %s","reaches Dawnline again","reloading rpcd","restarted · version %s","restarting for the AmneziaWG update","restarting it","restoring them","rules for Dawnline are in place again","rules for Dawnline aren't loaded","rules for Dawnline were changed or removed","runs again","setting it up again","started","started with the router · version %s","started · accepting connections on port %s","started · version %s","stopped unexpectedly","stopped unexpectedly - started again","update failed","update to %s failed its check - rolled back to %s","updated automatically · %s","updated automatically · %s → %s","updated · %s","updated · %s → %s","updates available · %s","was broken - set up again (%s as %s)"];var li={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",expiring:"people",expired_kept:"people",portal_blocked:"problems"},Nt=["connections","people","problems"];function Ye(n){return{connections:_("Connections"),people:_("People"),problems:_("Problems")}[n]}function ws(n){return{connections:_("Connects, disconnects and IP changes"),people:_("People and their devices added, changed, paused, removed"),problems:_("Blocked portal sign-ins (tunnels and services are in the service log)")}[n]}var qt=n=>li[n]??"problems";function Ft(n){return{awg:"AmneziaWG",dawnline:"Dawnline",portal:_("Portal")}[n]??n}var di=["person_added","person_removed","person_changed"];function Ve(n){return n.by?n.by:di.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function ys(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var vn=n=>n.sys?["error","repair","down"].includes(n.sys.level):qt(n.ev.type)==="problems";function bn(n){let e=n.keep_days>0?W(n.keep_days,"%s day","%s days"):_("no age limit"),o=n.persist==="off"?_("kept in memory only (lost on reboot)"):n.persist==="10min"?_("saved to flash every 10 minutes"):_("saved to flash hourly");return m(_("Kept for %s, %s, %s."),e,W(n.max,"up to %s event","up to %s events"),o)}function po(n){return{"paused by admin":_("paused by admin"),"end date reached":_("end date reached"),"data limit reached":_("data limit reached"),"outside allowed hours":_("outside allowed hours"),"no server":_("no server"),"server turned off":_("server turned off")}[n]??n}function ks(n){let e=/^(\d+) days?$/.exec(n);return e?Number(e[1]):null}function _s(n){let e={name:_("name"),access:_("access"),device_limit:_("device limit"),expires:_("end date"),expire_action:_("what happens at the end"),expire_warn:_("warning before the end"),quota_gb:_("data limit"),quota_period:_("data limit period"),bonus_gb:_("extra data"),hours:_("allowed hours"),dns_mode:_("DNS"),paused:_("pause"),services:_("home services"),circle:_("circle","setting"),home_nets:_("home networks"),server:_("server")};return n.split(", ").map(o=>{let s=/^moved to (.+)$/.exec(o)?.[1];return s?m(_("moved to %s"),s):e[o]??o.replace(/_/g," ")}).join(", ")}function Cs(n,e,o){let r={"cleared|the service log":_("You cleared the service log"),"cleared|the activity log":_("You cleared the activity log"),"exported|all settings":_("You exported all settings"),"imported|settings from a file":_("You imported settings from a file"),"restored|from a file":_("You restored a backup from a file"),"turned on|the personal portal":_("You turned on the personal portal"),"turned off|the personal portal":_("You turned off the personal portal"),"changed|the personal portal":_("You changed the personal portal"),"turned on|the watchdog":_("You turned on the watchdog"),"turned off|the watchdog":_("You turned off the watchdog"),"reset traffic history|for everyone":_("You reset traffic history for everyone")}[`${n}|${o??""}`];if(r)return{text:r,named:!1};let i={"created|server":_("You created server %s"),"changed|server":_("You changed server %s"),"removed|server":_("You removed server %s"),"turned on|server":_("You turned on server %s"),"turned off|server":_("You turned off server %s"),"added|circle":_("You added circle %s"),"changed|circle":_("You changed circle %s"),"removed|circle":_("You removed circle %s"),"restored|backup":_("You restored backup %s")}[`${n}|${e??""}`];return i?{text:i,named:!0}:n==="reset traffic history"&&/^for (.+)$/.exec(o??"")?.[1]?{text:_("You reset traffic history for %s"),named:!0}:null}var Ls=(n,e)=>n==="reset traffic history"?e.replace(/^for /,""):e;function Ms(n){let e=o=>{let s={"other addresses":_("other addresses"),certificate:_("certificate"),redirect:_("redirect"),"devices kept apart":_("devices kept apart"),"devices reach each other":_("devices reach each other"),"devices reach each other in circles":_("devices reach each other in circles"),"home network and internet path":_("home network and internet path"),"the file holds private keys":_("the file holds private keys"),"problems are only logged, nothing is repaired":_("problems are only logged, nothing is repaired"),name:_("name"),"public address":_("public address"),"AmneziaWG port":_("AmneziaWG port"),"tunnel network":_("tunnel network"),connections:Ye("connections"),people:Ye("people"),problems:Ye("problems")};if(s[o])return s[o];let r;return(r=/^port (\d+)$/.exec(o))?m(_("port %s"),r[1]):(r=/^address (.+)$/.exec(o))?m(_("address %s"),r[1]):(r=/^disguise: (.+)$/.exec(o))?m(_("disguise: %s"),r[1]):(r=/^(\d+) events?$/.exec(o))?W(Number(r[1]),"%s event","%s events"):(r=/^older than (\d+) days$/.exec(o))?W(Number(r[1]),"older than %s day","older than %s days"):(r=/^with (\d+) (person|people)$/.exec(o))?W(Number(r[1]),"with %s person","with %s people"):(r=/^(\d+) entr(y|ies)( older than (\d+) days)?$/.exec(o))?r[4]?`${W(Number(r[1]),"%s entry","%s entries")}, ${W(Number(r[4]),"older than %s day","older than %s days")}`:W(Number(r[1]),"%s entry","%s entries"):o};return n.split(" · ").map(o=>o.split(", ").map(e).join(", ")).join(" · ")}var ci=null,pi=new Set(co);function mi(){return ci??(ci=co.filter(n=>/%[sd]/.test(n)&&n.replace(/%[sd]/g,"").trim()).map(n=>({t:n,fixed:n.replace(/%[sd]/g,"").length,re:new RegExp(`^${n.split(/(%[sd])/).map(e=>e==="%s"?"(.+?)":e==="%d"?"(\\d+)":e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("")}$`)})).sort((n,e)=>e.fixed-n.fixed))}function At(n,e=0){let o=n.replace(/ — /g," - ");if(pi.has(o))return Qn(o);if(e>2)return n;for(let s of mi()){let r=s.re.exec(o);if(r)return m(Qn(s.t),...r.slice(1).map(a=>At(a,e+1)))}return o.includes(", ")?o.split(", ").map(s=>At(s,e+1)).join(", "):n}function Es(n,e=120,o=26,s=Ke(new Date)){let r=Math.max(1,...n),a=t("div",{class:"dl-spark"});return a.style.width=`${e}px`,a.style.height=`${o}px`,n.forEach((i,l)=>{let d=t("i");d.style.height=`${Math.max(6,i/r*100)}%`,i||d.classList.add("zero");let c=t("span",{},[d]),p=n.length-1-l;we(c,()=>[t("div",{class:"dl-tip-title"},p===0?_("Today"):p===1?_("Yesterday"):Mt(jt(s,-p)).toLocaleDateString(le(),{weekday:"short",day:"numeric",month:"short"})),t("div",{class:"dl-muted"},se(i))]),a.appendChild(c)}),a}function Ts(n){let e=n==null?"":String(n);return/^[=+\-@\t\r]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Ss(n,e,o){return[n.map(s=>Ts(o?.[s]??s)).join(","),...e.map(s=>n.map(r=>Ts(s[r])).join(","))].join(` -`)}function hi(n){let e=new Map(n.people.map(s=>[s.id,s.name])),o=new Map(n.people.flatMap(s=>s.devices.map(r=>[r.id,r.name])));return{people:e,devices:o}}function Qe(n,e,o,s="",r=[]){let a=hi(n),i=[...e.map(u=>({ts:u.ts,category:qt(u.type),type:u.type,person:u.person?a.people.get(u.person)??u.pname??u.person:"",device:u.device?a.devices.get(u.device)??u.dname??u.device:"",detail:u.detail??"",where:u.where??"",by:Ve(u)??""})),...r.map(u=>({ts:u.ts,category:"system",type:`${u.src}.${u.level}`,person:"",device:"",detail:`${u.who?`${u.who} `:""}${u.msg}${u.detail?` -${u.detail}`:""}`,where:Ft(u.src),by:""}))].sort((u,w)=>u.ts-w.ts).map(({ts:u,...w})=>({time:new Date(u*1e3).toISOString(),...w})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${s?`-${s}`:""}-${l}.${o}`;if(o==="json"){Ne(d,JSON.stringify(i,null,2),"application/json");return}let c=["time","category","type","person","device","detail","where","by"],p={time:_("Time"),category:_("Category"),type:_("Type"),person:_("Person"),device:_("Device"),detail:_("Detail"),where:_("Where"),by:_("By")};Ne(d,Ss(c,i,p),"text/csv")}var fi=["","7","30","90"],gi=n=>n?W(Number(n),"Older than %s day","Older than %s days"):_("Everything"),Ps=n=>n?W(n,"%s event removed","%s events removed"):_("Nothing matched");function lt(n,e,o,s,r,a=!1){let i=t("select",{class:"cbi-input-select"},[t("option",{value:""},_("All categories")),...Nt.map(d=>t("option",{value:d,selected:d===r?"selected":null},Ye(d))),a?t("option",{value:"system",selected:r==="system"?"selected":null},_("System")):""]),l=t("select",{class:"cbi-input-select"},fi.map(d=>t("option",{value:d},gi(d))));de(n,[t("p",{class:"dl-muted"},`${e} ${_("This cannot be undone; export first if you want a copy.")}`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},_("Category")),i]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},_("Which events")),l])],[ue()," ",A(_("Clear"),async()=>{let d=0;if(i.value!=="system")try{d+=(await N.logsClear({...o,category:i.value,older_days:l.value})).removed}catch(c){q(Ce(c),"error",1e4);return}if(a&&(i.value==="system"||i.value===""))try{d+=(await N.serviceLogClear(l.value)).removed}catch(c){ce();let p=m(_("The service log was not cleared: %s"),Ce(c));q(i.value==="system"?p:`${m(_("Activity: %s."),Ps(d).toLowerCase())} ${p}`,"error",1e4),s();return}ce(),q(Ps(d),"success",3e3),s()},"negative")])}function Ht(n,e,o,s){let r=n==="device"?m(_("Clears %s's daily and monthly traffic history. Their person's totals and data limit are not changed."),o):n==="person"?m(_("Clears %s's traffic history and that of their devices. Their data limit starts again from zero."),o):_("Clears traffic history for everyone. Data limits start again from zero.");de(n==="all"?_("Reset all traffic history?"):m(_("Reset traffic history for %s?"),o),[t("p",{class:"dl-muted"},r)],[ue()," ",A(_("Reset"),async()=>{await F(()=>N.usageClear(n,e),_("Traffic history reset"))&&(ce(),s())},"negative")])}function ye(n,e,o){let s=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let r=!s.classList.contains("on");uo(s,r),o?.(r)}},t("i"));return s}function uo(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var ze=n=>n.classList.contains("on");function Me(n,e,o={}){n.some(([a])=>a===e)||(n=[...n,[e,e]]);let s=t("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":e}),r=()=>s.querySelectorAll(":scope > button").forEach(a=>{let i=a.dataset.v===s.dataset.value;a.classList.toggle("on",i),a.setAttribute("aria-checked",i?"true":"false")});for(let[a,i]of n)s.appendChild(t("button",{type:"button",role:"radio","data-v":a,click:()=>{a!==s.dataset.value&&(o.optimistic!==!1&&(s.dataset.value=a,r()),o.onChange?.(a))}},i));return r(),s}function Xe(n,e,o,s={}){return t("button",{type:"button",...s,class:`dl-chipbtn${e?" on":""}${s.class?` ${s.class}`:""}`,"aria-pressed":e?"true":"false",click:o},n)}function xn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-pressed",e?"true":"false")}function he(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var vi={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},bi={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function xi(n){let e={};for(let[o,s]of Object.entries(bi))n[o]!=null&&n[o]!==""&&(e[s]=String(n[o]));return e}function wi(n,e){let o=n.amnezia,s=o.obfuscation??{},r=d=>s[d]!=null&&s[d]!==""?String(s[d]):vi[d],a=o.host.replace(/^\[(.*)\]$/,"$1"),i={H1:r("h1"),H2:r("h2"),H3:r("h3"),H4:r("h4"),I1:r("i1"),I2:r("i2"),I3:r("i3"),I4:r("i4"),I5:r("i5"),Jc:r("jc"),Jmin:r("jmin"),Jmax:r("jmax"),S1:r("s1"),S2:r("s2"),S3:r("s3"),S4:r("s4"),...xi(s),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r -`),hostName:a,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(i),port:String(o.port),protocol_version:s.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:a};return o.dns[0]&&(l.dns1=o.dns[0]),o.dns[1]&&(l.dns2=o.dns[1]),l}function yi(n){let e="";for(let o=0;o"u")return null;try{let o=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),s=new Uint8Array(await new e.Response(o).arrayBuffer()),r=new Uint8Array(4+s.length);return new DataView(r.buffer).setUint32(0,n.length,!1),r.set(s,4),r}catch{return null}}async function mo(n,e,o=!0){let s=new TextEncoder().encode(JSON.stringify(wi(n,e))),r=o?await ki(s):null;return`vpn://${yi(r??s)}`}function Ds(){return[{id:"off",title:_("Off"),ic:"zap",stealth:0,speed:4,text:_("Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block."),apps:_("Any WireGuard app"),short:_("Any WireGuard app")},{id:"balanced",title:_("Balanced"),ic:"shield",stealth:3,speed:4,needs:"v2",text:_("AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk."),apps:_("AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps"),short:_("AmneziaWG 2.0+ apps")},{id:"max",title:_("Maximum"),ic:"lock",stealth:4,speed:3,needs:"v3",text:_("AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS."),apps:_("Apps with AmneziaWG 3.1 (current AmneziaVPN)"),short:_("AmneziaWG 3.1 apps")}]}var Kt=n=>Ds().find(e=>e.id===n),wn=n=>n.v3?"max":n.v2?"balanced":"off",Yt=n=>n==="standard"?_("Standard (old)"):n==="strong"?_("Strong (old)"):null;function _i(n,e){return e?n==="v2"?_("Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on)."):_("Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."):n==="v2"?_("Needs AmneziaWG on the router."):_("Needs AmneziaWG 3.1 on the router: install it first.")}function $s(n,e){return t("span",{class:"dl-dots",title:m(_("%s: %s of 4"),e,n)},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>t("i",{class:odom.content(a,Ds().map(l=>{let d=!l.needs||n[l.needs],c=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":d?null:"true",class:`dl-method${c?" on":""}${d?"":" off"}`,click:()=>{!d||c||(e=l.id,i(),o(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},v(l.ic)),t("b",{},l.title),l.id===s?t("span",{class:"dl-pill ok"},_("Current")):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[$s(l.stealth,_("Stealth")),$s(l.speed,_("Speed"))]),t("div",{class:"dl-method-foot"},d?[v(l.id==="off"?"wireguard":"amneziawg"),t("span",{},l.apps)]:[v("alert"),t("span",{},_i(l.needs,r))])])}));return i(),a}function As(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var Ns=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function Ci(n){let e=c=>n[c]!=null&&n[c]!=="",o=Ns.filter(([c])=>e(c));if(!o.length)return null;let s=(c,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},c==="header_protection_key"?`${n[c].slice(0,6)}••••`:n[c])]),r=(c,p,u,w)=>{let M=Ns.filter(([g])=>w.includes(g)&&e(g));return M.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[v(p),t("b",{},c)]),t("p",{},u),t("div",{class:"dl-pvals"},M.map(([g,h])=>s(g,h)))]):""},a=Number(n.jc||0),i=(n.i1??"").includes("0x8580")?_("A first packet shaped like a DNS answer."):_("Extra packets sent before the handshake."),l=o.map(([c,p])=>`${p} = ${n[c]}`).join(` -`),d=t("div",{class:"dl-pgrid"},[r(_("Junk packets"),"zap",a?m(N_(a,"%s random packet of %s–%s bytes before each handshake.","%s random packets of %s–%s bytes before each handshake."),K(a),n.jmin,n.jmax):_("No junk packets."),["jc","jmin","jmax"]),r(_("Padding"),"archive",_("Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard."),["s1","s2","s3","s4"]),r(_("Packet types"),"key",_("The values that replace WireGuard’s recognisable message types."),["h1","h2","h3","h4"]),r(_("Signatures"),"globe",i,["i1","i2","i3","i4","i5"]),r(_("Protection"),"lock",_("AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets."),["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),r(_("Timing"),"clock",_("Handshake and key timers vary within these ranges instead of WireGuard’s fixed values."),["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},_("Current parameters")),t("span",{class:"dl-pcount"},String(o.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:c=>{c.preventDefault(),xe(l,_("Parameters copied"))}},_("Copy as config"))]),d])}function Hs(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!o)return document.createTextNode(n);let s=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},o[1])," ",s&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function Li(n){let e=!1,o=t("pre",{class:"dl-conf"}),s=()=>dom.content(o,n.conf.split(` +var Ba=Object.create;var Vo=Object.defineProperty;var Oa=Object.getOwnPropertyDescriptor;var ja=Object.getOwnPropertyNames;var Ua=Object.getPrototypeOf,Wa=Object.prototype.hasOwnProperty;var Ga=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var qa=(n,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ja(e))!Wa.call(n,r)&&r!==o&&Vo(n,r,{get:()=>e[r],enumerable:!(s=Oa(e,r))||s.enumerable});return n};var Fa=(n,e,o)=>(o=n!=null?Ba(Ua(n)):{},qa(e||!n||!n.__esModule?Vo(o,"default",{value:n,enumerable:!0}):o,n));var is=Ga((rs,as)=>{"use strict";var ss=(function(){var n=function(E,$){var b=236,k=17,y=E,I=o[$],w=null,f=0,T=null,C=[],D={},F=function(R,O){f=y*4+17,w=(function(P){for(var U=new Array(P),A=0;A=7&&ne(R),T==null&&(T=J(y,I,C)),se(T,O)},Y=function(R,O){for(var P=-1;P<=7;P+=1)if(!(R+P<=-1||f<=R+P))for(var U=-1;U<=7;U+=1)O+U<=-1||f<=O+U||(0<=P&&P<=6&&(U==0||U==6)||0<=U&&U<=6&&(P==0||P==6)||2<=P&&P<=4&&2<=U&&U<=4?w[R+P][O+U]=!0:w[R+P][O+U]=!1)},ee=function(){for(var R=0,O=0,P=0;P<8;P+=1){F(!0,P);var U=r.getLostPoint(D);(P==0||R>U)&&(R=U,O=P)}return O},B=function(){for(var R=8;R>P&1)==1;w[Math.floor(P/3)][P%3+f-8-3]=U}for(var P=0;P<18;P+=1){var U=!R&&(O>>P&1)==1;w[P%3+f-8-3][Math.floor(P/3)]=U}},fe=function(R,O){for(var P=I<<3|O,U=r.getBCHTypeInfo(P),A=0;A<15;A+=1){var G=!R&&(U>>A&1)==1;A<6?w[A][8]=G:A<8?w[A+1][8]=G:w[f-15+A][8]=G}for(var A=0;A<15;A+=1){var G=!R&&(U>>A&1)==1;A<8?w[8][f-A-1]=G:A<9?w[8][15-A-1+1]=G:w[8][15-A-1]=G}w[f-8][8]=!R},se=function(R,O){for(var P=-1,U=f-1,A=7,G=0,te=r.getMaskFunction(O),X=f-1;X>0;X-=2)for(X==6&&(X-=1);;){for(var be=0;be<2;be+=1)if(w[U][X-be]==null){var Le=!1;G>>A&1)==1);var ae=te(U,X-be);ae&&(Le=!Le),w[U][X-be]=Le,A-=1,A==-1&&(G+=1,A=7)}if(U+=P,U<0||f<=U){U-=P,P=-P;break}}},j=function(R,O){for(var P=0,U=0,A=0,G=new Array(O.length),te=new Array(O.length),X=0;X=0?qo.getAt(Fo):0}}for(var Ko=0,ae=0;aeX*8)throw"code length overflow. ("+A.getLengthInBits()+">"+X*8+")";for(A.getLengthInBits()+4<=X*8&&A.put(0,4);A.getLengthInBits()%8!=0;)A.putBit(!1);for(;!(A.getLengthInBits()>=X*8||(A.put(b,8),A.getLengthInBits()>=X*8));)A.put(k,8);return j(A,U)};D.addData=function(R,O){O=O||"Byte";var P=null;switch(O){case"Numeric":P=c(R);break;case"Alphanumeric":P=p(R);break;case"Byte":P=u(R);break;case"Kanji":P=v(R);break;default:throw"mode:"+O}C.push(P),T=null},D.isDark=function(R,O){if(R<0||f<=R||O<0||f<=O)throw R+","+O;return w[R][O]},D.getModuleCount=function(){return f},D.make=function(){if(y<1){for(var R=1;R<40;R++){for(var O=l.getRSBlocks(R,I),P=d(),U=0;U"u"?R*4:O;var P="";P+='";for(var A=0;A';P+=""}return P+="",P+="
",P},D.createSvgTag=function(R,O,P,U){var A={};typeof arguments[0]=="object"&&(A=arguments[0],R=A.cellSize,O=A.margin,P=A.alt,U=A.title),R=R||2,O=typeof O>"u"?R*4:O,P=typeof P=="string"?{text:P}:P||{},P.text=P.text||null,P.id=P.text?P.id||"qrcode-description":null,U=typeof U=="string"?{text:U}:U||{},U.text=U.text||null,U.id=U.text?U.id||"qrcode-title":null;var G=D.getModuleCount()*R+O*2,te,X,be,Le,ae="",Re;for(Re="l"+R+",0 0,"+R+" -"+R+",0 0,-"+R+"z ",ae+=''+ie(U.text)+"":"",ae+=P.text?''+ie(P.text)+"":"",ae+='',ae+='"u"?R*4:O;var P=D.getModuleCount()*R+O*2,U=O,A=P-O;return z(P,P,function(G,te){if(U<=G&&G"u"?R*4:O;var U=D.getModuleCount()*R+O*2,A="";return A+="",A};var ie=function(R){for(var O="",P=0;P":O+=">";break;case"&":O+="&";break;case'"':O+=""";break;default:O+=U;break}}return O},ve=function(R){var O=1;R=typeof R>"u"?O*2:R;var P=D.getModuleCount()*O+R*2,U=R,A=P-R,G,te,X,be,Le,ae={"██":"█","█ ":"▀"," █":"▄"," ":" "},Re={"██":"▀","█ ":"▀"," █":" "," ":" "},Ie="";for(G=0;G=A?Re[Le]:ae[Le];Ie+=` +`}return P%2&&R>0?Ie.substring(0,Ie.length-P-1)+Array(P+1).join("▀"):Ie.substring(0,Ie.length-1)};return D.createASCII=function(R,O){if(R=R||1,R<2)return ve(O);R-=1,O=typeof O>"u"?R*2:O;var P=D.getModuleCount()*R+O*2,U=O,A=P-O,G,te,X,be,Le=Array(R+1).join("██"),ae=Array(R+1).join(" "),Re="",Ie="";for(G=0;G>>8),I.push(T&255)):I.push(k)}}return I}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},s={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var E=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],$=1335,b=7973,k=21522,y={},I=function(w){for(var f=0;w!=0;)f+=1,w>>>=1;return f};return y.getBCHTypeInfo=function(w){for(var f=w<<10;I(f)-I($)>=0;)f^=$<=0;)f^=b<5&&(T+=3+F-5)}for(var C=0;C=256;)y-=255;return E[y]},k})();function i(E,$){if(typeof E.length>"u")throw E.length+"/"+$;var b=(function(){for(var y=0;y"u")throw"bad rs block @ typeNumber:"+y+"/errorCorrectionLevel:"+I;for(var f=w.length/3,T=[],C=0;C>>7-k%8&1)==1},b.put=function(k,y){for(var I=0;I>>y-I-1&1)==1)},b.getLengthInBits=function(){return $},b.putBit=function(k){var y=Math.floor($/8);E.length<=y&&E.push(0),k&&(E[y]|=128>>>$%8),$+=1},b},c=function(E){var $=e.MODE_NUMBER,b=E,k={};k.getMode=function(){return $},k.getLength=function(w){return b.length},k.write=function(w){for(var f=b,T=0;T+2>>8&255)*192+(C&255),w.put(C,13),T+=2}if(T>>8)},$.writeBytes=function(b,k,y){k=k||0,y=y||b.length;for(var I=0;I0&&(b+=","),b+=E[k];return b+="]",b},$},x=function(){var E=0,$=0,b=0,k="",y={},I=function(f){k+=String.fromCharCode(w(f&63))},w=function(f){if(!(f<0)){if(f<26)return 65+f;if(f<52)return 97+(f-26);if(f<62)return 48+(f-52);if(f==62)return 43;if(f==63)return 47}throw"n:"+f};return y.writeByte=function(f){for(E=E<<8|f&255,$+=8,b+=1;$>=6;)I(E>>>$-6),$-=6},y.flush=function(){if($>0&&(I(E<<6-$),E=0,$=0),b%3!=0)for(var f=3-b%3,T=0;T=$.length){if(y==0)return-1;throw"unexpected end of file./"+y}var f=$.charAt(b);if(b+=1,f=="=")return y=0,-1;if(f.match(/^\s$/))continue;k=k<<6|w(f.charCodeAt(0)),y+=6}var T=k>>>y-8&255;return y-=8,T};var w=function(f){if(65<=f&&f<=90)return f-65;if(97<=f&&f<=122)return f-97+26;if(48<=f&&f<=57)return f-48+52;if(f==43)return 62;if(f==47)return 63;throw"c:"+f};return I},S=function(E,$){var b=E,k=$,y=new Array(E*$),I={};I.setPixel=function(C,D,F){y[D*b+C]=F},I.write=function(C){C.writeString("GIF87a"),C.writeShort(b),C.writeShort(k),C.writeByte(128),C.writeByte(0),C.writeByte(0),C.writeByte(0),C.writeByte(0),C.writeByte(0),C.writeByte(255),C.writeByte(255),C.writeByte(255),C.writeString(","),C.writeShort(0),C.writeShort(0),C.writeShort(b),C.writeShort(k),C.writeByte(0);var D=2,F=f(D);C.writeByte(D);for(var Y=0;F.length-Y>255;)C.writeByte(255),C.writeBytes(F,Y,255),Y+=255;C.writeByte(F.length-Y),C.writeBytes(F,Y,F.length-Y),C.writeByte(0),C.writeString(";")};var w=function(C){var D=C,F=0,Y=0,ee={};return ee.write=function(B,Q){if(B>>>Q)throw"length over";for(;F+Q>=8;)D.writeByte(255&(B<>>=8-F,Y=0,F=0;Y=B<0&&D.writeByte(Y)},ee},f=function(C){for(var D=1<>6,128|a&63):a<55296||a>=57344?s.push(224|a>>12,128|a>>6&63,128|a&63):(r++,a=65536+((a&1023)<<10|o.charCodeAt(r)&1023),s.push(240|a>>18,128|a>>12&63,128|a>>6&63,128|a&63))}return s}return e(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof rs=="object"&&(as.exports=n())})(function(){return ss})});function Qn(n,e){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(o=>Qn(o,e)):e.push(n instanceof Node?n:String(n))),e}function t(n,e,o){let s=window.E,r=e!=null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Node);return!r&&o===void 0?s(n,{},Qn(e,[])):s(n,r?e:{},Qn(o,[]))}var Yo={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function _t(n,e="dl-icon"){let o=Yo[n]??Yo.phone;return``}function g(n,e="dl-icon"){let o=document.createElement("span");return o.className="dl-icon-wrap",o.innerHTML=_t(n,e),o}function q(n,e="info",o=0){let s=document.querySelector(".dl-toasts");s||(s=t("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(s));let r=e==="error"?"x":e==="warning"?"alert":e==="success"?"check":null,a=()=>{i.classList.remove("show"),setTimeout(()=>i.remove(),200)},i=t("div",{class:`dl-toast ${e}`},[r?g(r):"",t("span",{},n),e==="error"?t("button",{type:"button","aria-label":_("Close"),click:a},g("x")):""]);s.appendChild(i),requestAnimationFrame(()=>i.classList.add("show")),setTimeout(a,o||(e==="error"?8e3:e==="warning"?5e3:2600))}function Ce(n){return n instanceof Error?n.message:String(n)}async function K(n,e){try{let o=await n();return e&&q(e,"success",3500),o}catch(o){q(Ce(o),"error",1e4);return}}function Jo(n){try{let e=n();e&&typeof e.then=="function"&&e.catch(o=>q(Ce(o),"error"))}catch(e){q(Ce(e),"error")}}function Xn(){return(typeof document>"u"?"":document.documentElement.lang)||"en"}function le(){let n=Xn();return n==="en"?"en-GB":n}function m(n,...e){let o=0;return n.replace(/%([%sd])/g,(s,r)=>r==="%"?"%":String(e[o++]??""))}function V(n,e){return n.toLocaleString(le(),e===void 0?void 0:{minimumFractionDigits:e,maximumFractionDigits:e})}function W(n,e,o){return m(N_(n,e,o),V(n))}function oe(n,...e){let o=0;return n.split(/(%[%sd])/).filter(Boolean).map(s=>s==="%%"?"%":s==="%s"||s==="%d"?e[o++]:s)}var eo=n=>_(n);function Zo(n){if(n&&typeof n=="object"){if(typeof n.error=="string")throw new Error(n.error);typeof n.warning=="string"&&n.warning&&q(n.warning,"warning",12e3)}return n}function Z(n,e=[]){let o=rpc.declare({object:"luci.dawnline",method:n,params:[...e,"lang"]});return async(...s)=>Zo(await o(...e.map((r,a)=>s[a]),Xn()))}var Ka=Z("logs_clear",["person","device","category","older_days"]),Va=(n={})=>Ka(n.person??"",n.device??"",n.category??"",n.older_days??""),Ya=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets","server"]});async function Ja(n,e){let s=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(r=>e[r]),e.paused,e.services,e.circle,e.home_nets,e.server];return Zo(await Ya(...s))}var Za=Z("status",["days"]),H={rev:Z("rev"),personUpdate:Ja,settingsGet:Z("settings_get"),portalInfo:Z("portal_info"),settingsUpdate:Z("settings_update",["values"]),serviceSet:Z("service_set",["id","name","address","ports"]),serviceDelete:Z("service_delete",["id"]),geoClear:Z("geo_clear"),events:Z("events",["limit","person","since"]),logsClear:Va,interfaces:Z("interfaces",["id"]),serverInterfaces:Z("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:Z("circle_set",["id","server","name","color","members"]),circleDelete:Z("circle_delete",["id"]),accessCheck:Z("access_check",["from","to"]),homeHosts:Z("home_hosts",["id"]),usageClear:Z("usage_clear",["scope","id"]),uninstall:Z("uninstall",["confirm"]),status:Za,setupDefaults:Z("setup_defaults"),serverCreate:Z("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:Z("server_obfuscation",["id","preset"]),serverUpdate:Z("server_update",["id","values"]),serverPorts:Z("server_ports",["id"]),endpointProbe:Z("endpoint_probe",["host","id","port"]),serverDelete:Z("server_delete",["id"]),personLinks:Z("person_links",["id"]),personCreate:Z("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:Z("person_pause",["id","paused"]),personRegen:Z("person_regen",["id","remove"]),personDelete:Z("person_delete",["id"]),personUsage:Z("person_usage",["id","days"]),deviceCreate:Z("device_create",["person","name","kind"]),deviceConfig:Z("device_config",["id"]),deviceUpdate:Z("device_update",["id","name","disabled"]),deviceDelete:Z("device_delete",["id"]),deviceRotate:Z("device_rotate",["id"]),apply:Z("apply"),health:Z("health"),healthFix:Z("health_fix",["id"]),serviceLog:Z("service_log"),serviceLogClear:Z("service_log_clear",["older_days"]),backupList:Z("backup_list"),backupCreate:Z("backup_create"),backupRestore:Z("backup_restore",["name"]),backupDelete:Z("backup_delete",["name"]),backupRead:Z("backup_read",["name"]),backupUpload:Z("backup_upload",["data"]),exportJson:Z("export"),importJson:Z("import",["data"]),updatesStatus:Z("updates_status"),updatesRun:Z("updates_run",["what"]),updatesReleases:Z("updates_releases",["page"]),updatesNotes:Z("updates_notes",["component","tag","build"]),updatesChanges:Z("updates_changes",["from","to"])};function N(n,e,o="neutral",s={}){let{disabled:r,...a}=s,i=t("button",{class:`cbi-button cbi-button-${o}`,type:"button",...a,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!i.disabled){i.disabled=!0,i.classList.add("spinning");try{await e(l)}catch(d){q(Ce(d),"error")}finally{i.disabled=!1,i.classList.remove("spinning")}}}},n);return i.disabled=!!r,i}function Pe(n,e,o,s="neutral",r=""){return N([g(n),t("span",{class:"dl-btn-label"},e)],o,s,{title:e,class:`cbi-button cbi-button-${s} dl-icon-btn ${r}`.trim()})}function Ee(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var Ct=null;function to(n=!1){let e=Ct;Ct=null,e?.(n)}function de(n,e,o,s=""){to();let r=t("div",{class:`dl-modal ${s}`},e),a=t("div",{class:"button-row"},o);r.addEventListener("keydown",i=>{if(i.key==="Escape"){i.preventDefault(),i.stopPropagation(),ce();return}if(i.key!=="Enter"||i.shiftKey||i.ctrlKey||i.metaKey||i.altKey)return;let l=i.target;if(!l||["TEXTAREA","BUTTON","SELECT","A"].includes(l.tagName))return;let d=a.querySelector(".cbi-button-positive");!d||d.disabled||(i.preventDefault(),d.click())}),ui.showModal(n,[r,a])}function ce(){to(),ui.hideModal()}function ue(n=_("Cancel"),e=!1){return t("button",{class:`cbi-button ${e?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:ce},n)}function me(n,e,o=_("Confirm"),s=!1){return new Promise(r=>{de(n,e,[ue()," ",t("button",{class:`cbi-button ${s?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let a=Ct;Ct=null,ui.hideModal(),a?.(!0)}},o)]),Ct=r})}Ee(()=>{Ct&&(to(),ui.hideModal())});async function xe(n,e=_("Copied to clipboard"),o=!1){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let s=t("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(s),s.select();let r=document.execCommand("copy");if(s.remove(),!r)throw new Error(_("Copying is blocked here. Select the text and copy it by hand."))}return q(e,"success",2500),!0}catch(s){return o||q(Ce(s),"error"),!1}}function Ae(n,e,o="text/plain"){let s=globalThis,r=typeof e=="string"?new s.Blob([e],{type:o}):e,a=URL.createObjectURL(r),i=t("a",{href:a,download:n,style:"display:none"});document.body.appendChild(i),i.click(),setTimeout(()=>{URL.revokeObjectURL(a),i.remove()},1e3)}function no(n,e){return new Promise(o=>{let s=t("input",{type:"file",accept:n,style:"display:none"});s.addEventListener("cancel",()=>{s.remove(),o(null)}),s.addEventListener("change",()=>{let r=s.files?.[0];if(s.remove(),!r)return o(null);let a=new FileReader;a.onload=()=>{let i=String(a.result??"");o({name:r.name,data:e==="base64"?i.replace(/^data:[^,]*,/,""):i})},a.onerror=()=>o(null),e==="base64"?a.readAsDataURL(r):a.readAsText(r)}),document.body.appendChild(s),s.click()})}function Te(n,e){let o=document.querySelector(".dl-dd");if(o&&(o.dlClose?o.dlClose():o.remove(),o.dlAnchor===n))return;let s=t("div",{class:"dl-dd dl-root",role:"menu"},e.map(u=>u?t("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),Jo(u.run)}},[u.icon??"",t("span",{},u.label)]):t("hr")));document.body.appendChild(s);let r=n.getBoundingClientRect(),a=s.offsetWidth,i=s.offsetHeight;s.style.top=`${r.bottom+6+i>window.innerHeight-8&&r.top-6-i>8?r.top-6-i:r.bottom+6}px`,s.style.left=`${Math.max(8,Math.min(r.right-a,window.innerWidth-a-8))}px`;let l=u=>{!s.contains(u.target)&&!n.contains(u.target)&&p()},d=u=>{if(u.key==="Escape"||u.key==="Tab")return p();let v=[...s.querySelectorAll("button:not([disabled])")];if(!v.length||!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;u.preventDefault();let M=v.indexOf(document.activeElement),x=u.key==="Home"?0:u.key==="End"?v.length-1:u.key==="ArrowDown"?(M+1)%v.length:(M-1+v.length)%v.length;v[x].focus({preventScroll:!0})},c=Ee(p);s.dlAnchor=n,s.dlClose=p;function p(){s.remove(),c(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",p,!0)}),s.querySelector("button")?.focus({preventScroll:!0})}var gt=null,nt=null,oo=0;function Lt(){gt&&(gt.style.display="none"),nt=null,clearInterval(oo),oo=0}function we(n,e){let o=s=>{gt??(gt=document.body.appendChild(t("div",{class:"dl-tip dl-tip-float dl-root"}))),gt.replaceChildren(...e().map(r=>typeof r=="string"?document.createTextNode(r):r)),gt.style.display="",gt.style.left=`${s.clientX}px`,gt.style.top=`${s.clientY-10}px`,nt=n,oo||(oo=window.setInterval(()=>{(!nt?.isConnected||!nt.getClientRects().length)&&Lt()},400))};n.addEventListener("mouseenter",o),n.addEventListener("mousemove",o),n.addEventListener("mouseleave",Lt),n.addEventListener("pointerup",s=>{s.pointerType!=="mouse"&&(nt===n?Lt():o(s))})}Ee(Lt);window.addEventListener("scroll",()=>nt&&Lt(),{capture:!0,passive:!0});document.addEventListener("pointerdown",n=>{nt&&!nt.contains(n.target)&&Lt()},!0);function Qa(n,e,o){let s=0;for(;n>=o&&s=100||s===0?V(Math.round(n)):V(n,1)} ${e[s]}`}function re(n){return Qa(!n||n<0?0:n,[_("B"),_("KB"),_("MB"),_("GB"),_("TB")],1024)}function qe(n){let e=n*8,o=[_("bit/s"),_("kbit/s"),_("Mbit/s"),_("Gbit/s")];if(e<1e3)return`${V(Math.round(e))} ${o[0]}`;let s=e<1e6?1:e<1e9?2:3,r=e/1e3**s;return`${V(r,s===3||r<10?1:0)} ${o[s]}`}function pe(n,e=Date.now()/1e3){if(!n)return _("never");let o=Math.max(0,Math.round(e-n));return o<60?_("just now"):o<3600?m(_("%s min ago"),Math.floor(o/60)):o<86400?m(_("%s h ago"),Math.floor(o/3600)):o<86400*30?m(_("%s d ago"),Math.floor(o/86400)):new Date(n*1e3).toLocaleDateString(le(),{day:"numeric",month:"short",year:"numeric"})}function ot(n){if(!n||n<0)return"—";let e=Math.floor(n/86400),o=Math.floor(n%86400/3600),s=Math.floor(n%3600/60);return e?m(_("%sd %sh"),e,o):o?m(_("%sh %sm"),o,s):m(_("%sm"),s)}function Wt(n){let e=new Date(n*1e3),o=new Date,s=e.toDateString()===o.toDateString(),r=e.toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"});return s?r:`${e.toLocaleDateString(le(),{day:"numeric",month:"short"})} ${r}`}function Fe(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function Et(n){let[e,o,s]=n.split("-").map(Number);return new Date(e,(o||1)-1,s||1,12)}function Be(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?Et(n):new Date(n):n).toLocaleDateString(le(),{day:"numeric",month:"short",year:"numeric"})}function $e(n){return n?Be(n):""}function so(n,e){let o=s=>{let[r,a,i]=s.split("-").map(Number);return Date.UTC(r,a-1,i)};return Math.round((o(n)-o(e))/864e5)}function Ut(n,e){let o=Et(n);return o.setDate(o.getDate()+e),Fe(o)}function Mt(n,e){let[o,s,r]=n.split("-").map(Number),a=new Date(o,s-1+e,1,12),i=new Date(a.getFullYear(),a.getMonth()+1,0).getDate();return a.setDate(Math.min(r,i)),Fe(a)}function We(n){return n?.length?n[n.length-1].day:Fe(new Date)}function Qo(n,e,o,s,r=30){let a=n||s;return e==="day"?Ut(a,o):e==="week"?Ut(a,7*o):e==="month"?Mt(a,o):e==="year"?Mt(a,12*o):Ut(a,r*o)}function st(n,e=Date.now()){if(!n)return null;let o=typeof e=="number"?Fe(new Date(e)):e,s=so(n,o);return s>=0?s+1:s}function rt(n,e){return e!=null&&e>0&&n.expire_warn>0&&e<=n.expire_warn}function dn(n){return n<=1?_("ends today"):n===2?_("ends tomorrow"):W(n,"ends in %s day","ends in %s days")}function Tt(n){return n<1024?`${V(n)} ${_("B")}`:n<1048576?`${V(n/1024,n<10240?1:0)} ${_("KB")}`:`${V(n/1048576,1)} ${_("MB")}`}function vt(n){return{lan:_("Home network"),internet:_("Internet"),both:_("Home network + Internet")}[n]}var Xo=["computer","phone","tablet","router","other"];function at(n){return{computer:_("PC"),phone:_("Phone"),tablet:_("Tablet"),router:_("Router"),other:_("Other")}[n]}function es(n){return{active:_("Active"),paused:_("Paused"),expired:_("Expired"),quota:_("Data limit reached"),hours:_("Outside allowed hours"),no_server:_("No server"),server_off:_("Server is turned off")}[n]}function Oe(n){let e=n.trim().split(/\s+/).filter(Boolean);if(!e.length)return"?";let o=e[0][0]??"",s=e.length>1?e[e.length-1][0]??"":e[0][1]??"";return(o+s).toUpperCase()}function cn(n){let e=o=>o.disabled?3:o.online?0:o.handshake?1:2;return n.map((o,s)=>[o,s]).sort((o,s)=>e(o[0])-e(s[0])||o[1]-s[1]).map(([o])=>o)}function Se(n,e,o){return t("span",{class:`dl-pill ${n}`,title:o??null},e)}function Xa(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function ei(n){return n.state==="server_off"&&n.paused?"paused":n.state}function ts(n){let e=ei(n);return e==="active"||e==="server_off"?"":Se(Xa({...n,state:e}),es(e))}function ns(n){let e=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],o=t("span",{class:"dl-access","aria-label":vt(n.access)},e.map(s=>t("span",{class:`dl-ibadge ${s}`},g(s==="lan"?"home":"globe"))));return we(o,()=>[t("div",{class:"dl-tip-title"},vt(n.access)),n.access==="lan"&&n.services?.length?t("div",{class:"dl-muted"},W(n.services.length,"%s home service only","%s home services only")):""]),o}function ti(n){return{active:null,paused:_("Paused"),expired:_("Access ended"),quota:_("Data limit"),hours:_("Outside hours"),server_off:_("Server off"),no_server:_("No server")}[n]}function pn(n,e,o=_("Not set up yet"),s){let r=new Date(n.handshake*1e3).toLocaleString(le()),a=n.handshake?`${m(_("Last seen %s"),pe(n.handshake,e))} · ${r}`:"";if(n.disabled)return t("span",{class:"dl-dstat",title:a},_("Disabled"));if(n.online)return t("span",{class:"dl-dstat ok"},_("Connected"));let i=s&&ti(s.state);return i?t("span",{class:"dl-dstat warn",title:a||_("Not connected yet")},i):n.handshake?t("span",{class:"dl-dstat",title:r},m(_("Last seen %s"),pe(n.handshake,e))):t("span",{class:"dl-dstat warn",title:_("Waiting for the first connection")},o)}var un=null;function os(n,e,o,s){un?.close();let r=t("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[t("div",{class:"dl-drawer-head"},[n,t("button",{type:"button",class:"dl-drawer-x","aria-label":_("Close"),click:()=>c()},g("x"))]),t("div",{class:"dl-drawer-body"},e),o?t("div",{class:"dl-drawer-foot"},o):""]),a=t("div",{class:"dl-drawer-overlay dl-root",click:u=>{u.target===a&&c()}},r),i=u=>{u.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&c()},l=!1,d=Ee(()=>c());function c(){l||(l=!0,d(),document.removeEventListener("keydown",i),a.classList.remove("open"),setTimeout(()=>a.remove(),220),un===p&&(un=null),s())}let p={close:c,panel:r};return document.addEventListener("keydown",i),document.body.appendChild(a),requestAnimationFrame(()=>a.classList.add("open")),un=p,p}function ge(n,e,o){return t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},n),o?t("span",{class:"dl-sub"},o):""]),t("div",{class:"dl-setrow-ctl"},e)])}function _e(n,e,o,s=e){let r=ge(n,s," "),a=r.querySelector(".dl-sub"),i=()=>{let l=o();a.textContent=l.text,a.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",i),r.refresh=i,r.help=o,i(),r}function Me(n,e,o,s=e){let r=t("div",{class:"dl-sub"}),a=t("div",{class:"cbi-value dl-live"},[t("div",{class:"cbi-value-title"},[t("label",{},n),r]),t("div",{class:"cbi-value-field"},s)]),i=()=>{let l=o();r.textContent=l.text,r.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",i),e.addEventListener("change",i),a.refresh=i,a.help=o,i(),a}function je(n,e=[]){for(let o of n){let s=o.help?.();if(s?.bad)return s.text}for(let o of e){let s=o();if(s.bad)return s.text}return null}function Gt(n,e,o,s=""){return t("section",{class:`dl-setsec ${s}`},[t("div",{class:"dl-setsec-body"},[n?t("h3",{},n):"",...e]),o.length?t("div",{class:"dl-setsec-foot"},o):""])}function ke(n,e,o,s){return t("div",{class:"dl-group"},[t("div",{class:"dl-group-head"},[t("span",{class:"dl-group-ic"},g(n)),t("span",{class:"dl-stack"},[t("b",{},e),o?t("span",{class:"dl-sub"},o):""])]),t("div",{class:"dl-group-body"},s.filter(r=>r!==""))])}function it(n,e,o,s,r){return t("div",{class:`dl-row dl-need-row ${e}`},[e?t("span",{class:"dl-need-ic"},g(n)):g(n),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-sub"},s)]),r])}function bt(n){return t("div",{class:"dl-note warn"},[g("alert"),t("span",{},n)])}function xt(n,e){let o={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return t("div",{class:`alert-message ${o}`},e)}function St(n,e=""){let o=t("div",{class:e});return o.innerHTML=n,o}var ds=Fa(is(),1),ni=n=>``,ls="#0a0a0a",oi="#f2f2f2",si={night:[ls,oi],day:["#ffffff",ls]},ri=n=>n.length>300,Pt=n=>+n.toFixed(2);function ro(n,e,o,s,r){return`M${Pt(n+r)} ${Pt(e)}h${Pt(o-2*r)}a${r} ${r} 0 0 1 ${r} ${r}v${Pt(s-2*r)}a${r} ${r} 0 0 1 -${r} ${r}h-${Pt(o-2*r)}a${r} ${r} 0 0 1 -${r} -${r}v-${Pt(s-2*r)}a${r} ${r} 0 0 1 ${r} -${r}z`}function mn(n,e=3,o=!0,s="plain"){let r=ri(n),a=s!=="plain",[i,l]=a?si[s]:["#fff","#000"],d=(0,ds.default)(0,r?"L":"H");d.addData(n,"Byte"),d.make();let c=d.getModuleCount(),p=c+e*2,u=o&&!r?Math.round(c*.22):0;u&&(c-u)%2&&u++;let v=(c-u)/2,M=v+u,x=(b,k)=>u>0&&b>=v&&b=v&&ka&&(k<7&&b<7||k<7&&b>=c-7||k>=c-7&&b<7),S="";if(a){let b=r?.48:.42;for(let k=0;k${ni(a?i:"#fff")}`}let $=``;return a?`${$}${E}`:`${$}${E}`}function wt(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function hn(n){let e=wt();return St(mn(n,3,!0,e?"night":"day"),`dl-qr${e?"":" light"}`)}function ao(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(n.trim());if(!e)return null;let[o,s,r,a]=e.slice(1,5).map(Number),i=Number(e[5]);if([o,s,r,a].some(c=>c>255)||i<8||i>30)return null;let l=o*2**24+s*2**16+r*2**8+a,d=2**(32-i);return{net:l-l%d,size:d}}var ai=(n,e)=>n.netao(n));function Dt(n){return n.split("/")[0].split(".").slice(0,3).join(".")}function fn(n){return`${n.trim()}.0/24`}function lo(n,e,o){let s=n.trim(),r=/^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(s)?ao(fn(s)):null;if(!r)return{text:_("Three numbers, like 10.77.0."),bad:!0};if(!ii.some(i=>r.net>=i.net&&r.net+r.size<=i.net+i.size))return{text:_("Use a private range: 10.x.x, 172.16–31.x or 192.168.x."),bad:!0};let a=e.find(i=>{let l=ao(i.cidr);return l!=null&&ai(r,l)});if(a){let i=a.cidr.endsWith("/24")?`${Dt(a.cidr)}.x`:a.cidr,l=m(_("%s already uses %s."),a.name,i);return{text:o&&o!==s?`${l} ${m(_("Try %s."),o)}`:l,bad:!0}}return{text:m(_("Devices get %s – %s, the router %s."),`${s}.2`,`${s}.254`,`${s}.1`),bad:!1}}var ps=(n,e)=>e.find(o=>o.from<=n&&n<=o.to)?.who??null,li=n=>Number.isInteger(n)&&n>=1&&n<=65535;function qt(n,e,o){if(!li(n))return{text:_("Use a port from 1 to 65535."),bad:!0};let s=ps(n,e);return s?{text:m(_("Used by %s. Choose another port."),s),bad:!0}:{text:o,bad:!1}}function gn(n,e,o){let s=o?m(_("HTTPS here, plain HTTP for links on IP addresses on %s."),n+1):_("HTTPS on this port, opened on WAN."),r=qt(n,e,s);if(r.bad||!o)return r;if(n===65535)return{text:_("Links on IP addresses also need the next port: choose a lower one."),bad:!0};let a=ps(n+1,e);return a?{text:m(_("Links on IP addresses also need %s, used by %s. Choose another port."),n+1,a),bad:!0}:r}var co=n=>Array.from(n).length,cs=48,di=/[<>"\\\u0000-\u001f\u007f]/,us=(n,e)=>m(N_(n,"Up to %s character (%s now).","Up to %s characters (%s now)."),V(n),V(co(e)));function Ne(n,e=[],o=""){let s=n.trim();return s?co(n)>cs?{text:us(cs,n),bad:!0}:di.test(n)?{text:_('Names can’t contain < > " or \\.'),bad:!0}:e.some(r=>r.toLowerCase()===s.toLowerCase())?{text:m(_("“%s” already exists - pick another name."),s),bad:!0}:{text:o,bad:!1}:{text:_("Enter a name."),bad:!0}}function ms(n,e=[]){return co(n)>32?{text:us(32,n),bad:!0}:Ne(n,e,_("Shown on the person cards."))}var ci=/^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,pi=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function At(n){let e=pi.exec(n);return!!e&&e.slice(1).every(o=>Number(o)<=255)}function io(n){return/^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(n)&&!/:::/.test(n)}function $t(n,e,o=null){let s=n.trim();if(!s)return o!=null?{text:o,bad:!1}:{text:_("Enter a hostname or IP address."),bad:!0};if(/^[a-z]+:\/\//i.test(s))return{text:_("Leave out https:// - just the name."),bad:!0};if(/\/.*/.test(s))return{text:_("Just the name, without a path."),bad:!0};if(/^[^:\[]+:\d+$/.test(s))return{text:_("Just the name, without a port (the port is on AmneziaWG)."),bad:!0};if(/\s/.test(s))return{text:_("A hostname has no spaces."),bad:!0};if(s.length>253||!(ci.test(s)||At(s)||io(s)))return{text:_("Use a hostname or an IP address."),bad:!0};let r=io(s)?`[${s}]`:s;return{text:e?m(_("Devices connect to %s."),`${r}:${e}`):m(_("Links use %s."),r),bad:!1}}function hs(n,e){let o=n.split(/[ ,]+/).filter(Boolean);if(!o.length)return{text:m(_("This router (%s): queries go where your home network sends them, and home names work."),e),bad:!1};let s=o.find(a=>!At(a)&&!io(a));if(s)return{text:m(_("“%s” is not an IP address. Separate several with commas."),s),bad:!0};let r=new Intl.ListFormat(le(),{type:"conjunction"}).format(o);return{text:m(_("Devices use %s - home names and your LAN’s DNS filters no longer apply to them."),r),bad:!1}}function fs(n,e){let o=n.trim();if(!o)return{text:m(_("Automatic by device type and disguise: %s for computers and routers, %s for phones and tablets."),e.computer,e.phone),bad:!1};if(!/^\d{1,4}$/.test(o)||Number(o)<1280||Number(o)>1500)return{text:_("MTU must be 1280–1500, or empty for automatic."),bad:!0};let s=Number(o);return{text:m(_("Computers and routers get %s, phones and tablets %s."),s,Math.min(s,1280)),bad:!1}}function gs(n){let e=n.trim();return e?!/^\d{1,3}$/.test(e)||Number(e)>600?{text:_("Use 0–600 seconds."),bad:!0}:Number(e)===0?{text:_("Off: NAT may close the tunnel when idle, and “Connected” lags."),bad:!1}:{text:m(_("Devices send a packet every %s s to keep NAT open (a little battery on phones)."),e),bad:!1}:{text:_("Default: a packet every 25 s keeps NAT open and “Connected” accurate."),bad:!1}}function vn(n,e=0){let o=n.trim();if(!/^\d{1,2}$/.test(o)||Number(o)<1||Number(o)>32)return{text:_("Use 1–32."),bad:!0};let s=Number(o);return e>s?{text:e-s===1?m(N_(e,"Already has %s device: remove one first, or allow more.","Already has %s devices: remove one first, or allow more."),V(e)):m(N_(e,"Already has %s device: remove %s first, or allow more.","Already has %s devices: remove %s first, or allow more."),V(e),V(e-s)),bad:!0}:{text:W(s,"They can add %s device themselves.","They can add %s devices themselves."),bad:!1}}function bn(n,e=!0){let o=n.trim();if(!o)return{text:_("Optional. No data limit."),bad:!1};let s=Number(o);return!/^\d+(\.\d+)?$/.test(o)||s<0||s>1e5?{text:_("A number of GB, up to 100000."),bad:!0}:s===0?{text:_("Optional. No data limit."),bad:!1}:{text:m(e?_("Paused after %s GB this month, resumed on the 1st."):_("Paused after %s GB in total."),V(s)),bad:!1}}function vs(n,e,o,s){let r=n.trim();if(!r)return{text:_("Optional. No end date."),bad:!1};let a=o(r,e);return a==null?{text:_("Use a date."),bad:!0}:a<0?{text:_("That date has passed: access would end at once."),bad:!0}:{text:a===1?m(_("Access ends today (%s)."),s(r)):m(N_(a,"Access ends in %s day (%s).","Access ends in %s days (%s)."),V(a),s(r)),bad:!1}}function bs(n,e=null){let o=n.trim();return o?At(o)?e&&!e(o)?{text:m(_("%s is not in any home network of this server: nobody would reach it."),o),bad:!1}:{text:"",bad:!1}:{text:_("Use an IPv4 address, like 192.168.1.10."),bad:!0}:{text:_("The device’s address at home."),bad:!0}}function xs(n){let e=n.split(/[ ,]+/).filter(Boolean);if(!e.length)return{text:_("All ports."),bad:!1};let o=e.find(s=>!/^\d{1,5}$/.test(s)||Number(s)<1||Number(s)>65535);return o?{text:m(_("“%s” is not a port (1–65535)."),o),bad:!0}:{text:m(N_(e.length,"Port %s.","Ports %s."),e.join(", ")),bad:!1}}function ws(n){let e=n.trim();return e?/^https?:\/\//i.test(e)?e.length>300||!/^https?:\/\/[A-Za-z0-9.-]+(:[0-9]+)?(\/[^\s"'<>]*)?$/.test(e)?{text:_("Not a usable address (no spaces or quotes)."),bad:!0}:{text:_("Wrong links are sent there instead of a “Not found”."),bad:!1}:{text:_("Must start with http:// or https://."),bad:!0}:{text:_("Wrong links get a bare “Not found”."),bad:!1}}function ys(n,e="phone.myata"){let o=n.trim();return o?/^[a-z0-9-]{1,32}(\.[a-z0-9-]{1,32})*$/.test(o)?{text:m(_("Devices get names like %s."),`${e}.${o}`),bad:!1}:{text:/[A-Z]/.test(o)?_("Lowercase only."):_("Lowercase letters, digits, dashes and dots."),bad:!0}:{text:m(_("The default, lan: devices get names like %s."),`${e}.lan`),bad:!1}}function ks(n){let e=n.trim();return e?At(e)?{text:m(_("%s takes over when the tunnel is down."),e),bad:!1}:{text:_("Use an IPv4 address, or leave it empty."),bad:!0}:{text:_("None: without the tunnel those devices have no DNS."),bad:!1}}function _s(n){let e=n.trim();return/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e)?{text:m(_("Runs within an hour after %s (router time)."),e),bad:!1}:{text:_("Use HH:MM, 00:00–23:59."),bad:!0}}function po(n,e,o,s={}){let r=0,a="",i=null;return{help:()=>{let{host:c,port:p}=n(),u=$t(c,p,s.empty??null);return u.bad||!c.trim()?u:i&&i.host===c.trim()?{text:i.text,bad:i.bad}:{text:`${s.idle?.()||u.text} ${_("Checking where it points…")}`,bad:!1}},schedule:()=>{let{host:c}=n(),p=$t(c,n().port,s.empty??null);p.bad||!c.trim()||c.trim()===i?.host||(clearTimeout(r),r=window.setTimeout(async()=>{let u=c.trim();a=u;try{let{id:v,port:M}=n(),x=await e(u,v,M);if(a!==u)return;i={host:u,text:x.text,bad:x.status==="error"}}catch{if(a!==u)return;i={host:u,text:p.text,bad:!1}}o()},700))}}}var uo=["%d system package","%d system packages","%s (after %d repair)","%s (after %d repairs)","%s - %d repairs didn't help","%s - %s","%s - not repaired again (%d repairs didn't help)","%s has no IPv4 address.","%s is not a bridge, so Dawnline cannot join the LAN as a device.","%s needs a manual switch in Components","%s still give devices the old address: set the public address in the server settings (a DDNS name keeps working), then devices need new configurations.","%s still gives devices the old address: set the public address in the server settings (a DDNS name keeps working), then devices need new configurations.","%s · restored","Access rules","Activity","AmneziaWG is missing from the router","AmneziaWG is running again","AmneziaWG is running again · accepting connections on port %d","AmneziaWG isn't accepting connections on port %d","AmneziaWG isn't running","Backup","Browsers will refuse the portal after that. Renew it with ACME, or choose another certificate in Settings.","Choose another interface name in the server settings.","Components","Connections","DNS for Home-only devices","Dawnline didn't stop it: the router's network restarted, someone stopped it by hand, or it failed.","Firewall","Install it in Dawnline → Components.","Internet like a home device","MTU is now automatic","Missing: %s.","No LAN detected.","No free address on %s.","No free link-local range for the internal link.","No free routing table.","People","Personal links","Personal portal","Router","Servers","Speed","System packages","The new version did not answer in LuCI or its agent did not start. Try again from Components, or install it with install.sh to see why.","Traffic","Watchdog","Without kmod-nft-offload every packet on this path passes the firewall twice. Install it and restart Dawnline.","a new build needs a manual switch in Components","answers again","are loaded again","are missing","automatic update failed","background check failed: %s","can't reach Dawnline (luci.dawnline is missing in rpcd)","can't use the network interface %s: it exists and isn't Dawnline's","certificate expires %s","certificate expires within 7 days","certificate renewed · valid until %s","couldn't be repaired: %s","couldn't be updated - the previous rules stay, and changes to access wait until they load","couldn't load - no device is loaded into the tunnels until they do","couldn't load devices into the tunnel","couldn't start","couldn't start · %d failed attempts in %d min","failed - internet goes out directly for now","failed: %s",'has an invalid interface name "%s"',"installed the %s build","installed the %s build · %s","is kept down","is kept down: its disguise needs AmneziaWG %s (installed: %s)","is kept down: its disguise needs AmneziaWG %s (installed: none)","is off","is on · traffic enters %s as %s","is ready again","isn't answering on port %d","isn't installed: no tunnel can run - install it in Dawnline → Components","isn't installed: tunnels were left as they are","isn't known to the network service - restart the network or reboot","isn't running","isn't running on this router (fw4): tunnels and the portal are closed","kernel module isn't installed: no tunnel can run - install it in Dawnline → Components","kernel module isn't loaded","loading it","loading them again","moved to word codes","netifd reads its protocol handlers when it starts; it was running before AmneziaWG was installed.","network changed - Dawnline set itself up again","nightly backup failed: %s","public address changed · %s → %s","reaches Dawnline again","reloading rpcd","restarted · version %s","restarting for the AmneziaWG update","restarting it","restoring them","rules for Dawnline are in place again","rules for Dawnline aren't loaded","rules for Dawnline were changed or removed","runs again","runs without its fast path","setting it up again","started","started with the router · version %s","started · accepting connections on port %s","started · version %s","stopped unexpectedly","stopped unexpectedly - started again","update failed","update to %s failed its check - rolled back to %s","updated automatically · %s","updated automatically · %s → %s","updated · %s","updated · %s → %s","updates available · %s","was broken - set up again (%s as %s)"];var mi={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",expiring:"people",expired_kept:"people",portal_blocked:"problems"},Ht=["connections","people","problems"];function Ke(n){return{connections:_("Connections"),people:_("People"),problems:_("Problems")}[n]}function Cs(n){return{connections:_("Connects, disconnects and IP changes"),people:_("People and their devices added, changed, paused, removed"),problems:_("Blocked portal sign-ins (tunnels and services are in the service log)")}[n]}var Ft=n=>mi[n]??"problems";function Kt(n){return{awg:"AmneziaWG",dawnline:"Dawnline",portal:_("Portal")}[n]??n}var hi=["person_added","person_removed","person_changed"];function Ve(n){return n.by?n.by:hi.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function Ls(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var xn=n=>n.sys?["error","repair","down"].includes(n.sys.level):Ft(n.ev.type)==="problems";function wn(n){let e=n.keep_days>0?W(n.keep_days,"%s day","%s days"):_("no age limit"),o=n.persist==="off"?_("kept in memory only (lost on reboot)"):n.persist==="10min"?_("saved to flash every 10 minutes"):_("saved to flash hourly");return m(_("Kept for %s, %s, %s."),e,W(n.max,"up to %s event","up to %s events"),o)}function mo(n){return{"paused by admin":_("paused by admin"),"end date reached":_("end date reached"),"data limit reached":_("data limit reached"),"outside allowed hours":_("outside allowed hours"),"no server":_("no server"),"server turned off":_("server turned off")}[n]??n}function Ms(n){let e=/^(\d+) days?$/.exec(n);return e?Number(e[1]):null}function Es(n){let e={name:_("name"),access:_("access"),device_limit:_("device limit"),expires:_("end date"),expire_action:_("what happens at the end"),expire_warn:_("warning before the end"),quota_gb:_("data limit"),quota_period:_("data limit period"),bonus_gb:_("extra data"),hours:_("allowed hours"),dns_mode:_("DNS"),paused:_("pause"),services:_("home services"),circle:_("circle","setting"),home_nets:_("home networks"),server:_("server")};return n.split(", ").map(o=>{let s=/^moved to (.+)$/.exec(o)?.[1];return s?m(_("moved to %s"),s):e[o]??o.replace(/_/g," ")}).join(", ")}function Ts(n,e,o){let r={"cleared|the service log":_("You cleared the service log"),"cleared|the activity log":_("You cleared the activity log"),"exported|all settings":_("You exported all settings"),"imported|settings from a file":_("You imported settings from a file"),"restored|from a file":_("You restored a backup from a file"),"turned on|the personal portal":_("You turned on the personal portal"),"turned off|the personal portal":_("You turned off the personal portal"),"changed|the personal portal":_("You changed the personal portal"),"turned on|the watchdog":_("You turned on the watchdog"),"turned off|the watchdog":_("You turned off the watchdog"),"reset traffic history|for everyone":_("You reset traffic history for everyone")}[`${n}|${o??""}`];if(r)return{text:r,named:!1};let i={"created|server":_("You created server %s"),"changed|server":_("You changed server %s"),"removed|server":_("You removed server %s"),"turned on|server":_("You turned on server %s"),"turned off|server":_("You turned off server %s"),"added|circle":_("You added circle %s"),"changed|circle":_("You changed circle %s"),"removed|circle":_("You removed circle %s"),"restored|backup":_("You restored backup %s")}[`${n}|${e??""}`];return i?{text:i,named:!0}:n==="reset traffic history"&&/^for (.+)$/.exec(o??"")?.[1]?{text:_("You reset traffic history for %s"),named:!0}:null}var Ss=(n,e)=>n==="reset traffic history"?e.replace(/^for /,""):e;function Ps(n){let e=o=>{let s={"other addresses":_("other addresses"),certificate:_("certificate"),redirect:_("redirect"),"devices kept apart":_("devices kept apart"),"devices reach each other":_("devices reach each other"),"devices reach each other in circles":_("devices reach each other in circles"),"home network and internet path":_("home network and internet path"),"the file holds private keys":_("the file holds private keys"),"problems are only logged, nothing is repaired":_("problems are only logged, nothing is repaired"),name:_("name"),"public address":_("public address"),"AmneziaWG port":_("AmneziaWG port"),"tunnel network":_("tunnel network"),connections:Ke("connections"),people:Ke("people"),problems:Ke("problems")};if(s[o])return s[o];let r;return(r=/^port (\d+)$/.exec(o))?m(_("port %s"),r[1]):(r=/^address (.+)$/.exec(o))?m(_("address %s"),r[1]):(r=/^disguise: (.+)$/.exec(o))?m(_("disguise: %s"),r[1]):(r=/^(\d+) events?$/.exec(o))?W(Number(r[1]),"%s event","%s events"):(r=/^older than (\d+) days$/.exec(o))?W(Number(r[1]),"older than %s day","older than %s days"):(r=/^with (\d+) (person|people)$/.exec(o))?W(Number(r[1]),"with %s person","with %s people"):(r=/^(\d+) entr(y|ies)( older than (\d+) days)?$/.exec(o))?r[4]?`${W(Number(r[1]),"%s entry","%s entries")}, ${W(Number(r[4]),"older than %s day","older than %s days")}`:W(Number(r[1]),"%s entry","%s entries"):o};return n.split(" · ").map(o=>o.split(", ").map(e).join(", ")).join(" · ")}var fi=null,gi=new Set(uo);function vi(){return fi??(fi=uo.filter(n=>/%[sd]/.test(n)&&n.replace(/%[sd]/g,"").trim()).map(n=>({t:n,fixed:n.replace(/%[sd]/g,"").length,re:new RegExp(`^${n.split(/(%[sd])/).map(e=>e==="%s"?"(.+?)":e==="%d"?"(\\d+)":e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("")}$`)})).sort((n,e)=>e.fixed-n.fixed))}function Nt(n,e=0){let o=n.replace(/ — /g," - ");if(gi.has(o))return eo(o);if(e>2)return n;for(let s of vi()){let r=s.re.exec(o);if(r)return m(eo(s.t),...r.slice(1).map(a=>Nt(a,e+1)))}return o.includes(", ")?o.split(", ").map(s=>Nt(s,e+1)).join(", "):n}function $s(n,e=120,o=26,s=Fe(new Date)){let r=Math.max(1,...n),a=t("div",{class:"dl-spark"});return a.style.width=`${e}px`,a.style.height=`${o}px`,n.forEach((i,l)=>{let d=t("i");d.style.height=`${Math.max(6,i/r*100)}%`,i||d.classList.add("zero");let c=t("span",{},[d]),p=n.length-1-l;we(c,()=>[t("div",{class:"dl-tip-title"},p===0?_("Today"):p===1?_("Yesterday"):Et(Ut(s,-p)).toLocaleDateString(le(),{weekday:"short",day:"numeric",month:"short"})),t("div",{class:"dl-muted"},re(i))]),a.appendChild(c)}),a}function Ds(n){let e=n==null?"":String(n);return/^[=+\-@\t\r]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function As(n,e,o){return[n.map(s=>Ds(o?.[s]??s)).join(","),...e.map(s=>n.map(r=>Ds(s[r])).join(","))].join(` +`)}function bi(n){let e=new Map(n.people.map(s=>[s.id,s.name])),o=new Map(n.people.flatMap(s=>s.devices.map(r=>[r.id,r.name])));return{people:e,devices:o}}function Ze(n,e,o,s="",r=[]){let a=bi(n),i=[...e.map(u=>({ts:u.ts,category:Ft(u.type),type:u.type,person:u.person?a.people.get(u.person)??u.pname??u.person:"",device:u.device?a.devices.get(u.device)??u.dname??u.device:"",detail:u.detail??"",where:u.where??"",by:Ve(u)??""})),...r.map(u=>({ts:u.ts,category:"system",type:`${u.src}.${u.level}`,person:"",device:"",detail:`${u.who?`${u.who} `:""}${u.msg}${u.detail?` +${u.detail}`:""}`,where:Kt(u.src),by:""}))].sort((u,v)=>u.ts-v.ts).map(({ts:u,...v})=>({time:new Date(u*1e3).toISOString(),...v})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${s?`-${s}`:""}-${l}.${o}`;if(o==="json"){Ae(d,JSON.stringify(i,null,2),"application/json");return}let c=["time","category","type","person","device","detail","where","by"],p={time:_("Time"),category:_("Category"),type:_("Type"),person:_("Person"),device:_("Device"),detail:_("Detail"),where:_("Where"),by:_("By")};Ae(d,As(c,i,p),"text/csv")}var xi=["","7","30","90"],wi=n=>n?W(Number(n),"Older than %s day","Older than %s days"):_("Everything"),Ns=n=>n?W(n,"%s event removed","%s events removed"):_("Nothing matched");function lt(n,e,o,s,r,a=!1){let i=t("select",{class:"cbi-input-select"},[t("option",{value:""},_("All categories")),...Ht.map(d=>t("option",{value:d,selected:d===r?"selected":null},Ke(d))),a?t("option",{value:"system",selected:r==="system"?"selected":null},_("System")):""]),l=t("select",{class:"cbi-input-select"},xi.map(d=>t("option",{value:d},wi(d))));de(n,[t("p",{class:"dl-muted"},`${e} ${_("This cannot be undone; export first if you want a copy.")}`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},_("Category")),i]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},_("Which events")),l])],[ue()," ",N(_("Clear"),async()=>{let d=0;if(i.value!=="system")try{d+=(await H.logsClear({...o,category:i.value,older_days:l.value})).removed}catch(c){q(Ce(c),"error",1e4);return}if(a&&(i.value==="system"||i.value===""))try{d+=(await H.serviceLogClear(l.value)).removed}catch(c){ce();let p=m(_("The service log was not cleared: %s"),Ce(c));q(i.value==="system"?p:`${m(_("Activity: %s."),Ns(d).toLowerCase())} ${p}`,"error",1e4),s();return}ce(),q(Ns(d),"success",3e3),s()},"negative")])}function zt(n,e,o,s){let r=n==="device"?m(_("Clears %s's daily and monthly traffic history. Their person's totals and data limit are not changed."),o):n==="person"?m(_("Clears %s's traffic history and that of their devices. Their data limit starts again from zero."),o):_("Clears traffic history for everyone. Data limits start again from zero.");de(n==="all"?_("Reset all traffic history?"):m(_("Reset traffic history for %s?"),o),[t("p",{class:"dl-muted"},r)],[ue()," ",N(_("Reset"),async()=>{await K(()=>H.usageClear(n,e),_("Traffic history reset"))&&(ce(),s())},"negative")])}function ye(n,e,o){let s=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let r=!s.classList.contains("on");ho(s,r),o?.(r)}},t("i"));return s}function ho(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var He=n=>n.classList.contains("on");function Qe(n,e,o={}){n.some(([a])=>a===e)||(n=[...n,[e,e]]);let s=t("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":e}),r=()=>s.querySelectorAll(":scope > button").forEach(a=>{let i=a.dataset.v===s.dataset.value;a.classList.toggle("on",i),a.setAttribute("aria-checked",i?"true":"false")});for(let[a,i]of n)s.appendChild(t("button",{type:"button",role:"radio","data-v":a,click:()=>{a!==s.dataset.value&&(o.optimistic!==!1&&(s.dataset.value=a,r()),o.onChange?.(a))}},i));return r(),s}function Vt(n,e,o,s={}){return t("button",{type:"button",...s,class:`dl-chipbtn${e?" on":""}${s.class?` ${s.class}`:""}`,"aria-pressed":e?"true":"false",click:o},n)}function Xe(n,e,o,s){return n.some(([r])=>r===e)||(n=[...n,[e,e]]),t("select",{class:"cbi-input-select","aria-label":o,change:r=>s?.(r.target.value)},n.map(([r,a])=>t("option",{value:r,selected:r===e?"selected":null},a)))}function yn(n,e,o){let s=new ui.Dropdown(e,Object.fromEntries(n),{multiple:!0,sort:n.map(([a])=>a),select_placeholder:_("None")}),r=s.render();return r.setAttribute("aria-label",o),{node:r,value:()=>s.getValue()}}function he(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var yi={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},ki={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function _i(n){let e={};for(let[o,s]of Object.entries(ki))n[o]!=null&&n[o]!==""&&(e[s]=String(n[o]));return e}function Ci(n,e){let o=n.amnezia,s=o.obfuscation??{},r=d=>s[d]!=null&&s[d]!==""?String(s[d]):yi[d],a=o.host.replace(/^\[(.*)\]$/,"$1"),i={H1:r("h1"),H2:r("h2"),H3:r("h3"),H4:r("h4"),I1:r("i1"),I2:r("i2"),I3:r("i3"),I4:r("i4"),I5:r("i5"),Jc:r("jc"),Jmin:r("jmin"),Jmax:r("jmax"),S1:r("s1"),S2:r("s2"),S3:r("s3"),S4:r("s4"),..._i(s),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r +`),hostName:a,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(i),port:String(o.port),protocol_version:s.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:a};return o.dns[0]&&(l.dns1=o.dns[0]),o.dns[1]&&(l.dns2=o.dns[1]),l}function Li(n){let e="";for(let o=0;o"u")return null;try{let o=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),s=new Uint8Array(await new e.Response(o).arrayBuffer()),r=new Uint8Array(4+s.length);return new DataView(r.buffer).setUint32(0,n.length,!1),r.set(s,4),r}catch{return null}}async function fo(n,e,o=!0){let s=new TextEncoder().encode(JSON.stringify(Ci(n,e))),r=o?await Mi(s):null;return`vpn://${Li(r??s)}`}function zs(){return[{id:"off",title:_("Off"),ic:"zap",stealth:0,speed:4,text:_("Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block."),apps:_("Any WireGuard app"),short:_("Any WireGuard app")},{id:"balanced",title:_("Balanced"),ic:"shield",stealth:3,speed:4,needs:"v2",text:_("AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk."),apps:_("AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps"),short:_("AmneziaWG 2.0+ apps")},{id:"max",title:_("Maximum"),ic:"lock",stealth:4,speed:3,needs:"v3",text:_("AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS."),apps:_("Apps with AmneziaWG 3.1 (current AmneziaVPN)"),short:_("AmneziaWG 3.1 apps")}]}var Yt=n=>zs().find(e=>e.id===n),kn=n=>n.v3?"max":n.v2?"balanced":"off",Jt=n=>n==="standard"?_("Standard (old)"):n==="strong"?_("Strong (old)"):null;function Ei(n,e){return e?n==="v2"?_("Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on)."):_("Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."):n==="v2"?_("Needs AmneziaWG on the router."):_("Needs AmneziaWG 3.1 on the router: install it first.")}function Hs(n,e){return t("span",{class:"dl-dots",title:m(_("%s: %s of 4"),e,n)},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>t("i",{class:odom.content(a,zs().map(l=>{let d=!l.needs||n[l.needs],c=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":d?null:"true",class:`dl-method${c?" on":""}${d?"":" off"}`,click:()=>{!d||c||(e=l.id,i(),o(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},g(l.ic)),t("b",{},l.title),l.id===s?t("span",{class:"dl-pill ok"},_("Current")):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[Hs(l.stealth,_("Stealth")),Hs(l.speed,_("Speed"))]),t("div",{class:"dl-method-foot"},d?[g(l.id==="off"?"wireguard":"amneziawg"),t("span",{},l.apps)]:[g("alert"),t("span",{},Ei(l.needs,r))])])}));return i(),a}function Rs(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var Is=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function Ti(n){let e=c=>n[c]!=null&&n[c]!=="",o=Is.filter(([c])=>e(c));if(!o.length)return null;let s=(c,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},c==="header_protection_key"?`${n[c].slice(0,6)}••••`:n[c])]),r=(c,p,u,v)=>{let M=Is.filter(([x])=>v.includes(x)&&e(x));return M.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[g(p),t("b",{},c)]),t("p",{},u),t("div",{class:"dl-pvals"},M.map(([x,h])=>s(x,h)))]):""},a=Number(n.jc||0),i=(n.i1??"").includes("0x8580")?_("A first packet shaped like a DNS answer."):_("Extra packets sent before the handshake."),l=o.map(([c,p])=>`${p} = ${n[c]}`).join(` +`),d=t("div",{class:"dl-pgrid"},[r(_("Junk packets"),"zap",a?m(N_(a,"%s random packet of %s–%s bytes before each handshake.","%s random packets of %s–%s bytes before each handshake."),V(a),n.jmin,n.jmax):_("No junk packets."),["jc","jmin","jmax"]),r(_("Padding"),"archive",_("Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard."),["s1","s2","s3","s4"]),r(_("Packet types"),"key",_("The values that replace WireGuard’s recognisable message types."),["h1","h2","h3","h4"]),r(_("Signatures"),"globe",i,["i1","i2","i3","i4","i5"]),r(_("Protection"),"lock",_("AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets."),["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),r(_("Timing"),"clock",_("Handshake and key timers vary within these ranges instead of WireGuard’s fixed values."),["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[g("chevron"),t("span",{},_("Current parameters")),t("span",{class:"dl-pcount"},String(o.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:c=>{c.preventDefault(),xe(l,_("Parameters copied"))}},_("Copy as config"))]),d])}function Bs(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!o)return document.createTextNode(n);let s=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},o[1])," ",s&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function Si(n){let e=!1,o=t("pre",{class:"dl-conf"}),s=()=>dom.content(o,n.conf.split(` `).flatMap((i,l)=>l?[` -`,Hs(i,e)]:[Hs(i,e)])),r=t("button",{type:"button",class:"dl-chipbtn",click:i=>{i.preventDefault(),e=!e,dom.content(r,[v(e?"x":"key"),e?_("Hide key"):_("Show key")]),s()}},[v("key"),_("Show key")]);s();let a=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${W(a,"%s byte","%s bytes")}`)]),A([v("download")," ",_("Download")],()=>Ne(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},_("Configuration")),t("span",{class:"dl-spacer"}),r,t("button",{type:"button",class:"dl-chipbtn",click:i=>{i.preventDefault(),xe(n.conf,_("Configuration copied"))}},[v("copy"),_("Copy")])]),o])])}function ho(n){let e=n.amnezia.obfuscation??{},o={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([s,r])=>r==null||r===""||r===(o[s]??"0"))}async function Mi(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},_("This device generated its own keys in the browser, so its full configuration only exists on that device."));let o=await mo(n,n.server),s={qr:()=>t("div",{class:"dl-qr-pane"},[un(n.conf),t("span",{class:"dl-sub"},ho(n)?_("Scan with AmneziaVPN or any WireGuard app on the device."):_("Scan with AmneziaVPN or AmneziaWG on the device."))]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},o),A(_("Copy"),()=>xe(o,_("Key copied")))]),t("span",{class:"dl-sub"},m(_("AmneziaVPN → %s. Keep it private."),["+",_("Insert","AmneziaVPN app"),_("Continue","AmneziaVPN app")].join(" → ")))]),file:()=>Li(n)},r=t("div",{class:"dl-connect-body"}),a=t("div",{class:"dl-seg"}),i=l=>{a.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(r,s[l]())};for(let[l,d]of[["file",_("File")],["key",_("Key")],["qr",_("QR code")]])a.appendChild(t("button",{type:"button","data-id":l,click:()=>i(l)},d));return i(e),t("div",{class:"dl-stack gap12"},[a,r])}async function Ei(n,e,o,s){let r=Kt(o),i=n.st.people.filter(d=>d.server===e.id).reduce((d,c)=>d+c.devices.length,0);await me(s?_("Generate new disguise values?"):m(_("Switch to %s?"),r.title),[W(i,"%s AmneziaWG device stops connecting until it imports its configuration again (from their personal link or from you).","%s AmneziaWG devices stop connecting until they import their configuration again (from their personal link or from you)."),o==="max"?_("They need an app with AmneziaWG 3.1."):o==="balanced"?_("They need an app with AmneziaWG 2.0 or newer."):"",n.st.servers.length===1&&i?_("To keep the old disguise for some people, add a second server and move them there."):""].filter(Boolean).join(" "),s?_("Generate and apply"):_("Switch and apply"),!0)&&await F(()=>N.serverObfuscation(e.id,o),s?_("New values applied"):m(_("%s applied"),r.title))&&(q(_("Devices are marked “Update config” until they import again."),"info",6e3),await n.refresh())}function Ti(n,e){let o=n.st,s=he(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=he(e.mtu?String(e.mtu):"",{placeholder:_("Auto"),inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=he(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=Kt(e.preset)?e.preset:void 0,l=i??wn(o.awg),d=A("",()=>Ei(n,e,l,l===i),"neutral"),c=()=>dom.content(d,l===i?[v("reset")," ",_("Generate new values")]:[m(_("Switch to %s"),Kt(l).title)]);c();let p=o.awg_state?.tools!==!1,u=[],w=_e(_("UDP port"),s,()=>Gt(Number(s.value),u,[_("Opened on the WAN firewall automatically."),Number(s.value)===4500?_("4500 is IPsec’s port: most networks let it through."):""].filter(Boolean).join(" ")));N.serverPorts(e.id).then(h=>{u=h.udp_taken??[],w.refresh()}).catch(()=>{});let M=_e("MTU",r,()=>ps(r.value,e.mtus)),g=_e(_("Keep-alive"),a,()=>us(a.value));return Wt("",[As("AmneziaWG",e.ifname),ke("globe",_("Listening"),_("Where devices reach this core from the internet"),[w]),ke("file",_("In every device configuration"),_("Changing these marks devices “Update config” until they import again"),[M,g]),ke("shield",_("Disguise"),_("So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard"),[Yt(e.preset)?bt("warn",ae(_("%s is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to %s or %s: devices import their configuration again."),t("b",{},Yt(e.preset)),t("b",{},_("Balanced")),t("b",{},_("Maximum")))):"",yn(o.awg,l,h=>{l=h,c()},i,p),p&&!o.awg.v3?bt("info",ae(_("This router runs an older AmneziaWG. %s becomes available with kmod-amneziawg and amneziawg-tools 3.1."),t("b",{},_("Maximum")))):"",Ci(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},_("Applies at once: every AmneziaWG device imports its configuration again.")),d])]),t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},_("Tunnel")),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ge(_("Interface"),t("span",{class:"dl-mono"},`${e.ifname} · ${m(_("router %s"),e.address)}`)),ge(_("Tunnel subnet"),t("span",{class:"dl-mono"},e.subnet),_("Device addresses come from it.")),ge(_("Server public key"),t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),A([v("copy")],()=>xe(e.public_key,_("Public key copied")),"neutral",{title:_("Copy"),class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},_("Port, MTU and keep-alive apply at once.")),A(_("Save"),()=>{let h=Ue([w,M,g]);if(h){q(h,"warning");return}return n.save({port:s.value,mtu:r.value,keepalive:a.value},_("AmneziaWG saved"))},"positive")])}function Si(n){let e=Kt(n.preset),o=n.obf??{},s=(i,l)=>t("span",{class:`dl-segs ${l}`},[0,1,2,3].map(d=>t("i",{class:d+o[i]).map(i=>`${i.toUpperCase()} ${o[i]}`);return a.length&&r.push(a.slice(0,2).join(" · ")+(a.length>2?` +${a.length-2}`:"")),["h1","h2","h3","h4"].some(i=>o[i]&&o[i]!==String(["h1","h2","h3","h4"].indexOf(i)+1))&&r.push(_("H1–H4 random")),o.i1&&r.push(/0x(8580|0100)0001/.test(o.i1)?_("DNS-like first packets"):_("Signature packets")),o.header_protection_key&&r.push(_("Encrypted headers")),r.length||r.push(e?.id==="off"?_("Plain WireGuard"):_("No values yet")),t("div",{class:"dl-bento-tile dl-disg"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},_("Disguise")),t("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},_("Change"))]),t("div",{class:"dl-disg-id"},[t("span",{class:`dl-disg-ic${e?.id==="off"?" off":""}`},v(e?.ic??"shield")),t("span",{class:"dl-stack"},[t("b",{},e?e.title:Yt(n.preset)??_("Custom","disguise")),t("span",{class:"dl-sub"},e?e.short:Yt(n.preset)?_("Switch to Balanced or Maximum"):_("Set by hand"))])]),e?t("div",{class:"dl-disg-meters"},[t("span",{},_("Stealth")),s(e.stealth,"acc"),t("span",{},_("Speed")),s(e.speed,"ok")]):"",t("div",{class:"dl-disg-chips"},r.map(i=>t("span",{},i)))])}var fo={id:"awg",label:"AmneziaWG",settingsCard:Ti,overviewTile:Si,connectBlock:Mi,qrText:n=>n.conf,appKey:{get label(){return _("Copy AmneziaVPN config")},make:n=>mo(n,n.server)},file:{get label(){return _("Download AmneziaWG config")},make:n=>({name:n.filename,text:n.conf})}};var Pi={awg:fo};function qe(n){return Pi[n?.core||"awg"]??fo}function zt(n,e){return qe(n.find(o=>o.id===e))}var $i=2,Vt=new Set,go=null,kn=null;async function zs(){if(document.visibilityState!=="visible"||!Vt.size)return;let n=await N.rev().catch(()=>null);if(!n)return;let e=go!=null&&n.rev!==go;go=n.rev,n.version&&(kn&&n.version!==kn?(q(m(_("Dawnline was updated to %s: reload the page."),n.version),"warning",15e3),kn=null):kn??(kn=n.version)),e&&Vt.forEach(o=>o())}function _n(n){return Vt.add(n),poll.add(zs,$i),()=>{Vt.delete(n),Vt.size||poll.remove(zs)}}function Bs(n,e,o,s,r=0){let a=[],i=null,l=p=>{i&&p>i.from&&a.push({...i,to:p}),i=null},d=n.filter(p=>p.device===e).sort((p,u)=>p.ts-u.ts);for(let p of d)if(p.type==="connect")l(p.ts),p.detail&&(i={ip:p.detail,from:p.ts,to:p.ts,live:!1});else if(p.type==="roam"){let u=p.detail?.split("→")[1]?.trim();l(p.ts),u&&(i={ip:u,from:p.ts,to:p.ts,live:!1})}else p.type==="disconnect"&&l(p.ts);let c=i;return c&&s?a.push({...c,to:Math.max(o,c.from),live:!0}):l(Math.min(o,r)),a}function et(n){return`${n.city||`${n.lat.toFixed(1)},${n.lon.toFixed(1)}`}|${n.cc}`}function Os(n,e,o,s){let r=new Map;for(let i of e)(i.device===o||!r.has(i.ip))&&r.set(i.ip,i);let a=[];for(let i of n){let l=r.get(i.ip);!l||i.to<=s||a.push({key:et(l),point:l,from:Math.max(i.from,s),to:i.to,live:i.live})}return a}function js(n){let e=new Map,o=0;for(let s of n)e.set(s.key,(e.get(s.key)??0)+(s.to-s.from)),o+=s.to-s.from;return new Map([...e].map(([s,r])=>[s,o?r/o:0]))}function Rs(n,e=2700){let o=[];for(let s of n){let r=o[o.length-1];if(r&&s.key!==r.key&&!s.live&&s.to-s.from{a&&(o.push({kind:"move",k:a,start:s,ms:e}),s+=e);let i=Math.min(1100,Math.max(350,(r.to-r.from)/3600*45));o.push({kind:"stay",k:a,start:s,ms:i}),s+=i}),{steps:o,total:s}}function qs(n,e,o){let s=e.findIndex(l=>o>=l.start&&oo>=i.from&&oi.kind==="stay"&&i.k===s),a=n[s];return r.start+r.ms*Math.min(.999,Math.max(0,(o-a.from)/Math.max(1,a.to-a.from)))}var Di=n=>n<=0?0:n>=1?1:n<.5?2*n*n:1-(-2*n+2)**2/2;function Ks(n){return-vo/2+(1+vo)*Di((n-Is)/(1-Is))}var Ys=n=>n+Ws>=1;function Vs(n){return["interpolate",["linear"],["abs",["-",["get","pos"],n]],0,1,Ws,1,vo/2,0]}function Js(n,e){let o=n==="24h"?86400:n==="7d"?604800:2592e3,s=e-o,r=[],a=(l,d)=>{let c=(l-s)/o;c>.02&&c<.98&&r.push([c,d])},i=new Date(s*1e3);if(n==="24h")for(i.setMinutes(0,0,0);i.getTime()/1e3<=e;)i.getHours()%6===0&&a(i.getTime()/1e3,`${String(i.getHours()).padStart(2,"0")}:00`),i.setHours(i.getHours()+1);else if(n==="7d")for(i.setHours(12,0,0,0);i.getTime()/1e3<=e;i.setDate(i.getDate()+1))a(i.getTime()/1e3,i.toLocaleDateString(le(),{weekday:"short"}));else{let l=new Date(e*1e3);l.setHours(0,0,0,0);for(let d=0;d<5;d++){let c=new Date(l);c.setDate(l.getDate()-7*d),a(c.getTime()/1e3,c.toLocaleDateString(le(),{day:"numeric",month:"short"}))}r.reverse()}return r}var Cn=n=>new Date(n*1e3).toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"});function Zs(n,e){let o=s=>new Date(s*1e3).toDateString();return o(n)===o(e)?_("Today"):o(n)===o(e-86400)?_("Yesterday"):new Date(n*1e3).toLocaleDateString(le(),{weekday:"short",day:"numeric",month:"short"})}var xo="https://unpkg.com/maplibre-gl@6.14.0/dist",Qs={module:"sha384-q26X6R1yFeg0QR9SHHn6U3Nb0ddRRTtwxsahubv5R89/v5nijKpk9KviUp9ZLySk",css:"sha384-1TZtfVz7qtwR5vD7cMwjGT+9uiK4lqE3pbUOPwYO6OCpb+TYP0S9vLIhG02JCU04"},Xs="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",er="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",Ai={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Jt=null;function Ni(n){if(n.appendChild(t("link",{rel:"stylesheet",href:`${xo}/maplibre-gl.css`,integrity:Qs.css,crossorigin:"anonymous"})),Jt)return Jt;let e=`${xo}/maplibre-gl.mjs`;return Jt=new Promise((s,r)=>{let a=t("link",{rel:"modulepreload",href:e,integrity:Qs.module,crossorigin:"anonymous"});a.addEventListener("load",()=>s()),a.addEventListener("error",()=>r(new Error("integrity"))),document.head.appendChild(a)}).then(()=>import(e)).then(s=>(s.getWorkerUrl()||s.setWorkerUrl(`${xo}/maplibre-gl-worker.mjs`),s),s=>{throw Jt=null,new Error(s?.message==="integrity"?_("The map library from the CDN is not the expected file: not loading it."):_("Could not load the map library (no internet access from this browser?)"))}),Jt}var Hi=10,tr=30,zi=62,Ri=4,nr=4.5,Ii=7,Ln="#3b82f6",wo="#8a8a8a";function or(n,e,o=.2,s=64){let[r,a]=n,[i,l]=e,d=i-r,c=d>180?i-360:d<-180?i+360:i,p=c-r,u=l-a,w=Math.hypot(p,u);if(w===0||o===0)return[n,[c,l]];let M=-u/w,g=p/w,h=w*o,E=(r+c)/2+M*h,H=(a+l)/2+g*h,S=[],$=Math.max(2,Math.floor(s));for(let b=0;b<=$;b+=1){let C=b/$,y=1-C;S.push([y*y*r+2*y*C*E+C*C*c,y*y*a+2*y*C*H+C*C*l])}return S}function yo(n,e){let o=new Map;for(let s of n.geo.points){if(n.person&&s.person!==n.person||n.device&&s.device!==n.device||(e==="online"?!s.online:n.now-s.ts>Ai[e]))continue;let r=n.device?et(s):n.person?`${s.device}|${s.city}|${s.cc}`:s.device,a=o.get(r);(!a||s.online&&!a.online||s.online===a.online&&s.ts>a.ts)&&o.set(r,s)}return[...o.values()]}function ko(n,e){let o=0;return yo(n,e).sort((s,r)=>Number(r.online)-Number(s.online)||r.ts-s.ts).map(s=>({...s,n:s.online?0:++o}))}var dt=class{constructor(e,o="online",s=380){this.cb=e;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.theme=null;this.resize=null;this.fitBlind=!1;this.data=null;this.fitted=!1;this.fitKey=null;this.people=[];this.slots=[];this.merged=[];this.piles=new Map;this.dock=null;this.dockKey="";this.dockQuiet=!1;this.piledKeys=new Set;this.foldedKeys=new Set;this.targetZoom=null;this.before=null;this.hiddenKey="";this.focused=null;this.dead=!1;this.places=new Map;this.replaying=null;this.bandDots=[];this.range=o,this.status=t("div",{class:"dl-map-status"}),this.card=t("div",{class:"dl-map-card","aria-live":"polite"}),this.el=t("div",{class:"dl-geomap",style:`height:${s}px`},[this.status,this.card])}async mount(e){this.data=e;try{this.gl=await Ni(this.el)}catch(s){this.status.textContent=s.message;return}if(this.dead)return;this.map=new this.gl.Map({container:this.el,style:xt()?Xs:er,center:[e.geo.home?.lon??20,e.geo.home?.lat??50],zoom:1,renderWorldCopies:!1,attributionControl:{compact:!0},minZoom:1}),this.map.on("style.load",()=>this.layers()),this.map.on("move",()=>this.declutter()),this.map.once("idle",()=>{let s=this.el.querySelector(".maplibregl-ctrl-attrib");s?.classList.remove("maplibregl-compact-show"),s?.removeAttribute("open")}),this.resize=new ResizeObserver(()=>{!this.map||!this.el.clientWidth||!this.el.clientHeight||(this.map.resize(),this.fitBlind&&(this.fitKey=null,this.draw()))}),this.resize.observe(this.el);let o=xt();this.theme=new MutationObserver(()=>{!this.map||xt()===o||(o=xt(),this.map.setStyle(o?Xs:er))}),this.theme.observe(document.documentElement,{attributes:!0,attributeFilter:["data-darkmode"]})}layers(){if(this.map){this.hiddenKey="",this.map.setProjection({type:"globe"}),this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],Ln,wo],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],Ln,wo],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-band",{type:"geojson",data:{type:"FeatureCollection",features:this.bandDots}}),this.map.addLayer({id:"dl-band",type:"circle",source:"dl-band",paint:{"circle-radius":1.4,"circle-color":Ln,"circle-opacity":0}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}});for(let e of[!1,!0])this.map.addLayer({id:e?"dl-arc-live":"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],e],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":e?Ln:wo,"line-width":2,"line-opacity":.85,"line-dasharray":[2,2]}});this.draw()}}setRange(e){this.range=e,this.fitKey=null,this.draw()}update(e){this.data=e,this.draw()}destroy(){this.dead=!0,this.dropCard();for(let e of this.piles.values())e.marker.remove();this.piles.clear(),this.theme?.disconnect(),this.resize?.disconnect(),this.map?.remove(),this.map=null}groups(e){let o=new Map;for(let s of e){let r=`${s.person}|${et(s)}`,a=o.get(r);a||(a={key:r,person:s.person,lat:s.lat,lon:s.lon,city:s.city,country:s.country,cc:s.cc,asn:s.asn,org:s.org,online:!1,ts:0,points:[]},o.set(r,a)),a.points.push(s),a.online||(a.online=s.online),a.ts=Math.max(a.ts,s.ts)}return[...o.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let e=this.data,o=this.groups(yo(e,this.range)),s=e.person||e.device?null:e.geo.home;for(let d of this.markers)d.remove();this.markers=[];let r=e.person||e.device?null:Oi(o,s),a=o.map(d=>({g:d,at:r?.get(d.key)??[d.lon,d.lat]}));if(this.slots=[],this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:a.map(({g:d})=>({type:"Feature",properties:{online:d.online,key:d.key},geometry:{type:"Point",coordinates:[d.lon,d.lat]}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:s?a.map(({g:d,at:c})=>({type:"Feature",properties:{online:d.online,person:d.person,key:d.key},geometry:{type:"LineString",coordinates:or([s.lon,s.lat],c)}})):[]}),s){let d=t("span",{class:"dl-mk-host"});d.innerHTML=`${kt("server","dl-mk-host-ic")}`,this.dock=d.appendChild(t("span",{class:"dl-mk-dock"})),this.dockQuiet=this.dockKey!=="",this.dockKey="";let c=t("div",{class:"dl-mk-hub",title:`${_("Home router")}${s.city?` · ${s.city}`:""}${s.org?` · ${s.org}`:""}`},[d,t("span",{class:"dl-mk-label chip"},s.city||_("Home"))]);c.addEventListener("mouseenter",()=>this.showMerged(s.city)),c.addEventListener("mouseleave",()=>this.focus(this.focused)),c.addEventListener("click",()=>this.zoomToMerged()),this.add(c,[s.lon,s.lat],!0)}let i=new Map(e.device?ko(e,this.range).map(d=>[et(d),d.n]):[]);this.people=[],this.places.clear();for(let{g:d,at:c}of a){let p=d.points.length,u=e.people.find(h=>h.id===d.person);if(e.person){let h=e.device?this.deviceMarker(d,c,u,i.get(et(d))??0):this.placeMarker(d,c,u);this.add(h,c);continue}let w=d.points.map(h=>u?.devices.find(E=>E.id===h.device)?.kind??"other"),M=t("span",{class:"dl-mk-badge"});M.innerHTML=p<=2?w.map(h=>kt(h,"dl-mk-badge-ic")).join(""):String(p);let g=t("button",{type:"button",class:`dl-mk${d.online?" online":""}`,"aria-label":d.city?m(N_(p,"%s: %s device in %s","%s: %s devices in %s"),u?.name??_("Someone"),K(p),d.city):m(N_(p,"%s: %s device in an unknown city","%s: %s devices in an unknown city"),u?.name??_("Someone"),K(p))},[t("span",{class:"dl-mk-av"},[je(u?.name??"?"),M]),t("span",{class:"dl-mk-label below"},d.city||d.cc||"?")]);g.addEventListener("mouseenter",()=>this.focus(d.person)),g.addEventListener("mouseleave",()=>this.focus(null)),this.people.push({el:g,person:d.person}),g.addEventListener("click",h=>{h.stopPropagation(),this.openPopup(d,c,g)}),this.add(g,c,!1,u?.name??_("Someone"),`${d.city||d.cc||"?"} · ${d.online?_("now"):pe(d.ts,e.now)}`,d.key,d)}this.declutter();let l=a.map(d=>d.g.key).sort().join(";");if(l!==this.fitKey&&!this.popup){let d=this.fitted&&!this.fitBlind;if(this.fitBlind=!this.el.clientWidth||!this.el.clientHeight,this.fitKey=l,this.fitted=!0,s&&!a.length){let c={center:[s.lon,s.lat],zoom:12};d?this.glide(12,()=>this.map.flyTo({...c,duration:1200})):this.map.jumpTo(c)}else{let c=a.map(p=>p.at);s&&(c.length===0||this.range!=="online"||a.some(p=>p.g.online))&&c.push([s.lon,s.lat]),this.fit(c,d)}}this.status.textContent=a.length||s?"":_("No locations yet"),this.status.style.display=this.status.textContent?"":"none",this.focus(this.focused&&this.people.some(d=>d.person===this.focused)?this.focused:null)}add(e,o,s=!1,r,a,i,l){i&&this.foldedKeys.has(i)&&e.classList.add("merged"),i&&this.piledKeys.has(i)&&e.classList.add("piled"),e.dataset.key=i??"",e.classList.add("dl-mk-new"),requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("dl-mk-new")));let d=new this.gl.Marker({element:e}).setLngLat(o).addTo(this.map);this.markers.push(d),this.slots.push({marker:d,el:e,at:o,fixed:s,who:r,where:a,g:l})}declutter(){if(!this.map)return;let e=this.map.getZoom();this.el.classList.toggle("dl-lod-far",e=nr&&e{let l=this.map.project(i.at),d=i.el.querySelector(":scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile");return{x:l.x,y:l.y,r:(d?.offsetWidth||24)/2+3,fixed:i.fixed}}),s=o.filter(i=>i.fixed);this.merged=[],this.foldedKeys.clear();let r=this.targetZoom==null?1:Math.min(1,2**(this.targetZoom-this.map.getZoom()));o.forEach((i,l)=>{if(i.fixed)return;let d=this.slots[l],c=d.el.classList.contains("merged")?12:6,p=s.find(u=>Math.hypot(u.x-i.x,u.y-i.y)*r{let c=this.slots[d];!c||c.fixed||(o[d].fixed&&([i,l]=[0,0]),c.marker.setOffset([i,l]),Ui(c.el,i,l))})}closePopup(e=!1){let o=this.popup;if(!o||o.card.classList.contains("leaving"))return;o.card.classList.add("leaving"),setTimeout(()=>{this.popup===o&&this.dropCard()},140);let s=this.before;if(this.before=null,!s)return;let r=()=>this.map?.flyTo({...s,duration:800});if(!e)return r();let a=!1,i=()=>{a||(a=!0,window.removeEventListener("pointerup",i,!0),window.removeEventListener("pointercancel",i,!0),setTimeout(r,0))};window.addEventListener("pointerup",i,!0),window.addEventListener("pointercancel",i,!0),setTimeout(i,1500)}dropCard(){this.popup?.off(),this.popup?.card.remove(),this.popup=null}showMerged(e){this.merged.length&&(dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},e?m(_("Near %s"),e):_("Near the server")),` · ${_("click to zoom in")}`]),...this.merged.map(o=>t("div",{class:"dl-map-card-row"},[t("span",{},o.who),t("span",{class:"dl-faint"},o.where)]))]),this.card.classList.add("on"))}paintDock(){let e=this.dock;if(!e)return;let o=this.merged.map(r=>`${r.key}:${r.online?1:0}`).join("|");if(o===this.dockKey)return;this.dockKey=o,e.parentElement?.classList.toggle("docked",this.merged.length>0);let s=this.slots.find(r=>r.fixed).at;this.merged.length&&rr(e,this.merged,this.faceActions(()=>[s]),this.dockQuiet),this.dockQuiet=!1}faceActions(e){return{click:(o,s)=>this.openFace(o,s,e()),hover:o=>this.focus(o?.g?.person??null)}}pileUp(e){let o=new Set;if(!this.data?.person&&!this.data?.device){let s=e.flatMap((l,d)=>!l.fixed&&this.slots[d].el.querySelector(":scope > .dl-mk-av")?[d]:[]),r=new Map(s.map(l=>[l,l])),a=l=>r.get(l)===l?l:a(r.get(l));for(let l of s)for(let d of s){if(d<=l)continue;let c=this.slots[l].el.classList.contains("piled")&&this.slots[d].el.classList.contains("piled");Math.hypot(e[l].x-e[d].x,e[l].y-e[d].y)this.slots[h]),c=d.map(sr),p=c.map(h=>h.key).sort().join(",");o.add(p);let u=[d.reduce((h,E)=>h+E.at[0],0)/d.length,d.reduce((h,E)=>h+E.at[1],0)/d.length],w=this.piles.get(p);if(!w){let h=t("span",{class:"dl-mk-pile-box"}),E=[...new Set(d.map($=>$.g?.city||$.g?.cc||"?"))],H=t("div",{class:"dl-mk-pile"},[h,t("span",{class:"dl-mk-label below"},E.length===1?E[0]:W(d.length,"%s person","%s people"))]);w={marker:new this.gl.Marker({element:H}).setLngLat(u).addTo(this.map),el:H,box:h,faces:c},H.addEventListener("mouseleave",()=>this.focus(this.focused));let S=w;H.addEventListener("click",$=>{$.stopPropagation(),this.zoomInTo(S.faces.map(b=>b.at),!1)}),this.piles.set(p,w)}w.faces=c;let M=w;rr(w.box,c,this.faceActions(()=>M.faces.map(h=>h.at)));for(let h of l)this.slots[h].el.classList.add("piled"),Object.assign(e[h],{r:0,fixed:!0});let g=this.map.project(u);e.push({x:g.x,y:g.y,r:(w.el.offsetWidth||60)/2+3,fixed:!0})}}this.piledKeys=new Set(this.slots.filter(s=>s.el.classList.contains("piled")).map(s=>s.el.dataset.key??"")),this.slots.forEach((s,r)=>{(!e[r].fixed||s.fixed||s.el.classList.contains("merged"))&&s.el.classList.remove("piled")});for(let[s,r]of this.piles)o.has(s)||(this.piles.delete(s),r.el.classList.add("out"),setTimeout(()=>r.marker.remove(),200))}zoomToMerged(){!this.map||!this.merged.length||this.zoomInTo([this.slots.find(e=>e.fixed).at,...this.merged.map(e=>e.at)],!1)}openFace(e,o,s){if(!e.g)return;if(s.every(a=>Mn(a,e.at)<1))return this.openPopup(e.g,e.at,o);let r=()=>{let a=this.slots.find(i=>i.el.dataset.key===e.key);a?.g&&!a.el.classList.contains("merged")&&!a.el.classList.contains("piled")&&this.openPopup(a.g,a.at,a.el)};this.zoomInTo(this.nearby(e.at),!0)?this.map.once("moveend",r):r()}nearby(e){return[e,...this.slots.filter(o=>!o.fixed&&o.at!==e&&Mn(o.at,e)<=tr).map(o=>o.at)]}zoomInTo(e,o){let s=new this.gl.LngLatBounds;for(let p of e)s.extend(p);let r=e.some(p=>e.some(u=>Mn(p,u)>tr)),a=this.map.cameraForBounds(s,{padding:50,maxZoom:r?12:Hi}),i=this.map.getZoom(),l=e.map(p=>this.map.project(p)),d=0;l.forEach((p,u)=>l.slice(u+1).forEach(w=>{let M=Math.hypot(p.x-w.x,p.y-w.y),g=i+Math.log2(zi/Math.max(M,1e-6));g<=12&&(d=Math.max(d,g))}));let c=Math.min(12,Math.max(a?.zoom??0,d));return c<=i+.05?!1:(o&&!this.before&&(this.before={center:this.map.getCenter().toArray(),zoom:i}),this.map.flyTo({center:a?.center??s.getCenter(),zoom:c,duration:800}),!0)}placeMarker(e,o,s){let r=this.data.now,a=[...e.points].sort((u,w)=>Number(w.online)-Number(u.online)||w.ts-u.ts)[0],i=s?.devices.find(u=>u.id===a.device)?.kind??"other",l=e.points.length,d=t("span",{class:"dl-mk-tile"});d.innerHTML=kt(i,"dl-mk-tile-ic")+(l>1?`${l}`:"");let c=e.online?_("now"):pe(e.ts,r),p=t("button",{type:"button",class:`dl-mk place${e.online?" online":""}`,style:e.online?null:`--dl-mk-fade:${Math.max(.4,1-.6*(r-e.ts)/(30*86400)).toFixed(2)}`,"aria-label":e.city?m(N_(l,"%s device in %s, %s","%s devices in %s, %s"),K(l),e.city,c):m(N_(l,"%s device in an unknown city, %s","%s devices in an unknown city, %s"),K(l),c)},[d,t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",t("span",{class:"dl-mk-when"},c)])]);return p.addEventListener("click",u=>{u.stopPropagation(),this.openPopup(e,o,p)}),p}deviceMarker(e,o,s,r){let a=s?.devices.find(p=>p.id===e.points[0].device)?.kind??"other",i=t("span",{class:"dl-mk-tile"}),l=t("span",{class:"dl-mk-label below"}),d=t("button",{type:"button",class:"dl-mk place step"},[i,l]);d.addEventListener("click",p=>{p.stopPropagation(),this.openPopup(e,o,d)});let c=et(e);return this.places.set(c,{el:d,tile:i,label:l,when:null,g:e,n:r,kind:a}),this.paintPlace(c,!1),d}paintPlace(e,o){let s=this.places.get(e);if(!s)return;let r=this.replaying,a=r?r.active===e:s.g.online,i=s.el.classList.contains("online"),l=s.g.city||s.g.cc||"?";s.el.classList.toggle("online",a),s.el.classList.toggle("faded",!!r&&!a),s.tile.classList.toggle("sm",!a),a||!s.n?s.tile.innerHTML=kt(s.kind,"dl-mk-tile-ic"):s.tile.textContent=String(s.n),s.when=null,a?(s.when=t("span",{class:`dl-mk-when${r?" inline":""}`},r?r.when:_("now")),s.label.replaceChildren(l,r?" · ":"",s.when)):s.label.replaceChildren(`${l} · ${s.g.online?_("now"):pe(s.g.ts,this.data.now)}`);let d=a?r?r.when:_("now"):s.g.online?_("now"):pe(s.g.ts,this.data.now);s.el.setAttribute("aria-label",`${s.n?`${s.n}: `:""}${s.g.city||_("an unknown city")}, ${d}`),o&&a&&!i&&(s.el.classList.remove("arrive"),s.el.offsetWidth,s.el.classList.add("arrive"),setTimeout(()=>s.el.classList.remove("arrive"),500))}replay(e,o=!0){let s=this.replaying;if(this.replaying=e,s&&e&&s.active===e.active){let r=e.active?this.places.get(e.active):null;r?.when&&(r.when.textContent=e.when);return}for(let r of this.places.keys())r!==e?.active&&this.paintPlace(r,o);e?.active&&this.paintPlace(e.active,o),this.declutter(),setTimeout(()=>this.declutter(),320)}hoverPlace(e){for(let[o,s]of this.places)s.el.classList.toggle("hl",o===e)}band(e,o){if(this.bandDots=[],this.map&&e&&o){let s=or(e,o),r=s.map(c=>this.map.project(c)),a=[0];for(let c=1;ca[d]?(p-a[d])/(a[d+1]-a[d]):0,w=[s[d][0]+(s[d+1][0]-s[d][0])*u,s[d][1]+(s[d+1][1]-s[d][1])*u];this.bandDots.push({type:"Feature",properties:{pos:c/l},geometry:{type:"Point",coordinates:w}})}}this.map?.getLayer("dl-band")&&(this.map.setPaintProperty("dl-band","circle-opacity",0),this.map.getSource("dl-band").setData({type:"FeatureCollection",features:this.bandDots}))}bandAt(e){this.map?.getLayer("dl-band")&&this.map.setPaintProperty("dl-band","circle-opacity",Vs(e))}focus(e){this.focused=e;for(let i of this.people)i.el.classList.toggle("dim",!!e&&i.person!==e),i.el.classList.toggle("hl",i.person===e);let o=e?["case",["==",["get","person"],e],.85,.15]:.85;for(let i of["dl-arc-live","dl-arc-recent"])this.map?.getLayer(i)&&this.map.setPaintProperty(i,"line-opacity",o);if(this.card.classList.toggle("on",!!e),!e||!this.data)return;let s=this.data,r=s.people.find(i=>i.id===e),a=yo(s,this.range).filter(i=>i.person===e).sort((i,l)=>Number(l.online)-Number(i.online)||l.ts-i.ts);dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},r?.name??e),` · ${W(a.length,"%s device","%s devices")}`]),...a.map(i=>t("div",{class:"dl-map-card-row"},[t("span",{},r?.devices.find(l=>l.id===i.device)?.name??_("Device")),t("span",{class:"dl-faint"},`${i.city||i.cc||"?"} · ${i.online?_("now"):pe(i.ts,s.now)}`)]))])}fit(e,o=!1){if(!e.length)return;let s=(p,u)=>{let w=Math.PI/180,M=(u[1]-p[1])*w,g=(u[0]-p[0])*w,h=Math.sin(M/2)**2+Math.cos(p[1]*w)*Math.cos(u[1]*w)*Math.sin(g/2)**2;return 12742*Math.asin(Math.sqrt(h))},r=[e.reduce((p,u)=>p+u[0],0)/e.length,e.reduce((p,u)=>p+u[1],0)/e.length],a=e;if(e.length>=5){let p=[...e].sort((u,w)=>s(r,u)-s(r,w));a=p.slice(0,Math.ceil(p.length*.9))}let i=new this.gl.LngLatBounds(a[0],a[0]);a.forEach(p=>i.extend(p));let l=this.el.clientHeight||380,d=!!this.data?.person,c={padding:{top:this.data?.device?Math.min(56,l/4):Math.min(60,l/5),bottom:d?Math.min(52,l/4):Math.min(40,l/8),left:48,right:48},maxZoom:this.data?.person?11:12};o?this.glide(this.map.cameraForBounds(i,c)?.zoom??null,()=>this.map.fitBounds(i,{...c,duration:1200})):this.map.fitBounds(i,{...c,duration:0})}glide(e,o){this.targetZoom=e,this.declutter(),this.map.once("moveend",()=>{this.targetZoom=null,this.declutter()}),o()}openPopup(e,o,s){let r=this.data,a=[e.city,e.cc||e.country].filter(Boolean).join(", "),i=[...new Set(e.points.map(b=>b.person))],l=i.length===1?r.people.find(b=>b.id===i[0])?.name:void 0,d=e.points.sort((b,C)=>Number(C.online)-Number(b.online)||C.ts-b.ts).map(b=>{let C=r.people.find(z=>z.id===b.person),y=C?.devices.find(z=>z.id===b.device);return t("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(b.person,b.device)},[t("span",{class:`dl-pop-dot${b.online?" on":""}`}),t("span",{class:"dl-pop-name"},[t("b",{},C?.name??b.person),` · ${y?.name??_("device")}`]),t("span",{class:"dl-faint dl-nowrap"},b.online?_("now"):pe(b.ts,r.now))])}),c=t("div",{class:"dl-pop"},[t("div",{class:"dl-pop-head"},[t("span",{class:"dl-pop-net"},v("globe")),t("div",{class:"dl-stack"},[t("strong",{},e.org||_("Unknown network")),t("span",{class:"dl-faint"},[e.asn?`AS${e.asn} · `:"",a?`${a} · ${_("approximate")}`:_("approximate location")])])]),t("div",{class:"dl-pop-list"},d),i.length===1?t("div",{class:"dl-pop-actions"},[t("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(i[0])},l?m(_("Open %s"),l):_("Open person"))]):""]);this.zoomInTo(this.nearby(o),!0),this.dropCard();let p=t("div",{class:"dl-root dl-popcard",role:"dialog"},[t("span",{class:"dl-popcard-tip"}),c]);document.body.appendChild(p);let u=this.el,w=s?.querySelector(".dl-mk-av, .dl-mk-tile")??s??null,M=()=>{if(!w)return;let b=w.getBoundingClientRect(),C=u.getBoundingClientRect(),y=b.left+b.width/2,z=b.top+b.height/2;p.classList.toggle("away",yC.right||zC.bottom);let k=p.offsetWidth,f=p.offsetHeight,x=b.top-f-12>=8||b.top>window.innerHeight-b.bottom,T=Math.min(Math.max(8,y-k/2),window.innerWidth-k-8);p.classList.toggle("above",x),p.classList.toggle("below",!x),p.style.left=`${T}px`,p.style.top=`${x?b.top-f-12:b.bottom+12}px`,p.style.setProperty("--tip-x",`${y-T}px`)},g=b=>{b.target?.closest(".dl-popcard, .maplibregl-marker")||this.closePopup(!0)},h=b=>{b.key==="Escape"&&this.closePopup()},E=b=>{b.target instanceof Element&&b.target.closest(".dl-popcard")||this.closePopup()},H=()=>this.closePopup();this.map.on("move",M),window.addEventListener("scroll",E,{capture:!0,passive:!0}),window.addEventListener("resize",M),document.addEventListener("pointerdown",g,!0),document.addEventListener("keydown",h);let S=Te(H);window.addEventListener("pagehide",H),this.popup={card:p,off:()=>{this.map?.off("move",M),window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",M),document.removeEventListener("pointerdown",g,!0),document.removeEventListener("keydown",h),S(),window.removeEventListener("pagehide",H)}};let $=window.setInterval(()=>{if(this.popup?.card!==p)return clearInterval($);(!u.isConnected||!u.getClientRects().length)&&this.dropCard()},400);M()}};function Bi(n,e=6){let o=n.map(s=>({x:s.x,y:s.y}));for(let s=0;s<16;s++){let r=!1;for(let a=0;a[s.x-n[r].x,s.y-n[r].y])}function Oi(n,e){let o=new Map,s=e?[[e.lon,e.lat]]:[],r=a=>s.some(i=>Mn(a,i)<1.3);for(let a of[...n].sort((i,l)=>i.key>>12)/1048575),d=(i&4095)/4096*2*Math.PI,c=[a.lon,a.lat];for(let p=0;p<24;p++){let u=d+p*2.39996,w=Math.min(8,l+p*.25);if(c=[a.lon+w*Math.sin(u)/(111.32*Math.cos(a.lat*Math.PI/180)),a.lat+w*Math.cos(u)/111.32],!r(c))break}s.push(c),o.set(a.key,c)}return o}function ji(n){let e=2166136261;for(let o=0;o>>0}function sr(n){return{key:n.el.dataset.key??"",who:n.who??_("Someone"),where:n.where??"",online:!!n.g?.online,at:n.at,badge:n.el.querySelector(".dl-mk-badge")?.innerHTML??"",g:n.g}}function rr(n,e,o,s=!1){let r=e.length>3,a=()=>[...n.children].filter(g=>!g.classList.contains("out")),i=new Map(a().map(g=>[g,g.getBoundingClientRect().left])),l=n.getBoundingClientRect().width,d=new Map;n.querySelectorAll(".dl-mk-face:not(.out)").forEach(g=>d.set(g.dataset.key??"",g));let c=n.querySelector(".dl-mk-more:not(.out)"),p=g=>{Object.assign(g.style,{position:"absolute",left:`${g.offsetLeft}px`,top:`${g.offsetTop}px`,transform:""}),g.classList.add("out"),setTimeout(()=>g.remove(),200)},u=[];for(let g of e.slice(0,r?2:3)){let h=d.get(g.key);if(d.delete(g.key),!h){let S=t("button",{type:"button",class:`dl-mk-face${s?"":" in"}`,"data-key":g.key},[t("span",{class:"dl-mk-av"},je(g.who)),t("span",{class:"dl-mk-badge"})]);S.addEventListener("animationend",()=>S.classList.remove("in"),{once:!0}),h=S}let E=h,H=E.querySelector(".dl-mk-badge");H.innerHTML!==g.badge&&(H.innerHTML=g.badge),E.title=`${g.who} · ${g.where}`,E.setAttribute("aria-label",`${g.who}, ${g.where}`),E.classList.toggle("on",g.online),E.onclick=S=>{S.stopPropagation(),o.click(g,E)},E.onmouseenter=()=>o.hover(g),E.onmouseleave=()=>o.hover(null),u.push(E)}for(let g of d.values())p(g);if(r){if(!c){c=t("span",{class:`dl-mk-more${s?"":" in"}`});let g=c;g.addEventListener("animationend",()=>g.classList.remove("in"),{once:!0})}c.textContent=`+${e.length-2}`,u.push(c)}else c&&p(c);let w=null;for(let g of u)(w?w.nextElementSibling:n.firstElementChild)!==g&&(w?w.after(g):n.prepend(g)),w=g;for(let g of u){let h=i.get(g);if(h==null)continue;let E=h-g.getBoundingClientRect().left;Math.abs(E)<.5||(g.style.transition="none",g.style.transform=`translateX(${E}px)`,g.offsetWidth,g.style.transition="",g.style.transform="")}n.style.width="";let M=n.getBoundingClientRect().width;if(l&&Math.abs(M-l)>.5){n.style.width=`${l}px`,n.offsetWidth,n.style.width=`${M}px`;let g=()=>{n.style.width="",n.removeEventListener("transitionend",g)};n.addEventListener("transitionend",g),setTimeout(g,400)}}function Mn(n,e){let o=Math.PI/180,s=Math.sin((e[1]-n[1])*o/2)**2+Math.cos(n[1]*o)*Math.cos(e[1]*o)*Math.sin((e[0]-n[0])*o/2)**2;return 12742*Math.asin(Math.min(1,Math.sqrt(s)))}function Ui(n,e,o){let s=n.querySelector(":scope > .dl-mk-ptr"),r=Math.hypot(e,o);if(r<1){s?.remove();return}s||(s=t("span",{class:"dl-mk-ptr"},[t("i",{class:"line"}),t("i",{class:"spot"})]),n.prepend(s));let a=s.firstElementChild,i=s.lastElementChild;a.style.width=`${r}px`,a.style.transform=`rotate(${Math.atan2(-o,-e)}rad)`,i.style.transform=`translate(${-e}px, ${-o}px)`}function Rt(n,e,o=!0){let s=[["online",_("Online now")],["24h",_("24h")],["7d",_("7 days")],["30d",_("30 days")]],r=t("div",{class:"dl-seg",role:"tablist"});for(let[a,i]of s)a==="online"&&!o||r.appendChild(t("button",{type:"button",role:"tab",class:a===n?"on":"","data-v":a,click:()=>{r.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===a)),e(a)}},i));return r}var ar={"24h":86400,"7d":7*86400,"30d":30*86400},_o=(n,e)=>`${(n/e*100).toFixed(3)}%`,En=class{constructor(e,o,s){this.map=e;this.range=o;this.el=t("div",{class:"dl-dplaces"});this.controls=t("div",{class:"dl-map-replay"});this.pending=null;this.rows=new Map;this.st=[];this.steps=[];this.total=0;this.ms=0;this.stepI=-1;this.on=!1;this.playing=!1;this.raf=0;this.last=0;this.endTimer=0;this.play=t("button",{type:"button",class:"dl-map-btn"});this.chip=t("span",{class:"dl-map-chip"});this.stop=t("button",{type:"button",class:"dl-map-btn",title:_("Back to now"),"aria-label":_("Back to now")},v("x"));this.reduced=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;this.data=s,this.play.addEventListener("click",()=>this.toggle()),this.stop.addEventListener("click",()=>this.end()),this.paint()}mapData(){let e=this.data;return{geo:e.geo,people:[e.person],now:e.now,person:e.person.id,device:e.device.id}}update(e){let o={...this.pending??this.data,...e};if(this.on){this.pending=o;return}this.data=o,this.map.update(this.mapData()),this.paint()}setRange(e){this.end(),this.range=e,this.map.setRange(e),this.paint()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.endTimer)}paint(){let e=this.data,o=ar[this.range],s=e.now-o,r=Os(Bs(e.events??[],e.device.id,e.now,e.device.online,e.device.handshake),e.geo.points,e.device.id,s),a=js(r);this.st=Us(r);let i=ko(this.mapData(),this.range),l=r.length>0;this.el.classList.toggle("strips",l),this.el.classList.toggle("can-replay",this.st.length>1),this.rows.clear(),dom.content(this.el,i.length?[...i.map(d=>{let c=et(d),p=a.get(c),u=l?t("div",{class:`dl-dplace-strip${d.online?" live":""}`},r.filter(M=>M.key===c).map(M=>t("i",{style:`left:${_o(M.from-s,o)};width:${_o(M.to-M.from,o)}`}))):"",w=t("div",{class:"dl-dplace-row"},[t("span",{class:`dl-dplace-n${d.online?" live":""}`},d.online?v(e.device.kind):String(d.n)),t("span",{class:"dl-row-main dl-stack"},[t("span",{},[d.city||d.cc||_("Unknown city"),d.org?t("span",{class:"dl-muted"},` · ${d.org}`):""]),t("span",{class:"dl-faint"},[t("span",{class:"dl-mono"},d.ip),p!=null?` · ${m(_("%s%% of the time"),p>0&&p<.005?"<1":Math.round(p*100))}`:""])]),t("span",{class:d.online?"dl-dplace-now":"dl-faint dl-nowrap"},d.online?_("now"):pe(d.ts,e.now)),u]);if(w.addEventListener("mouseenter",()=>this.map.hoverPlace(c)),w.addEventListener("mouseleave",()=>this.map.hoverPlace(null)),u){let M=g=>{let h=u.getBoundingClientRect();this.seek(s+o*Math.min(1,Math.max(0,(g.clientX-h.left)/h.width)))};u.addEventListener("pointerdown",g=>{u.setPointerCapture(g.pointerId),M(g)}),u.addEventListener("pointermove",g=>g.buttons&&M(g))}return this.rows.set(c,w),w}),l?t("div",{class:"dl-dplace-axis"},Js(this.range,e.now).map(([d,c])=>t("span",{style:`left:${(d*100).toFixed(2)}%`},c))):""]:t("div",{class:"dl-sub"},_("No locations in this period."))),this.paintControls()}paintControls(){dom.content(this.play,v(this.playing?"pause":"play")),this.play.title=this.playing?_("Pause","replay"):_("Replay this period"),this.play.setAttribute("aria-label",this.play.title),dom.content(this.controls,this.on?[this.play,this.chip,this.stop]:this.st.length>1?[this.play]:[])}begin(){this.on=!0,{steps:this.steps,total:this.total}=Gs(this.st,this.reduced?400:bo),this.ms=0,this.stepI=-1,this.map.replay({active:null,when:""},!0)}toggle(){if(this.playing){this.playing=!1,cancelAnimationFrame(this.raf),this.paintControls();return}clearTimeout(this.endTimer),(!this.on||this.ms>=this.total)&&this.begin(),this.playing=!0,this.last=performance.now(),this.paintControls(),this.raf=requestAnimationFrame(e=>this.frame(e))}frame(e){if(this.playing){if(this.ms=Math.min(this.total,this.ms+(e-this.last)),this.last=e,this.show(!0),this.msthis.frame(o));return}this.playing=!1,this.paintControls(),this.endTimer=window.setTimeout(()=>this.end(),1500)}}seek(e){this.st.length<2||(clearTimeout(this.endTimer),this.on||this.begin(),this.ms=Fs(this.st,this.steps,e),this.stepI=-1,this.show(!1),this.paintControls())}show(e){let o=qs(this.st,this.steps,this.ms),s=this.st[o.step.k];if(o.step.kind==="move"){let i=this.st[o.step.k-1];o.i!==this.stepI&&(this.map.replay({active:null,when:""},e),this.map.band([i.point.lon,i.point.lat],[s.point.lon,s.point.lat]));let l=Ks(o.q);this.reduced||this.map.bandAt(l),(this.reduced?o.q>=.5:Ys(l))&&this.map.replay({active:s.key,when:Cn(o.t)},e)}else o.i!==this.stepI&&this.map.band(),this.map.replay({active:s.key,when:Cn(o.t)},e);this.stepI=o.i;let r=this.data,a=r.now-ar[this.range];this.el.classList.add("replay"),this.el.style.setProperty("--at",_o(o.t-a,r.now-a));for(let[i,l]of this.rows)l.classList.toggle("cur",i===s.key);this.chip.textContent=`${Zs(o.t,r.now)}, ${Cn(o.t)} · ${s.point.city||s.point.cc||"?"}`}end(){if(cancelAnimationFrame(this.raf),clearTimeout(this.endTimer),!!this.on){this.on=!1,this.playing=!1,this.ms=0,this.stepI=-1,this.map.band(),this.map.replay(null,!1),this.el.classList.remove("replay");for(let e of this.rows.values())e.classList.remove("cur");this.pending?(this.data=this.pending,this.pending=null,this.map.update(this.mapData()),this.paint()):this.paintControls()}}};function It(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function Re(n,e){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${e?`&device=${encodeURIComponent(e)}`:""}`}function Wi(n){return n?new Date(n*1e3).toLocaleString(le(),{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function Co(n,e,o=!1){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("button",{type:"button",class:`dl-kvrow-v copy${o?" dl-mono":""}`,title:_("Copy"),click:()=>xe(e,m(_("%s copied"),n))},[t("span",{},e),v("copy")])])}function Tn(n,e){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("span",{class:"dl-kvrow-v"},e)])}var ir={connect:["ok","plug"],disconnect:["","plug"],roam:["","network"],device_added:["ok","plus"],device_removed:["","trash"],device_keys:["","reset"]};function Gi(n){let e=s=>t("span",{class:"dl-muted"},s),o=Ve(n)==="portal"?_("on the portal"):Ve(n)==="admin"?_("by you"):"";switch(n.type){case"connect":return[...n.detail?ae(_("Connected from %s"),e(n.detail)):[_("Connected")],n.where?e(` · ${n.where}`):""];case"disconnect":return[_("Went offline")];case"roam":return[_("Changed network"),e(` · ${n.detail??""}`)];case"device_added":return o?ae(_("Added %s"),e(o)):[_("Added")];case"device_removed":return o?ae(_("Removed %s"),e(o)):[_("Removed")];default:return o?ae(_("New keys %s"),e(o)):[_("New keys")]}}function qi(n,e,o){let s=n.filter(r=>r.device===e&&ir[r.type]).reverse().slice(0,12);return s.length?t("div",{class:"dl-dev-log"},s.map(r=>{let[a,i]=ir[r.type],l=new Date(r.ts*1e3);return t("div",{class:`dl-dev-log-row${Ve(r)==="admin"?" dl-ev-by-admin":""}`},[Ve(r)==="admin"?t("span",{class:"dl-ev-tile",title:_("Done by you in LuCI")},v("admin")):t("span",{class:`dl-ev-tile ev ${a}`},v(i)),t("span",{class:"dl-row-main"},Gi(r)),t("span",{class:"dl-faint dl-nowrap",title:l.toLocaleString(le())},pe(r.ts,o))])})):t("div",{class:"dl-sub"},_("No activity yet."))}async function lr(n,e,o){let s=await N.status(1).catch(()=>null),r=s?.people.find(i=>i.id===n),a=r?.devices.find(i=>i.id===e);s&&r&&a&&Je(r,a,{...o,geo:s.geo,now:s.now,today:Ge(s.series),core:zt(s.servers,r.server)})}async function Je(n,e,o){let s=await F(()=>N.deviceConfig(e.id));if(!s)return;let r=o.core??qe(null),a=e,i=n,l=o.geo,d=o.now,c=o.today??Ke(new Date),p=await r.connectBlock(s,e.kind==="phone"||e.kind==="tablet"?"qr":"file"),u=t("div",{class:"dl-drawer-title"}),w=t("div",{}),M=t("div",{}),g=t("div",{},t("div",{class:"dl-sub"},_("Loading…"))),h=[],E=oe=>{h=oe.filter(j=>j.device===a.id),dom.content(g,qi(oe,a.id,d)),b?.update({events:oe})},H=async(oe=!1)=>{let j=o.events?.();if(j&&!oe)return E(j);let Y=await N.events(2e3,n.id).catch(()=>null);Y&&E(Y.events)},S="30d",$=null,b=null,C=()=>{dom.content(u,[t("span",{class:`dl-dcard-ic${a.online?" on":""}`},v(a.kind)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h3",{},a.name),A([v("edit")],()=>k(),"neutral",{title:_("Rename"),class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),t("span",{class:"dl-sub"},`${i.name} · ${at(a.kind)}`)])]);let oe=a.spark.map(([Y,ie])=>Y+ie),j=oe.reduce((Y,ie)=>Y+ie,0);dom.content(w,t("div",{class:"dl-dstats"},[t("div",{class:"dl-dstats-cell wide"},[t("span",{class:"dl-metric-label"},_("Status")),dn(a,d,_("Waiting for the first connection"),i)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},_("This month")),t("b",{},se(a.month[0]+a.month[1])),t("span",{class:"dl-sub dl-mono"},`↓ ${se(a.month[1])} ↑ ${se(a.month[0])}`)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},_("Last 7 days")),t("b",{},se(j)),Es(oe,120,22,c)])])),dom.content(M,t("div",{class:"dl-kv2"},[Co(_("Tunnel address"),a.address),a.hostname&&i.access!=="internet"?Co(_("Local address"),a.hostname):"",a.endpoint&&!l?.points.some(Y=>Y.device===a.id&&Y.ip===a.endpoint)?Tn(_("Client IP"),a.endpoint):"",Tn(_("Total"),t("span",{class:"dl-kv-act"},[`↓ ${se(a.total[1])} · ↑ ${se(a.total[0])}`,t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Ht("device",a.id,a.name,()=>setTimeout(z,300))},_("Reset"))])),Tn(_("Added"),`${Wi(a.created)} · ${a.created_by==="portal"?_("from the portal"):_("by you")}`),s.amnezia.client_pub_key?Co(_("Public key"),s.amnezia.client_pub_key):Tn(_("Public key"),"—")])),dom.content(f,[A([v(a.disabled?"play":"pause")," ",a.disabled?_("Enable"):_("Disable")],async()=>{await F(()=>N.deviceUpdate(a.id,void 0,!a.disabled),a.disabled?_("Device enabled"):_("Device disabled"))&&await z()},"neutral",a.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),A([v("key")," ",_("New keys")],async()=>{if(!await me(_("Generate new keys?"),_("The current configuration on this device stops working until it is imported again."),_("Generate"),!0))return;await F(()=>N.deviceRotate(a.id),_("New keys generated"))&&(o.refresh(),fe.close(),await lr(i.id,a.id,o))}),t("span",{class:"dl-spacer"}),A([v("trash")," ",_("Remove")],async()=>{await me(m(_("Remove %s?"),a.name),_("The device is disconnected immediately and its configuration stops working."),_("Remove"),!0)&&await F(()=>N.deviceDelete(a.id),_("Device removed"))&&(fe.close(),o.refresh())},"negative")])},y=async()=>{let oe=await N.status(1).catch(()=>null),j=oe?.people.find(ie=>ie.id===i.id),Y=j?.devices.find(ie=>ie.id===a.id);!oe||!j||!Y||(i=j,a=Y,l=oe.geo,d=oe.now,c=Ge(oe.series),C(),b?.update({geo:oe.geo,now:oe.now,person:i,device:a}))},z=async()=>{await y(),o.refresh()},k=()=>{let oe=t("input",{type:"text",class:"cbi-input-text",value:a.name,maxlength:48}),j=i.devices.filter(ie=>ie.id!==a.id).map(ie=>ie.name),Y=Ee(_("Name"),oe,()=>He(oe.value,j,_("Shown in the portal and in the app.")));de(m(_("Rename %s"),a.name),[Y],[ue()," ",A(_("Save"),async()=>{let ie=Y.help();if(ie.bad){q(ie.text,"warning");return}await F(()=>N.deviceUpdate(a.id,oe.value,void 0),_("Renamed"))&&(ce(),await z())},"positive")]),setTimeout(()=>oe.select(),50)},f=t("div",{class:"dl-drawer-actions"}),x=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},_("Connect","section"))]),a.config_stale?t("div",{class:"dl-note warn"},[v("alert"),t("span",{},_("This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below."))]):"",p]),T=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},_("Activity")),t("div",{class:"dl-dsec-actions"},[t("button",{type:"button",class:"dl-linkbtn",click:()=>Qe({people:[i]},h,"csv",a.id)},_("Export")),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>lt(m(_("Clear %s's activity"),a.name),m(_("Removes events about %s."),a.name),{device:a.id},()=>{H(!0),o.refresh()})},_("Clear")),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},_("All activity"))])]),g]),I=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},t("h4",{},_("Details","section"))),M]),V="";if(l?.enabled){$=new dt({openPerson:j=>location.href=Re(j),openDevice:(j,Y)=>location.href=Re(j,Y)},S,220);let oe=b=new En($,S,{geo:l,now:d??Date.now()/1e3,person:i,device:a,events:o.events?.()??null});V=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},_("Locations")),Rt(S,j=>{S=j,oe.setRange(j)},!1)]),t("div",{class:"dl-dmap"},[$.el,oe.controls]),oe.el])}let J=!a.handshake||a.config_stale,te=t("div",{class:"dl-stack gap16"},J?[w,x,I,V,T]:[w,I,V,T,x]);H();let B=()=>{y(),H()},Q=_n(B),ne=window.setInterval(B,3e4),fe=Xo(u,te,f,()=>{clearInterval(ne),Q(),b?.destroy(),$?.destroy()});C(),$&&b&&requestAnimationFrame(()=>b&&$?.mount(b.mapData()))}function dr(n,e,o,s){let r=s.core??qe(null),a=()=>F(()=>N.deviceConfig(o.id)),i=[{label:_("Show QR code"),icon:v("qr"),run:async()=>{let l=await a();l&&de(`${o.name} · ${_("QR code")}`,t("div",{class:"dl-qr-pane"},[un(r.qrText(l)),t("span",{class:"dl-sub"},ho(l)?_("Scan with AmneziaVPN or any WireGuard app on the device."):_("Scan with AmneziaVPN or AmneziaWG on the device."))]),ue(_("Close")))}},{label:r.file.label,icon:v("download"),run:async()=>{let l=await a();if(!l)return;let d=r.file.make(l);Ne(d.name,d.text,"application/octet-stream")}},r.appKey?{label:r.appKey.label,icon:v("copy"),run:async()=>{let l=await a();l&&xe(await r.appKey.make(l),_("Key copied"))}}:null,null,{label:_("Rename"),icon:v("edit"),run:()=>Je(e,o,s)},{label:_("New keys"),icon:v("key"),run:async()=>{await me(_("Generate new keys?"),_("The current configuration on this device stops working until it is imported again."),_("Generate"),!0)&&await F(()=>N.deviceRotate(o.id),_("New keys generated"))&&s.refresh()}},{label:o.disabled?_("Enable"):_("Disable"),icon:v(o.disabled?"play":"pause"),warn:!o.disabled,run:async()=>{await F(()=>N.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?_("Device enabled"):_("Device disabled"))&&s.refresh()}},{label:_("Delete"),icon:v("trash"),danger:!0,run:async()=>{await me(m(_("Remove %s?"),o.name),_("The device is disconnected immediately and its configuration stops working."),_("Remove"),!0)&&await F(()=>N.deviceDelete(o.id),_("Device removed"))&&s.refresh()}}];Se(n,i)}function ct(n,e){let o=n.devices.map(c=>c.name),s=c=>{let p=at(c),u=1,w=p;for(;o.some(M=>M.toLowerCase()===w.toLowerCase());)w=`${p} ${++u}`;return w},r="phone",a=t("input",{type:"text",class:"cbi-input-text",placeholder:s(r),maxlength:48}),i=Ee(_("Name"),a,()=>a.value.trim()?He(a.value,o,_("Shown in the portal and in the app.")):{text:m(_("Named after its type: %s."),s(r)),bad:!1}),l=t("div",{class:"dl-kinds",role:"radiogroup","aria-label":_("Type")},Vo.map(c=>t("button",{type:"button",role:"radio",class:c===r?"on":"","aria-checked":c===r?"true":"false","data-kind":c,click:()=>{r=c,l.querySelectorAll("button").forEach(p=>{let u=p.dataset.kind===c;p.classList.toggle("on",u),p.setAttribute("aria-checked",u?"true":"false")}),a.placeholder=s(c),i.refresh()}},[v(c),t("span",{},at(c))]))),d=n.devices.length>=n.device_limit;de(m(_("Add a device for %s"),n.name),[d?t("p",{class:"dl-hint"},m(N_(n.device_limit,"%s already has %s of %s device. As admin you can still add one.","%s already has %s of %s devices. As admin you can still add one."),n.name,K(n.devices.length),K(n.device_limit))):"",t("div",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},_("Type")),l]),i],[ue()," ",A(_("Add device"),async()=>{let c=i.help();if(c.bad){q(c.text,"warning");return}let p=a.value.trim()||s(r),u=await F(()=>N.deviceCreate(n.id,p,r));u&&(ce(),q(m(_("%s added"),p),"success",3e3),e.refresh(),await lr(n.id,u.id,e))},"positive")]),setTimeout(()=>a.focus(),50)}var tt=1080,Qt=1512,Ze=96,Fi="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Ki="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Zt=n=>n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]);function Yi(n,e,o){let s=new URL(o),r=s.pathname.slice(1),a=m(_("Hi, %s"),n.name),i=Math.min(92,Math.floor((tt-2*Ze)/(.58*a.length))),l=tt-2*Ze,d=392,c=40,p=pn(o,2).replace("`${E}`;return``+u(Ze+82,Ze+42,36,"#a3a3a3",Zt(e))+u(Ze,276,i,"#ffffff",Zt(a),'font-weight="600"')+u(Ze,340,40,"#8a8a8a",Zt(m(_("Scan to connect to %s"),e)))+``+p+`${Zt(r)}`+u(tt/2,d+l+156,34,"#737373",Zt(s.host),'text-anchor="middle"')+""}async function Vi(n){let e=new Image;e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await e.decode();let o=document.createElement("canvas");return o.width=tt,o.height=Qt,o.getContext("2d").drawImage(e,0,0,tt,Qt),new Promise((s,r)=>o.toBlob(a=>a?s(a):r(new Error(_("Could not draw the card"))),"image/png"))}async function cr(n){let e=await F(()=>N.personLinks(n));return e?e.link?{link:e.link,links:e.links??[]}:(q(_("The personal portal is off. Turn it on in Settings."),"warning"),null):null}async function Sn(n){let e=await cr(n);e&&await xe(e.link,_("Personal link copied"))}async function Xt(n,e,o={}){let s=n.link,r=n.links;if(s===void 0){let h=await cr(n.id);if(!h)return;s=h.link,r=h.links}if(!s){q(_("The personal portal is off. Turn it on in Settings."),"warning");return}let a=s,i=await F(()=>Vi(Yi(n,e,a)));if(!i)return;let l=new File([i],`${n.id}-invite.png`,{type:"image/png"}),d=URL.createObjectURL(i),c=navigator,p=!!c.canShare?.({files:[l]}),u=!p&&typeof c.share=="function"&&(c.canShare?.({url:a})??!0),w=()=>{URL.revokeObjectURL(d),ce()},M=async h=>{try{await c.share(h)}catch{}},g=p?A([v("link")," ",_("Share card")],()=>M({files:[l],title:m(_("Invite %s"),n.name)}),"positive"):u?A([v("link")," ",_("Share link")],()=>M({url:a,title:m(_("Invite %s"),n.name),text:_("Your personal VPN link")}),"positive"):A([v("download")," ",_("Download card")],()=>Ne(l.name,i),"positive");de(o.title??m(_("Invite %s"),n.name),t("div",{class:"dl-invite"},[t("img",{src:d,alt:m(_("Invite card for %s"),n.name)}),t("div",{class:"dl-invite-side"},[t("p",{class:"dl-muted"},o.lead??m(_("Send %s the card or the link. They open it, add their devices and connect - no account needed."),n.name)),t("button",{type:"button",class:"dl-invite-link",title:_("Copy link"),click:()=>xe(a,_("Personal link copied"))},[t("span",{},a.replace(/^https:\/\//,"")),v("copy")]),...(r??[]).filter(h=>h!==a).map(h=>t("button",{type:"button",class:"dl-invite-link alt",title:_("Copy this link"),click:()=>xe(h,_("Link copied"))},[t("span",{},h.replace(/^https?:\/\//,"")),t("span",{class:`dl-pill ${h.startsWith("http:")?"warn":""}`},h.startsWith("http:")?"HTTP":_("Also")),v("copy")])),t("ol",{class:"dl-invite-steps"},[t("li",{},ae(_("Install %s on the device"),t("b",{},"AmneziaVPN"))),t("li",{},_("Open the link or scan the code")),t("li",{},_("Add the device and connect"))]),t("div",{class:"dl-invite-actions"},[g,A([v("copy")," ",_("Copy link")],()=>xe(a,_("Personal link copied")))])])]),[t("button",{class:"cbi-button cbi-button-neutral",click:w},_("Done"))],"wide")}function en(n,e){let o=n.servers.find(d=>d.id===e)??n.servers[0],s=n.people.filter(d=>d.server===o.id),r=new Set(s.map(d=>d.id)),a=s.flatMap(d=>d.devices),i=d=>s.reduce((c,p)=>{let u=d(p);return[c[0]+u[0],c[1]+u[1]]},[0,0]),l=o.series?.[o.series.length-1];return{...n,servers:[o],people:s,series:o.series??n.series,events:n.events.filter(d=>d.person?r.has(d.person):!0),geo:{...n.geo,points:n.geo.points.filter(d=>r.has(d.person))},totals:{people:s.length,devices:a.length,online:a.filter(d=>d.online).length,active:s.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:i(d=>d.month)}}}var pr=3,Lo=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(e){return e{let w=e.next(),M=null;try{M=await n.fetch(u),o>=pr&&q(_("The router answers again."),"success",3e3),o=0}catch{return++o===pr&&q(_("The router is not answering: what you see may be out of date."),"warning",8e3),null}return M==null||!e.take(w)?null:(n.apply(M,p),M)},r=(p=!1)=>s(p,!1),a=()=>document.visibilityState==="visible",i=()=>a()&&(n.active?.()??!0)?s(!0,!1):Promise.resolve(null);poll.add(i,n.every);let l=n.live?_n(()=>void(a()&&(n.active?.()??!0)&&s(!0,!0))):null,d=()=>{poll.remove(i),l?.(),c()},c=Te(d);return{refresh:r,claim:()=>e.claim(),stop:d}}function Bt(n){let e=document.activeElement;return!!n&&!!e&&e!==document.body&&n.contains(e)}function Ae(n,e,o=!1){return o&&Bt(n)?!1:(dom.content(n,e),!0)}function ur(n,e){let o=n,s=[{v:"internet",ic:"globe",text:_("Browse the internet through your router. No access to devices at home.")},{v:"lan",ic:"home",text:_("Reach devices at home (NAS, printer, cameras). Internet stays on their own connection.")},{v:"both",ic:"shield",text:_("Home devices and the internet, all through your router.")}],r=t("div",{class:"dl-choices"},s.map(a=>t("button",{type:"button",class:`dl-choice${a.v===o?" selected":""}`,"data-v":a.v,click:()=>{o=a.v,r.querySelectorAll(".dl-choice").forEach(i=>i.classList.toggle("selected",i.dataset.v===a.v)),e?.(a.v)}},[t("span",{class:"dl-choice-title"},[v(a.ic),vt(a.v)]),t("span",{class:"dl-choice-text"},a.text)])));return{el:r,get:()=>o}}function Mo(n){try{return localStorage.getItem(n)}catch{return null}}function Eo(n,e){try{localStorage.setItem(n,e)}catch{}}function Ji(n){let e=n.devices.length,o=Math.max(1,n.device_limit,e),s=Math.min(160,o*22+(o-1)*3);return t("div",{class:"dl-slotbar",title:m(N_(n.device_limit,"%s of %s device","%s of %s devices"),e,n.device_limit)},[t("span",{class:"dl-slotbar-segs",style:`width: ${s}px`},Array.from({length:o},(r,a)=>t("i",{class:a>=n.device_limit?"over":an.state==="server_off"?n.paused:!["active","quota","expired"].includes(n.state),To=n=>n.state==="server_off"?n.paused:n.state!=="active",hr=n=>To(n)?n.state==="server_off"?"paused":n.state:null;function Zi(n,e){let o=st(n.expires,e);return n.state==="quota"||n.state==="expired"||rt(n,o)||!!n.quota_limit&&n.quota_used>=n.quota_limit*.9}function fr(n,e){return Lt(n&&no(n,e)>=0?n:e,1)}var gr=n=>n.people.map(e=>e.id).sort().join(" "),vr=!1,wt=class{constructor(){this.list=t("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(e=>e===(new URLSearchParams(location.search).get("filter")??Mo("dl.people.filter")))??"all";this.sort=["seen","name","usage"].find(e=>e===Mo("dl.people.sort"))??"seen";this.query="";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return N.status(30)}scope(e){return this.serverId?en(e,this.serverId):e}embed(e,o){return this.serverId=o,this.render(e)}person(e){return this.st.people.find(o=>o.id===e)}get today(){return Ge(this.st.series)}deviceOpts(e){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:zt(this.st.servers,e.server)}}take(e,o){let s=this.scope(e),r=gr(s)!==gr(this.st);this.st=s,r?this.rebuild():(this.paintCards(o),this.decorate(o))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let e=await N.status(30).catch(()=>null);e&&(this.st=this.scope(e),this.rebuild())}rebuild(){let e=new Map;for(let s of Array.from(this.list.children))s.dataset.sid&&e.set(s.dataset.sid,s);let o=this.st.people.map(s=>{let r=e.get(s.id)??t("div",{class:"dl-card",role:"listitem","data-sid":s.id});return this.renderCard(r,s.id)});dom.content(this.list,o.length?o:t("div",{class:"dl-plist-none"},this.st.servers.length?_("No people yet. Add someone and send them their personal link."):_("Set up the server first, then add people."))),this.decorate()}paintCards(e=!1){for(let o of this.st.people){let s=this.card(o.id);s&&!(e&&Bt(s))&&this.renderCard(s,o.id)}}card(e){return this.list.querySelector(`[data-sid="${CSS.escape(e)}"]`)}render(e){let o=this.scope(e);this.st=o;let s=this,r=t("select",{class:"dl-select","aria-label":_("Sort"),change:d=>{s.sort=d.target.value,Eo("dl.people.sort",s.sort),s.decorate()}},[t("option",{value:"seen",selected:s.sort==="seen"?"selected":null},_("Last seen","sort")),t("option",{value:"name",selected:s.sort==="name"?"selected":null},_("Name","sort")),t("option",{value:"usage",selected:s.sort==="usage"?"selected":null},_("Usage","sort"))]),a=t("input",{type:"search",class:"cbi-input-text dl-people-find",placeholder:_("Find…"),"aria-label":_("Find a person or device"),hidden:o.people.length>8?null:"hidden",input:d=>{s.query=d.target.value.trim().toLowerCase(),s.decorate()}}),i=d=>{let c=d.target;d.key==="/"&&!a.hidden&&!["INPUT","TEXTAREA","SELECT"].includes(c?.tagName)&&!c?.isContentEditable&&(d.preventDefault(),a.focus())};document.addEventListener("keydown",i),Te(()=>document.removeEventListener("keydown",i));let l=t("div",{class:"dl-root"},[s.serverId?"":t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},_("People")),t("span",{class:"dl-muted dl-people-count"},this.countText())]),o.servers.length?A([v("plus"),` ${_("Add person")}`],()=>s.openCreate(),"add"):""]),o.servers.length?"":t("div",{class:"alert-message warning"},ae(_("No server yet. %s before adding people."),t("a",{href:L.url("admin/network/dawnline/server")},_("Run the setup wizard")))),t("div",{class:"dl-toolbar"},[t("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),t("div",{class:"dl-toolbar-end"},[a,r,s.serverId?A([v("plus"),` ${_("Add person")}`],()=>s.openCreate(),"add"):""])]),this.list]);return this.el=l,this.rebuild(),this.poller??(this.poller=pt({fetch:()=>N.status(30),every:30,live:!0,active:()=>!!s.el?.isConnected,apply:(d,c)=>s.take(d,c)})),!vr&&new URLSearchParams(location.search).get("add")&&(vr=!0,setTimeout(()=>s.openCreate(),100)),Promise.resolve(l)}countText(){let e=this.st.totals;return[W(e.people,"%s person","%s people"),W(e.devices,"%s device","%s devices"),m(_("%s online"),K(e.online))].join(" · ")}decorate(e=!1){let o=this.el?.querySelector(".dl-people-count");o&&(o.textContent=this.countText());let s=this.st.people,r=this.today,a=h=>Zi(h,r),i={all:s.length,online:s.filter(h=>h.online>0).length,attention:s.filter(a).length,paused:s.filter(h=>mr(h)).length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(e&&Bt(l))){let h={all:_("All"),online:_("Online"),attention:_("Needs attention"),paused:_("Paused")};dom.content(l,Object.keys(h).map(E=>t("button",{type:"button",role:"tab",class:E===this.filter?"on":"",click:()=>{this.filter=E,Eo("dl.people.filter",E),this.decorate()}},[h[E],t("b",{class:E==="attention"&&i[E]?"warn":""},String(i[E]))])))}let d=this.query,c=h=>[h.name,h.note??"",...h.devices.flatMap(E=>[E.name,E.address,E.hostname,E.endpoint])].join(" ").toLowerCase(),p=h=>!(this.filter==="online"&&!h.online||this.filter==="attention"&&!a(h)||this.filter==="paused"&&!mr(h)||d&&!c(h).includes(d)),u=h=>hr(h)==="paused"?2:To(h)?1:0,w=[...s].sort((h,E)=>u(h)-u(E)||(this.sort==="name"?h.name.localeCompare(E.name):this.sort==="usage"?E.month[0]+E.month[1]-(h.month[0]+h.month[1]):E.online-h.online||E.last_seen-h.last_seen)),M=0;for(let h of w){let E=this.card(h.id);if(!E)continue;this.list.appendChild(E),E.classList.toggle("dl-off",To(h));let H=p(h);E.classList.toggle("dl-filtered",!H),H&&M++}let g=this.el?.querySelector(".dl-people-none")??null;s.length&&!M?(g??(g=t("div",{class:"dl-empty dl-people-none"},t("p",{},_("No one here right now.")))),g.previousElementSibling!==this.list&&this.list.after(g)):g?.remove()}async quick(e,o,s){await F(()=>N.personUpdate(e.id,o),s)&&await this.update()}renderCard(e,o){let s=this.person(o);if(!s)return dom.content(e,t("em",{},_("This person was just removed."))),e;let r=this.today,a=st(s.expires,r),i=Math.max(0,s.device_limit-s.devices.length),l=s.has_link??this.st.settings.portal_enabled,d=[],c=hr(s);if(s.expires&&c!=="expired"){let g=rt(s,a),h=a!=null&&a<0;d.push(t("span",{class:`dl-pill-ic${h?" bad":g?" warn":""}`,title:m(_("Access ends %s"),De(s.expires))},[v("calendar"),h?m(_("ended %s"),De(s.expires)):g?an(a):m(_("until %s"),De(s.expires))]))}s.hours&&c!=="hours"&&d.push(t("span",{class:"dl-pill-ic",title:_("Allowed hours")},[v("clock"),s.hours.replace("-","–")]));let p=ln(s.devices).map(g=>t("button",{type:"button",class:`dl-chip${g.disabled?" disabled":""}${g.online?" live":""}`,title:[at(g.kind),g.address,g.online?m(_("online from %s"),g.endpoint):g.handshake?m(_("seen %s"),pe(g.handshake,this.st.now)):""].filter(Boolean).join(" · "),click:h=>{h.preventDefault(),Je(s,g,this.deviceOpts(s))}},[v(g.kind),t("span",{class:"dl-chip-name"},g.name),!g.handshake&&!g.disabled?t("span",{class:"dl-chip-tag"},_("not set up")):""]));p.push(t("button",{type:"button",class:"dl-chip add",title:i>0?_("Add device"):_("Over the limit: admins can still add"),click:g=>{g.preventDefault(),ct(s,this.deviceOpts(s))}},[v("plus"),_("Add device")]));let u=[];s.expires&&rt(s,a)&&c!=="expired"&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>this.quick(s,{expires:fr(s.expires,r)},_("Extended by 1 month"))},_("Extend 1 month")));let w=$e("more",_("More"),g=>Se(g.currentTarget,[{label:_("Open"),icon:v("open"),run:()=>{location.href=Re(s.id)}},l?{label:_("Invite card"),icon:v("qr"),run:()=>Xt(s,this.st.servers.find(h=>h.id===s.server)?.name??_("Home"))}:null,i>0?{label:_("Add device"),icon:v("plus"),run:()=>ct(s,this.deviceOpts(s))}:null,null,{label:s.paused?_("Resume"):_("Pause"),icon:v(s.paused?"play":"pause"),warn:!s.paused,run:()=>this.togglePause(s)},{label:_("Delete"),icon:v("trash"),danger:!0,run:()=>this.remove(s.id)}].filter((h,E,H)=>h||E>0&&H[E-1])),"neutral","dl-icon-only"),M=t("div",{class:"dl-pcard-actions"},[l?$e("link",_("Copy link"),()=>Sn(s.id),"neutral","dl-icon-only"):"",w]);return dom.content(e,t("div",{class:"dl-pcard"},[t("div",{class:"dl-pcard-main"},[t("div",{class:"dl-pcard-top"},[t("span",{class:`dl-avatar${s.online?" online":""}`},je(s.name)),t("div",{class:"dl-pcard-who"},[t("div",{class:"dl-card-head"},[t("a",{class:"dl-card-name",href:Re(s.id)},s.name),Qo(s),...d]),Ji(s)])]),t("div",{class:"dl-chips"},p),u.length?t("div",{class:"dl-fixes"},u):""]),this.usageSide(s,M),c?this.stopStrip(s,c):""])),e}stopStrip(e,o){let s=this.today,r=Lt(`${s.slice(0,8)}01`,1),a=()=>this.quick(e,{bonus_gb:String((e.bonus_gb||0)+10)},_("+10 GB this month")),i={paused:["pause","warn",_("Paused"),_("Devices can’t connect until you resume"),["play",_("Resume"),()=>this.togglePause(e)]],quota:e.quota_period==="month"?["chart","bad",_("Data limit reached"),m(_("Paused until it resets on %s"),De(r)),["plus",_("+10 GB this month"),a]]:["chart","bad",_("Data limit reached"),_("Paused until the limit is raised"),["edit",_("Change limit"),()=>location.href=Re(e.id)]],expired:["calendar","bad",m(_("Access ended %s"),De(e.expires)),_("Devices can’t connect"),["calendar",_("Extend 1 month"),()=>this.quick(e,{expires:fr(e.expires,s)},_("Extended by 1 month"))]],hours:["clock","warn",_("Outside allowed hours"),m(_("Access %s (router time)"),e.hours.replace("-","–")),null],no_server:["alert","warn",_("No server"),_("Choose a server on their page"),null]},[l,d,c,p,u]=i[o];return t("div",{class:`dl-pstrip ${d}`},[t("span",{class:`dl-need-ic ${d}`},v(l)),t("span",{class:"dl-pstrip-text"},[t("b",{},c),t("span",{class:"dl-faint"},p)]),u?A([v(u[0]),` ${u[1]}`],u[2]):""])}usageSide(e,o){let s=e.quota_used||e.month[0]+e.month[1],r=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,a=e.devices.reduce((p,u)=>p+(u.spark[u.spark.length-1]??[0,0]).reduce((w,M)=>w+M),0),i=e.rate?.[e.rate.length-1],l=e.online&&i&&this.st.now-i[0]<180,d=t("div",{class:`dl-usebar${r>=100?" bad":r>=90?" warn":""}`});if(e.quota_limit){let p=t("i",{class:"fill"});p.style.width=`${r}%`,d.appendChild(p),we(d,()=>[t("div",{class:"dl-tip-title"},m(_("%s%% used"),K(r,1))),t("div",{class:"dl-muted"},`${m(_("%s of %s"),se(e.quota_used),se(e.quota_limit))} · ${m(_("%s left"),se(Math.max(0,e.quota_limit-e.quota_used)))}`),t("div",{class:"dl-faint"},e.quota_period==="total"?_("In total"):[_("This month"),e.bonus_gb?m(_("includes +%s GB extra"),K(e.bonus_gb)):""].filter(Boolean).join(" · "))])}else{let p=e.devices.map(u=>({d:u,v:u.month[0]+u.month[1]})).filter(u=>u.v>0).sort((u,w)=>w.v-u.v);p.forEach((u,w)=>{let M=t("i",{class:`c${Math.min(w,4)}`});M.style.flexGrow=String(u.v),d.appendChild(M)}),p.length&&we(d,()=>[t("div",{class:"dl-tip-title"},_("This month by device")),...p.map((u,w)=>t("div",{class:"dl-tip-row"},[t("span",{class:`dl-swatch c${Math.min(w,4)}`}),t("span",{},u.d.name),t("b",{},se(u.v))]))])}let c=e.quota_limit?m(_("%s left"),se(Math.max(0,e.quota_limit-e.quota_used))):_("no limit");return t("div",{class:"dl-pside"},[t("div",{class:"dl-pside-top"},[l?t("span",{class:"dl-pside-state live"},_("Online")):t("span",{class:"dl-pside-state"},e.online?_("Online"):e.last_seen?_("Offline"):_("Never connected")),o]),t("div",{class:"dl-use-num"},[t("b",{class:s?"":"dl-faint"},se(s)),t("span",{class:"dl-faint"},e.quota_limit?m(_("of %s"),se(e.quota_limit)):e.quota_period==="total"&&e.quota_gb?_("in total"):_("this month"))]),d,l?t("div",{class:"dl-use-live",title:_("Right now")},[`↓ ${Fe(i[2])}`,t("span",{class:"dl-faint"},`↑ ${Fe(i[1])}`)]):t("div",{class:"dl-faint dl-pside-foot"},a?`${m(_("today %s"),se(a))} · ${c}`:c)])}async togglePause(e){await F(()=>N.personPause(e.id,!e.paused),m(e.paused?_("%s resumed"):_("%s paused"),e.name))&&await this.refresh()}async remove(e){let o=this.person(e);await me(m(_("Remove %s?"),o?.name??e),W(o?.devices.length??0,"%s device is disconnected immediately and the personal link stops working. Usage history is kept in backups.","All %s devices are disconnected immediately and the personal link stops working. Usage history is kept in backups."),_("Remove"),!0)&&await F(()=>N.personDelete(e),_("Person removed"))&&await this.refresh()}openCreate(){let e=this.st;if(!e.servers.length){q(_("Set up the server first."),"warning");return}let o=t("input",{type:"text",class:"cbi-input-text",placeholder:_("e.g. Myata"),maxlength:48}),s=(()=>{try{return JSON.parse(Mo("dl.person.last")??"{}")}catch{return{}}})(),r=ur(s.access??"internet"),a=t("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:e.settings.default_device_limit}),i=t("input",{type:"date",class:"cbi-input-text"}),l=t("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:_("Unlimited"),value:s.quota??""}),d=(S,$)=>t("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{i.value=$?Lt(Ge(e.series),$):"",i.dispatchEvent(new Event("change"))}},S),c=e.servers[0],p=!this.serverId&&e.servers.length>1?t("select",{class:"cbi-input-select"},e.servers.map(S=>t("option",{value:S.id},S.name))):null,u=(S,$,b)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},S),t("div",{class:"cbi-value-field"},[$,b?t("div",{class:"cbi-value-description"},b):""])]),w=Ge(e.series),M=Ee(_("Name","person"),o,()=>He(o.value,[],_("Shown in their portal and apps."))),g=Ee(_("Devices"),a,()=>fn(a.value)),h=Ee(_("End date"),i,()=>ms(i.value,w,st,De),t("div",{class:"dl-actions"},[i,d(_("1 month"),1),d(_("3 months"),3),d(_("1 year"),12),d(_("None","end date"),0)])),E=Ee(_("Monthly data (GB)"),l,()=>gn(l.value));i.addEventListener("change",()=>h.refresh());let H=e.settings.portal_enabled;de(_("Add person"),[M,p?u(_("Server"),p):"",t("div",{class:"cbi-value dl-block"},[t("label",{class:"cbi-value-title"},_("Access")),t("div",{class:"cbi-value-field"},r.el)]),g,h,E],[ue()," ",A(H?_("Create and copy link"):_("Create"),async()=>{let S=Ue([M,g,h,E]);if(S){q(S,"warning");return}let $=await F(()=>N.personCreate(o.value.trim(),"",p?.value??c.id,r.get(),a.value.trim(),i.value,l.value.trim(),"month"));$&&(Eo("dl.person.last",JSON.stringify({access:r.get(),quota:l.value.trim()})),$.link&&await xe($.link,_("Personal link copied"),!0),this.showCreated($.id,o.value.trim(),$.link,e.servers.find(b=>b.id===(p?.value??c.id))?.name??c.name),await this.refresh())},"positive")]),setTimeout(()=>o.focus(),50)}showCreated(e,o,s,r){if(s){Xt({id:e,name:o,link:s},r,{title:m(_("%s is ready"),o),lead:m(_("Send %s the card or the link. They open it, add their devices and connect - no account needed."),o)});return}let a=this.person(e);de(m(_("%s is ready"),o),[t("p",{},_("Created. Turn on the personal portal in Settings to get a link, or add devices for them here."))],[t("button",{class:"cbi-button cbi-button-neutral",click:ce},_("Done"))," ",t("a",{class:"cbi-button cbi-button-neutral",href:`${L.url("admin/network/dawnline/settings")}?section=portal`},_("Open Settings"))," ",a?A(_("Add device"),()=>{ce(),ct(a,this.deviceOpts(a))},"positive"):""])}};var Pn=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],So=n=>t("i",{class:"dl-circle-dot",style:`background:${Pn[n?.color??0]??Pn[0]}`}),ut=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function br(n,e,o){let s=he(n?.name??e.name??"",{placeholder:_("NAS")}),r=he(n?.address??e.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),a=he((n?.ports??e.ports??[]).join(", "),{placeholder:_("All ports, or e.g. 445, 5000"),class:"cbi-input-text dl-mono"}),i=Ee(_("Name","circle or service"),s,()=>He(s.value,[],_("Shown to people who may reach it."))),l=Ee(_("Address"),r,()=>hs(r.value)),d=Ee(_("Ports"),a,()=>fs(a.value));de(n?m(_("Edit %s"),n.name):_("Add service"),[i,l,d],[ue()," ",A(_("Save"),async()=>{let c=Ue([i,l,d]);if(c){q(c,"warning");return}let p=a.value.split(/[ ,]+/).filter(Boolean);await F(()=>N.serviceSet(n?.id??"",s.value,r.value,p),_("Saved"))&&(ce(),o())},"positive")])}function Qi(){let n=_("Web"),e=_("Printer");return{_smb:"SMB",_afpovertcp:"AFP",_http:n,_https:n,_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:e,_ipps:e,_printer:e,"_pdl-datastream":e,_airplay:"AirPlay",_raop:"AirPlay",_rfb:_("Screen sharing"),_googlecast:"Cast",_hap:"HomeKit",_rdp:_("Remote desktop"),_ftp:"FTP"}}function Xi(n){let e=Qi(),o=new Map;for(let s of n.services){let r=e[s.type.split(".")[0]];!r||!s.port||(o.get(r)??o.set(r,new Set).get(r)).add(String(s.port))}return o.size?[...o].map(([s,r])=>[s,[...r].sort((a,i)=>+a-+i)]):[[_("Web"),["80","443"]],["SMB",["445"]],["SSH",["22"]]]}function xr(n,e,o){let s=n,r=null,a=!1,i=null,l=new Set,d=t("div",{class:"dl-list"}),c=t("div",{class:"dl-stack gap8"},t("span",{class:"dl-sub"},_("Looking for devices at home…"))),p=()=>{let h=s.services;dom.content(d,h.length?h.map(E=>t("div",{class:"dl-row"},[v("home"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},E.name),t("span",{class:"dl-mono dl-faint"},`${E.address} · ${E.ports.length?m(_("ports %s"),E.ports.join(", ")):_("all ports")}`)]),A(_("Edit"),()=>br(E,{},o)),A([v("trash")],async()=>{await me(m(_("Remove %s?"),E.name),_("People limited to this service lose access to it."),_("Remove"),!0)&&await F(()=>N.serviceDelete(E.id),_("Removed"))&&await o()},"neutral",{title:_("Remove"),"aria-label":m(_("Remove %s"),E.name)})])):[t("div",{class:"dl-row dl-muted"},_("No services yet: pick ports of a device below."))])};async function u(h,E){if(!l.has(h.address)){l.add(h.address),M();try{let H=s.services.find($=>$.address===h.address);(E===null?H&&await F(()=>N.serviceDelete(H.id),m(_("%s removed"),H.name)):await F(()=>N.serviceSet(H?.id??"",H?.name??(h.name||h.address),h.address,E),H?m(_("%s updated"),H.name):m(_("%s added"),h.name||h.address)))&&await o()}finally{l.delete(h.address),M()}}}function w(h){let E=s.services.find(C=>C.address===h.address),H=!!E&&!E.ports.length,S=new Set(E?.ports??[]),$=l.has(h.address),b=(C,y,z)=>Xe(C,y,z,{disabled:$?"disabled":null,"aria-busy":$?"true":null});return t("div",{class:"dl-row"},[v(h.services.some(C=>C.type.startsWith("_ipp")||C.type.startsWith("_printer"))?"file":"computer"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},h.name||h.address),t("span",{class:"dl-mono dl-faint"},h.address)]),t("div",{class:"dl-chips-row dl-host-ports"},[b(_("All ports"),H,()=>u(h,H?null:[])),...Xi(h).map(([C,y])=>{let z=!H&&y.every(k=>S.has(k));return b(`${C} ${y.join(", ")}`,z,()=>{let k=new Set(H?[]:S);for(let f of y)z?k.delete(f):k.add(f);u(h,k.size?[...k]:null)})})])])}function M(){if(a)return dom.content(c,t("span",{class:"dl-sub"},_("Couldn't read the devices at home.")));if(!r)return;let h=r;if(!h.hosts.length)return dom.content(c,t("span",{class:"dl-sub"},_("No devices found in the home network right now.")));let E=t("details",{class:"dl-params",open:i??!s.services.length?"":null},[t("summary",{},[v("chevron"),t("span",{},_("Add from devices at home")),t("span",{class:"dl-pcount"},String(h.hosts.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},h.mdns?_("Ports they announce over Bonjour. Pick what to open, or all ports."):_("Devices that got an address from this router. Pick the ports to open, or all ports.")),t("div",{class:"dl-list"},h.hosts.map(w))])]);E.addEventListener("toggle",()=>i=E.open),dom.content(c,E)}return N.homeHosts(e).then(h=>{r=h,M()}).catch(()=>{a=!0,M()}),p(),{el:t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-iflead"},[t("div",{class:"dl-iflead-row"},[t("b",{},_("Home services")),A([v("plus")," ",_("Add service")],()=>br(null,{},o))]),t("span",{class:"dl-sub"},_("Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers."))]),d,c]),update(h){s=h,p(),M()}}}function $n(n,e,o,s){let r=new Set(n.circles.filter(h=>h.server===e).map(h=>h.color)),a=o?.color??Pn.findIndex((h,E)=>!r.has(E));a<0&&(a=0);let i=he(o?.name??"",{placeholder:_("Family")}),l=n.people.filter(h=>h.server===e).sort((h,E)=>h.name.localeCompare(E.name)),d=new Set(l.filter(h=>o&&h.circle===o.id).map(h=>h.id)),c=t("div",{class:"dl-swatches",role:"radiogroup","aria-label":_("Colour")}),p=()=>dom.content(c,Pn.map((h,E)=>t("button",{type:"button",role:"radio",class:`dl-swatch${E===a?" on":""}`,style:`--sw:${h}`,"aria-checked":E===a?"true":"false","aria-label":m(_("Colour %s"),E+1),click:()=>{a=E,p()}})));p();let u=t("div",{class:"dl-chips-row"},l.map(h=>{let E=h.circle&&h.circle!==o?.id?n.circles.find(H=>H.id===h.circle):void 0;return t("button",{type:"button",class:`dl-chipbtn${d.has(h.id)?" on":""}`,title:ut(h)?E?m(_("Now in %s"),E.name):"":m(_("%s has no home access: their devices aren't reachable anyway"),h.name),click:H=>{d.delete(h.id)||d.add(h.id),H.currentTarget.classList.toggle("on",d.has(h.id))}},[h.name,ut(h)?E?t("b",{},E.name):"":t("b",{},_("internet"))])})),w=(h,E)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},h),t("div",{class:"cbi-value-field"},E)]),M=n.circles.filter(h=>h.server===e&&h.id!==o?.id).map(h=>h.name),g=Ee(_("Name","circle or service"),i,()=>ds(i.value,M));de(o?m(_("Edit %s"),o.name):_("New circle"),[g,w(_("Colour"),c),w(_("People"),u),t("p",{class:"dl-sub"},_("Devices of people in one circle reach each other. A person is in one circle at a time."))],[o?A(_("Delete"),async()=>{await F(()=>N.circleDelete(o.id),m(_("%s deleted"),o.name))&&(ce(),s())},"negative"):"",t("span",{class:"dl-spacer"}),ue()," ",A(_("Save"),async()=>{let h=g.help();if(h.bad){q(h.text,"warning");return}await F(()=>N.circleSet(o?.id??"",e,i.value,a,[...d]),_("Saved"))&&(ce(),s())},"positive")],"dl-circle-modal")}function wr(n,e,o){let s=n.circles.filter(r=>r.server===e);return t("div",{class:"dl-chips-row dl-circles"},[...s.map(r=>{let a=n.people.filter(i=>i.circle===r.id).map(i=>i.name);return t("button",{type:"button",class:"dl-chip",title:m(_("Edit %s"),r.name),click:()=>$n(n,e,r,o)},[So(r),t("b",{},r.name),t("span",{class:"dl-faint"},a.length?a.join(", "):_("nobody yet"))])}),t("button",{type:"button",class:"dl-chip add",title:_("New circle"),"aria-label":_("New circle"),click:()=>$n(n,e,null,o)},v("plus"))])}function Po(n,e){let o=n.people.filter(p=>p.server===e.id),s=(p="")=>t("span",{class:"dl-yes"},[v("check"),p]),r=()=>t("span",{class:"dl-faint"},"—"),a=p=>{let u=new Set(p.map(M=>M.access==="lan"&&M.services?.length?"services":M.home_nets?.length?"some":"all"));u.size||u.add("all");let w={all:_("all networks"),some:_("their networks"),services:_("services")};return s([...u].map(M=>w[M]).join(" / "))},i=()=>e.mesh==="off"?r():e.mesh==="circles"?s(_("circle")):s(),l=e.lan_like?_("like home"):_("direct"),d=(p,u,w)=>t("tr",{},[t("td",{},[t("b",{},p),t("div",{class:"dl-sub"},W(u.length,"%s person","%s people"))]),...w.map(M=>t("td",{},M))]),c=p=>o.filter(u=>u.access===p);return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Who reaches what")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},_("From the rules on this server"))]),t("div",{class:"dl-reach-wrap"},t("table",{class:"dl-table dl-reach"},[t("tr",{},["",_("Internet"),_("Home"),_("This router"),_("Each other")].map(p=>t("th",{},p))),d(_("Internet"),c("internet"),[s(l),r(),t("span",{class:"dl-faint"},"DNS"),r()]),d(_("Home"),c("lan"),[t("span",{class:"dl-faint"},_("their own")),a(c("lan")),s(),i()]),d(_("Both"),c("both"),[s(l),a(c("both")),s(),i()])])),t("p",{class:"dl-sub"},_("Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing."))])])}function yr(n,e){let o=n.people.filter(c=>c.server===e.id).flatMap(c=>c.devices.map(p=>({id:p.id,label:`${c.name} · ${p.name}`}))).sort((c,p)=>c.label.localeCompare(p.label)),s="@addr",r=(c,p)=>{let u=t("select",{class:"cbi-input-select","aria-label":c},[...o.map(h=>t("option",{value:h.id,selected:h.id===p?"selected":null},h.label)),t("option",{value:s,selected:p===s?"selected":null},_("Address"))]),w=he("",{placeholder:c,class:"cbi-input-text dl-mono"}),M=t("div",{class:"dl-check-end"},[u,w]),g=()=>w.hidden=u.value!==s;return u.addEventListener("change",g),g(),{el:M,value:()=>u.value===s?w.value.trim():u.value}},a=r("10.0.1.11",o[0]?.id??s),i=r("10.0.1.20:445",s),l=t("div",{class:"dl-stack gap8"}),d=async()=>{let c=await F(()=>N.accessCheck(a.value(),i.value()));if(!c)return;let p=c.steps.findIndex(u=>!u.ok);dom.content(l,[t("div",{class:`dl-verdict ${c.ok?"ok":"bad"}`},[t("b",{},c.ok?_("Allowed"):_("Blocked")),t("span",{class:"dl-sub"},c.ok?_("Every step lets it through"):m(_("Stops at step %s of %s"),p+1,c.steps.length))]),t("ul",{class:"dl-checks"},c.steps.map(u=>t("li",{},[t("span",{class:`dl-check-icon ${u.ok?"ok":"error"}`},v(u.ok?"check":"x")),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},u.title),u.detail?t("div",{class:"dl-check-detail"},u.detail):""])])))])};return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Check access")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},_("Why something does or does not connect"))]),t("div",{class:"dl-check-form"},[a.el,t("span",{class:"dl-faint"},"→"),i.el,A(_("Check"),d)]),l])])}function Dn(n){return n==="app"?"Dawnline":n==="amneziawg"?"AmneziaWG":n==="packages"||n==="pkgs"?_("System packages"):void 0}function mt(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function An(n){return mt(n.action==="check"?`check:${n.component??""}`:n.component??"")}function kr(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function _r(n,e){return!n?.from&&!n?.to?e:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??e}function Cr(n,e){let o=n.check?.components??{},s=e==="all"?["app","amneziawg","packages"]:[e],r=[],a;for(let l of s){let d=o[l];if(d){if(d.error)return{tone:"warn",text:d.error};l==="packages"&&d.updates?r.push(W(d.updates,"%s system package","%s system packages")):l!=="packages"&&d.update&&d.installed&&d.latest&&(r.push(`${Dn(l)} ${d.latest}`),e!=="all"&&(a=d.latest))}}if(r.length)return{tone:"acc",text:m(_("Update available: %s"),r.join(", ")),update:a};let i=s.length===1?o[s[0]]:null;return i?.status==="dev"?{tone:"acc",text:m(_("Installed version is newer than the release (%s)"),i.latest)}:i?.note?{tone:"warn",text:i.note}:{tone:"ok",text:s.length>1?_("Everything is up to date"):_("Latest version is installed")}}function Lr(n,e,o,s){return e?n.id===e:o&&n.id===o?!1:n.state==="running"||s>0&&n.started>=s}var $o=n=>new Promise(e=>setTimeout(e,n));async function tn(n,e,o){let s=o?An(o):mt(n),r=o?o.action==="check":n.startsWith("check"),a=Date.now(),i=t("b",{},Dn(s)??(s==="all"?_("All components"):"Dawnline")),l=t("span",{class:"dl-pill dl-mono"},e.version??""),d=t("span",{class:"dl-pill info",hidden:!0}),c=t("span",{},"0:00"),p=t("pre",{class:"dl-log"},_("Operation started. Waiting for log output…")),u=t("div",{}),w=t("div",{class:"dl-op-actions"}),M=[],g=x=>dom.content(w,x),h=(x=!1)=>ue(_("Close"),x);de(e.title,t("div",{class:"dl-op"},[t("div",{class:"dl-op-head"},[i,e.version?l:"",d,t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-op-timer"},[v("clock"),c])]),t("div",{class:"dl-op-loghead"},[t("b",{},_("Operation log")),$e("copy",_("Copy log"),()=>xe(M.join(` -`),_("Log copied")))]),p,u]),[w],"wide"),g([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?_("Checking…"):_("Working…"))]);let E=o??null,H=o?.id,S,$=0,b=x=>{H!==x.id&&(H=x.id,e.onJob?.(x))};if(o)e.onJob?.(o);else try{let x=await N.updatesStatus().catch(()=>null);S=x?.job?.id,$=x?.now??0;let T=await N.updatesRun(n);T.job&&T.job.state==="running"&&T.job.id!==S&&(E=T.job,b(T.job))}catch(x){return M=[Ce(x)],p.textContent=M[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[v("alert"),t("span",{},Ce(x))])),g([h(!0)]),q(Ce(x),"error"),null}let C=null,y=0;for(;;){if(await $o(1e3),C=await N.updatesStatus().catch(()=>null),!C){if(++y>60)break;continue}y=0;let x=C.job;if(!x||!Lr(x,H,S,$)){if(Date.now()-a>15e3)break;continue}if(b(x),E=x,x.log.length){M=x.log;let T=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=M.join(` -`),T&&(p.scrollTop=p.scrollHeight)}if(l.textContent=_r(x,e.version??""),!l.isConnected&&l.textContent&&i.after(l),c.textContent=kr((x.finished??C.now)-x.started),x.state==="running"){d.hidden=!x.phase,d.textContent=x.phase;continue}break}if(p.scrollTop=p.scrollHeight,d.hidden=!1,!E||E.state==="running")return d.className="dl-pill warn",d.textContent=_("No answer"),dom.content(u,t("div",{class:"dl-comp-status warn"},[v("alert"),t("span",{},_("The router stopped answering. The job may still finish: reopen Components in a minute."))])),g([h()]),e.onDone?.(C),E;if(E.state==="failed")return d.className="dl-pill bad",d.textContent=_("Failed"),dom.content(u,t("div",{class:"dl-comp-status bad"},[v("x"),t("span",{},[t("b",{},(E.error??_("Operation failed")).replace(/\.$/,"")),r?"":`. ${_("Nothing else was changed.")}`])])),g([A(_("Copy log"),()=>xe(M.join(` -`),_("Log copied"))),h(!0)]),q(`${Dn(s)??_("Update","noun")}: ${E.error??_("failed")}`,"error"),e.onDone?.(C),E;if(d.className="dl-pill ok",d.textContent=_("Finished"),r&&C){let x=Cr(C,s);if(dom.content(u,t("div",{class:`dl-comp-status ${x.tone}`},[v(x.tone==="ok"?"check":x.tone==="warn"?"alert":"download"),t("span",{},x.text)])),q(x.text,x.tone==="warn"?"warning":"success"),e.onDone?.(C),x.update&&e.onUpdate){let T=C;g([h(),A(m(_("Update to %s"),x.update),()=>e.onUpdate(T),"positive")])}else g([h()]),x.tone==="ok"&&setTimeout(()=>u.isConnected&&ce(),1200);return E}let z=/^app:(lang:|nolang$)/.exec(E.component??"");if(z){let x=()=>{ui.menu?.flushCache(),location.reload()};return dom.content(u,t("div",{class:"dl-comp-status ok"},[v("check"),t("span",{},[t("b",{},z[1]==="nolang"?_("The translation is removed."):_("The translation is installed."))," ",_("Reloading the page…")])])),g([h(),A(_("Reload now"),x,"positive")]),await $o(4e3),u.isConnected&&x(),E}if(s==="app"&&E.to){let x=E.to,T=t("span",{},_("Waiting for the router to restart its services…"));dom.content(u,t("div",{class:"dl-comp-status ok"},[v("check"),t("span",{},[t("b",{},m(_("Dawnline %s is installed."),x))," ",T])]));let I=()=>{ui.menu?.flushCache(),location.reload()};g([h(),A(_("Reload now"),I,"positive")]),q(m(_("Dawnline updated to %s"),x),"success",6e3);for(let V=1;V<=30;V++)if(T.textContent=m(_("Waiting for the router to restart its services (%s of 30)…"),V),await $o(1500),(await N.updatesStatus().catch(()=>null))?.version===x)return T.textContent=_("Services are back. Reloading…"),setTimeout(I,800),E;return T.textContent=_("Services restarted. Reload the page to use the new version."),E}let k=[...E.result?.pkgs?.updated??[],...E.result?.pkgs?.installed??[]],f=s==="pkgs"?k.length?m(_("Updated %s"),k.join(", ")):_("Updated system packages"):s==="amneziawg"?E.to?m(_("AmneziaWG %s is installed"),E.to):_("AmneziaWG is installed"):_("Operation completed");return dom.content(u,t("div",{class:"dl-comp-status ok"},[v("check"),t("span",{},f)])),g([h()]),q(f,"success"),e.onDone?.(C),E}function el(n){return{https:[_("Install HTTPS for the portal?"),_("Installing HTTPS for the portal")],acme:[_("Install ACME certificates?"),_("Installing ACME certificates")],home:[_("Install the home-like link?"),_("Installing the home-like link")],awg:[_("Install AmneziaWG?"),_("Installing AmneziaWG")]}[n]}async function Mr(n,e,o,s){let[r,a]=el(e);return!await me(r,o,_("Install"))||(await tn(n,{title:a}))?.state!=="done"?!1:(setTimeout(()=>s?.(),4e3),!0)}function Nn(n){return Mr("amneziawg:auto","awg",_("Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds."),n)}async function nn(n,e,o){return n==="awg"?Nn(o):e.length?Mr(`pkgs:${e.join(",")}`,n,m(_("%s from the OpenWrt feeds. Dawnline sets the rest up when they arrive."),e.join(", ")),o):!0}async function Er(n,e){if(n==="awg")return Nn(e);let o=await F(()=>N.updatesStatus());return o?nn(n,o.needs?.[n]??[],e):!1}var tl=()=>[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn",_("VPN & tunnels")],["other",_("Other")]],nl={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function Tr(n,e,o){let s=n.id,r=e,a=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},_("Loading interfaces…"))))),i,l=!0,d="",c=!0,p=!0,u="all",w=!1,M=xr(r,s,o),g=new Set,h="",E=()=>JSON.stringify([p,l,l?"":d,c,[...g].sort()]),H=()=>i.detected.lan||i.saved.lan||"",S=()=>(l?i.detected.wan||i.saved.wan:d)||"",$=()=>new Map(i.devices.map(B=>[B.name,B])),b=()=>{let B=$();return[...c&&H()?[H()]:[],...[...g].filter(ne=>ne!==H())].filter(ne=>ne!==S()).map(ne=>B.get(ne)??{name:ne,nets:[],missing:!0})},C=(B,Q)=>{i=B,Q&&(l=B.config.auto_wan,d=B.config.wan_device||B.detected.wan||B.saved.wan||"",c=B.config.auto_lan,p=B.config.lan_like,u=B.config.mesh??(B.config.device_mesh?"all":"off"),g=new Set(B.config.lan_devices),h=E()),J()},y=async B=>{let Q=await N.interfaces(s).catch(ne=>(q(ne.message,"error"),null));Q&&C(Q,B)};function z(B){let Q=c&&B.name===H(),ne=!!B.own||!!B.master||B.name===S()||Q;return Q||g.has(B.name)||!ne&&(B.nets.length>0||!!B.missing)}function k(B){let Q=c&&B.name===H(),ne=B.name===S(),fe=!Q&&g.has(B.name),j=!(!!B.own||!!B.master||ne||Q)&&(B.nets.length>0||fe||!!B.missing),Y=(fe||Q)&&!B.zone&&!B.missing,ie=B.missing?_("Not present right now"):B.own?_("This server"):B.master?m(_("Port of %s"),B.master):ne?`${_("Internet")}${B.zone?` · ${m(_("zone %s"),B.zone)}`:""}`:B.nets.length?B.nets.join(", "):_("No IPv4 network"),ve=t("button",{type:"button",class:`dl-if${fe?" sel":""}${Q?" auto":""}${!j&&!fe&&!Q?" off":""}${Y?" warn":""}`,"aria-pressed":fe||Q?"true":"false","aria-disabled":j?null:"true",click:()=>{j&&(g.has(B.name)?g.delete(B.name):g.add(B.name),J())}},[t("span",{class:"dl-if-ic"},v(nl[B.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},B.name),t("span",{class:"dl-if-sub"},ie)]),Q?t("span",{class:"dl-if-badge ok"},_("Auto")):fe?t("span",{class:"dl-if-check"},v("check")):""]);return we(ve,()=>[t("div",{class:"dl-tip-title"},B.name),t("div",{class:"dl-muted"},[B.logical?m(_("Interface %s"),B.logical):_("No netifd interface")," · ",B.zone?m(_("zone %s"),B.zone):_("no firewall zone")]),B.members.length?t("div",{class:"dl-muted"},m(_("Ports: %s"),B.members.join(", "))):"",B.nets.length?t("div",{class:"dl-mono"},B.nets.join(", ")):"",Y?t("div",{class:"dl-warn"},_("Not in a firewall zone: the firewall rejects this traffic.")):"",B.master?t("div",{class:"dl-muted"},m(_("Choose %s to include it."),B.master)):""]),ve}function f(){let B=i.like_home;return!p||!i.config.lan_like||!n.enabled?"":!i.needs?.length&&B.active&&B.bridged?"ok":"warn"}function x(){let B=i.like_home;return p?i.needs?.length?[t("span",{class:"dl-warn"},m(_("Needs %s."),new Intl.ListFormat(le(),{type:"conjunction"}).format(i.needs)))," ",_("Until they are installed, internet traffic goes straight to the WAN.")]:i.config.lan_like?n.enabled?B.active&&B.bridged?ae(_("Internet traffic enters %s as %s, so whatever handles home traffic (proxies, filters, DNS) handles it too."),t("span",{class:"dl-mono"},B.dev??""),t("span",{class:"dl-mono"},B.address??"")):[t("span",{class:"dl-warn"},m(_("Not working: %s"),B.error??_("the link is down")))," ",_("Internet traffic goes straight to the WAN for now.")]:[_("Internet traffic enters the router from your LAN, so whatever handles home traffic (proxies, filters, DNS) handles it too.")]:[_("Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on.")]:[_("Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router.")]}let T=B=>({off:_("Devices of different people never reach each other; a person's own devices don't either."),all:_("Devices of people with home access reach each other, like home devices do. Internet-only people never."),circles:_("Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never.")})[B];function I(B,Q,ne,fe,oe="",j){return t("div",{class:j?"dl-setrow head":"dl-setrow"},[t("div",{class:"dl-lh-main"},[t("span",{class:`dl-need-ic ${oe}`},v(B)),t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},Q),t("span",{class:"dl-sub"},ne),j??""])]),t("div",{class:"dl-setrow-ctl"},fe)])}let V=(B,Q)=>{let ne=fe=>t("span",{class:"dl-mono"},fe);return B?t("span",{},[" ",...Q&&Q!==B?ae(_("Now: %s, was %s."),ne(B),ne(Q)):ae(_("Now: %s."),ne(B))]):t("span",{},[" ",...Q?ae(_("Not found now: using %s."),ne(Q)):[_("Not found.")]])};function J(){let B=t("select",{class:"cbi-input-select","aria-label":_("Internet interface"),change:D=>{d=D.target.value,J()}},i.devices.filter(D=>!D.own&&!D.master&&D.zone&&!D.missing).map(D=>t("option",{value:D.name,selected:D.name===d?"selected":null},`${D.name} · ${m(_("zone %s"),D.zone)}`))),ne=b().flatMap(D=>D.nets.map(G=>[G,D.name])),fe=JSON.parse(E()),oe=JSON.parse(h),j=(...D)=>D.some(G=>JSON.stringify(fe[G])!==JSON.stringify(oe[G])),Y=j(0,1,2),ie=j(3,4),ve=D=>A(_("Save"),async()=>{let G=await F(()=>N.serverInterfaces(s,l,l?"":d,c,[...g],p,u!=="off",u),_("Access saved"));G&&(C(G,!0),G.nets_changed&&G.lan_only&&q(W(G.lan_only,"%s person has Home-only access: their devices need the configuration again to reach the new networks.","%s people have Home-only access: their devices need the configuration again to reach the new networks."),"warning",1e4))},"positive",{disabled:!D}),R=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Internet")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},_("People with Internet or Both"))]),I("home",_("Internet like a home device"),x(),[p&&i.needs?.length?A(_("Install"),()=>nn("home",i.needs,()=>y(!1)),"positive"):"",ye(p,_("Internet like a home device"),D=>{p=D,J()})],f()),I("globe",_("Auto-detect WAN"),[_("The interface with the default route: the server port opens there and Internet access leaves through it."),V(i.detected.wan,i.saved.wan)],[l?"":B,ye(l,_("Auto-detect WAN"),D=>{l=D,J()})])]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},p?[_("Internet like a home device"),S()?[" · ",...ae(_("leaves through %s"),t("span",{class:"dl-mono"},S()))]:""]:S()?ae(_("Internet straight to %s"),t("span",{class:"dl-mono"},S())):_("No WAN found")),ve(Y)])]),O=Me([["off",_("Off")],["all",_("Everyone")],["circles",_("Circles")]],u,{label:_("Devices reach each other"),cls:"sm",optimistic:!1,onChange:async D=>{let G={off:_("Off"),all:_("Everyone"),circles:_("Circles")}[D];await F(()=>N.serverUpdate(s,{mesh:D}),m(_("Devices reach each other: %s"),G))&&(u=D,i.config.mesh=D,J(),await o())}}),P=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Home network")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},_("People with Home or Both")),A([v("reset")," ",_("Rescan")],()=>y(!1),"neutral",{title:_("Read the interfaces again")})]),I("network",_("Networks"),_("Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it."),"","",te()),I("link",_("Devices reach each other"),T(u),O,"",u==="circles"?wr(r,s,o):void 0),M.el]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub dl-if-summary"},ne.length?ae(_("Home access reaches %s"),t("span",{},ne.flatMap(([D,G],ee)=>[ee?", ":"",t("span",{class:"dl-mono"},D),` (${G})`]))):_("No home network: Home access reaches nothing but this router.")),ve(ie)])]),U=window.scrollY;a.style.minHeight=`${a.offsetHeight}px`,dom.content(a,[R,P]),a.style.minHeight="",window.scrollTo({top:U})}function te(){let B=i.devices.filter(z),Q=i.devices.filter(ne=>!z(ne));return t("div",{class:"dl-stack gap8 dl-netpick"},[B.length?t("div",{class:"dl-ifgrid"},B.map(k)):t("span",{class:"dl-warn"},_("No home network: Home access reaches nothing but this router.")),t("label",{class:"dl-boxrow"},[t("span",{class:"dl-stack"},[t("span",{},_("Auto-detect LAN")),t("span",{class:"dl-sub"},[_("Adds the LAN this router uses."),V(i.detected.lan,i.saved.lan)])]),ye(c,_("Auto-detect LAN"),ne=>{c=ne,J()})]),Q.length?t("details",{class:"dl-params",open:w?"":null,toggle:ne=>w=ne.currentTarget.open},[t("summary",{},[v("chevron"),t("span",{},_("Other interfaces")),t("span",{class:"dl-pcount"},String(Q.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},_("The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network.")),...tl().map(([ne,fe])=>{let oe=Q.filter(j=>j.category===ne);return oe.length?t("div",{class:"dl-ifgroup"},[t("h4",{},fe),t("div",{class:"dl-ifgrid"},oe.map(k))]):""})])]):""])}return y(!0),{el:a,update(B){r=B,M.update(B),i&&J()}}}var ol={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",expiring:"warn",expired_kept:"",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},sl={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",expiring:"calendar",expired_kept:"calendar"};function rl(n,e){return e.device?n.people.flatMap(s=>s.devices).find(s=>s.id===e.device)?.kind??e.dkind??"other":sl[e.type]??"activity"}var al=n=>/^\d{4}-\d{2}-\d{2}$/.test(n)?Oe(n):n;function Do(n,e){let o=n.people.find(h=>h.id===e.person),s=o?.name??e.pname??e.person??"",r=o?.devices.find(h=>h.id===e.device)?.name??e.dname??"",a=h=>t("b",{},h),i=h=>t("span",{class:"dl-muted"},h),l=h=>t("span",{class:"dl-mono"},h),d=h=>e.hosts?.[h]?[t("span",{class:"dl-ev-host"},[t("b",{},e.hosts[h]),t("span",{class:"dl-faint"},` (${h})`)])]:[l(h)],c=(h,...E)=>ae(h,...E).map(H=>typeof H=="string"?i(H):H),p=(h,...E)=>{let H=_("You");return h.startsWith(`${H} `)?[t("span",{class:"dl-you"},H),...c(h.slice(H.length),...E)]:c(h,...E)},u=a(r?`${s} · ${r}`:s),w=ys(e),M=a(w||r||_("a device")),g=Ve(e);if(g==="admin")switch(e.type){case"device_added":return p(_("You added device %s for %s"),M,a(s));case"device_removed":return p(_("You removed device %s from %s"),M,a(s));case"paused":return p(_("You paused person %s"),a(s));case"resumed":return p(_("You resumed person %s"),a(s));case"device_changed":{let h=a(r||_("a device"));return w.startsWith("renamed from ")?[...p(_("You renamed device %s of %s"),h,a(s)),i(` · ${m(_("was %s"),w.slice(13))}`)]:w==="turned off"?p(_("You turned off device %s of %s"),h,a(s)):w==="turned on"?p(_("You turned on device %s of %s"),h,a(s)):[...p(_("You changed device %s of %s"),h,a(s)),...w?[i(` · ${w}`)]:[]]}case"device_keys":return[...p(_("You issued new keys for device %s of %s"),M,a(s)),i(` · ${_("it needs its new configuration")}`)];case"link_changed":return[...p(_("You issued a new link for person %s"),a(s)),i(` · ${_("the old link stopped working")}`)]}switch(e.type){case"connect":return[...e.detail?c(_("Device %s connected from %s"),u,t("span",{},d(e.detail))):c(_("Device %s connected"),u),...e.where?[i(` · ${e.where}`)]:[]];case"disconnect":return c(_("Device %s went offline"),u);case"roam":return c(_("Device %s changed network %s"),u,t("span",{},(e.detail??"").split(" → ").flatMap((h,E)=>E?[i(" → "),...d(h)]:d(h))));case"device_added":return c(g==="portal"?_("Person %s added device %s on their portal"):_("Person %s added device %s"),a(s),M);case"device_removed":return c(g==="portal"?_("Person %s removed device %s on their portal"):_("Person %s removed device %s"),a(s),M);case"device_keys":return c(_("Person %s issued new keys for device %s on their portal"),a(s),M);case"person_added":return p(_("You added person %s"),a(e.detail??s));case"person_removed":return p(_("You removed person %s"),a(e.detail??s));case"person_changed":return[...p(_("You changed person %s"),a(s)),...w?[i(` · ${_s(w)}`)]:[]];case"expiring":{let h=ks(e.detail??"");return h!=null?c(N_(h,"Person %s’s access ends in %s day","Person %s’s access ends in %s days"),a(s),i(K(h))):c(_("Person %s’s access ends in a few days"),a(s))}case"expired_kept":return c(_("Person %s’s end date passed (%s) · access kept"),a(s),i(al(e.detail??"")));case"paused":return e.detail?c(_("Person %s paused - %s"),a(s),i(po(e.detail))):c(_("Person %s paused"),a(s));case"resumed":return e.detail&&e.detail!=="active"?c(_("Person %s resumed - %s"),a(s),i(po(e.detail))):c(_("Person %s resumed"),a(s));case"portal_blocked":return c(_("%s blocked %s for 15 min after too many wrong codes"),t("b",{class:"dl-sys-src"},_("Personal portal")),e.detail==="all Cloudflare visitors"?i(_("all Cloudflare visitors")):l(e.detail??""));case"devices_removed":return c(_("Person %s - all devices removed, end date reached"),a(s));default:return[i(`${e.type}${e.detail?`: ${e.detail}`:""}`)]}}var il={portal_blocked:["globe","bad"]};function ll(n,e){if(n.servers.length<2||!e.person)return"";let o=n.people.find(r=>r.id===e.person),s=o&&n.servers.find(r=>r.id===o.server);return s?t("span",{class:"dl-ev-srv",title:_("Server")},s.name):""}function ht(n,e,o={}){let s=il[e.type],r=Ve(e);return t("div",{class:`dl-row${r==="admin"?" dl-ev-by-admin":s?` dl-ev-by-system ${s[1]}`:""}`},[r==="admin"?t("span",{class:"dl-ev-tile",title:_("Done by you in LuCI")},v("admin")):s?t("span",{class:"dl-ev-tile sys"},v(s[0])):t("span",{class:`dl-ev-tile ev ${ol[e.type]??""}`},v(rl(n,e))),t("span",{class:"dl-row-main"},Do(n,e)),o.server===!1?"":ll(n,e),t("span",{class:"dl-faint dl-nowrap",title:new Date(e.ts*1e3).toLocaleString(le())},o.time??pe(e.ts,n.now))])}var dl={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},cl={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function pl(n){return{info:_("info"),up:_("up"),down:_("down"),repair:_("repair"),error:_("error")}[n]??n}function ul(n){let e=Cs(n.msg,n.kind,n.who),o=_("You");if(!e)return[t("span",{class:"dl-you"},o),t("span",{class:"dl-muted"},` ${n.msg} `),n.kind?t("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?t("b",{},n.who):""];let s=(e.named?ae(e.text,t("b",{},Ls(n.msg,n.who??""))):[e.text]).map(a=>typeof a=="string"?t("span",{class:"dl-muted"},a):a),r=s[0]?.textContent??"";return r.startsWith(`${o} `)?[t("span",{class:"dl-you"},o),t("span",{class:"dl-muted"},r.slice(o.length)),...s.slice(1)]:s}var Sr=n=>n.split(` -`).map(e=>At(e)).join(` -`);function Hn(n,e,o,s){let r=n.by==="admin",a=At(n.msg),i=t("div",{class:`dl-row dl-slog-row ${r?"dl-ev-by-admin":`dl-ev-by-system ${dl[n.level]??""}`}${n.detail?" has-detail":""}`},[r?t("span",{class:"dl-ev-tile",title:_("Done by you in LuCI")},v("admin")):t("span",{class:"dl-ev-tile sys",title:pl(n.level)},v(cl[n.src]??"zap")),t("span",{class:"dl-row-main"},r?[...ul(n),n.note?t("span",{class:"dl-muted"},` · ${Ms(n.note)}`):"",n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},Sr(n.detail)):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?t("span",{class:"dl-ev-kind"},`${_("Server")} `):"",t("b",{class:"dl-sys-src",title:Ft(n.src)},n.who?n.src==="awg"?n.who:At(n.who):Ft(n.src)),/^[:,]/.test(a)?"":" ",t("span",{class:"dl-muted"},a),n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},Sr(n.detail)):""]),t("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString(le())},s)]);return n.detail&&i.addEventListener("click",l=>{l.target.closest("pre")||o()}),i}function Pr(n){let e=new Date(n*1e3),o=new Date,s=new Date;if(s.setDate(o.getDate()-1),e.toDateString()===o.toDateString())return _("Today");if(e.toDateString()===s.toDateString())return _("Yesterday");let r=e.toLocaleDateString(le(),{weekday:"long",day:"numeric",month:"long"});return r.charAt(0).toLocaleUpperCase(le())+r.slice(1)}var Ot=n=>Mt(n).toLocaleDateString(le(),{day:"numeric",month:"short"});function zn(n,e,o,s=!1){let r=n.slice(-15),a=r[r.length-1],i=a&&e-a[0]<180,l=i?a[2]:0,d=i?a[1]:0,[c,p]=o,u=200,w=40,M=Math.max(1,...r.map($=>Math.max($[1],$[2]))),g=$=>r.map((b,C)=>`${r.length>1?C/(r.length-1)*u:u},${w-2-b[$]/M*(w-6)}`),h=g(2),E=g(1),H=r.length>1&&!s?Tt(``):t("div",{class:"dl-speed-wait"},[t("i"),s?"":t("span",{},_("Collecting… 1 point a minute"))]),S=($,b,C,y)=>t("div",{class:"dl-speed-col"},[t("span",{class:"dl-sub"},[t("span",{class:C},b),` ${$}`]),s?t("span",{class:"dl-speed-val off"},"—"):t("span",{class:"dl-speed-val"},Fe(y))]);return r.length>1&&!s&&we(H,()=>{let $=r[r.length-1];return[t("div",{class:"dl-tip-title"},new Date($[0]*1e3).toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"})),t("div",{},`↓ ${Fe($[2])} · ↑ ${Fe($[1])}`)]}),t("div",{class:"dl-bento-tile"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},_("Speed now")),s?"":t("span",{class:"dl-sub"},_("last 15 min"))]),t("div",{class:"dl-speed-cols"},[S(_("Download","speed"),"↓","dl-dn",l),S(_("Upload","speed"),"↑","dl-up",d)]),H,t("div",{class:"dl-speed-today"},[t("span",{},ae(_("Today %s"),t("b",{},se(c+p)))),t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${se(p)} `,t("span",{class:"dl-up"},"↑"),` ${se(c)}`])])])}function Rn(n,e){let o=n.slice(-30),s=o.map(d=>d.rx+d.tx),r=Math.max(1,...s),a=s.reduce((d,c)=>d+c,0),i=s.reduce((d,c,p)=>c>s[d]?p:d,0),l=t("div",{class:"dl-bento-bars"},o.map((d,c)=>{let p=s[c],u=t("i",{class:c===o.length-1?"hi":"",style:`height:${Math.max(4,p/r*100)}%`}),w=t("span",{},[u]);return we(w,()=>[t("div",{class:"dl-tip-title"},c===o.length-1?`${_("Today")} · ${Ot(d.day)}`:Ot(d.day)),t("div",{},se(p)),t("div",{class:"dl-muted dl-mono"},`↓ ${se(d.tx)} ↑ ${se(d.rx)}`)]),w}));return t("div",{class:"dl-bento-tile month"},[t("div",{class:"dl-bento-head"},[t("span",{},[t("span",{class:"dl-metric-label"},_("Last 30 days")),t("b",{class:"dl-bento-total"},se(a))]),s[i]>0?t("span",{class:"dl-sub"},`${m(_("peak %s"),se(s[i]))} · ${Ot(o[i].day)}`):""]),o.length?l:t("p",{class:"dl-muted"},_("No traffic yet.")),t("div",{class:"dl-bento-head"},[t("span",{class:"dl-sub"},o.length?Ot(o[0].day):""),t("span",{class:"dl-sub"},e),t("span",{class:"dl-sub"},_("today"))])])}function $r(n){let e=n.slice(-30),o=e.map(r=>r.rx+r.tx),s=Math.max(1,...o);return t("div",{class:"dl-dbars"},e.map((r,a)=>{let i=t("i",{class:`${o[a]?"":"zero"}${a===e.length-1?" hi":""}`});i.style.height=`${Math.max(8,o[a]/s*100)}%`;let l=t("span",{},[i]);return we(l,()=>[t("div",{class:"dl-tip-title"},a===e.length-1?`${_("Today")} · ${Ot(r.day)}`:Ot(r.day)),t("div",{},se(o[a]))]),l}))}function Dr(n){return{apply:_("Repair"),sync:_("Reload devices"),restart:_("Restart service"),netrestart:_("Restart network"),updates:_("Open Components")}[n]??_("Fix")}async function In(n){return n==="netrestart"&&!await me(_("Restart the network?"),_("Every interface restarts. Connections drop for a few seconds."),_("Restart network"))?null:await F(()=>N.healthFix(n),_("Done"))??null}function Ao(n,e,o,s="action"){let r=n.fix;return r?r.startsWith("install:")?A(_("Install"),()=>Er(r.slice(8),o),s):r==="updates"?t("a",{class:`cbi-button cbi-button-${s}`,href:L.url("admin/network/dawnline/updates")},Dr(r)):A(Dr(r),()=>e(r),s):""}function ml(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="flash"?"download":n==="nft"?"lock":n==="data"?"users":"alert"}function Ar(n,e,o,s=3){let r=n.filter(i=>i.status==="error"||i.status==="warn").sort((i,l)=>i.status===l.status?0:i.status==="error"?-1:1);if(!r.length)return"";let a=r.length-s;return t("div",{class:"dl-list dl-notices"},[...r.slice(0,s).map(i=>it(ml(i.id),i.status==="error"?"bad":"warn",i.problem??i.title,i.detail,Ao(i,e,o,i.status==="error"?"positive":"neutral"))),a>0?t("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[m(_("%s more in Diagnostics"),K(a)),t("span",{class:"dl-spacer"}),"→"]):""])}function hl(n){let e=[],o=(l,d)=>t("a",{href:l},d),s=()=>o(L.url("admin/network/dawnline/diagnostics"),_("Open Diagnostics")),r=Ge(n.series),a=!!n.awg_state&&!n.awg_state.ok;for(let l of n.servers)l.enabled&&l.blocked?e.push({tone:"bad",text:[l.blocked," ",s()]}):l.enabled&&!l.up&&!a&&e.push({tone:"bad",text:[m(_("Tunnel %s is down."),l.ifname)," ",s()]});for(let l of n.people){let d=()=>o(Re(l.id),l.name);if(l.state==="quota")e.push({tone:"warn",text:ae(_("%s reached the data limit."),d())});else if(l.state==="expired")e.push({tone:"warn",text:ae(_("%s’s access has ended."),d())});else{let c=st(l.expires,r);rt(l,c)?e.push({tone:"",text:ae(_("%s’s access %s."),d(),an(c))}):c!=null&&c<0&&l.expire_action==="notify"&&e.push({tone:"",text:ae(_("%s’s end date passed (%s) · access kept."),d(),De(l.expires))}),l.quota_limit&&l.quota_used>=l.quota_limit*.9&&e.push({tone:"",text:ae(_("%s has used 90% of the data limit."),d())})}}let i=n.people.flatMap(l=>l.devices.filter(d=>d.config_stale).map(d=>[l,d]));i.length&&e.push({tone:"warn",text:i.length===1?ae(_("%s needs its configuration again."),o(Re(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)):[W(i.length,"%s device needs its configuration again (networks or DNS changed).","%s devices need their configuration again (networks or DNS changed).")]});for(let l of n.servers)n.wan&&Dt(l.endpoint)&&l.endpoint!==n.wan&&e.push({tone:"warn",text:[m(_("Public address changed: %s still gives devices %s, the router is %s now."),l.name,l.endpoint,n.wan)," ",t("button",{type:"button",class:"dl-fix",click:async d=>{let c=d.currentTarget;c.disabled=!0,await F(()=>N.serverUpdate(l.id,{endpoint:n.wan}),m(_("%s uses %s now - devices need their configuration again"),l.name,n.wan)),c.disabled=!1}},_("Use the new address"))," ",_("A DDNS name would follow it by itself.")]});return n.servers.some(l=>l.lan_like)&&n.like_home.error&&e.push({tone:"warn",text:[m(_("Internet through the LAN is off: %s"),n.like_home.error)," ",o(L.url("admin/network/dawnline/diagnostics"),_("Details"))]}),!n.settings.portal_enabled&&!n.people.length&&e.push({tone:"",text:[_("The personal portal is off.")," ",o(L.url("admin/network/dawnline/settings"),_("Turn on"))]}),e}var Bn=class{constructor(e,o){this.srvId=e;this.go=o;this.el=t("div",{class:"dl-srvov"});this.map=null;this.mapOn=null;this.range="online";this.parts={};this.healthAt=0}mount(e){this.st=en(e,this.srvId);for(let o of["health","bento","map","side","activity"])this.parts[o]=t("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.parts.map,t("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(e,o=!1){this.st=en(e,this.srvId),this.paint(o),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let e=await N.health().catch(()=>null);if(!e)return;let o=()=>void this.loadHealth(),s=async r=>{await In(r)&&(o(),r==="netrestart"&&setTimeout(o,5e3))};Ae(this.parts.health,Ar(e.checks,r=>void s(r),o),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}paintMap(){let e=this.st.geo.enabled;if(e===this.mapOn&&(!e||this.map)){this.map?.update(this.mapData());return}this.mapOn=e,dom.content(this.parts.map,this.mapCard())}mapCard(){let e=this.st,o=t("div",{class:"dl-panel-head pad"},[t("div",{class:"dl-stack"},[t("h3",{},_("Where people connect from")),t("span",{class:"dl-sub"},_("City-level, from the client IP · locations cached on the router"))]),t("span",{class:"dl-spacer"}),Rt(this.range,l=>{this.range=l,this.map?.setRange(l)})]);if(this.map?.destroy(),this.map=null,!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},ae(_("Locations are off. %s."),t("a",{href:L.url("admin/network/dawnline/settings")},_("Turn them on in Settings"))))]);let s=this.map=new dt({openPerson:l=>location.href=Re(l),openDevice:(l,d)=>location.href=Re(l,d)},this.range),r=Te(()=>{r(),s.destroy(),this.map===s&&(this.map=null)}),a=t("div",{class:"dl-map-legend"},[t("span",{},[t("i",{class:"line live"}),_("Live tunnel")]),t("span",{},[t("i",{class:"line"}),_("Seen recently")])]),i=t("div",{class:"dl-map-wrap"},[s.el,a]);return requestAnimationFrame(()=>s.mount(this.mapData())),t("div",{class:"dl-panel flush"},[o,i])}paint(e=!1){let o=this.st,s=o.servers[0];this.paintMap(),Ae(this.parts.bento,t("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),qe(s).overviewTile(s),this.monthTile()]),e);let r=hl(o);Ae(this.parts.side,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Needs attention")),t("span",{class:"dl-spacer"}),t("a",{href:L.url("admin/network/dawnline/diagnostics")},_("Health"))]),r.length?r.slice(0,8).map(i=>t("div",{class:"dl-attn-item dl-row"},[t("span",{class:`dl-ev-dot ${i.tone}`}),t("span",{},i.text),i.action??""])):t("div",{class:"dl-row dl-muted"},[v("check"),_("All good. Nothing needs you right now.")])]),e);let a=[...o.events].reverse().slice(0,8);Ae(this.parts.activity,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Activity")),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},_("View all"))]),a.length?a.map(i=>ht(o,i)):t("div",{class:"dl-row dl-muted"},_("Nothing yet. Connections, new devices and pauses appear here."))]),e)}onlineTile(){let e=this.st,o=e.servers[0]?!e.servers[0].enabled:!1,s=12,r=H=>{let[S,$]=H.spark[H.spark.length-1]??[0,0];return S+$},a=H=>e.geo.points.find(S=>S.device===H.id&&S.city)?.city,i=H=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(H.endpoint??""),l=(H,S=!1)=>i(H)?S&&H.endpoint?`LAN · ${H.endpoint}`:"LAN":a(H)??"",d=H=>[...e.events].reverse().find(S=>S.type==="connect"&&S.device===H.id)?.ts??0,c=e.people.map(H=>({p:H,devs:H.devices.filter(S=>S.online).sort((S,$)=>r($)-r(S))})).filter(H=>H.devs.length).sort((H,S)=>S.devs.reduce(($,b)=>$+r(b),0)-H.devs.reduce(($,b)=>$+r(b),0)),p=c.length<=2,u=({p:H,devs:S})=>{let $=S.map(d).filter(Boolean),b=$.length?Math.min(...$):0,C=(H.rate??[]).slice(-15),y=C[C.length-1],z=y&&e.now-y[0]<180?y:null,k=200,f=30,x=Math.max(1,...C.map(te=>Math.max(te[1],te[2]))),T=te=>C.map((B,Q)=>`${C.length>1?Q/(C.length-1)*k:k},${f-2-B[te]/x*(f-6)}`),I=C.length>1?Tt(``):"",V=!z||z[1]<64&&z[2]<64,J=H.access==="both"?["home","globe"]:H.access==="lan"?["home"]:["globe"];return[t("div",{class:"dl-hc"},[t("div",{class:"dl-hc-head"},[t("span",{class:"dl-onl-av sm"},je(H.name)),t("span",{class:"dl-stack"},[t("b",{},H.name),t("span",{class:"dl-hc-since"},b?m(_("online for %s"),ot(Math.max(60,e.now-b))):_("online"))]),t("span",{class:"dl-hc-reach"},J.map(te=>t("span",{class:`dl-ibadge ${te==="home"?"lan":"inet"}`},v(te))))]),t("div",{class:"dl-hc-speed"},[t("div",{class:"dl-hc-speed-row"},V?[t("span",{class:"dl-faint"},_("Idle right now"))]:[t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${Fe(z[2])}`]),t("span",{},[t("span",{class:"dl-up"},"↑"),` ${Fe(z[1])}`]),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint"},_("15 min"))]),I]),t("div",{class:"dl-hc-devs"},S.map(te=>t("span",{class:"dl-hc-dev"},[v(te.kind),te.name,l(te)?[" · ",l(te,!0)]:""]))),t("div",{class:"dl-hc-foot"},[t("span",{class:"dl-faint"},`${m(_("%s today"),se(S.reduce((te,B)=>te+r(B),0)))} · ${m(_("%s this month"),se(H.month[0]+H.month[1]))}`)])])]},w=H=>{let{p:S,devs:$}=H,b=t("span",{class:"dl-onl-dev"},$.length>1?String($.length):v($[0].kind)),C=t("a",{class:`dl-onl-p${p?"":" sm"}`,href:Re(S.id),"aria-label":m(_("%s, online"),S.name)},[t("span",{class:"dl-onl-av"},[je(S.name),b]),p?t("span",{class:"dl-onl-name"},S.name):"",p?t("span",{class:"dl-onl-meta"},[...$.slice(0,3).map(y=>v(y.kind)),$.length>3?`+${$.length-3}`:"",l($[0])?t("span",{},[" · ",l($[0])]):""]):""]);return we(C,()=>u(H)),C},M=t("b",{class:`dl-onl-count${c.length?"":" none"}`},String(c.length)),g=c.reduce((H,S)=>H+S.devs.length,0);c.length&&we(M,()=>[`${W(c.length,"%s person","%s people")} · ${W(g,"%s device","%s devices")}`]);let h=c.length>s?c.slice(0,s-1):c,E=e.people.flatMap(H=>H.devices.map(S=>({p:H,d:S}))).filter(H=>H.d.handshake).sort((H,S)=>S.d.handshake-H.d.handshake)[0];return t("div",{class:"dl-bento-tile online"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},_("Online")),M]),c.length?t("div",{class:`dl-onl-row${p?"":" grid"}`},[...h.map(w),c.length>s?t("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:_("Everyone online"),click:H=>{this.go&&(H.preventDefault(),this.go("people","online"))}},[t("span",{class:"dl-onl-av"},`+${c.length-h.length}`)]):""]):t("div",{class:"dl-onl-empty"},[t("span",{},o?_("The server is turned off"):_("Nobody is connected")),E?t("span",{class:"dl-sub"},m(_("Last: %s, %s"),E.p.name,pe(E.d.handshake,e.now))):t("span",{class:"dl-sub"},o?_("Devices connect once it is on"):_("No device has connected yet"))])])}speedTile(){let e=this.st.servers[0];return zn(e?.rate??[],this.st.now,this.st.totals.today,e?!e.enabled:!1)}monthTile(){let e=[...this.st.people].map(o=>[o,o.month[0]+o.month[1]]).filter(([,o])=>o>0).sort((o,s)=>s[1]-o[1]).slice(0,2);return Rn(this.st.series,e.length?m(_("Most: %s"),e.map(([o,s])=>`${o.name} ${se(s)}`).join(" · ")):"")}};var Nr=["overview","people","connection","access","awg"],fl=n=>({overview:_("Overview"),people:_("People"),connection:_("Connection"),access:_("Access")})[n],gl={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},No=(n,e)=>{let o=new URLSearchParams;n&&o.set("server",n),e&&e!=="overview"&&o.set("section",e);let s=o.toString();return`${L.url("admin/network/dawnline/server")}${s?`?${s}`:""}`},on=class{constructor(){this.noFooter=!0;this.root=t("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=t("div",{});this.headEl=t("div",{});this.secEl=t("div",{});this.bodyEl=t("div",{class:"dl-srvbody"})}async load(){let e=await N.status(31),o=e.servers.length?null:await N.setupDefaults();return[e,o]}render([e,o]){if(this.st=e,!e.servers.length&&o)return this.wizard(o);let s=new URLSearchParams(location.search),r=s.get("section")??"",a=gl[r]??r;return Nr.includes(a)&&(this.section=a),this.srvId=(e.servers.find(i=>i.id===s.get("server"))??e.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller?.stop(),this.poller=pt({fetch:()=>N.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(i,l)=>{i.servers.length&&(this.st=i,this.paintHead(l),this.ov[this.current().id]?.update(i,l))}}),this.root}paintHead(e=!1){Ae(this.headEl,this.head(this.current()),e),(!e||!Bt(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let e=await N.status(31).catch(()=>null);return e?.servers.length?(this.st=e,this.paintHead(),e):null}current(){return this.st.servers.find(e=>e.id===this.srvId)??this.st.servers[0]}async refresh(){let e=await N.status(31).catch(()=>null);e&&(this.st=e,e.servers.length?this.paint():location.href=No())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let e=this.current();dom.content(this.tabsEl,t("div",{class:"dl-srvtabs",role:"tablist","aria-label":_("Servers")},[...this.st.servers.map(o=>t("button",{type:"button",role:"tab",class:`dl-srvtab${o.id===e.id?" on":""}`,"aria-selected":o.id===e.id?"true":"false",click:()=>{o.id!==this.srvId&&(this.srvId=o.id,this.paint())}},[t("i",{class:`dot ${o.enabled?o.up?"ok":"bad":"warn"}`}),t("b",{},o.name)])),t("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[v("plus"),_("Add server")])]))}paintSections(){let e=qe(this.current());dom.content(this.secEl,t("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":_("Server")},Nr.map(o=>t("button",{type:"button",role:"tab","data-section":o,class:o===this.section?"on":"","aria-selected":o===this.section?"true":"false",click:()=>this.showSection(o)},o==="awg"?e.label:fl(o)))))}go(e,o){let s=this.pp[this.current().id];if(o&&s)s.filter=o,s.el&&s.decorate();else if(o){let r=this.pp[this.current().id]=new wt;r.filter=o}this.showSection(e),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let e=[...Object.values(this.ov).map(o=>o.el),...Object.values(this.pp).map(o=>o.el)];for(let o of e)o&&this.bodyEl.contains(o)&&o.remove()}showSection(e){this.section=e,this.secEl.querySelectorAll("[data-section]").forEach(i=>{let l=i.dataset.section===e;i.classList.toggle("on",l),i.setAttribute("aria-selected",l?"true":"false")});let o=this.st,s=this.current(),a={overview:()=>{let i=this.ov[s.id];return i?(i.update(o),i.el):(this.ov[s.id]=new Bn(s.id,(l,d)=>this.go(l,d))).mount(o)},people:()=>{var c,p;let i=this.pp[s.id];if(i?.el)return i.update(),i.el;let l=t("div",{},t("p",{class:"dl-muted"},_("Loading people…")));return((c=this.pp)[p=s.id]??(c[p]=new wt)).embed(o,s.id).then(u=>{l.isConnected?dom.content(l,u):l.replaceChildren(u)}).catch(u=>{delete this.pp[s.id],dom.content(l,t("p",{class:"dl-muted"},m(_("Couldn't show people: %s"),Ce(u))))}),l},connection:()=>this.connection(s),access:()=>this.access(s),awg:()=>this.awg(s)}[e]();this.detachKept(),dom.content(this.bodyEl,a)}head(e){let o=(a,i)=>t("span",{class:"dl-addrbar-seg"},[v(a),...i]),s=e.endpoint||"—",r=t("div",{class:"dl-actions"},[e.enabled?"":A([v("play"),` ${_("Turn on")}`],()=>this.save(e,{enabled:"1"},_("Server turned on")),"add")]);return t("div",{class:"dl-srvpagehead"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),t("span",{class:`dl-pill ${e.enabled?e.up?"ok":"bad":"warn"}`},e.enabled?e.up?_("Running"):e.blocked?_("Can’t start"):_("Not running"):_("Turned off")),t("span",{class:"dl-spacer"}),r]),t("div",{class:"dl-addrbar"},[t("button",{type:"button",class:"dl-addrbar-seg main",title:_("Copy address"),click:()=>xe(s,_("Address copied"))},[v("globe"),t("span",{class:"dl-mono"},s),v("copy")]),o(qe(e).id==="awg"?"amneziawg":"tunnel",[t("span",{class:"dl-mono"},`${qe(e).label} :${e.port}`)]),e.up?o("clock",[m(_("up %s"),ot(e.uptime))]):""]),e.blocked?t("div",{class:"dl-note warn"},[v("alert"),t("span",{},e.blocked)]):""])}async save(e,o,s=_("Saved")){await F(()=>N.serverUpdate(e.id,o),s)&&await this.refresh()}connection(e){let o=he(e.name,{placeholder:_("Home")}),s=he(e.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),r=he(e.dns.join(", "),{placeholder:_("This router (recommended)"),class:"cbi-input-text dl-mono"}),a=this.st.people.filter(M=>M.server===e.id).length,i=A([v(e.enabled?"pause":"play"),` ${e.enabled?_("Turn off"):_("Turn on")}`],async()=>{e.enabled&&!await me(m(_("Turn off %s?"),e.name),W(a,"The tunnel stops and %s person is disconnected until you turn it back on. Nothing is deleted.","The tunnel stops and %s people are disconnected until you turn it back on. Nothing is deleted."),_("Turn off"),!0)||await this.save(e,{enabled:e.enabled?"0":"1"},e.enabled?_("Server turned off"):_("Server turned on"))},e.enabled?"negative":"positive"),l=this.st.settings.portal_host,d=_e(_("Name"),o,()=>He(o.value,[],_("Shown to people in their portal and apps."))),c=lo(()=>({host:s.value,port:e.port,id:e.id}),(M,g,h)=>N.endpointProbe(M,g,h),()=>p.refresh(),{empty:l?m(_("Empty = the portal’s address (%s)."),l):_("Empty = the portal’s address.")}),p=_e(_("Public address"),s,c.help);s.addEventListener("input",c.schedule),c.schedule();let u=e.reached?m(_("Reached from the internet %s."),pe(e.reached,this.st.now)):_("Never reached from the internet yet - test with a phone on mobile data."),w=_e(_("DNS for devices"),r,()=>cs(r.value,e.address));return t("div",{class:"dl-stack gap16"},[Wt(_("Connection"),[t("p",{class:"dl-muted"},_("The name people see, where devices find the router, and DNS. The port is on AmneziaWG.")),ke("router",_("Server"),_("What people see"),[d]),ke("globe",_("Devices connect to"),_("A DDNS name keeps links working when your IP changes; not through Cloudflare (use a DNS-only name or an IP)"),[p,t("div",{class:`dl-sub ${e.reached?"ok":"warn"}`},u)]),ke("file",_("For every device"),_("Changing it marks devices “Update config” until they import again"),[w])],[t("span"),A(_("Save"),()=>{let M=Ue([d,p,w]);if(M){q(M,"warning");return}return this.save(e,{name:o.value,endpoint:s.value,dns:r.value})},"positive")]),Wt(_("Danger zone"),[t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},e.enabled?_("Turn off this server"):_("This server is off")),t("span",{class:"dl-sub"},e.enabled?_("Stops the tunnel and disconnects everyone on it. Settings and people are kept."):_("Nobody can connect. Turn it on to bring the tunnel back."))]),t("div",{class:"dl-setrow-ctl"},i)]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},_("Change the tunnel network")),t("span",{class:"dl-sub"},m(_("Devices have %s addresses now. A new range when it clashes with a network you connect to; every device then needs its configuration again."),`${$t(e.subnet)}.x`))]),t("div",{class:"dl-setrow-ctl"},A([v("edit"),` ${_("Change")}`],()=>this.changeSubnet(e),"negative"))]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},_("Remove server")),t("span",{class:"dl-sub"},W(a,"Removes the tunnel, its firewall rules and %s person with all their devices. A backup is made first.","Removes the tunnel, its firewall rules and %s people with all their devices. A backup is made first."))]),t("div",{class:"dl-setrow-ctl"},A([v("trash"),` ${_("Remove")}`],()=>this.remove(e),"negative"))])],[],"danger")])}access(e){let o=Po(this.st,e),s=Tr(e,this.st,async()=>{let r=await this.refreshStatus();if(!r)return;let a=r.servers.find(l=>l.id===e.id)??e;s.update(r);let i=Po(r,a);o.replaceWith(i),o=i});return t("div",{class:"dl-stack gap16"},[s.el,t("div",{class:"dl-health-cols"},[o,yr(this.st,e)])])}awg(e){let o={st:this.st,save:(s,r)=>this.save(e,s,r),refresh:()=>this.refresh()};return t("div",{class:"dl-stack gap16"},[qe(e).settingsCard(o,e)])}async addServer(){let e=await F(()=>N.setupDefaults());e&&dom.content(this.root,this.wizard(e,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async changeSubnet(e){let o=await F(()=>N.serverPorts(e.id));if(!o)return;let s=o.networks??[],r=this.st.people.filter(l=>l.server===e.id).reduce((l,d)=>l+d.devices.length,0),a=he($t(e.subnet),{class:"cbi-input-text dl-mono dl-w-range"}),i=_e(_("Address range"),a,()=>ao(a.value,s,""));de(_("Change the tunnel network"),[i,t("p",{class:"dl-muted"},r?W(r,"%s device gets a new address and stops connecting until it imports its configuration again (from their personal link or from you).","%s devices get new addresses and stop connecting until they import their configuration again (from their personal link or from you)."):_("No devices on this server yet: nothing else changes."))],[ue()," ",A(_("Change"),async()=>{let l=i.help();if(l.bad){q(l.text,"warning");return}let d=mn(a.value);if(d===e.subnet){ce();return}await F(()=>N.serverUpdate(e.id,{subnet:d}),_("Tunnel network changed"))&&(ce(),r&&q(_("Devices are marked “Update config” until they import again."),"info",6e3),await this.refresh())},"negative")]),setTimeout(()=>a.select(),50)}async remove(e){let o=this.st.people.filter(s=>s.server===e.id);de(m(_("Remove %s?"),e.name),[t("p",{},W(o.length,"This removes the tunnel, its firewall rules and %s person with all their devices. A backup is made first.","This removes the tunnel, its firewall rules and %s people with all their devices. A backup is made first."))],[ue()," ",A(_("Remove"),async()=>{ce(),await F(()=>N.serverDelete(e.id),_("Server removed"))&&setTimeout(()=>{location.href=No()},800)},"negative")])}wizard(e,o=!1,s){let r={id:e.id,name:e.name,endpoint:e.endpoint,port:e.port,range:$t(e.subnet),preset:wn(e.awg),portal:!1,portal_port:e.portal_port||8443,lan_like:!0,lan_zone:e.lan_zone,wan_zone:e.wan_zone},a=0,i=!o&&r.portal_port===r.port,l=()=>/^\d{1,3}(\.\d{1,3}){3}$/.test(r.endpoint),d=()=>Gt(r.port,e.udp_taken??[],r.port===4500?`${_("Opened on the WAN firewall automatically.")} ${_("4500 is IPsec’s port: most networks let it through.")}`:_("Opened on the WAN firewall automatically.")),c={ddns:_("From your DDNS name."),cert:_("From your Let’s Encrypt certificate."),wan:_("Your WAN address now - it may change; a DDNS name is better."),portal:_("The portal’s address.")},p=lo(()=>({host:r.endpoint,port:r.port}),(x,T,I)=>N.endpointProbe(x,"",I),()=>u?.refresh(),{idle:()=>r.endpoint===e.endpoint&&e.endpoint_from?c[e.endpoint_from]??"":""}),u=null,w=e.wan_kind==="cgnat"||e.wan_kind==="private"?it("alert","warn",e.wan_kind==="cgnat"?_("Your router has no public address (CGNAT)"):m(_("Your router is behind another router (WAN %s)"),e.wan_ip),e.wan_kind==="cgnat"?_("The ISP shares one address: devices can only connect if the ISP gives you a public address or IPv6. Ask them, or use a DDNS name that points at an IPv6 address."):_("Forward the UDP port on the upstream router to this one and use a DDNS name or that router’s public address here."),""):"",M=e.awg_state?.tools&&e.awg_state.handler===!1?t("div",{class:"dl-note warn"},[v("alert"),t("span",{},_("Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started."))]):"",g=()=>ao(r.range,e.networks??[],$t(e.subnet)),h=()=>hn(r.portal_port,e.tcp_taken??[],l()),E=t("div",{class:"dl-wizard"}),H=(x,T={})=>{let I=he(String(r[x]),T);return I.addEventListener("input",()=>{x==="port"||x==="portal_port"?r[x]=I.value.trim()===""?0:Number(I.value):r[x]=I.value.trim(),x==="port"&&i&&(r.portal_port=r.port),x==="portal_port"&&(i=r.portal_port===r.port)}),I},S={id:"server",title:_("Server"),render:()=>t("div",{class:"dl-wizard-groups"},[t("p",{class:"dl-muted"},o?_("One more server: another port or disguise for networks where the first does not get through, or its own home access rules. People are moved between servers from their page."):_("Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes.")),ke("router",_("Server"),_("What people see"),[_e(_("Name"),H("name"),()=>He(r.name,[],_("Shown to people in their portal and apps.")))]),ke("globe",_("Devices connect to"),_("A hostname or IP address of your router on the internet; not through Cloudflare (use a DNS-only name or an IP). IPv6 works too, and is the way out of CGNAT"),[(()=>{let x=H("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"});return u=_e(_("Public address"),x,p.help),x.addEventListener("input",p.schedule),p.schedule(),u})()]),w,M]),check:()=>{let x=He(r.name);if(x.bad)return m(_("Name: %s"),x.text);let T=Pt(r.endpoint,r.port);return T.bad?m(_("Public address: %s"),T.text):null}},$={id:"awg",title:"AmneziaWG",render:()=>t("div",{class:"dl-wizard-groups"},[ke("globe",_("Listening"),_("Where devices reach AmneziaWG from the internet"),[_e(_("UDP port"),H("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),d)]),ke("network",_("Tunnel network"),_("Addresses devices get inside the tunnel"),[(()=>{let x=H("range",{class:"cbi-input-text dl-w-range dl-mono","aria-label":_("First three numbers of the device addresses")});return _e(_("Device addresses"),x,g,t("span",{class:"dl-suffixed"},[x,t("span",{class:"dl-mono"},".x")]))})()]),ke("shield",_("Disguise"),_("So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard"),[yn(e.awg,r.preset,x=>r.preset=x,void 0,e.awg_state?.tools!==!1)])]),check:()=>{let x=d();if(x.bad)return m(_("UDP port: %s"),x.text);let T=g();return T.bad?m(_("Device addresses: %s"),T.text):null}},b={id:"portal",title:_("Portal"),render:()=>{let x=H("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),T=_e(_("Listening port"),x,h);T.hidden=!r.portal;let I=Me([["off",_("Off")],["on",_("On")]],r.portal?"on":"off",{label:_("Personal portal"),onChange:V=>{r.portal=V==="on",T.hidden=!r.portal}});return t("div",{class:"dl-wizard-groups"},[ke("home",_("Internet like a home device"),_("How devices reach the internet"),[ge(_("Through the home network"),ye(r.lan_like,_("Internet like a home device"),V=>r.lan_like=V),_("Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access."))]),ke("link",_("Personal portal"),_("A page where each person adds their own devices with their personal link"),[ge(_("Portal"),I,_("Off: only you add devices, from LuCI. On: people manage their devices within the limits you set.")),T])])},check:()=>{if(!r.portal)return null;let x=h();return x.bad?m(_("Portal port: %s"),x.text):null}},C=()=>[S,$,o?null:b].filter(x=>x!=null),y=e.awg_state,z=y?.missing??[],k=z.length?t("div",{class:"dl-list dl-notices"},[it("shield","bad",_("AmneziaWG isn’t installed"),m(_("The tunnel needs %s. Install the build made for this firmware, then create the server."),new Intl.ListFormat(le(),{type:"conjunction"}).format(z)),A(_("Install"),()=>Nn(()=>location.reload()),"positive"))]):y&&!y.loaded?t("div",{class:"dl-list dl-notices"},[it("shield","warn",_("AmneziaWG’s kernel module doesn’t load on this firmware"),_("Try another build in Components, or update OpenWrt. The server can’t start until it loads."),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},_("Open Components")))]):"",f=()=>{let x=C();a>=x.length&&(a=x.length-1),dom.content(E,[t("h2",{},o?_("Add a server"):_("Set up Dawnline")),k,t("div",{class:"dl-steps"},x.map((T,I)=>t("span",{class:`dl-step${I===a?" current":I0?A(_("Back"),()=>{a--,f()}):s?A(_("Cancel"),s):"",t("span",{class:"dl-spacer"}),a{let T=x[a].check?.();if(T){q(T,"warning");return}a++,f()},"positive"):A(_("Create server"),async()=>{for(let I of x){let V=I.check?.();if(V){q(V,"warning");return}}let T=await F(()=>N.serverCreate(r.id,r.name,e.ifname,r.port,mn(r.range),r.endpoint,e.mtu,r.preset,r.lan_zone,r.wan_zone,r.lan_like,o?void 0:r.portal,o?void 0:r.portal_port),_("Server created"));T&&(T.network_restart&&q(_("Restarting the network so it knows AmneziaWG: back in a few seconds")),setTimeout(()=>{location.href=No(T.id)},T.network_restart?1e4:1500))},"positive",{disabled:z.length>0,title:z.length?_("Install AmneziaWG first"):null})])])};return f(),E}};function ft(n){let e={el:n(),refresh(){let o=n();e.el.replaceWith(o),e.el=o}};return e}function We(n,e,o,s,r="",a=[]){return t("section",{class:`dl-setsec ${r}`,id:`dl-set-${n}`},[t("div",{class:"dl-setsec-body"},[a.length?t("div",{class:"dl-setsec-head"},[t("h3",{},e),t("span",{class:"dl-spacer"}),...a]):t("h3",{},e),...o]),s.length?t("div",{class:"dl-setsec-foot"},s):""])}function Hr(n){let e=n.filter(r=>r.status!=="skip"),o=e.filter(r=>r.status==="error"||r.status==="warn"),s=e.some(r=>r.status==="error")?"error":o.length?"warn":"ok";return{bad:o,worst:s}}function zr(n){let e=n.d.settings,o=n.d.effective,s=n.d.cert,r=ye(o.portal_enabled,_("Enable portal")),a=he(e.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),i=he(e.portal_redirect,{placeholder:_("Show “Not found”"),class:"cbi-input-text dl-mono"}),l=he("",{placeholder:_("vpn.example.com or an IP"),"aria-label":_("Other address")}),d=j=>/^\d{1,3}(\.\d{1,3}){3}$/.test(j),c=[o.portal_host,...o.portal_alt??[]].filter((j,Y,ie)=>j&&ie.indexOf(j)===Y),p=!!n.portal,u=[],w=j=>{j&&!u.some(Y=>Y.host===j)&&u.push({host:j,kind:d(j)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},M=j=>{u=[...j,...u.filter(Y=>!j.some(ie=>ie.host===Y.host))],!c.length&&j[0]&&(c=[j[0].host])};n.portal&&M(n.portal.candidates),c.forEach(w);let g=j=>j.kind==="ip"?t("span",{class:"dl-addr-warn"},[v("alert"),_("Plain HTTP: the link and VPN keys travel unencrypted")]):t("span",{class:"dl-sub"},j.cloudflare?_("Behind Cloudflare · often stalls in Russia"):j.ips.length?j.here?j.cert?_("Points at this router · Let’s Encrypt certificate"):_("Points at this router · no certificate yet"):m(_("Points at %s, not this router"),j.ips.join(", ")):p?_("Your address"):_("Checking where it points…")),h=t("div",{class:"dl-addr-opts",role:"group","aria-label":_("Portal addresses")}),E=j=>{c.includes(j)?c.length>1&&(c=c.filter(Y=>Y!==j)):c=[...c,j],H(),b()},H=()=>dom.content(h,[...u.map(j=>{let Y=c.includes(j.host),ie=c[0]===j.host;return t("div",{class:`dl-addr-opt${Y?" on":""}`,role:"checkbox","aria-checked":Y?"true":"false",tabindex:"0",click:()=>E(j.host),keydown:ve=>{(ve.key===" "||ve.key==="Enter")&&(ve.preventDefault(),E(j.host))}},[t("i",{class:"dl-addr-check"},Y?v("check"):""),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono"},j.host),g(j)]),ie?t("span",{class:"dl-pill info"},_("Main")):Y?t("button",{type:"button",class:"dl-linkbtn",click:ve=>{ve.stopPropagation(),c=[j.host,...c.filter(R=>R!==j.host)],H(),b()}},_("Make main")):j.cloudflare?t("span",{class:"dl-pill warn"},"Cloudflare"):j.kind==="ip"?t("span",{class:"dl-pill"},"IP"):j.here&&j.cert?t("span",{class:"dl-pill ok"},_("Recommended")):""])}),t("div",{class:"dl-addr-opt other"},[t("i",{class:"dl-addr-check"},v("plus")),l,A(_("Add"),()=>{let j=l.value.trim().toLowerCase();if(!j)return;let Y=Pt(j);if(Y.bad){q(Y.text,"warning");return}w(j),c.includes(j)||(c=[...c,j]),l.value="",H(),b()})])]);l.addEventListener("keydown",j=>{j.key==="Enter"&&(j.preventDefault(),l.nextElementSibling?.click())});let S=t("div",{class:"dl-links"}),$=()=>{},b=()=>{$();let j=Number(a.value)||o.portal_port;dom.content(S,c.map((Y,ie)=>{let ve=d(Y),R=ve?j+1:j,O=`${ve?"http":"https"}://${Y}${R===(ve?80:443)?"":`:${R}`}/`;return t("div",{class:"dl-link-row"},[t("span",{class:`dl-link-ic ${ve?"warn":"ok"}`},v(ve?"alert":"lock")),t("span",{class:"dl-mono dl-link-url"},[O,t("b",{},"kamiro-telosu-bavine")]),ie===0?t("span",{class:"dl-pill info"},_("Main")):ve?t("span",{class:"dl-pill warn"},"HTTP"):""])}))};H(),b(),a.addEventListener("input",()=>b());let C={portal:_("Portal running"),portal_dns:_("Points here"),portal_reply:_("Answers reach visitors"),portal_http:_("Plain HTTP"),cert:_("Certificate")},y=n.d.needs??{https:[],acme:[],home:[]},z=j=>{if(!o.portal_enabled)return t("div",{hidden:!0});if(!j)return ke("check",_("Ready to share"),_("The portal’s checks from Health"),[t("p",{class:"dl-muted dl-loading"},_("Running checks…"))]);let Y=j.filter(P=>P.status!=="skip");if(!Y.length)return t("div",{hidden:!0});let{bad:ie,worst:ve}=Hr(j),R=t("div",{class:"dl-ready-details",hidden:!0},Y.map(P=>t("div",{class:`dl-ready-item ${P.status}`},[v(P.status==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("span",{},P.title),t("span",{class:"dl-sub"},P.detail)])]))),O=t("div",{class:"dl-stack gap8"},[t("div",{class:`dl-ready-sum ${ve}`},[v(ve==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("b",{},ve==="ok"?W(Y.length,"All %s check passed","All %s checks passed"):m(N_(Y.length,"%s of %s check passed","%s of %s checks passed"),K(Y.length-ie.length),K(Y.length))),ie.length?t("span",{class:"dl-sub"},ie.map(P=>P.detail).join(" ")):t("span",{class:"dl-sub"},_("Links will open for the people you send them to."))]),t("button",{type:"button",class:"dl-linkbtn",click:P=>{R.hidden=!R.hidden,P.currentTarget.textContent=R.hidden?_("Details"):_("Hide")}},_("Details"))]),t("div",{class:"dl-chips-row"},Y.map(P=>t("span",{class:`dl-check-chip ${P.status}`,title:P.detail},[v(P.status==="ok"?"check":"alert"),C[P.id]??P.title]))),R]);return ke("check",_("Ready to share"),_("The portal’s checks from Health"),[O])},k=j=>{if(!o.portal_enabled||!j&&!y.https.length)return t("span",{hidden:!0});if(y.https.length)return t("span",{class:"dl-pill bad"},_("Can’t start"));let{worst:Y}=Hr(j);return t("span",{class:`dl-pill ${Y==="ok"?"ok":Y==="error"?"bad":"warn"}`},Y==="error"?_("Needs attention"):_("Ready"))},f=z(n.portal?.checks??null),x=k(n.portal?.checks??null);n.portalFill=j=>{p=!0,M(j.candidates),H(),b();let Y=z(j.checks);f.replaceWith(Y),f=Y;let ie=k(j.checks);x.replaceWith(ie),x=ie};let T=s&&!s.self_signed&&s.expires?Oe(s.expires):"",I=_e(_("Listening port"),a,()=>hn(a.value.trim()===""?o.portal_port:Number(a.value),n.d.tcp_taken??[],c.some(d)));$=I.refresh;let V=_e(_("Unknown links"),i,()=>gs(i.value)),J=!!(e.portal_cert&&e.portal_key),te=s?J?_("Your files"):s.self_signed?_("Self-signed"):"Let’s Encrypt":_("Portal is off"),B=()=>{let j=he(e.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),Y=he(e.portal_key,{placeholder:"/etc/ssl/…/key"});de(_("Use your own certificate"),[t("p",{class:"dl-muted"},_("Paths on the router. Leave both empty to pick a certificate automatically.")),ge(_("Certificate file"),j),ge(_("Key file"),Y)],[ue()," ",A(_("Save"),()=>{ce(),n.save({portal_cert:j.value.trim(),portal_key:Y.value.trim()},_("Certificate saved"),"portal")},"positive")])},Q=(j,Y,ie,ve,R,O)=>it(j,Y,ie,ve,A(O,()=>nn(R,y[R],()=>n.reload("portal")),"positive")),ne=y.https.length?Q("lock","bad",_("HTTPS isn’t available on this router"),m(_("The portal needs %s. It can’t start without them."),new Intl.ListFormat(le(),{type:"conjunction"}).format(y.https)),"https",_("Install")):"",fe=y.acme.length&&(!s||s.self_signed)?Q("lock","",_("Free certificate from Let’s Encrypt"),e.portal_host?m(_("ACME isn’t installed. With it the router gets a certificate for %s and browsers stop warning."),e.portal_host):_("ACME isn’t installed. With it the router gets a certificate and browsers stop warning."),"acme",_("Install ACME")):"",oe=[t("div",{class:"dl-row"},[v("lock"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},[te,T?t("span",{class:"dl-faint"},` · ${m(_("until %s"),T)}`):""]),t("span",{class:"dl-sub dl-ellipsis",title:s?.path??""},s?s.self_signed?_("Made by the router: browsers warn until a certificate covers the address."):`${J?_("Your files"):_("Found automatically")} · ${s.path}`:_("Turn the portal on to see its certificate."))])]),t("div",{class:"dl-row"},[v("file"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},_("Your own files")),t("span",{class:"dl-sub"},J?`${e.portal_cert} · ${e.portal_key}`:_("Not set: the certificate is picked automatically."))]),J?A(_("Reset"),()=>n.save({portal_cert:"",portal_key:""},_("Automatic certificate"),"portal"),"negative"):"",A(J?_("Change"):_("Use files"),B)]),fe];return We("portal",_("Personal portal"),[t("span",{class:"dl-muted"},_("A page where each person adds and manages their devices with their personal link.")),ne?t("div",{class:"dl-list"},[ne]):"",ke("network",_("Port"),_("How the portal listens (80 and 443 stay free)"),[I]),ke("edit",_("Appearance"),_("What people see"),[V]),ke("link",_("Addresses"),_("Pick one or more; the first is the main link"),[h,t("div",{class:"dl-stack gap8"},[S,t("span",{class:"dl-sub"},_("Example code; each person gets their own three words."))])]),ke("lock",_("Certificate"),_("Used for HTTPS links"),oe),f],[t("span"),A(_("Save"),()=>{let j=Ue([I,V]);if(j){q(j,"warning");return}return n.save({portal_enabled:ze(r)?"1":"0",portal_host:c[0]??"",portal_alt:c.slice(1),portal_port:a.value,portal_redirect:i.value.trim()},_("Saved"),"portal")},"positive")],"",[x,r])}function Rr(n){let e=n.d.settings,o=n.d.effective,s=he(e.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),r=ye(o.hostnames,_("Device hostnames")),a=he(e.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),i=he(e.home_dns_fallback==="none"?"":e.home_dns_fallback||o.home_dns_fallback||"",{placeholder:_("None"),inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),l=_e(_("Devices per person"),s,()=>{if(!s.value.trim())return{text:_("The default, 3. Pre-filled when you add someone."),bad:!1};let p=fn(s.value);return p.bad?p:{text:_("Pre-filled when you add someone."),bad:!1}}),d=_e(_("Device hostnames"),a,()=>vs(a.value),t("div",{class:"dl-hostport"},[r,t("span",{class:"dl-faint dl-mono"},"phone.myata."),a])),c=_e(_("Fallback DNS"),i,()=>{let p=bs(i.value);return p.bad?p:{text:m(_("For Home-only devices using home names: %s"),p.text),bad:!1}});return We("defaults",_("New people"),[l,d,c],[t("span"),A(_("Save"),()=>{let p=Ue([l,d,c]);if(p){q(p,"warning");return}return n.save({default_device_limit:s.value,hostnames:ze(r)?"1":"0",domain:a.value,home_dns_fallback:i.value},_("Saved"),"defaults")},"positive")])}function Ir(n){let e=n.d.effective,o=ye(e.geo_enabled,_("Locations")),s=t("select",{class:"cbi-input-select"},[t("option",{value:"ipwho.is",selected:e.geo_provider!=="ipapi.co"?"selected":null},m(_("%s (fallback: %s)"),"ipwho.is","ipapi.co")),t("option",{value:"ipapi.co",selected:e.geo_provider==="ipapi.co"?"selected":null},m(_("%s (fallback: %s)"),"ipapi.co","ipwho.is"))]);return We("map",_("Map & locations"),[t("div",{class:"dl-setrow head"},[t("span",{class:"dl-muted"},_("Show where people connect from on the Overview and person pages, at city level.")),o]),ge(_("Provider"),s)],[t("span",{class:"dl-sub"},_("The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map.")),A(_("Save"),()=>n.save({geo_enabled:ze(o)?"1":"0",geo_provider:s.value},_("Saved"),"map"),"positive")])}var vl=()=>[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages",_("System packages")]];function Br(n){let e=n.d.effective.updates,o=ye(e.check,_("Check automatically"),g=>M(g,ze(r))),s=Me([["6h",_("Every 6 h")],["12h",_("Every 12 h")],["1d",_("Daily")],["7d",_("Weekly")]],e.interval,{label:_("How often"),cls:"sm"}),r=ye(e.auto,_("Install automatically"),g=>M(ze(o),g)),a=he(e.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":_("Time")}),i=Me([["scheduled",_("At a set time")],["immediate",_("As soon as found")]],e.mode,{label:_("When"),cls:"sm",onChange:g=>a.hidden=g!=="scheduled"});a.hidden=e.mode!=="scheduled";let l=new Set(e.targets),d=t("div",{class:"dl-chips-row"},vl().map(([g,h])=>{let E=Xe(h,l.has(g),()=>{l.delete(g)||l.add(g),xn(E,l.has(g))});return E})),c=ye(e.keep,_("Keep the previous version")),p=ye(e.mirrors,_("GitHub mirrors")),u=ge(_("How often"),s),w=[ge(_("When"),t("div",{class:"dl-hostport"},[i,a]),_("A set time keeps tunnel restarts out of the evening; the run happens within an hour of it.")),ge(_("Components"),d,_("AmneziaWG is off by default: a new kernel module restarts every tunnel."))],M=(g,h)=>{u.hidden=!g;for(let E of w)E.hidden=!h};return M(e.check,e.auto),We("updates",_("Updates"),[t("span",{class:"dl-muted"},_("How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first.")),ge(_("Check automatically"),o,_("Looks for new versions in the background; Components shows what it found and the service log names it.")),u,ge(_("Install automatically"),r,_("Downloads and installs new versions of the components below.")),...w,ge(_("Keep the previous version"),c,_("Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB.")),ge(_("GitHub mirrors"),p,_("When GitHub is unreachable, download through mirrors. Checksums are still verified."))],[t("span",{class:"dl-sub"},_("Run a check or an update by hand in Components.")),A(_("Save"),()=>{if(i.dataset.value==="scheduled"){let g=xs(a.value);if(g.bad){q(m(_("Time: %s"),g.text),"warning");return}}return n.save({update_check:ze(o)?"1":"0",update_interval:s.dataset.value,update_auto:ze(r)?"1":"0",update_mode:i.dataset.value,update_time:a.value.trim(),update_targets:[...l],update_keep:ze(c)?"1":"0",update_mirrors:ze(p)?"1":"0"},_("Saved"),"updates")},"positive")])}function Or(n){let e=n.d.logs,o=e.policy,s=Me([["7",W(7,"%s day","%s days")],["30",W(30,"%s day","%s days")],["90",W(90,"%s day","%s days")],["365",W(1,"%s year","%s years")],["0",_("No limit","retention")]],String(o.keep_days),{label:_("Keep activity"),cls:"sm"}),r=Me([["500",K(500)],["2000",K(2e3)],["5000",K(5e3)],["20000",K(2e4)]],String(o.max),{label:_("Maximum events"),cls:"sm"}),a=Me([["10min",_("Every 10 min")],["hourly",_("Hourly")],["off",_("Memory only")]],o.persist,{label:_("Save to flash"),cls:"sm"}),i=Me([["31",W(1,"%s month","%s months")],["62",W(2,"%s month","%s months")],["180",W(6,"%s month","%s months")],["365",W(1,"%s year","%s years")],["730",W(2,"%s year","%s years")]],String(o.usage_days),{label:_("Daily traffic"),cls:"sm"}),l=Me([["12",W(1,"%s year","%s years")],["24",W(2,"%s year","%s years")],["60",W(5,"%s year","%s years")],["120",W(10,"%s year","%s years")]],String(o.usage_months),{label:_("Monthly traffic"),cls:"sm"}),d=new Set(o.categories),c=t("div",{class:"dl-chips-row"},Nt.map(M=>{let g=Xe([Ye(M),t("b",{},K(e.by_category[M]??0))],d.has(M),()=>{d.delete(M)||d.add(M),xn(g,d.has(M))},{title:ws(M)});return g})),p=e.oldest?Oe(new Date(e.oldest*1e3)):"",u=(M,g,h,E)=>t("div",{class:"dl-row"},[v(M),t("span",{class:"dl-row-main dl-stack"},[t("b",{},g),t("span",{class:"dl-sub"},h)]),...E]),w=M=>A(M.toUpperCase(),async()=>{let[g,h]=await Promise.all([N.status(1),N.events(2e4)]);Qe(g,h.events,M)},"neutral",{title:m(_("Download the log as %s"),M.toUpperCase())});return We("logs",_("Logs & history"),[t("p",{class:"dl-muted"},bn(o)),ge(_("Keep activity"),s,_("Older events are removed automatically.")),ge(_("Maximum size"),r,_("Newest events are kept when the log is full.")),ge(_("Record"),c,_("Switched-off categories are not logged from now on.")),ge(_("Save to flash"),a,_("The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot.")),ge(_("Daily traffic"),i,_("Per-day history behind the charts.")),ge(_("Monthly traffic"),l,_("Per-month totals; data limits use the current month.")),t("h4",{class:"dl-setsub"},_("Stored data")),t("div",{class:"dl-list"},[u("activity",_("Activity log"),e.events?`${m(_("%s since %s"),W(e.events,"%s event","%s events"),p)} · ${o.persist==="off"?m(_("%s in memory"),Et(e.log_ram)):m(_("%s in memory, %s on flash"),Et(e.log_ram),Et(e.log_flash))}`:_("Empty"),[w("csv"),w("json"),A(_("Clear"),()=>lt(_("Clear activity"),_("Removes events from the log on the router."),{},()=>n.reload("logs")),"negative")]),u("chart",_("Traffic history"),e.usage_days?`${m(_("%s since %s"),W(e.usage_days,"%s day","%s days"),Oe(e.usage_since))} · ${m(_("%s on flash"),Et(e.usage_flash))}`:_("Empty"),[A(_("Reset"),()=>Ht("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),u("pin",_("Location cache"),`${W(n.d.geo_cached,"%s address","%s addresses")} · ${m(_("%s on flash"),Et(e.geo_flash))}`,[A(_("Clear"),async()=>{await F(()=>N.geoClear(),_("Location cache cleared"))&&await n.reload("logs")},"negative")])])],[t("span",{class:"dl-sub"},_("Clear one person or device from their own page.")),A(_("Save"),()=>n.save({log_keep_days:s.dataset.value,log_max:r.dataset.value,log_persist:a.dataset.value,usage_keep_days:i.dataset.value,usage_keep_months:l.dataset.value,log_category:[...d]},_("Saved"),"logs"),"positive")])}function bl(n){return{manual:_("Manual"),auto:_("Nightly"),"pre-restore":_("Before restore"),"pre-import":_("Before import"),"pre-delete":_("Before removing a server"),"pre-update":_("Before update")}[n]??n}var jr=3;function Ho(n){let e=new Date(n*1e3),o=e.toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"}),s=Math.round((new Date(new Date().toDateString()).getTime()-new Date(e.toDateString()).getTime())/864e5);return s===0?m(_("Today, %s"),o):s===1?m(_("Yesterday, %s"),o):`${e.toLocaleDateString(le(),{day:"numeric",month:"short"})}, ${o}`}async function xl(n){let e=await F(()=>N.backupRead(n.name));if(!e)return;let o=atob(e.data),s=new Uint8Array(o.length);for(let a=0;axl(n),"neutral","dl-icon-only"),$e("more",_("More"),o=>Se(o.currentTarget,[{label:_("Restore"),icon:v("reset"),run:async()=>{await me(_("Restore this backup?"),m(_("Everything returns to %s. The current state is backed up first."),Ho(n.created)),_("Restore"),!0)&&await F(()=>N.backupRestore(n.name),_("Restored"))&&e(!0)}},{label:_("Delete"),icon:v("trash"),danger:!0,run:async()=>{await me(_("Delete this backup?"),m(_("The backup from %s is removed from the router."),Ho(n.created)),_("Delete"),!0)&&await F(()=>N.backupDelete(n.name),_("Backup deleted"))&&e()}}]),"neutral","dl-icon-only")])])}function Wr(n,e){let o=n.slice(0,jr).map(d=>Ur(d,e)),s=n.slice(jr),r=n.length?t("div",{class:"dl-list"},[...o,s.length?t("details",{class:"dl-bk-older"},[t("summary",{},[v("chevron"),W(s.length,"%s older backup","%s older backups")]),...s.map(d=>Ur(d,e))]):""]):t("div",{class:"dl-list"},[t("div",{class:"dl-row dl-muted"},_("No backups yet."))]),a=A(_("Restore from file"),async()=>{let d=await eo(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await me(_("Restore from file?"),m(_("Replace the current Dawnline configuration with %s? The current state is backed up first."),d.name),_("Restore"),!0)&&await F(()=>N.backupUpload(d.data),_("Restored"))&&e(!0)}),i=A(_("Export JSON"),async()=>{let d=await F(()=>N.exportJson());d&&Ne(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=A(_("Import JSON"),async()=>{let d=await eo(".json,application/json","text");if(!d)return;let c;try{c=JSON.parse(d.data)}catch{q(_("Not a JSON file."),"error");return}await me(_("Import?"),_("This replaces the whole Dawnline configuration on this router. The current state is backed up first."),_("Import"),!0)&&await F(()=>N.importJson(c),_("Imported"))&&e(!0)});return t("section",{class:"dl-setsec",id:"dl-set-backups"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-setsec-head"},[t("div",{class:"dl-stack"},[t("h3",{},_("Backups")),t("span",{class:"dl-sub"},_("Nightly when something changed, and before every restore, import or update. The last 10 are kept."))]),t("span",{class:"dl-spacer"}),A([v("plus")," ",_("Back up now")],async()=>{await F(()=>N.backupCreate(),_("Backup created"))&&e()},"positive")]),r]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},_("Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router.")),t("span",{class:"dl-row-actions dl-bk-actions"},[a,i,l])])])}var zo="remove";function wl(){let n=he("",{placeholder:zo}),e=A(_("Remove Dawnline"),async()=>{await F(()=>N.uninstall(n.value.trim()),_("Dawnline removed"))&&(ce(),setTimeout(()=>location.reload(),800))},"negative",{disabled:!0});n.addEventListener("input",()=>{e.disabled=n.value.trim()!==zo}),de(_("Remove Dawnline?"),[t("p",{},m(_("Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “%s” to confirm."),zo)),n],[ue()," ",e])}function Gr(){return We("danger",_("Remove Dawnline from this router"),[t("p",{class:"dl-muted"},_("Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup."))],[t("span"),A(_("Remove"),()=>wl(),"negative")],"danger")}var On=class{constructor(){this.root=t("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return N.settingsGet()}render(e){this.d=e,this.cards={portal:ft(()=>zr(this)),defaults:ft(()=>Rr(this)),map:ft(()=>Ir(this)),updates:ft(()=>Br(this)),logs:ft(()=>Or(this)),backups:ft(()=>Wr(this.backups,r=>this.loadBackups(r))),danger:ft(()=>Gr())};let o=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,o.map(r=>this.cards[r].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let s=new URLSearchParams(location.search).get("section");return s&&s!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${s}`)?.scrollIntoView({block:"start"})),t("div",{},[t("div",{class:"dl-pagehead"},[t("h2",{class:"dl-h1"},_("Settings"))]),this.root])}async save(e,o,s){let r=await F(()=>N.settingsUpdate(e),o);r&&(this.d=r,this.cards[s].refresh(),s==="portal"&&this.loadPortal())}async loadPortal(){let e=++this.portalSeq,o=await N.portalInfo().catch(()=>null);e===this.portalSeq&&(this.portal=o??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(e=!1){e&&await this.reload();let o=await N.backupList().catch(()=>null);o&&(this.backups=o.backups,this.cards.backups?.refresh())}async reload(e){let o=await N.settingsGet().catch(()=>null);if(o){if(this.d=o,e)this.cards[e].refresh();else for(let s of Object.values(this.cards))s.refresh();(!e||e==="portal")&&this.loadPortal()}}};function qr(n,e=!1){return n&&(e?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function Fr(n){let e=[],o=l=>{let d=[],c=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,p=0;for(let u;u=c.exec(l);)u.index>p&&d.push(l.slice(p,u.index)),u[1]?d.push(t("code",{},u[1].slice(1,-1))):u[2]?d.push(t("b",{},u[2].slice(2,-2))):u[3]?d.push(t("a",{href:u[4],target:"_blank",rel:"noopener"},u[3].replace(/^\[|\]\(.*$/g,""))):u[5]&&d.push(t("a",{href:u[5],target:"_blank",rel:"noopener"},u[5].replace(/^https?:\/\/(github\.com\/)?/,""))),p=u.index+u[0].length;return p{r.length&&e.push(t("p",{},o(r.join(" ")))),r=[],s=null};for(let l of n.replace(/\r/g,"").split(` +`,Bs(i,e)]:[Bs(i,e)])),r=t("button",{type:"button",class:"dl-chipbtn",click:i=>{i.preventDefault(),e=!e,dom.content(r,[g(e?"x":"key"),e?_("Hide key"):_("Show key")]),s()}},[g("key"),_("Show key")]);s();let a=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${W(a,"%s byte","%s bytes")}`)]),N([g("download")," ",_("Download")],()=>Ae(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[g("chevron"),t("span",{},_("Configuration")),t("span",{class:"dl-spacer"}),r,t("button",{type:"button",class:"dl-chipbtn",click:i=>{i.preventDefault(),xe(n.conf,_("Configuration copied"))}},[g("copy"),_("Copy")])]),o])])}function go(n){let e=n.amnezia.obfuscation??{},o={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([s,r])=>r==null||r===""||r===(o[s]??"0"))}async function Pi(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},_("This device generated its own keys in the browser, so its full configuration only exists on that device."));let o=await fo(n,n.server),s={qr:()=>t("div",{class:"dl-qr-pane"},[hn(n.conf),t("span",{class:"dl-sub"},go(n)?_("Scan with AmneziaVPN or any WireGuard app on the device."):_("Scan with AmneziaVPN or AmneziaWG on the device."))]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},o),N(_("Copy"),()=>xe(o,_("Key copied")))]),t("span",{class:"dl-sub"},m(_("AmneziaVPN → %s. Keep it private."),["+",_("Insert","AmneziaVPN app"),_("Continue","AmneziaVPN app")].join(" → ")))]),file:()=>Si(n)},r=t("div",{class:"dl-connect-body"}),a=t("div",{class:"dl-seg"}),i=l=>{a.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(r,s[l]())};for(let[l,d]of[["file",_("File")],["key",_("Key")],["qr",_("QR code")]])a.appendChild(t("button",{type:"button","data-id":l,click:()=>i(l)},d));return i(e),t("div",{class:"dl-stack gap12"},[a,r])}async function $i(n,e,o,s){let r=Yt(o),i=n.st.people.filter(d=>d.server===e.id).reduce((d,c)=>d+c.devices.length,0);await me(s?_("Generate new disguise values?"):m(_("Switch to %s?"),r.title),[W(i,"%s AmneziaWG device stops connecting until it imports its configuration again (from their personal link or from you).","%s AmneziaWG devices stop connecting until they import their configuration again (from their personal link or from you)."),o==="max"?_("They need an app with AmneziaWG 3.1."):o==="balanced"?_("They need an app with AmneziaWG 2.0 or newer."):"",n.st.servers.length===1&&i?_("To keep the old disguise for some people, add a second server and move them there."):""].filter(Boolean).join(" "),s?_("Generate and apply"):_("Switch and apply"),!0)&&await K(()=>H.serverObfuscation(e.id,o),s?_("New values applied"):m(_("%s applied"),r.title))&&(q(_("Devices are marked “Update config” until they import again."),"info",6e3),await n.refresh())}function Di(n,e){let o=n.st,s=he(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=he(e.mtu?String(e.mtu):"",{placeholder:_("Auto"),inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=he(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=Yt(e.preset)?e.preset:void 0,l=i??kn(o.awg),d=N("",()=>$i(n,e,l,l===i),"neutral"),c=()=>dom.content(d,l===i?[g("reset")," ",_("Generate new values")]:[m(_("Switch to %s"),Yt(l).title)]);c();let p=o.awg_state?.tools!==!1,u=[],v=_e(_("UDP port"),s,()=>qt(Number(s.value),u,[_("Opened on the WAN firewall automatically."),Number(s.value)===4500?_("4500 is IPsec’s port: most networks let it through."):""].filter(Boolean).join(" ")));H.serverPorts(e.id).then(h=>{u=h.udp_taken??[],v.refresh()}).catch(()=>{});let M=_e("MTU",r,()=>fs(r.value,e.mtus)),x=_e(_("Keep-alive"),a,()=>gs(a.value));return Gt("",[Rs("AmneziaWG",e.ifname),ke("globe",_("Listening"),_("Where devices reach this core from the internet"),[v]),ke("file",_("In every device configuration"),_("Changing these marks devices “Update config” until they import again"),[M,x]),ke("shield",_("Disguise"),_("So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard"),[Jt(e.preset)?xt("warn",oe(_("%s is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to %s or %s: devices import their configuration again."),t("b",{},Jt(e.preset)),t("b",{},_("Balanced")),t("b",{},_("Maximum")))):"",_n(o.awg,l,h=>{l=h,c()},i,p),p&&!o.awg.v3?xt("info",oe(_("This router runs an older AmneziaWG. %s becomes available with kmod-amneziawg and amneziawg-tools 3.1."),t("b",{},_("Maximum")))):"",Ti(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},_("Applies at once: every AmneziaWG device imports its configuration again.")),d])]),t("details",{class:"dl-params"},[t("summary",{},[g("chevron"),t("span",{},_("Tunnel")),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ge(_("Interface"),t("span",{class:"dl-mono"},`${e.ifname} · ${m(_("router %s"),e.address)}`)),ge(_("Tunnel subnet"),t("span",{class:"dl-mono"},e.subnet),_("Device addresses come from it.")),ge(_("Server public key"),t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),N([g("copy")],()=>xe(e.public_key,_("Public key copied")),"neutral",{title:_("Copy"),class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},_("Port, MTU and keep-alive apply at once.")),N(_("Save"),()=>{let h=je([v,M,x]);if(h){q(h,"warning");return}return n.save({port:s.value,mtu:r.value,keepalive:a.value},_("AmneziaWG saved"))},"positive")])}function Ai(n){let e=Yt(n.preset),o=n.obf??{},s=(i,l)=>t("span",{class:`dl-segs ${l}`},[0,1,2,3].map(d=>t("i",{class:d+o[i]).map(i=>`${i.toUpperCase()} ${o[i]}`);return a.length&&r.push(a.slice(0,2).join(" · ")+(a.length>2?` +${a.length-2}`:"")),["h1","h2","h3","h4"].some(i=>o[i]&&o[i]!==String(["h1","h2","h3","h4"].indexOf(i)+1))&&r.push(_("H1–H4 random")),o.i1&&r.push(/0x(8580|0100)0001/.test(o.i1)?_("DNS-like first packets"):_("Signature packets")),o.header_protection_key&&r.push(_("Encrypted headers")),r.length||r.push(e?.id==="off"?_("Plain WireGuard"):_("No values yet")),t("div",{class:"dl-bento-tile dl-disg"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},_("Disguise")),t("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},_("Change"))]),t("div",{class:"dl-disg-id"},[t("span",{class:`dl-disg-ic${e?.id==="off"?" off":""}`},g(e?.ic??"shield")),t("span",{class:"dl-stack"},[t("b",{},e?e.title:Jt(n.preset)??_("Custom","disguise")),t("span",{class:"dl-sub"},e?e.short:Jt(n.preset)?_("Switch to Balanced or Maximum"):_("Set by hand"))])]),e?t("div",{class:"dl-disg-meters"},[t("span",{},_("Stealth")),s(e.stealth,"acc"),t("span",{},_("Speed")),s(e.speed,"ok")]):"",t("div",{class:"dl-disg-chips"},r.map(i=>t("span",{},i)))])}var vo={id:"awg",label:"AmneziaWG",settingsCard:Di,overviewTile:Ai,connectBlock:Pi,qrText:n=>n.conf,appKey:{get label(){return _("Copy AmneziaVPN config")},make:n=>fo(n,n.server)},file:{get label(){return _("Download AmneziaWG config")},make:n=>({name:n.filename,text:n.conf})}};var Ni={awg:vo};function Ge(n){return Ni[n?.core||"awg"]??vo}function Rt(n,e){return Ge(n.find(o=>o.id===e))}var Hi=2,Zt=new Set,bo=null,Cn=null;async function Os(){if(document.visibilityState!=="visible"||!Zt.size)return;let n=await H.rev().catch(()=>null);if(!n)return;let e=bo!=null&&n.rev!==bo;bo=n.rev,n.version&&(Cn&&n.version!==Cn?(q(m(_("Dawnline was updated to %s: reload the page."),n.version),"warning",15e3),Cn=null):Cn??(Cn=n.version)),e&&Zt.forEach(o=>o())}function Ln(n){return Zt.add(n),poll.add(Os,Hi),()=>{Zt.delete(n),Zt.size||poll.remove(Os)}}function Ws(n,e,o,s,r=0){let a=[],i=null,l=p=>{i&&p>i.from&&a.push({...i,to:p}),i=null},d=n.filter(p=>p.device===e).sort((p,u)=>p.ts-u.ts);for(let p of d)if(p.type==="connect")l(p.ts),p.detail&&(i={ip:p.detail,from:p.ts,to:p.ts,live:!1});else if(p.type==="roam"){let u=p.detail?.split("→")[1]?.trim();l(p.ts),u&&(i={ip:u,from:p.ts,to:p.ts,live:!1})}else p.type==="disconnect"&&l(p.ts);let c=i;return c&&s?a.push({...c,to:Math.max(o,c.from),live:!0}):l(Math.min(o,r)),a}function et(n){return`${n.city||`${n.lat.toFixed(1)},${n.lon.toFixed(1)}`}|${n.cc}`}function Gs(n,e,o,s){let r=new Map;for(let i of e)(i.device===o||!r.has(i.ip))&&r.set(i.ip,i);let a=[];for(let i of n){let l=r.get(i.ip);!l||i.to<=s||a.push({key:et(l),point:l,from:Math.max(i.from,s),to:i.to,live:i.live})}return a}function qs(n){let e=new Map,o=0;for(let s of n)e.set(s.key,(e.get(s.key)??0)+(s.to-s.from)),o+=s.to-s.from;return new Map([...e].map(([s,r])=>[s,o?r/o:0]))}function js(n,e=2700){let o=[];for(let s of n){let r=o[o.length-1];if(r&&s.key!==r.key&&!s.live&&s.to-s.from{a&&(o.push({kind:"move",k:a,start:s,ms:e}),s+=e);let i=Math.min(1100,Math.max(350,(r.to-r.from)/3600*45));o.push({kind:"stay",k:a,start:s,ms:i}),s+=i}),{steps:o,total:s}}function Ys(n,e,o){let s=e.findIndex(l=>o>=l.start&&oo>=i.from&&oi.kind==="stay"&&i.k===s),a=n[s];return r.start+r.ms*Math.min(.999,Math.max(0,(o-a.from)/Math.max(1,a.to-a.from)))}var zi=n=>n<=0?0:n>=1?1:n<.5?2*n*n:1-(-2*n+2)**2/2;function Zs(n){return-xo/2+(1+xo)*zi((n-Us)/(1-Us))}var Qs=n=>n+Ks>=1;function Xs(n){return["interpolate",["linear"],["abs",["-",["get","pos"],n]],0,1,Ks,1,xo/2,0]}function er(n,e){let o=n==="24h"?86400:n==="7d"?604800:2592e3,s=e-o,r=[],a=(l,d)=>{let c=(l-s)/o;c>.02&&c<.98&&r.push([c,d])},i=new Date(s*1e3);if(n==="24h")for(i.setMinutes(0,0,0);i.getTime()/1e3<=e;)i.getHours()%6===0&&a(i.getTime()/1e3,`${String(i.getHours()).padStart(2,"0")}:00`),i.setHours(i.getHours()+1);else if(n==="7d")for(i.setHours(12,0,0,0);i.getTime()/1e3<=e;i.setDate(i.getDate()+1))a(i.getTime()/1e3,i.toLocaleDateString(le(),{weekday:"short"}));else{let l=new Date(e*1e3);l.setHours(0,0,0,0);for(let d=0;d<5;d++){let c=new Date(l);c.setDate(l.getDate()-7*d),a(c.getTime()/1e3,c.toLocaleDateString(le(),{day:"numeric",month:"short"}))}r.reverse()}return r}var Mn=n=>new Date(n*1e3).toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"});function tr(n,e){let o=s=>new Date(s*1e3).toDateString();return o(n)===o(e)?_("Today"):o(n)===o(e-86400)?_("Yesterday"):new Date(n*1e3).toLocaleDateString(le(),{weekday:"short",day:"numeric",month:"short"})}var yo="https://unpkg.com/maplibre-gl@6.14.0/dist",nr={module:"sha384-q26X6R1yFeg0QR9SHHn6U3Nb0ddRRTtwxsahubv5R89/v5nijKpk9KviUp9ZLySk",css:"sha384-1TZtfVz7qtwR5vD7cMwjGT+9uiK4lqE3pbUOPwYO6OCpb+TYP0S9vLIhG02JCU04"},or="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",sr="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",Ri={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Qt=null;function Ii(n){if(n.appendChild(t("link",{rel:"stylesheet",href:`${yo}/maplibre-gl.css`,integrity:nr.css,crossorigin:"anonymous"})),Qt)return Qt;let e=`${yo}/maplibre-gl.mjs`;return Qt=new Promise((s,r)=>{let a=t("link",{rel:"modulepreload",href:e,integrity:nr.module,crossorigin:"anonymous"});a.addEventListener("load",()=>s()),a.addEventListener("error",()=>r(new Error("integrity"))),document.head.appendChild(a)}).then(()=>import(e)).then(s=>(s.getWorkerUrl()||s.setWorkerUrl(`${yo}/maplibre-gl-worker.mjs`),s),s=>{throw Qt=null,new Error(s?.message==="integrity"?_("The map library from the CDN is not the expected file: not loading it."):_("Could not load the map library (no internet access from this browser?)"))}),Qt}var Bi=10,rr=30,Oi=62,ji=4,ar=4.5,Ui=7,En="#3b82f6",ko="#8a8a8a";function ir(n,e,o=.2,s=64){let[r,a]=n,[i,l]=e,d=i-r,c=d>180?i-360:d<-180?i+360:i,p=c-r,u=l-a,v=Math.hypot(p,u);if(v===0||o===0)return[n,[c,l]];let M=-u/v,x=p/v,h=v*o,S=(r+c)/2+M*h,z=(a+l)/2+x*h,E=[],$=Math.max(2,Math.floor(s));for(let b=0;b<=$;b+=1){let k=b/$,y=1-k;E.push([y*y*r+2*y*k*S+k*k*c,y*y*a+2*y*k*z+k*k*l])}return E}function _o(n,e){let o=new Map;for(let s of n.geo.points){if(n.person&&s.person!==n.person||n.device&&s.device!==n.device||(e==="online"?!s.online:n.now-s.ts>Ri[e]))continue;let r=n.device?et(s):n.person?`${s.device}|${s.city}|${s.cc}`:s.device,a=o.get(r);(!a||s.online&&!a.online||s.online===a.online&&s.ts>a.ts)&&o.set(r,s)}return[...o.values()]}function Co(n,e){let o=0;return _o(n,e).sort((s,r)=>Number(r.online)-Number(s.online)||r.ts-s.ts).map(s=>({...s,n:s.online?0:++o}))}var dt=class{constructor(e,o="online",s=380){this.cb=e;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.theme=null;this.resize=null;this.fitBlind=!1;this.data=null;this.fitted=!1;this.fitKey=null;this.people=[];this.slots=[];this.merged=[];this.piles=new Map;this.dock=null;this.dockKey="";this.dockQuiet=!1;this.piledKeys=new Set;this.foldedKeys=new Set;this.targetZoom=null;this.before=null;this.hiddenKey="";this.focused=null;this.dead=!1;this.places=new Map;this.replaying=null;this.bandDots=[];this.range=o,this.status=t("div",{class:"dl-map-status"}),this.card=t("div",{class:"dl-map-card","aria-live":"polite"}),this.el=t("div",{class:"dl-geomap",style:`height:${s}px`},[this.status,this.card])}async mount(e){this.data=e;try{this.gl=await Ii(this.el)}catch(s){this.status.textContent=s.message;return}if(this.dead)return;this.map=new this.gl.Map({container:this.el,style:wt()?or:sr,center:[e.geo.home?.lon??20,e.geo.home?.lat??50],zoom:1,renderWorldCopies:!1,attributionControl:{compact:!0},minZoom:1}),this.map.on("style.load",()=>this.layers()),this.map.on("move",()=>this.declutter()),this.map.once("idle",()=>{let s=this.el.querySelector(".maplibregl-ctrl-attrib");s?.classList.remove("maplibregl-compact-show"),s?.removeAttribute("open")}),this.resize=new ResizeObserver(()=>{!this.map||!this.el.clientWidth||!this.el.clientHeight||(this.map.resize(),this.fitBlind&&(this.fitKey=null,this.draw()))}),this.resize.observe(this.el);let o=wt();this.theme=new MutationObserver(()=>{!this.map||wt()===o||(o=wt(),this.map.setStyle(o?or:sr))}),this.theme.observe(document.documentElement,{attributes:!0,attributeFilter:["data-darkmode"]})}layers(){if(this.map){this.hiddenKey="",this.map.setProjection({type:"globe"}),this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],En,ko],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],En,ko],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-band",{type:"geojson",data:{type:"FeatureCollection",features:this.bandDots}}),this.map.addLayer({id:"dl-band",type:"circle",source:"dl-band",paint:{"circle-radius":1.4,"circle-color":En,"circle-opacity":0}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}});for(let e of[!1,!0])this.map.addLayer({id:e?"dl-arc-live":"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],e],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":e?En:ko,"line-width":2,"line-opacity":.85,"line-dasharray":[2,2]}});this.draw()}}setRange(e){this.range=e,this.fitKey=null,this.draw()}update(e){this.data=e,this.draw()}destroy(){this.dead=!0,this.dropCard();for(let e of this.piles.values())e.marker.remove();this.piles.clear(),this.theme?.disconnect(),this.resize?.disconnect(),this.map?.remove(),this.map=null}groups(e){let o=new Map;for(let s of e){let r=`${s.person}|${et(s)}`,a=o.get(r);a||(a={key:r,person:s.person,lat:s.lat,lon:s.lon,city:s.city,country:s.country,cc:s.cc,asn:s.asn,org:s.org,online:!1,ts:0,points:[]},o.set(r,a)),a.points.push(s),a.online||(a.online=s.online),a.ts=Math.max(a.ts,s.ts)}return[...o.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let e=this.data,o=this.groups(_o(e,this.range)),s=e.person||e.device?null:e.geo.home;for(let d of this.markers)d.remove();this.markers=[];let r=e.person||e.device?null:Gi(o,s),a=o.map(d=>({g:d,at:r?.get(d.key)??[d.lon,d.lat]}));if(this.slots=[],this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:a.map(({g:d})=>({type:"Feature",properties:{online:d.online,key:d.key},geometry:{type:"Point",coordinates:[d.lon,d.lat]}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:s?a.map(({g:d,at:c})=>({type:"Feature",properties:{online:d.online,person:d.person,key:d.key},geometry:{type:"LineString",coordinates:ir([s.lon,s.lat],c)}})):[]}),s){let d=t("span",{class:"dl-mk-host"});d.innerHTML=`${_t("server","dl-mk-host-ic")}`,this.dock=d.appendChild(t("span",{class:"dl-mk-dock"})),this.dockQuiet=this.dockKey!=="",this.dockKey="";let c=t("div",{class:"dl-mk-hub",title:`${_("Home router")}${s.city?` · ${s.city}`:""}${s.org?` · ${s.org}`:""}`},[d,t("span",{class:"dl-mk-label chip"},s.city||_("Home"))]);c.addEventListener("mouseenter",()=>this.showMerged(s.city)),c.addEventListener("mouseleave",()=>this.focus(this.focused)),c.addEventListener("click",()=>this.zoomToMerged()),this.add(c,[s.lon,s.lat],!0)}let i=new Map(e.device?Co(e,this.range).map(d=>[et(d),d.n]):[]);this.people=[],this.places.clear();for(let{g:d,at:c}of a){let p=d.points.length,u=e.people.find(h=>h.id===d.person);if(e.person){let h=e.device?this.deviceMarker(d,c,u,i.get(et(d))??0):this.placeMarker(d,c,u);this.add(h,c);continue}let v=d.points.map(h=>u?.devices.find(S=>S.id===h.device)?.kind??"other"),M=t("span",{class:"dl-mk-badge"});M.innerHTML=p<=2?v.map(h=>_t(h,"dl-mk-badge-ic")).join(""):String(p);let x=t("button",{type:"button",class:`dl-mk${d.online?" online":""}`,"aria-label":d.city?m(N_(p,"%s: %s device in %s","%s: %s devices in %s"),u?.name??_("Someone"),V(p),d.city):m(N_(p,"%s: %s device in an unknown city","%s: %s devices in an unknown city"),u?.name??_("Someone"),V(p))},[t("span",{class:"dl-mk-av"},[Oe(u?.name??"?"),M]),t("span",{class:"dl-mk-label below"},d.city||d.cc||"?")]);x.addEventListener("mouseenter",()=>this.focus(d.person)),x.addEventListener("mouseleave",()=>this.focus(null)),this.people.push({el:x,person:d.person}),x.addEventListener("click",h=>{h.stopPropagation(),this.openPopup(d,c,x)}),this.add(x,c,!1,u?.name??_("Someone"),`${d.city||d.cc||"?"} · ${d.online?_("now"):pe(d.ts,e.now)}`,d.key,d)}this.declutter();let l=a.map(d=>d.g.key).sort().join(";");if(l!==this.fitKey&&!this.popup){let d=this.fitted&&!this.fitBlind;if(this.fitBlind=!this.el.clientWidth||!this.el.clientHeight,this.fitKey=l,this.fitted=!0,s&&!a.length){let c={center:[s.lon,s.lat],zoom:12};d?this.glide(12,()=>this.map.flyTo({...c,duration:1200})):this.map.jumpTo(c)}else{let c=a.map(p=>p.at);s&&(c.length===0||this.range!=="online"||a.some(p=>p.g.online))&&c.push([s.lon,s.lat]),this.fit(c,d)}}this.status.textContent=a.length||s?"":_("No locations yet"),this.status.style.display=this.status.textContent?"":"none",this.focus(this.focused&&this.people.some(d=>d.person===this.focused)?this.focused:null)}add(e,o,s=!1,r,a,i,l){i&&this.foldedKeys.has(i)&&e.classList.add("merged"),i&&this.piledKeys.has(i)&&e.classList.add("piled"),e.dataset.key=i??"",e.classList.add("dl-mk-new"),requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("dl-mk-new")));let d=new this.gl.Marker({element:e}).setLngLat(o).addTo(this.map);this.markers.push(d),this.slots.push({marker:d,el:e,at:o,fixed:s,who:r,where:a,g:l})}declutter(){if(!this.map)return;let e=this.map.getZoom();this.el.classList.toggle("dl-lod-far",e=ar&&e{let l=this.map.project(i.at),d=i.el.querySelector(":scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile");return{x:l.x,y:l.y,r:(d?.offsetWidth||24)/2+3,fixed:i.fixed}}),s=o.filter(i=>i.fixed);this.merged=[],this.foldedKeys.clear();let r=this.targetZoom==null?1:Math.min(1,2**(this.targetZoom-this.map.getZoom()));o.forEach((i,l)=>{if(i.fixed)return;let d=this.slots[l],c=d.el.classList.contains("merged")?12:6,p=s.find(u=>Math.hypot(u.x-i.x,u.y-i.y)*r{let c=this.slots[d];!c||c.fixed||(o[d].fixed&&([i,l]=[0,0]),c.marker.setOffset([i,l]),Fi(c.el,i,l))})}closePopup(e=!1){let o=this.popup;if(!o||o.card.classList.contains("leaving"))return;o.card.classList.add("leaving"),setTimeout(()=>{this.popup===o&&this.dropCard()},140);let s=this.before;if(this.before=null,!s)return;let r=()=>this.map?.flyTo({...s,duration:800});if(!e)return r();let a=!1,i=()=>{a||(a=!0,window.removeEventListener("pointerup",i,!0),window.removeEventListener("pointercancel",i,!0),setTimeout(r,0))};window.addEventListener("pointerup",i,!0),window.addEventListener("pointercancel",i,!0),setTimeout(i,1500)}dropCard(){this.popup?.off(),this.popup?.card.remove(),this.popup=null}showMerged(e){this.merged.length&&(dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},e?m(_("Near %s"),e):_("Near the server")),` · ${_("click to zoom in")}`]),...this.merged.map(o=>t("div",{class:"dl-map-card-row"},[t("span",{},o.who),t("span",{class:"dl-faint"},o.where)]))]),this.card.classList.add("on"))}paintDock(){let e=this.dock;if(!e)return;let o=this.merged.map(r=>`${r.key}:${r.online?1:0}`).join("|");if(o===this.dockKey)return;this.dockKey=o,e.parentElement?.classList.toggle("docked",this.merged.length>0);let s=this.slots.find(r=>r.fixed).at;this.merged.length&&dr(e,this.merged,this.faceActions(()=>[s]),this.dockQuiet),this.dockQuiet=!1}faceActions(e){return{click:(o,s)=>this.openFace(o,s,e()),hover:o=>this.focus(o?.g?.person??null)}}pileUp(e){let o=new Set;if(!this.data?.person&&!this.data?.device){let s=e.flatMap((l,d)=>!l.fixed&&this.slots[d].el.querySelector(":scope > .dl-mk-av")?[d]:[]),r=new Map(s.map(l=>[l,l])),a=l=>r.get(l)===l?l:a(r.get(l));for(let l of s)for(let d of s){if(d<=l)continue;let c=this.slots[l].el.classList.contains("piled")&&this.slots[d].el.classList.contains("piled");Math.hypot(e[l].x-e[d].x,e[l].y-e[d].y)this.slots[h]),c=d.map(lr),p=c.map(h=>h.key).sort().join(",");o.add(p);let u=[d.reduce((h,S)=>h+S.at[0],0)/d.length,d.reduce((h,S)=>h+S.at[1],0)/d.length],v=this.piles.get(p);if(!v){let h=t("span",{class:"dl-mk-pile-box"}),S=[...new Set(d.map($=>$.g?.city||$.g?.cc||"?"))],z=t("div",{class:"dl-mk-pile"},[h,t("span",{class:"dl-mk-label below"},S.length===1?S[0]:W(d.length,"%s person","%s people"))]);v={marker:new this.gl.Marker({element:z}).setLngLat(u).addTo(this.map),el:z,box:h,faces:c},z.addEventListener("mouseleave",()=>this.focus(this.focused));let E=v;z.addEventListener("click",$=>{$.stopPropagation(),this.zoomInTo(E.faces.map(b=>b.at),!1)}),this.piles.set(p,v)}v.faces=c;let M=v;dr(v.box,c,this.faceActions(()=>M.faces.map(h=>h.at)));for(let h of l)this.slots[h].el.classList.add("piled"),Object.assign(e[h],{r:0,fixed:!0});let x=this.map.project(u);e.push({x:x.x,y:x.y,r:(v.el.offsetWidth||60)/2+3,fixed:!0})}}this.piledKeys=new Set(this.slots.filter(s=>s.el.classList.contains("piled")).map(s=>s.el.dataset.key??"")),this.slots.forEach((s,r)=>{(!e[r].fixed||s.fixed||s.el.classList.contains("merged"))&&s.el.classList.remove("piled")});for(let[s,r]of this.piles)o.has(s)||(this.piles.delete(s),r.el.classList.add("out"),setTimeout(()=>r.marker.remove(),200))}zoomToMerged(){!this.map||!this.merged.length||this.zoomInTo([this.slots.find(e=>e.fixed).at,...this.merged.map(e=>e.at)],!1)}openFace(e,o,s){if(!e.g)return;if(s.every(a=>Tn(a,e.at)<1))return this.openPopup(e.g,e.at,o);let r=()=>{let a=this.slots.find(i=>i.el.dataset.key===e.key);a?.g&&!a.el.classList.contains("merged")&&!a.el.classList.contains("piled")&&this.openPopup(a.g,a.at,a.el)};this.zoomInTo(this.nearby(e.at),!0)?this.map.once("moveend",r):r()}nearby(e){return[e,...this.slots.filter(o=>!o.fixed&&o.at!==e&&Tn(o.at,e)<=rr).map(o=>o.at)]}zoomInTo(e,o){let s=new this.gl.LngLatBounds;for(let p of e)s.extend(p);let r=e.some(p=>e.some(u=>Tn(p,u)>rr)),a=this.map.cameraForBounds(s,{padding:50,maxZoom:r?12:Bi}),i=this.map.getZoom(),l=e.map(p=>this.map.project(p)),d=0;l.forEach((p,u)=>l.slice(u+1).forEach(v=>{let M=Math.hypot(p.x-v.x,p.y-v.y),x=i+Math.log2(Oi/Math.max(M,1e-6));x<=12&&(d=Math.max(d,x))}));let c=Math.min(12,Math.max(a?.zoom??0,d));return c<=i+.05?!1:(o&&!this.before&&(this.before={center:this.map.getCenter().toArray(),zoom:i}),this.map.flyTo({center:a?.center??s.getCenter(),zoom:c,duration:800}),!0)}placeMarker(e,o,s){let r=this.data.now,a=[...e.points].sort((u,v)=>Number(v.online)-Number(u.online)||v.ts-u.ts)[0],i=s?.devices.find(u=>u.id===a.device)?.kind??"other",l=e.points.length,d=t("span",{class:"dl-mk-tile"});d.innerHTML=_t(i,"dl-mk-tile-ic")+(l>1?`${l}`:"");let c=e.online?_("now"):pe(e.ts,r),p=t("button",{type:"button",class:`dl-mk place${e.online?" online":""}`,style:e.online?null:`--dl-mk-fade:${Math.max(.4,1-.6*(r-e.ts)/(30*86400)).toFixed(2)}`,"aria-label":e.city?m(N_(l,"%s device in %s, %s","%s devices in %s, %s"),V(l),e.city,c):m(N_(l,"%s device in an unknown city, %s","%s devices in an unknown city, %s"),V(l),c)},[d,t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",t("span",{class:"dl-mk-when"},c)])]);return p.addEventListener("click",u=>{u.stopPropagation(),this.openPopup(e,o,p)}),p}deviceMarker(e,o,s,r){let a=s?.devices.find(p=>p.id===e.points[0].device)?.kind??"other",i=t("span",{class:"dl-mk-tile"}),l=t("span",{class:"dl-mk-label below"}),d=t("button",{type:"button",class:"dl-mk place step"},[i,l]);d.addEventListener("click",p=>{p.stopPropagation(),this.openPopup(e,o,d)});let c=et(e);return this.places.set(c,{el:d,tile:i,label:l,when:null,g:e,n:r,kind:a}),this.paintPlace(c,!1),d}paintPlace(e,o){let s=this.places.get(e);if(!s)return;let r=this.replaying,a=r?r.active===e:s.g.online,i=s.el.classList.contains("online"),l=s.g.city||s.g.cc||"?";s.el.classList.toggle("online",a),s.el.classList.toggle("faded",!!r&&!a),s.tile.classList.toggle("sm",!a),a||!s.n?s.tile.innerHTML=_t(s.kind,"dl-mk-tile-ic"):s.tile.textContent=String(s.n),s.when=null,a?(s.when=t("span",{class:`dl-mk-when${r?" inline":""}`},r?r.when:_("now")),s.label.replaceChildren(l,r?" · ":"",s.when)):s.label.replaceChildren(`${l} · ${s.g.online?_("now"):pe(s.g.ts,this.data.now)}`);let d=a?r?r.when:_("now"):s.g.online?_("now"):pe(s.g.ts,this.data.now);s.el.setAttribute("aria-label",`${s.n?`${s.n}: `:""}${s.g.city||_("an unknown city")}, ${d}`),o&&a&&!i&&(s.el.classList.remove("arrive"),s.el.offsetWidth,s.el.classList.add("arrive"),setTimeout(()=>s.el.classList.remove("arrive"),500))}replay(e,o=!0){let s=this.replaying;if(this.replaying=e,s&&e&&s.active===e.active){let r=e.active?this.places.get(e.active):null;r?.when&&(r.when.textContent=e.when);return}for(let r of this.places.keys())r!==e?.active&&this.paintPlace(r,o);e?.active&&this.paintPlace(e.active,o),this.declutter(),setTimeout(()=>this.declutter(),320)}hoverPlace(e){for(let[o,s]of this.places)s.el.classList.toggle("hl",o===e)}band(e,o){if(this.bandDots=[],this.map&&e&&o){let s=ir(e,o),r=s.map(c=>this.map.project(c)),a=[0];for(let c=1;ca[d]?(p-a[d])/(a[d+1]-a[d]):0,v=[s[d][0]+(s[d+1][0]-s[d][0])*u,s[d][1]+(s[d+1][1]-s[d][1])*u];this.bandDots.push({type:"Feature",properties:{pos:c/l},geometry:{type:"Point",coordinates:v}})}}this.map?.getLayer("dl-band")&&(this.map.setPaintProperty("dl-band","circle-opacity",0),this.map.getSource("dl-band").setData({type:"FeatureCollection",features:this.bandDots}))}bandAt(e){this.map?.getLayer("dl-band")&&this.map.setPaintProperty("dl-band","circle-opacity",Xs(e))}focus(e){this.focused=e;for(let i of this.people)i.el.classList.toggle("dim",!!e&&i.person!==e),i.el.classList.toggle("hl",i.person===e);let o=e?["case",["==",["get","person"],e],.85,.15]:.85;for(let i of["dl-arc-live","dl-arc-recent"])this.map?.getLayer(i)&&this.map.setPaintProperty(i,"line-opacity",o);if(this.card.classList.toggle("on",!!e),!e||!this.data)return;let s=this.data,r=s.people.find(i=>i.id===e),a=_o(s,this.range).filter(i=>i.person===e).sort((i,l)=>Number(l.online)-Number(i.online)||l.ts-i.ts);dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},r?.name??e),` · ${W(a.length,"%s device","%s devices")}`]),...a.map(i=>t("div",{class:"dl-map-card-row"},[t("span",{},r?.devices.find(l=>l.id===i.device)?.name??_("Device")),t("span",{class:"dl-faint"},`${i.city||i.cc||"?"} · ${i.online?_("now"):pe(i.ts,s.now)}`)]))])}fit(e,o=!1){if(!e.length)return;let s=(p,u)=>{let v=Math.PI/180,M=(u[1]-p[1])*v,x=(u[0]-p[0])*v,h=Math.sin(M/2)**2+Math.cos(p[1]*v)*Math.cos(u[1]*v)*Math.sin(x/2)**2;return 12742*Math.asin(Math.sqrt(h))},r=[e.reduce((p,u)=>p+u[0],0)/e.length,e.reduce((p,u)=>p+u[1],0)/e.length],a=e;if(e.length>=5){let p=[...e].sort((u,v)=>s(r,u)-s(r,v));a=p.slice(0,Math.ceil(p.length*.9))}let i=new this.gl.LngLatBounds(a[0],a[0]);a.forEach(p=>i.extend(p));let l=this.el.clientHeight||380,d=!!this.data?.person,c={padding:{top:this.data?.device?Math.min(56,l/4):Math.min(60,l/5),bottom:d?Math.min(52,l/4):Math.min(40,l/8),left:48,right:48},maxZoom:this.data?.person?11:12};o?this.glide(this.map.cameraForBounds(i,c)?.zoom??null,()=>this.map.fitBounds(i,{...c,duration:1200})):this.map.fitBounds(i,{...c,duration:0})}glide(e,o){this.targetZoom=e,this.declutter(),this.map.once("moveend",()=>{this.targetZoom=null,this.declutter()}),o()}openPopup(e,o,s){let r=this.data,a=[e.city,e.cc||e.country].filter(Boolean).join(", "),i=[...new Set(e.points.map(b=>b.person))],l=i.length===1?r.people.find(b=>b.id===i[0])?.name:void 0,d=e.points.sort((b,k)=>Number(k.online)-Number(b.online)||k.ts-b.ts).map(b=>{let k=r.people.find(I=>I.id===b.person),y=k?.devices.find(I=>I.id===b.device);return t("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(b.person,b.device)},[t("span",{class:`dl-pop-dot${b.online?" on":""}`}),t("span",{class:"dl-pop-name"},[t("b",{},k?.name??b.person),` · ${y?.name??_("device")}`]),t("span",{class:"dl-faint dl-nowrap"},b.online?_("now"):pe(b.ts,r.now))])}),c=t("div",{class:"dl-pop"},[t("div",{class:"dl-pop-head"},[t("span",{class:"dl-pop-net"},g("globe")),t("div",{class:"dl-stack"},[t("strong",{},e.org||_("Unknown network")),t("span",{class:"dl-faint"},[e.asn?`AS${e.asn} · `:"",a?`${a} · ${_("approximate")}`:_("approximate location")])])]),t("div",{class:"dl-pop-list"},d),i.length===1?t("div",{class:"dl-pop-actions"},[t("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(i[0])},l?m(_("Open %s"),l):_("Open person"))]):""]);this.zoomInTo(this.nearby(o),!0),this.dropCard();let p=t("div",{class:"dl-root dl-popcard",role:"dialog"},[t("span",{class:"dl-popcard-tip"}),c]);document.body.appendChild(p);let u=this.el,v=s?.querySelector(".dl-mk-av, .dl-mk-tile")??s??null,M=()=>{if(!v)return;let b=v.getBoundingClientRect(),k=u.getBoundingClientRect(),y=b.left+b.width/2,I=b.top+b.height/2;p.classList.toggle("away",yk.right||Ik.bottom);let w=p.offsetWidth,f=p.offsetHeight,T=b.top-f-12>=8||b.top>window.innerHeight-b.bottom,C=Math.min(Math.max(8,y-w/2),window.innerWidth-w-8);p.classList.toggle("above",T),p.classList.toggle("below",!T),p.style.left=`${C}px`,p.style.top=`${T?b.top-f-12:b.bottom+12}px`,p.style.setProperty("--tip-x",`${y-C}px`)},x=b=>{b.target?.closest(".dl-popcard, .maplibregl-marker")||this.closePopup(!0)},h=b=>{b.key==="Escape"&&this.closePopup()},S=b=>{b.target instanceof Element&&b.target.closest(".dl-popcard")||this.closePopup()},z=()=>this.closePopup();this.map.on("move",M),window.addEventListener("scroll",S,{capture:!0,passive:!0}),window.addEventListener("resize",M),document.addEventListener("pointerdown",x,!0),document.addEventListener("keydown",h);let E=Ee(z);window.addEventListener("pagehide",z),this.popup={card:p,off:()=>{this.map?.off("move",M),window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",M),document.removeEventListener("pointerdown",x,!0),document.removeEventListener("keydown",h),E(),window.removeEventListener("pagehide",z)}};let $=window.setInterval(()=>{if(this.popup?.card!==p)return clearInterval($);(!u.isConnected||!u.getClientRects().length)&&this.dropCard()},400);M()}};function Wi(n,e=6){let o=n.map(s=>({x:s.x,y:s.y}));for(let s=0;s<16;s++){let r=!1;for(let a=0;a[s.x-n[r].x,s.y-n[r].y])}function Gi(n,e){let o=new Map,s=e?[[e.lon,e.lat]]:[],r=a=>s.some(i=>Tn(a,i)<1.3);for(let a of[...n].sort((i,l)=>i.key>>12)/1048575),d=(i&4095)/4096*2*Math.PI,c=[a.lon,a.lat];for(let p=0;p<24;p++){let u=d+p*2.39996,v=Math.min(8,l+p*.25);if(c=[a.lon+v*Math.sin(u)/(111.32*Math.cos(a.lat*Math.PI/180)),a.lat+v*Math.cos(u)/111.32],!r(c))break}s.push(c),o.set(a.key,c)}return o}function qi(n){let e=2166136261;for(let o=0;o>>0}function lr(n){return{key:n.el.dataset.key??"",who:n.who??_("Someone"),where:n.where??"",online:!!n.g?.online,at:n.at,badge:n.el.querySelector(".dl-mk-badge")?.innerHTML??"",g:n.g}}function dr(n,e,o,s=!1){let r=e.length>3,a=()=>[...n.children].filter(x=>!x.classList.contains("out")),i=new Map(a().map(x=>[x,x.getBoundingClientRect().left])),l=n.getBoundingClientRect().width,d=new Map;n.querySelectorAll(".dl-mk-face:not(.out)").forEach(x=>d.set(x.dataset.key??"",x));let c=n.querySelector(".dl-mk-more:not(.out)"),p=x=>{Object.assign(x.style,{position:"absolute",left:`${x.offsetLeft}px`,top:`${x.offsetTop}px`,transform:""}),x.classList.add("out"),setTimeout(()=>x.remove(),200)},u=[];for(let x of e.slice(0,r?2:3)){let h=d.get(x.key);if(d.delete(x.key),!h){let E=t("button",{type:"button",class:`dl-mk-face${s?"":" in"}`,"data-key":x.key},[t("span",{class:"dl-mk-av"},Oe(x.who)),t("span",{class:"dl-mk-badge"})]);E.addEventListener("animationend",()=>E.classList.remove("in"),{once:!0}),h=E}let S=h,z=S.querySelector(".dl-mk-badge");z.innerHTML!==x.badge&&(z.innerHTML=x.badge),S.title=`${x.who} · ${x.where}`,S.setAttribute("aria-label",`${x.who}, ${x.where}`),S.classList.toggle("on",x.online),S.onclick=E=>{E.stopPropagation(),o.click(x,S)},S.onmouseenter=()=>o.hover(x),S.onmouseleave=()=>o.hover(null),u.push(S)}for(let x of d.values())p(x);if(r){if(!c){c=t("span",{class:`dl-mk-more${s?"":" in"}`});let x=c;x.addEventListener("animationend",()=>x.classList.remove("in"),{once:!0})}c.textContent=`+${e.length-2}`,u.push(c)}else c&&p(c);let v=null;for(let x of u)(v?v.nextElementSibling:n.firstElementChild)!==x&&(v?v.after(x):n.prepend(x)),v=x;for(let x of u){let h=i.get(x);if(h==null)continue;let S=h-x.getBoundingClientRect().left;Math.abs(S)<.5||(x.style.transition="none",x.style.transform=`translateX(${S}px)`,x.offsetWidth,x.style.transition="",x.style.transform="")}n.style.width="";let M=n.getBoundingClientRect().width;if(l&&Math.abs(M-l)>.5){n.style.width=`${l}px`,n.offsetWidth,n.style.width=`${M}px`;let x=()=>{n.style.width="",n.removeEventListener("transitionend",x)};n.addEventListener("transitionend",x),setTimeout(x,400)}}function Tn(n,e){let o=Math.PI/180,s=Math.sin((e[1]-n[1])*o/2)**2+Math.cos(n[1]*o)*Math.cos(e[1]*o)*Math.sin((e[0]-n[0])*o/2)**2;return 12742*Math.asin(Math.min(1,Math.sqrt(s)))}function Fi(n,e,o){let s=n.querySelector(":scope > .dl-mk-ptr"),r=Math.hypot(e,o);if(r<1){s?.remove();return}s||(s=t("span",{class:"dl-mk-ptr"},[t("i",{class:"line"}),t("i",{class:"spot"})]),n.prepend(s));let a=s.firstElementChild,i=s.lastElementChild;a.style.width=`${r}px`,a.style.transform=`rotate(${Math.atan2(-o,-e)}rad)`,i.style.transform=`translate(${-e}px, ${-o}px)`}function It(n,e,o=!0){let s=[["online",_("Online now")],["24h",_("24h")],["7d",_("7 days")],["30d",_("30 days")]],r=t("div",{class:"dl-seg",role:"tablist"});for(let[a,i]of s)a==="online"&&!o||r.appendChild(t("button",{type:"button",role:"tab",class:a===n?"on":"","data-v":a,click:()=>{r.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===a)),e(a)}},i));return r}var cr={"24h":86400,"7d":7*86400,"30d":30*86400},Lo=(n,e)=>`${(n/e*100).toFixed(3)}%`,Sn=class{constructor(e,o,s){this.map=e;this.range=o;this.el=t("div",{class:"dl-dplaces"});this.controls=t("div",{class:"dl-map-replay"});this.pending=null;this.rows=new Map;this.st=[];this.steps=[];this.total=0;this.ms=0;this.stepI=-1;this.on=!1;this.playing=!1;this.raf=0;this.last=0;this.endTimer=0;this.play=t("button",{type:"button",class:"dl-map-btn"});this.chip=t("span",{class:"dl-map-chip"});this.stop=t("button",{type:"button",class:"dl-map-btn",title:_("Back to now"),"aria-label":_("Back to now")},g("x"));this.reduced=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;this.data=s,this.play.addEventListener("click",()=>this.toggle()),this.stop.addEventListener("click",()=>this.end()),this.paint()}mapData(){let e=this.data;return{geo:e.geo,people:[e.person],now:e.now,person:e.person.id,device:e.device.id}}update(e){let o={...this.pending??this.data,...e};if(this.on){this.pending=o;return}this.data=o,this.map.update(this.mapData()),this.paint()}setRange(e){this.end(),this.range=e,this.map.setRange(e),this.paint()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.endTimer)}paint(){let e=this.data,o=cr[this.range],s=e.now-o,r=Gs(Ws(e.events??[],e.device.id,e.now,e.device.online,e.device.handshake),e.geo.points,e.device.id,s),a=qs(r);this.st=Fs(r);let i=Co(this.mapData(),this.range),l=r.length>0;this.el.classList.toggle("strips",l),this.el.classList.toggle("can-replay",this.st.length>1),this.rows.clear(),dom.content(this.el,i.length?[...i.map(d=>{let c=et(d),p=a.get(c),u=l?t("div",{class:`dl-dplace-strip${d.online?" live":""}`},r.filter(M=>M.key===c).map(M=>t("i",{style:`left:${Lo(M.from-s,o)};width:${Lo(M.to-M.from,o)}`}))):"",v=t("div",{class:"dl-dplace-row"},[t("span",{class:`dl-dplace-n${d.online?" live":""}`},d.online?g(e.device.kind):String(d.n)),t("span",{class:"dl-row-main dl-stack"},[t("span",{},[d.city||d.cc||_("Unknown city"),d.org?t("span",{class:"dl-muted"},` · ${d.org}`):""]),t("span",{class:"dl-faint"},[t("span",{class:"dl-mono"},d.ip),p!=null?` · ${m(_("%s%% of the time"),p>0&&p<.005?"<1":Math.round(p*100))}`:""])]),t("span",{class:d.online?"dl-dplace-now":"dl-faint dl-nowrap"},d.online?_("now"):pe(d.ts,e.now)),u]);if(v.addEventListener("mouseenter",()=>this.map.hoverPlace(c)),v.addEventListener("mouseleave",()=>this.map.hoverPlace(null)),u){let M=x=>{let h=u.getBoundingClientRect();this.seek(s+o*Math.min(1,Math.max(0,(x.clientX-h.left)/h.width)))};u.addEventListener("pointerdown",x=>{u.setPointerCapture(x.pointerId),M(x)}),u.addEventListener("pointermove",x=>x.buttons&&M(x))}return this.rows.set(c,v),v}),l?t("div",{class:"dl-dplace-axis"},er(this.range,e.now).map(([d,c])=>t("span",{style:`left:${(d*100).toFixed(2)}%`},c))):""]:t("div",{class:"dl-sub"},_("No locations in this period."))),this.paintControls()}paintControls(){dom.content(this.play,g(this.playing?"pause":"play")),this.play.title=this.playing?_("Pause","replay"):_("Replay this period"),this.play.setAttribute("aria-label",this.play.title),dom.content(this.controls,this.on?[this.play,this.chip,this.stop]:this.st.length>1?[this.play]:[])}begin(){this.on=!0,{steps:this.steps,total:this.total}=Vs(this.st,this.reduced?400:wo),this.ms=0,this.stepI=-1,this.map.replay({active:null,when:""},!0)}toggle(){if(this.playing){this.playing=!1,cancelAnimationFrame(this.raf),this.paintControls();return}clearTimeout(this.endTimer),(!this.on||this.ms>=this.total)&&this.begin(),this.playing=!0,this.last=performance.now(),this.paintControls(),this.raf=requestAnimationFrame(e=>this.frame(e))}frame(e){if(this.playing){if(this.ms=Math.min(this.total,this.ms+(e-this.last)),this.last=e,this.show(!0),this.msthis.frame(o));return}this.playing=!1,this.paintControls(),this.endTimer=window.setTimeout(()=>this.end(),1500)}}seek(e){this.st.length<2||(clearTimeout(this.endTimer),this.on||this.begin(),this.ms=Js(this.st,this.steps,e),this.stepI=-1,this.show(!1),this.paintControls())}show(e){let o=Ys(this.st,this.steps,this.ms),s=this.st[o.step.k];if(o.step.kind==="move"){let i=this.st[o.step.k-1];o.i!==this.stepI&&(this.map.replay({active:null,when:""},e),this.map.band([i.point.lon,i.point.lat],[s.point.lon,s.point.lat]));let l=Zs(o.q);this.reduced||this.map.bandAt(l),(this.reduced?o.q>=.5:Qs(l))&&this.map.replay({active:s.key,when:Mn(o.t)},e)}else o.i!==this.stepI&&this.map.band(),this.map.replay({active:s.key,when:Mn(o.t)},e);this.stepI=o.i;let r=this.data,a=r.now-cr[this.range];this.el.classList.add("replay"),this.el.style.setProperty("--at",Lo(o.t-a,r.now-a));for(let[i,l]of this.rows)l.classList.toggle("cur",i===s.key);this.chip.textContent=`${tr(o.t,r.now)}, ${Mn(o.t)} · ${s.point.city||s.point.cc||"?"}`}end(){if(cancelAnimationFrame(this.raf),clearTimeout(this.endTimer),!!this.on){this.on=!1,this.playing=!1,this.ms=0,this.stepI=-1,this.map.band(),this.map.replay(null,!1),this.el.classList.remove("replay");for(let e of this.rows.values())e.classList.remove("cur");this.pending?(this.data=this.pending,this.pending=null,this.map.update(this.mapData()),this.paint()):this.paintControls()}}};function Bt(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function ze(n,e){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${e?`&device=${encodeURIComponent(e)}`:""}`}function Ki(n){return n?new Date(n*1e3).toLocaleString(le(),{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function Mo(n,e,o=!1){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("button",{type:"button",class:`dl-kvrow-v copy${o?" dl-mono":""}`,title:_("Copy"),click:()=>xe(e,m(_("%s copied"),n))},[t("span",{},e),g("copy")])])}function Pn(n,e){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("span",{class:"dl-kvrow-v"},e)])}var pr={connect:["ok","plug"],disconnect:["","plug"],roam:["","network"],device_added:["ok","plus"],device_removed:["","trash"],device_keys:["","reset"]};function Vi(n){let e=s=>t("span",{class:"dl-muted"},s),o=Ve(n)==="portal"?_("on the portal"):Ve(n)==="admin"?_("by you"):"";switch(n.type){case"connect":return[...n.detail?oe(_("Connected from %s"),e(n.detail)):[_("Connected")],n.where?e(` · ${n.where}`):""];case"disconnect":return[_("Went offline")];case"roam":return[_("Changed network"),e(` · ${n.detail??""}`)];case"device_added":return o?oe(_("Added %s"),e(o)):[_("Added")];case"device_removed":return o?oe(_("Removed %s"),e(o)):[_("Removed")];default:return o?oe(_("New keys %s"),e(o)):[_("New keys")]}}function Yi(n,e,o){let s=n.filter(r=>r.device===e&&pr[r.type]).reverse().slice(0,12);return s.length?t("div",{class:"dl-dev-log"},s.map(r=>{let[a,i]=pr[r.type],l=new Date(r.ts*1e3);return t("div",{class:`dl-dev-log-row${Ve(r)==="admin"?" dl-ev-by-admin":""}`},[Ve(r)==="admin"?t("span",{class:"dl-ev-tile",title:_("Done by you in LuCI")},g("admin")):t("span",{class:`dl-ev-tile ev ${a}`},g(i)),t("span",{class:"dl-row-main"},Vi(r)),t("span",{class:"dl-faint dl-nowrap",title:l.toLocaleString(le())},pe(r.ts,o))])})):t("div",{class:"dl-sub"},_("No activity yet."))}async function ur(n,e,o){let s=await H.status(1).catch(()=>null),r=s?.people.find(i=>i.id===n),a=r?.devices.find(i=>i.id===e);s&&r&&a&&Ye(r,a,{...o,geo:s.geo,now:s.now,today:We(s.series),core:Rt(s.servers,r.server)})}async function Ye(n,e,o){let s=await K(()=>H.deviceConfig(e.id));if(!s)return;let r=o.core??Ge(null),a=e,i=n,l=o.geo,d=o.now,c=o.today??Fe(new Date),p=await r.connectBlock(s,e.kind==="phone"||e.kind==="tablet"?"qr":"file"),u=t("div",{class:"dl-drawer-title"}),v=t("div",{}),M=t("div",{}),x=t("div",{},t("div",{class:"dl-sub"},_("Loading…"))),h=[],S=se=>{h=se.filter(j=>j.device===a.id),dom.content(x,Yi(se,a.id,d)),b?.update({events:se})},z=async(se=!1)=>{let j=o.events?.();if(j&&!se)return S(j);let J=await H.events(2e3,n.id).catch(()=>null);J&&S(J.events)},E="30d",$=null,b=null,k=()=>{dom.content(u,[t("span",{class:`dl-dcard-ic${a.online?" on":""}`},g(a.kind)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h3",{},a.name),N([g("edit")],()=>w(),"neutral",{title:_("Rename"),class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),t("span",{class:"dl-sub"},`${i.name} · ${at(a.kind)}`)])]);let se=a.spark.map(([J,ie])=>J+ie),j=se.reduce((J,ie)=>J+ie,0);dom.content(v,t("div",{class:"dl-dstats"},[t("div",{class:"dl-dstats-cell wide"},[t("span",{class:"dl-metric-label"},_("Status")),pn(a,d,_("Waiting for the first connection"),i)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},_("This month")),t("b",{},re(a.month[0]+a.month[1])),t("span",{class:"dl-sub dl-mono"},`↓ ${re(a.month[1])} ↑ ${re(a.month[0])}`)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},_("Last 7 days")),t("b",{},re(j)),$s(se,120,22,c)])])),dom.content(M,t("div",{class:"dl-kv2"},[Mo(_("Tunnel address"),a.address),a.hostname&&i.access!=="internet"?Mo(_("Local address"),a.hostname):"",a.endpoint&&!l?.points.some(J=>J.device===a.id&&J.ip===a.endpoint)?Pn(_("Client IP"),a.endpoint):"",Pn(_("Total"),t("span",{class:"dl-kv-act"},[`↓ ${re(a.total[1])} · ↑ ${re(a.total[0])}`,t("button",{type:"button",class:"dl-linkbtn danger",click:()=>zt("device",a.id,a.name,()=>setTimeout(I,300))},_("Reset"))])),Pn(_("Added"),`${Ki(a.created)} · ${a.created_by==="portal"?_("from the portal"):_("by you")}`),s.amnezia.client_pub_key?Mo(_("Public key"),s.amnezia.client_pub_key):Pn(_("Public key"),"—")])),dom.content(f,[N([g(a.disabled?"play":"pause")," ",a.disabled?_("Enable"):_("Disable")],async()=>{await K(()=>H.deviceUpdate(a.id,void 0,!a.disabled),a.disabled?_("Device enabled"):_("Device disabled"))&&await I()},"neutral",a.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),N([g("key")," ",_("New keys")],async()=>{if(!await me(_("Generate new keys?"),_("The current configuration on this device stops working until it is imported again."),_("Generate"),!0))return;await K(()=>H.deviceRotate(a.id),_("New keys generated"))&&(o.refresh(),fe.close(),await ur(i.id,a.id,o))}),t("span",{class:"dl-spacer"}),N([g("trash")," ",_("Remove")],async()=>{await me(m(_("Remove %s?"),a.name),_("The device is disconnected immediately and its configuration stops working."),_("Remove"),!0)&&await K(()=>H.deviceDelete(a.id),_("Device removed"))&&(fe.close(),o.refresh())},"negative")])},y=async()=>{let se=await H.status(1).catch(()=>null),j=se?.people.find(ie=>ie.id===i.id),J=j?.devices.find(ie=>ie.id===a.id);!se||!j||!J||(i=j,a=J,l=se.geo,d=se.now,c=We(se.series),k(),b?.update({geo:se.geo,now:se.now,person:i,device:a}))},I=async()=>{await y(),o.refresh()},w=()=>{let se=t("input",{type:"text",class:"cbi-input-text",value:a.name,maxlength:48}),j=i.devices.filter(ie=>ie.id!==a.id).map(ie=>ie.name),J=Me(_("Name"),se,()=>Ne(se.value,j,_("Shown in the portal and in the app.")));de(m(_("Rename %s"),a.name),[J],[ue()," ",N(_("Save"),async()=>{let ie=J.help();if(ie.bad){q(ie.text,"warning");return}await K(()=>H.deviceUpdate(a.id,se.value,void 0),_("Renamed"))&&(ce(),await I())},"positive")]),setTimeout(()=>se.select(),50)},f=t("div",{class:"dl-drawer-actions"}),T=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},_("Connect","section"))]),a.config_stale?bt(_("This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")):"",p]),C=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},_("Activity")),t("div",{class:"dl-dsec-actions"},[t("button",{type:"button",class:"dl-linkbtn",click:()=>Ze({people:[i]},h,"csv",a.id)},_("Export")),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>lt(m(_("Clear %s's activity"),a.name),m(_("Removes events about %s."),a.name),{device:a.id},()=>{z(!0),o.refresh()})},_("Clear")),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},_("All activity"))])]),x]),D=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},t("h4",{},_("Details","section"))),M]),F="";if(l?.enabled){$=new dt({openPerson:j=>location.href=ze(j),openDevice:(j,J)=>location.href=ze(j,J)},E,220);let se=b=new Sn($,E,{geo:l,now:d??Date.now()/1e3,person:i,device:a,events:o.events?.()??null});F=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},_("Locations")),It(E,j=>{E=j,se.setRange(j)},!1)]),t("div",{class:"dl-dmap"},[$.el,se.controls]),se.el])}let Y=!a.handshake||a.config_stale,ee=t("div",{class:"dl-stack gap16"},Y?[v,T,D,F,C]:[v,D,F,C,T]);z();let B=()=>{y(),z()},Q=Ln(B),ne=window.setInterval(B,3e4),fe=os(u,ee,f,()=>{clearInterval(ne),Q(),b?.destroy(),$?.destroy()});k(),$&&b&&requestAnimationFrame(()=>b&&$?.mount(b.mapData()))}function mr(n,e,o,s){let r=s.core??Ge(null),a=()=>K(()=>H.deviceConfig(o.id)),i=[{label:_("Show QR code"),icon:g("qr"),run:async()=>{let l=await a();l&&de(`${o.name} · ${_("QR code")}`,t("div",{class:"dl-qr-pane"},[hn(r.qrText(l)),t("span",{class:"dl-sub"},go(l)?_("Scan with AmneziaVPN or any WireGuard app on the device."):_("Scan with AmneziaVPN or AmneziaWG on the device."))]),ue(_("Close")))}},{label:r.file.label,icon:g("download"),run:async()=>{let l=await a();if(!l)return;let d=r.file.make(l);Ae(d.name,d.text,"application/octet-stream")}},r.appKey?{label:r.appKey.label,icon:g("copy"),run:async()=>{let l=await a();l&&xe(await r.appKey.make(l),_("Key copied"))}}:null,null,{label:_("Rename"),icon:g("edit"),run:()=>Ye(e,o,s)},{label:_("New keys"),icon:g("key"),run:async()=>{await me(_("Generate new keys?"),_("The current configuration on this device stops working until it is imported again."),_("Generate"),!0)&&await K(()=>H.deviceRotate(o.id),_("New keys generated"))&&s.refresh()}},{label:o.disabled?_("Enable"):_("Disable"),icon:g(o.disabled?"play":"pause"),warn:!o.disabled,run:async()=>{await K(()=>H.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?_("Device enabled"):_("Device disabled"))&&s.refresh()}},{label:_("Delete"),icon:g("trash"),danger:!0,run:async()=>{await me(m(_("Remove %s?"),o.name),_("The device is disconnected immediately and its configuration stops working."),_("Remove"),!0)&&await K(()=>H.deviceDelete(o.id),_("Device removed"))&&s.refresh()}}];Te(n,i)}function ct(n,e){let o=n.devices.map(c=>c.name),s=c=>{let p=at(c),u=1,v=p;for(;o.some(M=>M.toLowerCase()===v.toLowerCase());)v=`${p} ${++u}`;return v},r="phone",a=t("input",{type:"text",class:"cbi-input-text",placeholder:s(r),maxlength:48}),i=Me(_("Name"),a,()=>a.value.trim()?Ne(a.value,o,_("Shown in the portal and in the app.")):{text:m(_("Named after its type: %s."),s(r)),bad:!1}),l=t("div",{class:"dl-kinds",role:"radiogroup","aria-label":_("Type")},Xo.map(c=>t("button",{type:"button",role:"radio",class:c===r?"on":"","aria-checked":c===r?"true":"false","data-kind":c,click:()=>{r=c,l.querySelectorAll("button").forEach(p=>{let u=p.dataset.kind===c;p.classList.toggle("on",u),p.setAttribute("aria-checked",u?"true":"false")}),a.placeholder=s(c),i.refresh()}},[g(c),t("span",{},at(c))]))),d=n.devices.length>=n.device_limit;de(m(_("Add a device for %s"),n.name),[d?t("p",{class:"dl-hint"},m(N_(n.device_limit,"%s already has %s of %s device. As admin you can still add one.","%s already has %s of %s devices. As admin you can still add one."),n.name,V(n.devices.length),V(n.device_limit))):"",t("div",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},_("Type")),l]),i],[ue()," ",N(_("Add device"),async()=>{let c=i.help();if(c.bad){q(c.text,"warning");return}let p=a.value.trim()||s(r),u=await K(()=>H.deviceCreate(n.id,p,r));u&&(ce(),q(m(_("%s added"),p),"success",3e3),e.refresh(),await ur(n.id,u.id,e))},"positive")]),setTimeout(()=>a.focus(),50)}var tt=1080,en=1512,Je=96,Ji="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Zi="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Xt=n=>n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]);function Qi(n,e,o){let s=new URL(o),r=s.pathname.slice(1),a=m(_("Hi, %s"),n.name),i=Math.min(92,Math.floor((tt-2*Je)/(.58*a.length))),l=tt-2*Je,d=392,c=40,p=mn(o,2).replace("`${S}`;return``+u(Je+82,Je+42,36,"#a3a3a3",Xt(e))+u(Je,276,i,"#ffffff",Xt(a),'font-weight="600"')+u(Je,340,40,"#8a8a8a",Xt(m(_("Scan to connect to %s"),e)))+``+p+`${Xt(r)}`+u(tt/2,d+l+156,34,"#737373",Xt(s.host),'text-anchor="middle"')+""}async function Xi(n){let e=new Image;e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await e.decode();let o=document.createElement("canvas");return o.width=tt,o.height=en,o.getContext("2d").drawImage(e,0,0,tt,en),new Promise((s,r)=>o.toBlob(a=>a?s(a):r(new Error(_("Could not draw the card"))),"image/png"))}async function hr(n){let e=await K(()=>H.personLinks(n));return e?e.link?{link:e.link,links:e.links??[]}:(q(_("The personal portal is off. Turn it on in Settings."),"warning"),null):null}async function $n(n){let e=await hr(n);e&&await xe(e.link,_("Personal link copied"))}async function tn(n,e,o={}){let s=n.link,r=n.links;if(s===void 0){let h=await hr(n.id);if(!h)return;s=h.link,r=h.links}if(!s){q(_("The personal portal is off. Turn it on in Settings."),"warning");return}let a=s,i=await K(()=>Xi(Qi(n,e,a)));if(!i)return;let l=new File([i],`${n.id}-invite.png`,{type:"image/png"}),d=URL.createObjectURL(i),c=navigator,p=!!c.canShare?.({files:[l]}),u=!p&&typeof c.share=="function"&&(c.canShare?.({url:a})??!0),v=()=>{URL.revokeObjectURL(d),ce()},M=async h=>{try{await c.share(h)}catch{}},x=p?N([g("link")," ",_("Share card")],()=>M({files:[l],title:m(_("Invite %s"),n.name)}),"positive"):u?N([g("link")," ",_("Share link")],()=>M({url:a,title:m(_("Invite %s"),n.name),text:_("Your personal VPN link")}),"positive"):N([g("download")," ",_("Download card")],()=>Ae(l.name,i),"positive");de(o.title??m(_("Invite %s"),n.name),t("div",{class:"dl-invite"},[t("img",{src:d,alt:m(_("Invite card for %s"),n.name)}),t("div",{class:"dl-invite-side"},[t("p",{class:"dl-muted"},o.lead??m(_("Send %s the card or the link. They open it, add their devices and connect - no account needed."),n.name)),t("button",{type:"button",class:"dl-invite-link",title:_("Copy link"),click:()=>xe(a,_("Personal link copied"))},[t("span",{},a.replace(/^https:\/\//,"")),g("copy")]),...(r??[]).filter(h=>h!==a).map(h=>t("button",{type:"button",class:"dl-invite-link alt",title:_("Copy this link"),click:()=>xe(h,_("Link copied"))},[t("span",{},h.replace(/^https?:\/\//,"")),t("span",{class:`dl-pill ${h.startsWith("http:")?"warn":""}`},h.startsWith("http:")?"HTTP":_("Also")),g("copy")])),t("ol",{class:"dl-invite-steps"},[t("li",{},oe(_("Install %s on the device"),t("b",{},"AmneziaVPN"))),t("li",{},_("Open the link or scan the code")),t("li",{},_("Add the device and connect"))]),t("div",{class:"dl-invite-actions"},[x,N([g("copy")," ",_("Copy link")],()=>xe(a,_("Personal link copied")))])])]),[t("button",{class:"cbi-button cbi-button-neutral",click:v},_("Done"))],"wide")}function nn(n,e){let o=n.servers.find(d=>d.id===e)??n.servers[0],s=n.people.filter(d=>d.server===o.id),r=new Set(s.map(d=>d.id)),a=s.flatMap(d=>d.devices),i=d=>s.reduce((c,p)=>{let u=d(p);return[c[0]+u[0],c[1]+u[1]]},[0,0]),l=o.series?.[o.series.length-1];return{...n,servers:[o],people:s,series:o.series??n.series,events:n.events.filter(d=>d.person?r.has(d.person):!0),geo:{...n.geo,points:n.geo.points.filter(d=>r.has(d.person))},totals:{people:s.length,devices:a.length,online:a.filter(d=>d.online).length,active:s.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:i(d=>d.month)}}}var fr=3,Eo=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(e){return e{let v=e.next(),M=null;try{M=await n.fetch(u),o>=fr&&q(_("The router answers again."),"success",3e3),o=0}catch{return++o===fr&&q(_("The router is not answering: what you see may be out of date."),"warning",8e3),null}return M==null||!e.take(v)?null:(n.apply(M,p),M)},r=(p=!1)=>s(p,!1),a=()=>document.visibilityState==="visible",i=()=>a()&&(n.active?.()??!0)?s(!0,!1):Promise.resolve(null);poll.add(i,n.every);let l=n.live?Ln(()=>void(a()&&(n.active?.()??!0)&&s(!0,!0))):null,d=()=>{poll.remove(i),l?.(),c()},c=Ee(d);return{refresh:r,claim:()=>e.claim(),stop:d}}function Ot(n){let e=document.activeElement;return!!n&&!!e&&e!==document.body&&n.contains(e)}function De(n,e,o=!1){return o&&Ot(n)?!1:(dom.content(n,e),!0)}function gr(n,e){let o=n,s=[{v:"internet",ic:"globe",text:_("Browse the internet through your router. No access to devices at home.")},{v:"lan",ic:"home",text:_("Reach devices at home (NAS, printer, cameras). Internet stays on their own connection.")},{v:"both",ic:"shield",text:_("Home devices and the internet, all through your router.")}],r=t("div",{class:"dl-choices"},s.map(a=>t("button",{type:"button",class:`dl-choice${a.v===o?" selected":""}`,"data-v":a.v,click:()=>{o=a.v,r.querySelectorAll(".dl-choice").forEach(i=>i.classList.toggle("selected",i.dataset.v===a.v)),e?.(a.v)}},[t("span",{class:"dl-choice-title"},[g(a.ic),vt(a.v)]),t("span",{class:"dl-choice-text"},a.text)])));return{el:r,get:()=>o}}function To(n){try{return localStorage.getItem(n)}catch{return null}}function So(n,e){try{localStorage.setItem(n,e)}catch{}}function el(n){let e=n.devices.length,o=Math.max(1,n.device_limit,e),s=Math.min(160,o*22+(o-1)*3);return t("div",{class:"dl-slotbar",title:m(N_(n.device_limit,"%s of %s device","%s of %s devices"),e,n.device_limit)},[t("span",{class:"dl-slotbar-segs",style:`width: ${s}px`},Array.from({length:o},(r,a)=>t("i",{class:a>=n.device_limit?"over":an.state==="server_off"?n.paused:!["active","quota","expired"].includes(n.state),Po=n=>n.state==="server_off"?n.paused:n.state!=="active",br=n=>Po(n)?n.state==="server_off"?"paused":n.state:null;function tl(n,e){let o=st(n.expires,e);return n.state==="quota"||n.state==="expired"||rt(n,o)||!!n.quota_limit&&n.quota_used>=n.quota_limit*.9}function xr(n,e){return Mt(n&&so(n,e)>=0?n:e,1)}var wr=n=>n.people.map(e=>e.id).sort().join(" "),yr=!1,yt=class{constructor(){this.list=t("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(e=>e===(new URLSearchParams(location.search).get("filter")??To("dl.people.filter")))??"all";this.sort=["seen","name","usage"].find(e=>e===To("dl.people.sort"))??"seen";this.query="";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return H.status(30)}scope(e){return this.serverId?nn(e,this.serverId):e}embed(e,o){return this.serverId=o,this.render(e)}person(e){return this.st.people.find(o=>o.id===e)}get today(){return We(this.st.series)}deviceOpts(e){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:Rt(this.st.servers,e.server)}}take(e,o){let s=this.scope(e),r=wr(s)!==wr(this.st);this.st=s,r?this.rebuild():(this.paintCards(o),this.decorate(o))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let e=await H.status(30).catch(()=>null);e&&(this.st=this.scope(e),this.rebuild())}rebuild(){let e=new Map;for(let s of Array.from(this.list.children))s.dataset.sid&&e.set(s.dataset.sid,s);let o=this.st.people.map(s=>{let r=e.get(s.id)??t("div",{class:"dl-card",role:"listitem","data-sid":s.id});return this.renderCard(r,s.id)});dom.content(this.list,o.length?o:t("div",{class:"dl-plist-none"},this.st.servers.length?_("No people yet. Add someone and send them their personal link."):_("Set up the server first, then add people."))),this.decorate()}paintCards(e=!1){for(let o of this.st.people){let s=this.card(o.id);s&&!(e&&Ot(s))&&this.renderCard(s,o.id)}}card(e){return this.list.querySelector(`[data-sid="${CSS.escape(e)}"]`)}render(e){let o=this.scope(e);this.st=o;let s=this,r=t("select",{class:"dl-select","aria-label":_("Sort"),change:d=>{s.sort=d.target.value,So("dl.people.sort",s.sort),s.decorate()}},[t("option",{value:"seen",selected:s.sort==="seen"?"selected":null},_("Last seen","sort")),t("option",{value:"name",selected:s.sort==="name"?"selected":null},_("Name","sort")),t("option",{value:"usage",selected:s.sort==="usage"?"selected":null},_("Usage","sort"))]),a=t("input",{type:"search",class:"cbi-input-text dl-people-find",placeholder:_("Find…"),"aria-label":_("Find a person or device"),hidden:o.people.length>8?null:"hidden",input:d=>{s.query=d.target.value.trim().toLowerCase(),s.decorate()}}),i=d=>{let c=d.target;d.key==="/"&&!a.hidden&&!["INPUT","TEXTAREA","SELECT"].includes(c?.tagName)&&!c?.isContentEditable&&(d.preventDefault(),a.focus())};document.addEventListener("keydown",i),Ee(()=>document.removeEventListener("keydown",i));let l=t("div",{class:"dl-root"},[s.serverId?"":t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},_("People")),t("span",{class:"dl-muted dl-people-count"},this.countText())]),o.servers.length?N([g("plus"),` ${_("Add person")}`],()=>s.openCreate(),"add"):""]),o.servers.length?"":t("div",{class:"alert-message warning"},oe(_("No server yet. %s before adding people."),t("a",{href:L.url("admin/network/dawnline/server")},_("Run the setup wizard")))),t("div",{class:"dl-toolbar"},[t("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),t("div",{class:"dl-toolbar-end"},[a,r,s.serverId?N([g("plus"),` ${_("Add person")}`],()=>s.openCreate(),"add"):""])]),this.list]);return this.el=l,this.rebuild(),this.poller??(this.poller=pt({fetch:()=>H.status(30),every:30,live:!0,active:()=>!!s.el?.isConnected,apply:(d,c)=>s.take(d,c)})),!yr&&new URLSearchParams(location.search).get("add")&&(yr=!0,setTimeout(()=>s.openCreate(),100)),Promise.resolve(l)}countText(){let e=this.st.totals;return[W(e.people,"%s person","%s people"),W(e.devices,"%s device","%s devices"),m(_("%s online"),V(e.online))].join(" · ")}decorate(e=!1){let o=this.el?.querySelector(".dl-people-count");o&&(o.textContent=this.countText());let s=this.st.people,r=this.today,a=h=>tl(h,r),i={all:s.length,online:s.filter(h=>h.online>0).length,attention:s.filter(a).length,paused:s.filter(h=>vr(h)).length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(e&&Ot(l))){let h={all:_("All"),online:_("Online"),attention:_("Needs attention"),paused:_("Paused")};dom.content(l,Object.keys(h).map(S=>t("button",{type:"button",role:"tab",class:S===this.filter?"on":"",click:()=>{this.filter=S,So("dl.people.filter",S),this.decorate()}},[h[S],t("b",{class:S==="attention"&&i[S]?"warn":""},String(i[S]))])))}let d=this.query,c=h=>[h.name,h.note??"",...h.devices.flatMap(S=>[S.name,S.address,S.hostname,S.endpoint])].join(" ").toLowerCase(),p=h=>!(this.filter==="online"&&!h.online||this.filter==="attention"&&!a(h)||this.filter==="paused"&&!vr(h)||d&&!c(h).includes(d)),u=h=>br(h)==="paused"?2:Po(h)?1:0,v=[...s].sort((h,S)=>u(h)-u(S)||(this.sort==="name"?h.name.localeCompare(S.name):this.sort==="usage"?S.month[0]+S.month[1]-(h.month[0]+h.month[1]):S.online-h.online||S.last_seen-h.last_seen)),M=0;for(let h of v){let S=this.card(h.id);if(!S)continue;this.list.appendChild(S),S.classList.toggle("dl-off",Po(h));let z=p(h);S.classList.toggle("dl-filtered",!z),z&&M++}let x=this.el?.querySelector(".dl-people-none")??null;s.length&&!M?(x??(x=t("div",{class:"dl-empty dl-people-none"},t("p",{},_("No one here right now.")))),x.previousElementSibling!==this.list&&this.list.after(x)):x?.remove()}async quick(e,o,s){await K(()=>H.personUpdate(e.id,o),s)&&await this.update()}renderCard(e,o){let s=this.person(o);if(!s)return dom.content(e,t("em",{},_("This person was just removed."))),e;let r=this.today,a=st(s.expires,r),i=Math.max(0,s.device_limit-s.devices.length),l=s.has_link??this.st.settings.portal_enabled,d=[],c=br(s);if(s.expires&&c!=="expired"){let x=rt(s,a),h=a!=null&&a<0;d.push(t("span",{class:`dl-pill-ic${h?" bad":x?" warn":""}`,title:m(_("Access ends %s"),$e(s.expires))},[g("calendar"),h?m(_("ended %s"),$e(s.expires)):x?dn(a):m(_("until %s"),$e(s.expires))]))}s.hours&&c!=="hours"&&d.push(t("span",{class:"dl-pill-ic",title:_("Allowed hours")},[g("clock"),s.hours.replace("-","–")]));let p=cn(s.devices).map(x=>t("button",{type:"button",class:`dl-chip${x.disabled?" disabled":""}${x.online?" live":""}`,title:[at(x.kind),x.address,x.online?m(_("online from %s"),x.endpoint):x.handshake?m(_("seen %s"),pe(x.handshake,this.st.now)):""].filter(Boolean).join(" · "),click:h=>{h.preventDefault(),Ye(s,x,this.deviceOpts(s))}},[g(x.kind),t("span",{class:"dl-chip-name"},x.name),!x.handshake&&!x.disabled?t("span",{class:"dl-chip-tag"},_("not set up")):""]));p.push(t("button",{type:"button",class:"dl-chip add",title:i>0?_("Add device"):_("Over the limit: admins can still add"),click:x=>{x.preventDefault(),ct(s,this.deviceOpts(s))}},[g("plus"),_("Add device")]));let u=[];s.expires&&rt(s,a)&&c!=="expired"&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>this.quick(s,{expires:xr(s.expires,r)},_("Extended by 1 month"))},_("Extend 1 month")));let v=Pe("more",_("More"),x=>Te(x.currentTarget,[{label:_("Open"),icon:g("open"),run:()=>{location.href=ze(s.id)}},l?{label:_("Invite card"),icon:g("qr"),run:()=>tn(s,this.st.servers.find(h=>h.id===s.server)?.name??_("Home"))}:null,i>0?{label:_("Add device"),icon:g("plus"),run:()=>ct(s,this.deviceOpts(s))}:null,null,{label:s.paused?_("Resume"):_("Pause"),icon:g(s.paused?"play":"pause"),warn:!s.paused,run:()=>this.togglePause(s)},{label:_("Delete"),icon:g("trash"),danger:!0,run:()=>this.remove(s.id)}].filter((h,S,z)=>h||S>0&&z[S-1])),"neutral","dl-icon-only"),M=t("div",{class:"dl-pcard-actions"},[l?Pe("link",_("Copy link"),()=>$n(s.id),"neutral","dl-icon-only"):"",v]);return dom.content(e,t("div",{class:"dl-pcard"},[t("div",{class:"dl-pcard-main"},[t("div",{class:"dl-pcard-top"},[t("span",{class:`dl-avatar${s.online?" online":""}`},Oe(s.name)),t("div",{class:"dl-pcard-who"},[t("div",{class:"dl-card-head"},[t("a",{class:"dl-card-name",href:ze(s.id)},s.name),ns(s),...d]),el(s)])]),t("div",{class:"dl-chips"},p),u.length?t("div",{class:"dl-fixes"},u):""]),this.usageSide(s,M),c?this.stopStrip(s,c):""])),e}stopStrip(e,o){let s=this.today,r=Mt(`${s.slice(0,8)}01`,1),a=()=>this.quick(e,{bonus_gb:String((e.bonus_gb||0)+10)},_("+10 GB this month")),i={paused:["pause","warn",_("Paused"),_("Devices can’t connect until you resume"),["play",_("Resume"),()=>this.togglePause(e)]],quota:e.quota_period==="month"?["chart","bad",_("Data limit reached"),m(_("Paused until it resets on %s"),$e(r)),["plus",_("+10 GB this month"),a]]:["chart","bad",_("Data limit reached"),_("Paused until the limit is raised"),["edit",_("Change limit"),()=>location.href=ze(e.id)]],expired:["calendar","bad",m(_("Access ended %s"),$e(e.expires)),_("Devices can’t connect"),["calendar",_("Extend 1 month"),()=>this.quick(e,{expires:xr(e.expires,s)},_("Extended by 1 month"))]],hours:["clock","warn",_("Outside allowed hours"),m(_("Access %s (router time)"),e.hours.replace("-","–")),null],no_server:["alert","warn",_("No server"),_("Choose a server on their page"),null]},[l,d,c,p,u]=i[o];return t("div",{class:`dl-pstrip ${d}`},[t("span",{class:`dl-need-ic ${d}`},g(l)),t("span",{class:"dl-pstrip-text"},[t("b",{},c),t("span",{class:"dl-faint"},p)]),u?N([g(u[0]),` ${u[1]}`],u[2]):""])}usageSide(e,o){let s=e.quota_used||e.month[0]+e.month[1],r=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,a=e.devices.reduce((p,u)=>p+(u.spark[u.spark.length-1]??[0,0]).reduce((v,M)=>v+M),0),i=e.rate?.[e.rate.length-1],l=e.online&&i&&this.st.now-i[0]<180,d=t("div",{class:`dl-usebar${r>=100?" bad":r>=90?" warn":""}`});if(e.quota_limit){let p=t("i",{class:"fill"});p.style.width=`${r}%`,d.appendChild(p),we(d,()=>[t("div",{class:"dl-tip-title"},m(_("%s%% used"),V(r,1))),t("div",{class:"dl-muted"},`${m(_("%s of %s"),re(e.quota_used),re(e.quota_limit))} · ${m(_("%s left"),re(Math.max(0,e.quota_limit-e.quota_used)))}`),t("div",{class:"dl-faint"},e.quota_period==="total"?_("In total"):[_("This month"),e.bonus_gb?m(_("includes +%s GB extra"),V(e.bonus_gb)):""].filter(Boolean).join(" · "))])}else{let p=e.devices.map(u=>({d:u,v:u.month[0]+u.month[1]})).filter(u=>u.v>0).sort((u,v)=>v.v-u.v);p.forEach((u,v)=>{let M=t("i",{class:`c${Math.min(v,4)}`});M.style.flexGrow=String(u.v),d.appendChild(M)}),p.length&&we(d,()=>[t("div",{class:"dl-tip-title"},_("This month by device")),...p.map((u,v)=>t("div",{class:"dl-tip-row"},[t("span",{class:`dl-swatch c${Math.min(v,4)}`}),t("span",{},u.d.name),t("b",{},re(u.v))]))])}let c=e.quota_limit?m(_("%s left"),re(Math.max(0,e.quota_limit-e.quota_used))):_("no limit");return t("div",{class:"dl-pside"},[t("div",{class:"dl-pside-top"},[l?t("span",{class:"dl-pside-state live"},_("Online")):t("span",{class:"dl-pside-state"},e.online?_("Online"):e.last_seen?_("Offline"):_("Never connected")),o]),t("div",{class:"dl-use-num"},[t("b",{class:s?"":"dl-faint"},re(s)),t("span",{class:"dl-faint"},e.quota_limit?m(_("of %s"),re(e.quota_limit)):e.quota_period==="total"&&e.quota_gb?_("in total"):_("this month"))]),d,l?t("div",{class:"dl-use-live",title:_("Right now")},[`↓ ${qe(i[2])}`,t("span",{class:"dl-faint"},`↑ ${qe(i[1])}`)]):t("div",{class:"dl-faint dl-pside-foot"},a?`${m(_("today %s"),re(a))} · ${c}`:c)])}async togglePause(e){await K(()=>H.personPause(e.id,!e.paused),m(e.paused?_("%s resumed"):_("%s paused"),e.name))&&await this.refresh()}async remove(e){let o=this.person(e);await me(m(_("Remove %s?"),o?.name??e),W(o?.devices.length??0,"%s device is disconnected immediately and the personal link stops working. Usage history is kept in backups.","All %s devices are disconnected immediately and the personal link stops working. Usage history is kept in backups."),_("Remove"),!0)&&await K(()=>H.personDelete(e),_("Person removed"))&&await this.refresh()}openCreate(){let e=this.st;if(!e.servers.length){q(_("Set up the server first."),"warning");return}let o=t("input",{type:"text",class:"cbi-input-text",placeholder:_("e.g. Myata"),maxlength:48}),s=(()=>{try{return JSON.parse(To("dl.person.last")??"{}")}catch{return{}}})(),r=gr(s.access??"internet"),a=t("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:e.settings.default_device_limit}),i=t("input",{type:"date",class:"cbi-input-text"}),l=t("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:_("Unlimited"),value:s.quota??""}),d=(E,$)=>t("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{i.value=$?Mt(We(e.series),$):"",i.dispatchEvent(new Event("change"))}},E),c=e.servers[0],p=!this.serverId&&e.servers.length>1?t("select",{class:"cbi-input-select"},e.servers.map(E=>t("option",{value:E.id},E.name))):null,u=(E,$,b)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},E),t("div",{class:"cbi-value-field"},[$,b?t("div",{class:"cbi-value-description"},b):""])]),v=We(e.series),M=Me(_("Name","person"),o,()=>Ne(o.value,[],_("Shown in their portal and apps."))),x=Me(_("Devices"),a,()=>vn(a.value)),h=Me(_("End date"),i,()=>vs(i.value,v,st,$e),t("div",{class:"dl-actions"},[i,d(_("1 month"),1),d(_("3 months"),3),d(_("1 year"),12),d(_("None","end date"),0)])),S=Me(_("Monthly data (GB)"),l,()=>bn(l.value));i.addEventListener("change",()=>h.refresh());let z=e.settings.portal_enabled;de(_("Add person"),[M,p?u(_("Server"),p):"",t("div",{class:"cbi-value dl-block"},[t("label",{class:"cbi-value-title"},_("Access")),t("div",{class:"cbi-value-field"},r.el)]),x,h,S],[ue()," ",N(z?_("Create and copy link"):_("Create"),async()=>{let E=je([M,x,h,S]);if(E){q(E,"warning");return}let $=await K(()=>H.personCreate(o.value.trim(),"",p?.value??c.id,r.get(),a.value.trim(),i.value,l.value.trim(),"month"));$&&(So("dl.person.last",JSON.stringify({access:r.get(),quota:l.value.trim()})),$.link&&await xe($.link,_("Personal link copied"),!0),this.showCreated($.id,o.value.trim(),$.link,e.servers.find(b=>b.id===(p?.value??c.id))?.name??c.name),await this.refresh())},"positive")]),setTimeout(()=>o.focus(),50)}showCreated(e,o,s,r){if(s){tn({id:e,name:o,link:s},r,{title:m(_("%s is ready"),o),lead:m(_("Send %s the card or the link. They open it, add their devices and connect - no account needed."),o)});return}let a=this.person(e);de(m(_("%s is ready"),o),[t("p",{},_("Created. Turn on the personal portal in Settings to get a link, or add devices for them here."))],[t("button",{class:"cbi-button cbi-button-neutral",click:ce},_("Done"))," ",t("a",{class:"cbi-button cbi-button-neutral",href:`${L.url("admin/network/dawnline/settings")}?section=portal`},_("Open Settings"))," ",a?N(_("Add device"),()=>{ce(),ct(a,this.deviceOpts(a))},"positive"):""])}};var Dn=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],$o=n=>t("i",{class:"dl-circle-dot",style:`background:${Dn[n?.color??0]??Dn[0]}`}),ut=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function kr(n,e,o){let s=he(n?.name??e.name??"",{placeholder:_("NAS")}),r=he(n?.address??e.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),a=he((n?.ports??e.ports??[]).join(", "),{placeholder:_("All ports, or e.g. 445, 5000"),class:"cbi-input-text dl-mono"}),i=Me(_("Name","circle or service"),s,()=>Ne(s.value,[],_("Shown to people who may reach it."))),l=Me(_("Address"),r,()=>bs(r.value)),d=Me(_("Ports"),a,()=>xs(a.value));de(n?m(_("Edit %s"),n.name):_("Add service"),[i,l,d],[ue()," ",N(_("Save"),async()=>{let c=je([i,l,d]);if(c){q(c,"warning");return}let p=a.value.split(/[ ,]+/).filter(Boolean);await K(()=>H.serviceSet(n?.id??"",s.value,r.value,p),_("Saved"))&&(ce(),o())},"positive")])}function nl(){let n=_("Web"),e=_("Printer");return{_smb:"SMB",_afpovertcp:"AFP",_http:n,_https:n,_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:e,_ipps:e,_printer:e,"_pdl-datastream":e,_airplay:"AirPlay",_raop:"AirPlay",_rfb:_("Screen sharing"),_googlecast:"Cast",_hap:"HomeKit",_rdp:_("Remote desktop"),_ftp:"FTP"}}function ol(n){let e=nl(),o=new Map;for(let s of n.services){let r=e[s.type.split(".")[0]];!r||!s.port||(o.get(r)??o.set(r,new Set).get(r)).add(String(s.port))}return o.size?[...o].map(([s,r])=>[s,[...r].sort((a,i)=>+a-+i)]):[[_("Web"),["80","443"]],["SMB",["445"]],["SSH",["22"]]]}function _r(n,e,o){let s=n,r=null,a=!1,i=null,l=new Set,d=t("div",{class:"dl-list"}),c=t("div",{class:"dl-stack gap8"},t("span",{class:"dl-sub"},_("Looking for devices at home…"))),p=()=>{let h=s.services;dom.content(d,h.length?h.map(S=>t("div",{class:"dl-row"},[g("home"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},S.name),t("span",{class:"dl-mono dl-faint"},`${S.address} · ${S.ports.length?m(_("ports %s"),S.ports.join(", ")):_("all ports")}`)]),N(_("Edit"),()=>kr(S,{},o)),N([g("trash")],async()=>{await me(m(_("Remove %s?"),S.name),_("People limited to this service lose access to it."),_("Remove"),!0)&&await K(()=>H.serviceDelete(S.id),_("Removed"))&&await o()},"neutral",{title:_("Remove"),"aria-label":m(_("Remove %s"),S.name)})])):[t("div",{class:"dl-row dl-muted"},_("No services yet: pick ports of a device below."))])};async function u(h,S){if(!l.has(h.address)){l.add(h.address),M();try{let z=s.services.find($=>$.address===h.address);(S===null?z&&await K(()=>H.serviceDelete(z.id),m(_("%s removed"),z.name)):await K(()=>H.serviceSet(z?.id??"",z?.name??(h.name||h.address),h.address,S),z?m(_("%s updated"),z.name):m(_("%s added"),h.name||h.address)))&&await o()}finally{l.delete(h.address),M()}}}function v(h){let S=s.services.find(k=>k.address===h.address),z=!!S&&!S.ports.length,E=new Set(S?.ports??[]),$=l.has(h.address),b=(k,y,I)=>Vt(k,y,I,{disabled:$?"disabled":null,"aria-busy":$?"true":null});return t("div",{class:"dl-row dl-host"},[g(h.services.some(k=>k.type.startsWith("_ipp")||k.type.startsWith("_printer"))?"file":"computer"),t("div",{class:"dl-host-body"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},h.name||h.address),t("span",{class:"dl-mono dl-faint"},h.address)]),t("div",{class:"dl-chips-row"},[b(_("All ports"),z,()=>u(h,z?null:[])),...ol(h).map(([k,y])=>{let I=!z&&y.every(w=>E.has(w));return b(`${k} ${y.join(", ")}`,I,()=>{let w=new Set(z?[]:E);for(let f of y)I?w.delete(f):w.add(f);u(h,w.size?[...w]:null)})})])])])}function M(){if(a)return dom.content(c,t("span",{class:"dl-sub"},_("Couldn't read the devices at home.")));if(!r)return;let h=r;if(!h.hosts.length)return dom.content(c,t("span",{class:"dl-sub"},_("No devices found in the home network right now.")));let S=t("details",{class:"dl-params",open:i??!s.services.length?"":null},[t("summary",{},[g("chevron"),t("span",{},_("Add from devices at home")),t("span",{class:"dl-pcount"},String(h.hosts.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},h.mdns?_("Ports they announce over Bonjour. Pick what to open, or all ports."):_("Devices that got an address from this router. Pick the ports to open, or all ports.")),t("div",{class:"dl-list"},h.hosts.map(v))])]);S.addEventListener("toggle",()=>i=S.open),dom.content(c,S)}return H.homeHosts(e).then(h=>{r=h,M()}).catch(()=>{a=!0,M()}),p(),{el:t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-iflead"},[t("div",{class:"dl-iflead-row"},[t("b",{},_("Home services")),N([g("plus")," ",_("Add service")],()=>kr(null,{},o))]),t("span",{class:"dl-sub"},_("Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers."))]),d,c]),update(h){s=h,p(),M()}}}function An(n,e,o,s){let r=new Set(n.circles.filter(h=>h.server===e).map(h=>h.color)),a=o?.color??Dn.findIndex((h,S)=>!r.has(S));a<0&&(a=0);let i=he(o?.name??"",{placeholder:_("Family")}),l=n.people.filter(h=>h.server===e).sort((h,S)=>h.name.localeCompare(S.name)),d=new Set(l.filter(h=>o&&h.circle===o.id).map(h=>h.id)),c=t("div",{class:"dl-swatches",role:"radiogroup","aria-label":_("Colour")}),p=()=>dom.content(c,Dn.map((h,S)=>t("button",{type:"button",role:"radio",class:`dl-swatch${S===a?" on":""}`,style:`--sw:${h}`,"aria-checked":S===a?"true":"false","aria-label":m(_("Colour %s"),S+1),click:()=>{a=S,p()}})));p();let u=t("div",{class:"dl-chips-row"},l.map(h=>{let S=h.circle&&h.circle!==o?.id?n.circles.find(z=>z.id===h.circle):void 0;return t("button",{type:"button",class:`dl-chipbtn${d.has(h.id)?" on":""}`,title:ut(h)?S?m(_("Now in %s"),S.name):"":m(_("%s has no home access: their devices aren't reachable anyway"),h.name),click:z=>{d.delete(h.id)||d.add(h.id),z.currentTarget.classList.toggle("on",d.has(h.id))}},[h.name,ut(h)?S?t("b",{},S.name):"":t("b",{},_("internet"))])})),v=(h,S)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},h),t("div",{class:"cbi-value-field"},S)]),M=n.circles.filter(h=>h.server===e&&h.id!==o?.id).map(h=>h.name),x=Me(_("Name","circle or service"),i,()=>ms(i.value,M));de(o?m(_("Edit %s"),o.name):_("New circle"),[x,v(_("Colour"),c),v(_("People"),u),t("p",{class:"dl-sub"},_("Devices of people in one circle reach each other. A person is in one circle at a time."))],[o?N(_("Delete"),async()=>{await K(()=>H.circleDelete(o.id),m(_("%s deleted"),o.name))&&(ce(),s())},"negative"):"",t("span",{class:"dl-spacer"}),ue()," ",N(_("Save"),async()=>{let h=x.help();if(h.bad){q(h.text,"warning");return}await K(()=>H.circleSet(o?.id??"",e,i.value,a,[...d]),_("Saved"))&&(ce(),s())},"positive")],"dl-circle-modal")}function Cr(n,e,o){let s=n.circles.filter(r=>r.server===e);return t("div",{class:"dl-chips-row dl-circles"},[...s.map(r=>{let a=n.people.filter(i=>i.circle===r.id).map(i=>i.name);return t("button",{type:"button",class:"dl-chip",title:m(_("Edit %s"),r.name),click:()=>An(n,e,r,o)},[$o(r),t("b",{},r.name),t("span",{class:"dl-faint"},a.length?a.join(", "):_("nobody yet"))])}),t("button",{type:"button",class:"dl-chip add",title:_("New circle"),"aria-label":_("New circle"),click:()=>An(n,e,null,o)},g("plus"))])}function Do(n,e){let o=n.people.filter(p=>p.server===e.id),s=(p="")=>t("span",{class:"dl-yes"},[g("check"),p]),r=()=>t("span",{class:"dl-faint"},"—"),a=p=>{let u=new Set(p.map(M=>M.access==="lan"&&M.services?.length?"services":M.home_nets?.length?"some":"all"));u.size||u.add("all");let v={all:_("all networks"),some:_("their networks"),services:_("services")};return s([...u].map(M=>v[M]).join(" / "))},i=()=>e.mesh==="off"?r():e.mesh==="circles"?s(_("circle")):s(),l=e.lan_like?_("like home"):_("direct"),d=(p,u,v)=>t("tr",{},[t("td",{},[t("b",{},p),t("div",{class:"dl-sub"},W(u.length,"%s person","%s people"))]),...v.map(M=>t("td",{},M))]),c=p=>o.filter(u=>u.access===p);return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Who reaches what")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},_("From the rules on this server"))]),t("div",{class:"dl-reach-wrap"},t("table",{class:"dl-table dl-reach"},[t("tr",{},["",_("Internet"),_("Home"),_("This router"),_("Each other")].map(p=>t("th",{},p))),d(_("Internet"),c("internet"),[s(l),r(),t("span",{class:"dl-faint"},"DNS"),r()]),d(_("Home"),c("lan"),[t("span",{class:"dl-faint"},_("their own")),a(c("lan")),s(),i()]),d(_("Both"),c("both"),[s(l),a(c("both")),s(),i()])])),t("p",{class:"dl-sub"},_("Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing."))])])}function Lr(n,e){let o=n.people.filter(c=>c.server===e.id).flatMap(c=>c.devices.map(p=>({id:p.id,label:`${c.name} · ${p.name}`}))).sort((c,p)=>c.label.localeCompare(p.label)),s="@addr",r=(c,p)=>{let u=t("select",{class:"cbi-input-select","aria-label":c},[...o.map(h=>t("option",{value:h.id,selected:h.id===p?"selected":null},h.label)),t("option",{value:s,selected:p===s?"selected":null},_("Address"))]),v=he("",{placeholder:c,class:"cbi-input-text dl-mono"}),M=t("div",{class:"dl-check-end"},[u,v]),x=()=>v.hidden=u.value!==s;return u.addEventListener("change",x),x(),{el:M,value:()=>u.value===s?v.value.trim():u.value}},a=r("10.0.1.11",o[0]?.id??s),i=r("10.0.1.20:445",s),l=t("div",{class:"dl-stack gap8"}),d=async()=>{let c=await K(()=>H.accessCheck(a.value(),i.value()));if(!c)return;let p=c.steps.findIndex(u=>!u.ok);dom.content(l,[t("div",{class:`dl-verdict ${c.ok?"ok":"bad"}`},[t("b",{},c.ok?_("Allowed"):_("Blocked")),t("span",{class:"dl-sub"},c.ok?_("Every step lets it through"):m(_("Stops at step %s of %s"),p+1,c.steps.length))]),t("ul",{class:"dl-checks"},c.steps.map(u=>t("li",{},[t("span",{class:`dl-check-icon ${u.ok?"ok":"error"}`},g(u.ok?"check":"x")),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},u.title),u.detail?t("div",{class:"dl-check-detail"},u.detail):""])])))])};return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Check access")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},_("Why something does or does not connect"))]),t("div",{class:"dl-check-form"},[a.el,t("span",{class:"dl-faint"},"→"),i.el,N(_("Check"),d)]),l])])}function Nn(n){return n==="app"?"Dawnline":n==="amneziawg"?"AmneziaWG":n==="packages"||n==="pkgs"?_("System packages"):void 0}function mt(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function Hn(n){return mt(n.action==="check"?`check:${n.component??""}`:n.component??"")}function Mr(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function Er(n,e){return!n?.from&&!n?.to?e:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??e}function Tr(n,e){let o=n.check?.components??{},s=e==="all"?["app","amneziawg","packages"]:[e],r=[],a;for(let l of s){let d=o[l];if(d){if(d.error)return{tone:"warn",text:d.error};l==="packages"&&d.updates?r.push(W(d.updates,"%s system package","%s system packages")):l!=="packages"&&d.update&&d.installed&&d.latest&&(r.push(`${Nn(l)} ${d.latest}`),e!=="all"&&(a=d.latest))}}if(r.length)return{tone:"acc",text:m(_("Update available: %s"),r.join(", ")),update:a};let i=s.length===1?o[s[0]]:null;return i?.status==="dev"?{tone:"acc",text:m(_("Installed version is newer than the release (%s)"),i.latest)}:i?.note?{tone:"warn",text:i.note}:{tone:"ok",text:s.length>1?_("Everything is up to date"):_("Latest version is installed")}}function Sr(n,e,o,s){return e?n.id===e:o&&n.id===o?!1:n.state==="running"||s>0&&n.started>=s}var Ao=n=>new Promise(e=>setTimeout(e,n));async function on(n,e,o){let s=o?Hn(o):mt(n),r=o?o.action==="check":n.startsWith("check"),a=Date.now(),i=t("b",{},Nn(s)??(s==="all"?_("All components"):"Dawnline")),l=t("span",{class:"dl-pill dl-mono"},e.version??""),d=t("span",{class:"dl-pill info",hidden:!0}),c=t("span",{},"0:00"),p=t("pre",{class:"dl-log"},_("Operation started. Waiting for log output…")),u=t("div",{}),v=t("div",{class:"dl-op-actions"}),M=[],x=T=>dom.content(v,T),h=(T=!1)=>ue(_("Close"),T);de(e.title,t("div",{class:"dl-op"},[t("div",{class:"dl-op-head"},[i,e.version?l:"",d,t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-op-timer"},[g("clock"),c])]),t("div",{class:"dl-op-loghead"},[t("b",{},_("Operation log")),Pe("copy",_("Copy log"),()=>xe(M.join(` +`),_("Log copied")))]),p,u]),[v],"wide"),x([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?_("Checking…"):_("Working…"))]);let S=o??null,z=o?.id,E,$=0,b=T=>{z!==T.id&&(z=T.id,e.onJob?.(T))};if(o)e.onJob?.(o);else try{let T=await H.updatesStatus().catch(()=>null);E=T?.job?.id,$=T?.now??0;let C=await H.updatesRun(n);C.job&&C.job.state==="running"&&C.job.id!==E&&(S=C.job,b(C.job))}catch(T){return M=[Ce(T)],p.textContent=M[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[g("alert"),t("span",{},Ce(T))])),x([h(!0)]),q(Ce(T),"error"),null}let k=null,y=0;for(;;){if(await Ao(1e3),k=await H.updatesStatus().catch(()=>null),!k){if(++y>60)break;continue}y=0;let T=k.job;if(!T||!Sr(T,z,E,$)){if(Date.now()-a>15e3)break;continue}if(b(T),S=T,T.log.length){M=T.log;let C=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=M.join(` +`),C&&(p.scrollTop=p.scrollHeight)}if(l.textContent=Er(T,e.version??""),!l.isConnected&&l.textContent&&i.after(l),c.textContent=Mr((T.finished??k.now)-T.started),T.state==="running"){d.hidden=!T.phase,d.textContent=T.phase;continue}break}if(p.scrollTop=p.scrollHeight,d.hidden=!1,!S||S.state==="running")return d.className="dl-pill warn",d.textContent=_("No answer"),dom.content(u,t("div",{class:"dl-comp-status warn"},[g("alert"),t("span",{},_("The router stopped answering. The job may still finish: reopen Components in a minute."))])),x([h()]),e.onDone?.(k),S;if(S.state==="failed")return d.className="dl-pill bad",d.textContent=_("Failed"),dom.content(u,t("div",{class:"dl-comp-status bad"},[g("x"),t("span",{},[t("b",{},(S.error??_("Operation failed")).replace(/\.$/,"")),r?"":`. ${_("Nothing else was changed.")}`])])),x([N(_("Copy log"),()=>xe(M.join(` +`),_("Log copied"))),h(!0)]),q(`${Nn(s)??_("Update","noun")}: ${S.error??_("failed")}`,"error"),e.onDone?.(k),S;if(d.className="dl-pill ok",d.textContent=_("Finished"),r&&k){let T=Tr(k,s);if(dom.content(u,t("div",{class:`dl-comp-status ${T.tone}`},[g(T.tone==="ok"?"check":T.tone==="warn"?"alert":"download"),t("span",{},T.text)])),q(T.text,T.tone==="warn"?"warning":"success"),e.onDone?.(k),T.update&&e.onUpdate){let C=k;x([h(),N(m(_("Update to %s"),T.update),()=>e.onUpdate(C),"positive")])}else x([h()]),T.tone==="ok"&&setTimeout(()=>u.isConnected&&ce(),1200);return S}let I=/^app:(lang:|nolang$)/.exec(S.component??"");if(I){let T=()=>{ui.menu?.flushCache(),location.reload()};return dom.content(u,t("div",{class:"dl-comp-status ok"},[g("check"),t("span",{},[t("b",{},I[1]==="nolang"?_("The translation is removed."):_("The translation is installed."))," ",_("Reloading the page…")])])),x([h(),N(_("Reload now"),T,"positive")]),await Ao(4e3),u.isConnected&&T(),S}if(s==="app"&&S.to){let T=S.to,C=t("span",{},_("Waiting for the router to restart its services…"));dom.content(u,t("div",{class:"dl-comp-status ok"},[g("check"),t("span",{},[t("b",{},m(_("Dawnline %s is installed."),T))," ",C])]));let D=()=>{ui.menu?.flushCache(),location.reload()};x([h(),N(_("Reload now"),D,"positive")]),q(m(_("Dawnline updated to %s"),T),"success",6e3);for(let F=1;F<=30;F++)if(C.textContent=m(_("Waiting for the router to restart its services (%s of 30)…"),F),await Ao(1500),(await H.updatesStatus().catch(()=>null))?.version===T)return C.textContent=_("Services are back. Reloading…"),setTimeout(D,800),S;return C.textContent=_("Services restarted. Reload the page to use the new version."),S}let w=[...S.result?.pkgs?.updated??[],...S.result?.pkgs?.installed??[]],f=s==="pkgs"?w.length?m(_("Updated %s"),w.join(", ")):_("Updated system packages"):s==="amneziawg"?S.to?m(_("AmneziaWG %s is installed"),S.to):_("AmneziaWG is installed"):_("Operation completed");return dom.content(u,t("div",{class:"dl-comp-status ok"},[g("check"),t("span",{},f)])),x([h()]),q(f,"success"),e.onDone?.(k),S}function sl(n){return{https:[_("Install HTTPS for the portal?"),_("Installing HTTPS for the portal")],acme:[_("Install ACME certificates?"),_("Installing ACME certificates")],home:[_("Install the home-like link?"),_("Installing the home-like link")],awg:[_("Install AmneziaWG?"),_("Installing AmneziaWG")]}[n]}async function Pr(n,e,o,s){let[r,a]=sl(e);return!await me(r,o,_("Install"))||(await on(n,{title:a}))?.state!=="done"?!1:(setTimeout(()=>s?.(),4e3),!0)}function zn(n){return Pr("amneziawg:auto","awg",_("Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds."),n)}async function sn(n,e,o){return n==="awg"?zn(o):e.length?Pr(`pkgs:${e.join(",")}`,n,m(_("%s from the OpenWrt feeds. Dawnline sets the rest up when they arrive."),e.join(", ")),o):!0}async function $r(n,e){if(n==="awg")return zn(e);let o=await K(()=>H.updatesStatus());return o?sn(n,o.needs?.[n]??[],e):!1}var rl=()=>[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn",_("VPN & tunnels")],["other",_("Other")]],al={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function No(n){let e=t("b",{},oe(_("add its interface %s to their source interfaces yourself"),t("span",{class:"dl-mono"},n)));return[...oe(_("Off: internet traffic goes straight to the WAN, the fastest way. DNS still goes through this router. Proxies and filters here handle the tunnel only if you %s."),e)," ",t("span",{class:"dl-warn"},_("If the router’s DNS hands out proxy addresses, those sites won’t open without it."))]}function Ho(){return bt(_("Slower: every packet crosses the router twice. On a dual-core router expect up to a third less speed, and lost packets at full load."))}function Dr(n,e,o){let s=n.id,r=e,a=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},_("Loading interfaces…"))))),i,l=!0,d="",c=!0,p=!0,u="all",v=!1,M=_r(r,s,o),x=new Set,h="",S=()=>JSON.stringify([p,l,l?"":d,c,[...x].sort()]),z=()=>i.detected.lan||i.saved.lan||"",E=()=>(l?i.detected.wan||i.saved.wan:d)||"",$=()=>new Map(i.devices.map(B=>[B.name,B])),b=()=>{let B=$();return[...c&&z()?[z()]:[],...[...x].filter(ne=>ne!==z())].filter(ne=>ne!==E()).map(ne=>B.get(ne)??{name:ne,nets:[],missing:!0})},k=(B,Q)=>{i=B,Q&&(l=B.config.auto_wan,d=B.config.wan_device||B.detected.wan||B.saved.wan||"",c=B.config.auto_lan,p=B.config.lan_like,u=B.config.mesh??(B.config.device_mesh?"all":"off"),x=new Set(B.config.lan_devices),h=S()),Y()},y=async B=>{let Q=await H.interfaces(s).catch(ne=>(q(ne.message,"error"),null));Q&&k(Q,B)};function I(B){let Q=c&&B.name===z(),ne=!!B.own||!!B.master||B.name===E()||Q;return Q||x.has(B.name)||!ne&&(B.nets.length>0||!!B.missing)}function w(B){let Q=c&&B.name===z(),ne=B.name===E(),fe=!Q&&x.has(B.name),j=!(!!B.own||!!B.master||ne||Q)&&(B.nets.length>0||fe||!!B.missing),J=(fe||Q)&&!B.zone&&!B.missing,ie=B.missing?_("Not present right now"):B.own?_("This server"):B.master?m(_("Port of %s"),B.master):ne?`${_("Internet")}${B.zone?` · ${m(_("zone %s"),B.zone)}`:""}`:B.nets.length?B.nets.join(", "):_("No IPv4 network"),ve=t("button",{type:"button",class:`dl-if${fe?" sel":""}${Q?" auto":""}${!j&&!fe&&!Q?" off":""}${J?" warn":""}`,"aria-pressed":fe||Q?"true":"false","aria-disabled":j?null:"true",click:()=>{j&&(x.has(B.name)?x.delete(B.name):x.add(B.name),Y())}},[t("span",{class:"dl-if-ic"},g(al[B.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},B.name),t("span",{class:"dl-if-sub"},ie)]),Q?t("span",{class:"dl-if-badge ok"},_("Auto")):fe?t("span",{class:"dl-if-check"},g("check")):""]);return we(ve,()=>[t("div",{class:"dl-tip-title"},B.name),t("div",{class:"dl-muted"},[B.logical?m(_("Interface %s"),B.logical):_("No netifd interface")," · ",B.zone?m(_("zone %s"),B.zone):_("no firewall zone")]),B.members.length?t("div",{class:"dl-muted"},m(_("Ports: %s"),B.members.join(", "))):"",B.nets.length?t("div",{class:"dl-mono"},B.nets.join(", ")):"",J?t("div",{class:"dl-warn"},_("Not in a firewall zone: the firewall rejects this traffic.")):"",B.master?t("div",{class:"dl-muted"},m(_("Choose %s to include it."),B.master)):""]),ve}function f(){let B=i.like_home;return!p||!i.config.lan_like||!n.enabled?"":!i.needs?.length&&B.active&&B.bridged?"ok":"warn"}function T(){let B=i.like_home;return p?i.needs?.length?[t("span",{class:"dl-warn"},m(_("Needs %s."),new Intl.ListFormat(le(),{type:"conjunction"}).format(i.needs)))," ",_("Until they are installed, internet traffic goes straight to the WAN.")]:i.config.lan_like?n.enabled?B.active&&B.bridged?oe(_("Internet traffic enters %s as %s, so whatever handles home traffic (proxies, filters, DNS) handles it too."),t("span",{class:"dl-mono"},B.dev??""),t("span",{class:"dl-mono"},B.address??"")):[t("span",{class:"dl-warn"},m(_("Not working: %s"),B.error??_("the link is down")))," ",_("Internet traffic goes straight to the WAN for now.")]:[_("Internet traffic enters the router from your LAN, so whatever handles home traffic (proxies, filters, DNS) handles it too.")]:[_("Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on.")]:No(n.ifname)}let C=B=>({off:_("Devices of different people never reach each other; a person's own devices don't either."),all:_("Devices of people with home access reach each other, like home devices do. Internet-only people never."),circles:_("Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never.")})[B];function D(B,Q,ne,fe,se="",j){return t("div",{class:j?"dl-setrow head":"dl-setrow"},[t("div",{class:"dl-lh-main"},[t("span",{class:`dl-need-ic ${se}`},g(B)),t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},Q),t("span",{class:"dl-sub"},ne),j??""])]),t("div",{class:"dl-setrow-ctl"},fe)])}let F=(B,Q)=>{let ne=fe=>t("span",{class:"dl-mono"},fe);return B?t("span",{},[" ",...Q&&Q!==B?oe(_("Now: %s, was %s."),ne(B),ne(Q)):oe(_("Now: %s."),ne(B))]):t("span",{},[" ",...Q?oe(_("Not found now: using %s."),ne(Q)):[_("Not found.")]])};function Y(){let B=t("select",{class:"cbi-input-select","aria-label":_("Internet interface"),change:A=>{d=A.target.value,Y()}},i.devices.filter(A=>!A.own&&!A.master&&A.zone&&!A.missing).map(A=>t("option",{value:A.name,selected:A.name===d?"selected":null},`${A.name} · ${m(_("zone %s"),A.zone)}`))),ne=b().flatMap(A=>A.nets.map(G=>[G,A.name])),fe=JSON.parse(S()),se=JSON.parse(h),j=(...A)=>A.some(G=>JSON.stringify(fe[G])!==JSON.stringify(se[G])),J=j(0,1,2),ie=j(3,4),ve=A=>N(_("Save"),async()=>{let G=await K(()=>H.serverInterfaces(s,l,l?"":d,c,[...x],p,u!=="off",u),_("Access saved"));G&&(k(G,!0),G.nets_changed&&G.lan_only&&q(W(G.lan_only,"%s person has Home-only access: their devices need the configuration again to reach the new networks.","%s people have Home-only access: their devices need the configuration again to reach the new networks."),"warning",1e4))},"positive",{disabled:!A}),R=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Internet")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},_("People with Internet or Both"))]),D("home",_("Internet like a home device"),T(),[p&&i.needs?.length?N(_("Install"),()=>sn("home",i.needs,()=>y(!1)),"positive"):"",ye(p,_("Internet like a home device"),A=>{p=A,Y()})],f(),p?Ho():void 0),D("globe",_("Auto-detect WAN"),[_("The interface with the default route: the server port opens there and Internet access leaves through it."),F(i.detected.wan,i.saved.wan)],[l?"":B,ye(l,_("Auto-detect WAN"),A=>{l=A,Y()})])]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},p?[_("Internet like a home device"),E()?[" · ",...oe(_("leaves through %s"),t("span",{class:"dl-mono"},E()))]:""]:E()?oe(_("Internet straight to %s"),t("span",{class:"dl-mono"},E())):_("No WAN found")),ve(J)])]),O=Qe([["off",_("Off")],["all",_("Everyone")],["circles",_("Circles")]],u,{label:_("Devices reach each other"),cls:"sm",optimistic:!1,onChange:async A=>{let G={off:_("Off"),all:_("Everyone"),circles:_("Circles")}[A];await K(()=>H.serverUpdate(s,{mesh:A}),m(_("Devices reach each other: %s"),G))&&(u=A,i.config.mesh=A,Y(),await o())}}),P=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Home network")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},_("People with Home or Both")),N([g("reset")," ",_("Rescan")],()=>y(!1),"neutral",{title:_("Read the interfaces again")})]),D("network",_("Networks"),_("Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it."),"","",ee()),D("link",_("Devices reach each other"),C(u),O,"",u==="circles"?Cr(r,s,o):void 0),M.el]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub dl-if-summary"},ne.length?oe(_("Home access reaches %s"),t("span",{},ne.flatMap(([A,G],te)=>[te?", ":"",t("span",{class:"dl-mono"},A),` (${G})`]))):_("No home network: Home access reaches nothing but this router.")),ve(ie)])]),U=window.scrollY;a.style.minHeight=`${a.offsetHeight}px`,dom.content(a,[R,P]),a.style.minHeight="",window.scrollTo({top:U})}function ee(){let B=i.devices.filter(I),Q=i.devices.filter(ne=>!I(ne));return t("div",{class:"dl-stack gap8 dl-netpick"},[B.length?t("div",{class:"dl-ifgrid"},B.map(w)):t("span",{class:"dl-warn"},_("No home network: Home access reaches nothing but this router.")),t("label",{class:"dl-boxrow"},[t("span",{class:"dl-stack"},[t("span",{},_("Auto-detect LAN")),t("span",{class:"dl-sub"},[_("Adds the LAN this router uses."),F(i.detected.lan,i.saved.lan)])]),ye(c,_("Auto-detect LAN"),ne=>{c=ne,Y()})]),Q.length?t("details",{class:"dl-params",open:v?"":null,toggle:ne=>v=ne.currentTarget.open},[t("summary",{},[g("chevron"),t("span",{},_("Other interfaces")),t("span",{class:"dl-pcount"},String(Q.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},_("The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network.")),...rl().map(([ne,fe])=>{let se=Q.filter(j=>j.category===ne);return se.length?t("div",{class:"dl-ifgroup"},[t("h4",{},fe),t("div",{class:"dl-ifgrid"},se.map(w))]):""})])]):""])}return y(!0),{el:a,update(B){r=B,M.update(B),i&&Y()}}}var il={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",expiring:"warn",expired_kept:"",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},ll={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",expiring:"calendar",expired_kept:"calendar"};function dl(n,e){return e.device?n.people.flatMap(s=>s.devices).find(s=>s.id===e.device)?.kind??e.dkind??"other":ll[e.type]??"activity"}var cl=n=>/^\d{4}-\d{2}-\d{2}$/.test(n)?Be(n):n;function zo(n,e){let o=n.people.find(h=>h.id===e.person),s=o?.name??e.pname??e.person??"",r=o?.devices.find(h=>h.id===e.device)?.name??e.dname??"",a=h=>t("b",{},h),i=h=>t("span",{class:"dl-muted"},h),l=h=>t("span",{class:"dl-mono"},h),d=h=>e.hosts?.[h]?[t("span",{class:"dl-ev-host"},[t("b",{},e.hosts[h]),t("span",{class:"dl-faint"},` (${h})`)])]:[l(h)],c=(h,...S)=>oe(h,...S).map(z=>typeof z=="string"?i(z):z),p=(h,...S)=>{let z=_("You");return h.startsWith(`${z} `)?[t("span",{class:"dl-you"},z),...c(h.slice(z.length),...S)]:c(h,...S)},u=a(r?`${s} · ${r}`:s),v=Ls(e),M=a(v||r||_("a device")),x=Ve(e);if(x==="admin")switch(e.type){case"device_added":return p(_("You added device %s for %s"),M,a(s));case"device_removed":return p(_("You removed device %s from %s"),M,a(s));case"paused":return p(_("You paused person %s"),a(s));case"resumed":return p(_("You resumed person %s"),a(s));case"device_changed":{let h=a(r||_("a device"));return v.startsWith("renamed from ")?[...p(_("You renamed device %s of %s"),h,a(s)),i(` · ${m(_("was %s"),v.slice(13))}`)]:v==="turned off"?p(_("You turned off device %s of %s"),h,a(s)):v==="turned on"?p(_("You turned on device %s of %s"),h,a(s)):[...p(_("You changed device %s of %s"),h,a(s)),...v?[i(` · ${v}`)]:[]]}case"device_keys":return[...p(_("You issued new keys for device %s of %s"),M,a(s)),i(` · ${_("it needs its new configuration")}`)];case"link_changed":return[...p(_("You issued a new link for person %s"),a(s)),i(` · ${_("the old link stopped working")}`)]}switch(e.type){case"connect":return[...e.detail?c(_("Device %s connected from %s"),u,t("span",{},d(e.detail))):c(_("Device %s connected"),u),...e.where?[i(` · ${e.where}`)]:[]];case"disconnect":return c(_("Device %s went offline"),u);case"roam":return c(_("Device %s changed network %s"),u,t("span",{},(e.detail??"").split(" → ").flatMap((h,S)=>S?[i(" → "),...d(h)]:d(h))));case"device_added":return c(x==="portal"?_("Person %s added device %s on their portal"):_("Person %s added device %s"),a(s),M);case"device_removed":return c(x==="portal"?_("Person %s removed device %s on their portal"):_("Person %s removed device %s"),a(s),M);case"device_keys":return c(_("Person %s issued new keys for device %s on their portal"),a(s),M);case"person_added":return p(_("You added person %s"),a(e.detail??s));case"person_removed":return p(_("You removed person %s"),a(e.detail??s));case"person_changed":return[...p(_("You changed person %s"),a(s)),...v?[i(` · ${Es(v)}`)]:[]];case"expiring":{let h=Ms(e.detail??"");return h!=null?c(N_(h,"Person %s’s access ends in %s day","Person %s’s access ends in %s days"),a(s),i(V(h))):c(_("Person %s’s access ends in a few days"),a(s))}case"expired_kept":return c(_("Person %s’s end date passed (%s) · access kept"),a(s),i(cl(e.detail??"")));case"paused":return e.detail?c(_("Person %s paused - %s"),a(s),i(mo(e.detail))):c(_("Person %s paused"),a(s));case"resumed":return e.detail&&e.detail!=="active"?c(_("Person %s resumed - %s"),a(s),i(mo(e.detail))):c(_("Person %s resumed"),a(s));case"portal_blocked":return c(_("%s blocked %s for 15 min after too many wrong codes"),t("b",{class:"dl-sys-src"},_("Personal portal")),e.detail==="all Cloudflare visitors"?i(_("all Cloudflare visitors")):l(e.detail??""));case"devices_removed":return c(_("Person %s - all devices removed, end date reached"),a(s));default:return[i(`${e.type}${e.detail?`: ${e.detail}`:""}`)]}}var pl={portal_blocked:["globe","bad"]};function ul(n,e){if(n.servers.length<2||!e.person)return"";let o=n.people.find(r=>r.id===e.person),s=o&&n.servers.find(r=>r.id===o.server);return s?t("span",{class:"dl-ev-srv",title:_("Server")},s.name):""}function ht(n,e,o={}){let s=pl[e.type],r=Ve(e);return t("div",{class:`dl-row${r==="admin"?" dl-ev-by-admin":s?` dl-ev-by-system ${s[1]}`:""}`},[r==="admin"?t("span",{class:"dl-ev-tile",title:_("Done by you in LuCI")},g("admin")):s?t("span",{class:"dl-ev-tile sys"},g(s[0])):t("span",{class:`dl-ev-tile ev ${il[e.type]??""}`},g(dl(n,e))),t("span",{class:"dl-row-main"},zo(n,e)),o.server===!1?"":ul(n,e),t("span",{class:"dl-faint dl-nowrap",title:new Date(e.ts*1e3).toLocaleString(le())},o.time??pe(e.ts,n.now))])}var ml={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},hl={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function fl(n){return{info:_("info"),up:_("up"),down:_("down"),repair:_("repair"),error:_("error")}[n]??n}function gl(n){let e=Ts(n.msg,n.kind,n.who),o=_("You");if(!e)return[t("span",{class:"dl-you"},o),t("span",{class:"dl-muted"},` ${n.msg} `),n.kind?t("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?t("b",{},n.who):""];let s=(e.named?oe(e.text,t("b",{},Ss(n.msg,n.who??""))):[e.text]).map(a=>typeof a=="string"?t("span",{class:"dl-muted"},a):a),r=s[0]?.textContent??"";return r.startsWith(`${o} `)?[t("span",{class:"dl-you"},o),t("span",{class:"dl-muted"},r.slice(o.length)),...s.slice(1)]:s}var Ar=n=>n.split(` +`).map(e=>Nt(e)).join(` +`);function Rn(n,e,o,s){let r=n.by==="admin",a=Nt(n.msg),i=t("div",{class:`dl-row dl-slog-row ${r?"dl-ev-by-admin":`dl-ev-by-system ${ml[n.level]??""}`}${n.detail?" has-detail":""}`},[r?t("span",{class:"dl-ev-tile",title:_("Done by you in LuCI")},g("admin")):t("span",{class:"dl-ev-tile sys",title:fl(n.level)},g(hl[n.src]??"zap")),t("span",{class:"dl-row-main"},r?[...gl(n),n.note?t("span",{class:"dl-muted"},` · ${Ps(n.note)}`):"",n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},g("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},Ar(n.detail)):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?t("span",{class:"dl-ev-kind"},`${_("Server")} `):"",t("b",{class:"dl-sys-src",title:Kt(n.src)},n.who?n.src==="awg"?n.who:Nt(n.who):Kt(n.src)),/^[:,]/.test(a)?"":" ",t("span",{class:"dl-muted"},a),n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},g("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},Ar(n.detail)):""]),t("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString(le())},s)]);return n.detail&&i.addEventListener("click",l=>{l.target.closest("pre")||o()}),i}function Nr(n){let e=new Date(n*1e3),o=new Date,s=new Date;if(s.setDate(o.getDate()-1),e.toDateString()===o.toDateString())return _("Today");if(e.toDateString()===s.toDateString())return _("Yesterday");let r=e.toLocaleDateString(le(),{weekday:"long",day:"numeric",month:"long"});return r.charAt(0).toLocaleUpperCase(le())+r.slice(1)}var jt=n=>Et(n).toLocaleDateString(le(),{day:"numeric",month:"short"});function In(n,e,o,s=!1){let r=n.slice(-15),a=r[r.length-1],i=a&&e-a[0]<180,l=i?a[2]:0,d=i?a[1]:0,[c,p]=o,u=200,v=40,M=Math.max(1,...r.map($=>Math.max($[1],$[2]))),x=$=>r.map((b,k)=>`${r.length>1?k/(r.length-1)*u:u},${v-2-b[$]/M*(v-6)}`),h=x(2),S=x(1),z=r.length>1&&!s?St(``):t("div",{class:"dl-speed-wait"},[t("i"),s?"":t("span",{},_("Collecting… 1 point a minute"))]),E=($,b,k,y)=>t("div",{class:"dl-speed-col"},[t("span",{class:"dl-sub"},[t("span",{class:k},b),` ${$}`]),s?t("span",{class:"dl-speed-val off"},"—"):t("span",{class:"dl-speed-val"},qe(y))]);return r.length>1&&!s&&we(z,()=>{let $=r[r.length-1];return[t("div",{class:"dl-tip-title"},new Date($[0]*1e3).toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"})),t("div",{},`↓ ${qe($[2])} · ↑ ${qe($[1])}`)]}),t("div",{class:"dl-bento-tile"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},_("Speed now")),s?"":t("span",{class:"dl-sub"},_("last 15 min"))]),t("div",{class:"dl-speed-cols"},[E(_("Download","speed"),"↓","dl-dn",l),E(_("Upload","speed"),"↑","dl-up",d)]),z,t("div",{class:"dl-speed-today"},[t("span",{},oe(_("Today %s"),t("b",{},re(c+p)))),t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${re(p)} `,t("span",{class:"dl-up"},"↑"),` ${re(c)}`])])])}function Bn(n,e){let o=n.slice(-30),s=o.map(d=>d.rx+d.tx),r=Math.max(1,...s),a=s.reduce((d,c)=>d+c,0),i=s.reduce((d,c,p)=>c>s[d]?p:d,0),l=t("div",{class:"dl-bento-bars"},o.map((d,c)=>{let p=s[c],u=t("i",{class:c===o.length-1?"hi":"",style:`height:${Math.max(4,p/r*100)}%`}),v=t("span",{},[u]);return we(v,()=>[t("div",{class:"dl-tip-title"},c===o.length-1?`${_("Today")} · ${jt(d.day)}`:jt(d.day)),t("div",{},re(p)),t("div",{class:"dl-muted dl-mono"},`↓ ${re(d.tx)} ↑ ${re(d.rx)}`)]),v}));return t("div",{class:"dl-bento-tile month"},[t("div",{class:"dl-bento-head"},[t("span",{},[t("span",{class:"dl-metric-label"},_("Last 30 days")),t("b",{class:"dl-bento-total"},re(a))]),s[i]>0?t("span",{class:"dl-sub"},`${m(_("peak %s"),re(s[i]))} · ${jt(o[i].day)}`):""]),o.length?l:t("p",{class:"dl-muted"},_("No traffic yet.")),t("div",{class:"dl-bento-head"},[t("span",{class:"dl-sub"},o.length?jt(o[0].day):""),t("span",{class:"dl-sub"},e),t("span",{class:"dl-sub"},_("today"))])])}function Hr(n){let e=n.slice(-30),o=e.map(r=>r.rx+r.tx),s=Math.max(1,...o);return t("div",{class:"dl-dbars"},e.map((r,a)=>{let i=t("i",{class:`${o[a]?"":"zero"}${a===e.length-1?" hi":""}`});i.style.height=`${Math.max(8,o[a]/s*100)}%`;let l=t("span",{},[i]);return we(l,()=>[t("div",{class:"dl-tip-title"},a===e.length-1?`${_("Today")} · ${jt(r.day)}`:jt(r.day)),t("div",{},re(o[a]))]),l}))}function zr(n){return{apply:_("Repair"),sync:_("Reload devices"),restart:_("Restart service"),netrestart:_("Restart network"),updates:_("Open Components")}[n]??_("Fix")}async function On(n){return n==="netrestart"&&!await me(_("Restart the network?"),_("Every interface restarts. Connections drop for a few seconds."),_("Restart network"))?null:await K(()=>H.healthFix(n),_("Done"))??null}function Ro(n,e,o,s="action"){let r=n.fix;return r?r.startsWith("install:")?N(_("Install"),()=>$r(r.slice(8),o),s):r==="updates"?t("a",{class:`cbi-button cbi-button-${s}`,href:L.url("admin/network/dawnline/updates")},zr(r)):N(zr(r),()=>e(r),s):""}function vl(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="flash"?"download":n==="nft"?"lock":n==="data"?"users":"alert"}function Rr(n,e,o,s=3){let r=n.filter(i=>i.status==="error"||i.status==="warn").sort((i,l)=>i.status===l.status?0:i.status==="error"?-1:1);if(!r.length)return"";let a=r.length-s;return t("div",{class:"dl-list dl-notices"},[...r.slice(0,s).map(i=>it(vl(i.id),i.status==="error"?"bad":"warn",i.problem??i.title,i.detail,Ro(i,e,o,i.status==="error"?"positive":"neutral"))),a>0?t("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[m(_("%s more in Diagnostics"),V(a)),t("span",{class:"dl-spacer"}),"→"]):""])}function bl(n){let e=[],o=(l,d)=>t("a",{href:l},d),s=()=>o(L.url("admin/network/dawnline/diagnostics"),_("Open Diagnostics")),r=We(n.series),a=!!n.awg_state&&!n.awg_state.ok;for(let l of n.servers)l.enabled&&l.blocked?e.push({tone:"bad",text:[l.blocked," ",s()]}):l.enabled&&!l.up&&!a&&e.push({tone:"bad",text:[m(_("Tunnel %s is down."),l.ifname)," ",s()]});for(let l of n.people){let d=()=>o(ze(l.id),l.name);if(l.state==="quota")e.push({tone:"warn",text:oe(_("%s reached the data limit."),d())});else if(l.state==="expired")e.push({tone:"warn",text:oe(_("%s’s access has ended."),d())});else{let c=st(l.expires,r);rt(l,c)?e.push({tone:"",text:oe(_("%s’s access %s."),d(),dn(c))}):c!=null&&c<0&&l.expire_action==="notify"&&e.push({tone:"",text:oe(_("%s’s end date passed (%s) · access kept."),d(),$e(l.expires))}),l.quota_limit&&l.quota_used>=l.quota_limit*.9&&e.push({tone:"",text:oe(_("%s has used 90% of the data limit."),d())})}}let i=n.people.flatMap(l=>l.devices.filter(d=>d.config_stale).map(d=>[l,d]));i.length&&e.push({tone:"warn",text:i.length===1?oe(_("%s needs its configuration again."),o(ze(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)):[W(i.length,"%s device needs its configuration again (networks or DNS changed).","%s devices need their configuration again (networks or DNS changed).")]});for(let l of n.servers)n.wan&&At(l.endpoint)&&l.endpoint!==n.wan&&e.push({tone:"warn",text:[m(_("Public address changed: %s still gives devices %s, the router is %s now."),l.name,l.endpoint,n.wan)," ",t("button",{type:"button",class:"dl-fix",click:async d=>{let c=d.currentTarget;c.disabled=!0,await K(()=>H.serverUpdate(l.id,{endpoint:n.wan}),m(_("%s uses %s now - devices need their configuration again"),l.name,n.wan)),c.disabled=!1}},_("Use the new address"))," ",_("A DDNS name would follow it by itself.")]});return n.servers.some(l=>l.lan_like)&&n.like_home.error&&e.push({tone:"warn",text:[m(_("Internet through the LAN is off: %s"),n.like_home.error)," ",o(L.url("admin/network/dawnline/diagnostics"),_("Details"))]}),!n.settings.portal_enabled&&!n.people.length&&e.push({tone:"",text:[_("The personal portal is off.")," ",o(L.url("admin/network/dawnline/settings"),_("Turn on"))]}),e}var jn=class{constructor(e,o){this.srvId=e;this.go=o;this.el=t("div",{class:"dl-srvov"});this.map=null;this.mapOn=null;this.range="online";this.parts={};this.healthAt=0}mount(e){this.st=nn(e,this.srvId);for(let o of["health","bento","map","side","activity"])this.parts[o]=t("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.parts.map,t("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(e,o=!1){this.st=nn(e,this.srvId),this.paint(o),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let e=await H.health().catch(()=>null);if(!e)return;let o=()=>void this.loadHealth(),s=async r=>{await On(r)&&(o(),r==="netrestart"&&setTimeout(o,5e3))};De(this.parts.health,Rr(e.checks,r=>void s(r),o),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}paintMap(){let e=this.st.geo.enabled;if(e===this.mapOn&&(!e||this.map)){this.map?.update(this.mapData());return}this.mapOn=e,dom.content(this.parts.map,this.mapCard())}mapCard(){let e=this.st,o=t("div",{class:"dl-panel-head pad"},[t("div",{class:"dl-stack"},[t("h3",{},_("Where people connect from")),t("span",{class:"dl-sub"},_("City-level, from the client IP · locations cached on the router"))]),t("span",{class:"dl-spacer"}),It(this.range,l=>{this.range=l,this.map?.setRange(l)})]);if(this.map?.destroy(),this.map=null,!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},oe(_("Locations are off. %s."),t("a",{href:L.url("admin/network/dawnline/settings")},_("Turn them on in Settings"))))]);let s=this.map=new dt({openPerson:l=>location.href=ze(l),openDevice:(l,d)=>location.href=ze(l,d)},this.range),r=Ee(()=>{r(),s.destroy(),this.map===s&&(this.map=null)}),a=t("div",{class:"dl-map-legend"},[t("span",{},[t("i",{class:"line live"}),_("Live tunnel")]),t("span",{},[t("i",{class:"line"}),_("Seen recently")])]),i=t("div",{class:"dl-map-wrap"},[s.el,a]);return requestAnimationFrame(()=>s.mount(this.mapData())),t("div",{class:"dl-panel flush"},[o,i])}paint(e=!1){let o=this.st,s=o.servers[0];this.paintMap(),De(this.parts.bento,t("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Ge(s).overviewTile(s),this.monthTile()]),e);let r=bl(o);De(this.parts.side,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Needs attention")),t("span",{class:"dl-spacer"}),t("a",{href:L.url("admin/network/dawnline/diagnostics")},_("Health"))]),r.length?r.slice(0,8).map(i=>t("div",{class:"dl-attn-item dl-row"},[t("span",{class:`dl-ev-dot ${i.tone}`}),t("span",{},i.text),i.action??""])):t("div",{class:"dl-row dl-muted"},[g("check"),_("All good. Nothing needs you right now.")])]),e);let a=[...o.events].reverse().slice(0,8);De(this.parts.activity,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Activity")),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},_("View all"))]),a.length?a.map(i=>ht(o,i)):t("div",{class:"dl-row dl-muted"},_("Nothing yet. Connections, new devices and pauses appear here."))]),e)}onlineTile(){let e=this.st,o=e.servers[0]?!e.servers[0].enabled:!1,s=12,r=z=>{let[E,$]=z.spark[z.spark.length-1]??[0,0];return E+$},a=z=>e.geo.points.find(E=>E.device===z.id&&E.city)?.city,i=z=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(z.endpoint??""),l=(z,E=!1)=>i(z)?E&&z.endpoint?`LAN · ${z.endpoint}`:"LAN":a(z)??"",d=z=>[...e.events].reverse().find(E=>E.type==="connect"&&E.device===z.id)?.ts??0,c=e.people.map(z=>({p:z,devs:z.devices.filter(E=>E.online).sort((E,$)=>r($)-r(E))})).filter(z=>z.devs.length).sort((z,E)=>E.devs.reduce(($,b)=>$+r(b),0)-z.devs.reduce(($,b)=>$+r(b),0)),p=c.length<=2,u=({p:z,devs:E})=>{let $=E.map(d).filter(Boolean),b=$.length?Math.min(...$):0,k=(z.rate??[]).slice(-15),y=k[k.length-1],I=y&&e.now-y[0]<180?y:null,w=200,f=30,T=Math.max(1,...k.map(ee=>Math.max(ee[1],ee[2]))),C=ee=>k.map((B,Q)=>`${k.length>1?Q/(k.length-1)*w:w},${f-2-B[ee]/T*(f-6)}`),D=k.length>1?St(``):"",F=!I||I[1]<64&&I[2]<64,Y=z.access==="both"?["home","globe"]:z.access==="lan"?["home"]:["globe"];return[t("div",{class:"dl-hc"},[t("div",{class:"dl-hc-head"},[t("span",{class:"dl-onl-av sm"},Oe(z.name)),t("span",{class:"dl-stack"},[t("b",{},z.name),t("span",{class:"dl-hc-since"},b?m(_("online for %s"),ot(Math.max(60,e.now-b))):_("online"))]),t("span",{class:"dl-hc-reach"},Y.map(ee=>t("span",{class:`dl-ibadge ${ee==="home"?"lan":"inet"}`},g(ee))))]),t("div",{class:"dl-hc-speed"},[t("div",{class:"dl-hc-speed-row"},F?[t("span",{class:"dl-faint"},_("Idle right now"))]:[t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${qe(I[2])}`]),t("span",{},[t("span",{class:"dl-up"},"↑"),` ${qe(I[1])}`]),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint"},_("15 min"))]),D]),t("div",{class:"dl-hc-devs"},E.map(ee=>t("span",{class:"dl-hc-dev"},[g(ee.kind),ee.name,l(ee)?[" · ",l(ee,!0)]:""]))),t("div",{class:"dl-hc-foot"},[t("span",{class:"dl-faint"},`${m(_("%s today"),re(E.reduce((ee,B)=>ee+r(B),0)))} · ${m(_("%s this month"),re(z.month[0]+z.month[1]))}`)])])]},v=z=>{let{p:E,devs:$}=z,b=t("span",{class:"dl-onl-dev"},$.length>1?String($.length):g($[0].kind)),k=t("a",{class:`dl-onl-p${p?"":" sm"}`,href:ze(E.id),"aria-label":m(_("%s, online"),E.name)},[t("span",{class:"dl-onl-av"},[Oe(E.name),b]),p?t("span",{class:"dl-onl-name"},E.name):"",p?t("span",{class:"dl-onl-meta"},[...$.slice(0,3).map(y=>g(y.kind)),$.length>3?`+${$.length-3}`:"",l($[0])?t("span",{},[" · ",l($[0])]):""]):""]);return we(k,()=>u(z)),k},M=t("b",{class:`dl-onl-count${c.length?"":" none"}`},String(c.length)),x=c.reduce((z,E)=>z+E.devs.length,0);c.length&&we(M,()=>[`${W(c.length,"%s person","%s people")} · ${W(x,"%s device","%s devices")}`]);let h=c.length>s?c.slice(0,s-1):c,S=e.people.flatMap(z=>z.devices.map(E=>({p:z,d:E}))).filter(z=>z.d.handshake).sort((z,E)=>E.d.handshake-z.d.handshake)[0];return t("div",{class:"dl-bento-tile online"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},_("Online")),M]),c.length?t("div",{class:`dl-onl-row${p?"":" grid"}`},[...h.map(v),c.length>s?t("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:_("Everyone online"),click:z=>{this.go&&(z.preventDefault(),this.go("people","online"))}},[t("span",{class:"dl-onl-av"},`+${c.length-h.length}`)]):""]):t("div",{class:"dl-onl-empty"},[t("span",{},o?_("The server is turned off"):_("Nobody is connected")),S?t("span",{class:"dl-sub"},m(_("Last: %s, %s"),S.p.name,pe(S.d.handshake,e.now))):t("span",{class:"dl-sub"},o?_("Devices connect once it is on"):_("No device has connected yet"))])])}speedTile(){let e=this.st.servers[0];return In(e?.rate??[],this.st.now,this.st.totals.today,e?!e.enabled:!1)}monthTile(){let e=[...this.st.people].map(o=>[o,o.month[0]+o.month[1]]).filter(([,o])=>o>0).sort((o,s)=>s[1]-o[1]).slice(0,2);return Bn(this.st.series,e.length?m(_("Most: %s"),e.map(([o,s])=>`${o.name} ${re(s)}`).join(" · ")):"")}};var Ir=["overview","people","connection","access","awg"],xl=n=>({overview:_("Overview"),people:_("People"),connection:_("Connection"),access:_("Access")})[n],wl={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},Io=(n,e)=>{let o=new URLSearchParams;n&&o.set("server",n),e&&e!=="overview"&&o.set("section",e);let s=o.toString();return`${L.url("admin/network/dawnline/server")}${s?`?${s}`:""}`},rn=class{constructor(){this.noFooter=!0;this.root=t("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=t("div",{});this.headEl=t("div",{});this.secEl=t("div",{});this.bodyEl=t("div",{class:"dl-srvbody"})}async load(){let e=await H.status(31),o=e.servers.length?null:await H.setupDefaults();return[e,o]}render([e,o]){if(this.st=e,!e.servers.length&&o)return this.wizard(o);let s=new URLSearchParams(location.search),r=s.get("section")??"",a=wl[r]??r;return Ir.includes(a)&&(this.section=a),this.srvId=(e.servers.find(i=>i.id===s.get("server"))??e.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller?.stop(),this.poller=pt({fetch:()=>H.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(i,l)=>{i.servers.length&&(this.st=i,this.paintHead(l),this.ov[this.current().id]?.update(i,l))}}),this.root}paintHead(e=!1){De(this.headEl,this.head(this.current()),e),(!e||!Ot(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let e=await H.status(31).catch(()=>null);return e?.servers.length?(this.st=e,this.paintHead(),e):null}current(){return this.st.servers.find(e=>e.id===this.srvId)??this.st.servers[0]}async refresh(){let e=await H.status(31).catch(()=>null);e&&(this.st=e,e.servers.length?this.paint():location.href=Io())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let e=this.current();dom.content(this.tabsEl,t("div",{class:"dl-srvtabs",role:"tablist","aria-label":_("Servers")},[...this.st.servers.map(o=>t("button",{type:"button",role:"tab",class:`dl-srvtab${o.id===e.id?" on":""}`,"aria-selected":o.id===e.id?"true":"false",click:()=>{o.id!==this.srvId&&(this.srvId=o.id,this.paint())}},[t("i",{class:`dot ${o.enabled?o.up?"ok":"bad":"warn"}`}),t("b",{},o.name)])),t("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[g("plus"),_("Add server")])]))}paintSections(){let e=Ge(this.current());dom.content(this.secEl,t("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":_("Server")},Ir.map(o=>t("button",{type:"button",role:"tab","data-section":o,class:o===this.section?"on":"","aria-selected":o===this.section?"true":"false",click:()=>this.showSection(o)},o==="awg"?e.label:xl(o)))))}go(e,o){let s=this.pp[this.current().id];if(o&&s)s.filter=o,s.el&&s.decorate();else if(o){let r=this.pp[this.current().id]=new yt;r.filter=o}this.showSection(e),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let e=[...Object.values(this.ov).map(o=>o.el),...Object.values(this.pp).map(o=>o.el)];for(let o of e)o&&this.bodyEl.contains(o)&&o.remove()}showSection(e){this.section=e,this.secEl.querySelectorAll("[data-section]").forEach(i=>{let l=i.dataset.section===e;i.classList.toggle("on",l),i.setAttribute("aria-selected",l?"true":"false")});let o=this.st,s=this.current(),a={overview:()=>{let i=this.ov[s.id];return i?(i.update(o),i.el):(this.ov[s.id]=new jn(s.id,(l,d)=>this.go(l,d))).mount(o)},people:()=>{var c,p;let i=this.pp[s.id];if(i?.el)return i.update(),i.el;let l=t("div",{},t("p",{class:"dl-muted"},_("Loading people…")));return((c=this.pp)[p=s.id]??(c[p]=new yt)).embed(o,s.id).then(u=>{l.isConnected?dom.content(l,u):l.replaceChildren(u)}).catch(u=>{delete this.pp[s.id],dom.content(l,t("p",{class:"dl-muted"},m(_("Couldn't show people: %s"),Ce(u))))}),l},connection:()=>this.connection(s),access:()=>this.access(s),awg:()=>this.awg(s)}[e]();this.detachKept(),dom.content(this.bodyEl,a)}head(e){let o=(a,i)=>t("span",{class:"dl-addrbar-seg"},[g(a),...i]),s=e.endpoint||"—",r=t("div",{class:"dl-actions"},[e.enabled?"":N([g("play"),` ${_("Turn on")}`],()=>this.save(e,{enabled:"1"},_("Server turned on")),"add")]);return t("div",{class:"dl-srvpagehead"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),t("span",{class:`dl-pill ${e.enabled?e.up?"ok":"bad":"warn"}`},e.enabled?e.up?_("Running"):e.blocked?_("Can’t start"):_("Not running"):_("Turned off")),t("span",{class:"dl-spacer"}),r]),t("div",{class:"dl-addrbar"},[t("button",{type:"button",class:"dl-addrbar-seg main",title:_("Copy address"),click:()=>xe(s,_("Address copied"))},[g("globe"),t("span",{class:"dl-mono"},s),g("copy")]),o(Ge(e).id==="awg"?"amneziawg":"tunnel",[t("span",{class:"dl-mono"},`${Ge(e).label} :${e.port}`)]),e.up?o("clock",[m(_("up %s"),ot(e.uptime))]):""]),e.blocked?bt(e.blocked):""])}async save(e,o,s=_("Saved")){await K(()=>H.serverUpdate(e.id,o),s)&&await this.refresh()}connection(e){let o=he(e.name,{placeholder:_("Home")}),s=he(e.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),r=he(e.dns.join(", "),{placeholder:_("This router (recommended)"),class:"cbi-input-text dl-mono"}),a=this.st.people.filter(M=>M.server===e.id).length,i=N([g(e.enabled?"pause":"play"),` ${e.enabled?_("Turn off"):_("Turn on")}`],async()=>{e.enabled&&!await me(m(_("Turn off %s?"),e.name),W(a,"The tunnel stops and %s person is disconnected until you turn it back on. Nothing is deleted.","The tunnel stops and %s people are disconnected until you turn it back on. Nothing is deleted."),_("Turn off"),!0)||await this.save(e,{enabled:e.enabled?"0":"1"},e.enabled?_("Server turned off"):_("Server turned on"))},e.enabled?"negative":"positive"),l=this.st.settings.portal_host,d=_e(_("Name"),o,()=>Ne(o.value,[],_("Shown to people in their portal and apps."))),c=po(()=>({host:s.value,port:e.port,id:e.id}),(M,x,h)=>H.endpointProbe(M,x,h),()=>p.refresh(),{empty:l?m(_("Empty = the portal’s address (%s)."),l):_("Empty = the portal’s address.")}),p=_e(_("Public address"),s,c.help);s.addEventListener("input",c.schedule),c.schedule();let u=e.reached?m(_("Reached from the internet %s."),pe(e.reached,this.st.now)):_("Never reached from the internet yet - test with a phone on mobile data."),v=_e(_("DNS for devices"),r,()=>hs(r.value,e.address));return t("div",{class:"dl-stack gap16"},[Gt(_("Connection"),[t("p",{class:"dl-muted"},_("The name people see, where devices find the router, and DNS. The port is on AmneziaWG.")),ke("router",_("Server"),_("What people see"),[d]),ke("globe",_("Devices connect to"),_("A DDNS name keeps links working when your IP changes; not through Cloudflare (use a DNS-only name or an IP)"),[p,t("div",{class:`dl-sub ${e.reached?"ok":"warn"}`},u)]),ke("file",_("For every device"),_("Changing it marks devices “Update config” until they import again"),[v])],[t("span"),N(_("Save"),()=>{let M=je([d,p,v]);if(M){q(M,"warning");return}return this.save(e,{name:o.value,endpoint:s.value,dns:r.value})},"positive")]),Gt(_("Danger zone"),[t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},e.enabled?_("Turn off this server"):_("This server is off")),t("span",{class:"dl-sub"},e.enabled?_("Stops the tunnel and disconnects everyone on it. Settings and people are kept."):_("Nobody can connect. Turn it on to bring the tunnel back."))]),t("div",{class:"dl-setrow-ctl"},i)]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},_("Change the tunnel network")),t("span",{class:"dl-sub"},m(_("Devices have %s addresses now. A new range when it clashes with a network you connect to; every device then needs its configuration again."),`${Dt(e.subnet)}.x`))]),t("div",{class:"dl-setrow-ctl"},N([g("edit"),` ${_("Change")}`],()=>this.changeSubnet(e),"negative"))]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},_("Remove server")),t("span",{class:"dl-sub"},W(a,"Removes the tunnel, its firewall rules and %s person with all their devices. A backup is made first.","Removes the tunnel, its firewall rules and %s people with all their devices. A backup is made first."))]),t("div",{class:"dl-setrow-ctl"},N([g("trash"),` ${_("Remove")}`],()=>this.remove(e),"negative"))])],[],"danger")])}access(e){let o=Do(this.st,e),s=Dr(e,this.st,async()=>{let r=await this.refreshStatus();if(!r)return;let a=r.servers.find(l=>l.id===e.id)??e;s.update(r);let i=Do(r,a);o.replaceWith(i),o=i});return t("div",{class:"dl-stack gap16"},[s.el,t("div",{class:"dl-health-cols"},[o,Lr(this.st,e)])])}awg(e){let o={st:this.st,save:(s,r)=>this.save(e,s,r),refresh:()=>this.refresh()};return t("div",{class:"dl-stack gap16"},[Ge(e).settingsCard(o,e)])}async addServer(){let e=await K(()=>H.setupDefaults());e&&dom.content(this.root,this.wizard(e,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async changeSubnet(e){let o=await K(()=>H.serverPorts(e.id));if(!o)return;let s=o.networks??[],r=this.st.people.filter(l=>l.server===e.id).reduce((l,d)=>l+d.devices.length,0),a=he(Dt(e.subnet),{class:"cbi-input-text dl-mono dl-w-range"}),i=_e(_("Address range"),a,()=>lo(a.value,s,""));de(_("Change the tunnel network"),[i,t("p",{class:"dl-muted"},r?W(r,"%s device gets a new address and stops connecting until it imports its configuration again (from their personal link or from you).","%s devices get new addresses and stop connecting until they import their configuration again (from their personal link or from you)."):_("No devices on this server yet: nothing else changes."))],[ue()," ",N(_("Change"),async()=>{let l=i.help();if(l.bad){q(l.text,"warning");return}let d=fn(a.value);if(d===e.subnet){ce();return}await K(()=>H.serverUpdate(e.id,{subnet:d}),_("Tunnel network changed"))&&(ce(),r&&q(_("Devices are marked “Update config” until they import again."),"info",6e3),await this.refresh())},"negative")]),setTimeout(()=>a.select(),50)}async remove(e){let o=this.st.people.filter(s=>s.server===e.id);de(m(_("Remove %s?"),e.name),[t("p",{},W(o.length,"This removes the tunnel, its firewall rules and %s person with all their devices. A backup is made first.","This removes the tunnel, its firewall rules and %s people with all their devices. A backup is made first."))],[ue()," ",N(_("Remove"),async()=>{ce(),await K(()=>H.serverDelete(e.id),_("Server removed"))&&setTimeout(()=>{location.href=Io()},800)},"negative")])}wizard(e,o=!1,s){let r={id:e.id,name:e.name,endpoint:e.endpoint,port:e.port,range:Dt(e.subnet),preset:kn(e.awg),portal:!1,portal_port:e.portal_port||8443,lan_like:!1,lan_zone:e.lan_zone,wan_zone:e.wan_zone},a=0,i=!o&&r.portal_port===r.port,l=()=>/^\d{1,3}(\.\d{1,3}){3}$/.test(r.endpoint),d=()=>qt(r.port,e.udp_taken??[],r.port===4500?`${_("Opened on the WAN firewall automatically.")} ${_("4500 is IPsec’s port: most networks let it through.")}`:_("Opened on the WAN firewall automatically.")),c={ddns:_("From your DDNS name."),cert:_("From your Let’s Encrypt certificate."),wan:_("Your WAN address now - it may change; a DDNS name is better."),portal:_("The portal’s address.")},p=po(()=>({host:r.endpoint,port:r.port}),(C,D,F)=>H.endpointProbe(C,"",F),()=>u?.refresh(),{idle:()=>r.endpoint===e.endpoint&&e.endpoint_from?c[e.endpoint_from]??"":""}),u=null,v=e.wan_kind==="cgnat"||e.wan_kind==="private"?it("alert","warn",e.wan_kind==="cgnat"?_("Your router has no public address (CGNAT)"):m(_("Your router is behind another router (WAN %s)"),e.wan_ip),e.wan_kind==="cgnat"?_("The ISP shares one address: devices can only connect if the ISP gives you a public address or IPv6. Ask them, or use a DDNS name that points at an IPv6 address."):_("Forward the UDP port on the upstream router to this one and use a DDNS name or that router’s public address here."),""):"",M=e.awg_state?.tools&&e.awg_state.handler===!1?bt(_("Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started.")):"",x=()=>lo(r.range,e.networks??[],Dt(e.subnet)),h=()=>gn(r.portal_port,e.tcp_taken??[],l()),S=t("div",{class:"dl-wizard"}),z=(C,D={})=>{let F=he(String(r[C]),D);return F.addEventListener("input",()=>{C==="port"||C==="portal_port"?r[C]=F.value.trim()===""?0:Number(F.value):r[C]=F.value.trim(),C==="port"&&i&&(r.portal_port=r.port),C==="portal_port"&&(i=r.portal_port===r.port)}),F},E=()=>{let C=Ho(),D=ge(_("Through the home network"),ye(r.lan_like,_("Internet like a home device"),ee=>{r.lan_like=ee,F()})," "),F=()=>{dom.content(D.querySelector(".dl-sub"),r.lan_like?_("Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access."):No(e.ifname)),r.lan_like?D.after(C):C.remove()},Y=ke("home",_("Internet like a home device"),_("How devices reach the internet"),[D]);return F(),Y},$={id:"server",title:_("Server"),render:()=>t("div",{class:"dl-wizard-groups"},[t("p",{class:"dl-muted"},o?_("One more server: another port or disguise for networks where the first does not get through, or its own home access rules. People are moved between servers from their page."):_("Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes.")),ke("router",_("Server"),_("What people see"),[_e(_("Name"),z("name"),()=>Ne(r.name,[],_("Shown to people in their portal and apps.")))]),ke("globe",_("Devices connect to"),_("A hostname or IP address of your router on the internet; not through Cloudflare (use a DNS-only name or an IP). IPv6 works too, and is the way out of CGNAT"),[(()=>{let C=z("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"});return u=_e(_("Public address"),C,p.help),C.addEventListener("input",p.schedule),p.schedule(),u})()]),v,M]),check:()=>{let C=Ne(r.name);if(C.bad)return m(_("Name: %s"),C.text);let D=$t(r.endpoint,r.port);return D.bad?m(_("Public address: %s"),D.text):null}},b={id:"awg",title:"AmneziaWG",render:()=>t("div",{class:"dl-wizard-groups"},[ke("globe",_("Listening"),_("Where devices reach AmneziaWG from the internet"),[_e(_("UDP port"),z("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),d)]),ke("network",_("Tunnel network"),_("Addresses devices get inside the tunnel"),[(()=>{let C=z("range",{class:"cbi-input-text dl-w-range dl-mono","aria-label":_("First three numbers of the device addresses")});return _e(_("Device addresses"),C,x,t("span",{class:"dl-suffixed"},[C,t("span",{class:"dl-mono"},".x")]))})()]),ke("shield",_("Disguise"),_("So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard"),[_n(e.awg,r.preset,C=>r.preset=C,void 0,e.awg_state?.tools!==!1)]),o?E():""]),check:()=>{let C=d();if(C.bad)return m(_("UDP port: %s"),C.text);let D=x();return D.bad?m(_("Device addresses: %s"),D.text):null}},k={id:"portal",title:_("Portal"),render:()=>{let C=z("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),D=_e(_("Listening port"),C,h);D.hidden=!r.portal;let F=Qe([["off",_("Off")],["on",_("On")]],r.portal?"on":"off",{label:_("Personal portal"),onChange:Y=>{r.portal=Y==="on",D.hidden=!r.portal}});return t("div",{class:"dl-wizard-groups"},[E(),ke("link",_("Personal portal"),_("A page where each person adds their own devices with their personal link"),[ge(_("Portal"),F,_("Off: only you add devices, from LuCI. On: people manage their devices within the limits you set.")),D])])},check:()=>{if(!r.portal)return null;let C=h();return C.bad?m(_("Portal port: %s"),C.text):null}},y=()=>[$,b,o?null:k].filter(C=>C!=null),I=e.awg_state,w=I?.missing??[],f=w.length?t("div",{class:"dl-list dl-notices"},[it("shield","bad",_("AmneziaWG isn’t installed"),m(_("The tunnel needs %s. Install the build made for this firmware, then create the server."),new Intl.ListFormat(le(),{type:"conjunction"}).format(w)),N(_("Install"),()=>zn(()=>location.reload()),"positive"))]):I&&!I.loaded?t("div",{class:"dl-list dl-notices"},[it("shield","warn",_("AmneziaWG’s kernel module doesn’t load on this firmware"),_("Try another build in Components, or update OpenWrt. The server can’t start until it loads."),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},_("Open Components")))]):"",T=()=>{let C=y();a>=C.length&&(a=C.length-1),dom.content(S,[t("h2",{},o?_("Add a server"):_("Set up Dawnline")),f,t("div",{class:"dl-steps"},C.map((D,F)=>t("span",{class:`dl-step${F===a?" current":F0?N(_("Back"),()=>{a--,T()}):s?N(_("Cancel"),s):"",t("span",{class:"dl-spacer"}),a{let D=C[a].check?.();if(D){q(D,"warning");return}a++,T()},"positive"):N(_("Create server"),async()=>{for(let F of C){let Y=F.check?.();if(Y){q(Y,"warning");return}}let D=await K(()=>H.serverCreate(r.id,r.name,e.ifname,r.port,fn(r.range),r.endpoint,e.mtu,r.preset,r.lan_zone,r.wan_zone,r.lan_like,o?void 0:r.portal,o?void 0:r.portal_port),_("Server created"));D&&(D.network_restart&&q(_("Restarting the network so it knows AmneziaWG: back in a few seconds")),setTimeout(()=>{location.href=Io(D.id)},D.network_restart?1e4:1500))},"positive",{disabled:w.length>0,title:w.length?_("Install AmneziaWG first"):null})])])};return T(),S}};function ft(n){let e={el:n(),refresh(){let o=n();e.el.replaceWith(o),e.el=o}};return e}function Ue(n,e,o,s,r="",a=[]){return t("section",{class:`dl-setsec ${r}`,id:`dl-set-${n}`},[t("div",{class:"dl-setsec-body"},[a.length?t("div",{class:"dl-setsec-head"},[t("h3",{},e),t("span",{class:"dl-spacer"}),...a]):t("h3",{},e),...o]),s.length?t("div",{class:"dl-setsec-foot"},s):""])}function Br(n){let e=n.filter(r=>r.status!=="skip"),o=e.filter(r=>r.status==="error"||r.status==="warn"),s=e.some(r=>r.status==="error")?"error":o.length?"warn":"ok";return{bad:o,worst:s}}function Or(n){let e=n.d.settings,o=n.d.effective,s=n.d.cert,r=ye(o.portal_enabled,_("Enable portal")),a=he(e.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),i=he(e.portal_redirect,{placeholder:_("Show “Not found”"),class:"cbi-input-text dl-mono"}),l=he("",{placeholder:_("vpn.example.com or an IP"),"aria-label":_("Other address")}),d=j=>/^\d{1,3}(\.\d{1,3}){3}$/.test(j),c=[o.portal_host,...o.portal_alt??[]].filter((j,J,ie)=>j&&ie.indexOf(j)===J),p=!!n.portal,u=[],v=j=>{j&&!u.some(J=>J.host===j)&&u.push({host:j,kind:d(j)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},M=j=>{u=[...j,...u.filter(J=>!j.some(ie=>ie.host===J.host))],!c.length&&j[0]&&(c=[j[0].host])};n.portal&&M(n.portal.candidates),c.forEach(v);let x=j=>j.kind==="ip"?t("span",{class:"dl-addr-warn"},[g("alert"),_("Plain HTTP: the link and VPN keys travel unencrypted")]):t("span",{class:"dl-sub"},j.cloudflare?_("Behind Cloudflare · often stalls in Russia"):j.ips.length?j.here?j.cert?_("Points at this router · Let’s Encrypt certificate"):_("Points at this router · no certificate yet"):m(_("Points at %s, not this router"),j.ips.join(", ")):p?_("Your address"):_("Checking where it points…")),h=t("div",{class:"dl-addr-opts",role:"group","aria-label":_("Portal addresses")}),S=j=>{c.includes(j)?c.length>1&&(c=c.filter(J=>J!==j)):c=[...c,j],z(),b()},z=()=>dom.content(h,[...u.map(j=>{let J=c.includes(j.host),ie=c[0]===j.host;return t("div",{class:`dl-addr-opt${J?" on":""}`,role:"checkbox","aria-checked":J?"true":"false",tabindex:"0",click:()=>S(j.host),keydown:ve=>{(ve.key===" "||ve.key==="Enter")&&(ve.preventDefault(),S(j.host))}},[t("i",{class:"dl-addr-check"},J?g("check"):""),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono"},j.host),x(j)]),ie?t("span",{class:"dl-pill info"},_("Main")):J?t("button",{type:"button",class:"dl-linkbtn",click:ve=>{ve.stopPropagation(),c=[j.host,...c.filter(R=>R!==j.host)],z(),b()}},_("Make main")):j.cloudflare?t("span",{class:"dl-pill warn"},"Cloudflare"):j.kind==="ip"?t("span",{class:"dl-pill"},"IP"):j.here&&j.cert?t("span",{class:"dl-pill ok"},_("Recommended")):""])}),t("div",{class:"dl-addr-opt other"},[t("i",{class:"dl-addr-check"},g("plus")),l,N(_("Add"),()=>{let j=l.value.trim().toLowerCase();if(!j)return;let J=$t(j);if(J.bad){q(J.text,"warning");return}v(j),c.includes(j)||(c=[...c,j]),l.value="",z(),b()})])]);l.addEventListener("keydown",j=>{j.key==="Enter"&&(j.preventDefault(),l.nextElementSibling?.click())});let E=t("div",{class:"dl-links"}),$=()=>{},b=()=>{$();let j=Number(a.value)||o.portal_port;dom.content(E,c.map((J,ie)=>{let ve=d(J),R=ve?j+1:j,O=`${ve?"http":"https"}://${J}${R===(ve?80:443)?"":`:${R}`}/`;return t("div",{class:"dl-link-row"},[t("span",{class:`dl-link-ic ${ve?"warn":"ok"}`},g(ve?"alert":"lock")),t("span",{class:"dl-mono dl-link-url"},[O,t("b",{},"kamiro-telosu-bavine")]),ie===0?t("span",{class:"dl-pill info"},_("Main")):ve?t("span",{class:"dl-pill warn"},"HTTP"):""])}))};z(),b(),a.addEventListener("input",()=>b());let k={portal:_("Portal running"),portal_dns:_("Points here"),portal_reply:_("Answers reach visitors"),portal_http:_("Plain HTTP"),cert:_("Certificate")},y=n.d.needs??{https:[],acme:[],home:[]},I=j=>{if(!o.portal_enabled)return t("div",{hidden:!0});if(!j)return ke("check",_("Ready to share"),_("The portal’s checks from Health"),[t("p",{class:"dl-muted dl-loading"},_("Running checks…"))]);let J=j.filter(P=>P.status!=="skip");if(!J.length)return t("div",{hidden:!0});let{bad:ie,worst:ve}=Br(j),R=t("div",{class:"dl-ready-details",hidden:!0},J.map(P=>t("div",{class:`dl-ready-item ${P.status}`},[g(P.status==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("span",{},P.title),t("span",{class:"dl-sub"},P.detail)])]))),O=t("div",{class:"dl-stack gap8"},[t("div",{class:`dl-ready-sum ${ve}`},[g(ve==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("b",{},ve==="ok"?W(J.length,"All %s check passed","All %s checks passed"):m(N_(J.length,"%s of %s check passed","%s of %s checks passed"),V(J.length-ie.length),V(J.length))),ie.length?t("span",{class:"dl-sub"},ie.map(P=>P.detail).join(" ")):t("span",{class:"dl-sub"},_("Links will open for the people you send them to."))]),t("button",{type:"button",class:"dl-linkbtn",click:P=>{R.hidden=!R.hidden,P.currentTarget.textContent=R.hidden?_("Details"):_("Hide")}},_("Details"))]),t("div",{class:"dl-chips-row"},J.map(P=>t("span",{class:`dl-check-chip ${P.status}`,title:P.detail},[g(P.status==="ok"?"check":"alert"),k[P.id]??P.title]))),R]);return ke("check",_("Ready to share"),_("The portal’s checks from Health"),[O])},w=j=>{if(!o.portal_enabled||!j&&!y.https.length)return t("span",{hidden:!0});if(y.https.length)return t("span",{class:"dl-pill bad"},_("Can’t start"));let{worst:J}=Br(j);return t("span",{class:`dl-pill ${J==="ok"?"ok":J==="error"?"bad":"warn"}`},J==="error"?_("Needs attention"):_("Ready"))},f=I(n.portal?.checks??null),T=w(n.portal?.checks??null);n.portalFill=j=>{p=!0,M(j.candidates),z(),b();let J=I(j.checks);f.replaceWith(J),f=J;let ie=w(j.checks);T.replaceWith(ie),T=ie};let C=s&&!s.self_signed&&s.expires?Be(s.expires):"",D=_e(_("Listening port"),a,()=>gn(a.value.trim()===""?o.portal_port:Number(a.value),n.d.tcp_taken??[],c.some(d)));$=D.refresh;let F=_e(_("Unknown links"),i,()=>ws(i.value)),Y=!!(e.portal_cert&&e.portal_key),ee=s?Y?_("Your files"):s.self_signed?_("Self-signed"):"Let’s Encrypt":_("Portal is off"),B=()=>{let j=he(e.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),J=he(e.portal_key,{placeholder:"/etc/ssl/…/key"});de(_("Use your own certificate"),[t("p",{class:"dl-muted"},_("Paths on the router. Leave both empty to pick a certificate automatically.")),ge(_("Certificate file"),j),ge(_("Key file"),J)],[ue()," ",N(_("Save"),()=>{ce(),n.save({portal_cert:j.value.trim(),portal_key:J.value.trim()},_("Certificate saved"),"portal")},"positive")])},Q=(j,J,ie,ve,R,O)=>it(j,J,ie,ve,N(O,()=>sn(R,y[R],()=>n.reload("portal")),"positive")),ne=y.https.length?Q("lock","bad",_("HTTPS isn’t available on this router"),m(_("The portal needs %s. It can’t start without them."),new Intl.ListFormat(le(),{type:"conjunction"}).format(y.https)),"https",_("Install")):"",fe=y.acme.length&&(!s||s.self_signed)?Q("lock","",_("Free certificate from Let’s Encrypt"),e.portal_host?m(_("ACME isn’t installed. With it the router gets a certificate for %s and browsers stop warning."),e.portal_host):_("ACME isn’t installed. With it the router gets a certificate and browsers stop warning."),"acme",_("Install ACME")):"",se=[t("div",{class:"dl-row"},[g("lock"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},[ee,C?t("span",{class:"dl-faint"},` · ${m(_("until %s"),C)}`):""]),t("span",{class:"dl-sub dl-ellipsis",title:s?.path??""},s?s.self_signed?_("Made by the router: browsers warn until a certificate covers the address."):`${Y?_("Your files"):_("Found automatically")} · ${s.path}`:_("Turn the portal on to see its certificate."))])]),t("div",{class:"dl-row"},[g("file"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},_("Your own files")),t("span",{class:"dl-sub"},Y?`${e.portal_cert} · ${e.portal_key}`:_("Not set: the certificate is picked automatically."))]),Y?N(_("Reset"),()=>n.save({portal_cert:"",portal_key:""},_("Automatic certificate"),"portal"),"negative"):"",N(Y?_("Change"):_("Use files"),B)]),fe];return Ue("portal",_("Personal portal"),[t("span",{class:"dl-muted"},_("A page where each person adds and manages their devices with their personal link.")),ne?t("div",{class:"dl-list"},[ne]):"",ke("network",_("Port"),_("How the portal listens (80 and 443 stay free)"),[D]),ke("edit",_("Appearance"),_("What people see"),[F]),ke("link",_("Addresses"),_("Pick one or more; the first is the main link"),[h,t("div",{class:"dl-stack gap8"},[E,t("span",{class:"dl-sub"},_("Example code; each person gets their own three words."))])]),ke("lock",_("Certificate"),_("Used for HTTPS links"),se),f],[t("span"),N(_("Save"),()=>{let j=je([D,F]);if(j){q(j,"warning");return}return n.save({portal_enabled:He(r)?"1":"0",portal_host:c[0]??"",portal_alt:c.slice(1),portal_port:a.value,portal_redirect:i.value.trim()},_("Saved"),"portal")},"positive")],"",[T,r])}function jr(n){let e=n.d.settings,o=n.d.effective,s=he(e.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),r=ye(o.hostnames,_("Device hostnames")),a=he(e.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),i=he(e.home_dns_fallback==="none"?"":e.home_dns_fallback||o.home_dns_fallback||"",{placeholder:_("None"),inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),l=_e(_("Devices per person"),s,()=>{if(!s.value.trim())return{text:_("The default, 3. Pre-filled when you add someone."),bad:!1};let p=vn(s.value);return p.bad?p:{text:_("Pre-filled when you add someone."),bad:!1}}),d=_e(_("Device hostnames"),a,()=>ys(a.value),t("div",{class:"dl-hostport"},[r,t("span",{class:"dl-faint dl-mono"},"phone.myata."),a])),c=_e(_("Fallback DNS"),i,()=>{let p=ks(i.value);return p.bad?p:{text:m(_("For Home-only devices using home names: %s"),p.text),bad:!1}});return Ue("defaults",_("New people"),[l,d,c],[t("span"),N(_("Save"),()=>{let p=je([l,d,c]);if(p){q(p,"warning");return}return n.save({default_device_limit:s.value,hostnames:He(r)?"1":"0",domain:a.value,home_dns_fallback:i.value},_("Saved"),"defaults")},"positive")])}function Ur(n){let e=n.d.effective,o=ye(e.geo_enabled,_("Locations")),s=t("select",{class:"cbi-input-select"},[t("option",{value:"ipwho.is",selected:e.geo_provider!=="ipapi.co"?"selected":null},m(_("%s (fallback: %s)"),"ipwho.is","ipapi.co")),t("option",{value:"ipapi.co",selected:e.geo_provider==="ipapi.co"?"selected":null},m(_("%s (fallback: %s)"),"ipapi.co","ipwho.is"))]);return Ue("map",_("Map & locations"),[t("div",{class:"dl-setrow head"},[t("span",{class:"dl-muted"},_("Show where people connect from on the Overview and person pages, at city level.")),o]),ge(_("Provider"),s)],[t("span",{class:"dl-sub"},_("The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map.")),N(_("Save"),()=>n.save({geo_enabled:He(o)?"1":"0",geo_provider:s.value},_("Saved"),"map"),"positive")])}var yl=()=>[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages",_("System packages")]];function Wr(n){let e=n.d.effective.updates,o=ye(e.check,_("Check automatically"),M=>v(M,He(r))),s=Xe([["6h",_("Every 6 h")],["12h",_("Every 12 h")],["1d",_("Daily")],["7d",_("Weekly")]],e.interval,_("How often")),r=ye(e.auto,_("Install automatically"),M=>v(He(o),M)),a=he(e.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":_("Time")}),i=Xe([["scheduled",_("At a set time")],["immediate",_("As soon as found")]],e.mode,_("When"),M=>a.hidden=M!=="scheduled");a.hidden=e.mode!=="scheduled";let l=yn(yl(),e.targets,_("Components")),d=ye(e.keep,_("Keep the previous version")),c=ye(e.mirrors,_("GitHub mirrors")),p=ge(_("How often"),s),u=[ge(_("When"),t("div",{class:"dl-hostport"},[i,a]),_("A set time keeps tunnel restarts out of the evening; the run happens within an hour of it.")),ge(_("Components"),l.node,_("AmneziaWG is off by default: a new kernel module restarts every tunnel."))],v=(M,x)=>{p.hidden=!M;for(let h of u)h.hidden=!x};return v(e.check,e.auto),Ue("updates",_("Updates"),[t("span",{class:"dl-muted"},_("How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first.")),ge(_("Check automatically"),o,_("Looks for new versions in the background; Components shows what it found and the service log names it.")),p,ge(_("Install automatically"),r,_("Downloads and installs new versions of the components below.")),...u,ge(_("Keep the previous version"),d,_("Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB.")),ge(_("GitHub mirrors"),c,_("When GitHub is unreachable, download through mirrors. Checksums are still verified."))],[t("span",{class:"dl-sub"},_("Run a check or an update by hand in Components.")),N(_("Save"),()=>{if(i.value==="scheduled"){let M=_s(a.value);if(M.bad){q(m(_("Time: %s"),M.text),"warning");return}}return n.save({update_check:He(o)?"1":"0",update_interval:s.value,update_auto:He(r)?"1":"0",update_mode:i.value,update_time:a.value.trim(),update_targets:l.value(),update_keep:He(d)?"1":"0",update_mirrors:He(c)?"1":"0"},_("Saved"),"updates")},"positive")])}function Gr(n){let e=n.d.logs,o=e.policy,s=Xe([["7",W(7,"%s day","%s days")],["30",W(30,"%s day","%s days")],["90",W(90,"%s day","%s days")],["365",W(1,"%s year","%s years")],["0",_("No limit","retention")]],String(o.keep_days),_("Keep activity")),r=Xe([["500",V(500)],["2000",V(2e3)],["5000",V(5e3)],["20000",V(2e4)]],String(o.max),_("Maximum events")),a=Xe([["10min",_("Every 10 min")],["hourly",_("Hourly")],["off",_("Memory only")]],o.persist,_("Save to flash")),i=Xe([["31",W(1,"%s month","%s months")],["62",W(2,"%s month","%s months")],["180",W(6,"%s month","%s months")],["365",W(1,"%s year","%s years")],["730",W(2,"%s year","%s years")]],String(o.usage_days),_("Daily traffic")),l=Xe([["12",W(1,"%s year","%s years")],["24",W(2,"%s year","%s years")],["60",W(5,"%s year","%s years")],["120",W(10,"%s year","%s years")]],String(o.usage_months),_("Monthly traffic")),d=yn(Ht.map(v=>[v,t("span",{title:Cs(v)},[Ke(v)," ",t("span",{class:"dl-faint dl-opt-note"},V(e.by_category[v]??0))])]),o.categories,_("Record")),c=e.oldest?Be(new Date(e.oldest*1e3)):"",p=(v,M,x,h)=>t("div",{class:"dl-row"},[g(v),t("span",{class:"dl-row-main dl-stack"},[t("b",{},M),t("span",{class:"dl-sub"},x)]),...h]),u=v=>N(v.toUpperCase(),async()=>{let[M,x]=await Promise.all([H.status(1),H.events(2e4)]);Ze(M,x.events,v)},"neutral",{title:m(_("Download the log as %s"),v.toUpperCase())});return Ue("logs",_("Logs & history"),[t("p",{class:"dl-muted"},wn(o)),ge(_("Keep activity"),s,_("Older events are removed automatically.")),ge(_("Maximum size"),r,_("Newest events are kept when the log is full.")),ge(_("Record"),d.node,_("Switched-off categories are not logged from now on.")),ge(_("Save to flash"),a,_("The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot.")),ge(_("Daily traffic"),i,_("Per-day history behind the charts.")),ge(_("Monthly traffic"),l,_("Per-month totals; data limits use the current month.")),t("h4",{class:"dl-setsub"},_("Stored data")),t("div",{class:"dl-list"},[p("activity",_("Activity log"),e.events?`${m(_("%s since %s"),W(e.events,"%s event","%s events"),c)} · ${o.persist==="off"?m(_("%s in memory"),Tt(e.log_ram)):m(_("%s in memory, %s on flash"),Tt(e.log_ram),Tt(e.log_flash))}`:_("Empty"),[u("csv"),u("json"),N(_("Clear"),()=>lt(_("Clear activity"),_("Removes events from the log on the router."),{},()=>n.reload("logs")),"negative")]),p("chart",_("Traffic history"),e.usage_days?`${m(_("%s since %s"),W(e.usage_days,"%s day","%s days"),Be(e.usage_since))} · ${m(_("%s on flash"),Tt(e.usage_flash))}`:_("Empty"),[N(_("Reset"),()=>zt("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),p("pin",_("Location cache"),`${W(n.d.geo_cached,"%s address","%s addresses")} · ${m(_("%s on flash"),Tt(e.geo_flash))}`,[N(_("Clear"),async()=>{await K(()=>H.geoClear(),_("Location cache cleared"))&&await n.reload("logs")},"negative")])])],[t("span",{class:"dl-sub"},_("Clear one person or device from their own page.")),N(_("Save"),()=>n.save({log_keep_days:s.value,log_max:r.value,log_persist:a.value,usage_keep_days:i.value,usage_keep_months:l.value,log_category:d.value()},_("Saved"),"logs"),"positive")])}function kl(n){return{manual:_("Manual"),auto:_("Nightly"),"pre-restore":_("Before restore"),"pre-import":_("Before import"),"pre-delete":_("Before removing a server"),"pre-update":_("Before update")}[n]??n}var qr=3;function Bo(n){let e=new Date(n*1e3),o=e.toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"}),s=Math.round((new Date(new Date().toDateString()).getTime()-new Date(e.toDateString()).getTime())/864e5);return s===0?m(_("Today, %s"),o):s===1?m(_("Yesterday, %s"),o):`${e.toLocaleDateString(le(),{day:"numeric",month:"short"})}, ${o}`}async function _l(n){let e=await K(()=>H.backupRead(n.name));if(!e)return;let o=atob(e.data),s=new Uint8Array(o.length);for(let a=0;a_l(n),"neutral","dl-icon-only"),Pe("more",_("More"),o=>Te(o.currentTarget,[{label:_("Restore"),icon:g("reset"),run:async()=>{await me(_("Restore this backup?"),m(_("Everything returns to %s. The current state is backed up first."),Bo(n.created)),_("Restore"),!0)&&await K(()=>H.backupRestore(n.name),_("Restored"))&&e(!0)}},{label:_("Delete"),icon:g("trash"),danger:!0,run:async()=>{await me(_("Delete this backup?"),m(_("The backup from %s is removed from the router."),Bo(n.created)),_("Delete"),!0)&&await K(()=>H.backupDelete(n.name),_("Backup deleted"))&&e()}}]),"neutral","dl-icon-only")])])}function Kr(n,e){let o=n.slice(0,qr).map(d=>Fr(d,e)),s=n.slice(qr),r=n.length?t("div",{class:"dl-list"},[...o,s.length?t("details",{class:"dl-bk-older"},[t("summary",{},[g("chevron"),W(s.length,"%s older backup","%s older backups")]),...s.map(d=>Fr(d,e))]):""]):t("div",{class:"dl-list"},[t("div",{class:"dl-row dl-muted"},_("No backups yet."))]),a=N(_("Restore from file"),async()=>{let d=await no(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await me(_("Restore from file?"),m(_("Replace the current Dawnline configuration with %s? The current state is backed up first."),d.name),_("Restore"),!0)&&await K(()=>H.backupUpload(d.data),_("Restored"))&&e(!0)}),i=N(_("Export JSON"),async()=>{let d=await K(()=>H.exportJson());d&&Ae(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=N(_("Import JSON"),async()=>{let d=await no(".json,application/json","text");if(!d)return;let c;try{c=JSON.parse(d.data)}catch{q(_("Not a JSON file."),"error");return}await me(_("Import?"),_("This replaces the whole Dawnline configuration on this router. The current state is backed up first."),_("Import"),!0)&&await K(()=>H.importJson(c),_("Imported"))&&e(!0)});return t("section",{class:"dl-setsec",id:"dl-set-backups"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-setsec-head"},[t("div",{class:"dl-stack"},[t("h3",{},_("Backups")),t("span",{class:"dl-sub"},_("Nightly when something changed, and before every restore, import or update. The last 10 are kept."))]),t("span",{class:"dl-spacer"}),N([g("plus")," ",_("Back up now")],async()=>{await K(()=>H.backupCreate(),_("Backup created"))&&e()},"positive")]),r]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},_("Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router.")),t("span",{class:"dl-row-actions dl-bk-actions"},[a,i,l])])])}var Oo="remove";function Cl(){let n=he("",{placeholder:Oo}),e=N(_("Remove Dawnline"),async()=>{await K(()=>H.uninstall(n.value.trim()),_("Dawnline removed"))&&(ce(),setTimeout(()=>location.reload(),800))},"negative",{disabled:!0});n.addEventListener("input",()=>{e.disabled=n.value.trim()!==Oo}),de(_("Remove Dawnline?"),[t("p",{},m(_("Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “%s” to confirm."),Oo)),n],[ue()," ",e])}function Vr(){return Ue("danger",_("Remove Dawnline from this router"),[t("p",{class:"dl-muted"},_("Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup."))],[t("span"),N(_("Remove"),()=>Cl(),"negative")],"danger")}var Un=class{constructor(){this.root=t("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return H.settingsGet()}render(e){this.d=e,this.cards={portal:ft(()=>Or(this)),defaults:ft(()=>jr(this)),map:ft(()=>Ur(this)),updates:ft(()=>Wr(this)),logs:ft(()=>Gr(this)),backups:ft(()=>Kr(this.backups,r=>this.loadBackups(r))),danger:ft(()=>Vr())};let o=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,o.map(r=>this.cards[r].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let s=new URLSearchParams(location.search).get("section");return s&&s!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${s}`)?.scrollIntoView({block:"start"})),t("div",{},[t("div",{class:"dl-pagehead"},[t("h2",{class:"dl-h1"},_("Settings"))]),this.root])}async save(e,o,s){let r=await K(()=>H.settingsUpdate(e),o);r&&(this.d=r,this.cards[s].refresh(),s==="portal"&&this.loadPortal())}async loadPortal(){let e=++this.portalSeq,o=await H.portalInfo().catch(()=>null);e===this.portalSeq&&(this.portal=o??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(e=!1){e&&await this.reload();let o=await H.backupList().catch(()=>null);o&&(this.backups=o.backups,this.cards.backups?.refresh())}async reload(e){let o=await H.settingsGet().catch(()=>null);if(o){if(this.d=o,e)this.cards[e].refresh();else for(let s of Object.values(this.cards))s.refresh();(!e||e==="portal")&&this.loadPortal()}}};function Yr(n,e=!1){return n&&(e?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function Jr(n){let e=[],o=l=>{let d=[],c=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,p=0;for(let u;u=c.exec(l);)u.index>p&&d.push(l.slice(p,u.index)),u[1]?d.push(t("code",{},u[1].slice(1,-1))):u[2]?d.push(t("b",{},u[2].slice(2,-2))):u[3]?d.push(t("a",{href:u[4],target:"_blank",rel:"noopener"},u[3].replace(/^\[|\]\(.*$/g,""))):u[5]&&d.push(t("a",{href:u[5],target:"_blank",rel:"noopener"},u[5].replace(/^https?:\/\/(github\.com\/)?/,""))),p=u.index+u[0].length;return p{r.length&&e.push(t("p",{},o(r.join(" ")))),r=[],s=null};for(let l of n.replace(/\r/g,"").split(` `)){let d=l.trimEnd();if(a){/^```/.test(d.trim())?(e.push(t("pre",{},a.join(` `))),a=null):a.push(l);continue}if(/^```/.test(d.trim())){i(),a=[];continue}let c=/^(#{1,6})\s+(.*)$/.exec(d),p=/^\s*[-*+]\s+(.*)$/.exec(d)??/^\s*\d+[.)]\s+(.*)$/.exec(d);c?(i(),e.push(t("h5",{},o(c[2])))):p?(r.length&&i(),s||(s=t("ul",{}),e.push(s)),s.appendChild(t("li",{},o(p[1])))):d.trim()?(s&&(s=null),r.push(d.trim())):i()}return a&&e.push(t("pre",{},a.join(` -`))),i(),e}function Kr(n){let e=[],o=!1;for(let s of n.replace(/\r/g,"").split(` +`))),i(),e}function Zr(n){let e=[],o=!1;for(let s of n.replace(/\r/g,"").split(` `)){let r=/^#{1,6}\s+(.*)$/.exec(s);if(r){if(o=/^install\b/i.test(r[1].trim()),/^what.s new$/i.test(r[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(s)&&(o=!1);o||e.push(s)}return e.join(` `).replace(/\n{3,}/g,` -`).trim()}async function sn(n,e,o,s){let r=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},_("Loading release notes…"))),a=t("div",{class:"dl-op-head"}),i="";de(o,[a,r],[A([v("copy")," ",_("Copy")],()=>xe(i,_("Release notes copied")))," ",ue(_("Close"))],"wide");try{let l=await N.updatesNotes(n,e,s??"");i=Kr(l.body||"");let d=qr(l.url);dom.content(a,[l.published?t("span",{class:"dl-pill"},Oe(l.published)):"",l.prerelease?t("span",{class:"dl-pill warn"},_("Pre-release")):"",t("span",{class:"dl-spacer"}),d?t("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},[_("On GitHub")," ",v("open")]):""]),dom.content(r,i.trim()?Fr(i):t("p",{class:"dl-muted"},_("This release has no notes.")))}catch(l){dom.content(r,t("p",{class:"dl-muted"},Ce(l)))}}function yl(n){let e={"6h":_("checks every 6 h"),"12h":_("checks every 12 h"),"1d":_("checks daily"),"7d":_("checks weekly")};return e[n]??e["1d"]}var Ro=n=>n?Oe(n):"";function kl(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function Vr(n,e){let o=n.st,s=o.policy,r=o.kept?.app,a=e?.update&&e.tag?e.tag:o.version,i=w=>()=>sn("app",w,m(_("What’s new in Dawnline %s"),w.replace(/^v/,""))),l=e?.tag&&(e.update||e.status==="latest")?_l(n,e.tag,e.update?o.version:""):null,d=e?.tag??a,c=s.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[s.interval]??24)*3600:0,p=(w,M)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},w),t("span",{class:"dl-comp-side-v"},M)]),u=[{label:_("What’s new"),ic:"file",run:i(a)},{label:_("Open on GitHub"),ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:m(_("Reinstall %s"),o.version),ic:"reset",warn:!0,run:()=>n.op("app:reinstall",_("Reinstalling Dawnline"),o.version)},r?{label:m(_("Roll back to %s"),r.version),ic:"archive",warn:!0,run:async()=>{await me(m(_("Roll back to Dawnline %s?"),r.version),m(_("The copy kept on the router replaces %s. A backup of the settings is made first."),o.version),_("Roll back"))&&n.op("app:rollback",_("Rolling back Dawnline"),o.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},v("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app",_("Checking Dawnline"),o.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[o.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},m(_("release %s"),e.latest)):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?m(_("released %s"),Ro(e.published)):"":e?.status==="dev"?_("ahead of the latest release"):e?[_("latest release"),e.published?m(_("released %s"),Ro(e.published)):""].filter(Boolean).join(" · "):_("not checked yet"))])]),l?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},l.items.map(w=>t("li",{},w))),l.total>l.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:i(d)},W(l.total-l.items.length,"+%s more in What’s new","+%s more in What’s new")):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[A(_("Update now"),()=>n.op("app",_("Updating Dawnline"),o.version),"positive",{disabled:n.busy}),A(_("What’s new"),i(a))]):"",Ll(n),Cl(n)]),t("div",{class:"dl-comp-hero-side"},[p(_("Source"),[v("globe"),t("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p(_("Auto-update"),[s.auto?Pe("ok",_("On")):Pe("",_("Off")),t("span",{class:"dl-muted"},s.auto?s.mode==="immediate"?_("as soon as found"):m(s.interval==="7d"?_("weekly at %s"):_("daily at %s"),s.time):s.check?yl(s.interval):_("checks off"))]),p(_("Last check"),o.check?[pe(o.check.time,o.now),c>o.now?t("span",{class:"dl-faint"},`· ${m(_("next in %s"),ot(c-o.now))}`):""]:[_("Never")]),p(_("Rollback"),r?[t("span",{class:"dl-mono"},r.version),t("span",{class:"dl-faint"},_("kept on flash"))]:[t("span",{class:"dl-muted"},s.keep?_("Kept after the next update"):_("Off"))])])])}function _l(n,e,o){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let s=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(a,i)=>i??"").trim();return(async()=>{let a=((await N.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` -`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);a.length||(a=(await N.updatesChanges(o,e).catch(()=>null))?.items??[]);let i={items:a.slice(0,3).map(l=>kl(s(l))),total:a.length};n.notes.set(e,i),i.items.length&&n.root.isConnected&&n.paint()})(),null}function jn(n){return n==="ru"?_("Russian translation"):n}function Cl(n){let e=(n.st.translations??[]).includes("ru"),o=ye(e,jn("ru"),r=>{n.op(r?"app:lang:ru":"app:nolang",r?_("Adding the Russian translation"):_("Removing the Russian translation"),n.st.version)});o.disabled=n.busy;let s=t("details",{class:"dl-params dl-comp-fold",open:n.langOpen?"open":null},[t("summary",{},[v("chevron"),t("span",{},_("Translation")),t("span",{class:"dl-sub"},e?_("Russian"):_("English only"))]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},jn("ru")),t("span",{class:"dl-sub"},_("LuCI pages for Dawnline"))]),t("span",{class:"dl-comp-bact"},o)])])])]);return s.addEventListener("toggle",()=>n.langOpen=s.open),s}function Ll(n){let e=t("div",{class:"dl-params-body"}),o=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[v("chevron"),t("span",{},_("Versions")),t("span",{class:"dl-sub"},_("install any release"))]),e]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&Un(n,e)}),n.versOpen&&Un(n,e),o}async function Un(n,e){let o=he("",{placeholder:_("Tag, e.g. 0.3.1"),class:"cbi-input-text dl-mono","aria-label":_("Release tag")}),s=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return q(_("Enter a release tag like 0.3.1"),"warning");Yr(n,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),s(o.value))});let r=t("div",{class:"dl-comp-tag"},[o,A(_("Install"),()=>s(o.value),"neutral",{disabled:n.busy})]),a=n.versPage,i=p=>{n.versPage=Math.max(1,n.versPage+p),Un(n,e)},l=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:a<=1?"disabled":null,click:()=>i(-1)},_("← Newer")),t("span",{class:"dl-faint"},m(_("Page %s"),a)),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>i(1)},_("Older →"))]),d=n.versCache.get(a);if(!d){dom.content(e,[r,t("p",{class:"dl-muted dl-loading"},_("Loading versions…"))]);try{d=(await N.updatesReleases(a)).releases}catch(p){if(a!==n.versPage||!e.isConnected)return;dom.content(e,[r,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},m(_("Failed to load versions: %s"),Ce(p))),A(_("Try again"),()=>Un(n,e))]),l(!1)]);return}if(n.versCache.set(a,d),a!==n.versPage||!e.isConnected)return}if(!d.length)return dom.content(e,[r,t("p",{class:"dl-muted"},a>1?_("No more versions."):_("No versions found.")),l(!1)]);let c=n.st.version;dom.content(e,[r,...d.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},Ro(p.published)),p.prerelease?Pe("warn",_("Pre-release")):"",t("span",{class:"dl-comp-ic"},$e("file",_("What’s new"),()=>sn("app",p.tag,m(_("What’s new in Dawnline %s"),u)))),u===c?Pe("ok",_("Installed")):A(_("Install"),()=>Yr(n,p.tag),"neutral",{disabled:n.busy})])}),l(d.length>=5)])}async function Yr(n,e){let o=e.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await me(m(_("Install Dawnline %s?"),o),m(_("It is older than %s. A backup of the settings is made first; restore it from Settings if something looks wrong."),n.st.version),_("Install"))||n.op(`app@${e}`,m(_("Installing Dawnline %s"),o),n.st.version)}function Jr(n,e){let o=n.st,s=o.kept?.amneziawg,r=e?.sources??{},a=Object.keys(r),i=e?.current??null,l=i?r[i]:void 0,d=!!e?.ru,c=o.needs?.awg??[],p=c.length?null:e?.installed??null,u=[];i&&p&&u.push({label:_("Reinstall this build"),warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${i}${d?":ru":""}`,_("Reinstalling AmneziaWG"),p)}),s&&u.push({label:m(_("Roll back to %s"),s.version),ic:"archive",warn:!0,run:async()=>{await me(m(_("Roll back AmneziaWG to %s?"),s.version),_("The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."),_("Roll back"))&&n.op("amneziawg:rollback",_("Rolling back AmneziaWG"),p??void 0)}});let w=[e?.release?{label:_("What’s new"),ic:"file",run:()=>sn("amneziawg",e.release,m(_("What’s new in the %s build"),l?.label??"AmneziaWG"),i??"slava")}:null,{label:_("Open on GitHub"),ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((k,f,x)=>k!==null||f>0&&x[f-1]!==null),M=o.tunnels??[],g=M.length?M.length===1?m(_("Switching restarts the tunnel for a few seconds: %s. Devices keep their configurations."),M[0]):m(N_(M.length,"Switching restarts %s tunnel for a few seconds: %s. Devices keep their configurations.","Switching restarts %s tunnels for a few seconds: %s. Devices keep their configurations."),K(M.length),M.join(", ")):_("Switching takes a few seconds. Devices keep their configurations."),h=M.length>1?m(_("%s and %s"),M.slice(0,-1).join(", "),M[M.length-1]):M[0],E=M.length?m(_("Switching restarts %s for a few seconds."),h):_("Switching takes a few seconds."),H=async k=>{let f=r[k];await me(p?m(_("Switch to AmneziaWG %s?"),f.gen):m(_("Install AmneziaWG %s?"),f.gen),[m(_("The %s build, %s."),f.label,f.version),g,f.gen==="3.1"?_("Devices need AmneziaVPN 3.1 or newer."):""].filter(Boolean).join(" "),p?_("Switch"):_("Install"))&&n.op(`amneziawg:${k}${d?":ru":""}`,p?m(_("Switching to AmneziaWG %s"),f.gen):_("Installing AmneziaWG"),p??void 0)},S=k=>{let f=r[k],x=i===k&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},f.gen?`AmneziaWG ${f.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${f.label} · ${f.gen==="3.1"?"AmneziaVPN 3.1+":_("every app")}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},f.version??_("none yet")),t("span",{class:"dl-comp-bact"},x?Pe("ok",_("Active","build")):f.version?A(p?_("Switch"):_("Install"),()=>H(k),p?"neutral":"positive",{disabled:n.busy}):Pe("",_("No build")))])},$=a.map(k=>r[k]?.newer?m(_("%s moves to %s with OpenWrt %s."),r[k].label,r[k].newer.gen,r[k].newer.tag.replace(/^v/,"")):"").filter(Boolean),b=ye(d,_("Russian translation"),k=>{i&&n.op(`amneziawg:${i}${k?":ru":""}`,k?_("Adding the Russian translation"):_("Removing the Russian translation"),p??void 0)});b.disabled=!i||!p||n.busy;let C=n.awgOpen??!p,y=t("details",{class:"dl-params dl-comp-fold",open:C?"open":null},[t("summary",{},[v("chevron"),t("span",{},_("Build and translation"))]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[...a.length?a.map(S):[t("div",{class:"dl-row"},t("span",{class:"dl-sub"},_("Check for updates to see the builds for this router.")))],t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},_("Russian translation")),t("span",{class:"dl-sub"},_("LuCI pages for AmneziaWG"))]),t("span",{class:"dl-comp-bact"},b)])]),p&&a.length||$.length?t("div",{class:`dl-comp-status ${p&&a.length?"warn":"acc"}`},[v(p&&a.length?"alert":"download"),t("span",{},[p&&a.length?t("b",{},E):"",...$.map(k=>` ${k}`)])]):""])]);y.addEventListener("toggle",()=>n.awgOpen=y.open);let z=[];return e?.update&&p&&i?z.push(A(m(_("Update to %s"),e.latest),()=>n.op(`amneziawg:${i}${d?":ru":""}`,_("Updating AmneziaWG"),p),"neutral",{disabled:n.busy})):z.push((e||c.length)&&!p?Pe("warn",_("Not installed")):n.state("amneziawg",e,e?.latest??"")),z.push(n.round(()=>n.op("check:amneziawg",_("Checking AmneziaWG"),p??void 0),w)),[n.row("shield","AmneziaWG",[p?`${p}${e?.release?` · ${m(_("%s build"),e.release)}`:""}`:c.length?m(_("missing %s"),c.join(", ")):e?_("not installed"):_("version not checked")],z),t("div",{class:"dl-comp-foldwrap"},y)]}function Ml(){return[{title:_("Home-like link"),sub:_("Policy routing and the veth pair"),pkgs:["ip-full","kmod-veth"],feature:"home"},{title:_("HTTPS for the portal"),sub:_("OpenSSL for uhttpd"),pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:_("Certificates (ACME)"),sub:_("Let’s Encrypt certificate for the portal"),pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}]}var Io={home:"network",https:"lock",acme:"file"};function Zr(n,e){let o=n.st,s=e?.pkgs??{},r=Ml().filter(c=>c.feature==="home"?o.home:o.portal),a=async(c,p,u=c)=>{await me(m(_("Update %s?"),p),m(_("%s from the OpenWrt feeds. Services that use them restart for a moment."),u.join(", ")),_("Update"))&&n.op(`pkgs:${c.join(",")}`,m(_("Updating %s"),p))},i=[{label:_("Check system packages"),ic:"refresh",run:()=>n.op("check:packages",_("Checking system packages"))},{label:_("Open the OpenWrt package list"),ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],l=0;return{rows:r.map(c=>{let p=c.pkgs.filter(h=>s[h]?.installed),u=[...new Set(p.flatMap(h=>[...s[h]?.latest?[h]:[],...s[h]?.with??[]]))],w=o.needs?.[c.feature]??c.pkgs.filter(h=>!s[h]?.installed),M=p.find(h=>s[h]?.latest),g=p.map(h=>`${h} ${s[h]?.installed??""}`).join(", ");return w.length?n.row(Io[c.feature],c.title,[c.optional?_("not installed"):m(_("missing %s"),w.join(", "))],[A(_("Install"),()=>n.op(`pkgs:${w.join(",")}`,m(_("Installing %s"),c.title)),c.optional?"neutral":"positive",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(i))]):e&&u.length?(l++,n.row(Io[c.feature],c.title,M?[`${s[M].installed} → ${s[M].latest}`,u.length>1?` · +${u.length-1}`:""]:[u.join(", ")],[A(_("Update"),()=>a(p.filter(h=>s[h]?.latest||s[h]?.with?.length),c.title,u),"neutral",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(i))])):n.row(Io[c.feature],c.title,[g||c.sub],[n.state("pkgs",e,""),t("span",{class:"dl-comp-ic"},n.more(i))])}),updates:l,total:r.length}}function El(n){return n==="app"?"Dawnline":n==="amneziawg"?"AmneziaWG":n==="pkgs"?_("System packages"):_("Components")}function Tl(n){let e=/^(\d+) system packages?$/.exec(n)?.[1];return e?W(Number(e),"%s system package","%s system packages"):n}function Qr(n){let e=n.st,o=r=>{let a=mt(r.component??"app"),i=t("b",{},El(a)),l="ok",d="check",c;if(r.kind==="found")l="accent",d="download",c=ae(r.auto?_("%s found by the automatic check"):_("%s found by a check"),t("b",{},(r.items??[]).map(Tl).join(", ")));else if(r.state==="failed")l="bad",d="x",c=[...ae(r.kind==="install"?_("%s update failed"):_("%s check failed"),i),r.error?` · ${r.error}`:""];else if(/^app:(lang:|nolang$)/.test(r.component??"")){let p=/^app:lang:(.+)$/.exec(r.component??"")?.[1];c=p?ae(_("%s added by you"),t("b",{},jn(p))):[_("Translation removed by you")]}else{let p=r.from&&r.to&&r.from!==r.to?`${r.from} → ${r.to}`:r.to??"";c=[...p?ae(r.auto?_("%s %s automatically"):_("%s %s by you"),i,p):ae(r.auto?_("%s updated automatically"):_("%s updated by you"),i),r.took?` · ${ot(r.took)}`:""]}return t("div",{class:"dl-row"},[t("span",{class:`dl-ev-tile ev ${l}`},v(d)),t("span",{class:"dl-row-main"},c),t("span",{class:"dl-faint dl-nowrap",title:new Date(r.ts*1e3).toLocaleString(le())},pe(r.ts,e.now))])},s=e.history??[];return t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Activity")),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},_("All in Log →"))]),s.length?t("div",{},s.slice(0,8).map(o)):t("p",{class:"dl-sub dl-comp-empty"},_("Updates, and checks that found something, show up here."))])}var Wn=class{constructor(){this.root=t("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null;this.langOpen=!1}load(){return N.updatesStatus()}render(e){return this.st=e,this.paint(),e.job?.state==="running"&&this.follow(e.job),poll.add(async()=>{if(!this.root.isConnected)return;let o=await N.updatesStatus().catch(()=>null);if(!o)return;let s=this.st;this.st=o,o.job?.state==="running"&&this.following!=="starting"&&o.job.id!==this.following&&this.follow(o.job),(o.job?.id!==s.job?.id||o.job?.state!==s.job?.state||o.job?.phase!==s.job?.phase||o.check?.time!==s.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(e){this.st=e??await N.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(e,o,s){if(this.busy||this.following==="starting"){q(_("Another component action is already running"),"warning");return}this.following="starting",this.paint();let r=mt(e),a=await tn(e,{title:o,version:s,onJob:i=>this.following=i.id,onDone:i=>this.refresh(i),onUpdate:i=>{let l=i.check?.components??{};r==="amneziawg"&&l.amneziawg?.current?this.op(`amneziawg:${l.amneziawg.current}${l.amneziawg.ru?":ru":""}`,_("Updating AmneziaWG"),l.amneziawg.installed??void 0):this.op("app",_("Updating Dawnline"),this.st.version)}});this.following==="starting"&&(this.following=a?.id??null),this.refresh()}async follow(e){this.following=e.id;let o={app:[_("Checking Dawnline"),_("Automatic update: Dawnline"),_("Updating Dawnline")],amneziawg:[_("Checking AmneziaWG"),_("Automatic update: AmneziaWG"),_("Updating AmneziaWG")],pkgs:[_("Checking system packages"),_("Automatic update: system packages"),_("Updating system packages")],all:[_("Checking components"),_("Automatic update: components"),_("Updating components")]};await tn(null,{title:(o[An(e)]??o.all)[e.action==="check"?0:e.auto?1:2],onDone:s=>this.refresh(s)},e)}paint(){let e=this.st,o=e.check?.components??{},s=e.firmware,r=Zr(this,o.packages),a=(e.needs?.awg??[]).length>0,l=(!a&&o.amneziawg?.update&&o.amneziawg.installed?1:0)+r.updates;dom.content(this.root,[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},_("Components")),t("span",{class:"dl-faint"},[s?.version?`OpenWrt ${s.version} · ${s.target}`:"",e.check?m(_("checked %s"),pe(e.check.time,e.now)):_("not checked yet")].filter(Boolean).join(" · "))]),t("div",{class:"dl-row-actions"},[t("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[v("edit")," ",_("Settings")]),A([v("refresh")," ",_("Check all")],()=>this.op("check",_("Checking all components")),"neutral",{disabled:this.busy})])]),Vr(this,o.app),t("div",{class:"dl-comp-cols"},[t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Components")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-comp-count"},a?l?`${_("AmneziaWG not installed")} · ${W(l,"%s update","%s updates")}`:_("AmneziaWG not installed"):!o.amneziawg&&!o.packages?"":l?m(N_(l,"%s of %s needs an update","%s of %s need an update"),K(l),K(1+r.total)):_("Everything is up to date"))]),t("div",{},[...Jr(this,o.amneziawg),...r.rows])]),Qr(this)])])}state(e,o,s){let r=this.st.job;if(r?.state==="running"){let a=l=>l==="packages"?"pkgs":l,i=r.action==="check"?[a(r.component||"all")]:(r.component??"").split(" ").map(l=>a(mt(l)));if(i.includes(e)||i.includes("all"))return t("button",{type:"button",class:"dl-pill info dl-comp-run",title:_("Show progress"),click:()=>this.follow(r)},[r.action==="check"?_("Checking…"):_("Updating…")])}return o?o.error?Pe("warn",_("Check failed"),o.error):o.update?Pe("info",_("Update available")):o.status==="dev"?Pe("info",_("Newer than release"),m(_("The latest release is %s"),s)):Pe("ok",_("Up to date")):Pe("",_("Not checked"))}more(e){let o=A([v("more")],()=>Se(o,e.filter((s,r,a)=>s!==null||r>0&&rs?{label:s.label,icon:v(s.ic),warn:s.warn,run:s.run}:null)),"neutral",{title:_("More"),"aria-label":_("More")});return o}round(e,o,s=!1){let r=this.busy?" is-busy":"",a;return s?a=A([v("refresh")," ",_("Check")],e,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${r}`,"aria-label":_("Check for updates")}):(a=$e("refresh",_("Check for updates"),e,"neutral",r.trim()),a.removeAttribute("title"),a.setAttribute("aria-label",_("Check for updates")),we(a,()=>[_("Check for updates")])),t("span",{class:"dl-comp-ic"},[a,this.more(o)])}row(e,o,s,r){return t("div",{class:"dl-row"},[t("span",{class:"dl-group-ic"},v(e)),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-mono dl-faint dl-comp-sub"},s)]),...r])}};var Xr=(n,e)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},n),t("div",{class:"cbi-value-field"},e)]);function ea(n){let e=n.st.servers.find(o=>o.id===n.p.server)?.name??_("Home");Xt(n.p,e)}async function ta(n){let e=n.p,o=e.code_set??0,s=e.devices.filter(l=>l.created_by==="portal"&&l.created>=o),r=s.map(l=>t("input",{type:"checkbox",id:`dl-rm-${l.id}`,checked:"checked","data-id":l.id})),a=[t("p",{},_("The old link stops working right away."))];s.length&&a.push(t("p",{},_("Devices added through the old link keep working until they are removed. Remove them too:")),t("div",{class:"dl-checklist"},s.map((l,d)=>t("label",{for:`dl-rm-${l.id}`},[r[d],` ${l.name}`]))));let i=async()=>{let l=r.filter(c=>c.checked).map(c=>c.dataset.id),d=await F(()=>N.personRegen(e.id,l),l.length?W(l.length,"New link created, %s device removed","New link created, %s devices removed"):_("New link created"));d&&(ce(),l.length&&await n.refresh(),d.link&&await xe(d.link,_("New link copied")))};de(_("Create a new link?"),a,[ue()," ",A(_("Create new link"),i,"negative")])}function Bo(n){let e=t("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:_("Only you see this")},n.p.note??"");de(_("Note"),[e],[ue()," ",A(_("Save"),async()=>{ce(),await n.patch({note:e.value.trim()},e.value.trim()?_("Note saved"):_("Note removed"))},"positive")]),setTimeout(()=>e.focus(),50)}function na(n){let e=n.p,o=t("select",{class:"cbi-input-select"},[t("option",{value:"pause",selected:e.expire_action==="pause"?"selected":null},_("Pause access")),t("option",{value:"notify",selected:e.expire_action==="notify"?"selected":null},_("Keep access")),t("option",{value:"remove",selected:e.expire_action==="remove"?"selected":null},_("Remove their devices"))]),s=t("select",{class:"cbi-input-select"},[0,1,3,7,14].map(r=>t("option",{value:r,selected:e.expire_warn===r?"selected":null},r?W(r,"%s day before","%s days before"):_("Don’t warn"))));de(_("When access ends"),[Xr(_("Then"),o),t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},_("Warn")),t("div",{class:"cbi-value-field"},[s,t("div",{class:"cbi-value-description"},_("Shown in their portal and on the Overview."))])])],[ue()," ",A(_("Save"),async()=>{ce(),await n.patch({expire_action:o.value,expire_warn:s.value},_("Saved"))},"positive")])}function oa(n){let e=t("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48}),o=Ee(_("Name","person"),e,()=>He(e.value,[],_("Shown in their portal and apps.")));de(_("Rename"),[o],[ue()," ",A(_("Save"),async()=>{let s=o.help();if(s.bad){q(s.text,"warning");return}await n.patch({name:e.value.trim()},_("Renamed"))&&ce()},"positive")]),setTimeout(()=>e.select(),50)}function sa(n){let e=n.p,o=n.st.servers.filter(a=>a.id!==e.server),s=t("select",{class:"cbi-input-select"},o.map(a=>t("option",{value:a.id},`${a.name} · ${a.endpoint||_("no address")}:${a.port}`))),r=e.devices.length;de(m(_("Move %s to another server"),e.name),[Xr(_("Server"),s),t("p",{class:"dl-muted"},r?W(r,"%s device gets a new address and stops connecting until it imports its configuration again (from the personal link or from you). Circles and home networks of the old server are left behind.","%s devices get new addresses and stop connecting until they import their configuration again (from the personal link or from you). Circles and home networks of the old server are left behind."):_("They have no devices yet: nothing else changes."))],[ue()," ",A(_("Move"),async()=>{await n.patch({server:s.value},m(_("Moved to %s"),o.find(a=>a.id===s.value)?.name??_("the server")))&&(ce(),r&&q(_("Devices are marked “Update config” until they import again."),"info",6e3))},"positive")])}async function ra(n){let e=n.p;await me(m(_("Delete %s?"),e.name),W(e.devices.length,"%s device is disconnected immediately and the personal link stops working.","All %s devices are disconnected immediately and the personal link stops working."),_("Delete"),!0)&&await F(()=>N.personDelete(e.id),_("Deleted"))&&(location.href=It(e.server))}function aa(n){let e=n.p,o=n.st,s=e.online?_("online now"):e.last_seen?m(_("last seen %s"),pe(e.last_seen,o.now)):_("never connected"),r=e.created?m(_("Added %s","date"),De(Ke(new Date(e.created*1e3)))):"",a=e.has_link??o.settings.portal_enabled,i=[{label:_("Rename"),icon:v("edit"),run:()=>oa(n)},{label:e.note?_("Edit note"):_("Add note"),icon:v("file"),run:()=>Bo(n)},...o.servers.length>1?[{label:_("Move to server…"),icon:v("server"),run:()=>sa(n)}]:[],...a?[null,{label:_("Invite card"),icon:v("qr"),run:()=>ea(n)},{label:_("New link"),icon:v("key"),run:()=>ta(n)}]:[],null,...e.paused?[]:[{label:_("Pause"),icon:v("pause"),warn:!0,run:()=>n.patch({paused:!0},_("Paused"))}],{label:_("Delete"),icon:v("trash"),danger:!0,run:()=>ra(n)}];return t("div",{class:"dl-person-head"},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-person-id"},[t("span",{class:`dl-avatar lg${e.online?" online":""}`},je(e.name)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),Zo(e)]),t("span",{class:"dl-faint",title:r},`${m(N_(e.device_limit,"%s of %s device","%s of %s devices"),e.devices.length,e.device_limit)} · ${s}`)])]),t("div",{class:"dl-pcard-actions"},[e.paused?A([v("play"),` ${_("Resume")}`],()=>n.patch({paused:!1},_("Resumed")),"add"):"",a?$e("link",_("Copy link"),()=>Sn(e.id),"neutral","dl-icon-only"):"",$e("more",_("More"),l=>Se(l.currentTarget,i),"neutral","dl-icon-only")])]),e.note?t("button",{type:"button",class:"dl-pnote",title:_("Edit note"),click:()=>Bo(n)},[v("file"),t("span",{},e.note)]):""])}function ia(n){let e=n.p,o=n.series[n.series.length-1];return t("div",{class:`dl-person-live${e.online?"":" solo"}`},[e.online?zn(e.rate??[],n.st.now,o?[o.rx,o.tx]:[0,0]):"",Rn(n.series,m(_("%s this month"),se(e.month[0]+e.month[1])))])}async function Sl(n,e){let o=await F(()=>N.deviceConfig(e.id));o&&de(m(_("Set up %s"),e.name),[await n.core.connectBlock(o,"qr")],[ue(_("Close"))])}async function Pl(n,e){let o=await F(()=>N.deviceConfig(e.id));if(!o)return;if(!o.has_private_key){q(_("This device made its own keys in the browser; its configuration only exists there."),"warning");return}let s=n.core.file.make(o);Ne(s.name,s.text,"application/octet-stream")}function la(n){let e=n.p,o=n.st.now,s=d=>Je(e,d,n.deviceOpts()),r=d=>c=>{c.target.closest("button:not(.dl-dcard-title), a")||s(d)},a=d=>A([v("more")],c=>dr(c.currentTarget,e,d,n.deviceOpts()),"neutral",{title:_("QR, file, key, rename, new keys, remove"),class:"cbi-button cbi-button-neutral dl-icon-only"}),i=ln(e.devices).map(d=>{let c=t("div",{class:"dl-dcard-head"},[t("span",{class:"dl-dcard-ic"},v(d.kind)),t("button",{type:"button",class:"dl-dcard-title",click:()=>s(d)},[t("b",{},d.name),dn(d,o,void 0,e),d.config_stale?t("span",{class:"dl-pill warn dl-stale"},_("Update config")):""]),a(d)]),p=t("div",{class:"dl-dcard-trend"},[t("div",{class:"dl-stack"},[t("b",{},se(d.month[0]+d.month[1])),t("span",{class:"dl-sub"},_("this month"))]),$r(n.devSeries[d.id]??[])]);return t("article",{class:`dl-dcard clickable${d.online?" online":""}${d.disabled?" off":""}`,click:r(d)},[c,d.handshake?p:d.disabled?t("div",{class:"dl-sub"},`${at(d.kind)} · ${m(d.created_by==="portal"?_("created %s in the portal."):_("created %s by you."),pe(d.created,o))}`):t("div",{class:"dl-chips-row"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>Sl(n,d)},[v("qr"),_("Show QR")]),t("button",{type:"button",class:"dl-chipbtn",click:()=>Pl(n,d)},[v("download"),_("Config")])])])}),l=e.devices.length>=e.device_limit;return i.push(t("button",{type:"button",class:"dl-dslot add",click:()=>ct(e,n.deviceOpts())},[t("span",{class:"dl-dslot-ic"},v("plus")),t("span",{class:"dl-stack"},[t("b",{},_("Add device")),t("span",{class:"dl-sub"},l?`${_("Over the limit")} · ${m(_("%s of %s"),e.devices.length,e.device_limit)}`:m(_("%s of %s"),e.devices.length,e.device_limit))])])),t("section",{class:"dl-devsec"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Devices")),t("span",{class:"dl-sub"},m(_("%s online"),K(e.online)))]),t("div",{class:"dl-dgrid"},i)])}function da(n){let e=n.p,o=Me([["device",_("Device’s own DNS")],["home",_("Home names")]],e.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:r=>n.patch({dns_mode:r},r==="home"?_("Home names on - devices need their configuration again"):_("Device DNS - devices need their configuration again"))}),s=n.st.settings.home_dns_fallback;return t("div",{class:"dl-stack gap4 dl-dnspick"},[t("div",{class:"dl-row-actions"},[t("span",{class:"dl-sub"},"DNS"),o]),t("span",{class:"dl-sub"},e.dns_mode==="home"?s?ae(_("Names like %s work. Internet names are resolved at home, so they depend on the tunnel (%s takes over when it is down)."),t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`),t("span",{class:"dl-mono"},s)):ae(_("Names like %s work. Internet names are resolved at home, so they depend on the tunnel - with no fallback set, they stop when it is down."),t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)):_("Internet keeps working exactly as without the VPN. Reach home devices by IP address."))])}function ca(n){let e=n.p,s=n.st.servers.find(a=>a.id===e.server)?.home??[];if(s.length<2)return"";let r=new Set(e.home_nets?.length?e.home_nets:s.map(a=>a.dev));return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},s.map(a=>Xe(a.dev,r.has(a.dev),()=>{let i=new Set(r);if(i.delete(a.dev)||i.add(a.dev),!i.size)return q(_("Keep at least one network, or choose Internet only."),"warning",5e3);let l=i.size===s.length?[]:[...i];n.patch({home_nets:l},l.length?m(_("%s reaches %s"),e.name,l.join(", ")):m(_("%s reaches every home network"),e.name))},{title:a.nets.join(", ")}))),t("span",{class:"dl-sub"},e.home_nets?.length?m(_("Home networks %s reaches. Networks added to the server later stay out."),e.name):m(_("Home networks %s reaches: all of them. Untick one to keep %s out of it."),e.name,e.name))])}function pa(n){let e=new Set(n.p.services??[]);return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},n.st.services.map(o=>Xe(o.name,e.has(o.id),()=>{let s=new Set(e);s.delete(o.id)||s.add(o.id),n.patch({services:[...s]},s.size?_("Home services updated"):_("Whole home network"))},{title:`${o.address}${o.ports.length?` · ${o.ports.join(", ")}`:""}`}))),t("span",{class:"dl-sub"},e.size?_("Only the selected services at home."):_("Whole home network. Pick services to narrow it down."))])}function ua(n){let e=n.p,o=n.st;if(o.servers.find(c=>c.id===e.server)?.mesh!=="circles"||!ut(e))return"";let r=o.circles.filter(c=>c.server===e.server),a=r.find(c=>c.id===e.circle),i=a?o.people.filter(c=>c.id!==e.id&&c.circle===a.id&&ut(c)).map(c=>c.name):[],l=t("button",{type:"button",class:"dl-chipbtn",click:()=>Se(l,[...r.map(c=>({label:c.name,icon:So(c),run:()=>c.id!==e.circle&&n.patch({circle:c.id},m(_("%s is in %s"),e.name,c.name))})),e.circle?{label:_("No circle"),icon:v("x"),run:()=>n.patch({circle:""},m(_("%s is in no circle"),e.name))}:null,{label:_("New circle"),icon:v("plus"),run:()=>$n(o,e.server,null,()=>n.refresh())}])},_("Change")),d=a?o.people.filter(c=>c.circle===a.id&&ut(c)):[e];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},_("Devices see each other")),l]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},a?a.name:_("No circle")),t("span",{class:"dl-avstack",title:d.map(c=>c.name).join(", ")},d.slice(0,5).map(c=>t("span",{class:"dl-avatar sm"},je(c.name))))]),t("span",{class:"dl-sub"},a?i.length?[e.name,...i].join(", "):m(_("Nobody else in %s yet"),a.name):m(_("Only %s's own devices"),e.name))])}function ma(n){let e=n.p,o=n.st.now,s=t("div",{class:"dl-slots"});for(let i=0;i=e.device_limit,c=t("i",{class:d?"over":l?"used":""});we(c,()=>[t("div",{class:"dl-tip-title"},l?`${l.name}${d?` · ${_("over the limit")}`:""}`:_("Free slot")),t("div",{class:"dl-muted"},l?l.online?_("Connected"):l.handshake?m(_("Last seen %s"),pe(l.handshake,o)):_("Not set up yet"):_("They can add a device here"))]),s.appendChild(c)}let r=Math.max(1,e.devices.length),a=t("button",{type:"button","aria-label":_("Allow fewer devices"),disabled:e.device_limit<=r?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit-1)})},"−");return e.device_limit<=r&&e.devices.length>1&&we(a,()=>[t("div",{class:"dl-tip-title"},W(e.devices.length,"%s device in use","%s devices in use")),t("div",{class:"dl-muted"},_("Remove a device first to lower the limit"))]),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},_("Devices")),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[String(e.devices.length),t("span",{class:"dl-faint"},` / ${e.device_limit}`)]),t("div",{class:"dl-stepper"},[a,t("button",{type:"button","aria-label":_("Allow more devices"),disabled:e.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit+1)})},"+")])]),s])}function $l(n){return{internet:_("Browse the internet through your router. No access to devices at home, and home cannot reach theirs."),lan:_("Reach devices at home, and home reaches theirs. Internet stays on their own connection."),both:_("Home devices and the internet, all through your router. Home reaches their devices too.")}[n]}var ha=/^([01]\d|2[0-3]):[0-5]\d$/;function Dl(n){let e=n.p,o=n.today,s=st(e.expires,o),r=t("input",{type:"date",class:"dl-date-hidden",value:e.expires,tabindex:"-1","aria-hidden":"true"});r.addEventListener("change",()=>r.value&&n.patch({expires:r.value},m(_("Access until %s"),De(r.value))));let a=(c,p)=>{let u=Yo(e.expires&&(s??-1)>=0?e.expires:"",c,p,o);n.patch({expires:u},m(_("Access until %s"),De(u)))},i=[["week",1,_("+1 week")],["month",1,_("+1 month")],["month",3,_("+3 months")],["year",1,_("+1 year")]].map(([c,p,u])=>t("button",{type:"button",class:"dl-chipbtn",click:()=>a(c,p)},u)),l=t("span",{class:"dl-datechip"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>{r.focus({preventScroll:!0});try{r.showPicker()}catch{}}},[v("calendar"),e.expires?De(e.expires):_("Date")]),r]),d={pause:_("pause access"),notify:_("keep access"),remove:_("remove their devices")}[e.expire_action];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},_("Access ends")),e.expires?t("span",{class:s!=null&&s<0?"dl-bad":rt(e,s)?"dl-warn":"dl-ok"},s!=null&&s<0?_("ended"):W(s??0,"%s day left","%s days left")):t("span",{class:"dl-faint"},_("no end date"))]),t("div",{class:"dl-chips-row"},[...i,l,e.expires?t("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},_("No end date"))},_("No end")):""]),t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.expire_warn?m(N_(e.expire_warn,"When it ends: %s, warn %s day before","When it ends: %s, warn %s days before"),d,K(e.expire_warn)):m(_("When it ends: %s"),d)),t("a",{href:"#",click:c=>{c.preventDefault(),na(n)}},_("Change"))])])}function Al(n){let e=n.p,o=e.quota_used||e.month[0]+e.month[1],s=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,r=t("div",{class:`dl-meter${s>=100?" bad":s>=90?" warn":""}`},[t("i"),e.quota_limit?t("span",{class:"mark",title:_("Alert at 90%")}):""]);r.firstChild.style.width=`${s}%`,e.quota_limit&&we(r,()=>[t("div",{class:"dl-tip-title"},m(_("%s%% used"),K(s,1))),t("div",{class:"dl-muted"},`${m(_("%s of %s"),se(e.quota_used),se(e.quota_limit))} · ${m(_("%s left"),se(Math.max(0,e.quota_limit-e.quota_used)))}`),t("div",{class:"dl-faint"},_("Alert at 90%"))]);let a=Me([["month",_("Monthly")],["total",_("Total")]],e.quota_period,{label:_("Data limit period"),cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),i=[10,50,100].map(l=>t("button",{type:"button",class:`dl-chipbtn${e.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},m(_("Data limit %s GB"),K(l)))},`${K(l)} ${_("GB")}`));return i.push(t("button",{type:"button",class:`dl-chipbtn${e.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},_("No data limit"))},_("Unlimited"))),i.push(t("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=t("input",{type:"number",class:"cbi-input-text dl-w-port",min:0,step:"any",value:e.quota_gb?String(e.quota_gb):""}),d=Ee(_("Data limit (GB)"),l,()=>gn(l.value,e.quota_period==="month"));de(_("Data limit"),[d],[ue()," ",A(_("Save"),async()=>{let c=d.help();if(c.bad){q(c.text,"warning");return}let p=l.value.trim();await n.patch({quota_gb:p},p&&Number(p)>0?m(_("Data limit %s GB"),K(Number(p))):_("No data limit"))&&ce()},"positive")]),setTimeout(()=>l.select(),50)}},_("Custom"))),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},_("Data")),a]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[se(o),e.quota_limit?t("span",{class:"dl-faint"},` ${m(_("of %s"),se(e.quota_limit))}`):t("span",{class:"dl-faint"},` · ${_("no limit")}`)]),e.quota_period==="month"?t("span",{class:"dl-sub"},_("resets on the 1st")):""]),e.quota_limit?r:"",t("div",{class:"dl-chips-row"},i),e.quota_gb&&e.quota_period==="month"?t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.bonus_gb?m(_("Includes +%s GB extra this month"),K(e.bonus_gb)):_("Need a little more this month?")),t("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((e.bonus_gb||0)+10)},_("+10 GB this month"))}},_("+10 GB this month"))]):"",t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},m(_("%s in total"),se(e.total[0]+e.total[1]))),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Ht("person",e.id,e.name,()=>setTimeout(()=>n.refresh(),300))},_("Reset usage"))])])}function Nl(n){let e=n.p,o=!!e.hours,[s,r]=(e.hours||"07:00-23:00").split("-"),a=t("input",{type:"time",class:"cbi-input-text",value:s,"aria-label":_("From")}),i=t("input",{type:"time",class:"cbi-input-text",value:r,"aria-label":_("To")}),l=t("div",{class:"dl-tile2-row"},[a,t("span",{class:"dl-faint"},_("to","time range")),i]),d=()=>{let w=`${a.value}-${i.value}`;if(w!==e.hours){if(!ha.test(a.value)||!ha.test(i.value))return q(_("Enter both times, like 07:00 and 23:00."),"warning");if(a.value===i.value)return q(_("The start and the end must differ."),"warning");n.patch({hours:w},m(_("Allowed %s–%s"),a.value,i.value))}};l.addEventListener("focusout",w=>{l.contains(w.relatedTarget)||d()});for(let w of[a,i])w.addEventListener("keydown",M=>{M.key==="Enter"&&(M.preventDefault(),d())});let c=t("button",{type:"button",role:"switch","aria-checked":o?"true":"false",class:`dl-switch${o?" on":""}`,"aria-label":_("Limit hours"),click:()=>{if(o)return n.patch({hours:""},_("Any time"));c.classList.add("on"),c.setAttribute("aria-checked","true"),p.textContent=_("Set the hours, then press Enter"),u.appendChild(l),a.focus()}},t("i")),p=t("span",{},o?m(_("%s – %s (router time)"),s,r):_("Any time")),u=t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-row"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-tile2-label"},_("Allowed hours")),p]),c]),o?l:""]);return u}function fa(n){let e=n.p,o=Me(["internet","lan","both"].map(s=>[s,[v(s==="internet"?"globe":s==="lan"?"home":"shield"),s==="internet"?_("Internet"):s==="lan"?_("Home"):_("Both")]]),e.access,{label:_("Access"),cls:"wide",optimistic:!1,onChange:s=>n.patch({access:s},m(_("Access: %s"),vt(s)))});return t("section",{class:"dl-devsec","aria-label":_("Access and limits")},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Access & limits"))]),t("div",{class:"dl-panel"},[t("div",{class:"dl-stack gap8"},[t("span",{class:"dl-tile2-label"},_("Can reach")),o,t("span",{class:"dl-sub"},$l(e.access)),e.access==="lan"&&n.st.services.length?pa(n):"",ut(e)?ca(n):"",e.access==="lan"?da(n):""]),t("div",{class:"dl-tiles2"},[ma(n),ua(n),Dl(n),Al(n),Nl(n)])])])}function Hl(n){let e=n.st,o=t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Locations")),t("span",{class:"dl-spacer"}),e.geo.enabled?Rt("30d",r=>n.map?.setRange(r),!1):"",A(_("Hide"),()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},ae(_("Locations are off. %s."),t("a",{href:L.url("admin/network/dawnline/settings")},_("Turn them on in Settings"))))]);let s=new dt({openPerson:()=>{},openDevice:(r,a)=>{let i=n.p.devices.find(l=>l.id===a);i&&Je(n.p,i,n.deviceOpts())}},"30d",280);return n.map=s,requestAnimationFrame(()=>s.mount(n.mapData())),t("div",{class:"dl-panel flush"},[o,s.el])}function ga(n){let e=n.st;if(!e.geo.enabled)return t("div",{class:"dl-places"},[v("pin"),t("div",{class:"dl-stack"},[t("span",{},_("Locations are off")),t("span",{class:"dl-sub"},_("City-level, from the client IP"))]),t("span",{class:"dl-spacer"}),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},_("Turn on"))]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:Hl(n);let o=e.now-30*86400,s=e.geo.points.filter(i=>i.person===n.p.id&&i.ts>=o).sort((i,l)=>l.ts-i.ts),r=[...new Set(s.map(i=>i.city||i.country).filter(Boolean))],a=s[0];return t("div",{class:"dl-places"},[v("pin"),t("div",{class:"dl-stack"},[t("span",{},a?a.city||a.country:_("No locations yet")),t("span",{class:"dl-sub"},a?[W(r.length,"%s place in 30 days","%s places in 30 days"),a.org].filter(Boolean).join(" · "):_("Shown after a device connects"))]),t("span",{class:"dl-spacer"}),s.length?A(_("Show map"),()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function va(n){let e=n.p,o=n.st,s=n.events.filter(l=>l.person===e.id),r=[],a=[...s].reverse();for(let l=0;l1){let u=p.querySelector(".dl-row-main");dom.content(u,[...Do(o,d).slice(0,3),t("span",{class:"dl-muted"},W(c,"%s time","%s times"))]),u.title=a.slice(l,l+c).map(w=>w.detail??"").join(` -`)}r.push(p),l+=c-1}let i=A([v("more")],()=>Se(i,[{label:_("Export CSV"),icon:v("download"),run:()=>Qe(o,s,"csv",e.id)},{label:_("Export JSON"),icon:v("download"),run:()=>Qe(o,s,"json",e.id)},null,{label:m(_("Clear %s's activity"),e.name),icon:v("trash"),danger:!0,run:()=>lt(m(_("Clear %s's activity"),e.name),m(_("Removes events about %s and their devices."),e.name),{person:e.id},()=>n.refresh())}]),"neutral",{title:_("Export or clear"),class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Activity")),t("span",{class:"dl-sub"},s.length>10?m(_("latest 10 of %s"),K(s.length)):""),t("span",{class:"dl-spacer"}),i]),r.length?r:t("div",{class:"dl-row dl-muted"},_("Nothing yet."))])}var Gn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,s,r]=await Promise.all([N.status(30),e?N.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?N.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:s?.events??null,use:r}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(i=>i.id===this.id);if(!o)return t("div",{class:"dl-empty"},[t("h3",{},_("Person not found")),t("p",{},_("They may have been removed.")),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},_("Back to Servers"))]);this.p=o;for(let i of["crumbs","head","devices","traffic","places","activity","limits"])this.parts[i]=t("div",{});this.parts.devices.className="dl-person-devices";let s=t("div",{},[this.parts.crumbs,this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),a=r.get("device")&&o.devices.find(i=>i.id===r.get("device"));return a?setTimeout(()=>Je(this.p,a,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>ct(this.p,this.deviceOpts()),50),this.poller=pt({fetch:i=>{let l=i||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>s.isConnected,apply:(i,l)=>this.apply(i,l)}),s}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let s=this.st.people.find(r=>r.id===this.id);if(!s){o||(location.href=It(this.p?.server));return}this.p=s,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var a;this.poller?.claim();let s=await F(()=>N.personUpdate(this.p.id,e),o);if(!s)return!1;this.poller?.claim();let r=this.st.people.findIndex(i=>i.id===this.p.id);return(a=s.person).rate??(a.rate=this.p.rate),r>=0&&(this.st.people[r]=s.person),this.p=s.person,this.paint(),!0}get today(){return Ge(this.series.length?this.series:this.st.series)}get core(){return zt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}crumbs(){let e=this.p;return t("nav",{class:"dl-crumbs","aria-label":_("Breadcrumb")},[t("a",{href:It(e.server)},this.st.servers.find(o=>o.id===e.server)?.name??_("Servers")),t("span",{},"/"),t("a",{href:It(e.server)},_("People")),t("span",{},"/"),t("span",{},e.name)])}paint(e=!1){Ae(this.parts.crumbs,this.crumbs(),e),Ae(this.parts.head,aa(this),e),Ae(this.parts.traffic,ia(this),e),Ae(this.parts.devices,la(this),e),Ae(this.parts.limits,fa(this),e),this.paintPlaces(e),Ae(this.parts.activity,va(this),e)}paintPlaces(e=!1){let o=ga(this);o&&Ae(this.parts.places,o,e&&!this.mapOpen)}};var zl={ok:"check",warn:"alert",error:"x",skip:"pause"},qn=class{constructor(e,o,s,r){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=s,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,s)}async run(e){let o=e?await In(e):await N.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},_("Checks"))]),t("p",{class:"dl-muted dl-loading"},_("Running checks…"))]);return}let o=e.filter(i=>i.status==="error").length,s=e.filter(i=>i.status==="warn").length;dom.content(this.summary,o?bt("error",W(o,"%s problem needs attention.","%s problems need attention.")):s?bt("warn",W(s,"%s warning.","%s warnings.")):bt("ok",_("All checks passed.")));let r=new Map;for(let i of this.sl.watchdog.repairs)r.set(i.id,Math.max(r.get(i.id)??0,i.ts));let a=()=>this.run();dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},_("Checks")),t("span",{class:"dl-spacer"}),A(_("Run again"),a)]),t("ul",{class:"dl-checks"},e.map(i=>t("li",{},[t("span",{class:`dl-check-icon ${i.status}`},v(zl[i.status])),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},i.title),t("div",{class:"dl-check-detail"},i.detail),r.has(i.id)?t("div",{class:"dl-check-repaired"},m(_("Repaired by the watchdog at %s"),Ut(r.get(i.id)))):""]),Ao(i,l=>void this.run(l),a)])))])}paintLive(e,o){this.sl=e,this.events=o;let s=e.watchdog,r=s.beat!=null&&s.now-s.beat>180,a=s.repairs.filter(d=>s.now-d.ts<86400),i=a[a.length-1],l=ye(s.enabled,_("Watchdog repairs"),async d=>{await F(()=>N.settingsUpdate({watchdog:d?"1":"0"}),d?_("Watchdog on"):_("Watchdog off"))||uo(l,!d);let p=await N.serviceLog().catch(()=>null);p&&this.paintLive(p,this.events)});dom.content(this.wdEl,t("div",{class:"dl-panel dl-wd"},[t("div",{class:"dl-wd-head"},[t("span",{class:`dl-wd-tile${s.enabled?"":" off"}`},v("shield")),t("div",{class:"dl-stack"},[t("span",{class:"dl-wd-title"},_("Watchdog")),t("span",{class:"dl-sub"},s.enabled?_("Every minute it checks the tunnels and services and repairs what it can on its own."):_("Off: problems are only written to the log. Nothing is repaired on its own."))]),t("span",{class:"dl-spacer"}),l]),t("div",{class:"dl-wd-foot"},[t("div",{class:"dl-wd-chips"},s.targets.map(d=>t("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?_("OK"):d.tries?`${_("Not working")} · ${W(d.tries,"%s repair","%s repairs")}`:_("Not working")},[v(d.ok?"check":"x"),d.name]))),t("span",{class:`dl-sub${r?" dl-warn-text":""}`},r?m(_("The agent has not checked in for %s min; cron restarts it after 5."),K(Math.round((s.now-s.beat)/60))):[s.last?m(_("Looked %s"),pe(s.last,s.now)):_("Starts within a minute")," · ",a.length?m(N_(a.length,"%s repair today, last %s at %s","%s repairs today, last %s at %s"),K(a.length),i.name,Ut(i.ts)):_("no repairs today")])])])),this.paintRecent()}paintRecent(){let e=(this.sl.watchdog.now||Date.now()/1e3)-604800,o=[...this.events.map(r=>({ts:r.ts,ev:r})),...this.sl.log.map(r=>({ts:r.ts,sys:r}))].filter(r=>r.ts>=e&&vn(r)).sort((r,a)=>a.ts-r.ts),s=t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Recent problems")),t("span",{class:"dl-spacer"}),o.length?t("a",{href:"#",click:r=>(r.preventDefault(),this.toLog())},`${_("All in Log")} →`):""]);if(!o.length){dom.content(this.recentEl,[s,t("div",{class:"dl-recent-empty"},[t("span",{class:"dl-check-icon ok"},v("check")),_("No problems in the last 7 days.")])]);return}dom.content(this.recentEl,[s,...o.slice(0,8).map(r=>{if(r.sys){let a=r.sys,i=`${a.ts}|${a.msg}`;return Hn(a,this.open.has(i),()=>{this.open.delete(i)||this.open.add(i),this.paintRecent()},Ut(a.ts))}return ht(this.st,r.ev,{time:Ut(r.ts)})})])}};var Fn=300,Rl=["all","connections","people","system","problems"],Kn=class{constructor(e,o,s){this.events=[];this.system=[];this.kind="all";this.shown=Fn;this.open=new Set;this.list=t("div",{});this.sub="";this.tabs=t("div",{class:"dl-seg",role:"tablist"});this.st=e,this.take(o),this.system=s,this.el=t("div",{},[t("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let e=()=>this.kind==="all"?"":this.kind,o=a=>()=>{let i=this.filtered().reverse();Qe(this.st,i.filter(l=>l.ev).map(l=>l.ev),a,e(),i.filter(l=>l.sys).map(l=>l.sys))},s=A([v("download"),` ${_("Export")}`],()=>Se(s,[{label:_("CSV (spreadsheet)"),icon:v("download"),run:o("csv")},{label:"JSON",icon:v("download"),run:o("json")}])),r=A([v("trash"),` ${_("Clear")}`],()=>lt(_("Clear the log"),_("Removes events from the log on the router."),{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[s,r]}take(e){this.events=e.events,this.policy=e.policy;let o=Nt.filter(r=>!e.policy.categories.includes(r)),s=bn(e.policy);this.sub=o.length?`${s} ${m(_("Not recorded: %s."),o.map(r=>Ye(r).toLowerCase()).join(", "))}`:s}async reload(){let[e,o]=await Promise.all([N.events(2e4).catch(()=>null),N.serviceLog().catch(()=>null)]);e&&this.take(e),o&&(this.system=o.log),this.paint()}items(){return[...this.events.map(e=>({ts:e.ts,ev:e})),...this.system.map(e=>({ts:e.ts,sys:e}))].sort((e,o)=>o.ts-e.ts)}matches(e,o){return o==="all"?!0:o==="problems"?vn(e):o==="system"?!!e.sys:!!e.ev&&qt(e.ev.type)===o}filtered(){return this.items().filter(e=>this.matches(e,this.kind))}paintTabs(e){dom.content(this.tabs,Rl.map(o=>t("button",{type:"button",role:"tab",class:o===this.kind?"on":"","aria-selected":o===this.kind?"true":"false",click:()=>this.show(o)},[o==="all"?_("All"):o==="system"?_("System"):Ye(o),t("b",{},String(e.filter(s=>this.matches(s,o)).length))])))}show(e){this.kind=e,this.shown=Fn,this.paint()}paint(){this.paintTabs(this.items());let e=this.filtered();if(!e.length){dom.content(this.list,t("div",{class:"dl-empty"},[t("p",{},this.events.length||this.system.length?_("No events match."):_("The log is empty."))]));return}let o=[],s="",r=null;for(let a of e.slice(0,this.shown)){let i=Pr(a.ts);i!==s&&(s=i,r=t("div",{class:"dl-panel flush"},t("div",{class:"dl-panel-head pad"},t("h3",{},i))),o.push(r));let l=new Date(a.ts*1e3).toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"});if(a.sys){let d=`${a.sys.ts}|${a.sys.msg}`;r.appendChild(Hn(a.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else r.appendChild(ht(this.st,a.ev,{time:l}))}e.length>this.shown&&o.push(t("div",{class:"dl-more-row"},A(m(_("Show %s more of %s"),K(Math.min(Fn,e.length-this.shown)),K(e.length-this.shown)),()=>{this.shown+=Fn,this.paint()}))),dom.content(this.list,o)}};var Il=["health","log"],Bl=n=>n==="log"?_("Log"):_("Health"),Oo=2e4,Yn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=t("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":_("Diagnostics")});this.subEl=t("span",{class:"dl-muted"});this.actionsEl=t("div",{class:"dl-row-actions"});this.bodyEl=t("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([N.status(1),N.events(Oo),N.serviceLog()])}render([e,o,s]){return this.log=new Kn(e,o,s.log),this.health=new qn(e,s,o.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),pt({fetch:async()=>{let r=this.tab==="log",[a,i]=await Promise.all([N.serviceLog().catch(()=>null),r?N.events(Oo).catch(()=>null):Promise.resolve(null)]);return a||i?{n:a,e:i}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:r,e:a})=>this.take(r,a)}),t("div",{},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},_("Diagnostics")),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(e,o){o&&(this.log.take(o),this.eventsAt=Date.now()),e&&(this.log.system=e.log),e&&this.health.paintLive(e,o?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(e){this.tab=e,dom.content(this.segEl,Il.map(o=>t("button",{type:"button",role:"tab",class:o===e?"on":"","aria-selected":o===e?"true":"false",click:()=>o!==this.tab&&this.show(o)},Bl(o)))),this.bodyEl.replaceChildren(e==="log"?this.log.el:this.health.el),this.subEl.textContent=e==="log"?this.log.sub:_("Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own."),dom.content(this.actionsEl,e==="log"?this.log.actions():""),e==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&N.events(Oo).then(o=>this.take(null,o)).catch(()=>null)):this.health.checks||this.health.run()}};var ba=":root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-root,.dl-modal{cursor:default}:is(.dl-root,.dl-modal) :is(input:not([type=checkbox],[type=radio],[type=range],[type=button],[type=submit]),textarea,[contenteditable=true]){cursor:text}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}";var xa='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off :is(.dl-card-name,.dl-avatar,.dl-access,.dl-slotbar,.dl-chips,.dl-pill-ic,.dl-use-num,.dl-pside-foot,.dl-pside-state){opacity:.45}.dl-plist>.dl-card.dl-off .dl-usebar i{background:var(--dl-fg-faint)}.dl-plist>.dl-card.dl-off .dl-chip-tag{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pcard:has(>.dl-pstrip){row-gap:14px}.dl-pstrip{grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 -16px -16px;padding:10px 16px;border-top:1px solid var(--dl-line);border-radius:0 0 var(--dl-radius) var(--dl-radius);font-size:14px;line-height:20px}.dl-pstrip.warn{background:color-mix(in srgb,var(--dl-warn) 7%,transparent)}.dl-pstrip.bad{background:color-mix(in srgb,var(--dl-bad) 7%,transparent)}.dl-pstrip-text{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px}.dl-pstrip-text b{font-weight:500}.dl-pstrip>.cbi-button{flex:none;height:32px!important}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;border:1px dashed color-mix(in srgb,var(--dl-fg) 28%,transparent);color:var(--dl-fg-muted)}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg);border-color:color-mix(in srgb,var(--dl-fg) 45%,transparent)}.dl-chip.add:hover .dl-icon{color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}.dl-people-find{width:160px;min-width:0}.dl-people-find[hidden]{display:none}';var wa="#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-warn{color:var(--dl-warn)}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}.dl-srvtab i.dot.warn{background:var(--dl-warn)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}";var ya=".dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}";var ka=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;--dl-gap: 2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars>span:hover i{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-6.5px;bottom:-6.5px;width:20px;height:20px;border-radius:8.5px;border:1.5px solid transparent;background:var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p:hover .dl-onl-dev{background:linear-gradient(var(--dl-soft),var(--dl-soft)),var(--dl-card)}.dl-onl-p.sm:hover{background:none}.dl-onl-p.sm:hover .dl-onl-dev{background:var(--dl-card)}.dl-onl-p.sm .dl-onl-av{transition:box-shadow .15s ease}.dl-onl-p.sm:hover .dl-onl-av{box-shadow:0 0 0 2px var(--dl-ok),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm.more:hover .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-ic.off{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;height:54px;--dl-gap: 3px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars>span:hover i:not(.hi){background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-speed-val.off{color:var(--dl-fg-faint)}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var _a='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-modal .cbi-value.dl-live>.cbi-value-title{display:flex;flex-direction:column;gap:2px;text-align:left}.dl-modal .cbi-value.dl-live>.cbi-value-title>.dl-sub{white-space:normal}.dl-checklist{display:flex;flex-direction:column;gap:6px;margin:4px 0 8px}.dl-checklist label{display:flex;align-items:center;gap:8px;font-size:14px;cursor:pointer}.dl-checklist input{margin:0}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var Ca=".dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#0a0a0a;border-radius:18px;overflow:hidden}.dl-qr.light{background:#fff;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}";var La=".dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}.dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}";var Ma=".dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}";var Ea=`.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:transparent}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.line{width:14px;height:0;border-top:2px dashed #8a8a8a}.dl-map-legend i.line.live{border-top-color:#3b82f6}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.dl-mk-hub{position:relative;display:flex;align-items:center;justify-content:center}.dl-mk-host{box-sizing:border-box;width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059}.dl-mk-host-tile{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:var(--dl-fg);color:var(--background, var(--dl-elevated))}.dl-mk-host-ic{width:14px;height:14px}.dl-mk-av{position:relative;box-sizing:border-box;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:500;line-height:1;border:2px solid #8a8a8a;background:var(--dl-elevated);color:var(--dl-fg-muted);transition:box-shadow .2s}.dl-mk.online .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-badge{position:absolute;left:16px;bottom:-6px;height:16px;min-width:16px;padding:0 3px;border-radius:8px;border:2px solid var(--dl-elevated);background:#6b6b6b;color:#fff;display:flex;align-items:center;justify-content:center;gap:1px;font-size:9px;font-weight:600;white-space:nowrap;box-sizing:content-box}.dl-mk.online .dl-mk-badge{background:#3b82f6}.dl-mk-badge-ic{width:10px;height:10px;stroke-width:2.2}.dl-mk-badge:has(>svg:only-child){width:16px;min-width:0;padding:0}.dl-mk-tile{position:relative;width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk.place.online .dl-mk-tile{background:#3b82f6;color:#fff;box-shadow:0 2px 8px #3b82f659}.dl-mk-tile-ic{width:14px;height:14px}.dl-mk-tile-n{position:absolute;right:-5px;top:-5px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dl-fg);color:var(--dl-elevated);font-size:9px;font-weight:600;line-height:14px;text-align:center}.dl-mk-when{display:block;text-align:center;color:var(--dl-fg-faint);font-weight:400}.dl-mk.place.online .dl-mk-when{color:#3b82f6}.dl-mk-tile.sm{width:18px;height:18px;border-radius:5px;font-size:9px;font-weight:600}.dl-dmap{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-dmap .dl-geomap{border-top:0}.dl-dplaces{display:flex;flex-direction:column;margin-top:4px}.dl-dplace-row{display:flex;align-items:center;gap:10px;padding:9px 2px;border-top:1px solid var(--dl-line);font-size:13px}.dl-dplace-row:first-child{border-top:0}.dl-dplace-n{flex:0 0 auto;width:20px;height:20px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-dplace-n.live{background:#3b82f6;color:#fff}.dl-dplace-n .dl-icon{width:12px;height:12px}.dl-dplace-now{color:#3b82f6}.dl-dplaces.strips .dl-dplace-row{position:relative;display:grid;grid-template-columns:20px minmax(0,1fr) auto;column-gap:10px;row-gap:9px;margin:0 -10px;padding:11px 10px;border-top:0;border-radius:10px;transition:background .15s}.dl-dplaces.strips .dl-dplace-row+.dl-dplace-row:before{content:"";position:absolute;left:10px;right:10px;top:0;height:1px;background:var(--dl-line)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur){background:var(--dl-soft)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur):before,.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur)+.dl-dplace-row:before{opacity:0}.dl-dplace-strip{grid-column:2 / 4;position:relative;height:6px;border-radius:3px;background:var(--dl-track)}.dl-dplaces.can-replay .dl-dplace-strip{cursor:ew-resize;touch-action:none}.dl-dplace-strip i{position:absolute;top:0;bottom:0;min-width:2px;border-radius:2px;background:#8a8a8a}.dl-dplace-strip.live i{background:#3b82f6}.dl-dplaces.replay .dl-dplace-strip:after{content:"";position:absolute;left:var(--at);top:-4px;bottom:-4px;width:2px;margin-left:-1px;border-radius:1px;background:var(--dl-fg);box-shadow:0 0 0 2px var(--dialog-bg, var(--dl-elevated));pointer-events:none}.dl-dplace-axis{position:relative;height:16px;margin:4px 0 0 30px;font-size:11px;line-height:16px;color:var(--dl-fg-faint)}.dl-dplace-axis span{position:absolute;top:0;transform:translate(-50%);white-space:nowrap}.dl-dmap{position:relative}.dl-map-replay{position:absolute;left:10px;top:10px;z-index:3;display:flex;align-items:center;gap:6px}.dl-map-btn{all:unset;box-sizing:border-box;cursor:pointer;width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg)}.dl-map-btn:hover{background:color-mix(in srgb,var(--dl-fg) 8%,var(--dl-elevated))}.dl-map-btn:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-btn .dl-icon{width:13px;height:13px}.dl-map-chip{display:inline-flex;align-items:center;height:28px;box-sizing:border-box;padding:0 10px;border-radius:8px;font-size:11.5px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg);font-variant-numeric:tabular-nums}.dl-mk.step .dl-mk-tile{transition:width .3s cubic-bezier(.2,.8,.2,1),height .3s cubic-bezier(.2,.8,.2,1),border-radius .3s,background-color .3s,color .3s,box-shadow .3s,transform .24s}.dl-mk.step .dl-mk-tile.sm .dl-mk-tile-ic{width:11px;height:11px}.dl-mk.step.faded>*{opacity:.5}.dl-mk.step:is(.online,.hl){z-index:2}.dl-mk.step.hl .dl-mk-tile{box-shadow:0 0 0 3px color-mix(in srgb,#3b82f6 55%,transparent)}.dl-mk.step.arrive .dl-mk-tile{animation:dl-mk-arrive .45s cubic-bezier(.2,.8,.2,1)}@keyframes dl-mk-arrive{0%{transform:scale(.8)}55%{transform:scale(1.12)}to{transform:scale(1)}}.dl-mk-when.inline{display:inline}.dl-mk>*{transition:opacity .15s;opacity:var(--dl-mk-fade, 1)}.dl-mk.merged,.dl-mk.piled{pointer-events:none}.dl-mk.dl-mk-new>*{transition:none}.dl-mk.merged>*,.dl-mk.piled>*{opacity:0}.dl-mk-hub{cursor:default}.dl-mk-host{position:relative}.dl-mk-host{transition:border-radius .22s ease,border-right-color .22s ease}.dl-mk-host.docked{border-top-right-radius:0;border-bottom-right-radius:0;border-right-color:transparent}.dl-mk-dock{position:absolute;left:100%;top:-1px;height:40px;box-sizing:border-box;display:flex;align-items:center;gap:6px;padding:0 10px 0 2px;border:1px solid var(--dl-line);border-left:0;border-radius:0 11px 11px 0;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;pointer-events:none;opacity:0;clip-path:inset(-24px 100% -24px 0);transition:clip-path .28s cubic-bezier(.2,.8,.2,1),opacity .2s ease}.dl-mk-host.docked .dl-mk-dock{pointer-events:auto;opacity:1;clip-path:inset(-24px -24px -24px 0)}.dl-mk-new .dl-mk-host,.dl-mk-new .dl-mk-dock{transition:none}.dl-mk-pile{position:relative;display:flex;justify-content:center}.dl-mk-pile-box{box-sizing:border-box;height:40px;display:flex;align-items:center;gap:6px;padding:0 10px 0 6px;border-radius:20px;cursor:zoom-in;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;animation:dl-plate-in .26s cubic-bezier(.2,.8,.2,1) both;transition:opacity .18s ease,transform .18s ease}.dl-mk-pile.out{pointer-events:none}.dl-mk-pile.out>*{opacity:0;transform:scale(.85);transition:opacity .18s ease,transform .18s ease}@keyframes dl-plate-in{0%{opacity:0;transform:scale(.85)}}.dl-mk-face{all:unset;position:relative;display:flex;cursor:pointer;transition:transform .18s ease,opacity .18s ease}.dl-mk-face>.dl-mk-badge{position:relative;left:auto;bottom:-8px;margin-left:-12px;align-self:center}.dl-mk-face.on .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-face.on .dl-mk-badge{background:#3b82f6}.dl-mk-face:hover .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-face.in{animation:dl-dock-in .24s cubic-bezier(.2,.8,.2,1) both}.dl-mk-face.out{transform:scale(.4);opacity:0;pointer-events:none}@keyframes dl-dock-in{0%{transform:scale(.4);opacity:0}}.dl-mk-more{font-size:11px;font-weight:600;color:var(--dl-fg-muted)}.dl-mk-av,.dl-mk-tile{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1)}.dl-mk.merged .dl-mk-av,.dl-mk.merged .dl-mk-tile,.dl-mk.piled .dl-mk-av{transform:scale(.5)}.dl-mk-host,.dl-mk-dock,.dl-mk-pile-box{transition-property:border-radius,border-right-color,clip-path,opacity,height,width,padding,gap}.dl-mk-dock,.dl-mk-pile-box{transition-duration:.22s;transition-timing-function:cubic-bezier(.2,.8,.2,1)}.dl-mk-pile-box{position:relative}.dl-mk-more{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease}.dl-mk-more.in{animation:dl-dock-in .24s ease both}.dl-mk-more.out{transform:scale(.4);opacity:0}.dl-mk-face .dl-mk-av{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1),width .2s ease,height .2s ease,font-size .2s ease}.dl-mk-face{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease,margin .2s ease}.dl-mk-face>.dl-mk-badge{max-width:48px;overflow:hidden;transition:opacity .2s ease,transform .2s ease,max-width .22s ease,margin .22s ease,padding .22s ease,border-width .22s ease,height .22s ease,min-width .22s ease,width .22s ease,bottom .22s ease}.dl-lod-far .dl-mk-host{width:32px;height:32px;border-radius:9px}.dl-lod-far .dl-mk-host.docked{border-radius:9px 0 0 9px}.dl-lod-far .dl-mk-host-tile{width:20px;height:20px;border-radius:6px}.dl-lod-far .dl-mk-host-ic{width:11px;height:11px}.dl-lod-far .dl-mk-dock{height:32px;gap:0;padding:0 4px 0 0;border-radius:0 9px 9px 0}.dl-lod-far .dl-mk-pile-box{height:32px;gap:0;padding:0 4px;border-radius:16px}.dl-lod-far .dl-mk-face+.dl-mk-face{margin-left:-6px}.dl-lod-far .dl-mk-face .dl-mk-av{width:22px;height:22px;font-size:8px;box-shadow:0 0 0 2px var(--dl-elevated)}.dl-lod-far .dl-mk-face>.dl-mk-badge{max-width:0;min-width:0;padding:0;margin-left:0;border-width:0;opacity:0;transform:scale(.5);pointer-events:none}.dl-lod-far .dl-mk-more{margin-left:4px;font-size:10px}.dl-mk-label{transition:opacity .2s ease}.dl-lod-far .dl-mk:not(.step) .dl-mk-label{opacity:0}.dl-lod-mid .dl-mk-host{width:36px;height:36px}.dl-lod-mid .dl-mk-dock,.dl-lod-mid .dl-mk-pile-box{height:36px}.dl-lod-mid .dl-mk-face .dl-mk-av{width:24px;height:24px;font-size:9px}.dl-lod-mid .dl-mk-face>.dl-mk-badge{height:12px;min-width:12px;margin-left:-10px;bottom:-7px}.dl-lod-mid .dl-mk-face>.dl-mk-badge:has(>svg:only-child){width:12px}.dl-lod-mid .dl-mk-face>.dl-mk-badge .dl-mk-badge-ic{width:8px;height:8px}@media(prefers-reduced-motion:reduce){.dl-mk-dock,.dl-mk-pile-box,.dl-mk-face,.dl-mk-av,.dl-mk-tile,.dl-mk.step .dl-mk-tile,.dl-mk-host,.dl-mk-face>.dl-mk-badge{transition:none;animation:none}}.dl-mk-hub:has(.dl-mk-host.docked) .dl-mk-host{cursor:zoom-in}.dl-mk-ptr{position:absolute;left:50%;top:50%;width:0;height:0;z-index:-1;pointer-events:none}.dl-mk-ptr .line{position:absolute;left:0;top:-.5px;height:1px;background:var(--dl-fg-faint);transform-origin:0 50%}.dl-mk-ptr .spot{position:absolute;left:-3.5px;top:-3.5px;width:7px;height:7px;border-radius:50%;box-sizing:border-box;border:1.5px solid #fff;background:#8a8a8a}.dl-mk.online .dl-mk-ptr .spot,.dl-mk.place.online .dl-mk-ptr .spot{background:#3b82f6}.dl-mk.dim>*{opacity:.18}.dl-mk.hl .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-label{position:absolute;left:50%;bottom:100%;margin-bottom:4px;transform:translate(-50%);white-space:nowrap;pointer-events:none;font-size:10px;line-height:14px;font-weight:500;color:var(--dl-fg)}.dl-mk-label.below{bottom:auto;top:100%;margin:4px 0 0}.dl-mk-label.chip{padding:2px 6px;border-radius:4px;font-size:11px;line-height:16px;font-weight:600;background:color-mix(in srgb,var(--background, var(--dl-card)) 80%,transparent);backdrop-filter:blur(8px)}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact{margin:0 10px 10px 0;min-height:28px;padding:0;border-radius:8px;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg-muted);box-shadow:none;font-size:11px;line-height:26px}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show){width:28px;height:28px;box-sizing:border-box}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show{padding:0 32px 0 10px}.dl-geomap .maplibregl-ctrl-attrib a{color:var(--dl-fg-muted)}.dl-geomap .maplibregl-ctrl-attrib-button{top:0;right:0;width:26px;height:26px;margin:0;border-radius:8px;background:none}.dl-geomap .maplibregl-ctrl-attrib-button:after{content:"";position:absolute;inset:5px;background:var(--dl-fg);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat}.dl-geomap .maplibregl-ctrl-attrib-button:focus{outline:none;box-shadow:none}.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-card{position:absolute;right:12px;top:12px;z-index:3;min-width:200px;max-width:260px;padding:10px 12px;border-radius:10px;font-size:12px;line-height:20px;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));opacity:0;transition:opacity .2s;pointer-events:none}.dl-map-card.on{opacity:1}.dl-map-card-head b{font-weight:500}.dl-map-card-row{display:flex;justify-content:space-between;gap:12px;white-space:nowrap}.dl-popcard{position:fixed;z-index:2100;width:max-content;max-width:300px;padding:12px;border-radius:12px;box-sizing:border-box;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4))}.dl-popcard.away{visibility:hidden}.dl-popcard.leaving{pointer-events:none}.dl-popcard-tip{position:absolute;left:var(--tip-x, 50%);width:10px;height:10px;margin-left:-6px;box-sizing:border-box;background:var(--dl-elevated);border:solid var(--dl-line);transform:rotate(45deg)}.dl-popcard.above .dl-popcard-tip{bottom:-6px;border-width:0 1px 1px 0}.dl-popcard.below .dl-popcard-tip{top:-6px;border-width:1px 0 0 1px}.dl-popcard.above{transform-origin:var(--tip-x, 50%) 100%}.dl-popcard.below{transform-origin:var(--tip-x, 50%) 0}@media(prefers-reduced-motion:no-preference){.dl-popcard{animation:dl-pop-in .16s ease-out}.dl-popcard.leaving{animation:dl-pop-out .14s ease-in forwards}}@keyframes dl-pop-in{0%{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}@keyframes dl-pop-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.94)}}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px 0 0;max-height:116px;overflow-y:auto}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;flex:0 0 auto;--dl-gap: 2px}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}.dl-spark>span:hover i:not(.zero){opacity:1;filter:brightness(1.25)}.dl-spark>span,.dl-dbars>span,.dl-bento-bars>span{flex:1;min-width:0;height:100%;display:flex;align-items:flex-end;padding:0 calc(var(--dl-gap) / 2)}.dl-spark>span:first-child,.dl-dbars>span:first-child,.dl-bento-bars>span:first-child{padding-left:0}.dl-spark>span:last-child,.dl-dbars>span:last-child,.dl-bento-bars>span:last-child{padding-right:0}`;var Ta=`.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}`;var Sa=".dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";var Pa=".dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*:not(.alert-message):not(.dl-params){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*{border-top:0}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-root input.dl-w-range{flex:0 0 130px;width:130px}.dl-setrow .dl-sub.bad{color:var(--dl-bad)}.dl-suffixed{display:inline-flex;align-items:center;gap:6px}.dl-suffixed>span{color:var(--dl-fg-muted)}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-bad{color:var(--dl-bad)}";var $a=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var Da=".dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row{margin-top:8px}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host-ports{justify-content:flex-end}@media(max-width:760px){.dl-host-ports{justify-content:flex-start}}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var td=[ba,xa,wa,ya,ka,_a,Ca,La,Ma,Ea,Ta,Sa,Pa,$a,Da].join(` -`);function Aa(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=td,n}function yt(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async s=>{let r=await e.render(s),a=document.createElement("div");return a.className="dl-root",a.append(Aa(),r),a},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var Jb=yt(on),Zb=yt(wt),Qb=yt(on),Xb=yt(On),e0=yt(Gn),t0=yt(Yn),n0=yt(Wn);function Na(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var o0=Na(""),s0=Na("log");return baseclass.extend({ activity: s0, diagnostics: t0, health: o0, overview: Jb, people: Zb, person: e0, server: Qb, settings: Xb, updates: n0 }); +`).trim()}async function an(n,e,o,s){let r=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},_("Loading release notes…"))),a=t("div",{class:"dl-op-head"}),i="";de(o,[a,r],[N([g("copy")," ",_("Copy")],()=>xe(i,_("Release notes copied")))," ",ue(_("Close"))],"wide");try{let l=await H.updatesNotes(n,e,s??"");i=Zr(l.body||"");let d=Yr(l.url);dom.content(a,[l.published?t("span",{class:"dl-pill"},Be(l.published)):"",l.prerelease?t("span",{class:"dl-pill warn"},_("Pre-release")):"",t("span",{class:"dl-spacer"}),d?t("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},[_("On GitHub")," ",g("open")]):""]),dom.content(r,i.trim()?Jr(i):t("p",{class:"dl-muted"},_("This release has no notes.")))}catch(l){dom.content(r,t("p",{class:"dl-muted"},Ce(l)))}}function Ll(n){let e={"6h":_("checks every 6 h"),"12h":_("checks every 12 h"),"1d":_("checks daily"),"7d":_("checks weekly")};return e[n]??e["1d"]}var jo=n=>n?Be(n):"";function Ml(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function Xr(n,e){let o=n.st,s=o.policy,r=o.kept?.app,a=e?.update&&e.tag?e.tag:o.version,i=v=>()=>an("app",v,m(_("What’s new in Dawnline %s"),v.replace(/^v/,""))),l=e?.tag&&(e.update||e.status==="latest")?El(n,e.tag,e.update?o.version:""):null,d=e?.tag??a,c=s.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[s.interval]??24)*3600:0,p=(v,M)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},v),t("span",{class:"dl-comp-side-v"},M)]),u=[{label:_("What’s new"),ic:"file",run:i(a)},{label:_("Open on GitHub"),ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:m(_("Reinstall %s"),o.version),ic:"reset",warn:!0,run:()=>n.op("app:reinstall",_("Reinstalling Dawnline"),o.version)},r?{label:m(_("Roll back to %s"),r.version),ic:"archive",warn:!0,run:async()=>{await me(m(_("Roll back to Dawnline %s?"),r.version),m(_("The copy kept on the router replaces %s. A backup of the settings is made first."),o.version),_("Roll back"))&&n.op("app:rollback",_("Rolling back Dawnline"),o.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},g("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app",_("Checking Dawnline"),o.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[o.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},m(_("release %s"),e.latest)):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?m(_("released %s"),jo(e.published)):"":e?.status==="dev"?_("ahead of the latest release"):e?[_("latest release"),e.published?m(_("released %s"),jo(e.published)):""].filter(Boolean).join(" · "):_("not checked yet"))])]),l?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},l.items.map(v=>t("li",{},v))),l.total>l.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:i(d)},W(l.total-l.items.length,"+%s more in What’s new","+%s more in What’s new")):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[N(_("Update now"),()=>n.op("app",_("Updating Dawnline"),o.version),"positive",{disabled:n.busy}),N(_("What’s new"),i(a))]):"",Sl(n),Tl(n)]),t("div",{class:"dl-comp-hero-side"},[p(_("Source"),[g("globe"),t("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p(_("Auto-update"),[s.auto?Se("ok",_("On")):Se("",_("Off")),t("span",{class:"dl-muted"},s.auto?s.mode==="immediate"?_("as soon as found"):m(s.interval==="7d"?_("weekly at %s"):_("daily at %s"),s.time):s.check?Ll(s.interval):_("checks off"))]),p(_("Last check"),o.check?[pe(o.check.time,o.now),c>o.now?t("span",{class:"dl-faint"},`· ${m(_("next in %s"),ot(c-o.now))}`):""]:[_("Never")]),p(_("Rollback"),r?[t("span",{class:"dl-mono"},r.version),t("span",{class:"dl-faint"},_("kept on flash"))]:[t("span",{class:"dl-muted"},s.keep?_("Kept after the next update"):_("Off"))])])])}function El(n,e,o){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let s=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(a,i)=>i??"").trim();return(async()=>{let a=((await H.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` +`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);a.length||(a=(await H.updatesChanges(o,e).catch(()=>null))?.items??[]);let i={items:a.slice(0,3).map(l=>Ml(s(l))),total:a.length};n.notes.set(e,i),i.items.length&&n.root.isConnected&&n.paint()})(),null}function Wn(n){return n==="ru"?_("Russian translation"):n}function Tl(n){let e=(n.st.translations??[]).includes("ru"),o=ye(e,Wn("ru"),r=>{n.op(r?"app:lang:ru":"app:nolang",r?_("Adding the Russian translation"):_("Removing the Russian translation"),n.st.version)});o.disabled=n.busy;let s=t("details",{class:"dl-params dl-comp-fold",open:n.langOpen?"open":null},[t("summary",{},[g("chevron"),t("span",{},_("Translation")),t("span",{class:"dl-sub"},e?_("Russian"):_("English only"))]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},Wn("ru")),t("span",{class:"dl-sub"},_("LuCI pages for Dawnline"))]),t("span",{class:"dl-comp-bact"},o)])])])]);return s.addEventListener("toggle",()=>n.langOpen=s.open),s}function Sl(n){let e=t("div",{class:"dl-params-body"}),o=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[g("chevron"),t("span",{},_("Versions")),t("span",{class:"dl-sub"},_("install any release"))]),e]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&Gn(n,e)}),n.versOpen&&Gn(n,e),o}async function Gn(n,e){let o=he("",{placeholder:_("Tag, e.g. 0.3.1"),class:"cbi-input-text dl-mono","aria-label":_("Release tag")}),s=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return q(_("Enter a release tag like 0.3.1"),"warning");Qr(n,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),s(o.value))});let r=t("div",{class:"dl-comp-tag"},[o,N(_("Install"),()=>s(o.value),"neutral",{disabled:n.busy})]),a=n.versPage,i=p=>{n.versPage=Math.max(1,n.versPage+p),Gn(n,e)},l=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:a<=1?"disabled":null,click:()=>i(-1)},_("← Newer")),t("span",{class:"dl-faint"},m(_("Page %s"),a)),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>i(1)},_("Older →"))]),d=n.versCache.get(a);if(!d){dom.content(e,[r,t("p",{class:"dl-muted dl-loading"},_("Loading versions…"))]);try{d=(await H.updatesReleases(a)).releases}catch(p){if(a!==n.versPage||!e.isConnected)return;dom.content(e,[r,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},m(_("Failed to load versions: %s"),Ce(p))),N(_("Try again"),()=>Gn(n,e))]),l(!1)]);return}if(n.versCache.set(a,d),a!==n.versPage||!e.isConnected)return}if(!d.length)return dom.content(e,[r,t("p",{class:"dl-muted"},a>1?_("No more versions."):_("No versions found.")),l(!1)]);let c=n.st.version;dom.content(e,[r,...d.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},jo(p.published)),p.prerelease?Se("warn",_("Pre-release")):"",t("span",{class:"dl-comp-ic"},Pe("file",_("What’s new"),()=>an("app",p.tag,m(_("What’s new in Dawnline %s"),u)))),u===c?Se("ok",_("Installed")):N(_("Install"),()=>Qr(n,p.tag),"neutral",{disabled:n.busy})])}),l(d.length>=5)])}async function Qr(n,e){let o=e.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await me(m(_("Install Dawnline %s?"),o),m(_("It is older than %s. A backup of the settings is made first; restore it from Settings if something looks wrong."),n.st.version),_("Install"))||n.op(`app@${e}`,m(_("Installing Dawnline %s"),o),n.st.version)}function ea(n,e){let o=n.st,s=o.kept?.amneziawg,r=e?.sources??{},a=Object.keys(r),i=e?.current??null,l=i?r[i]:void 0,d=!!e?.ru,c=o.needs?.awg??[],p=c.length?null:e?.installed??null,u=[];i&&p&&u.push({label:_("Reinstall this build"),warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${i}${d?":ru":""}`,_("Reinstalling AmneziaWG"),p)}),s&&u.push({label:m(_("Roll back to %s"),s.version),ic:"archive",warn:!0,run:async()=>{await me(m(_("Roll back AmneziaWG to %s?"),s.version),_("The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."),_("Roll back"))&&n.op("amneziawg:rollback",_("Rolling back AmneziaWG"),p??void 0)}});let v=[e?.release?{label:_("What’s new"),ic:"file",run:()=>an("amneziawg",e.release,m(_("What’s new in the %s build"),l?.label??"AmneziaWG"),i??"slava")}:null,{label:_("Open on GitHub"),ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((w,f,T)=>w!==null||f>0&&T[f-1]!==null),M=o.tunnels??[],x=M.length?M.length===1?m(_("Switching restarts the tunnel for a few seconds: %s. Devices keep their configurations."),M[0]):m(N_(M.length,"Switching restarts %s tunnel for a few seconds: %s. Devices keep their configurations.","Switching restarts %s tunnels for a few seconds: %s. Devices keep their configurations."),V(M.length),M.join(", ")):_("Switching takes a few seconds. Devices keep their configurations."),h=M.length>1?m(_("%s and %s"),M.slice(0,-1).join(", "),M[M.length-1]):M[0],S=M.length?m(_("Switching restarts %s for a few seconds."),h):_("Switching takes a few seconds."),z=async w=>{let f=r[w];await me(p?m(_("Switch to AmneziaWG %s?"),f.gen):m(_("Install AmneziaWG %s?"),f.gen),[m(_("The %s build, %s."),f.label,f.version),x,f.gen==="3.1"?_("Devices need AmneziaVPN 3.1 or newer."):""].filter(Boolean).join(" "),p?_("Switch"):_("Install"))&&n.op(`amneziawg:${w}${d?":ru":""}`,p?m(_("Switching to AmneziaWG %s"),f.gen):_("Installing AmneziaWG"),p??void 0)},E=w=>{let f=r[w],T=i===w&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},f.gen?`AmneziaWG ${f.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${f.label} · ${f.gen==="3.1"?"AmneziaVPN 3.1+":_("every app")}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},f.version??_("none yet")),t("span",{class:"dl-comp-bact"},T?Se("ok",_("Active","build")):f.version?N(p?_("Switch"):_("Install"),()=>z(w),p?"neutral":"positive",{disabled:n.busy}):Se("",_("No build")))])},$=a.map(w=>r[w]?.newer?m(_("%s moves to %s with OpenWrt %s."),r[w].label,r[w].newer.gen,r[w].newer.tag.replace(/^v/,"")):"").filter(Boolean),b=ye(d,_("Russian translation"),w=>{i&&n.op(`amneziawg:${i}${w?":ru":""}`,w?_("Adding the Russian translation"):_("Removing the Russian translation"),p??void 0)});b.disabled=!i||!p||n.busy;let k=n.awgOpen??!p,y=t("details",{class:"dl-params dl-comp-fold",open:k?"open":null},[t("summary",{},[g("chevron"),t("span",{},_("Build and translation"))]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[...a.length?a.map(E):[t("div",{class:"dl-row"},t("span",{class:"dl-sub"},_("Check for updates to see the builds for this router.")))],t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},_("Russian translation")),t("span",{class:"dl-sub"},_("LuCI pages for AmneziaWG"))]),t("span",{class:"dl-comp-bact"},b)])]),p&&a.length||$.length?t("div",{class:`dl-comp-status ${p&&a.length?"warn":"acc"}`},[g(p&&a.length?"alert":"download"),t("span",{},[p&&a.length?t("b",{},S):"",...$.map(w=>` ${w}`)])]):""])]);y.addEventListener("toggle",()=>n.awgOpen=y.open);let I=[];return e?.update&&p&&i?I.push(N(m(_("Update to %s"),e.latest),()=>n.op(`amneziawg:${i}${d?":ru":""}`,_("Updating AmneziaWG"),p),"neutral",{disabled:n.busy})):I.push((e||c.length)&&!p?Se("warn",_("Not installed")):n.state("amneziawg",e,e?.latest??"")),I.push(n.round(()=>n.op("check:amneziawg",_("Checking AmneziaWG"),p??void 0),v)),[n.row("shield","AmneziaWG",[p?`${p}${e?.release?` · ${m(_("%s build"),e.release)}`:""}`:c.length?m(_("missing %s"),c.join(", ")):e?_("not installed"):_("version not checked")],I),t("div",{class:"dl-comp-foldwrap"},y)]}function Pl(){return[{title:_("Home-like link"),sub:_("Policy routing and the veth pair"),pkgs:["ip-full","kmod-veth"],feature:"home"},{title:_("HTTPS for the portal"),sub:_("OpenSSL for uhttpd"),pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:_("Certificates (ACME)"),sub:_("Let’s Encrypt certificate for the portal"),pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}]}var Uo={home:"network",https:"lock",acme:"file"};function ta(n,e){let o=n.st,s=e?.pkgs??{},r=Pl().filter(c=>c.feature==="home"?o.home:o.portal),a=async(c,p,u=c)=>{await me(m(_("Update %s?"),p),m(_("%s from the OpenWrt feeds. Services that use them restart for a moment."),u.join(", ")),_("Update"))&&n.op(`pkgs:${c.join(",")}`,m(_("Updating %s"),p))},i=[{label:_("Check system packages"),ic:"refresh",run:()=>n.op("check:packages",_("Checking system packages"))},{label:_("Open the OpenWrt package list"),ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],l=0;return{rows:r.map(c=>{let p=c.pkgs.filter(h=>s[h]?.installed),u=[...new Set(p.flatMap(h=>[...s[h]?.latest?[h]:[],...s[h]?.with??[]]))],v=o.needs?.[c.feature]??c.pkgs.filter(h=>!s[h]?.installed),M=p.find(h=>s[h]?.latest),x=p.map(h=>`${h} ${s[h]?.installed??""}`).join(", ");return v.length?n.row(Uo[c.feature],c.title,[c.optional?_("not installed"):m(_("missing %s"),v.join(", "))],[N(_("Install"),()=>n.op(`pkgs:${v.join(",")}`,m(_("Installing %s"),c.title)),c.optional?"neutral":"positive",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(i))]):e&&u.length?(l++,n.row(Uo[c.feature],c.title,M?[`${s[M].installed} → ${s[M].latest}`,u.length>1?` · +${u.length-1}`:""]:[u.join(", ")],[N(_("Update"),()=>a(p.filter(h=>s[h]?.latest||s[h]?.with?.length),c.title,u),"neutral",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(i))])):n.row(Uo[c.feature],c.title,[x||c.sub],[n.state("pkgs",e,""),t("span",{class:"dl-comp-ic"},n.more(i))])}),updates:l,total:r.length}}function $l(n){return n==="app"?"Dawnline":n==="amneziawg"?"AmneziaWG":n==="pkgs"?_("System packages"):_("Components")}function Dl(n){let e=/^(\d+) system packages?$/.exec(n)?.[1];return e?W(Number(e),"%s system package","%s system packages"):n}function na(n){let e=n.st,o=r=>{let a=mt(r.component??"app"),i=t("b",{},$l(a)),l="ok",d="check",c;if(r.kind==="found")l="accent",d="download",c=oe(r.auto?_("%s found by the automatic check"):_("%s found by a check"),t("b",{},(r.items??[]).map(Dl).join(", ")));else if(r.state==="failed")l="bad",d="x",c=[...oe(r.kind==="install"?_("%s update failed"):_("%s check failed"),i),r.error?` · ${r.error}`:""];else if(/^app:(lang:|nolang$)/.test(r.component??"")){let p=/^app:lang:(.+)$/.exec(r.component??"")?.[1];c=p?oe(_("%s added by you"),t("b",{},Wn(p))):[_("Translation removed by you")]}else{let p=r.from&&r.to&&r.from!==r.to?`${r.from} → ${r.to}`:r.to??"";c=[...p?oe(r.auto?_("%s %s automatically"):_("%s %s by you"),i,p):oe(r.auto?_("%s updated automatically"):_("%s updated by you"),i),r.took?` · ${ot(r.took)}`:""]}return t("div",{class:"dl-row"},[t("span",{class:`dl-ev-tile ev ${l}`},g(d)),t("span",{class:"dl-row-main"},c),t("span",{class:"dl-faint dl-nowrap",title:new Date(r.ts*1e3).toLocaleString(le())},pe(r.ts,e.now))])},s=e.history??[];return t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Activity")),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},_("All in Log →"))]),s.length?t("div",{},s.slice(0,8).map(o)):t("p",{class:"dl-sub dl-comp-empty"},_("Updates, and checks that found something, show up here."))])}var qn=class{constructor(){this.root=t("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null;this.langOpen=!1}load(){return H.updatesStatus()}render(e){return this.st=e,this.paint(),e.job?.state==="running"&&this.follow(e.job),poll.add(async()=>{if(!this.root.isConnected)return;let o=await H.updatesStatus().catch(()=>null);if(!o)return;let s=this.st;this.st=o,o.job?.state==="running"&&this.following!=="starting"&&o.job.id!==this.following&&this.follow(o.job),(o.job?.id!==s.job?.id||o.job?.state!==s.job?.state||o.job?.phase!==s.job?.phase||o.check?.time!==s.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(e){this.st=e??await H.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(e,o,s){if(this.busy||this.following==="starting"){q(_("Another component action is already running"),"warning");return}this.following="starting",this.paint();let r=mt(e),a=await on(e,{title:o,version:s,onJob:i=>this.following=i.id,onDone:i=>this.refresh(i),onUpdate:i=>{let l=i.check?.components??{};r==="amneziawg"&&l.amneziawg?.current?this.op(`amneziawg:${l.amneziawg.current}${l.amneziawg.ru?":ru":""}`,_("Updating AmneziaWG"),l.amneziawg.installed??void 0):this.op("app",_("Updating Dawnline"),this.st.version)}});this.following==="starting"&&(this.following=a?.id??null),this.refresh()}async follow(e){this.following=e.id;let o={app:[_("Checking Dawnline"),_("Automatic update: Dawnline"),_("Updating Dawnline")],amneziawg:[_("Checking AmneziaWG"),_("Automatic update: AmneziaWG"),_("Updating AmneziaWG")],pkgs:[_("Checking system packages"),_("Automatic update: system packages"),_("Updating system packages")],all:[_("Checking components"),_("Automatic update: components"),_("Updating components")]};await on(null,{title:(o[Hn(e)]??o.all)[e.action==="check"?0:e.auto?1:2],onDone:s=>this.refresh(s)},e)}paint(){let e=this.st,o=e.check?.components??{},s=e.firmware,r=ta(this,o.packages),a=(e.needs?.awg??[]).length>0,l=(!a&&o.amneziawg?.update&&o.amneziawg.installed?1:0)+r.updates;dom.content(this.root,[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},_("Components")),t("span",{class:"dl-faint"},[s?.version?`OpenWrt ${s.version} · ${s.target}`:"",e.check?m(_("checked %s"),pe(e.check.time,e.now)):_("not checked yet")].filter(Boolean).join(" · "))]),t("div",{class:"dl-row-actions"},[t("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[g("edit")," ",_("Settings")]),N([g("refresh")," ",_("Check all")],()=>this.op("check",_("Checking all components")),"neutral",{disabled:this.busy})])]),Xr(this,o.app),t("div",{class:"dl-comp-cols"},[t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Components")),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-comp-count"},a?l?`${_("AmneziaWG not installed")} · ${W(l,"%s update","%s updates")}`:_("AmneziaWG not installed"):!o.amneziawg&&!o.packages?"":l?m(N_(l,"%s of %s needs an update","%s of %s need an update"),V(l),V(1+r.total)):_("Everything is up to date"))]),t("div",{},[...ea(this,o.amneziawg),...r.rows])]),na(this)])])}state(e,o,s){let r=this.st.job;if(r?.state==="running"){let a=l=>l==="packages"?"pkgs":l,i=r.action==="check"?[a(r.component||"all")]:(r.component??"").split(" ").map(l=>a(mt(l)));if(i.includes(e)||i.includes("all"))return t("button",{type:"button",class:"dl-pill info dl-comp-run",title:_("Show progress"),click:()=>this.follow(r)},[r.action==="check"?_("Checking…"):_("Updating…")])}return o?o.error?Se("warn",_("Check failed"),o.error):o.update?Se("info",_("Update available")):o.status==="dev"?Se("info",_("Newer than release"),m(_("The latest release is %s"),s)):Se("ok",_("Up to date")):Se("",_("Not checked"))}more(e){let o=N([g("more")],()=>Te(o,e.filter((s,r,a)=>s!==null||r>0&&rs?{label:s.label,icon:g(s.ic),warn:s.warn,run:s.run}:null)),"neutral",{title:_("More"),"aria-label":_("More")});return o}round(e,o,s=!1){let r=this.busy?" is-busy":"",a;return s?a=N([g("refresh")," ",_("Check")],e,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${r}`,"aria-label":_("Check for updates")}):(a=Pe("refresh",_("Check for updates"),e,"neutral",r.trim()),a.removeAttribute("title"),a.setAttribute("aria-label",_("Check for updates")),we(a,()=>[_("Check for updates")])),t("span",{class:"dl-comp-ic"},[a,this.more(o)])}row(e,o,s,r){return t("div",{class:"dl-row"},[t("span",{class:"dl-group-ic"},g(e)),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-mono dl-faint dl-comp-sub"},s)]),...r])}};var oa=(n,e)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},n),t("div",{class:"cbi-value-field"},e)]);function sa(n){let e=n.st.servers.find(o=>o.id===n.p.server)?.name??_("Home");tn(n.p,e)}async function ra(n){let e=n.p,o=e.code_set??0,s=e.devices.filter(l=>l.created_by==="portal"&&l.created>=o),r=s.map(l=>t("input",{type:"checkbox",id:`dl-rm-${l.id}`,checked:"checked","data-id":l.id})),a=[t("p",{},_("The old link stops working right away."))];s.length&&a.push(t("p",{},_("Devices added through the old link keep working until they are removed. Remove them too:")),t("div",{class:"dl-checklist"},s.map((l,d)=>t("label",{for:`dl-rm-${l.id}`},[r[d],` ${l.name}`]))));let i=async()=>{let l=r.filter(c=>c.checked).map(c=>c.dataset.id),d=await K(()=>H.personRegen(e.id,l),l.length?W(l.length,"New link created, %s device removed","New link created, %s devices removed"):_("New link created"));d&&(ce(),l.length&&await n.refresh(),d.link&&await xe(d.link,_("New link copied")))};de(_("Create a new link?"),a,[ue()," ",N(_("Create new link"),i,"negative")])}function Wo(n){let e=t("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:_("Only you see this")},n.p.note??"");de(_("Note"),[e],[ue()," ",N(_("Save"),async()=>{ce(),await n.patch({note:e.value.trim()},e.value.trim()?_("Note saved"):_("Note removed"))},"positive")]),setTimeout(()=>e.focus(),50)}function aa(n){let e=n.p,o=t("select",{class:"cbi-input-select"},[t("option",{value:"pause",selected:e.expire_action==="pause"?"selected":null},_("Pause access")),t("option",{value:"notify",selected:e.expire_action==="notify"?"selected":null},_("Keep access")),t("option",{value:"remove",selected:e.expire_action==="remove"?"selected":null},_("Remove their devices"))]),s=t("select",{class:"cbi-input-select"},[0,1,3,7,14].map(r=>t("option",{value:r,selected:e.expire_warn===r?"selected":null},r?W(r,"%s day before","%s days before"):_("Don’t warn"))));de(_("When access ends"),[oa(_("Then"),o),t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},_("Warn")),t("div",{class:"cbi-value-field"},[s,t("div",{class:"cbi-value-description"},_("Shown in their portal and on the Overview."))])])],[ue()," ",N(_("Save"),async()=>{ce(),await n.patch({expire_action:o.value,expire_warn:s.value},_("Saved"))},"positive")])}function ia(n){let e=t("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48}),o=Me(_("Name","person"),e,()=>Ne(e.value,[],_("Shown in their portal and apps.")));de(_("Rename"),[o],[ue()," ",N(_("Save"),async()=>{let s=o.help();if(s.bad){q(s.text,"warning");return}await n.patch({name:e.value.trim()},_("Renamed"))&&ce()},"positive")]),setTimeout(()=>e.select(),50)}function la(n){let e=n.p,o=n.st.servers.filter(a=>a.id!==e.server),s=t("select",{class:"cbi-input-select"},o.map(a=>t("option",{value:a.id},`${a.name} · ${a.endpoint||_("no address")}:${a.port}`))),r=e.devices.length;de(m(_("Move %s to another server"),e.name),[oa(_("Server"),s),t("p",{class:"dl-muted"},r?W(r,"%s device gets a new address and stops connecting until it imports its configuration again (from the personal link or from you). Circles and home networks of the old server are left behind.","%s devices get new addresses and stop connecting until they import their configuration again (from the personal link or from you). Circles and home networks of the old server are left behind."):_("They have no devices yet: nothing else changes."))],[ue()," ",N(_("Move"),async()=>{await n.patch({server:s.value},m(_("Moved to %s"),o.find(a=>a.id===s.value)?.name??_("the server")))&&(ce(),r&&q(_("Devices are marked “Update config” until they import again."),"info",6e3))},"positive")])}async function da(n){let e=n.p;await me(m(_("Delete %s?"),e.name),W(e.devices.length,"%s device is disconnected immediately and the personal link stops working.","All %s devices are disconnected immediately and the personal link stops working."),_("Delete"),!0)&&await K(()=>H.personDelete(e.id),_("Deleted"))&&(location.href=Bt(e.server))}function ca(n){let e=n.p,o=n.st,s=e.online?_("online now"):e.last_seen?m(_("last seen %s"),pe(e.last_seen,o.now)):_("never connected"),r=e.created?m(_("Added %s","date"),$e(Fe(new Date(e.created*1e3)))):"",a=e.has_link??o.settings.portal_enabled,i=[{label:_("Rename"),icon:g("edit"),run:()=>ia(n)},{label:e.note?_("Edit note"):_("Add note"),icon:g("file"),run:()=>Wo(n)},...o.servers.length>1?[{label:_("Move to server…"),icon:g("server"),run:()=>la(n)}]:[],...a?[null,{label:_("Invite card"),icon:g("qr"),run:()=>sa(n)},{label:_("New link"),icon:g("key"),run:()=>ra(n)}]:[],null,...e.paused?[]:[{label:_("Pause"),icon:g("pause"),warn:!0,run:()=>n.patch({paused:!0},_("Paused"))}],{label:_("Delete"),icon:g("trash"),danger:!0,run:()=>da(n)}];return t("div",{class:"dl-person-head"},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-person-id"},[t("span",{class:`dl-avatar lg${e.online?" online":""}`},Oe(e.name)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),ts(e)]),t("span",{class:"dl-faint",title:r},`${m(N_(e.device_limit,"%s of %s device","%s of %s devices"),e.devices.length,e.device_limit)} · ${s}`)])]),t("div",{class:"dl-pcard-actions"},[e.paused?N([g("play"),` ${_("Resume")}`],()=>n.patch({paused:!1},_("Resumed")),"add"):"",a?Pe("link",_("Copy link"),()=>$n(e.id),"neutral","dl-icon-only"):"",Pe("more",_("More"),l=>Te(l.currentTarget,i),"neutral","dl-icon-only")])]),e.note?t("button",{type:"button",class:"dl-pnote",title:_("Edit note"),click:()=>Wo(n)},[g("file"),t("span",{},e.note)]):""])}function pa(n){let e=n.p,o=n.series[n.series.length-1];return t("div",{class:`dl-person-live${e.online?"":" solo"}`},[e.online?In(e.rate??[],n.st.now,o?[o.rx,o.tx]:[0,0]):"",Bn(n.series,m(_("%s this month"),re(e.month[0]+e.month[1])))])}async function Al(n,e){let o=await K(()=>H.deviceConfig(e.id));o&&de(m(_("Set up %s"),e.name),[await n.core.connectBlock(o,"qr")],[ue(_("Close"))])}async function Nl(n,e){let o=await K(()=>H.deviceConfig(e.id));if(!o)return;if(!o.has_private_key){q(_("This device made its own keys in the browser; its configuration only exists there."),"warning");return}let s=n.core.file.make(o);Ae(s.name,s.text,"application/octet-stream")}function ua(n){let e=n.p,o=n.st.now,s=d=>Ye(e,d,n.deviceOpts()),r=d=>c=>{c.target.closest("button:not(.dl-dcard-title), a")||s(d)},a=d=>N([g("more")],c=>mr(c.currentTarget,e,d,n.deviceOpts()),"neutral",{title:_("QR, file, key, rename, new keys, remove"),class:"cbi-button cbi-button-neutral dl-icon-only"}),i=cn(e.devices).map(d=>{let c=t("div",{class:"dl-dcard-head"},[t("span",{class:"dl-dcard-ic"},g(d.kind)),t("button",{type:"button",class:"dl-dcard-title",click:()=>s(d)},[t("b",{},d.name),pn(d,o,void 0,e),d.config_stale?t("span",{class:"dl-pill warn dl-stale"},_("Update config")):""]),a(d)]),p=t("div",{class:"dl-dcard-trend"},[t("div",{class:"dl-stack"},[t("b",{},re(d.month[0]+d.month[1])),t("span",{class:"dl-sub"},_("this month"))]),Hr(n.devSeries[d.id]??[])]);return t("article",{class:`dl-dcard clickable${d.online?" online":""}${d.disabled?" off":""}`,click:r(d)},[c,d.handshake?p:d.disabled?t("div",{class:"dl-sub"},`${at(d.kind)} · ${m(d.created_by==="portal"?_("created %s in the portal."):_("created %s by you."),pe(d.created,o))}`):t("div",{class:"dl-chips-row"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>Al(n,d)},[g("qr"),_("Show QR")]),t("button",{type:"button",class:"dl-chipbtn",click:()=>Nl(n,d)},[g("download"),_("Config")])])])}),l=e.devices.length>=e.device_limit;return i.push(t("button",{type:"button",class:"dl-dslot add",click:()=>ct(e,n.deviceOpts())},[t("span",{class:"dl-dslot-ic"},g("plus")),t("span",{class:"dl-stack"},[t("b",{},_("Add device")),t("span",{class:"dl-sub"},l?`${_("Over the limit")} · ${m(_("%s of %s"),e.devices.length,e.device_limit)}`:m(_("%s of %s"),e.devices.length,e.device_limit))])])),t("section",{class:"dl-devsec"},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Devices")),t("span",{class:"dl-sub"},m(_("%s online"),V(e.online)))]),t("div",{class:"dl-dgrid"},i)])}function ma(n){let e=n.p,o=Qe([["device",_("Device’s own DNS")],["home",_("Home names")]],e.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:r=>n.patch({dns_mode:r},r==="home"?_("Home names on - devices need their configuration again"):_("Device DNS - devices need their configuration again"))}),s=n.st.settings.home_dns_fallback;return t("div",{class:"dl-stack gap4 dl-dnspick"},[t("div",{class:"dl-row-actions"},[t("span",{class:"dl-sub"},"DNS"),o]),t("span",{class:"dl-sub"},e.dns_mode==="home"?s?oe(_("Names like %s work. Internet names are resolved at home, so they depend on the tunnel (%s takes over when it is down)."),t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`),t("span",{class:"dl-mono"},s)):oe(_("Names like %s work. Internet names are resolved at home, so they depend on the tunnel - with no fallback set, they stop when it is down."),t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)):_("Internet keeps working exactly as without the VPN. Reach home devices by IP address."))])}function ha(n){let e=n.p,s=n.st.servers.find(a=>a.id===e.server)?.home??[];if(s.length<2)return"";let r=new Set(e.home_nets?.length?e.home_nets:s.map(a=>a.dev));return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},s.map(a=>Vt(a.dev,r.has(a.dev),()=>{let i=new Set(r);if(i.delete(a.dev)||i.add(a.dev),!i.size)return q(_("Keep at least one network, or choose Internet only."),"warning",5e3);let l=i.size===s.length?[]:[...i];n.patch({home_nets:l},l.length?m(_("%s reaches %s"),e.name,l.join(", ")):m(_("%s reaches every home network"),e.name))},{title:a.nets.join(", ")}))),t("span",{class:"dl-sub"},e.home_nets?.length?m(_("Home networks %s reaches. Networks added to the server later stay out."),e.name):m(_("Home networks %s reaches: all of them. Untick one to keep %s out of it."),e.name,e.name))])}function fa(n){let e=new Set(n.p.services??[]);return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},n.st.services.map(o=>Vt(o.name,e.has(o.id),()=>{let s=new Set(e);s.delete(o.id)||s.add(o.id),n.patch({services:[...s]},s.size?_("Home services updated"):_("Whole home network"))},{title:`${o.address}${o.ports.length?` · ${o.ports.join(", ")}`:""}`}))),t("span",{class:"dl-sub"},e.size?_("Only the selected services at home."):_("Whole home network. Pick services to narrow it down."))])}function ga(n){let e=n.p,o=n.st;if(o.servers.find(c=>c.id===e.server)?.mesh!=="circles"||!ut(e))return"";let r=o.circles.filter(c=>c.server===e.server),a=r.find(c=>c.id===e.circle),i=a?o.people.filter(c=>c.id!==e.id&&c.circle===a.id&&ut(c)).map(c=>c.name):[],l=t("button",{type:"button",class:"dl-chipbtn",click:()=>Te(l,[...r.map(c=>({label:c.name,icon:$o(c),run:()=>c.id!==e.circle&&n.patch({circle:c.id},m(_("%s is in %s"),e.name,c.name))})),e.circle?{label:_("No circle"),icon:g("x"),run:()=>n.patch({circle:""},m(_("%s is in no circle"),e.name))}:null,{label:_("New circle"),icon:g("plus"),run:()=>An(o,e.server,null,()=>n.refresh())}])},_("Change")),d=a?o.people.filter(c=>c.circle===a.id&&ut(c)):[e];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},_("Devices see each other")),l]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},a?a.name:_("No circle")),t("span",{class:"dl-avstack",title:d.map(c=>c.name).join(", ")},d.slice(0,5).map(c=>t("span",{class:"dl-avatar sm"},Oe(c.name))))]),t("span",{class:"dl-sub"},a?i.length?[e.name,...i].join(", "):m(_("Nobody else in %s yet"),a.name):m(_("Only %s's own devices"),e.name))])}function va(n){let e=n.p,o=n.st.now,s=t("div",{class:"dl-slots"});for(let i=0;i=e.device_limit,c=t("i",{class:d?"over":l?"used":""});we(c,()=>[t("div",{class:"dl-tip-title"},l?`${l.name}${d?` · ${_("over the limit")}`:""}`:_("Free slot")),t("div",{class:"dl-muted"},l?l.online?_("Connected"):l.handshake?m(_("Last seen %s"),pe(l.handshake,o)):_("Not set up yet"):_("They can add a device here"))]),s.appendChild(c)}let r=Math.max(1,e.devices.length),a=t("button",{type:"button","aria-label":_("Allow fewer devices"),disabled:e.device_limit<=r?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit-1)})},"−");return e.device_limit<=r&&e.devices.length>1&&we(a,()=>[t("div",{class:"dl-tip-title"},W(e.devices.length,"%s device in use","%s devices in use")),t("div",{class:"dl-muted"},_("Remove a device first to lower the limit"))]),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},_("Devices")),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[String(e.devices.length),t("span",{class:"dl-faint"},` / ${e.device_limit}`)]),t("div",{class:"dl-stepper"},[a,t("button",{type:"button","aria-label":_("Allow more devices"),disabled:e.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit+1)})},"+")])]),s])}function Hl(n){return{internet:_("Browse the internet through your router. No access to devices at home, and home cannot reach theirs."),lan:_("Reach devices at home, and home reaches theirs. Internet stays on their own connection."),both:_("Home devices and the internet, all through your router. Home reaches their devices too.")}[n]}var ba=/^([01]\d|2[0-3]):[0-5]\d$/;function zl(n){let e=n.p,o=n.today,s=st(e.expires,o),r=t("input",{type:"date",class:"dl-date-hidden",value:e.expires,tabindex:"-1","aria-hidden":"true"});r.addEventListener("change",()=>r.value&&n.patch({expires:r.value},m(_("Access until %s"),$e(r.value))));let a=(c,p)=>{let u=Qo(e.expires&&(s??-1)>=0?e.expires:"",c,p,o);n.patch({expires:u},m(_("Access until %s"),$e(u)))},i=[["week",1,_("+1 week")],["month",1,_("+1 month")],["month",3,_("+3 months")],["year",1,_("+1 year")]].map(([c,p,u])=>t("button",{type:"button",class:"dl-chipbtn",click:()=>a(c,p)},u)),l=t("span",{class:"dl-datechip"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>{r.focus({preventScroll:!0});try{r.showPicker()}catch{}}},[g("calendar"),e.expires?$e(e.expires):_("Date")]),r]),d={pause:_("pause access"),notify:_("keep access"),remove:_("remove their devices")}[e.expire_action];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},_("Access ends")),e.expires?t("span",{class:s!=null&&s<0?"dl-bad":rt(e,s)?"dl-warn":"dl-ok"},s!=null&&s<0?_("ended"):W(s??0,"%s day left","%s days left")):t("span",{class:"dl-faint"},_("no end date"))]),t("div",{class:"dl-chips-row"},[...i,l,e.expires?t("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},_("No end date"))},_("No end")):""]),t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.expire_warn?m(N_(e.expire_warn,"When it ends: %s, warn %s day before","When it ends: %s, warn %s days before"),d,V(e.expire_warn)):m(_("When it ends: %s"),d)),t("a",{href:"#",click:c=>{c.preventDefault(),aa(n)}},_("Change"))])])}function Rl(n){let e=n.p,o=e.quota_used||e.month[0]+e.month[1],s=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,r=t("div",{class:`dl-meter${s>=100?" bad":s>=90?" warn":""}`},[t("i"),e.quota_limit?t("span",{class:"mark",title:_("Alert at 90%")}):""]);r.firstChild.style.width=`${s}%`,e.quota_limit&&we(r,()=>[t("div",{class:"dl-tip-title"},m(_("%s%% used"),V(s,1))),t("div",{class:"dl-muted"},`${m(_("%s of %s"),re(e.quota_used),re(e.quota_limit))} · ${m(_("%s left"),re(Math.max(0,e.quota_limit-e.quota_used)))}`),t("div",{class:"dl-faint"},_("Alert at 90%"))]);let a=Qe([["month",_("Monthly")],["total",_("Total")]],e.quota_period,{label:_("Data limit period"),cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),i=[10,50,100].map(l=>t("button",{type:"button",class:`dl-chipbtn${e.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},m(_("Data limit %s GB"),V(l)))},`${V(l)} ${_("GB")}`));return i.push(t("button",{type:"button",class:`dl-chipbtn${e.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},_("No data limit"))},_("Unlimited"))),i.push(t("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=t("input",{type:"number",class:"cbi-input-text dl-w-port",min:0,step:"any",value:e.quota_gb?String(e.quota_gb):""}),d=Me(_("Data limit (GB)"),l,()=>bn(l.value,e.quota_period==="month"));de(_("Data limit"),[d],[ue()," ",N(_("Save"),async()=>{let c=d.help();if(c.bad){q(c.text,"warning");return}let p=l.value.trim();await n.patch({quota_gb:p},p&&Number(p)>0?m(_("Data limit %s GB"),V(Number(p))):_("No data limit"))&&ce()},"positive")]),setTimeout(()=>l.select(),50)}},_("Custom"))),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},_("Data")),a]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[re(o),e.quota_limit?t("span",{class:"dl-faint"},` ${m(_("of %s"),re(e.quota_limit))}`):t("span",{class:"dl-faint"},` · ${_("no limit")}`)]),e.quota_period==="month"?t("span",{class:"dl-sub"},_("resets on the 1st")):""]),e.quota_limit?r:"",t("div",{class:"dl-chips-row"},i),e.quota_gb&&e.quota_period==="month"?t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.bonus_gb?m(_("Includes +%s GB extra this month"),V(e.bonus_gb)):_("Need a little more this month?")),t("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((e.bonus_gb||0)+10)},_("+10 GB this month"))}},_("+10 GB this month"))]):"",t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},m(_("%s in total"),re(e.total[0]+e.total[1]))),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>zt("person",e.id,e.name,()=>setTimeout(()=>n.refresh(),300))},_("Reset usage"))])])}function Il(n){let e=n.p,o=!!e.hours,[s,r]=(e.hours||"07:00-23:00").split("-"),a=t("input",{type:"time",class:"cbi-input-text",value:s,"aria-label":_("From")}),i=t("input",{type:"time",class:"cbi-input-text",value:r,"aria-label":_("To")}),l=t("div",{class:"dl-tile2-row"},[a,t("span",{class:"dl-faint"},_("to","time range")),i]),d=()=>{let v=`${a.value}-${i.value}`;if(v!==e.hours){if(!ba.test(a.value)||!ba.test(i.value))return q(_("Enter both times, like 07:00 and 23:00."),"warning");if(a.value===i.value)return q(_("The start and the end must differ."),"warning");n.patch({hours:v},m(_("Allowed %s–%s"),a.value,i.value))}};l.addEventListener("focusout",v=>{l.contains(v.relatedTarget)||d()});for(let v of[a,i])v.addEventListener("keydown",M=>{M.key==="Enter"&&(M.preventDefault(),d())});let c=t("button",{type:"button",role:"switch","aria-checked":o?"true":"false",class:`dl-switch${o?" on":""}`,"aria-label":_("Limit hours"),click:()=>{if(o)return n.patch({hours:""},_("Any time"));c.classList.add("on"),c.setAttribute("aria-checked","true"),p.textContent=_("Set the hours, then press Enter"),u.appendChild(l),a.focus()}},t("i")),p=t("span",{},o?m(_("%s – %s (router time)"),s,r):_("Any time")),u=t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-row"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-tile2-label"},_("Allowed hours")),p]),c]),o?l:""]);return u}function xa(n){let e=n.p,o=Qe(["internet","lan","both"].map(s=>[s,[g(s==="internet"?"globe":s==="lan"?"home":"shield"),s==="internet"?_("Internet"):s==="lan"?_("Home"):_("Both")]]),e.access,{label:_("Access"),cls:"wide",optimistic:!1,onChange:s=>n.patch({access:s},m(_("Access: %s"),vt(s)))});return t("section",{class:"dl-devsec","aria-label":_("Access and limits")},[t("div",{class:"dl-panel-head"},[t("h3",{},_("Access & limits"))]),t("div",{class:"dl-panel"},[t("div",{class:"dl-stack gap8"},[t("span",{class:"dl-tile2-label"},_("Can reach")),o,t("span",{class:"dl-sub"},Hl(e.access)),e.access==="lan"&&n.st.services.length?fa(n):"",ut(e)?ha(n):"",e.access==="lan"?ma(n):""]),t("div",{class:"dl-tiles2"},[va(n),ga(n),zl(n),Rl(n),Il(n)])])])}function Bl(n){let e=n.st,o=t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Locations")),t("span",{class:"dl-spacer"}),e.geo.enabled?It("30d",r=>n.map?.setRange(r),!1):"",N(_("Hide"),()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},oe(_("Locations are off. %s."),t("a",{href:L.url("admin/network/dawnline/settings")},_("Turn them on in Settings"))))]);let s=new dt({openPerson:()=>{},openDevice:(r,a)=>{let i=n.p.devices.find(l=>l.id===a);i&&Ye(n.p,i,n.deviceOpts())}},"30d",280);return n.map=s,requestAnimationFrame(()=>s.mount(n.mapData())),t("div",{class:"dl-panel flush"},[o,s.el])}function wa(n){let e=n.st;if(!e.geo.enabled)return t("div",{class:"dl-places"},[g("pin"),t("div",{class:"dl-stack"},[t("span",{},_("Locations are off")),t("span",{class:"dl-sub"},_("City-level, from the client IP"))]),t("span",{class:"dl-spacer"}),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},_("Turn on"))]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:Bl(n);let o=e.now-30*86400,s=e.geo.points.filter(i=>i.person===n.p.id&&i.ts>=o).sort((i,l)=>l.ts-i.ts),r=[...new Set(s.map(i=>i.city||i.country).filter(Boolean))],a=s[0];return t("div",{class:"dl-places"},[g("pin"),t("div",{class:"dl-stack"},[t("span",{},a?a.city||a.country:_("No locations yet")),t("span",{class:"dl-sub"},a?[W(r.length,"%s place in 30 days","%s places in 30 days"),a.org].filter(Boolean).join(" · "):_("Shown after a device connects"))]),t("span",{class:"dl-spacer"}),s.length?N(_("Show map"),()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function ya(n){let e=n.p,o=n.st,s=n.events.filter(l=>l.person===e.id),r=[],a=[...s].reverse();for(let l=0;l1){let u=p.querySelector(".dl-row-main");dom.content(u,[...zo(o,d).slice(0,3),t("span",{class:"dl-muted"},W(c,"%s time","%s times"))]),u.title=a.slice(l,l+c).map(v=>v.detail??"").join(` +`)}r.push(p),l+=c-1}let i=N([g("more")],()=>Te(i,[{label:_("Export CSV"),icon:g("download"),run:()=>Ze(o,s,"csv",e.id)},{label:_("Export JSON"),icon:g("download"),run:()=>Ze(o,s,"json",e.id)},null,{label:m(_("Clear %s's activity"),e.name),icon:g("trash"),danger:!0,run:()=>lt(m(_("Clear %s's activity"),e.name),m(_("Removes events about %s and their devices."),e.name),{person:e.id},()=>n.refresh())}]),"neutral",{title:_("Export or clear"),class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Activity")),t("span",{class:"dl-sub"},s.length>10?m(_("latest 10 of %s"),V(s.length)):""),t("span",{class:"dl-spacer"}),i]),r.length?r:t("div",{class:"dl-row dl-muted"},_("Nothing yet."))])}var Fn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,s,r]=await Promise.all([H.status(30),e?H.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?H.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:s?.events??null,use:r}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(i=>i.id===this.id);if(!o)return t("div",{class:"dl-empty"},[t("h3",{},_("Person not found")),t("p",{},_("They may have been removed.")),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},_("Back to Servers"))]);this.p=o;for(let i of["crumbs","head","devices","traffic","places","activity","limits"])this.parts[i]=t("div",{});this.parts.devices.className="dl-person-devices";let s=t("div",{},[this.parts.crumbs,this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),a=r.get("device")&&o.devices.find(i=>i.id===r.get("device"));return a?setTimeout(()=>Ye(this.p,a,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>ct(this.p,this.deviceOpts()),50),this.poller=pt({fetch:i=>{let l=i||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>s.isConnected,apply:(i,l)=>this.apply(i,l)}),s}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let s=this.st.people.find(r=>r.id===this.id);if(!s){o||(location.href=Bt(this.p?.server));return}this.p=s,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var a;this.poller?.claim();let s=await K(()=>H.personUpdate(this.p.id,e),o);if(!s)return!1;this.poller?.claim();let r=this.st.people.findIndex(i=>i.id===this.p.id);return(a=s.person).rate??(a.rate=this.p.rate),r>=0&&(this.st.people[r]=s.person),this.p=s.person,this.paint(),!0}get today(){return We(this.series.length?this.series:this.st.series)}get core(){return Rt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}crumbs(){let e=this.p;return t("nav",{class:"dl-crumbs","aria-label":_("Breadcrumb")},[t("a",{href:Bt(e.server)},this.st.servers.find(o=>o.id===e.server)?.name??_("Servers")),t("span",{},"/"),t("a",{href:Bt(e.server)},_("People")),t("span",{},"/"),t("span",{},e.name)])}paint(e=!1){De(this.parts.crumbs,this.crumbs(),e),De(this.parts.head,ca(this),e),De(this.parts.traffic,pa(this),e),De(this.parts.devices,ua(this),e),De(this.parts.limits,xa(this),e),this.paintPlaces(e),De(this.parts.activity,ya(this),e)}paintPlaces(e=!1){let o=wa(this);o&&De(this.parts.places,o,e&&!this.mapOpen)}};var Ol={ok:"check",warn:"alert",error:"x",skip:"pause"},Kn=class{constructor(e,o,s,r){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=s,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,s)}async run(e){let o=e?await On(e):await H.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},_("Checks"))]),t("p",{class:"dl-muted dl-loading"},_("Running checks…"))]);return}let o=e.filter(i=>i.status==="error").length,s=e.filter(i=>i.status==="warn").length;dom.content(this.summary,o?xt("error",W(o,"%s problem needs attention.","%s problems need attention.")):s?xt("warn",W(s,"%s warning.","%s warnings.")):xt("ok",_("All checks passed.")));let r=new Map;for(let i of this.sl.watchdog.repairs)r.set(i.id,Math.max(r.get(i.id)??0,i.ts));let a=()=>this.run();dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},_("Checks")),t("span",{class:"dl-spacer"}),N(_("Run again"),a)]),t("ul",{class:"dl-checks"},e.map(i=>t("li",{},[t("span",{class:`dl-check-icon ${i.status}`},g(Ol[i.status])),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},i.title),t("div",{class:"dl-check-detail"},i.detail),r.has(i.id)?t("div",{class:"dl-check-repaired"},m(_("Repaired by the watchdog at %s"),Wt(r.get(i.id)))):""]),Ro(i,l=>void this.run(l),a)])))])}paintLive(e,o){this.sl=e,this.events=o;let s=e.watchdog,r=s.beat!=null&&s.now-s.beat>180,a=s.repairs.filter(d=>s.now-d.ts<86400),i=a[a.length-1],l=ye(s.enabled,_("Watchdog repairs"),async d=>{await K(()=>H.settingsUpdate({watchdog:d?"1":"0"}),d?_("Watchdog on"):_("Watchdog off"))||ho(l,!d);let p=await H.serviceLog().catch(()=>null);p&&this.paintLive(p,this.events)});dom.content(this.wdEl,t("div",{class:"dl-panel dl-wd"},[t("div",{class:"dl-wd-head"},[t("span",{class:`dl-wd-tile${s.enabled?"":" off"}`},g("shield")),t("div",{class:"dl-stack"},[t("span",{class:"dl-wd-title"},_("Watchdog")),t("span",{class:"dl-sub"},s.enabled?_("Every minute it checks the tunnels and services and repairs what it can on its own."):_("Off: problems are only written to the log. Nothing is repaired on its own."))]),t("span",{class:"dl-spacer"}),l]),t("div",{class:"dl-wd-foot"},[t("div",{class:"dl-wd-chips"},s.targets.map(d=>t("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?_("OK"):d.tries?`${_("Not working")} · ${W(d.tries,"%s repair","%s repairs")}`:_("Not working")},[g(d.ok?"check":"x"),d.name]))),t("span",{class:`dl-sub${r?" dl-warn-text":""}`},r?m(_("The agent has not checked in for %s min; cron restarts it after 5."),V(Math.round((s.now-s.beat)/60))):[s.last?m(_("Looked %s"),pe(s.last,s.now)):_("Starts within a minute")," · ",a.length?m(N_(a.length,"%s repair today, last %s at %s","%s repairs today, last %s at %s"),V(a.length),i.name,Wt(i.ts)):_("no repairs today")])])])),this.paintRecent()}paintRecent(){let e=(this.sl.watchdog.now||Date.now()/1e3)-604800,o=[...this.events.map(r=>({ts:r.ts,ev:r})),...this.sl.log.map(r=>({ts:r.ts,sys:r}))].filter(r=>r.ts>=e&&xn(r)).sort((r,a)=>a.ts-r.ts),s=t("div",{class:"dl-panel-head pad"},[t("h3",{},_("Recent problems")),t("span",{class:"dl-spacer"}),o.length?t("a",{href:"#",click:r=>(r.preventDefault(),this.toLog())},`${_("All in Log")} →`):""]);if(!o.length){dom.content(this.recentEl,[s,t("div",{class:"dl-recent-empty"},[t("span",{class:"dl-check-icon ok"},g("check")),_("No problems in the last 7 days.")])]);return}dom.content(this.recentEl,[s,...o.slice(0,8).map(r=>{if(r.sys){let a=r.sys,i=`${a.ts}|${a.msg}`;return Rn(a,this.open.has(i),()=>{this.open.delete(i)||this.open.add(i),this.paintRecent()},Wt(a.ts))}return ht(this.st,r.ev,{time:Wt(r.ts)})})])}};var Vn=300,jl=["all","connections","people","system","problems"],Yn=class{constructor(e,o,s){this.events=[];this.system=[];this.kind="all";this.shown=Vn;this.open=new Set;this.list=t("div",{});this.sub="";this.tabs=t("div",{class:"dl-seg",role:"tablist"});this.st=e,this.take(o),this.system=s,this.el=t("div",{},[t("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let e=()=>this.kind==="all"?"":this.kind,o=a=>()=>{let i=this.filtered().reverse();Ze(this.st,i.filter(l=>l.ev).map(l=>l.ev),a,e(),i.filter(l=>l.sys).map(l=>l.sys))},s=N([g("download"),` ${_("Export")}`],()=>Te(s,[{label:_("CSV (spreadsheet)"),icon:g("download"),run:o("csv")},{label:"JSON",icon:g("download"),run:o("json")}])),r=N([g("trash"),` ${_("Clear")}`],()=>lt(_("Clear the log"),_("Removes events from the log on the router."),{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[s,r]}take(e){this.events=e.events,this.policy=e.policy;let o=Ht.filter(r=>!e.policy.categories.includes(r)),s=wn(e.policy);this.sub=o.length?`${s} ${m(_("Not recorded: %s."),o.map(r=>Ke(r).toLowerCase()).join(", "))}`:s}async reload(){let[e,o]=await Promise.all([H.events(2e4).catch(()=>null),H.serviceLog().catch(()=>null)]);e&&this.take(e),o&&(this.system=o.log),this.paint()}items(){return[...this.events.map(e=>({ts:e.ts,ev:e})),...this.system.map(e=>({ts:e.ts,sys:e}))].sort((e,o)=>o.ts-e.ts)}matches(e,o){return o==="all"?!0:o==="problems"?xn(e):o==="system"?!!e.sys:!!e.ev&&Ft(e.ev.type)===o}filtered(){return this.items().filter(e=>this.matches(e,this.kind))}paintTabs(e){dom.content(this.tabs,jl.map(o=>t("button",{type:"button",role:"tab",class:o===this.kind?"on":"","aria-selected":o===this.kind?"true":"false",click:()=>this.show(o)},[o==="all"?_("All"):o==="system"?_("System"):Ke(o),t("b",{},String(e.filter(s=>this.matches(s,o)).length))])))}show(e){this.kind=e,this.shown=Vn,this.paint()}paint(){this.paintTabs(this.items());let e=this.filtered();if(!e.length){dom.content(this.list,t("div",{class:"dl-empty"},[t("p",{},this.events.length||this.system.length?_("No events match."):_("The log is empty."))]));return}let o=[],s="",r=null;for(let a of e.slice(0,this.shown)){let i=Nr(a.ts);i!==s&&(s=i,r=t("div",{class:"dl-panel flush"},t("div",{class:"dl-panel-head pad"},t("h3",{},i))),o.push(r));let l=new Date(a.ts*1e3).toLocaleTimeString(le(),{hour:"2-digit",minute:"2-digit"});if(a.sys){let d=`${a.sys.ts}|${a.sys.msg}`;r.appendChild(Rn(a.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else r.appendChild(ht(this.st,a.ev,{time:l}))}e.length>this.shown&&o.push(t("div",{class:"dl-more-row"},N(m(_("Show %s more of %s"),V(Math.min(Vn,e.length-this.shown)),V(e.length-this.shown)),()=>{this.shown+=Vn,this.paint()}))),dom.content(this.list,o)}};var Ul=["health","log"],Wl=n=>n==="log"?_("Log"):_("Health"),Go=2e4,Jn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=t("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":_("Diagnostics")});this.subEl=t("span",{class:"dl-muted"});this.actionsEl=t("div",{class:"dl-row-actions"});this.bodyEl=t("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([H.status(1),H.events(Go),H.serviceLog()])}render([e,o,s]){return this.log=new Yn(e,o,s.log),this.health=new Kn(e,s,o.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),pt({fetch:async()=>{let r=this.tab==="log",[a,i]=await Promise.all([H.serviceLog().catch(()=>null),r?H.events(Go).catch(()=>null):Promise.resolve(null)]);return a||i?{n:a,e:i}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:r,e:a})=>this.take(r,a)}),t("div",{},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},_("Diagnostics")),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(e,o){o&&(this.log.take(o),this.eventsAt=Date.now()),e&&(this.log.system=e.log),e&&this.health.paintLive(e,o?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(e){this.tab=e,dom.content(this.segEl,Ul.map(o=>t("button",{type:"button",role:"tab",class:o===e?"on":"","aria-selected":o===e?"true":"false",click:()=>o!==this.tab&&this.show(o)},Wl(o)))),this.bodyEl.replaceChildren(e==="log"?this.log.el:this.health.el),this.subEl.textContent=e==="log"?this.log.sub:_("Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own."),dom.content(this.actionsEl,e==="log"?this.log.actions():""),e==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&H.events(Go).then(o=>this.take(null,o)).catch(()=>null)):this.health.checks||this.health.run()}};var ka=":root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-fg: var(--foreground, var(--text-color-highest, currentColor));--dl-soft: var(--muted, color-mix(in srgb, var(--dl-fg) 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, var(--dl-fg) 10%, transparent));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-info: var(--info, #2c67c5);--dl-ok-wash: var(--success-a15, color-mix(in srgb, var(--dl-ok) 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, var(--dl-warn) 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, var(--dl-bad) 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, var(--dl-info) 15%, transparent));--dl-track: var(--foreground-a10, color-mix(in srgb, var(--dl-fg) 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, var(--dl-ok));--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, var(--dl-fg));--dl-primary-fg: var(--primary-foreground, var(--dl-elevated));--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}:root[data-darkmode=true]{--dl-card: var(--panel-bg, var(--background-color-low, transparent));--dl-elevated: var(--elevated, var(--background-color-low, Canvas));--dl-accent: var(--accent, #006efe);--dl-ok: var(--success, #40c977);--dl-warn: var(--warning, #ff8549);--dl-bad: var(--danger, #ff6764);--dl-info: var(--info, #5ba2fe);--dl-ring: var(--ring, #5ba2febc)}.dl-root,.dl-modal{cursor:default}:is(.dl-root,.dl-modal) :is(input:not([type=checkbox],[type=radio],[type=range],[type=button],[type=submit]),textarea,[contenteditable=true]){cursor:text}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}";var _a='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off :is(.dl-card-name,.dl-avatar,.dl-access,.dl-slotbar,.dl-chips,.dl-pill-ic,.dl-use-num,.dl-pside-foot,.dl-pside-state){opacity:.45}.dl-plist>.dl-card.dl-off .dl-usebar i{background:var(--dl-fg-faint)}.dl-plist>.dl-card.dl-off .dl-chip-tag{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pcard:has(>.dl-pstrip){row-gap:14px}.dl-pstrip{grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 -16px -16px;padding:10px 16px;border-top:1px solid var(--dl-line);border-radius:0 0 var(--dl-radius) var(--dl-radius);font-size:14px;line-height:20px}.dl-pstrip.warn{background:color-mix(in srgb,var(--dl-warn) 7%,transparent)}.dl-pstrip.bad{background:color-mix(in srgb,var(--dl-bad) 7%,transparent)}.dl-pstrip-text{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px}.dl-pstrip-text b{font-weight:500}.dl-pstrip>.cbi-button{flex:none;height:32px!important}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;border:1px dashed color-mix(in srgb,var(--dl-fg) 28%,transparent);color:var(--dl-fg-muted)}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg);border-color:color-mix(in srgb,var(--dl-fg) 45%,transparent)}.dl-chip.add:hover .dl-icon{color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}.dl-people-find{width:160px;min-width:0}.dl-people-find[hidden]{display:none}';var Ca="#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-warn{color:var(--dl-warn)}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.cbi-dropdown>ul:not(.dropdown) .dl-opt-note{display:none}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}.dl-srvtab i.dot.warn{background:var(--dl-warn)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}";var La=".dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}";var Ma=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;--dl-gap: 2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars>span:hover i{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-6.5px;bottom:-6.5px;width:20px;height:20px;border-radius:8.5px;border:1.5px solid transparent;background:var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p:hover .dl-onl-dev{background:linear-gradient(var(--dl-soft),var(--dl-soft)),var(--dl-card)}.dl-onl-p.sm:hover{background:none}.dl-onl-p.sm:hover .dl-onl-dev{background:var(--dl-card)}.dl-onl-p.sm .dl-onl-av{transition:box-shadow .15s ease}.dl-onl-p.sm:hover .dl-onl-av{box-shadow:0 0 0 2px var(--dl-ok),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm.more:hover .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-ic.off{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;height:54px;--dl-gap: 3px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars>span:hover i:not(.hi){background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-speed-val.off{color:var(--dl-fg-faint)}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var Ea='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-modal .cbi-value.dl-live>.cbi-value-title{display:flex;flex-direction:column;gap:2px;text-align:left}.dl-modal .cbi-value.dl-live>.cbi-value-title>.dl-sub{white-space:normal}.dl-checklist{display:flex;flex-direction:column;gap:6px;margin:4px 0 8px}.dl-checklist label{display:flex;align-items:center;gap:8px;font-size:14px;cursor:pointer}.dl-checklist input{margin:0}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var Ta=".dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#0a0a0a;border-radius:18px;overflow:hidden}.dl-qr.light{background:#fff;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}";var Sa=".dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}.dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}";var Pa=".dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}";var $a=`.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:transparent}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.line{width:14px;height:0;border-top:2px dashed #8a8a8a}.dl-map-legend i.line.live{border-top-color:#3b82f6}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.dl-mk-hub{position:relative;display:flex;align-items:center;justify-content:center}.dl-mk-host{box-sizing:border-box;width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059}.dl-mk-host-tile{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:var(--dl-fg);color:var(--background, var(--dl-elevated))}.dl-mk-host-ic{width:14px;height:14px}.dl-mk-av{position:relative;box-sizing:border-box;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:500;line-height:1;border:2px solid #8a8a8a;background:var(--dl-elevated);color:var(--dl-fg-muted);transition:box-shadow .2s}.dl-mk.online .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-badge{position:absolute;left:16px;bottom:-6px;height:16px;min-width:16px;padding:0 3px;border-radius:8px;border:2px solid var(--dl-elevated);background:#6b6b6b;color:#fff;display:flex;align-items:center;justify-content:center;gap:1px;font-size:9px;font-weight:600;white-space:nowrap;box-sizing:content-box}.dl-mk.online .dl-mk-badge{background:#3b82f6}.dl-mk-badge-ic{width:10px;height:10px;stroke-width:2.2}.dl-mk-badge:has(>svg:only-child){width:16px;min-width:0;padding:0}.dl-mk-tile{position:relative;width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk.place.online .dl-mk-tile{background:#3b82f6;color:#fff;box-shadow:0 2px 8px #3b82f659}.dl-mk-tile-ic{width:14px;height:14px}.dl-mk-tile-n{position:absolute;right:-5px;top:-5px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dl-fg);color:var(--dl-elevated);font-size:9px;font-weight:600;line-height:14px;text-align:center}.dl-mk-when{display:block;text-align:center;color:var(--dl-fg-faint);font-weight:400}.dl-mk.place.online .dl-mk-when{color:#3b82f6}.dl-mk-tile.sm{width:18px;height:18px;border-radius:5px;font-size:9px;font-weight:600}.dl-dmap{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-dmap .dl-geomap{border-top:0}.dl-dplaces{display:flex;flex-direction:column;margin-top:4px}.dl-dplace-row{display:flex;align-items:center;gap:10px;padding:9px 2px;border-top:1px solid var(--dl-line);font-size:13px}.dl-dplace-row:first-child{border-top:0}.dl-dplace-n{flex:0 0 auto;width:20px;height:20px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-dplace-n.live{background:#3b82f6;color:#fff}.dl-dplace-n .dl-icon{width:12px;height:12px}.dl-dplace-now{color:#3b82f6}.dl-dplaces.strips .dl-dplace-row{position:relative;display:grid;grid-template-columns:20px minmax(0,1fr) auto;column-gap:10px;row-gap:9px;margin:0 -10px;padding:11px 10px;border-top:0;border-radius:10px;transition:background .15s}.dl-dplaces.strips .dl-dplace-row+.dl-dplace-row:before{content:"";position:absolute;left:10px;right:10px;top:0;height:1px;background:var(--dl-line)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur){background:var(--dl-soft)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur):before,.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur)+.dl-dplace-row:before{opacity:0}.dl-dplace-strip{grid-column:2 / 4;position:relative;height:6px;border-radius:3px;background:var(--dl-track)}.dl-dplaces.can-replay .dl-dplace-strip{cursor:ew-resize;touch-action:none}.dl-dplace-strip i{position:absolute;top:0;bottom:0;min-width:2px;border-radius:2px;background:#8a8a8a}.dl-dplace-strip.live i{background:#3b82f6}.dl-dplaces.replay .dl-dplace-strip:after{content:"";position:absolute;left:var(--at);top:-4px;bottom:-4px;width:2px;margin-left:-1px;border-radius:1px;background:var(--dl-fg);box-shadow:0 0 0 2px var(--dialog-bg, var(--dl-elevated));pointer-events:none}.dl-dplace-axis{position:relative;height:16px;margin:4px 0 0 30px;font-size:11px;line-height:16px;color:var(--dl-fg-faint)}.dl-dplace-axis span{position:absolute;top:0;transform:translate(-50%);white-space:nowrap}.dl-dmap{position:relative}.dl-map-replay{position:absolute;left:10px;top:10px;z-index:3;display:flex;align-items:center;gap:6px}.dl-map-btn{all:unset;box-sizing:border-box;cursor:pointer;width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg)}.dl-map-btn:hover{background:color-mix(in srgb,var(--dl-fg) 8%,var(--dl-elevated))}.dl-map-btn:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-btn .dl-icon{width:13px;height:13px}.dl-map-chip{display:inline-flex;align-items:center;height:28px;box-sizing:border-box;padding:0 10px;border-radius:8px;font-size:11.5px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg);font-variant-numeric:tabular-nums}.dl-mk.step .dl-mk-tile{transition:width .3s cubic-bezier(.2,.8,.2,1),height .3s cubic-bezier(.2,.8,.2,1),border-radius .3s,background-color .3s,color .3s,box-shadow .3s,transform .24s}.dl-mk.step .dl-mk-tile.sm .dl-mk-tile-ic{width:11px;height:11px}.dl-mk.step.faded>*{opacity:.5}.dl-mk.step:is(.online,.hl){z-index:2}.dl-mk.step.hl .dl-mk-tile{box-shadow:0 0 0 3px color-mix(in srgb,#3b82f6 55%,transparent)}.dl-mk.step.arrive .dl-mk-tile{animation:dl-mk-arrive .45s cubic-bezier(.2,.8,.2,1)}@keyframes dl-mk-arrive{0%{transform:scale(.8)}55%{transform:scale(1.12)}to{transform:scale(1)}}.dl-mk-when.inline{display:inline}.dl-mk>*{transition:opacity .15s;opacity:var(--dl-mk-fade, 1)}.dl-mk.merged,.dl-mk.piled{pointer-events:none}.dl-mk.dl-mk-new>*{transition:none}.dl-mk.merged>*,.dl-mk.piled>*{opacity:0}.dl-mk-hub{cursor:default}.dl-mk-host{position:relative}.dl-mk-host{transition:border-radius .22s ease,border-right-color .22s ease}.dl-mk-host.docked{border-top-right-radius:0;border-bottom-right-radius:0;border-right-color:transparent}.dl-mk-dock{position:absolute;left:100%;top:-1px;height:40px;box-sizing:border-box;display:flex;align-items:center;gap:6px;padding:0 10px 0 2px;border:1px solid var(--dl-line);border-left:0;border-radius:0 11px 11px 0;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;pointer-events:none;opacity:0;clip-path:inset(-24px 100% -24px 0);transition:clip-path .28s cubic-bezier(.2,.8,.2,1),opacity .2s ease}.dl-mk-host.docked .dl-mk-dock{pointer-events:auto;opacity:1;clip-path:inset(-24px -24px -24px 0)}.dl-mk-new .dl-mk-host,.dl-mk-new .dl-mk-dock{transition:none}.dl-mk-pile{position:relative;display:flex;justify-content:center}.dl-mk-pile-box{box-sizing:border-box;height:40px;display:flex;align-items:center;gap:6px;padding:0 10px 0 6px;border-radius:20px;cursor:zoom-in;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;animation:dl-plate-in .26s cubic-bezier(.2,.8,.2,1) both;transition:opacity .18s ease,transform .18s ease}.dl-mk-pile.out{pointer-events:none}.dl-mk-pile.out>*{opacity:0;transform:scale(.85);transition:opacity .18s ease,transform .18s ease}@keyframes dl-plate-in{0%{opacity:0;transform:scale(.85)}}.dl-mk-face{all:unset;position:relative;display:flex;cursor:pointer;transition:transform .18s ease,opacity .18s ease}.dl-mk-face>.dl-mk-badge{position:relative;left:auto;bottom:-8px;margin-left:-12px;align-self:center}.dl-mk-face.on .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-face.on .dl-mk-badge{background:#3b82f6}.dl-mk-face:hover .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-face.in{animation:dl-dock-in .24s cubic-bezier(.2,.8,.2,1) both}.dl-mk-face.out{transform:scale(.4);opacity:0;pointer-events:none}@keyframes dl-dock-in{0%{transform:scale(.4);opacity:0}}.dl-mk-more{font-size:11px;font-weight:600;color:var(--dl-fg-muted)}.dl-mk-av,.dl-mk-tile{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1)}.dl-mk.merged .dl-mk-av,.dl-mk.merged .dl-mk-tile,.dl-mk.piled .dl-mk-av{transform:scale(.5)}.dl-mk-host,.dl-mk-dock,.dl-mk-pile-box{transition-property:border-radius,border-right-color,clip-path,opacity,height,width,padding,gap}.dl-mk-dock,.dl-mk-pile-box{transition-duration:.22s;transition-timing-function:cubic-bezier(.2,.8,.2,1)}.dl-mk-pile-box{position:relative}.dl-mk-more{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease}.dl-mk-more.in{animation:dl-dock-in .24s ease both}.dl-mk-more.out{transform:scale(.4);opacity:0}.dl-mk-face .dl-mk-av{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1),width .2s ease,height .2s ease,font-size .2s ease}.dl-mk-face{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease,margin .2s ease}.dl-mk-face>.dl-mk-badge{max-width:48px;overflow:hidden;transition:opacity .2s ease,transform .2s ease,max-width .22s ease,margin .22s ease,padding .22s ease,border-width .22s ease,height .22s ease,min-width .22s ease,width .22s ease,bottom .22s ease}.dl-lod-far .dl-mk-host{width:32px;height:32px;border-radius:9px}.dl-lod-far .dl-mk-host.docked{border-radius:9px 0 0 9px}.dl-lod-far .dl-mk-host-tile{width:20px;height:20px;border-radius:6px}.dl-lod-far .dl-mk-host-ic{width:11px;height:11px}.dl-lod-far .dl-mk-dock{height:32px;gap:0;padding:0 4px 0 0;border-radius:0 9px 9px 0}.dl-lod-far .dl-mk-pile-box{height:32px;gap:0;padding:0 4px;border-radius:16px}.dl-lod-far .dl-mk-face+.dl-mk-face{margin-left:-6px}.dl-lod-far .dl-mk-face .dl-mk-av{width:22px;height:22px;font-size:8px;box-shadow:0 0 0 2px var(--dl-elevated)}.dl-lod-far .dl-mk-face>.dl-mk-badge{max-width:0;min-width:0;padding:0;margin-left:0;border-width:0;opacity:0;transform:scale(.5);pointer-events:none}.dl-lod-far .dl-mk-more{margin-left:4px;font-size:10px}.dl-mk-label{transition:opacity .2s ease}.dl-lod-far .dl-mk:not(.step) .dl-mk-label{opacity:0}.dl-lod-mid .dl-mk-host{width:36px;height:36px}.dl-lod-mid .dl-mk-dock,.dl-lod-mid .dl-mk-pile-box{height:36px}.dl-lod-mid .dl-mk-face .dl-mk-av{width:24px;height:24px;font-size:9px}.dl-lod-mid .dl-mk-face>.dl-mk-badge{height:12px;min-width:12px;margin-left:-10px;bottom:-7px}.dl-lod-mid .dl-mk-face>.dl-mk-badge:has(>svg:only-child){width:12px}.dl-lod-mid .dl-mk-face>.dl-mk-badge .dl-mk-badge-ic{width:8px;height:8px}@media(prefers-reduced-motion:reduce){.dl-mk-dock,.dl-mk-pile-box,.dl-mk-face,.dl-mk-av,.dl-mk-tile,.dl-mk.step .dl-mk-tile,.dl-mk-host,.dl-mk-face>.dl-mk-badge{transition:none;animation:none}}.dl-mk-hub:has(.dl-mk-host.docked) .dl-mk-host{cursor:zoom-in}.dl-mk-ptr{position:absolute;left:50%;top:50%;width:0;height:0;z-index:-1;pointer-events:none}.dl-mk-ptr .line{position:absolute;left:0;top:-.5px;height:1px;background:var(--dl-fg-faint);transform-origin:0 50%}.dl-mk-ptr .spot{position:absolute;left:-3.5px;top:-3.5px;width:7px;height:7px;border-radius:50%;box-sizing:border-box;border:1.5px solid #fff;background:#8a8a8a}.dl-mk.online .dl-mk-ptr .spot,.dl-mk.place.online .dl-mk-ptr .spot{background:#3b82f6}.dl-mk.dim>*{opacity:.18}.dl-mk.hl .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-label{position:absolute;left:50%;bottom:100%;margin-bottom:4px;transform:translate(-50%);white-space:nowrap;pointer-events:none;font-size:10px;line-height:14px;font-weight:500;color:var(--dl-fg)}.dl-mk-label.below{bottom:auto;top:100%;margin:4px 0 0}.dl-mk-label.chip{padding:2px 6px;border-radius:4px;font-size:11px;line-height:16px;font-weight:600;background:color-mix(in srgb,var(--background, var(--dl-card)) 80%,transparent);backdrop-filter:blur(8px)}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact{margin:0 10px 10px 0;min-height:28px;padding:0;border-radius:8px;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg-muted);box-shadow:none;font-size:11px;line-height:26px}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show){width:28px;height:28px;box-sizing:border-box}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show{padding:0 32px 0 10px}.dl-geomap .maplibregl-ctrl-attrib a{color:var(--dl-fg-muted)}.dl-geomap .maplibregl-ctrl-attrib-button{top:0;right:0;width:26px;height:26px;margin:0;border-radius:8px;background:none}.dl-geomap .maplibregl-ctrl-attrib-button:after{content:"";position:absolute;inset:5px;background:var(--dl-fg);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat}.dl-geomap .maplibregl-ctrl-attrib-button:focus{outline:none;box-shadow:none}.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-card{position:absolute;right:12px;top:12px;z-index:3;min-width:200px;max-width:260px;padding:10px 12px;border-radius:10px;font-size:12px;line-height:20px;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));opacity:0;transition:opacity .2s;pointer-events:none}.dl-map-card.on{opacity:1}.dl-map-card-head b{font-weight:500}.dl-map-card-row{display:flex;justify-content:space-between;gap:12px;white-space:nowrap}.dl-popcard{position:fixed;z-index:2100;width:max-content;max-width:300px;padding:12px;border-radius:12px;box-sizing:border-box;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4))}.dl-popcard.away{visibility:hidden}.dl-popcard.leaving{pointer-events:none}.dl-popcard-tip{position:absolute;left:var(--tip-x, 50%);width:10px;height:10px;margin-left:-6px;box-sizing:border-box;background:var(--dl-elevated);border:solid var(--dl-line);transform:rotate(45deg)}.dl-popcard.above .dl-popcard-tip{bottom:-6px;border-width:0 1px 1px 0}.dl-popcard.below .dl-popcard-tip{top:-6px;border-width:1px 0 0 1px}.dl-popcard.above{transform-origin:var(--tip-x, 50%) 100%}.dl-popcard.below{transform-origin:var(--tip-x, 50%) 0}@media(prefers-reduced-motion:no-preference){.dl-popcard{animation:dl-pop-in .16s ease-out}.dl-popcard.leaving{animation:dl-pop-out .14s ease-in forwards}}@keyframes dl-pop-in{0%{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}@keyframes dl-pop-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.94)}}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px 0 0;max-height:116px;overflow-y:auto}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;flex:0 0 auto;--dl-gap: 2px}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}.dl-spark>span:hover i:not(.zero){opacity:1;filter:brightness(1.25)}.dl-spark>span,.dl-dbars>span,.dl-bento-bars>span{flex:1;min-width:0;height:100%;display:flex;align-items:flex-end;padding:0 calc(var(--dl-gap) / 2)}.dl-spark>span:first-child,.dl-dbars>span:first-child,.dl-bento-bars>span:first-child{padding-left:0}.dl-spark>span:last-child,.dl-dbars>span:last-child,.dl-bento-bars>span:last-child{padding-right:0}`;var Da=`.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}`;var Aa=".dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";var Na=".dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*:not(.alert-message):not(.dl-params):not(.dl-note){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.dl-note{margin:0 0 14px!important;padding:10px 12px}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*,.dl-group-body>.dl-note+*{border-top:0}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-root input.dl-w-range{flex:0 0 130px;width:130px}.dl-setrow .dl-sub.bad{color:var(--dl-bad)}.dl-suffixed{display:inline-flex;align-items:center;gap:6px}.dl-suffixed>span{color:var(--dl-fg-muted)}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-bad{color:var(--dl-bad)}";var Ha=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var za=".dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row,.dl-setrow.head .dl-note{margin-top:8px}.dl-setrow.head .dl-note{margin-bottom:0}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host{align-items:flex-start}.dl-host>.dl-icon-wrap{margin-top:13px}.dl-host-body{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px}.dl-host-body>.dl-row-main{flex:1 1 160px}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var rd=[ka,_a,Ca,La,Ma,Ea,Ta,Sa,Pa,$a,Da,Aa,Na,Ha,za].join(` +`);function Ra(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=rd,n}function kt(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async s=>{let r=await e.render(s),a=document.createElement("div");return a.className="dl-root",a.append(Ra(),r),a},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var tx=kt(rn),nx=kt(yt),ox=kt(rn),sx=kt(Un),rx=kt(Fn),ax=kt(Jn),ix=kt(qn);function Ia(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var lx=Ia(""),dx=Ia("log");return baseclass.extend({ activity: dx, diagnostics: ax, health: lx, overview: tx, people: nx, person: rx, server: ox, settings: sx, updates: ix }); diff --git a/package/luci-app-dawnline/po/ru/dawnline.po b/package/luci-app-dawnline/po/ru/dawnline.po index 0ddbf56..73cdde9 100644 --- a/package/luci-app-dawnline/po/ru/dawnline.po +++ b/package/luci-app-dawnline/po/ru/dawnline.po @@ -3250,6 +3250,10 @@ msgstr "Как портал принимает подключения (80 и 443 msgid "Idle right now" msgstr "Сейчас без трафика" +#: web/src/admin/interfaces.ts +msgid "If the router’s DNS hands out proxy addresses, those sites won’t open without it." +msgstr "Если DNS роутера выдаёт адреса прокси, без этого такие сайты не откроются." + #: web/src/admin/pages/settings/backups.ts msgid "Import" msgstr "Импортировать" @@ -4327,6 +4331,7 @@ msgid "Nobody is connected" msgstr "Никто не подключён" #: web/src/admin/pages/settings/defaults.ts +#: web/src/admin/ui/controls.ts msgid "None" msgstr "Нет" @@ -4489,8 +4494,8 @@ msgid "Off: NAT may close the tunnel when idle, and “Connected” lags." msgstr "Выкл.: NAT может закрыть туннель при простое, а статус «Подключено» будет запаздывать." #: web/src/admin/interfaces.ts -msgid "Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router." -msgstr "Выкл.: интернет-трафик идёт прямо в WAN, минуя всё, что обрабатывает домашний трафик на этом роутере." +msgid "Off: internet traffic goes straight to the WAN, the fastest way. DNS still goes through this router. Proxies and filters here handle the tunnel only if you %s." +msgstr "Выкл.: интернет-трафик идёт прямо в WAN, это самый быстрый путь. DNS по-прежнему через роутер. Прокси и фильтры на роутере обработают туннель, только если вы %s." #: web/src/admin/pages/server.ts msgid "Off: only you add devices, from LuCI. On: people manage their devices within the limits you set." @@ -5812,6 +5817,10 @@ msgstr "Пакеты-сигнатуры" msgid "Signatures" msgstr "Сигнатуры" +#: web/src/admin/interfaces.ts +msgid "Slower: every packet crosses the router twice. On a dual-core router expect up to a third less speed, and lost packets at full load." +msgstr "Медленнее: каждый пакет проходит через роутер дважды. На двухъядерном роутере скорость ниже до трети, а на пределе теряются пакеты." + #: web/src/admin/cores/awg.ts #: web/src/admin/pages/server.ts msgid "So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard" @@ -7002,6 +7011,10 @@ msgstr "Почему соединение проходит или нет" msgid "Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never." msgstr "Внутри круга: семья видит семью, гости - гостей. Каждый видит свои устройства. Люди только с интернетом - никогда." +#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/loop.uc +msgid "Without kmod-nft-offload every packet on this path passes the firewall twice. Install it and restart Dawnline." +msgstr "Без kmod-nft-offload каждый пакет на этом пути дважды проходит через межсетевой экран. Установите его и перезапустите Dawnline." + #: web/src/admin/updater/operation.ts msgid "Working…" msgstr "Выполняется…" @@ -7216,6 +7229,10 @@ msgstr ": новую сборку нужно включить вручную в msgid "access" msgstr "доступ" +#: web/src/admin/interfaces.ts +msgid "add its interface %s to their source interfaces yourself" +msgstr "сами добавите его интерфейс %s в их источники трафика" + #: web/src/admin/events/model.ts msgid "address %s" msgstr "адрес %s" @@ -7927,6 +7944,10 @@ msgstr ": правила Dawnline изменены или удалены" msgid "runs again" msgstr "снова работает" +#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/loop.uc +msgid "runs without its fast path" +msgstr "работает без ускорения" + #: web/src/admin/events/model.ts msgid "saved to flash every 10 minutes" msgstr "записываются во флеш-память каждые 10 минут" diff --git a/package/luci-app-dawnline/po/templates/dawnline.pot b/package/luci-app-dawnline/po/templates/dawnline.pot index f5591a6..cacfc24 100644 --- a/package/luci-app-dawnline/po/templates/dawnline.pot +++ b/package/luci-app-dawnline/po/templates/dawnline.pot @@ -3197,6 +3197,10 @@ msgstr "" msgid "Idle right now" msgstr "" +#: web/src/admin/interfaces.ts +msgid "If the router’s DNS hands out proxy addresses, those sites won’t open without it." +msgstr "" + #: web/src/admin/pages/settings/backups.ts msgid "Import" msgstr "" @@ -4273,6 +4277,7 @@ msgid "Nobody is connected" msgstr "" #: web/src/admin/pages/settings/defaults.ts +#: web/src/admin/ui/controls.ts msgid "None" msgstr "" @@ -4435,7 +4440,7 @@ msgid "Off: NAT may close the tunnel when idle, and “Connected” lags." msgstr "" #: web/src/admin/interfaces.ts -msgid "Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router." +msgid "Off: internet traffic goes straight to the WAN, the fastest way. DNS still goes through this router. Proxies and filters here handle the tunnel only if you %s." msgstr "" #: web/src/admin/pages/server.ts @@ -5753,6 +5758,10 @@ msgstr "" msgid "Signatures" msgstr "" +#: web/src/admin/interfaces.ts +msgid "Slower: every packet crosses the router twice. On a dual-core router expect up to a third less speed, and lost packets at full load." +msgstr "" + #: web/src/admin/cores/awg.ts #: web/src/admin/pages/server.ts msgid "So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard" @@ -6937,6 +6946,10 @@ msgstr "" msgid "Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never." msgstr "" +#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/loop.uc +msgid "Without kmod-nft-offload every packet on this path passes the firewall twice. Install it and restart Dawnline." +msgstr "" + #: web/src/admin/updater/operation.ts msgid "Working…" msgstr "" @@ -7151,6 +7164,10 @@ msgstr "" msgid "access" msgstr "" +#: web/src/admin/interfaces.ts +msgid "add its interface %s to their source interfaces yourself" +msgstr "" + #: web/src/admin/events/model.ts msgid "address %s" msgstr "" @@ -7860,6 +7877,10 @@ msgstr "" msgid "runs again" msgstr "" +#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/loop.uc +msgid "runs without its fast path" +msgstr "" + #: web/src/admin/events/model.ts msgid "saved to flash every 10 minutes" msgstr "" diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc index 4687b4c..9290ce1 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc @@ -28,6 +28,9 @@ export const OBF_CONF = { const TOOL = '/usr/bin/awg', PROTO = '/lib/netifd/proto/amneziawg.sh'; /** The packages AmneziaWG comes in (the Components tab installs them). */ const PACKAGES = [ 'kmod-amneziawg', 'amneziawg-tools' ]; +// A module constant, compiled once (a literal is compiled each time it runs): +// dump() checks it on every line of `awg show all dump`, every second. +const DIGITS = /^[0-9]+$/; /** netifd knows the amneziawg protocol (it reads the proto scripts when it starts). */ function proto_handler() { @@ -282,7 +285,7 @@ export function obf_errors(o) { let v = o[k]; if (v == null || v == '') continue; - if (!match(v, /^[0-9]+$/) || +v < r[0] || +v > r[1]) + if (!match(v, DIGITS) || +v < r[0] || +v > r[1]) push(errs, `${k}=${v} (${r[0]}-${r[1]})`); } if (o.jmin != null && o.jmax != null && +o.jmin > +o.jmax) @@ -375,7 +378,7 @@ export function client_config(m, dev) { if (!srv) return null; let host = core.endpoint_host(m, srv); - let ep = match(host, /:/) && !match(host, /^\[/) ? `[${host}]` : host; + let ep = index(host, ':') >= 0 && substr(host, 0, 1) != '[' ? `[${host}]` : host; let allowed = allowed_ips(m, srv, p); let dns = core.client_dns(m, srv, p); let mtu = core.device_mtu(srv, dev); @@ -506,9 +509,10 @@ export function dump(wanted) { let f = split(line, '\t'); if (length(f) < 5 || !valid_key(f[1])) continue; - if (valid_key(f[2]) && match(f[3] ?? '', /^[0-9]+$/)) + let key2 = valid_key(f[2]); + if (key2 && match(f[3] ?? '', DIGITS)) out.ifaces[f[0]] = { public_key: f[2], port: +f[3] }; - else if (length(f) >= 9 && (f[2] == '(none)' || valid_key(f[2]))) { + else if (length(f) >= 9 && (key2 || f[2] == '(none)')) { let ep = f[3] == '(none)' ? '' : f[3]; out.peers[f[1]] = { ifname: f[0], @@ -654,6 +658,9 @@ export function probes(m, ctx) { /* ---------- issued configurations ---------- */ const ISSUED = `${DATA_DIR}/issued.json`; +// The lines a fingerprint leaves out. A module constant, compiled once, not +// for each line of each device's configuration. +const DEVICE_OWN = /^(PrivateKey|Jc|Jmin|Jmax) /; function fnv32(str) { let h = 2166136261; @@ -670,7 +677,7 @@ function fnv32(str) { */ export function config_fingerprint(m, dev) { let c = dev ? client_config(m, dev) : null; - return c ? fnv32(join('\n', filter(split(c.conf, '\n'), (l) => !match(l, /^(PrivateKey|Jc|Jmin|Jmax) /)))) : null; + return c ? fnv32(join('\n', filter(split(c.conf, '\n'), (l) => !match(l, DEVICE_OWN)))) : null; }; /** Device id → fingerprint of the configuration last shown or downloaded. */ diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc index bb6a90c..5114bb4 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc @@ -4,7 +4,7 @@ import { cursor } from 'uci'; import { - valid_name, valid_key, valid_host, valid_date, slugify, host_label, ucut, name_rule, parse_cidr, cidr_overlaps, int2ip, ip2int, + valid_name, valid_key, valid_host, valid_iface, valid_date, slugify, host_label, ucut, name_rule, parse_cidr, cidr_overlaps, int2ip, ip2int, rand_hex, rand_bytes, date_end, month_key, read_json, DATA_DIR, RUN_DIR, uniq } from 'dawnline.util'; import { _, N_ } from 'dawnline.i18n'; @@ -635,7 +635,7 @@ export function update_person(c, m, id, a) { c.delete(CONFIG, id, 'home_net'); } if (type(a.home_nets) == 'array') { - let nets = uniq(filter(map(a.home_nets, (x) => trim(`${x}`)), (x) => match(x, /^[A-Za-z0-9_.@-]{1,32}$/))); + let nets = uniq(filter(map(a.home_nets, (x) => trim(`${x}`)), valid_iface)); if (length(nets)) c.set(CONFIG, id, 'home_net', nets); else @@ -895,7 +895,7 @@ export function wan_forwards(zone, proto) { c.load('firewall'); let out = []; c.foreach('firewall', 'redirect', (r) => { - if (match(r['.name'], /^dawnline_/) || r.enabled == '0' || (r.target ?? 'DNAT') != 'DNAT' || r.src != zone) + if (substr(r['.name'], 0, 9) == 'dawnline_' || r.enabled == '0' || (r.target ?? 'DNAT') != 'DNAT' || r.src != zone) return; // fw4's default is "tcp udp". let protos = split(type(r.proto) == 'array' ? join(' ', r.proto) : r.proto ?? 'tcp udp', /[ ,]+/); diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/fw.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/fw.uc index 234e8b8..5fc9dbe 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/fw.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/fw.uc @@ -126,7 +126,7 @@ export function sync(m, dry) { let stale = []; c.foreach('firewall', null, (s) => { - if (match(s['.name'], /^dawnline_/) && !want[s['.name']]) + if (substr(s['.name'], 0, 9) == 'dawnline_' && !want[s['.name']]) push(stale, s['.name']); }); for (let s in stale) { @@ -170,6 +170,9 @@ export function drift(m) { }; const MARK_ALL = 0xffffffff; +// "1000: from all fwmark 0x1 lookup 100", or "fwmark 0x1/0xff". A module +// constant, compiled once, not for each rule. +const MARK_RULE = /^(\d+):.*fwmark 0x([0-9a-f]+)(\/0x([0-9a-f]+))?.* lookup (\S+)/; function hx(n) { return sprintf('0x%x', n); @@ -184,8 +187,7 @@ export function proxy_diverts() { let out = [], seen = {}; for (let fam in [ '-4', '-6' ]) for (let line in split(sh_out(`ip ${fam} rule show 2>/dev/null`) ?? '', '\n')) { - // "1000: from all fwmark 0x1 lookup 100", or "fwmark 0x1/0xff". - let mm = match(line, /^(\d+):.*fwmark 0x([0-9a-f]+)(\/0x([0-9a-f]+))?.* lookup (\S+)/); + let mm = match(line, MARK_RULE); if (!mm || +mm[1] >= 32766) continue; let d = { pref: +mm[1], mark: hex(mm[2]), mask: mm[4] ? hex(mm[4]) : MARK_ALL, table: mm[5] }; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc index b096994..ce9c7e1 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc @@ -45,19 +45,27 @@ export function needs() { }; }; +// " 12: 00000000:1194 00000000:0000 07 …": local address, then the remote one (none). +// A module constant, compiled once: a literal in the loop would be compiled +// again for every socket (0.12 ms each on the WR3000P, some 90 sockets a call). +const UDP_UNCONNECTED = /^ *[0-9]+: [0-9A-F]+:([0-9A-F]{4}) [0-9A-F]+:0000 /; + /** UDP ports an unconnected socket is bound to (IPv4 and IPv6): nothing else can listen there. */ export function udp_bound() { let out = {}; for (let f in [ '/proc/net/udp', '/proc/net/udp6' ]) for (let line in split(readfile(f) ?? '', '\n')) { - // " 12: 00000000:1194 00000000:0000 07 …": local address, then the remote one (none). - let m = match(line, /^ *[0-9]+: [0-9A-F]+:([0-9A-F]{4}) [0-9A-F]+:0000 /); + let m = match(line, UDP_UNCONNECTED); if (m) out[hex(m[1])] = true; } return map(keys(out), (k) => +k); }; +// netstat's columns and the port of "0.0.0.0:53" / ":::53". Module constants, +// compiled once, not for each socket. +const BLANKS = /[ \t]+/, PORT_SUFFIX = /:([0-9]+)$/; + /** * Programs on 'tcp' or 'udp' ports, our portal left out: { port: "dnsmasq" }. * Kernel sockets (a tunnel's) have no name. @@ -65,10 +73,10 @@ export function udp_bound() { function port_programs(proto) { let out = {}; for (let line in split(sh_out(`netstat -ln${proto == 'tcp' ? 't' : 'u'}p 2>/dev/null`) ?? '', '\n')) { - let f = split(trim(line), /[ \t]+/); + let f = split(trim(line), BLANKS); if (f[0] != proto && f[0] != `${proto}6`) continue; - let m = match(f[3] ?? '', /:([0-9]+)$/); + let m = match(f[3] ?? '', PORT_SUFFIX); let owner = split(f[length(f) - 1], '/'); if (!m || !owner[1] || out[m[1]]) continue; @@ -264,6 +272,9 @@ function endpoint_check(id, title, problem, srv, host, proto_note) { return check(id, title, w.status, w.text, null, problem); } +// "1000: from all fwmark 0x1 lookup 100". A module constant, compiled once, not for each rule. +const MARK_RULE = /^(\d+):.*fwmark 0x([0-9a-f]+)(\/0x[0-9a-f]+)?.* lookup (\S+)/; + /** * Policy routing by another package (mwan3, pbr): an fwmark rule ahead of * Dawnline's (pref < 5205) whose table has a default route of its own sends @@ -273,7 +284,7 @@ function endpoint_check(id, title, problem, srv, host, proto_note) { function policy_routing() { let out = []; for (let line in split(sh_out('ip -4 rule show 2>/dev/null') ?? '', '\n')) { - let mm = match(line, /^(\d+):.*fwmark 0x([0-9a-f]+)(\/0x[0-9a-f]+)?.* lookup (\S+)/); + let mm = match(line, MARK_RULE); if (!mm || +mm[1] >= 5205) continue; let routes = sh_out(`ip -4 route show table ${q(mm[4])} 2>/dev/null`) ?? ''; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc index 0f134fb..6c0b3c0 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc @@ -124,8 +124,12 @@ export function online(dmp, id, peer) { return !!(peer && peer.handshake > 0 && time() - peer.handshake < ONLINE_WINDOW); }; +// "203.0.113.7:41821", "[2001:db8::1]:41821". A module constant, compiled once: +// the agent's watcher asks for every device, every second. +const ENDPOINT = /^\[?([^\]]+)\]?:[0-9]+$/; + export function endpoint_ip(ep) { - let m = match(ep ?? '', /^\[?([^\]]+)\]?:[0-9]+$/); + let m = match(ep ?? '', ENDPOINT); return m ? m[1] : ep; }; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/loop.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/loop.uc index bb37427..206b625 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/loop.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/loop.uc @@ -7,13 +7,24 @@ // └── NAT to a LAN address ┘ // // The netns is one more device on the LAN bridge with its own address (picked -// from the LAN subnet above the DHCP pool). Replies come back the same way. +// from the LAN subnet above the DHCP pool) and its own MAC (hashed from the +// bridge's), the same each time it is created: the router's neighbour table +// knows the address by that MAC, so a netns created again keeps its address +// instead of seeing it held by another device. Replies come back the same way. // Home-network destinations keep their direct route; per-person access is // still enforced on dawn0 before any of this (table inet dawnline). // // Clients also use the netns address as DNS: it forwards to the DNS the LAN // gets from DHCP, from the LAN side, so DNS interception applies as well. // +// The netns forwards and NATs every packet a second time (conntrack, the +// forward hook): about 40% more CPU per packet on an MT7981. A flowtable on +// its two links (dlx1, dll1) lets established TCP and UDP flows skip that +// work. The netns holds no access rules: who may reach what is judged on the +// tunnel interfaces in the root namespace, which no flowtable here touches. +// Without kernel flowtables (kmod-nft-offload) the loop runs as before, +// slower, and logs it once. +// // Separately, people with Home-only access get a plain resolver // (dawnline.resolver). While the netns exists it runs inside it and sends its // upstream queries back out through the transit link as forwarded traffic — @@ -41,6 +52,7 @@ const TX_ROOT = net.INTERNAL.transit, TX_NS = 'dlx1', LAN_ROOT = net.INTERNAL.la const PREF_LOOP_DNS = 5205, PREF_MAIN = 5210, PREF_LOOP = 5290; export const RESOLVER_CONF = resolver.CONF; const STATE = `${RUN_DIR}/loop.json`; +const NS_RULES = '/var/etc/dawnline-ns.nft'; const WHO = L_('Internet like a home device'); @@ -106,39 +118,64 @@ function used_addresses(dev) { return used; } +/** The MAC the netns's LAN link has now; null without the link. */ function our_mac() { return sh_out(`ip -n ${NS} -j link show ${LAN_NS} 2>/dev/null | jsonfilter -e '@[0].address'`); } +/** 32-bit FNV-1a of a string, continuing from `h`. */ +function fnv1a(s, h) { + for (let i = 0; i < length(s); i++) + h = ((h ^ ord(s, i)) * 16777619) & 0xffffffff; + return h; +} + /** - * A LAN address for the netns: keep the saved one while it is valid and not - * taken by someone else, otherwise the highest free host above the DHCP pool - * (then below it), skipping static leases and anything that answers. + * The MAC for the netns's LAN link, from the bridge's MAC: a locally + * administered unicast address hashed from it, so it is the same every time + * and differs between routers. Not the bridge's MAC with a bit flipped: radios + * and ports often get those. */ -function pick_address(lan, facts, saved, dev) { +export function lan_mac(bridge) { + let s = lc(trim(bridge ?? '')); + let h1 = fnv1a(`dawnline lan ${s}`, 0x811c9dc5), h2 = fnv1a(s, h1); + let b = [ ((h1 >> 24) & 0xfc) | 0x02, (h1 >> 16) & 0xff, (h1 >> 8) & 0xff, h1 & 0xff, (h2 >> 24) & 0xff, (h2 >> 16) & 0xff ]; + return join(':', map(b, (x) => sprintf('%02x', x))); +}; + +/** + * True when the netns may use a LAN address (a number): a host of the + * network, not the router's, not a static lease, outside the DHCP pool and + * not held by another device in `used` (address → MAC, or true without one). + * An entry with one of the MACs in `mine` is the netns itself, also from + * before it was created again. + */ +export function address_free(ip, lan, facts, used, mine) { + if (ip <= lan.net || ip >= lan.net + lan.size - 1 || ip == lan.ip || index(facts.statics, ip) >= 0) + return false; + if (facts.pool && ip >= facts.pool[0] && ip <= facts.pool[1]) + return false; + let u = used[int2ip(ip)]; + return u == null || index(mine, u) >= 0; +}; + +/** + * A LAN address for the netns: keep the saved one while it is free (see + * address_free; `mine` are the netns's MACs), otherwise the highest free host + * above the DHCP pool (then below it) that does not answer. + */ +function pick_address(lan, facts, saved, dev, mine) { let used = used_addresses(dev); - let mine = our_mac(); - let taken = (ip) => { - let s = int2ip(ip); - if (ip == lan.ip || index(facts.statics, ip) >= 0) - return true; - if (facts.pool && ip >= facts.pool[0] && ip <= facts.pool[1]) - return true; - let u = used[s]; - return u != null && !(mine && u == mine); - }; let sv = ip2int(saved ?? ''); - if (sv != null && sv > lan.net && sv < lan.net + lan.size - 1 && !taken(sv)) + if (sv != null && address_free(sv, lan, facts, used, mine)) return int2ip(sv); for (let ip = lan.net + lan.size - 2; ip > lan.net; ip--) { - if (taken(ip)) + if (!address_free(ip, lan, facts, used, mine)) continue; // Last check: nobody answers on it. sh(`ping -c 1 -W 1 -I ${q(dev)} ${int2ip(ip)}`); - let again = used_addresses(dev)[int2ip(ip)]; - if (again != null && !(mine && again == mine)) - continue; - return int2ip(ip); + if (address_free(ip, lan, facts, used_addresses(dev), mine)) + return int2ip(ip); } return null; } @@ -271,7 +308,9 @@ export function plan(m) { return { error: { code: 'no_ipv4', dev } }; let facts = dhcp_facts(d.logical, lan); let st = settings(); - let addr = pick_address(lan, facts, st.lan_address, dev); + let mac = lan_mac(readfile(`/sys/class/net/${dev}/address`)); + // The netns's MACs: the one it gets, and the one it has (a random one from an older version). + let addr = pick_address(lan, facts, st.lan_address, dev, [ mac, our_mac() ]); if (!addr) return { error: { code: 'no_address', net: `${int2ip(lan.net)}/${lan.prefix}` } }; let last = read_json(STATE, {}); @@ -291,6 +330,7 @@ export function plan(m) { dev, gateway: int2ip(lan.ip), address: addr, + mac, prefix: lan.prefix, dns: facts.dns ?? int2ip(lan.ip), transit: tx, @@ -303,10 +343,20 @@ export function plan(m) { /* ---------- apply ---------- */ -function ns_rules(p) { +/** + * The netns's nft script as text (nothing is loaded). With `fast`, a + * flowtable on the netns's own two links takes established TCP and UDP flows + * past conntrack and the forward hook here. Only dlx1 and dll1: the root + * namespace's links (dawn0, dlx0) stay out, the guard there sees every packet. + */ +export function ns_rules(p, fast) { return `table inet dawnline delete table inet dawnline -table inet dawnline { +table inet dawnline {${fast ? ` + flowtable ft { + hook ingress priority 0; + devices = { "${TX_NS}", "${LAN_NS}" }; + }` : ''} chain nat_pre { type nat hook prerouting priority dstnat; policy accept; iifname "${TX_NS}" ip daddr ${p.address} meta l4proto { tcp, udp } th dport 53 dnat ip to ${p.dns}:53 @@ -316,7 +366,8 @@ table inet dawnline { oifname "${LAN_NS}" masquerade } chain filter_forward { - type filter hook forward priority filter; policy drop; + type filter hook forward priority filter; policy drop;${fast ? ` + ct state established meta l4proto { tcp, udp } flow add @ft` : ''} ct state established,related accept iifname "${TX_NS}" oifname "${LAN_NS}" accept } @@ -329,6 +380,21 @@ table inet dawnline { } } `; +}; + +/** + * Load the netns's rules, with the flowtable when the kernel takes it, else + * without (the loop works either way). { fast, slow, err }: slow is why the + * flowtable failed, err why the rules without it failed too. + */ +function load_ns_rules(p) { + ensure_dir('/var/etc'); + let load = (fast) => { + writefile(NS_RULES, ns_rules(p, fast)); + return run([ `ip netns exec ${NS} nft -f ${NS_RULES}` ])[0]; + }; + let slow = load(true); + return slow ? { fast: false, slow, err: load(false) } : { fast: true }; } /** Our policy rules: in our priority band and bound to a Dawnline tunnel interface. */ @@ -382,21 +448,27 @@ function tunnel_ifnames() { return out; } -/** Remove the netns, links and rules. */ +/** Remove the netns, links and rules, and the router's neighbour entry for the netns. */ export function remove(ifnames) { ifnames ??= tunnel_ifnames(); + let last = read_json(STATE, {})?.plan; + // Read while the link is there: the entry is ours when it carries the netns's MAC. + let held = last?.dev ? used_addresses(last.dev)[last.address] : null; + let stale = type(held) == 'string' && index([ last.mac, our_mac() ], held) >= 0; let cmds = []; for (let r in current_rules(ifnames)) push(cmds, `ip -4 rule del priority ${r.priority} iif ${q(r.iif)}${r.dst ? ' to ' + r.dst + (r.dstlen != null ? '/' + r.dstlen : '') : ''} lookup ${r.table}`); - let t = read_json(STATE, {})?.plan?.table; - if (t) - push(cmds, `ip -4 route flush table ${t}`); + if (last?.table) + push(cmds, `ip -4 route flush table ${last.table}`); if (exists(TX_ROOT)) push(cmds, `ip link del ${TX_ROOT}`); if (exists(LAN_ROOT)) push(cmds, `ip link del ${LAN_ROOT}`); if (stat(`/var/run/netns/${NS}`)) push(cmds, `ip netns del ${NS}`); + // Left there, it would hold the address for a MAC nobody has. + if (stale) + push(cmds, `ip -4 neigh del ${q(last.address)} dev ${q(last.dev)}`); run(cmds); unlink(STATE); }; @@ -427,13 +499,18 @@ export function ensure(m, force) { if (same && healthy && !length(rules)) return p; + // A link made by an older version has a random MAC (its plan had none, so + // this runs once after an update): it gets the stable one. + let remac = exists(LAN_ROOT) && our_mac() != p.mac; let cmds = []; if (!stat(`/var/run/netns/${NS}`)) push(cmds, `ip netns add ${NS}`); if (!exists(TX_ROOT)) push(cmds, `ip link add ${TX_ROOT} type veth peer name ${TX_NS} netns ${NS}`); if (!exists(LAN_ROOT)) - push(cmds, `ip link add ${LAN_ROOT} type veth peer name ${LAN_NS} netns ${NS}`); + push(cmds, `ip link add ${LAN_ROOT} type veth peer name ${LAN_NS} address ${p.mac} netns ${NS}`); + if (remac) + push(cmds, `ip -n ${NS} link set ${LAN_NS} down`, `ip -n ${NS} link set ${LAN_NS} address ${p.mac}`); let errs = run(cmds); cmds = [ `ip addr flush dev ${TX_ROOT}`, @@ -457,10 +534,13 @@ export function ensure(m, force) { ]; for (let s in p.servers) push(cmds, `ip -n ${NS} route replace ${q(s.subnet)} via ${q(p.tx_root)} dev ${TX_NS}`); - ensure_dir('/var/etc'); - writefile('/var/etc/dawnline-ns.nft', ns_rules(p)); - push(cmds, `ip netns exec ${NS} nft -f /var/etc/dawnline-ns.nft`); + // The router knows the address by the old MAC: ask again now, not when the entry expires. + if (remac) + push(cmds, `ip -4 neigh flush to ${p.address} dev ${q(p.dev)}`); push(errs, ...run(cmds)); + let ft = load_ns_rules(p); + if (ft.err) + push(errs, ft.err); push(errs, ...run(sync_rules(p, ifnames))); if (length(errs)) { @@ -472,11 +552,17 @@ export function ensure(m, force) { return { error: why }; } ensure_dir(RUN_DIR); - write_json(STATE, { applied: time(), plan: p, transit: p.transit }, 0o644); + write_json(STATE, { applied: time(), plan: p, transit: p.transit, fast: ft.fast }, 0o644); if (!last.applied || last.plan?.dev != p.dev || last.plan?.address != p.address) log(sprintf(L_('is on · traffic enters %s as %s'), p.dev, p.address), 'up'); else if (!healthy) log(sprintf(L_('was broken - set up again (%s as %s)'), p.dev, p.address), 'repair'); + // Once, not again on every apply while the module is still missing. + if (!ft.fast && last.fast !== false) + log(L_('runs without its fast path'), 'info', join('\n', [ + L_('Without kmod-nft-offload every packet on this path passes the firewall twice. Install it and restart Dawnline.'), + ft.slow, + ])); return p; }; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/net.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/net.uc index 09776da..d41db36 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/net.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/net.uc @@ -163,7 +163,7 @@ export function snapshot(fresh) { let flags = hex(sysread(dev, 'flags') || '0'); let kind = +(sysread(dev, 'type') || '0'); let master = readlink(`${SYS}/${dev}/master`); - master = master ? replace(master, /^.*\//, '') : null; + master = master ? substr(master, rindex(master, '/') + 1) : null; let bridge = stat(`${SYS}/${dev}/bridge`) != null; let wifi = stat(`${SYS}/${dev}/phy80211`) != null || stat(`${SYS}/${dev}/wireless`) != null; let nets = routes[dev] ? collapse(routes[dev]) : []; @@ -295,10 +295,13 @@ export function lan_names() { return out; }; +// A module constant, compiled once: event_hosts runs for every event of the log. +const ANY_IPV4 = /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/g; + /** Event addresses that belong to devices at home, with their names ({ ip: name }). */ export function event_hosts(e, names) { let out = null; - for (let ip in match(e.detail ?? '', /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/g) ?? []) + for (let ip in match(e.detail ?? '', ANY_IPV4) ?? []) if (names[ip[0]]) (out ??= {})[ip[0]] = names[ip[0]]; return out; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portalcert.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portalcert.uc index 54fd317..7ec1050 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portalcert.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portalcert.uc @@ -21,11 +21,14 @@ export function name_covers(name, host) { return substr(name, 0, 2) == '*.' && dot > 0 && substr(host, dot) == substr(name, 1); }; +// A module constant, compiled once, not for each file of the directory. +const FULLCHAIN = /^(.+)\.fullchain\.crt$/; + /** ACME certificates on the router and the names each covers. */ export function acme_certs() { let out = []; for (let f in sort(lsdir('/etc/ssl/acme') ?? [])) { - let m = match(f, /^(.+)\.fullchain\.crt$/); + let m = match(f, FULLCHAIN); if (!m) continue; let c = `/etc/ssl/acme/${f}`, k = `/etc/ssl/acme/${m[1]}.key`; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc index 4c11b4f..027d82e 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc @@ -325,7 +325,8 @@ function server_create(a) { set('detected_wan', snap.wan); if (snap.lan) set('detected_lan', snap.lan); - set('lan_like', a.lan_like === false || a.lan_like === '0' ? '0' : '1'); + // Off unless asked for: the loop through the LAN costs speed (the wizard says how much). + set('lan_like', a.lan_like === true || a.lan_like === 1 || a.lan_like === '1' ? '1' : '0'); set('enabled', '1'); if (a.portal_enabled != null) { let on = a.portal_enabled === true || a.portal_enabled === 1 || a.portal_enabled === '1'; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/updates.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/updates.uc index 0bd5295..bcd3ba8 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/updates.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/updates.uc @@ -44,11 +44,14 @@ function awg_tunnels() { return out; } +// A line of /etc/openwrt_release. A module constant, compiled once, not for each line. +const RELEASE_LINE = /^DISTRIB_(RELEASE|TARGET|ARCH)='([^']*)'/; + function status(a) { let m = core.load(); let rel = {}; for (let line in split(readfile('/etc/openwrt_release') ?? '', '\n')) { - let x = match(line, /^DISTRIB_(RELEASE|TARGET|ARCH)='([^']*)'/); + let x = match(line, RELEASE_LINE); if (x) rel[lc(x[1])] = x[2]; } diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc index 9cbc19d..fce329e 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc @@ -5,7 +5,7 @@ import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs'; import { _ } from 'dawnline.i18n'; -export const VERSION = '0.12.1'; +export const VERSION = '0.13.0'; /** GitHub repository with Dawnline releases (updates and the installer). */ export const REPO = 'tickcount/luci-app-dawnline'; export const RUN_DIR = '/var/run/dawnline'; @@ -365,8 +365,14 @@ export function slog_restore() { /* ---------- IPv4 ---------- */ +// Module constants, compiled once: a regex literal is compiled again each +// time it runs (rules/backend.md), and these run for every address and every +// network in a list (status, the portal, the agent's checks). +const IPV4 = /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/; +const CIDR = /^([0-9.]+)(\/([0-9]+))?$/; + export function ip2int(ip) { - let m = match(ip, /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/); + let m = match(ip, IPV4); if (!m) return null; let n = 0; @@ -389,7 +395,7 @@ export function int2ip(n) { * allowed networks use this; parse_cidr is the stricter one for subnets. */ export function cidr_any(s) { - let m = match(s ?? '', /^([0-9.]+)(\/([0-9]+))?$/); + let m = match(s ?? '', CIDR); if (!m) return null; let ip = ip2int(m[1]), prefix = m[3] != null ? +m[3] : 32; @@ -432,10 +438,10 @@ export function cloudflare_ip(a) { /** Parse "a.b.c.d/len" → { net, prefix, first, last, size } (net is the masked base). */ export function parse_cidr(cidr) { - let m = match(cidr ?? '', /^([0-9.]+)\/([0-9]+)$/); - if (!m) + let m = match(cidr ?? '', CIDR); + if (!m || m[3] == null) return null; - let ip = ip2int(m[1]), prefix = +m[2]; + let ip = ip2int(m[1]), prefix = +m[3]; if (ip == null || prefix < 8 || prefix > 30) return null; let size = 1 << (32 - prefix); @@ -549,8 +555,24 @@ export function name_rule() { return _('Enter a name: up to 48 characters, without < > " or \\.'); }; +// Character sets for checks written without a regex: ucode compiles a regex +// literal each time it runs, and musl's regcomp takes milliseconds for a +// bounded repeat (rules/backend.md). ltrim stops at a NUL byte, so a string +// with one fails these checks (a regex looks only up to it). +const ASCII_ALNUM = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; +const B64 = `${ASCII_ALNUM}+/`; +// 32 bytes are 43 base64 characters: the last holds four bits of the key and two zero bits. +const KEY_LAST = 'AEIMQUYcgkosw048'; + +/** + * A (Amnezia)WireGuard key: 32 bytes in base64, 43 characters and "=", the + * same as /^[A-Za-z0-9+\/]{42}[AEIMQUYcgkosw048]=$/ without its 1.7 ms + * compile on the WR3000P: the agent's watcher checks two keys per line of + * `awg show all dump` every second. This takes about 0.03 ms. + */ export function valid_key(s) { - return type(s) == 'string' && match(s, /^[A-Za-z0-9+\/]{42}[AEIMQUYcgkosw048]=$/) != null; + return type(s) == 'string' && length(s) == 44 && substr(s, 43) == '=' && + index(KEY_LAST, substr(s, 42, 1)) >= 0 && ltrim(substr(s, 0, 42), B64) == ''; }; /** An IPv6 address in its usual spelling (no zone, no brackets). */ @@ -558,10 +580,25 @@ export function is_ip6(s) { return type(s) == 'string' && match(s, /^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/) != null && match(s, /:::/) == null; }; +const LABEL = `${ASCII_ALNUM}-`; + +/** + * Dot-separated labels of 1-63 letters, digits and dashes, none starting or + * ending with a dash: the same as + * /^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/ + * without its 10 ms compile on the WR3000P. + */ +function host_name(s) { + for (let l in split(s, '.')) + if (length(l) < 1 || length(l) > 63 || ltrim(l, LABEL) != '' || + index(ASCII_ALNUM, substr(l, 0, 1)) < 0 || index(ASCII_ALNUM, substr(l, -1)) < 0) + return false; + return true; +} + +/** A host name or an IP address, as a public address or the portal's name may be given. */ export function valid_host(s) { - return type(s) == 'string' && length(s) <= 253 && - (match(s, /^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/) != null || - ip2int(s) != null || is_ip6(s)); + return type(s) == 'string' && length(s) <= 253 && (host_name(s) || ip2int(s) != null || is_ip6(s)); }; /** YYYY-MM-DD, and a day that exists (2026-02-30 does not). */ @@ -573,11 +610,18 @@ export function valid_date(s) { return l.year == +m[1] && l.mon == +m[2] && l.mday == +m[3]; }; +// Runs of other characters become one dash. Module constants: host_label and +// tunnel_name run for every device of a status or a portal answer. +const NOT_LC_ALNUM = /[^a-z0-9]+/g, NOT_ALNUM = /[^A-Za-z0-9]+/g; +// Names Windows keeps for devices: no file may be called that, whatever the case. +const WIN_DEVICES = [ 'con', 'prn', 'aux', 'nul', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', + 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9' ]; + /** Turn a display name into a portal slug candidate ("Мама Таня" → "mama-tanya"). */ export function slugify(s) { let out = lc(translit(trim(`${s ?? ''}`))); - out = replace(out, /[^a-z0-9]+/g, '-'); - out = replace(out, /^-+|-+$/g, ''); + out = replace(out, NOT_LC_ALNUM, '-'); + out = trim(out, '-'); return substr(out, 0, 32) || 'user'; }; @@ -586,8 +630,8 @@ export function slugify(s) { * "telefon"): at most 40 characters, "device" when nothing is left. */ export function host_label(s) { - let l = replace(lc(translit(`${s ?? ''}`)), /[^a-z0-9]+/g, '-'); - l = replace(substr(replace(l, /^-+|-+$/g, ''), 0, 40), /-+$/g, ''); + let l = replace(lc(translit(`${s ?? ''}`)), NOT_LC_ALNUM, '-'); + l = rtrim(substr(trim(l, '-'), 0, 40), '-'); return l || 'device'; }; @@ -598,9 +642,9 @@ export function host_label(s) { * refuses its device names (CON, NUL, COM1…). "dawnline" when nothing is left. */ export function tunnel_name(s) { - let l = replace(translit(`${s ?? ''}`), /[^A-Za-z0-9]+/g, '-'); - l = replace(substr(replace(l, /^-+|-+$/g, ''), 0, 15), /-+$/g, ''); - return l && !match(l, /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i) ? l : 'dawnline'; + let l = replace(translit(`${s ?? ''}`), NOT_ALNUM, '-'); + l = rtrim(substr(trim(l, '-'), 0, 15), '-'); + return l && index(WIN_DEVICES, lc(l)) < 0 ? l : 'dawnline'; }; /* ---------- time ---------- */ @@ -660,9 +704,21 @@ export function now() { return time(); }; +const IFACE = `${ASCII_ALNUM}_.@-`; + +/** + * A netifd interface name (network.interface., a person's home network): + * 1-32 letters, digits and _ . @ -, the same as /^[A-Za-z0-9_.@-]{1,32}$/ + * without its 3 ms compile on the WR3000P (iface_status runs several times for + * the Overview's status, and in the agent's minute checks). + */ +export function valid_iface(s) { + return type(s) == 'string' && length(s) >= 1 && length(s) <= 32 && ltrim(s, IFACE) == ''; +}; + /** netifd's view of an interface (ubus network.interface. status), or null. */ export function iface_status(ifname) { - if (!match(ifname ?? '', /^[A-Za-z0-9_.@-]{1,32}$/)) + if (!valid_iface(ifname)) return null; let s = sh_out(`ubus call network.interface.${ifname} status 2>/dev/null`); if (!s) diff --git a/rules/backend.md b/rules/backend.md index 971fa0a..18733ed 100644 --- a/rules/backend.md +++ b/rules/backend.md @@ -23,7 +23,8 @@ Read with `code-standards.md`. Everything here runs on a small router (2 × Cort - **The portal is CGI:** every request starts ucode and compiles the module graph, about 140 ms of CPU before any work (a full `state` answer about 180 ms). No periodic polling from the portal; one request per user action. - **rpcd keeps the admin backend loaded:** LuCI RPC calls are cheap, so the admin UI may poll small methods often (`rev`), and the heavy ones (`status`) only on change or rarely. -- **Code on the agent's 1-second watcher stays in the low milliseconds:** one `awg show all dump` (about 4 ms with process start), the model cached by the config file's mtime/inode (`core.load()` is about 4 ms), files written only when something changed. Slow work (geo lookups, apply) runs only on a transition. +- **Code on the agent's 1-second watcher stays in the low milliseconds:** one `awg show all dump` (about 4 ms with process start, 1 ms to parse), the model cached by the config file's mtime/inode (`core.load()` is about 4 ms), files written only when something changed. Slow work (geo lookups, apply) runs only on a transition. +- **A regex literal is compiled every time it runs:** ucode calls regcomp for `/…/` each time the expression is evaluated, and musl's regcomp grows with the pattern. Bounded repeats are copied out (`{42}` about 1.7 ms on the WR3000P, `[A-Za-z0-9_.@-]{1,32}` 3 ms, two `{0,61}` 10 ms), alternations and classes add up (`/^(PrivateKey|Jc|Jmin|Jmax) /` 0.11 ms, `/^[0-9]+$/` 0.02 ms); matching a compiled regex takes 0.01–0.1 ms. In a loop or on a hot path, hoist the regex into a module `const` (compiled once, when the module loads — every portal request pays that too) or check with `length`/`substr`/`ltrim` (`util.valid_key`, `valid_host`, `valid_iface`). - Measure before and after on the router (a loop of 20–200 calls, `/proc/self/stat` CPU ticks, system busy from `/proc/stat`) when adding anything periodic. ## Checks diff --git a/rules/frontend.md b/rules/frontend.md index 0fe981b..51d0bc1 100644 --- a/rules/frontend.md +++ b/rules/frontend.md @@ -1,6 +1,6 @@ # Frontend (TypeScript: admin UI and portal) -Read with `code-standards.md` and, for anything visible, `ui-design.md` and `i18n.md` (every visible string goes through `_()`). +Read with `code-standards.md` and, for anything visible, `ui-design.md` and `i18n.md` (every visible string goes through `_()`). Portal work starts with `DESIGN.md` (its tokens, components and motion). ## Code diff --git a/rules/ui-design.md b/rules/ui-design.md index 04a80fd..21c313d 100644 --- a/rules/ui-design.md +++ b/rules/ui-design.md @@ -2,6 +2,8 @@ The bar is a modern product UI (Linear / Vercel / Raycast level), not a "native" LuCI form. A plain label + input row, a bare radio list, three columns of check marks or a text dump is a first draft, never the result. +**The portal has its own design system, `DESIGN.md`** (repo root): read it before any portal work, mocks included. Build from its tokens, components and spring tokens, follow its Do's and Don'ts, and update it in the same change when the portal's look or motion changes. The admin follows this file and the LuCI theme. + ## Approach - **Mock first.** Any visible change beyond a one-line fix: show a mockup (2–4 genuinely different options when the direction is open) with a recommendation, then build the chosen one. Do not start coding a layout the user has not seen. diff --git a/scripts/lint-ucode.py b/scripts/lint-ucode.py index cddc19a..32cb308 100755 --- a/scripts/lint-ucode.py +++ b/scripts/lint-ucode.py @@ -41,9 +41,13 @@ def strip_comments(text): return re.sub(r'//[^\n]*|/\*.*?\*/', '', text, flags=re.S) -def blank_comments(text): - """Comments replaced by their newlines: line numbers stay, their text goes.""" - return re.sub(r'//[^\n]*|/\*.*?\*/', lambda m: '\n' * m.group(0).count('\n'), text, flags=re.S) +def blank_comments_templates(text): + """Comments and template literals replaced by their newlines, strings kept: + line numbers stay, and a `}` that starts a line of a template (nft rules) + ends no function. A template inside another one's `${…}` reads as code: + good enough for how Dawnline writes them.""" + return re.sub(r"//[^\n]*|/\*.*?\*/|'(?:\\.|[^'\\\n])*'|\"(?:\\.|[^\"\\\n])*\"|`(?:\\.|[^`\\])*`", + lambda m: m.group(0) if m.group(0)[0] in '\'"' else '\n' * m.group(0).count('\n'), text, flags=re.S) # A regex literal on one line: `/…/` with no slash inside, followed by flags or @@ -66,7 +70,7 @@ for f in files: problem(f"{f}:{line}: {name}() is used before its definition") # In a module an exported function is an expression statement: its closing # brace needs a semicolon ("Expecting ';'" breaks the whole module). - lines = blank_comments(open(f, encoding='utf-8').read()).split('\n') + lines = blank_comments_templates(open(f, encoding='utf-8').read()).split('\n') inside = None for n, text in enumerate(lines, 1): if inside is None and re.match(r'^export function \w+\(', text): diff --git a/tests/ucode/awg.test.uc b/tests/ucode/awg.test.uc index fa76447..07d8f1a 100644 --- a/tests/ucode/awg.test.uc +++ b/tests/ucode/awg.test.uc @@ -1,8 +1,10 @@ // dawnline.awg: disguise presets against their own validation, the parser // of `awg show all dump` on the output formats of AmneziaWG 1.0, 2.0 and 3.1 -// (the stand-in awg in fixtures/bin prints the fixture put at AWG_DUMP), and Reconnect. +// (the stand-in awg in fixtures/bin prints the fixture put at AWG_DUMP), +// Reconnect, and a device's configuration from the fixture model. import { readfile, writefile, unlink } from 'fs'; import * as awg from 'dawnline.awg'; +import * as core from 'dawnline.core'; const AWG_DUMP = '/tmp/dawnline-tests/awg-dump'; let fixtures = sourcepath(0, true) + '/fixtures'; @@ -115,3 +117,39 @@ test('blocked reasons', () => { eq(awg.blocked_text(srv('has an invalid interface name "x"')), 'Home has an invalid interface name "x".', 'old fragment'); eq(awg.blocked_note({ code: 'ifname', ifname: 'x' }), 'has an invalid interface name "x"', 'the log keeps the fragment'); }); + +test('client_config: an IPv6 endpoint in brackets, without a regex', () => { + let m = core.load(); + let srv = m.servers.main, dev = m.devices.alice_phone; + let ep = (h) => { + srv.endpoint = h; + return match(awg.client_config(m, dev).conf, /\nEndpoint = ([^\n]*)\n/)?.[1]; + }; + eq(ep('vpn.example.com'), 'vpn.example.com:51820', 'a name'); + eq(ep('203.0.113.7'), '203.0.113.7:51820', 'IPv4'); + eq(ep('2001:db8::1'), '[2001:db8::1]:51820', 'IPv6'); + eq(ep('[2001:db8::1]'), '[2001:db8::1]:51820', 'IPv6 in brackets already'); + eq(ep(''), 'vpn.example.com:51820', 'the portal name when the server has none'); + // The regexes it stands for, on hosts changed at each character. + for (let h in [ '2001:db8::1', '[::1]', 'a.b' ]) + for (let i = 0; i <= length(h); i++) + for (let c in [ ':', '[', ']', 'a', '' ]) { + let s = `${substr(h, 0, i)}${c}${substr(h, i + 1)}`; + let want = match(s, /:/) && !match(s, /^\[/) ? `[${s}]` : s; + eq(ep(s), `${want || 'vpn.example.com'}:51820`, s); + } +}); + +test('config_fingerprint leaves out the private key and the junk', () => { + let m = core.load(); + let dev = m.devices.alice_phone; + let f = awg.config_fingerprint(m, dev); + ok(match(f, /^[0-9a-f]{8}$/), 'eight hex digits'); + dev.private_key = 'yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk='; + eq(awg.config_fingerprint(m, dev), f, 'a private key'); + m.servers.main.obf.jc = '7'; + eq(awg.config_fingerprint(m, dev), f, 'another junk count'); + m.servers.main.port = 51821; + ok(awg.config_fingerprint(m, dev) != f, 'another port'); + eq(awg.config_fingerprint(m, null), null, 'no device'); +}); diff --git a/tests/ucode/core.test.uc b/tests/ucode/core.test.uc index 2244aa3..754f651 100644 --- a/tests/ucode/core.test.uc +++ b/tests/ucode/core.test.uc @@ -1,6 +1,7 @@ // dawnline.core: the model read from the fixture config (real libuci), access // hours, quotas and the derived person state at an explicit time, address -// allocation and the automatic MTU. +// allocation, the automatic MTU, and other packages' port forwards. +import { readfile, writefile, unlink } from 'fs'; import * as core from 'dawnline.core'; // A local time that no time zone turns into another day. @@ -164,3 +165,29 @@ test('device_labels', () => { let p = { id: 'p', devices: [ 'd', 'c', 'b', 'a' ] }; eq(core.device_labels(mm, p), { a: 'iphone', b: 'iphone-2', c: 'telefon', d: 'telefon-2' }, 'unique by age'); }); + +test('wan_forwards leaves out Dawnline\'s own, without a regex', () => { + // A firewall config for this case only (the container's own is put back). + let path = '/etc/config/firewall', saved = readfile(path); + let names = [ 'dawnline_portal', 'dawnline_', 'dawnline', 'Dawnline_x', 'xdawnline_y', 'dawnlinex_1', 'web' ]; + let conf = ''; + for (let i = 0; i < length(names); i++) + conf += sprintf("config redirect '%s'\n\toption src 'wan'\n\toption proto 'udp'\n\toption src_dport '%d'\n\n", names[i], 6000 + i); + writefile(path, conf); + let got = null, err = null; + try { + got = core.wan_forwards('wan', 'udp'); + } + catch (e) { + err = e; + } + if (saved != null) + writefile(path, saved); + else + unlink(path); + if (err) + die(err.message); + // The names the pattern it stands for let through. + eq(map(got, (f) => f.name), filter(names, (n) => !match(n, /^dawnline_/)), 'names'); + eq(got[0], { from: 6002, to: 6002, name: 'dawnline' }, 'a forward'); +}); diff --git a/tests/ucode/loop.test.uc b/tests/ucode/loop.test.uc index 47da681..c7c04ef 100644 --- a/tests/ucode/loop.test.uc +++ b/tests/ucode/loop.test.uc @@ -1,6 +1,7 @@ // dawnline.loop: the "like a home device" link's errors, stored as codes and -// put into words when read. +// put into words when read; the netns's MAC and which LAN address it may use. import * as loop from 'dawnline.loop'; +import { ip2int, parse_cidr } from 'dawnline.util'; test('error_text', () => { eq(loop.error_text(null), null, 'no error'); @@ -10,3 +11,48 @@ test('error_text', () => { eq(loop.error_text({ code: 'setup', detail: 'ip: RTNETLINK answers: File exists' }), 'Setup failed: ip: RTNETLINK answers: File exists', 'setup'); eq(loop.error_text('an old message'), 'an old message', 'older files: as written'); }); + +test('lan_mac', () => { + let mac = loop.lan_mac('d4:0d:ab:06:94:aa\n'); + // Pinned: another MAC after an update would make the netns look like someone else once. + eq(mac, '7a:4e:71:7a:e0:83', 'hashed from the bridge MAC, as sysfs gives it'); + eq(loop.lan_mac('D4:0D:AB:06:94:AA'), mac, 'the same however it is written'); + ok(loop.lan_mac('d4:0d:ab:06:94:ab') != mac, 'another bridge, another MAC'); + for (let b in [ 'd4:0d:ab:06:94:aa', 'd4:0d:ab:06:94:ab', '00:00:00:00:00:00', 'ff:ff:ff:ff:ff:ff' ]) { + let m = loop.lan_mac(b); + ok(match(m, /^[0-9a-f]{2}(:[0-9a-f]{2}){5}$/), `${b}: a MAC`); + let first = hex(substr(m, 0, 2)); + eq([ first & 1, first & 2 ], [ 0, 2 ], `${b}: unicast, locally administered`); + } +}); + +test('address_free', () => { + let lan = parse_cidr('10.0.1.1/24'); + let facts = { pool: [ ip2int('10.0.1.100'), ip2int('10.0.1.249') ], statics: [ ip2int('10.0.1.50') ] }; + let ours = '7a:4e:71:7a:e0:83', old = '7e:8b:31:7d:04:ba', other = '3c:22:fb:01:02:03'; + let free = (ip, used, mine) => loop.address_free(ip2int(ip), lan, facts, used ?? {}, mine ?? [ ours, null ]); + ok(free('10.0.1.254'), 'nobody on it'); + ok(free('10.0.1.254', { '10.0.1.254': ours }), 'the neighbour entry of the netns before it was created again'); + ok(free('10.0.1.254', { '10.0.1.254': old }, [ ours, old ]), 'the netns as it is now (an older version gave it a random MAC)'); + ok(!free('10.0.1.254', { '10.0.1.254': old }), 'a MAC that is not the netns\'s: someone else'); + ok(!free('10.0.1.254', { '10.0.1.254': other }, [ ours, null ]), 'another device'); + ok(!free('10.0.1.254', { '10.0.1.254': true }), 'an entry without a MAC'); + ok(!free('10.0.1.1'), 'the router'); + ok(!free('10.0.1.50'), 'a static lease'); + ok(!free('10.0.1.100') && !free('10.0.1.249'), 'the DHCP pool'); + ok(free('10.0.1.99') && free('10.0.1.250'), 'next to the pool'); + ok(!free('10.0.1.0') && !free('10.0.1.255'), 'the network and broadcast addresses'); + ok(loop.address_free(ip2int('10.0.1.120'), lan, { pool: null, statics: [] }, {}, [ ours ]), 'no DHCP on the LAN: the pool is free'); +}); + +// The netns's rules: the flowtable only on the netns's own links, never on +// the root namespace's (the guard on dawn0 must see every packet). +test('ns_rules', () => { + let p = { address: '10.0.1.250', dns: '10.0.1.1' }; + let fast = loop.ns_rules(p, true), plain = loop.ns_rules(p, false); + eq(map(match(fast, /devices = \{ ([^}]*) \}/g), (m) => m[1]), [ '"dlx1", "dll1"' ], 'one flowtable, on dlx1 and dll1 only'); + ok(!match(fast, /dlx0|dll0/), 'no root namespace link'); + ok(index(fast, 'ct state established meta l4proto { tcp, udp } flow add @ft') >= 0, 'established flows added'); + ok(index(plain, 'flowtable') < 0 && index(plain, 'flow add') < 0, 'plain: no flowtable'); + eq(replace(fast, /\n\tflowtable ft \{(\n\t\t[^\n]*)*\n\t\}|\n\t\tct state established meta l4proto \{ tcp, udp \} flow add @ft/g, ''), plain, 'otherwise the same rules'); +}); diff --git a/tests/ucode/util.test.uc b/tests/ucode/util.test.uc index bb6cd24..057e0c0 100644 --- a/tests/ucode/util.test.uc +++ b/tests/ucode/util.test.uc @@ -55,6 +55,76 @@ test('valid_slug and valid_key', () => { ok(!util.valid_key(''), 'empty'); }); +test('valid_key without a regex', () => { + let k = 'yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk='; + ok(util.valid_key('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop0='), 'letters'); + ok(util.valid_key('qrstuvwxyz0123456789+/qrstuvwxyz0123456789w='), 'digits, + and /'); + ok(!util.valid_key(`${k}=`), '45 characters'); + ok(!util.valid_key(substr(k, 1)), '43 characters'); + ok(!util.valid_key(replace(k, '+', '-')), 'URL-safe alphabet'); + ok(!util.valid_key(`${substr(k, 0, 20)}=${substr(k, 21)}`), 'padding inside'); + ok(!util.valid_key(`${substr(k, 0, 20)}\u0000${substr(k, 21)}`), 'NUL byte'); + ok(!util.valid_key(`${k}\u0000x`), 'NUL and more after the key'); + ok(!util.valid_key(` ${substr(k, 1)}`), 'space'); + ok(!util.valid_key(null), 'null'); + ok(!util.valid_key([ k ]), 'array'); + // The pattern it stands for, on keys changed at both ends and in the middle. + let re = /^[A-Za-z0-9+\/]{42}[AEIMQUYcgkosw048]=$/; + for (let i in [ 0, 1, 21, 41, 42, 43 ]) + for (let c in [ 'A', 'z', '0', '9', '+', '/', 'b', 'k', '=', '-', '_', ' ', '.', '\n' ]) { + let s = `${substr(k, 0, i)}${c}${substr(k, i + 1)}`; + eq(util.valid_key(s), match(s, re) != null, s); + } +}); + +test('valid_host without a regex', () => { + ok(util.valid_host('a'), 'one character'); + ok(util.valid_host('xn--80ak6aa92e.com'), 'dashes inside a label'); + ok(util.valid_host('Router-1.LAN'), 'upper case'); + ok(!util.valid_host('example.com.'), 'trailing dot'); + ok(!util.valid_host('.example.com'), 'leading dot'); + ok(!util.valid_host('a-.example.com'), 'dash ending a label'); + ok(!util.valid_host('under_score.example'), 'underscore'); + ok(!util.valid_host('example.com\u0000x'), 'NUL byte'); + // The pattern it stands for (and the address checks after it), on names with + // each character replaced, removed or with one inserted before it. + let re = /^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/; + let old = (s) => length(s) <= 253 && (match(s, re) != null || util.ip2int(s) != null || util.is_ip6(s)); + let label = replace(sprintf('%63s', ''), ' ', 'b'); + for (let h in [ 'vpn.example.com', 'a.b-c.d', `${label}.x`, `x.${label}`, '203.0.113.7', '2001:db8::1' ]) { + let at = []; + for (let i = 0; i <= length(h); i++) + if (length(h) < 20 || i < 2 || i > length(h) - 3 || (i > 60 && i < 66)) + push(at, i); + for (let i in at) + for (let c in [ 'a', 'Z', '0', '-', '.', '_', ' ', '*', ':', '\n', '' ]) { + let s = `${substr(h, 0, i)}${c}${substr(h, i + 1)}`, t = `${substr(h, 0, i)}${c}${substr(h, i)}`; + eq(util.valid_host(s), old(s), s); + eq(util.valid_host(t), old(t), t); + } + } +}); + +test('valid_iface without a regex', () => { + ok(util.valid_iface('wan'), 'wan'); + ok(util.valid_iface('lan.100'), 'dot'); + ok(util.valid_iface('@wan6'), 'alias'); + ok(!util.valid_iface(''), 'empty'); + ok(!util.valid_iface(replace(sprintf('%33s', ''), ' ', 'a')), '33 characters'); + ok(!util.valid_iface('wan\u0000x'), 'NUL byte'); + ok(!util.valid_iface(null), 'null'); + ok(!util.valid_iface([ 'wan' ]), 'array'); + // The pattern it stands for, as above. + let re = /^[A-Za-z0-9_.@-]{1,32}$/; + for (let n in [ 'wan', 'br-lan.10', 'A_z@0', replace(sprintf('%32s', ''), ' ', 'x') ]) + for (let i = 0; i <= length(n); i++) + for (let c in [ 'a', 'Z', '9', '_', '.', '@', '-', ' ', '$', ';', '/', '\n', '' ]) { + let s = `${substr(n, 0, i)}${c}${substr(n, i + 1)}`, t = `${substr(n, 0, i)}${c}${substr(n, i)}`; + eq(util.valid_iface(s), match(s, re) != null, s); + eq(util.valid_iface(t), match(t, re) != null, t); + } +}); + test('ip2int / int2ip / cidr_any', () => { eq(util.ip2int('10.9.0.1'), 168361985, 'ip2int'); eq(util.int2ip(168361985), '10.9.0.1', 'int2ip'); @@ -85,6 +155,40 @@ test('parse_cidr', () => { ok(!util.in_cidr('10.9.1.1', util.parse_cidr('10.9.0.0/24')), 'not in_cidr'); }); +test('parse_cidr and cidr_any share one pattern', () => { + // The patterns each had, on networks changed at each character. + let old_any = (s) => { + let m = match(s ?? '', /^([0-9.]+)(\/([0-9]+))?$/); + if (!m) + return null; + let ip = util.ip2int(m[1]), prefix = m[3] != null ? +m[3] : 32; + if (ip == null || prefix > 32) + return null; + let size = 1 << (32 - prefix); + return { net: ip - ip % size, prefix, size, ip }; + }; + let old_cidr = (s) => { + let m = match(s ?? '', /^([0-9.]+)\/([0-9]+)$/); + if (!m) + return null; + let ip = util.ip2int(m[1]), prefix = +m[2]; + if (ip == null || prefix < 8 || prefix > 30) + return null; + let size = 1 << (32 - prefix); + let net = ip - ip % size; + return { net, prefix, size, first: net + 1, last: net + size - 2, ip }; + }; + for (let n in [ '10.9.0.0/24', '192.168.1.77/30', '0.0.0.0/8', '10.0.0.5', '1.2.3.4/32', '//', '' ]) + for (let i = 0; i <= length(n); i++) + for (let c in [ '0', '9', '.', '/', ' ', 'a', '-', '\n', '' ]) { + let s = `${substr(n, 0, i)}${c}${substr(n, i + 1)}`, t = `${substr(n, 0, i)}${c}${substr(n, i)}`; + eq(util.parse_cidr(s), old_cidr(s), s); + eq(util.parse_cidr(t), old_cidr(t), t); + eq(util.cidr_any(s), old_any(s), s); + eq(util.cidr_any(t), old_any(t), t); + } +}); + test('cloudflare_ip', () => { ok(util.cloudflare_ip('104.16.1.1'), 'v4 range'); ok(util.cloudflare_ip('2606:4700::1'), 'v6 range'); @@ -140,3 +244,45 @@ test('text: ulength, ucut, translit, host_label, tunnel_name', () => { eq(util.host_label('!!!'), 'device', 'nothing left'); eq(length(util.host_label(replace(sprintf('%50s', ''), ' ', 'x'))), 40, 'cut at 40'); }); + +test('host_label, tunnel_name, slugify: dashes trimmed without a regex', () => { + // What they were with the dash patterns and the device-name regex, on names + // changed at each character (names come from uci, which holds no NUL byte). + let old_label = (s) => { + let l = replace(lc(util.translit(`${s ?? ''}`)), /[^a-z0-9]+/g, '-'); + l = replace(substr(replace(l, /^-+|-+$/g, ''), 0, 40), /-+$/g, ''); + return l || 'device'; + }; + let old_tunnel = (s) => { + let l = replace(util.translit(`${s ?? ''}`), /[^A-Za-z0-9]+/g, '-'); + l = replace(substr(replace(l, /^-+|-+$/g, ''), 0, 15), /-+$/g, ''); + return l && !match(l, /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i) ? l : 'dawnline'; + }; + let old_slug = (s) => { + let out = lc(util.translit(trim(`${s ?? ''}`))); + out = replace(out, /[^a-z0-9]+/g, '-'); + out = replace(out, /^-+|-+$/g, ''); + return substr(out, 0, 32) || 'user'; + }; + let same = (s) => { + eq(util.host_label(s), old_label(s), s); + eq(util.tunnel_name(s), old_tunnel(s), s); + eq(util.slugify(s), old_slug(s), s); + }; + let long = replace(sprintf('%13s', ''), ' ', 'x'); + for (let n in [ 'Outline Home', '--a--b--', ' (My VPN)! ', 'Дом у моря', `${long}-yz`, `${long}y-z`, + `${long}${long}${long}-ab`, `${replace(sprintf('%31s', ''), ' ', 'q')}--r`, '-', '' ]) + for (let i = 0; i <= length(n); i++) + for (let c in [ 'a', 'Z', '0', '-', ' ', '!', '.', '_', 'Ж', '\n', '' ]) { + same(`${substr(n, 0, i)}${c}${substr(n, i + 1)}`); + same(`${substr(n, 0, i)}${c}${substr(n, i)}`); + } + // Windows device names in any case, and their neighbours. + for (let b in [ 'con', 'prn', 'aux', 'nul', 'com', 'lpt', 'co', 'conx' ]) + for (let d in [ '', '0', '1', '5', '9', 'x', '10', '-1', ' 2' ]) { + same(`${b}${d}`); + same(uc(`${b}${d}`)); + same(`${uc(substr(b, 0, 1))}${substr(b, 1)}${d}`); + } + same(null); +}); diff --git a/web/package-lock.json b/web/package-lock.json index bd07199..58960b8 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "dawnline-web", - "version": "0.12.1", + "version": "0.13.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dawnline-web", - "version": "0.12.1", + "version": "0.13.0", "license": "MIT", "dependencies": { "qrcode-generator": "1.4.4" diff --git a/web/package.json b/web/package.json index e302ca7..5f76063 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "dawnline-web", - "version": "0.12.1", + "version": "0.13.0", "private": true, "license": "MIT", "type": "module", diff --git a/web/src/admin/access.ts b/web/src/admin/access.ts index 6350732..6435ff0 100644 --- a/web/src/admin/access.ts +++ b/web/src/admin/access.ts @@ -196,22 +196,28 @@ export function homeServices(initial: Status, serverId: string, reload: () => Pr const wait = busy.has(h.address); const chip = (label: string, on: boolean, click: () => void) => chipToggle(label, on, click, { disabled: wait ? 'disabled' : null, 'aria-busy': wait ? 'true' : null }); - return E('div', { class: 'dl-row' }, [ + // The name and the ports share a wrapping line: the ports go under the name before it is squeezed. + return E('div', { class: 'dl-row dl-host' }, [ icon(h.services.some((s) => s.type.startsWith('_ipp') || s.type.startsWith('_printer')) ? 'file' : 'computer'), - E('span', { class: 'dl-row-main dl-stack' }, [E('b', {}, h.name || h.address), E('span', { class: 'dl-mono dl-faint' }, h.address)]), - E('div', { class: 'dl-chips-row dl-host-ports' }, [ - chip(_('All ports'), all, () => choose(h, all ? null : [])), - ...portGroups(h).map(([label, ports]) => { - const on = !all && ports.every((p) => chosen.has(p)); - return chip(`${label} ${ports.join(', ')}`, on, () => { - const next = new Set(all ? [] : chosen); - for (const p of ports) { - if (on) next.delete(p); - else next.add(p); - } - choose(h, next.size ? [...next] : null); - }); - }), + E('div', { class: 'dl-host-body' }, [ + E('span', { class: 'dl-row-main dl-stack' }, [ + E('b', {}, h.name || h.address), + E('span', { class: 'dl-mono dl-faint' }, h.address), + ]), + E('div', { class: 'dl-chips-row' }, [ + chip(_('All ports'), all, () => choose(h, all ? null : [])), + ...portGroups(h).map(([label, ports]) => { + const on = !all && ports.every((p) => chosen.has(p)); + return chip(`${label} ${ports.join(', ')}`, on, () => { + const next = new Set(all ? [] : chosen); + for (const p of ports) { + if (on) next.delete(p); + else next.add(p); + } + choose(h, next.size ? [...next] : null); + }); + }), + ]), ]), ]); } diff --git a/web/src/admin/device.ts b/web/src/admin/device.ts index a6719e6..184e3ff 100644 --- a/web/src/admin/device.ts +++ b/web/src/admin/device.ts @@ -11,7 +11,7 @@ import { copyText, downloadFile } from './ui/files'; import { dropdown, type MenuItem } from './ui/menu'; import { drawer } from './ui/drawer'; import { attempt, notify } from './ui/toast'; -import { liveField } from './ui/layout'; +import { liveField, warnNote } from './ui/layout'; import { qrCode } from './ui/qr'; import { nameHelp } from './netcheck'; import { deviceStatus } from './ui/badges'; @@ -331,16 +331,11 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { // Whether it is connected (or still waiting) is in Status above. E('div', { class: 'dl-dsec-head' }, [E('h4', {}, _('Connect', 'section'))]), d.config_stale - ? E('div', { class: 'dl-note warn' }, [ - icon('alert'), - E( - 'span', - {}, - _( - 'This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.', - ), + ? warnNote( + _( + 'This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.', ), - ]) + ) : '', connect, ]); diff --git a/web/src/admin/events/log-templates.ts b/web/src/admin/events/log-templates.ts index ac88d5f..4ebb166 100644 --- a/web/src/admin/events/log-templates.ts +++ b/web/src/admin/events/log-templates.ts @@ -48,6 +48,7 @@ export const LOG_TEMPLATES: string[] = [ 'The new version did not answer in LuCI or its agent did not start. Try again from Components, or install it with install.sh to see why.', 'Traffic', 'Watchdog', + 'Without kmod-nft-offload every packet on this path passes the firewall twice. Install it and restart Dawnline.', 'a new build needs a manual switch in Components', 'answers again', 'are loaded again', @@ -101,6 +102,7 @@ export const LOG_TEMPLATES: string[] = [ "rules for Dawnline aren't loaded", 'rules for Dawnline were changed or removed', 'runs again', + 'runs without its fast path', 'setting it up again', 'started', 'started with the router · version %s', diff --git a/web/src/admin/interfaces.ts b/web/src/admin/interfaces.ts index 18e8127..c5e764b 100644 --- a/web/src/admin/interfaces.ts +++ b/web/src/admin/interfaces.ts @@ -9,6 +9,7 @@ import { button } from './ui/button'; import { attempt, notify } from './ui/toast'; import { seg, sw } from './ui/controls'; import { attachTip } from './ui/tooltip'; +import { warnNote } from './ui/layout'; import { installMissing } from './pkgs'; import { icon } from '../shared/icons'; import { fill, fmt, locale, plural } from '../shared/i18n'; @@ -31,6 +32,40 @@ const ICON: Record = { other: 'link', }; +/** + * "Internet like a home device" off: traffic leaves past the router's own + * proxies and filters, while DNS still goes through the router, which may + * answer with addresses only those proxies serve. Said wherever it is chosen. + */ +export function likeHomeOffText(ifname: string): (Node | string)[] { + // The step to take, in bold. + const add = E('b', {}, fill(_('add its interface %s to their source interfaces yourself'), E('span', { class: 'dl-mono' }, ifname))); + return [ + ...fill( + _( + 'Off: internet traffic goes straight to the WAN, the fastest way. DNS still goes through this router. Proxies and filters here handle the tunnel only if you %s.', + ), + add, + ), + ' ', + // What breaks, not only what is missed: the one part to notice. + E('span', { class: 'dl-warn' }, _('If the router’s DNS hands out proxy addresses, those sites won’t open without it.')), + ]; +} + +/** + * What "like a home device" costs: every packet crosses the router twice + * (through the netns and back over the LAN bridge). Measured on a dual-core + * MT7981: about 225 Mbit/s down without it, 160 with it, the CPU full either way. + */ +export function likeHomeCost(): HTMLElement { + return warnNote( + _( + 'Slower: every packet crosses the router twice. On a dual-core router expect up to a third less speed, and lost packets at full load.', + ), + ); +} + /** Server → Access cards; `update` takes a new status without touching the draft. */ export interface AccessCards { el: HTMLElement; @@ -170,7 +205,7 @@ export function accessCards(srv: Server, first: Status, refresh: () => Promise Promise rangeHelp(state.range, d.networks ?? [], rangeOf(d.subnet)); const portalHelpNow = () => portalPortHelp(state.portal_port, d.tcp_taken ?? [], ipLinks()); @@ -662,6 +656,34 @@ export class ServerPage { return el; }; + /** "Internet like a home device": the help follows the switch; on, the cost shows under it. */ + const likeHomeGroup = (): HTMLElement => { + const cost = likeHomeCost(); + const likeRow = row( + _('Through the home network'), + sw(state.lan_like, _('Internet like a home device'), (v) => { + state.lan_like = v; + paintLike(); + }), + ' ', + ); + const paintLike = () => { + dom.content( + likeRow.querySelector('.dl-sub') as HTMLElement, + state.lan_like + ? _( + 'Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.', + ) + : likeHomeOffText(d.ifname), + ); + if (state.lan_like) likeRow.after(cost); + else cost.remove(); + }; + const g = group('home', _('Internet like a home device'), _('How devices reach the internet'), [likeRow]); + paintLike(); + return g; + }; + type Page = { id: string; title: string; render: () => Node; check?: () => string | null }; const serverPage: Page = { id: 'server', @@ -733,6 +755,8 @@ export class ServerPage { group('shield', _('Disguise'), _('So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard'), [ methodPicker(d.awg, state.preset, (m) => (state.preset = m), undefined, d.awg_state?.tools !== false), ]), + // One more server has no portal step: the choice comes last here, as it does there. + extra ? likeHomeGroup() : '', ]), check: () => { const p = portHelpNow(); @@ -764,15 +788,7 @@ export class ServerPage { }, ); return E('div', { class: 'dl-wizard-groups' }, [ - group('home', _('Internet like a home device'), _('How devices reach the internet'), [ - row( - _('Through the home network'), - sw(state.lan_like, _('Internet like a home device'), (v) => (state.lan_like = v)), - _( - 'Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.', - ), - ), - ]), + likeHomeGroup(), group('link', _('Personal portal'), _('A page where each person adds their own devices with their personal link'), [ row(_('Portal'), onOff, _('Off: only you add devices, from LuCI. On: people manage their devices within the limits you set.')), portRow, diff --git a/web/src/admin/pages/settings/logs.ts b/web/src/admin/pages/settings/logs.ts index fd3f85a..4db9662 100644 --- a/web/src/admin/pages/settings/logs.ts +++ b/web/src/admin/pages/settings/logs.ts @@ -4,7 +4,7 @@ import { E } from '../../e'; import { api } from '../../api'; import { button } from '../../ui/button'; import { attempt } from '../../ui/toast'; -import { chipToggle, seg, setChip } from '../../ui/controls'; +import { multiSelect, select } from '../../ui/controls'; import { row } from '../../ui/layout'; import { icon } from '../../../shared/icons'; import { fmtDay, kb } from '../../../shared/format'; @@ -16,7 +16,7 @@ import { section, type SettingsHost } from './common'; export function logsCard(host: SettingsHost): HTMLElement { const L = host.d.logs; const p = L.policy; - const keep = seg( + const keep = select( [ ['7', plural(7, '%s day', '%s days')], ['30', plural(30, '%s day', '%s days')], @@ -25,9 +25,9 @@ export function logsCard(host: SettingsHost): HTMLElement { ['0', _('No limit', 'retention')], ], String(p.keep_days), - { label: _('Keep activity'), cls: 'sm' }, + _('Keep activity'), ); - const size = seg( + const size = select( [ ['500', num(500)], ['2000', num(2000)], @@ -35,18 +35,18 @@ export function logsCard(host: SettingsHost): HTMLElement { ['20000', num(20000)], ], String(p.max), - { label: _('Maximum events'), cls: 'sm' }, + _('Maximum events'), ); - const persist = seg( + const persist = select( [ ['10min', _('Every 10 min')], ['hourly', _('Hourly')], ['off', _('Memory only')], ], p.persist, - { label: _('Save to flash'), cls: 'sm' }, + _('Save to flash'), ); - const days = seg( + const days = select( [ ['31', plural(1, '%s month', '%s months')], ['62', plural(2, '%s month', '%s months')], @@ -55,9 +55,9 @@ export function logsCard(host: SettingsHost): HTMLElement { ['730', plural(2, '%s year', '%s years')], ], String(p.usage_days), - { label: _('Daily traffic'), cls: 'sm' }, + _('Daily traffic'), ); - const months = seg( + const months = select( [ ['12', plural(1, '%s year', '%s years')], ['24', plural(2, '%s year', '%s years')], @@ -65,24 +65,19 @@ export function logsCard(host: SettingsHost): HTMLElement { ['120', plural(10, '%s year', '%s years')], ], String(p.usage_months), - { label: _('Monthly traffic'), cls: 'sm' }, + _('Monthly traffic'), ); - const chosen = new Set(p.categories); - const cats = E( - 'div', - { class: 'dl-chips-row' }, - CATEGORIES.map((c) => { - const b = chipToggle( - [categoryLabel(c), E('b', {}, num(L.by_category[c] ?? 0))], - chosen.has(c), - () => { - if (!chosen.delete(c)) chosen.add(c); - setChip(b, chosen.has(c)); - }, - { title: categoryHelp(c) }, - ); - return b; - }), + const cats = multiSelect( + CATEGORIES.map((c): [string, Node] => [ + c, + E('span', { title: categoryHelp(c) }, [ + categoryLabel(c), + ' ', + E('span', { class: 'dl-faint dl-opt-note' }, num(L.by_category[c] ?? 0)), + ]), + ]), + p.categories, + _('Record'), ); const since = L.oldest ? fmtDay(new Date(L.oldest * 1000)) : ''; @@ -110,7 +105,7 @@ export function logsCard(host: SettingsHost): HTMLElement { E('p', { class: 'dl-muted' }, retentionText(p)), row(_('Keep activity'), keep, _('Older events are removed automatically.')), row(_('Maximum size'), size, _('Newest events are kept when the log is full.')), - row(_('Record'), cats, _('Switched-off categories are not logged from now on.')), + row(_('Record'), cats.node, _('Switched-off categories are not logged from now on.')), row( _('Save to flash'), persist, @@ -172,12 +167,12 @@ export function logsCard(host: SettingsHost): HTMLElement { () => host.save( { - log_keep_days: keep.dataset.value!, - log_max: size.dataset.value!, - log_persist: persist.dataset.value!, - usage_keep_days: days.dataset.value!, - usage_keep_months: months.dataset.value!, - log_category: [...chosen], + log_keep_days: keep.value, + log_max: size.value, + log_persist: persist.value, + usage_keep_days: days.value, + usage_keep_months: months.value, + log_category: cats.value(), }, _('Saved'), 'logs', diff --git a/web/src/admin/pages/settings/updates.ts b/web/src/admin/pages/settings/updates.ts index ce7be15..2de3ce7 100644 --- a/web/src/admin/pages/settings/updates.ts +++ b/web/src/admin/pages/settings/updates.ts @@ -4,14 +4,14 @@ import type { UpdatePolicy } from '../../api'; import { E } from '../../e'; import { button } from '../../ui/button'; -import { chipToggle, input, isOn, seg, setChip, sw } from '../../ui/controls'; +import { input, isOn, multiSelect, select, sw } from '../../ui/controls'; import { row } from '../../ui/layout'; import { notify } from '../../ui/toast'; import { timeHelp } from '../../netcheck'; import { fmt } from '../../../shared/i18n'; import { section, type SettingsHost } from './common'; -/** The components automatic updates may install: id and chip label. */ +/** The components automatic updates may install: id and label. */ const targetChoices = (): [string, string][] => [ ['app', 'Dawnline'], ['amneziawg', 'AmneziaWG'], @@ -21,7 +21,7 @@ const targetChoices = (): [string, string][] => [ export function updatesCard(host: SettingsHost): HTMLElement { const u = (host.d.effective as Record).updates as UpdatePolicy; const check = sw(u.check, _('Check automatically'), (v) => show(v, isOn(auto))); - const every = seg( + const every = select( [ ['6h', _('Every 6 h')], ['12h', _('Every 12 h')], @@ -29,7 +29,7 @@ export function updatesCard(host: SettingsHost): HTMLElement { ['7d', _('Weekly')], ], u.interval, - { label: _('How often'), cls: 'sm' }, + _('How often'), ); const auto = sw(u.auto, _('Install automatically'), (v) => show(isOn(check), v)); const at = input(u.time, { @@ -38,27 +38,17 @@ export function updatesCard(host: SettingsHost): HTMLElement { class: 'cbi-input-text dl-w-port dl-mono', 'aria-label': _('Time'), }); - const mode = seg( + const mode = select( [ ['scheduled', _('At a set time')], ['immediate', _('As soon as found')], ], u.mode, - { label: _('When'), cls: 'sm', onChange: (v) => (at.hidden = v !== 'scheduled') }, + _('When'), + (v) => (at.hidden = v !== 'scheduled'), ); at.hidden = u.mode !== 'scheduled'; - const chosen = new Set(u.targets); - const targets = E( - 'div', - { class: 'dl-chips-row' }, - targetChoices().map(([k, t]) => { - const b = chipToggle(t, chosen.has(k), () => { - if (!chosen.delete(k)) chosen.add(k); - setChip(b, chosen.has(k)); - }); - return b; - }), - ); + const targets = multiSelect(targetChoices(), u.targets, _('Components')); const keep = sw(u.keep, _('Keep the previous version')); const mirrors = sw(u.mirrors, _('GitHub mirrors')); const everyRow = row(_('How often'), every); @@ -68,7 +58,7 @@ export function updatesCard(host: SettingsHost): HTMLElement { E('div', { class: 'dl-hostport' }, [mode, at]), _('A set time keeps tunnel restarts out of the evening; the run happens within an hour of it.'), ), - row(_('Components'), targets, _('AmneziaWG is off by default: a new kernel module restarts every tunnel.')), + row(_('Components'), targets.node, _('AmneziaWG is off by default: a new kernel module restarts every tunnel.')), ]; const show = (c: boolean, a: boolean) => { everyRow.hidden = !c; @@ -104,7 +94,7 @@ export function updatesCard(host: SettingsHost): HTMLElement { button( _('Save'), () => { - if (mode.dataset.value === 'scheduled') { + if (mode.value === 'scheduled') { const h = timeHelp(at.value); if (h.bad) { notify(fmt(_('Time: %s'), h.text), 'warning'); @@ -114,11 +104,11 @@ export function updatesCard(host: SettingsHost): HTMLElement { return host.save( { update_check: isOn(check) ? '1' : '0', - update_interval: every.dataset.value!, + update_interval: every.value, update_auto: isOn(auto) ? '1' : '0', - update_mode: mode.dataset.value!, + update_mode: mode.value, update_time: at.value.trim(), - update_targets: [...chosen], + update_targets: targets.value(), update_keep: isOn(keep) ? '1' : '0', update_mirrors: isOn(mirrors) ? '1' : '0', }, diff --git a/web/src/admin/styles/access.css b/web/src/admin/styles/access.css index 12d1b4e..2cc6d68 100644 --- a/web/src/admin/styles/access.css +++ b/web/src/admin/styles/access.css @@ -2,7 +2,8 @@ /* Server → Access: networks as chips, circles, services from home, who reaches what, check access. */ .dl-chip.static { cursor: default; } .dl-chip.static:hover { background: var(--dl-soft); } .dl-chip.static .dl-chip-name { font-weight: 500; } -.dl-setrow.head .dl-chips-row { margin-top: 8px; } +.dl-setrow.head .dl-chips-row, .dl-setrow.head .dl-note { margin-top: 8px; } +.dl-setrow.head .dl-note { margin-bottom: 0; } .dl-setrow.head > .dl-lh-main, .dl-setrow.head > .dl-lh-main > .dl-stack { flex: 1 1 auto; min-width: 0; } .dl-setrow.head > .dl-setrow-ctl:empty { display: none; } .dl-setrow.head:has(> .dl-lh-main) { align-items: flex-start; } @@ -12,8 +13,12 @@ .dl-boxrow > .dl-switch { flex: none; } .dl-ifpick { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--dl-line); border-radius: 14px; } .dl-iflead-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; } -.dl-host-ports { justify-content: flex-end; } -@media (max-width: 760px) { .dl-host-ports { justify-content: flex-start; } } +/* A device at home: the name keeps at least 160px; past that the ports wrap under it, lined up with it, + and on one line the name's growth pushes them to the right. The icon sits centred on name and address (20 + 2 + 20px). */ +.dl-host { align-items: flex-start; } +.dl-host > .dl-icon-wrap { margin-top: 13px; } +.dl-host-body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; } +.dl-host-body > .dl-row-main { flex: 1 1 160px; } .dl-circle-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; } .dl-circles .dl-chip b { font-weight: 500; } .dl-circle-name { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; } diff --git a/web/src/admin/styles/base.css b/web/src/admin/styles/base.css index 9f3de1d..1adc287 100644 --- a/web/src/admin/styles/base.css +++ b/web/src/admin/styles/base.css @@ -1,33 +1,45 @@ /* Tokens (Outline first, LuCI Bootstrap next, a fallback that works anywhere), pills, cards, activity rows. */ :root { - /* Outline's tokens first, then LuCI Bootstrap's, then something that works anywhere. */ + /* Outline's tokens first, then LuCI Bootstrap's, then Outline's own values (light here, dark below). + Washes mix the theme's text colour, not currentColor: on muted text (icon tiles) currentColor fades them out. */ --dl-card: var(--panel-bg, var(--background-color-high, transparent)); --dl-elevated: var(--elevated, var(--background-color-high, Canvas)); --dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent))); - --dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent)); - --dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent)); - --dl-fg: var(--foreground, var(--text-color-highest, inherit)); + --dl-fg: var(--foreground, var(--text-color-highest, currentColor)); + --dl-soft: var(--muted, color-mix(in srgb, var(--dl-fg) 5%, transparent)); + --dl-soft-hover: var(--soft-hover, color-mix(in srgb, var(--dl-fg) 10%, transparent)); --dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent)); --dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent)); --dl-accent: var(--accent, #3a83f7); --dl-ok: var(--success, #00a240); --dl-warn: var(--warning, #e25507); --dl-bad: var(--danger, #e02e2a); - --dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent)); - --dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent)); - --dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent)); - --dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent)); --dl-info: var(--info, #2c67c5); - --dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent)); + --dl-ok-wash: var(--success-a15, color-mix(in srgb, var(--dl-ok) 15%, transparent)); + --dl-warn-wash: var(--warning-a15, color-mix(in srgb, var(--dl-warn) 15%, transparent)); + --dl-bad-wash: var(--destructive-a15, color-mix(in srgb, var(--dl-bad) 15%, transparent)); + --dl-info-wash: var(--info-a15, color-mix(in srgb, var(--dl-info) 15%, transparent)); + --dl-track: var(--foreground-a10, color-mix(in srgb, var(--dl-fg) 10%, transparent)); --dl-chart-1: var(--chart-blue, #3a83f7); - --dl-chart-2: var(--chart-green, #00a240); + --dl-chart-2: var(--chart-green, var(--dl-ok)); --dl-ring: var(--ring, #3a83f7); - --dl-primary: var(--primary, #0d0d0d); - --dl-primary-fg: var(--primary-foreground, #fff); + --dl-primary: var(--primary, var(--dl-fg)); + --dl-primary-fg: var(--primary-foreground, var(--dl-elevated)); --dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); --dl-shadow: var(--shadow-sm, none); --dl-radius: 16px; } +/* Bootstrap's page is its --background-color-high: in dark mode cards and popovers sit one step lighter, as on Outline. */ +:root[data-darkmode="true"] { + --dl-card: var(--panel-bg, var(--background-color-low, transparent)); + --dl-elevated: var(--elevated, var(--background-color-low, Canvas)); + --dl-accent: var(--accent, #006efe); + --dl-ok: var(--success, #40c977); + --dl-warn: var(--warning, #ff8549); + --dl-bad: var(--danger, #ff6764); + --dl-info: var(--info, #5ba2fe); + --dl-ring: var(--ring, #5ba2febc); +} /* Text is read, not edited: the arrow over it, the I-beam only where you type. */ .dl-root, .dl-modal { cursor: default; } diff --git a/web/src/admin/styles/controls.css b/web/src/admin/styles/controls.css index 1793b3f..4f3700b 100644 --- a/web/src/admin/styles/controls.css +++ b/web/src/admin/styles/controls.css @@ -59,6 +59,8 @@ .dl-w-ip { width: 160px; } .dl-dnspick { padding-top: 8px; border-top: 1px solid var(--dl-line); } .dl-dnspick .dl-row-actions { gap: 10px; } +/* A note on a LuCI dropdown's option (a count): in the open list only, not in the closed box. */ +.cbi-dropdown > ul:not(.dropdown) .dl-opt-note { display: none; } .dl-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 18px; margin: 0 0 10px; background: var(--dl-soft); } .dl-note.warn { background: var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent)); } .dl-note .dl-icon { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; color: var(--dl-warn); } diff --git a/web/src/admin/styles/index.ts b/web/src/admin/styles/index.ts index 9208a35..58b2b8a 100644 --- a/web/src/admin/styles/index.ts +++ b/web/src/admin/styles/index.ts @@ -2,7 +2,8 @@ // (luci-theme-outline: --panel-bg, --border, --muted, --accent, --success-a15, // …). Every token has a fallback so other themes still get a sane look. // Outline switches dark mode with html[data-darkmode], and its tokens follow -// it automatically, so nothing here needs a dark variant. +// it automatically; only the fallbacks in base.css have a dark variant (LuCI +// Bootstrap sets the same attribute). // // One file per feature, imported as text (tsup minifies them, see // tsup.config.ts) and joined in cascade order: later files override earlier ones. diff --git a/web/src/admin/styles/settings.css b/web/src/admin/styles/settings.css index e1cfebe..3e96b7d 100644 --- a/web/src/admin/styles/settings.css +++ b/web/src/admin/styles/settings.css @@ -13,12 +13,14 @@ .dl-group-ic { width: 32px; height: 32px; border-radius: 10px; background: var(--dl-soft); color: var(--dl-fg-muted); display: inline-flex; align-items: center; justify-content: center; flex: none; } .dl-group-ic .dl-icon-wrap { display: inline-flex; } .dl-group-ic .dl-icon { width: 16px; height: 16px; } .dl-group-body > * { padding: 12px 0; margin: 0 !important; } -.dl-group-body > * + *:not(.alert-message):not(.dl-params) { border-top: 1px solid var(--dl-line); } +.dl-group-body > * + *:not(.alert-message):not(.dl-params):not(.dl-note) { border-top: 1px solid var(--dl-line); } /* Boxed pieces (a notice, a parameters panel) keep their own padding and frame: spaced, not ruled. */ .dl-group-body > .alert-message, .dl-group-body > .dl-params { margin: 12px 0 !important; } .dl-group-body > .alert-message { padding: 10px 14px; } .dl-group-body > .dl-params { padding: 0; } -.dl-group-body > .alert-message + *, .dl-group-body > .dl-params + * { border-top: 0; } +/* A warning note belongs to the row above it: no gap before, room to the group's edge after. */ +.dl-group-body > .dl-note { margin: 0 0 14px !important; padding: 10px 12px; } +.dl-group-body > .alert-message + *, .dl-group-body > .dl-params + *, .dl-group-body > .dl-note + * { border-top: 0; } .dl-group-body > .dl-row { border-left: 0; border-right: 0; border-bottom: 0; padding-left: 0; padding-right: 0; background: none; } .dl-group-body > .dl-row:first-child { border-top: 0; } .dl-setsec-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 20px; border-top: 1px solid var(--dl-line); background: var(--dl-soft); } diff --git a/web/src/admin/ui/controls.ts b/web/src/admin/ui/controls.ts index 0128076..3dd1662 100644 --- a/web/src/admin/ui/controls.ts +++ b/web/src/admin/ui/controls.ts @@ -1,5 +1,5 @@ // Form controls in the house style: a switch, a segmented control, a chip -// toggle and a text input. +// toggle and a text input; LuCI's own select and multi-select for settings. import { E } from '../e'; @@ -113,6 +113,35 @@ export function setChip(b: HTMLElement, on: boolean) { b.setAttribute('aria-pressed', on ? 'true' : 'false'); } +/** + * Single choice as LuCI's select (a ListValue's widget); the choice is `.value`. + * Unknown values get an option of their own, so nothing is lost on save. + */ +export function select(options: [T, string][], value: T, label: string, onChange?: (v: T) => void): HTMLSelectElement { + if (!options.some(([v]) => v === value)) options = [...options, [value, value]]; + return E( + 'select', + { class: 'cbi-input-select', 'aria-label': label, change: (ev: Event) => onChange?.((ev.target as HTMLSelectElement).value as T) }, + options.map(([v, t]) => E('option', { value: v, selected: v === value ? 'selected' : null }, t)), + ) as HTMLSelectElement; +} + +/** Several choices as LuCI's multi-select dropdown (a MultiValue's widget): `node` to show, `value()` to save. */ +export function multiSelect( + options: [string, Node | string][], + values: string[], + label: string, +): { node: HTMLElement; value: () => string[] } { + const w = new ui.Dropdown(values, Object.fromEntries(options), { + multiple: true, + sort: options.map(([v]) => v), + select_placeholder: _('None'), + }); + const node = w.render() as HTMLElement; + node.setAttribute('aria-label', label); + return { node, value: () => w.getValue() as string[] }; +} + export function input(value: string, attrs: Record = {}): HTMLInputElement { return E('input', { type: 'text', class: 'cbi-input-text', value, ...attrs }) as HTMLInputElement; } diff --git a/web/src/admin/ui/layout.ts b/web/src/admin/ui/layout.ts index 58cde04..c1d0e4d 100644 --- a/web/src/admin/ui/layout.ts +++ b/web/src/admin/ui/layout.ts @@ -1,12 +1,12 @@ // Layout pieces: a labelled setting row, a settings card, a titled group, a -// "missing package" row, LuCI's callout and an SVG holder. +// "missing package" row, a warning note, LuCI's callout and an SVG holder. import type { Child } from '../luci.d'; import { E } from '../e'; import { icon } from '../../shared/icons'; /** Label and help on the left, the control on the right. */ -export function row(label: string, control: Node, help?: string): HTMLElement { +export function row(label: string, control: Node, help?: Child): HTMLElement { return E('div', { class: 'dl-setrow' }, [ E('div', { class: 'dl-stack' }, [E('span', { class: 'dl-setrow-label' }, label), help ? E('span', { class: 'dl-sub' }, help) : '']), E('div', { class: 'dl-setrow-ctl' }, control), @@ -117,6 +117,11 @@ export function needRow(ic: string, tone: '' | 'bad' | 'warn', title: string, su ]); } +/** A warning beside the choice it is about: alert icon and text on an orange wash. */ +export function warnNote(text: Child): HTMLElement { + return E('div', { class: 'dl-note warn' }, [icon('alert'), E('span', {}, text)]); +} + export function callout(tone: 'ok' | 'warn' | 'error' | 'info', children: Child): HTMLElement { const cls = { ok: 'success', warn: 'warning', error: 'error', info: 'notice' }[tone]; return E('div', { class: `alert-message ${cls}` }, children);